/* Tokens sourced directly from asnani_flutter/design/brand_identity.json (v1.2.0+) — the
   "chart & ledger" direction: opaque surfaces + a colored folder-tab accent, no glass/blur.
   See brand_identity.json's changelog_1_2_0 + pending-decisions.md 2026-08-27 continuation 9
   for why glassmorphism was dropped and what replaced it. Do not invent new color values without
   updating that file first — --color-muted and the --tint-*-fg / --color-danger-text values below
   exist because the brand file's own hexes fail WCAG AA in certain contexts (see changelog_1_1_0). */
:root {
  --color-primary: #0B7285;
  --color-primary-dark: #075A69;
  --color-secondary: #20C4B6;
  --color-accent: #F4C95D;
  --color-ink: #16323A;
  --color-muted: #5b6c71;
  --color-canvas: #F7FBFA;
  --color-surface: #FFFFFF;
  --color-border: #E3EFED;
  --color-success: #2A9D70;
  --color-danger: #D95D5D;
  --radius-card: 20px;
  --radius-button: 14px;
  --radius-input: 14px;

  /* Accessible foregrounds for colored text sitting on its own translucent tint (pill badges,
     stat-icon backgrounds) — solved per WCAG contrast against each *specific* tinted background.
     Kept separate from --color-success/--color-danger/--color-secondary (used as solid button
     backgrounds with white text, a different contrast problem). */
  --tint-success-fg: #1f7553;
  --tint-danger-fg: #c52e2e;
  --tint-warning-fg: #866a15;
  --tint-secondary-fg: #147971;
  /* Accessible danger text for plain usage on canvas/card (form errors, toasts, alerts) —
     --color-danger itself stays untouched because it also backs .btn-danger with white text. */
  --color-danger-text: #d13c3c;

  /* Solid "brand spine" sidebar — deep teal in both themes on purpose, so it reads as a constant
     identity anchor rather than flipping with light/dark mode (a deliberate signature choice).
     Text opacity solved for ≥4.5:1 against this exact teal (0.90 → 4.86:1). */
  --sidebar-bg: #0B7285;
  --sidebar-text: rgba(255, 255, 255, 0.90);
  --sidebar-text-active: #FFFFFF;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.10);
  --sidebar-active-bg: rgba(255, 255, 255, 0.14);

  --shadow-card: 0 1px 2px rgba(11, 114, 133, 0.05), 0 8px 24px rgba(11, 114, 133, 0.08);
  --shadow-card-hover: 0 1px 2px rgba(11, 114, 133, 0.06), 0 12px 32px rgba(11, 114, 133, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary: #20C4B6;
    --color-primary-dark: #0B7285;
    --color-ink: #E7F2F1;
    --color-muted: #9AB3B1;
    --color-canvas: #0F2429;
    --color-surface: #16323A;
    --color-border: #1F4048;
    --tint-success-fg: #2ead7b;
    --tint-danger-fg: #df7676;
    --tint-warning-fg: #d0a521;
    --tint-secondary-fg: #20c4b6;
    --color-danger-text: #db6565;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-card-hover: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --color-primary: #20C4B6;
  --color-primary-dark: #0B7285;
  --color-ink: #E7F2F1;
  --color-muted: #9AB3B1;
  --color-canvas: #0F2429;
  --color-surface: #16323A;
  --color-border: #1F4048;
  --tint-success-fg: #2ead7b;
  --tint-danger-fg: #df7676;
  --tint-warning-fg: #d0a521;
  --tint-secondary-fg: #20c4b6;
  --color-danger-text: #db6565;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-card-hover: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Tajawal", Arial, sans-serif;
  letter-spacing: normal;
  background: var(--color-canvas);
  color: var(--color-ink);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* Iconography per asnani_flutter/design/brand_identity.json: "Material Symbols Rounded",
   default_size 24, rounded stroke. */
.material-symbols-rounded {
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  color: currentColor;
}
h1, h2, h3 { font-weight: 800; line-height: 1.3; margin: 0 0 12px; }
p { margin: 0 0 8px; }
code { background: var(--color-border); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }

.content-plain {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 8px 20px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: #fff; color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
}
.brand-name { font-weight: 800; font-size: 18px; color: #fff; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-button);
  border-inline-start: 4px solid transparent;
  color: var(--sidebar-text);
  font-weight: 500;
  transition: background-color 150ms, color 150ms, border-color 150ms;
}
.nav-link:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-active); }
.nav-link.active {
  background: var(--sidebar-active-bg);
  border-inline-start-color: var(--color-accent);
  color: var(--sidebar-text-active);
  font-weight: 700;
}
.logout-form { margin: 0; }
.logout-btn {
  width: 100%; text-align: start; background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: inherit; color: var(--sidebar-text); padding: 10px 12px;
}
.logout-btn:hover { color: var(--sidebar-text-active); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; flex-shrink: 0;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--color-surface);
}
.user-name { font-weight: 700; color: var(--color-primary); }
.theme-toggle {
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 150ms;
}
.theme-toggle:hover { background: var(--color-border); }
.content { padding: 24px; overflow-x: auto; }
.content > * { max-width: 1560px; margin-inline: auto; }

