/* ============================================================
   Pharma — system designu
   Inspiracja: dashboard w stylu "eco system" — ciemny pasek
   nawigacji, jasne tło typu sage, białe zaokrąglone karty,
   limonkowy akcent. Roboto + Roboto Condensed + Material Symbols.
   ============================================================ */

:root {
  --bg-gradient: linear-gradient(160deg, #e7ece2 0%, #f4f6f1 45%, #ffffff 100%);
  --sidebar-bg: #1b1c19;
  --sidebar-icon: #9a9f8f;
  --sidebar-icon-hover: #e7ece2;
  --accent: #a9d94c;
  --accent-dark: #8bbf34;
  --accent-soft: #eaf5d4;
  --card-bg: #ffffff;
  --text-primary: #1c1d19;
  --text-secondary: #767c6d;
  --text-muted: #9aa08f;
  --border-soft: #e7e9e2;
  --danger: #d64545;
  --danger-soft: #fbe7e7;
  --warning: #d99a2b;
  --warning-soft: #fbf1de;
  --success: #4f9c53;
  --success-soft: #e6f2e3;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 10px 30px rgba(28, 29, 25, 0.06);
  --shadow-soft: 0 4px 14px rgba(28, 29, 25, 0.05);
  --font-body: "Roboto", "Segoe UI", sans-serif;
  --font-heading: "Roboto Condensed", "Roboto", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-gradient);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  font-size: 22px;
  line-height: 1;
  vertical-align: middle;
}

/* ---------- Layout ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 234px 1fr;
  min-height: 100vh;
  padding: 18px;
  gap: 18px;
}

.sidebar {
  background: var(--sidebar-bg);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 20px 14px;
  color: var(--sidebar-icon);
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 2px;
  margin-bottom: 26px;
}

.sidebar .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--accent);
  color: #1c1d19;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar .brand-text {
  font-weight: 700;
  font-family: var(--font-heading);
  color: #fff;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar .nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-icon);
  opacity: 0.6;
  padding: 16px 10px 6px;
}

.sidebar .nav-section-label:first-child {
  padding-top: 2px;
}

.sidebar .nav-item {
  width: 100%;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 9px 10px;
  color: var(--sidebar-icon);
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar .nav-item .nav-label {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .nav-item:hover {
  color: var(--sidebar-icon-hover);
  background: rgba(255, 255, 255, 0.06);
}

/* Przycisk "Wyloguj" musi być formularzem POST (Django 5 wymaga POST dla logout),
   ale wizualnie ma wyglądać identycznie jak pozostałe pozycje nawigacji. */
button.nav-item {
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.sidebar .nav-item.active {
  background: var(--accent);
  color: #1c1d19;
}

.sidebar .nav-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .nav-bottom .avatar {
  align-self: center;
}

.sidebar .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar .eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.topbar h1 {
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 30px;
  margin: 0;
}

.topbar .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: var(--shadow-soft);
  font-size: 14px;
  color: var(--text-secondary);
}

.search-pill {
  min-width: 220px;
}
.search-pill input {
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  color: var(--text-primary);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 999px;
  padding: 6px 16px 6px 6px;
  box-shadow: var(--shadow-soft);
}
.user-chip .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #1c1d19;
}
.user-chip .role-badge {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
}

.card-flat {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-header h2, .card-header h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.grid {
  display: grid;
  gap: 18px;
}
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { width: 100%; }
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stat-card .icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card .value {
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 700;
}
.stat-card .label {
  color: var(--text-secondary);
  font-size: 13px;
}
.stat-card .trend {
  align-self: flex-start;
  font-size: 12px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 600;
}
.stat-card .trend.warn { background: var(--warning-soft); color: var(--warning); }
.stat-card .trend.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tables ---------- */

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data-table th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}
table.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #fafbf8; }

