/* ============================================================
   OMS – Outreach Medical Screening System
   assets/css/main.css
   Font: DM Sans (body) + DM Mono (values/IDs)
   Theme: Dark sidebar + light content area
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Sidebar */
  --sb-bg:           #0d1117;
  --sb-surface:      #161b22;
  --sb-border:       #21262d;
  --sb-text:         #8b949e;
  --sb-text-active:  #e6edf3;
  --sb-accent:       #2dd4bf;      /* teal accent */
  --sb-accent-dim:   rgba(45,212,191,.12);
  --sb-width:        240px;

  /* Content area */
  --bg:              #f4f6f9;
  --surface:         #ffffff;
  --surface-2:       #f0f4f8;
  --border:          #e2e8f0;
  --text-primary:    #0f172a;
  --text-secondary:  #64748b;
  --text-muted:      #94a3b8;

  /* Accent colours */
  --teal:            #0d9488;
  --teal-light:      #ccfbf1;
  --blue:            #2563eb;
  --blue-light:      #dbeafe;
  --amber:           #d97706;
  --amber-light:     #fef3c7;
  --red:             #dc2626;
  --red-light:       #fee2e2;
  --green:           #16a34a;
  --green-light:     #dcfce7;
  --purple:          #7c3aed;
  --purple-light:    #ede9fe;

  /* Typography */
  --font:            'DM Sans', sans-serif;
  --font-mono:       'DM Mono', monospace;

  /* Radii / shadows */
  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       14px;
  --shadow-card:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-modal:    0 20px 60px rgba(0,0,0,.18);

  /* Topbar */
  --topbar-h:        56px;

  --transition:      .18s ease;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
}

/* ── Layout Shell ── */
body { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sb-width);
  height: 100vh;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .brand-sub,
.sidebar.collapsed .brand-name,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-item span:last-child,
.sidebar.collapsed .user-info,
.sidebar.collapsed .logout-btn { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-footer { justify-content: center; padding: 12px 0; }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.brand-icon {
  font-size: 22px;
  color: var(--sb-accent);
  line-height: 1;
}
.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--sb-text-active);
  letter-spacing: .3px;
}
.brand-sub {
  font-size: 11px;
  color: var(--sb-text);
  margin-top: 1px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--sb-border) transparent;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sb-text);
  padding: 14px 16px 4px;
  opacity: .6;
  white-space: nowrap;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--sb-text);
  font-size: 13.5px;
  font-weight: 400;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  position: relative;
}
.nav-item:hover {
  background: var(--sb-surface);
  color: var(--sb-text-active);
}
.nav-item.active {
  background: var(--sb-accent-dim);
  color: var(--sb-accent);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--sb-accent);
  border-radius: 0 2px 2px 0;
}
.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--sb-border);
  padding: 14px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow: hidden;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--sb-accent-dim);
  color: var(--sb-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--sb-text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--sb-text);
  white-space: nowrap;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--sb-text);
  font-size: 16px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.logout-btn:hover { color: var(--red); background: rgba(220,38,38,.1); }