/* Signature element: a colored "folder tab" on the leading edge (RTL: right) of every card —
   drawn from dentistry's own vernacular (a patient chart's tabbed divider), not a mood effect.
   Surfaces are fully opaque now — legibility for dense tables/forms matters more here than a
   marketing page's atmosphere. See pending-decisions.md 2026-08-27 continuation 9. */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-inline-start: 4px solid var(--color-primary);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 20px;
  transition: box-shadow 200ms, transform 200ms;
}
.card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-header h3 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 20px;
  border-radius: var(--radius-button);
  border: none; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 15px;
  transition: background-color 150ms, transform 100ms;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-ink); }
.btn-outline:hover { background: var(--color-border); }
.btn-block { width: 100%; }

/* Base input/select styling applies with or without a .field wrapper — a few inline update-status
   forms (e.g. Appointments/Index.cshtml) use a bare <select> next to a fully-styled .btn, and an
   unstyled native select next to a rounded pill button reads as a jarring shape mismatch.
   Checkboxes/radios are excluded — they're native controls used inline with a text label, not
   text-entry fields, and boxing one in a 44px bar would look broken, not consistent. */
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--color-border);
  background: var(--color-canvas);
  color: var(--color-ink);
  font-family: inherit;
  font-size: 15px;
  transition: border-color 150ms;
}
input:focus:not([type="checkbox"]):not([type="radio"]), select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
textarea { height: auto; padding: 10px 14px; min-height: 88px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; }
.field .error { color: var(--color-danger-text); font-size: 13px; margin-top: 4px; display: block; }

/* Ledger tables: tabular-nums keeps amounts/dates/counts aligned into scannable columns, like a
   real patient ledger — a deliberate nod to the "chart & ledger" direction, not decoration. */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--color-border); }
th { color: var(--color-muted); font-size: 13px; font-weight: 700; }
tbody tr:hover { background: var(--color-canvas); }
td { font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex; align-items: center;
  padding: 6px 10px; border-radius: 24px;
  font-weight: 700; font-size: 12px;
}
.pill-success { background: rgba(42,157,112,0.14); color: var(--tint-success-fg); }
.pill-warning { background: rgba(244,201,93,0.18); color: var(--tint-warning-fg); }
.pill-danger { background: rgba(217,93,93,0.14); color: var(--tint-danger-fg); }
.pill-muted { background: var(--color-border); color: var(--color-muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.stat-card .value { font-size: 30px; font-weight: 800; color: var(--color-primary); font-variant-numeric: tabular-nums; }
.stat-card .label { color: var(--color-muted); font-size: 14px; }
.stat-icon {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px;
  font-size: 22px; margin-bottom: 12px;
}
.stat-card-link { display: block; transition: transform 150ms, box-shadow 200ms; }
.stat-card-link:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }

/* Weekly appointments load (Pages/Index) — every bar is a real COUNT(*) per calendar day, never
   decorative placeholder data (see Index.cshtml.cs's comment on why this replaced the old React
   admin's hardcoded fake weekly chart). */
.week-chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; height: 220px; padding-bottom: 4px; border-bottom: 1px dashed var(--color-border); }
.week-chart-col { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 100%; }
.week-chart-count { font-size: 13px; font-weight: 800; color: var(--color-ink); font-variant-numeric: tabular-nums; }
.week-chart-bar-track { flex: 1; width: 100%; max-width: 40px; display: flex; align-items: flex-end; }
.week-chart-bar { width: 100%; min-height: 4px; border-radius: 8px 8px 0 0; background: var(--color-secondary); transition: height 300ms; }
.week-chart-bar-today { background: var(--color-primary); }
.week-chart-day { font-size: 12px; font-weight: 700; color: var(--color-muted); }
@media (prefers-reduced-motion: reduce) { .week-chart-bar { transition: none; } }

