/* eMedics – UI styles */

:root {
  /* Sidebar */
  --sidebar-bg:    #0f172a;
  --sidebar-w:     220px;
  --sidebar-w-sm:  52px;

  /* Page */
  --page-bg:       #f1f5f9;
  --card-bg:       #ffffff;
  --topstrip-bg:   #ffffff;

  /* Brand */
  --brand:         #0d6efd;
  --brand-dk:      #0a58ca;

  /* Text */
  --ink:           #0f172a;
  --muted:         #64748b;
  --line:          #e2e8f0;
  --bg:            #f8fafc;

  /* Semantic */
  --ok:            #0a6332;
  --warn:          #92400e;
  --err:           #b91c1c;

  /* Shadows */
  --shadow-card:   0 1px 3px rgba(0,0,0,.06), 0 1px 8px rgba(0,0,0,.04);
  --shadow-drawer: 4px 0 20px rgba(0,0,0,.25);

  /* Radius */
  --radius-card:   12px;
  --radius-btn:    8px;
  --radius-badge:  20px;
  --radius-input:  8px;

}

/* ── App Shell ───────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.logo-link {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 18px; font-weight: 800; color: #fff;
  text-decoration: none; letter-spacing: -.03em;
  display: block;
}
.logo-accent { color: #60a5fa; }
.sidebar-org {
  font-size: 11px; color: #475569; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-cta { padding: 12px 10px 6px; flex-shrink: 0; }
.btn-full { display: block; width: 100%; text-align: center; box-sizing: border-box; }

.sidebar-nav { padding: 4px 10px; flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 2px; }
.nav-group-label {
  font-size: 10px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: .08em;
  padding: 10px 6px 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  color: #94a3b8; text-decoration: none; font-size: 13px;
  margin-bottom: 1px; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
/* Buttons używają nav-link; UA stylesheet przeglądarki może nadpisać kolor —
   jawna reguła z wyższą specyficznością (tag+class) gwarantuje widoczność. */