/* ---------- Badges / statusy ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.badge-active, .badge-aktywna, .badge-nowe { background: var(--success-soft); color: var(--success); }
.badge-active .badge-dot, .badge-aktywna .badge-dot, .badge-nowe .badge-dot { background: var(--success); }

.badge-zawieszona, .badge-w-realizacji, .badge-potwierdzone { background: var(--warning-soft); color: var(--warning); }
.badge-zawieszona .badge-dot, .badge-w-realizacji .badge-dot, .badge-potwierdzone .badge-dot { background: var(--warning); }

.badge-nieaktywna, .badge-anulowane { background: var(--danger-soft); color: var(--danger); }
.badge-nieaktywna .badge-dot, .badge-anulowane .badge-dot { background: var(--danger); }

.badge-wyslane, .badge-zrealizowane { background: #e4edfb; color: #3b6bc4; }
.badge-wyslane .badge-dot, .badge-zrealizowane .badge-dot { background: #3b6bc4; }

.badge-dark {
  background: var(--sidebar-bg);
  color: #fff;
}

/* Odznaka do informacji pomocniczych (np. cechy produktu) — ma nie przyciągać
   wzroku jak statusy/kategorie, tylko bardzo dyskretnie uzupełniać treść. */
.badge-subtle {
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  padding: 1px 7px;
  font-size: 10px;
  opacity: 0.75;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #1c1d19; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-dark { background: var(--sidebar-bg); color: #fff; }
.btn-outline { background: #fff; color: var(--text-primary); box-shadow: var(--shadow-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-field input,
.form-field select,
.form-field textarea {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  background: #fbfcfa;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent-dark);
}
.helptext { font-size: 12px; color: var(--text-muted); }
.errorlist { color: var(--danger); font-size: 12px; margin: 0; padding: 0; list-style: none; }

.form-section { margin-bottom: 22px; }
.form-section:not(:first-child) {
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.form-section-title {
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 14px 0;
}

.formset-row {
  display: grid;
  grid-template-columns: 3fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 10px;
}

/* ---------- Messages ---------- */

.messages { display: flex; flex-direction: column; gap: 10px; }
.message {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.message.success { background: var(--success-soft); color: var(--success); }
.message.info { background: #e4edfb; color: #3b6bc4; }
.message.warning { background: var(--warning-soft); color: var(--warning); }
.message.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Auth pages ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-gradient);
}
.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.auth-card .brand {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.auth-card h1 {
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: 24px;
  margin: 0 0 6px;
}
.auth-card p.subtitle { color: var(--text-secondary); font-size: 14px; margin: 0 0 24px; }

/* ---------- Credential reveal ---------- */

.credential-box {
  background: var(--sidebar-bg);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.credential-box .credential-item .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--sidebar-icon);
  letter-spacing: 0.05em;
}
.credential-box .credential-item .value {
  font-family: "Roboto Mono", monospace;
  font-size: 18px;
  font-weight: 700;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.empty-state .material-symbols-outlined { font-size: 40px; color: var(--text-muted); }

.text-muted { color: var(--text-secondary); font-size: 13px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.flex-gap { display: flex; align-items: center; gap: 10px; }

.tooltip-wrap {
  position: relative;
  display: inline-flex;
  cursor: help;
}
.tooltip-wrap::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  transform: translateX(-50%);
  background: var(--text-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  white-space: pre-line;
  text-align: left;
  padding: 7px 11px;
  border-radius: 8px;
  min-width: 180px;
  max-width: 260px;
  width: max-content;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s ease;
  z-index: 30;
  box-shadow: 0 6px 16px rgba(0,0,0,0.22);
}
.tooltip-wrap::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-primary);
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s ease;
  z-index: 30;
}
.tooltip-wrap:hover::after,
.tooltip-wrap:hover::before {
  opacity: 1;
  visibility: visible;
}

/* ---------- Miniatury zdjęć (produkty / grupy produktów) ---------- */

.thumb-sm {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-dark);
}

/* ---------- Status badges (apo, English status codes) ----------
   The badge class is built from the status value in the templates
   ({{ order.status|lower }}), so every status of Pharmacy and Order needs a
   matching rule here. Colours reuse the same tokens as the older rules above. */

.badge-new { background: var(--success-soft); color: var(--success); }
.badge-new .badge-dot { background: var(--success); }

.badge-confirmed, .badge-in_progress { background: var(--warning-soft); color: var(--warning); }
.badge-confirmed .badge-dot, .badge-in_progress .badge-dot { background: var(--warning); }

.badge-shipped, .badge-completed { background: #e4edfb; color: #3b6bc4; }
.badge-shipped .badge-dot, .badge-completed .badge-dot { background: #3b6bc4; }

.badge-cancelled, .badge-inactive { background: var(--danger-soft); color: var(--danger); }
.badge-cancelled .badge-dot, .badge-inactive .badge-dot { background: var(--danger); }
