/* ==========================================================================
   Dr. Shahid Sameja — design tokens and shared components
   Used by the public site, patient portal, doctor dashboard and admin panel.
   ========================================================================== */

@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope-var.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-var.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  /* Brand palette – colorful clinical: deep violet, electric blue, cyan and warm amber */
  --navy: #1E1650;          /* deep violet ink – headings, dark surfaces */
  --navy-2: #140E3A;
  --navy-3: #2E2370;
  --teal: #6D28D9;          /* primary violet, 7.1:1 on white */
  --teal-strong: #5B21B6;   /* hover / pressed */
  --teal-soft: #EDE9FE;
  --blue: #2563EB;
  --cyan: #06B6D4;
  --pink: #DB2777;
  --amber: #F59E0B;
  --green: #16A34A;
  --blue-gray: #EEF0FF;
  --off-white: #F7F6FE;
  --white: #FFFFFF;
  --ink: #1E1650;
  --text: #3B3760;          /* body, 10:1 on white */
  --muted: #615D84;         /* 5.6:1 on white */
  --line: #E7E4F6;
  --line-strong: #CBC5EA;
  --grad: linear-gradient(120deg, #6D28D9 0%, #4F46E5 45%, #2563EB 100%);
  --grad-hero: radial-gradient(1200px 600px at 85% -10%, rgba(6,182,212,.35), transparent 60%),
               radial-gradient(900px 500px at -10% 110%, rgba(219,39,119,.30), transparent 60%),
               linear-gradient(135deg, #1A1046 0%, #3B1A8F 45%, #5B21B6 70%, #2563EB 100%);
  --grad-text: linear-gradient(90deg, #67E8F9 0%, #A5B4FC 45%, #F9A8D4 100%);

  /* Status (all ≥ 4.5:1 on their tint) */
  --success: #15693F;  --success-tint: #E3F5EA;
  --warning: #7A4F00;  --warning-tint: #FDF2D8;
  --error:   #A3201A;  --error-tint:   #FCE8E6;
  --info:    #3730A3;  --info-tint:    #EEF0FF;

  /* Type */
  --font-sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --fs-xs: 0.8125rem;   /* 13 */
  --fs-sm: 0.875rem;    /* 14 */
  --fs-base: 1.0625rem; /* 17 */
  --fs-md: 1.1875rem;   /* 19 */
  --fs-lg: 1.375rem;    /* 22 */
  --fs-xl: clamp(1.35rem, 1.05rem + 1.5vw, 2.3rem);
  --fs-2xl: clamp(1.6rem, 1.1rem + 2.5vw, 3.2rem);
  --fs-3xl: clamp(2rem, 1.15rem + 4vw, 4.4rem);
  --lh-tight: 1.06;
  --lh-head: 1.18;
  --lh-body: 1.65;

  /* Space (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --s7: 48px; --s8: 64px; --s9: 96px; --s10: 128px;

  /* Shape */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --r-xl: 28px;
  --shadow-1: 0 1px 2px rgba(30, 22, 80, .06), 0 1px 1px rgba(30, 22, 80, .04);
  --shadow-2: 0 18px 40px -18px rgba(46, 35, 112, .35);
  --shadow-3: 0 30px 60px -25px rgba(46, 35, 112, .45);
  --shadow-glow: 0 10px 30px -8px rgba(109, 40, 217, .55);
  --focus: 0 0 0 3px #fff, 0 0 0 5px var(--teal);

  --container: 1200px;
  --measure: 68ch;
  --header-h: 76px;
}
@media (max-width: 600px) {
  :root { --fs-base: 1rem; --fs-md: 1.0625rem; --fs-lg: 1.2rem; --header-h: 64px; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01" 0;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--teal-strong); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--navy); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
button, input, select, textarea { font: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s6) 0; }
::selection { background: var(--teal-soft); color: var(--navy); }

h1, h2, h3, h4 { color: var(--ink); margin: 0 0 var(--s4); line-height: var(--lh-head); font-weight: 700; }
h1, .h1 { font-weight: 800; font-size: var(--fs-2xl); line-height: 1.08; letter-spacing: -0.025em; }
h2, .h2 { font-weight: 800; font-size: var(--fs-xl); letter-spacing: -0.02em; }
h3, .h3 { font-size: var(--fs-lg); font-weight: 750; letter-spacing: -0.015em; }
h4, .h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--s4); }
small, .small { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.lead { font-size: var(--fs-md); color: var(--text); max-width: 62ch; }
strong { font-weight: 700; color: var(--ink); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--s4); top: -60px; z-index: 1000; padding: var(--s3) var(--s4);
  background: var(--navy); color: #fff; border-radius: var(--r); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: var(--s3); color: #fff; }

.container { width: min(100% - 40px, var(--container)); margin-inline: auto; }
.container-narrow { width: min(100% - 40px, 820px); margin-inline: auto; }
.stack > * + * { margin-top: var(--s4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.between { justify-content: space-between; }
.grid { display: grid; gap: var(--s5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }

.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; flex: none; }
a > .icon, a > .icon-sm, p > .icon, p > .icon-sm, label > .icon-sm { display: inline-block; vertical-align: -0.15em; }
.icon-lg { width: 28px; height: 28px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--grad); --btn-fg: #fff; --btn-bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 46px; padding: 10px 22px; border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  font-weight: 700; font-size: var(--fs-sm); letter-spacing: .01em; line-height: 1.2;
  text-decoration: none; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .2s ease, box-shadow .2s ease;
  white-space: nowrap;
}
.btn { box-shadow: var(--shadow-glow); }
.btn:hover { --btn-bg: var(--grad); --btn-bd: transparent; color: #fff; transform: translateY(-1px); box-shadow: 0 16px 34px -10px rgba(109,40,217,.6); }
.btn:active { transform: translateY(1px); }
.btn-ghost:hover, .btn-outline:hover { transform: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-navy, .btn-outline, .btn-ghost, .btn-danger, .btn-on-dark, .btn-outline-light, .btn-light { box-shadow: none; }
.btn-navy { --btn-bg: var(--navy); --btn-bd: var(--navy); }
.btn-navy:hover { --btn-bg: var(--navy-3); --btn-bd: var(--navy-3); box-shadow: none; }
.btn-outline { --btn-bg: transparent; --btn-fg: var(--navy); --btn-bd: var(--line-strong); }
.btn-outline:hover { box-shadow: none; --btn-bg: var(--off-white); --btn-fg: var(--navy); --btn-bd: var(--navy); color: var(--navy); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--teal-strong); --btn-bd: transparent; padding-inline: 10px; }
.btn-ghost:hover { box-shadow: none; --btn-bg: var(--teal-soft); --btn-bd: transparent; color: var(--navy); }
.btn-danger { --btn-bg: var(--error); --btn-bd: var(--error); }
.btn-danger:hover { box-shadow: none; --btn-bg: #861813; --btn-bd: #861813; }
.btn-on-dark { --btn-bg: #fff; --btn-fg: var(--navy); --btn-bd: #fff; }
.btn-on-dark:hover { box-shadow: none; --btn-bg: var(--teal-soft); --btn-bd: var(--teal-soft); color: var(--navy); }
.btn-outline-light { --btn-bg: transparent; --btn-fg: #fff; --btn-bd: rgba(255,255,255,.5); }
.btn-outline-light:hover { box-shadow: none; --btn-bg: rgba(255,255,255,.1); --btn-bd: #fff; color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: var(--fs-xs); }
.btn-lg { min-height: 56px; padding: 14px 30px; font-size: var(--fs-base); }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--teal-strong); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 600; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: var(--s5); }
.field > label, .label { font-weight: 700; font-size: var(--fs-sm); color: var(--ink); }
.field .hint { font-size: var(--fs-sm); color: var(--muted); margin: 0; }
.optional { font-weight: 500; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid var(--line-strong);
  border-radius: var(--r); background: #fff; color: var(--ink); font-size: var(--fs-base); line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 120px; resize: vertical; }
.select { appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23344654' stroke-width='1.6'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(109, 40, 217, .18); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--error); }
.field-error { color: var(--error); font-size: var(--fs-sm); font-weight: 600; display: flex; gap: 6px; align-items: flex-start; margin: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); line-height: 1.5; padding: 4px 0; }
.check input { width: 24px; height: 24px; margin: 1px 0 0; accent-color: var(--teal); flex: none; }
.radio-cards { display: grid; gap: var(--s3); }
.radio-card { position: relative; display: flex; gap: var(--s4); padding: var(--s4) var(--s5); border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; cursor: pointer; }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card:hover { border-color: var(--navy); }
.radio-card:has(input:checked) { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: #FAF8FF; }
.radio-card:has(input:focus-visible) { box-shadow: var(--focus); }
.form-row { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.form-actions { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; margin-top: var(--s5); }
fieldset { border: 0; padding: 0; margin: 0 0 var(--s5); min-width: 0; }
legend { font-weight: 700; color: var(--ink); margin-bottom: var(--s3); padding: 0; }

/* ---------- Alerts / badges ---------- */
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: 14px 16px; border-radius: var(--r); border: 1px solid; font-size: var(--fs-sm); line-height: 1.55; margin-bottom: var(--s4); }
.alert .icon { margin-top: 2px; }
.alert p:last-child { margin-bottom: 0; }
.alert-success { background: var(--success-tint); border-color: #B6DCC5; color: var(--success); }
.alert-warning { background: var(--warning-tint); border-color: #EBCF91; color: var(--warning); }
.alert-error { background: var(--error-tint); border-color: #EFBDB8; color: var(--error); }
.alert-info { background: var(--info-tint); border-color: #C3D5E6; color: var(--info); }
.alert strong { color: inherit; }
.alert-emergency { background: #fff; border: 1px solid var(--error); color: var(--text); }
.alert-emergency .icon { color: var(--error); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 700; line-height: 1.4; white-space: nowrap;
  background: var(--blue-gray); color: var(--navy);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-plain::before { display: none; }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-warning { background: var(--warning-tint); color: var(--warning); }
.badge-error { background: var(--error-tint); color: var(--error); }
.badge-info { background: var(--info-tint); color: var(--info); }
.badge-teal { background: var(--teal-soft); color: var(--teal-strong); }
.badge-muted { background: #F0EFF6; color: #4F4B6E; }

/* ---------- Cards / panels ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-1); }
.card-tight { padding: var(--s4); }
.card h2, .card h3 { margin-top: 0; }
.panel { background: var(--off-white); border-radius: var(--r-lg); padding: var(--s5); }

/* ---------- Tables ---------- */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 700; color: var(--muted); font-size: var(--fs-xs); background: var(--off-white); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FAF9FF; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table a { font-weight: 600; }

/* ---------- Dialog ---------- */
dialog.modal { border: 0; border-radius: var(--r-lg); padding: 0; width: min(560px, calc(100% - 32px)); box-shadow: var(--shadow-2); color: var(--text); }
dialog.modal::backdrop { background: rgba(20, 14, 58, .6); backdrop-filter: blur(3px); }
.modal-body { padding: var(--s6); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); margin-bottom: var(--s4); }
.modal-head h2 { font-size: var(--fs-lg); font-family: var(--font-sans); font-weight: 700; margin: 0; }

/* ---------- Tabs ---------- */
.tabs { position: relative; display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); overflow-x: auto; margin-bottom: var(--s5); }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; font-weight: 700; font-size: var(--fs-sm); color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; }
.tabs a[aria-current="page"], .tabs [aria-selected="true"] { color: var(--navy); border-bottom-color: var(--teal); }
.tabs a:hover { color: var(--navy); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: var(--s2); align-items: center; justify-content: center; margin-top: var(--s5); flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 40px; min-height: 40px; display: inline-grid; place-items: center; padding: 0 10px; border-radius: var(--r); border: 1px solid var(--line); text-decoration: none; font-weight: 700; font-size: var(--fs-sm); color: var(--navy); }
.pagination [aria-current="page"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination .disabled { color: var(--line-strong); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: var(--s7) var(--s5); color: var(--muted); }
.empty .icon-lg { margin: 0 auto var(--s3); color: var(--teal); }
.empty h3 { font-size: var(--fs-md); margin-bottom: var(--s2); }
.empty p { max-width: 46ch; margin-inline: auto; }

/* ---------- Toast ---------- */
.toast-region { position: fixed; z-index: 900; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: var(--r); box-shadow: var(--shadow-2); font-size: var(--fs-sm); display: flex; gap: 10px; align-items: flex-start; animation: toast-in .2s ease-out; }
.toast .icon { color: #A5F3FC; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Loading ---------- */
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
[aria-busy="true"] .btn-label { opacity: .6; }

/* ---------- Description lists ---------- */
.dl { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 10px 20px; margin: 0; font-size: var(--fs-sm); }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .site-footer, .sticky-cta, .no-print { display: none !important; }
  body { color: #000; }
}