/* ── Main Wrapper ── */
.main-wrapper {
  margin-left: var(--sb-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main-wrapper { margin-left: 60px; }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.sidebar-toggle {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--surface-2); }
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-date {
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Flash messages ── */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  font-size: 13.5px;
  font-weight: 500;
  gap: 12px;
}
.flash-success { background: var(--green-light); color: #14532d; border-bottom: 1px solid #bbf7d0; }
.flash-error   { background: var(--red-light);   color: #7f1d1d; border-bottom: 1px solid #fecaca; }
.flash-info    { background: var(--blue-light);   color: #1e3a8a; border-bottom: 1px solid #bfdbfe; }
.flash-warning { background: var(--amber-light);  color: #78350f; border-bottom: 1px solid #fde68a; }
.flash-close {
  background: none; border: none;
  font-size: 18px; line-height: 1;
  opacity: .6; cursor: pointer;
}

/* ── Page Content ── */
.page-content { padding: 28px 28px 48px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Stat cards (dashboard) ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.stat-icon.teal   { background: var(--teal-light);   color: var(--teal); }
.stat-icon.blue   { background: var(--blue-light);   color: var(--blue); }
.stat-icon.green  { background: var(--green-light);  color: var(--green); }
.stat-icon.amber  { background: var(--amber-light);  color: var(--amber); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.red    { background: var(--red-light);    color: var(--red); }
.stat-value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-primary);
  font-family: var(--font-mono);
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table.oms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.oms-table th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.oms-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.oms-table tbody tr:last-child td { border-bottom: none; }
.oms-table tbody tr:hover { background: var(--surface-2); }
.oms-table .mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-secondary); }

/* ── Badges / Status pills ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge-pending    { background: var(--amber-light);  color: var(--amber); }
.badge-progress   { background: var(--blue-light);   color: var(--blue); }
.badge-completed  { background: var(--green-light);  color: var(--green); }
.badge-cancelled  { background: #f1f5f9;             color: var(--text-muted); }
.badge-lab        { background: var(--purple-light);  color: var(--purple); }
.badge-clinical   { background: var(--blue-light);   color: var(--blue); }
.badge-nutritional{ background: var(--teal-light);   color: var(--teal); }
.badge-normal     { background: var(--green-light);  color: var(--green); }
.badge-high       { background: var(--red-light);    color: var(--red); }
.badge-low        { background: var(--amber-light);  color: var(--amber); }
.badge-abnormal   { background: var(--red-light);    color: var(--red); }

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-label .req { color: var(--red); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}
.form-control:disabled { background: var(--surface-2); color: var(--text-muted); }
.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
}
.form-error {
  font-size: 11.5px;
  color: var(--red);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--transition), box-shadow var(--transition), transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary   { background: var(--teal);  color: #fff; border-color: var(--teal); }
.btn-primary:hover { background: #0f766e; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger    { background: var(--red);   color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost     { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 7px; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header-left h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}
.page-header-left p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Section divider ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 0 16px;
}
.section-divider span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  white-space: nowrap;
}
.section-divider::before, .section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Search bar ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  max-width: 320px;
}
.search-bar input {
  border: none;
  outline: none;
  background: transparent;
  padding: 9px 0;
  flex: 1;
  font-size: 13.5px;
}
.search-icon { color: var(--text-muted); font-size: 14px; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-state-title { font-size: 15px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; }

/* ── Report specific ── */
.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.report-section {
  margin-bottom: 24px;
}
.report-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--teal);
  padding: 6px 0;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--teal-light);
}
.result-flag-high  { color: var(--red);   font-weight: 600; }
.result-flag-low   { color: var(--amber); font-weight: 600; }
.result-flag-abnormal { color: var(--red); font-weight: 600; }
.signed-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-light);
  color: var(--green);
  border: 1px solid #bbf7d0;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
}

/* ── Login page ── */
body.login-body {
  display: block;
}
.login-page {
  min-height: 100vh;
  background: var(--sb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-icon { font-size: 36px; color: var(--sb-accent); }
.login-logo-name { font-size: 22px; font-weight: 600; color: var(--sb-text-active); margin-top: 6px; }
.login-logo-sub  { font-size: 12px; color: var(--sb-text); margin-top: 2px; }
.login-card .form-label { color: #8b949e; }
.login-card .form-control {
  background: var(--sb-bg);
  border-color: var(--sb-border);
  color: var(--sb-text-active);
}
.login-card .form-control:focus { border-color: var(--sb-accent); box-shadow: 0 0 0 3px rgba(45,212,191,.15); }
.login-card .btn-primary { background: var(--sb-accent); border-color: var(--sb-accent); color: #0d1117; width: 100%; justify-content: center; }
.login-card .btn-primary:hover { background: #2cc4b0; }

/* ── Utilities ── */
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.flex  { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.w-full { width: 100%; }

/* ── Print ── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 0; }
  body { background: #fff; color: #000; }
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.active { display: block; }

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --sb-width: 240px; }

  /* Sidebar slides in from left; hidden by default on mobile */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }

  /* Content always full-width on mobile */
  .main-wrapper { margin-left: 0 !important; }

  /* Topbar toggle button more tappable on mobile */
  .sidebar-toggle {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
