/* ─────────────────────────────────────────
   MediTrack | Design System v2
───────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --brand:        #0ea5e9;
  --brand-dk:     #0284c7;
  --brand-dkk:    #0369a1;
  --brand-lt:     #e0f2fe;
  --brand-xlt:    #f0f9ff;

  /* Accent */
  --accent:       #6366f1;
  --accent-lt:    #eef2ff;

  /* Status */
  --success:      #10b981;
  --success-lt:   #d1fae5;
  --warning:      #f59e0b;
  --warning-lt:   #fef3c7;
  --danger:       #ef4444;
  --danger-lt:    #fee2e2;

  /* Neutrals */
  --gray-50:      #f8fafc;
  --gray-100:     #f1f5f9;
  --gray-200:     #e2e8f0;
  --gray-300:     #cbd5e1;
  --gray-400:     #94a3b8;
  --gray-500:     #64748b;
  --gray-600:     #475569;
  --gray-700:     #334155;
  --gray-800:     #1e293b;
  --gray-900:     #0f172a;

  /* Layout */
  --sidebar-w:    256px;
  --header-h:     64px;
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --radius-xl:    20px;

  /* Shadows */
  --shadow-sm:    0 1px 2px rgba(0,0,0,.05);
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:    0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:    0 10px 24px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.05);
  --shadow-brand: 0 4px 14px rgba(14,165,233,.35);
}

html { font-size: 14px; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dk); }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 200px;
  background: linear-gradient(180deg, rgba(14,165,233,.15) 0%, transparent 100%);
  pointer-events: none;
}

.sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  position: relative;
  z-index: 1;
}

.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dkk));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand);
  flex-shrink: 0;
}

.sidebar-logo-icon svg { width: 18px; height: 18px; }

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: #fff;
}

.sidebar-logo-text span {
  color: var(--brand);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section {
  padding: 14px 10px 5px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.25);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  cursor: pointer;
  margin-bottom: 1px;
}
.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
  text-decoration: none;
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(14,165,233,.25), rgba(14,165,233,.1));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(14,165,233,.3);
}
.nav-item.active svg { opacity: 1; color: var(--brand); }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: 12px;
  color: rgba(255,255,255,.35);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.sidebar-footer-info { flex: 1; min-width: 0; }