/* Visual platform picker (Pages/Social) — a colored icon badge per platform instead of a plain
   <select>, recovered from the old React admin's nicer button-grid picker (client/src/pages/admin/
   social.tsx @ d5e810f). Real radio inputs underneath for keyboard/no-JS support; visually hidden,
   not display:none, so they stay focusable. */
.platform-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.platform-option {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius-button);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms;
}
.platform-option:hover { background: var(--color-canvas); }
.platform-option input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.platform-option:has(input:checked) { border-color: var(--color-primary); background: var(--color-canvas); }
.platform-option:focus-within { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.platform-badge {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.platform-badge .material-symbols-rounded { color: #fff; font-size: 20px; }
.platform-badge-sm { width: 28px; height: 28px; }
.platform-badge-sm .material-symbols-rounded { font-size: 16px; }
.platform-label { font-size: 11px; font-weight: 700; text-align: center; }

.login-card { width: 100%; max-width: 380px; }
.alert { background: rgba(217,93,93,0.1); color: var(--color-danger-text); padding: 12px 16px; border-radius: var(--radius-input); margin-bottom: 16px; font-weight: 500; }

/* Action feedback (TempData-driven, see _Layout.cshtml) */
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-input);
  margin-bottom: 16px; font-weight: 700; font-size: 14px;
}
.toast-success { background: rgba(42,157,112,0.12); color: var(--tint-success-fg); }
.toast-error { background: rgba(217,93,93,0.12); color: var(--color-danger-text); }

/* Empty states for tables/lists with no data */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px 20px; color: var(--color-muted); text-align: center;
}
.empty-state .material-symbols-rounded { font-size: 36px; opacity: 0.5; }
.empty-state p { margin: 0; font-size: 14px; }

/* Visible focus ring per brand_identity.json accessibility spec (2px primary outline) — nav-link
   sits on the solid teal sidebar, where a teal outline would be invisible, so it gets white instead. */
a:focus-visible, button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
.nav-link:focus-visible, .theme-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.nav-link:focus-visible, .logout-btn:focus-visible { outline-color: #fff; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

/* Responsive: collapse the fixed sidebar into an icon rail below ~960px so tables/forms
   on laptop-sized screens don't get squeezed under a 240px-wide sidebar. */
@media (max-width: 960px) {
  .sidebar { width: 76px; padding: 20px 10px; }
  .brand-name, .nav-link span:last-child, .logout-btn span:last-child { display: none; }
  .brand { justify-content: center; padding-inline: 0; }
  .nav-link, .logout-btn { justify-content: center; padding-inline: 0; }
}
@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  /* Several pages lay out multi-column forms with an inline grid-template-columns style
     rather than a class; collapse those to one column on narrow screens too. */
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .stat-card-link:hover, .card:hover { transform: none; }
  .btn:active { transform: none; }
}

/* Table row action-button groups (edit/toggle/delete) — several pages lay these out inline
   with `style="display:flex; gap:6px;"` rather than a class; bump to the 8px minimum spacing
   between adjacent touch targets without having to touch every page individually. */
[style*="display:flex; gap:6px"] { gap: 8px !important; }
