/* ============================================================
   Eye Screening Program — main.css
   Design system: slate/teal palette, clean sidebar layout
   ============================================================ */

/* ── Fonts ─────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Brand palette */
  --color-primary:        #0f766e;   /* teal-700  */
  --color-primary-dark:   #0d6460;
  --color-primary-light:  #ccfbf1;   /* teal-100  */
  --color-accent:         #14b8a6;   /* teal-500  */

  /* Sidebar */
  --sidebar-bg:           #0f172a;   /* slate-900 */
  --sidebar-text:         #94a3b8;   /* slate-400 */
  --sidebar-text-hover:   #f1f5f9;   /* slate-100 */
  --sidebar-active-bg:    rgba(20,184,166,.15);
  --sidebar-active-text:  #5eead4;   /* teal-300  */
  --sidebar-width:        240px;

  /* Surface */
  --bg-page:              #f8fafc;   /* slate-50  */
  --bg-card:              #ffffff;
  --border-color:         #e2e8f0;   /* slate-200 */

  /* Text */
  --text-primary:         #0f172a;   /* slate-900 */
  --text-muted:           #64748b;   /* slate-500 */

  /* Status badges */
  --badge-healthy-bg:     #dcfce7;
  --badge-healthy-text:   #15803d;
  --badge-reader-bg:      #fef9c3;
  --badge-reader-text:    #a16207;
  --badge-spectacle-bg:   #fee2e2;
  --badge-spectacle-text: #b91c1c;

  /* Order status */
  --status-received-bg:   #f1f5f9;
  --status-printed-bg:    #dbeafe;
  --status-assembled-bg:  #ede9fe;
  --status-dispatched-bg: #fef3c7;
  --status-collected-bg:  #dcfce7;
}

/* ── Base ───────────────────────────────────────────────────── */
* { box-sizing: border-box; }

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

body {
  font-family: 'Inter', sans-serif;
  font-size: .875rem;
  background: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
}

/* ── App Shell (sidebar + content) ─────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}
.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--color-accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.sidebar-brand-text {
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: .68rem;
  color: var(--sidebar-text);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
}

.sidebar-section-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  padding: .75rem 1.25rem .25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 0;
  font-size: .825rem;
  font-weight: 400;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
  white-space: nowrap;
}
.sidebar-link:hover {
  background: rgba(255,255,255,.05);
  color: var(--sidebar-text-hover);
}
.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--color-accent);
  font-weight: 500;
}
.sidebar-link i {
  font-size: 1rem;
  width: 1.1rem;
  text-align: center;
}

.sidebar-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-footer .sidebar-link {
  border-radius: 8px;
  border-left: none;
  color: #f87171;
}
.sidebar-footer .sidebar-link:hover {
  background: rgba(248,113,113,.1);
  color: #fca5a5;
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: var(--text-muted);
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
}

.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.card-header-bar h1,
.card-header-bar h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

/* ── KPI Cards ──────────────────────────────────────────────── */
.kpi-card {
  border-radius: 10px;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: box-shadow .15s;
}
.kpi-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.kpi-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .35rem;
}
.kpi-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: .25rem;
}
.kpi-sub {
  font-size: .72rem;
  color: var(--text-muted);
}
.kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.kpi-teal   { background: var(--color-primary-light); color: var(--color-primary); }
.kpi-blue   { background: #dbeafe; color: #1d4ed8; }
.kpi-amber  { background: #fef3c7; color: #b45309; }
.kpi-violet { background: #ede9fe; color: #7c3aed; }
.kpi-green  { background: #dcfce7; color: #15803d; }

/* ── Performance Snapshot Row ───────────────────────────────── */
.perf-card {
  border-radius: 10px;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}
.perf-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* ── Tables ─────────────────────────────────────────────────── */
.table th {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}
.table td {
  vertical-align: middle;
  font-size: .82rem;
  border-color: var(--border-color);
}
.table tbody tr:hover { background: #f8fafc; }

/* ── Pathway / Status Badges ────────────────────────────────── */
.badge-healthy {
  background: var(--badge-healthy-bg);
  color: var(--badge-healthy-text);
  font-size: .7rem; font-weight: 600; border-radius: 20px; padding: .2rem .65rem;
}
.badge-reader {
  background: var(--badge-reader-bg);
  color: var(--badge-reader-text);
  font-size: .7rem; font-weight: 600; border-radius: 20px; padding: .2rem .65rem;
}
.badge-spectacle {
  background: var(--badge-spectacle-bg);
  color: var(--badge-spectacle-text);
  font-size: .7rem; font-weight: 600; border-radius: 20px; padding: .2rem .65rem;
}
.badge-review {
  background: #f1f5f9; color: #475569;
  font-size: .7rem; font-weight: 600; border-radius: 20px; padding: .2rem .65rem;
}

/* Order-status inline badges */
.status-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .7rem; font-weight: 600; border-radius: 20px; padding: .2rem .7rem;
}
.status-RECEIVED   { background: var(--status-received-bg);   color: #475569; }
.status-PRINTED    { background: var(--status-printed-bg);    color: #1d4ed8; }
.status-ASSEMBLED  { background: var(--status-assembled-bg);  color: #6d28d9; }
.status-DISPATCHED { background: var(--status-dispatched-bg); color: #92400e; }
.status-COLLECTED  { background: var(--status-collected-bg);  color: #15803d; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
.btn-icon {
  padding: .25rem .45rem;
  line-height: 1;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: .82rem; }
.form-control, .form-select {
  font-size: .85rem;
  border-color: var(--border-color);
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(20,184,166,.15);
}

/* ── Login Page ──────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.75rem 1rem 1.75rem;
  gap: 1.25rem;
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
}

.login-footer {
  margin-top: auto;
  width: 100%;
  max-width: 400px;
  text-align: center;
  color: rgba(226, 232, 240, .92);
  font-size: .8rem;
}

.login-footer-text {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.login-footer a {
  color: var(--color-accent);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

.app-footer {
  padding: .9rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
}

.app-footer a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.app-footer a:hover {
  text-decoration: underline;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.5rem;
  margin: 0 auto 1.25rem;
}

/* ── Modals ──────────────────────────────────────────────────── */
.modal-content { border: none; border-radius: 14px; }
.modal-header { border-bottom: 1px solid var(--border-color); padding: 1rem 1.25rem; }
.modal-footer { border-top: 1px solid var(--border-color); padding: .75rem 1.25rem; }
.detail-row { padding: .4rem 0; border-bottom: 1px solid var(--border-color); font-size: .82rem; }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-weight: 600; color: var(--text-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.detail-value { color: var(--text-primary); }

/* Status timeline inside modal */
.audit-entry {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: .8rem;
}
.audit-entry:last-child { border-bottom: none; }
.audit-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-accent); flex-shrink: 0;
  margin-top: .35rem;
}

/* ── Filter Bar ──────────────────────────────────────────────── */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: .875rem 1.125rem;
  margin-bottom: 1rem;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { border-radius: 8px; font-size: .83rem; }

/* ── Responsive Sidebar ──────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }
}