.sidebar-footer-name { color: rgba(255,255,255,.8); font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer-links { margin-top: 2px; }
.sidebar-footer-links a { color: rgba(255,255,255,.35); font-size: 11px; }
.sidebar-footer-links a:hover { color: var(--brand); }

/* ── Main ── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

/* ── Topbar ── */
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title { font-size: 15px; font-weight: 700; color: var(--gray-800); white-space: nowrap; }
.topbar-search { flex: 1; max-width: 380px; position: relative; }
.topbar-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.topbar-search input {
  width: 100%;
  padding: 8px 12px 8px 35px;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-size: 13px;
  background: var(--gray-50);
  color: var(--gray-800);
  transition: all .15s;
}
.topbar-search input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(14,165,233,.12); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ── Content ── */
.content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  background: #fff;
}
.card-header h2 { font-size: 14px; font-weight: 700; color: var(--gray-800); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ── Stat tiles ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  opacity: 0;
  transition: opacity .2s;
}
.stat-card:hover::after { opacity: 1; }

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.stat-label { font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--gray-900); letter-spacing: -.5px; line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--gray-400); margin-top: 5px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all .15s;
  white-space: nowrap; line-height: 1.4;
  text-decoration: none !important;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dk));
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-dk), var(--brand-dkk)); color: #fff; box-shadow: 0 6px 16px rgba(14,165,233,.4); }

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--gray-50); color: var(--gray-900); border-color: var(--gray-300); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-ghost { background: transparent; color: var(--gray-600); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--gray-600); letter-spacing: .2px; }
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--gray-800);
  background: #fff;
  transition: all .15s;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14,165,233,.12);
}
.form-control:disabled { background: var(--gray-50); color: var(--gray-400); cursor: not-allowed; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase; letter-spacing: .5px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--brand-xlt); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .2px;
}
.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-green   { background: var(--success-lt); color: #065f46; }
.badge-yellow  { background: var(--warning-lt); color: #92400e; }
.badge-red     { background: var(--danger-lt); color: #991b1b; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }
.badge-purple  { background: #ede9fe; color: #5b21b6; }
.badge-teal    { background: #ccfbf1; color: #065f46; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert-error   { background: var(--danger-lt); color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-lt); color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: var(--brand-lt); color: var(--brand-dkk); border: 1px solid #7dd3fc; }
.alert-warning { background: var(--warning-lt); color: #92400e; border: 1px solid #fcd34d; }

/* ── Search bar ── */
.search-bar { position: relative; }
.search-bar svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.search-bar input { padding-left: 34px; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--gray-200); background: #fff; color: var(--gray-700);
  text-decoration: none; transition: all .15s;
}
.page-btn:hover { background: var(--gray-50); color: var(--gray-900); text-decoration: none; }
.page-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: var(--shadow-brand); }
.page-btn.disabled { color: var(--gray-300); cursor: default; pointer-events: none; }
.page-info { font-size: 12px; color: var(--gray-400); margin-left: 8px; }

/* ── Activity feed ── */
.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex-shrink: 0; margin-top: 5px; }
.activity-time { color: var(--gray-400); font-size: 11px; margin-top: 2px; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-900);
  position: relative;
  overflow: hidden;
}
.login-wrap::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(14,165,233,.2) 0%, transparent 70%);
  top: -150px; right: -150px;
  pointer-events: none;
}
.login-wrap::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(99,102,241,.15) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}
.login-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  position: relative; z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dkk));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  box-shadow: var(--shadow-brand);
}
.login-logo h1 { font-size: 24px; font-weight: 800; color: var(--gray-900); letter-spacing: -.5px; }
.login-logo h1 span { color: var(--brand); }
.login-logo p  { font-size: 13px; color: var(--gray-400); margin-top: 4px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

.quick-access {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 20px;
  font-size: 12px;
  color: var(--gray-600);
}
.quick-access strong { color: var(--gray-800); display: block; margin-bottom: 4px; }
code {
  background: var(--gray-200);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--brand-dkk);
}

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty-state svg { margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── Schedule page specific ── */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.week-day {
  border-right: 1px solid var(--gray-100);
  min-height: 140px;
  padding: 10px 8px;
}
.week-day:last-child { border-right: none; }
.week-day-header { text-align: center; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--gray-100); }
.week-day-name { font-size: 10px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .5px; }
.week-day-num  { font-size: 22px; font-weight: 800; color: var(--gray-800); line-height: 1.1; }
.week-day-num.today { color: var(--brand); }
.week-day.off { background: var(--gray-50); }
.week-day.blocked { background: #fff5f5; }
.appt-chip {
  display: block;
  padding: 4px 7px;
  background: var(--brand-lt);
  color: var(--brand-dkk);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 3px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-left: 2px solid var(--brand);
  text-decoration: none;
}
.appt-chip:hover { background: #bae6fd; color: var(--brand-dkk); text-decoration: none; }

.schedule-row {
  display: grid;
  grid-template-columns: 110px 1fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}
.schedule-row:last-child { border-bottom: none; }

/* ── Kiosk / print ── */
@media print {
  .sidebar, .topbar, .topbar-actions, .btn, form, .no-print { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
}

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── Section heading ── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--gray-400);
  margin-bottom: 10px;
}

/* ── Tooltip-style label ── */
.meta-row { display: flex; gap: 6px; align-items: baseline; margin-bottom: 8px; }
.meta-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--gray-400); min-width: 90px; }
.meta-value { font-size: 13px; color: var(--gray-800); }

/* ── Layout overflow guards ── */
.main { min-width: 0; }
.content { min-width: 0; max-width: 100%; }
.sched-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.week-scroll { overflow-x: auto; }
.week-scroll .week-grid { min-width: 700px; }
.schedule-row { grid-template-columns: 105px minmax(0, 1fr) minmax(0, 1fr); }
.schedule-row .form-control { min-width: 0; }
@media (max-width: 1100px) {
  .sched-layout { grid-template-columns: 1fr; }
}