button.nav-link { color: #94a3b8; font: inherit; }
button.nav-link:hover { color: #e2e8f0; }
/* Form-button rendered jako nav-link (np. POST /onboarding/powtorz/ —
   <a href> zwracał 405 bo view ma @require_POST). Reset UA defaults. */
.nav-link-button {
  width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
}
.nav-link.active {
  background: rgba(13,110,253,.18);
  color: #93c5fd; font-weight: 600;
}
.nav-link:focus-visible {
  outline: 2px solid #60a5fa; outline-offset: 2px;
}

.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 12px; font-weight: 600; color: #e2e8f0; }
.sidebar-user-role { font-size: 11px; color: #475569; margin-top: 1px; }
.sidebar-user-action {
  display: inline-block; margin-top: 4px;
  font-size: 11px; color: #60a5fa; text-decoration: none;
}
.sidebar-user-bottom {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
}
.sidebar-logout {
  background: none; border: none; padding: 0;
  font-size: 11px; color: #475569; cursor: pointer;
  text-decoration: none; font-family: inherit;
  /* Wymuszamy klikalność nawet gdy tour-overlay (z-index 9998) jest
   * aktywny — wylogowanie to fundamentalna funkcja UX, nie może być
   * blokowane przez welcome tour (Apka-ad4). */
  position: relative;
  z-index: 10001;
}
.sidebar-logout:hover { color: #94a3b8; }

/* ── Main content ────────────────────────────────── */
.main-content {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; background: var(--page-bg);
}
.topstrip {
  background: var(--topstrip-bg);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  padding: 10px 24px; display: flex; align-items: center;
  justify-content: space-between; flex-shrink: 0;
}
.topstrip-breadcrumb { font-size: 12px; color: var(--muted); }
.topstrip-right { display: flex; align-items: center; gap: 12px; }
.page-body { padding: 20px; flex: 1; }

.flash-container { padding: 12px 20px 0; }
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 500; margin-bottom: 8px;
  border: 1px solid transparent;
}
.flash.flash-success, .flash.success { background: #dcfce7; border-color: #bbf7d0; color: #15803d; }
.flash.flash-error,   .flash.error   { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }
.flash.flash-warning, .flash.warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.flash.flash-info,    .flash.info    { background: #dbeafe; border-color: #bfdbfe; color: #1d4ed8; }
.flash-close {
  margin-left: auto; background: none; border: none;
  cursor: pointer; font-size: 16px; color: inherit; opacity: .6; padding: 0;
}
.flash-close:hover { opacity: 1; }

/* ── Site footer ─────────────────────────────────── */
.site-footer {
  padding: 12px 20px; font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--line); margin-top: auto;
}
.legal { display: block; margin-top: 2px; }

/* ── Skip link ───────────────────────────────────── */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  padding: 8px 16px; background: var(--brand); color: #fff;
  font-weight: 600; border-radius: 0 0 6px 0; z-index: 9999;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ── Mobile topbar + drawer ──────────────────────── */
.mobile-topbar {
  display: none;
  background: var(--sidebar-bg);
  padding: 10px 16px;
  align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 200;
  flex-shrink: 0;
}
.logo-link-mobile {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 16px; font-weight: 800; color: #fff; text-decoration: none;
  letter-spacing: -.03em;
}
.hamburger {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px; flex-shrink: 0;
}
.hamburger span {
  display: block; width: 20px; height: 2px;
  background: #fff; border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg) translate(4px, 4px);
}
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg) translate(4px, -4px);
}
.drawer-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 150;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 767px) {
  .mobile-topbar { display: flex; }
  .app-shell { flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 160; height: 100vh;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-drawer);
  }
  .drawer-overlay.open { display: block; }
  .topstrip { display: none; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar { width: var(--sidebar-w-sm); overflow: hidden; }
  .sidebar-org, .nav-group-label, .sidebar-user-name,
  .sidebar-user-role, .sidebar-user-action,
  .sidebar-user-bottom, .sidebar-cta { display: none; }
  .nav-link { justify-content: center; padding: 10px; font-size: 16px; }
  .nav-link span:not(:first-child) { display: none; }
  .sidebar-logo { padding: 14px 8px; text-align: center; }
  .logo-link { font-size: 13px; }
}

@media print {
  .sidebar, .mobile-topbar, .topstrip, .drawer-overlay { display: none !important; }
  .app-shell { display: block; }
  .main-content { width: 100%; }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'IBM Plex Sans', system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page-bg);
  font-size: 16px;
  line-height: 1.5;
}

/* Typography */
h1 {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 22px; font-weight: 700; margin: 0 0 16px;
  letter-spacing: -.025em; line-height: 1.2;
}
h2 {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 17px; font-weight: 700; margin: 0 0 12px;
  letter-spacing: -.015em;
}
h3 { font-size: 11px; margin: 14px 0 4px; color: var(--muted);
     text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
  transition: box-shadow .2s, transform .2s;
}
a.card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
  transform: translateY(-2px);
  text-decoration: none;
}
.card.table-card { padding: 0; overflow: hidden; }

/* Grid */
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) {
  .grid.c3, .grid.c4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 840px) {
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
}

/* Forms */
.form-row { display: flex; flex-direction: column; margin-bottom: 12px; }
.form-row label {
  font-weight: 600; font-size: 13px; margin-bottom: 4px;
}
.field .hint, .form-row .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="date"], input[type="time"], input[type="number"], select, textarea {
  font-family: inherit; font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13,110,253,.15);
}
textarea { resize: vertical; min-height: 80px; }

/* ── Form fields ─────────────────────────────────── */
.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 12px; font-weight: 600;
  color: #475569; margin-bottom: 4px;
}
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  width: 100%; border: 1.5px solid var(--line);
  border-radius: var(--radius-input);
  padding: 8px 12px; font-size: 13px; color: var(--ink);
  background: #fff; box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13,110,253,.12);
}

.checkbox-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; }
.checkbox-list label { font-weight: 400; }

ul.errorlist { color: var(--err); font-size: 13px; padding-left: 18px; margin: 4px 0; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-btn);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s, transform .15s, box-shadow .15s;
  line-height: 1.4;
}
/* Primary (domyślny — niebieski) */
.btn:not(.ghost):not(.danger):not(.success) {
  background: var(--brand); color: #fff; border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(13,110,253,.25);
}
.btn:not(.ghost):not(.danger):not(.success):hover {
  background: var(--brand-dk); border-color: var(--brand-dk);
  box-shadow: 0 4px 14px rgba(13,110,253,.35);
  transform: translateY(-1px);
}
/* Ghost */
.btn.ghost {
  background: transparent; color: var(--ink); border-color: var(--line);
}
.btn.ghost:hover { background: var(--bg); border-color: #c9d4e0; }
/* Success */
.btn.success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.success:hover { background: #085228; border-color: #085228; }
/* Danger */
.btn.danger { background: #fee2e2; color: var(--err); border-color: #fecaca; }
.btn.danger:hover { background: #fecaca; }
/* Disabled */
.btn:disabled, .btn[aria-disabled="true"],
.btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
/* Sizes */
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.lg { padding: 11px 22px; font-size: 15px; }
/* Focus */
.btn:focus-visible {
  outline: 3px solid rgba(13,110,253,.35);
  outline-offset: 2px;
}

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ── Tables ──────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 16px; background: var(--bg);
  border-bottom: 1px solid var(--line);
  text-align: left; white-space: nowrap;
}
tbody td {
  padding: 11px 16px; font-size: 13px;
  color: var(--ink); vertical-align: middle;
}
tbody tr { border-bottom: 1px solid #f8fafc; transition: background .12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

/* Utility */
.small { color: var(--muted); font-size: 14px; }
a { color: var(--brand); }
.flashes { margin-bottom: 14px; }

/* ── Status badges ───────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-badge); font-size: 11px; font-weight: 600; }
.badge.ok { background: #ecfdf5; color: #065f46; }
.badge.err { background: #fef2f2; color: #991b1b; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.info { background: #e0f2fe; color: #075985; }
.badge.scheduled   { background: #dbeafe; color: #1d4ed8; }
.badge.arrived     { background: #fef3c7; color: #92400e; }
.badge.in_progress { background: #fce7f3; color: #9d174d; }
.badge.completed   { background: #dcfce7; color: #15803d; }
.badge.cancelled       { background: #f1f5f9; color: #64748b; }
.badge.pending_payment { background: #fefce8; color: #713f12; }
.badge.no_show         { background: #fee2e2; color: #991b1b; }

/* 2026-05-19 Apka-NEW UI discoverability — badge "nowe" w sidebar dla modułów
   których user nie odwiedził. Per-user dismiss zapisany w User.preferences. */
.badge.feature-new {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  margin-left: 6px;
  font-size: 10px;
  padding: 2px 7px;
  text-transform: lowercase;
  letter-spacing: 0.3px;
  animation: pulse-new 2s ease-in-out infinite;
}
@keyframes pulse-new {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

/* ── Dashboard stat cards ────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
}
.stat-card.accent {
  background: linear-gradient(135deg, var(--brand) 0%, #3b82f6 100%);
}
.stat-card .stat-label {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.stat-card.accent .stat-label { color: rgba(255,255,255,.7); }
.stat-card .stat-num {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 30px; font-weight: 800; color: var(--ink); line-height: 1;
  letter-spacing: -.02em;
}
.stat-card.accent .stat-num { color: #fff; }
.stat-card .stat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat-card.accent .stat-sub { color: rgba(255,255,255,.65); }
/* Legacy .stat aliases */
.stat {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
}
.stat .num { font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 30px; font-weight: 800; color: var(--brand); line-height: 1; letter-spacing: -.02em; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Login page — legacy classes kept for backward compat */
.login-card { display: none; }

/* Toolbar */
.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; margin-bottom: 18px;
}
.toolbar h1 { margin: 0; font-size: 24px; }

/* Filter bar (compact form in toolbar — date range, etc.) */
.filter-bar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin: 0;
}
.filter-bar .field { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.filter-bar label { font-size: 12px; color: var(--muted, #64748b); font-weight: 500; }
.filter-bar input[type="date"] {
  height: 38px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 14px;
}
.filter-bar .btn { height: 38px; align-self: flex-end; }

footer {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding: 16px 0;
  background: #fff;
}

/* Empty states */
.empty-row td { text-align: center; padding: 48px 20px !important; color: var(--muted); }
.empty-row .empty-icon { font-size: 36px; display: block; margin-bottom: 10px; }
.empty-row .empty-title { display: block; font-size: 15px; margin-bottom: 12px; }

/* Breadcrumb */
.breadcrumb {
  font-size: 13px; color: var(--muted);
  margin-bottom: 12px;
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); text-decoration: underline; }
.breadcrumb span[aria-current] { color: var(--ink); }

/* KBP – Karta Badania Profilaktycznego */
.kbp-form .kbp-page {
  margin-bottom: 24px; padding: 16px 20px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.kbp-form h2 { margin-top: 0; border-bottom: 2px solid var(--brand); padding-bottom: 6px; }
.kbp-form h3 { margin-top: 16px; }
.kbp-form table { width: 100%; margin: 8px 0; }
.kbp-form table.fs td, .kbp-form table.hist td, .kbp-form table.anamnesis td,
.kbp-form table.physexam td { padding: 4px 6px; vertical-align: middle; font-size: 13px; }
.kbp-form table.fs th { background: #f7f9fb; }
.kbp-form table input[type="text"], .kbp-form table input[type="date"],
.kbp-form table textarea { width: 100%; font-size: 13px; }
.kbp-form table input.wide { width: 100%; }
.kbp-form .chk { display: inline-flex; align-items: center; gap: 6px; margin: 4px 10px 4px 0; font-weight: 500; }
.kbp-form .chk input[type="checkbox"] { margin: 0; }

/* Apka-35w — 4-stanowe radio (palenie/alkohol/specjalista/leki).
   Django RadioSelect renderuje <ul><li><label><input>label text</label></li></ul>.
   Robimy poziomy układ z większymi click-targetami (lekarz pracuje szybko). */
ul.radio-inline-4 {
  list-style: none; padding: 0; margin: 4px 0 8px 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
ul.radio-inline-4 li { margin: 0; }
ul.radio-inline-4 label {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px;
  background: #f8fafc; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
ul.radio-inline-4 label:hover { background: #e2e8f0; border-color: #94a3b8; }
ul.radio-inline-4 input[type="radio"]:checked + * { color: #0369a1; }
ul.radio-inline-4 label:has(input[type="radio"]:checked) {
  background: #dbeafe; border-color: #3b82f6; color: #0c4a6e; font-weight: 600;
}
ul.radio-inline-4 input[type="radio"] { margin: 0; accent-color: #3b82f6; }

.kbp-form .field-radio-label {
  display: block; font-weight: 500; margin-bottom: 4px; font-size: 14px;
}
.kbp-form .subfield-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px;
}
.kbp-form .subfield-row .hint-label {
  font-size: 12px; color: #64748b; flex-basis: auto;
}
.kbp-form .subfield-row input[type="text"] { flex: 1; min-width: 100px; }

/* Anamneza pacjent — radio horyzontalne (palenie/alkohol) */
.radio-group-inline {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0;
}
.radio-group-inline .radio-opt {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #f8fafc; font-size: 15px; font-weight: 500; cursor: pointer;
  min-height: 44px; /* touch target */
}
.radio-group-inline .radio-opt:has(input[type="radio"]:checked) {
  background: #dbeafe; border-color: #3b82f6; color: #0c4a6e; font-weight: 600;
}
.radio-group-inline input[type="radio"] { margin: 0; accent-color: #3b82f6; }
.kbp-form .center { text-align: center; }
.kbp-form .orz-flags { display: flex; flex-direction: column; gap: 2px; }
.kbp-form kbd { background: #eee; padding: 2px 5px; border-radius: 3px; font-size: 11px; }

/* Styled file input */
.file-input-wrapper { position: relative; display: inline-block; }
.file-input-wrapper input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; width: 100%; height: 100%;
}
.file-input-label {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border: 1.5px dashed var(--line);
  border-radius: 6px; background: var(--bg);
  color: var(--muted); font-size: 14px; cursor: pointer; user-select: none;
}
.file-input-wrapper:hover .file-input-label,
.file-input-wrapper:focus-within .file-input-label {
  border-color: var(--brand); color: var(--brand);
}

/* Sort links (F3.3) */
.sort-link { color: var(--muted); text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--ink); }
.sort-link.asc::after { content: " ↑"; }
.sort-link.desc::after { content: " ↓"; }

/* Pagination (F3.1) */
.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 16px 0; flex-wrap: wrap; }
.pagination-info { font-size: 13px; color: var(--muted); }
.btn.disabled, .btn.sm.disabled { opacity: .45; pointer-events: none; cursor: default; }

/* Inline validation (F3.2) */
.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--err); }
.field-errors {
  color: var(--err); font-size: 12px; margin: 4px 0 0;
  padding-left: 0; list-style: none;
}


/* ── Lang switcher ───────────────────────────────── */
.langswitch { display: inline-flex; margin: 0; padding: 0; }
.langswitch select {
  background: transparent; border: 1px solid rgba(255,255,255,.15);
  color: #94a3b8; border-radius: 4px;
  padding: 3px 6px; font-size: 11px; cursor: pointer;
}
.langswitch select:focus { outline: none; border-color: #60a5fa; }
/* In topstrip (light background) */
.topstrip-right .langswitch select {
  border-color: var(--line); color: var(--muted); background: #fff;
}

/* Lang switcher on login-style pages (fixed top-right) */
.login-langswitch {
  position: fixed; top: 14px; right: 16px; z-index: 10;
}

/* ── Login page ──────────────────────────────────── */
.login-body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: #0f172a;
}

/* Split layout */
.lp-split {
  display: flex;
  min-height: 100vh;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
}

/* ── Hero (left) panel ── */
.lp-hero {
  flex: 1 1 50%;
  background: var(--sidebar-bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Ambient glows */
.lp-hero-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}
.lp-hero-glow--a {
  width: 460px; height: 460px;
  top: -80px; left: -100px;
  background: rgba(13,110,253,.18);
  animation: glow-drift 9s ease-in-out infinite alternate;
}
.lp-hero-glow--b {
  width: 320px; height: 320px;
  bottom: 60px; right: -80px;
  background: rgba(13,110,253,.10);
  animation: glow-drift 12s ease-in-out infinite alternate-reverse;
}
@keyframes glow-drift {
  from { transform: translate(0, 0); }
  to   { transform: translate(30px, 40px); }
}

/* Hero body content */
.lp-hero-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px 52px;
  position: relative;
  z-index: 1;
}

.lp-hero-logo {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-weight: 800;
  font-size: 42px;
  color: #f8fafc;
  letter-spacing: -1px;
  margin-bottom: 20px;
  line-height: 1;
}
.lp-hero-logo span { color: #0d6efd; }

.lp-hero-tagline {
  font-size: 22px;
  font-weight: 300;
  color: #cbd5e1;
  line-height: 1.45;
  margin: 0 0 44px;
  max-width: 300px;
}

.lp-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lp-features li {
  color: #94a3b8;
  font-size: 14px;
  font-weight: 400;
  padding-left: 22px;
  position: relative;
}
.lp-features li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0d6efd;
}

/* ECG strip at bottom */
.lp-ecg-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  overflow: hidden;
}
.lp-ecg {
  width: 200%;
  height: 60px;
  display: block;
  animation: ecg-scroll 9s linear infinite;
}
@keyframes ecg-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ── Form (right) panel ── */
.lp-form-panel {
  flex: 0 0 520px;
  min-height: 100vh;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 56px;
}

.lp-form-inner {
  width: 100%;
  max-width: 360px;
  animation: lp-enter .5s ease both;
}
@keyframes lp-enter {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lp-form-brand {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: -.5px;
  margin-bottom: 32px;
}
.lp-form-brand span { color: #0d6efd; }

.lp-form-heading {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 4px;
  letter-spacing: -.5px;
}
.lp-form-sub {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 32px;
}

/* Form fields */
.lp-form { display: flex; flex-direction: column; gap: 0; }
.lp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.lp-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.lp-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-input);
  font-size: 14px;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--ink);
  background: #fff;
  transition: border-color .18s, box-shadow .18s;
  box-sizing: border-box;
}
.lp-field input:focus {
  outline: none;
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13,110,253,.12);
}
.lp-field .errorlist {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--err);
}

/* Submit button */
.lp-btn {
  margin-top: 4px;
  width: 100%;
  padding: 13px 20px;
  background: #0d6efd;
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .01em;
  transition: background .18s, transform .12s, box-shadow .18s;
  box-shadow: 0 4px 14px rgba(13,110,253,.35);
}
.lp-btn:hover {
  background: #0a58ca;
  box-shadow: 0 6px 20px rgba(13,110,253,.45);
  transform: translateY(-1px);
}
.lp-btn:active { transform: translateY(0); }

/* Error flash on login */
.lp-error {
  margin-bottom: 16px;
  font-size: 14px;
}

/* Help text */
.lp-help {
  margin-top: 24px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .lp-form-panel { flex: 1 1 auto; }
  .lp-hero { display: none; }
  .login-body { background: #fff; }
}
@media (max-width: 480px) {
  .lp-form-panel { padding: 32px 20px; align-items: flex-start; padding-top: 60px; }
}

/* ── Range slider + number input jednocześnie (Apka-9zg, KBP antropometria) ── */
.range-with-display {
  display: inline-flex; align-items: center; gap: 12px;
  width: 100%; max-width: 420px;
}
.range-with-display input[type="range"] {
  flex: 1 1 auto;
  height: 6px; cursor: pointer;
  accent-color: var(--brand, #0d6efd);
}
.range-with-display input[type="number"].range-number-input {
  width: 80px; padding: 4px 8px;
  font-weight: 600; font-variant-numeric: tabular-nums;
  text-align: right;
}
.range-unit { font-size: 12px; color: #6b7280; }

/* Bool radio (Zez/Oczopląs — Apka-9zg) — etykieta przed, opcje horyzontalnie */
.field.bool-field {
  display: flex; align-items: center; gap: 12px;
  margin: 8px 0;
}
.field.bool-field > label {
  font-weight: 500; min-width: 140px; margin: 0;
}
.bool-radio { display: inline-flex; align-items: center; gap: 16px; }
/* Django RadioSelect generuje <ul> lub <div> — resetujemy oba */
.bool-radio ul, .bool-radio > div {
  display: inline-flex; gap: 16px; padding: 0; margin: 0; list-style: none;
}
.bool-radio li, .bool-radio > div > div { display: inline-flex; }
.bool-radio label {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; font-weight: normal; font-size: inherit;
}
.bool-radio input[type="radio"] { margin: 0 4px 0 0; }

/* Apka-95b — htmx loading indicators + form submit spinner.
   User feedback: "warto pokazywać symbol przetwarzania po kliknięciu". */
@keyframes htmx-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.htmx-busy {
  cursor: wait !important;
  opacity: 0.7;
  pointer-events: none;
}
.htmx-spinner {
  /* style inline w JS (XSS-safe createElement); tu fallback */
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: htmx-spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
.htmx-indicator {
  display: none;
  transition: opacity .2s ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block !important; }

/* Apka-95b — KBP stepper nav (visual upgrade ze sticky-skip-link). */
.kbp-stepper-nav {
  position: sticky; top: 8px; z-index: 50;
  display: flex; align-items: center; gap: .15rem;
  background: rgba(15, 23, 42, 0.96); color: #e2e8f0;
  padding: .55rem .8rem; border-radius: 10px;
  margin: .6rem 0 1rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  font-size: .86rem; flex-wrap: wrap;
}
.kbp-step {
  display: flex; align-items: center; gap: .45rem;
  padding: .35rem .7rem; border-radius: 6px;
  color: #cbd5e1; text-decoration: none;
  background: rgba(255,255,255,0.04);
  transition: all .18s ease;
}
.kbp-step:hover { background: rgba(255,255,255,0.10); color: #fff; }
.kbp-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,0.10); color: #cbd5e1;
  font-size: .82rem; font-weight: 700;
  transition: all .18s ease;
}
.kbp-step-label { font-weight: 500; }
.kbp-step-shortcut {
  font-size: .7rem; opacity: .55; margin-left: .15rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
/* Active state — Intersection Observer dodaje class .kbp-step-active */
.kbp-step.kbp-step-active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}
.kbp-step.kbp-step-active .kbp-step-num {
  background: #fff; color: #2563eb;
}
/* Completed (kluczowe pola wypełnione) */
.kbp-step.kbp-step-done .kbp-step-num {
  background: #16a34a; color: #fff;
}
.kbp-step.kbp-step-done .kbp-step-num::after {
  content: "✓"; position: absolute;
}
.kbp-step.kbp-step-done .kbp-step-num > span { display: none; }
.kbp-step.kbp-step-active.kbp-step-done .kbp-step-num {
  background: #fff; color: #16a34a;
}
.kbp-step-line {
  flex: 1; min-width: 16px; max-width: 30px;
  height: 2px; background: rgba(255,255,255,0.12);
  border-radius: 2px;
}
#kbp-fill-progress {
  margin-left: auto; color: #94a3b8;
  font-size: .82rem; padding-left: .8rem;
  border-left: 1px solid rgba(255,255,255,0.10);
}
/* Mobile — chowamy shortcut, zmniejszamy paddingi */
@media (max-width: 720px) {
  .kbp-step-shortcut { display: none; }
  .kbp-step { padding: .3rem .5rem; gap: .3rem; }
  .kbp-step-line { display: none; }
  .kbp-stepper-nav { gap: .25rem; padding: .45rem .55rem; }
}

/* ─── Apka-piel-extension Faza 2 — Triaż kanban ────────────────────── */
.triage-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 18px;
}
.triage-col {
  background: var(--surface, #fafbfc);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--border, #e3e6ea);
  min-height: 240px;
}
.triage-col > h2 {
  font-size: 1rem;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.triage-col > h2 .badge {
  background: var(--accent, #3b6ec5);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.triage-czeka  { border-top: 3px solid #d39c00; }
.triage-pomiary { border-top: 3px solid #6f9be8; }
.triage-gotowy { border-top: 3px solid #2da66b; }
.triage-u-lekarza { border-top: 3px solid #888; }
.triage-card {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border, #e3e6ea);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.triage-card.triage-ready {
  background: #f0faf5;
  border-color: #b9e8cd;
}
.triage-card.triage-done {
  opacity: 0.78;
}
.triage-time {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent, #3b6ec5);
}
.triage-name {
  font-weight: 500;
  margin: 2px 0 6px;
}
.triage-meta {
  color: var(--muted, #555);
  line-height: 1.45;
}
.triage-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.triage-actions form {
  display: inline;
  margin: 0;
}
@media (max-width: 1100px) {
  .triage-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .triage-board { grid-template-columns: 1fr; }
}

/* ─── Apka-piel-extension Faza 3 — Wywiad pielęgniarski ─────────────── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: background-color 0.1s;
}
.checkbox-row:hover {
  background-color: var(--surface, #f7f9fb);
}
.checkbox-row input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}
.chronic-conditions-grid {
  gap: 6px;
  margin-top: 8px;
}
