/* ==========================================================================
   Aurora Finance — design tokens + component styles
   Tailwind (Play CDN) maps semantic utilities (bg-page, text-ink, …) to the
   CSS variables below, so flipping .dark on <html> re-themes the whole page
   without any dark: variants for colors.
   ========================================================================== */

:root {
  --page: #F5F7FA;
  --surface: #FFFFFF;
  --line: #E4E8EF;
  --ink: #0F172A;
  --sub: #64748B;
  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --accent-soft: #EEF2FF;
  --on-accent: #FFFFFF;
  --success: #059669;
  --warning: #D97706;
  --danger: #E11D48;
  /* Text-on-tint variants: the base hues dip below 4.5:1 on their soft pill
     backgrounds, so small text (pills, signed amounts) uses these 700/800
     shades instead — all ≥4.4:1 on their composite tints (WCAG AA). */
  --success-text: #047857;
  --warning-text: #92400E;
  --danger-text: #BE123C;
  --sub-strong: #475569;
  --success-soft: rgb(5 150 105 / .10);
  --warning-soft: rgb(217 119 6 / .12);
  --danger-soft: rgb(225 29 72 / .10);
  --neutral-soft: #F1F5F9;
  --track: #E2E8F0;
  --row-hover: #F8FAFC;
  --shadow-card: 0 1px 2px rgb(15 23 42 / .05), 0 4px 16px -4px rgb(15 23 42 / .06);
  --shadow-lift: 0 2px 4px rgb(15 23 42 / .06), 0 12px 28px -6px rgb(15 23 42 / .12);
}

.dark {
  --page: #0B0E13;
  --surface: #141A23;
  --line: #242E3B;
  --ink: #F1F5F9;
  --sub: #94A3B8;
  --accent: #818CF8;
  --accent-hover: #A5B4FC;
  --accent-soft: rgb(129 140 248 / .12);
  --on-accent: #10131B; /* near-black text on the lighter dark accent keeps buttons ≥7:1 */
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #FB7185;
  /* Dark tints already pass AA as-is (≥5.5:1), so text variants mirror them. */
  --success-text: #34D399;
  --warning-text: #FBBF24;
  --danger-text: #FB7185;
  --sub-strong: #94A3B8;
  --success-soft: rgb(52 211 153 / .12);
  --warning-soft: rgb(251 191 36 / .13);
  --danger-soft: rgb(251 113 133 / .12);
  --neutral-soft: rgb(148 163 184 / .12);
  --track: #334155;
  --row-hover: rgb(148 163 184 / .06);
  --shadow-card: 0 1px 2px rgb(0 0 0 / .45), 0 8px 24px -8px rgb(0 0 0 / .50);
  --shadow-lift: 0 2px 6px rgb(0 0 0 / .55), 0 16px 32px -8px rgb(0 0 0 / .60);
}

/* Native form controls / scrollbars follow the theme */
html { color-scheme: light; }
html.dark { color-scheme: dark; }

body {
  background: var(--page);
  color: var(--ink);
  transition: background-color .2s ease, color .2s ease; /* no global * transition */
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  transition: background-color .2s ease, border-color .2s ease;
}
.card-lift {
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease;
}
@media (hover: hover) {
  .card-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
}

/* ---------- Buttons / inputs ---------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background-color .15s ease;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn-secondary:hover:not(:disabled) { background: var(--row-hover); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--sub);
  transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}
.icon-btn:hover { color: var(--ink); background: var(--row-hover); }

/* Desktop-only theme toggle (mobile uses the top-bar toggle). A class beats
   Tailwind's `hidden` here because this stylesheet loads after the CDN. */
.theme-toggle-desktop { display: none; }
@media (min-width: 1024px) { .theme-toggle-desktop { display: inline-flex; } }

.input {
  width: 100%; min-height: 44px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 14px; padding: 0 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--sub); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.select {
  min-height: 44px; appearance: none; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 14px; padding: 0 36px 0 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Pills & chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 9999px; padding: 4px 10px;
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
}
.pill-success { background: var(--success-soft); color: var(--success-text); }
.pill-warning { background: var(--warning-soft); color: var(--warning-text); }
.pill-danger { background: var(--danger-soft); color: var(--danger-text); }
.pill-neutral { background: var(--neutral-soft); color: var(--sub-strong); }

.chip {
  display: inline-block; margin-top: 4px; border-radius: 9999px;
  background: var(--accent-soft); color: var(--accent);
  padding: 2px 8px; font-size: 11px; font-weight: 500; line-height: 16px;
}

/* ---------- Sidebar / nav ---------- */
.nav-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: 10px;
  font-size: 14px; font-weight: 500; color: var(--sub);
  transition: background-color .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--row-hover); color: var(--ink); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

#sidebar { transition: transform .25s ease, width .2s ease; }
#collapse-icon { transition: transform .2s ease; }

/* Off-canvas drawer below lg */
@media (max-width: 1023.98px) {
  #sidebar { transform: translateX(-100%); }
  html.drawer-open #sidebar { transform: translateX(0); }
}

/* Collapsed 76px icon rail, desktop only */
@media (min-width: 1024px) {
  html.sidebar-collapsed #sidebar { width: 76px; }
  html.sidebar-collapsed #sidebar .nav-text,
  html.sidebar-collapsed #sidebar #promo-card,
  html.sidebar-collapsed #sidebar #sidebar-wordmark { display: none; }
  html.sidebar-collapsed #sidebar .nav-link { justify-content: center; gap: 0; padding: 0; }
  html.sidebar-collapsed #sidebar #collapse-icon { transform: rotate(180deg); }
  html.sidebar-collapsed #content { padding-left: 76px; }
}

/* ---------- Transactions table ---------- */
.tx-table thead th {
  padding: 10px 16px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--sub);
}
.tx-table thead th[data-col] { padding: 0; } /* sort button provides its own padding */
.tx-table tbody td { padding: 14px 16px; }
.tx-table th:first-child, .tx-table td:first-child { padding-left: 20px; }
.tx-table th:last-child, .tx-table td:last-child { padding-right: 20px; }
.tx-table thead th[data-col]:first-child .sort-btn { padding-left: 20px; }
@media (min-width: 640px) {
  .tx-table th:first-child, .tx-table td:first-child { padding-left: 24px; }
  .tx-table th:last-child, .tx-table td:last-child { padding-right: 24px; }
  .tx-table thead th[data-col]:first-child .sort-btn { padding-left: 24px; }
}

.sort-btn {
  display: flex; width: 100%; align-items: center; gap: 6px;
  min-height: 44px; padding: 10px 16px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--sub); cursor: pointer; text-align: left;
  transition: color .15s ease;
}
.sort-btn:hover { color: var(--ink); }

.tx-table tbody td.tx-empty { padding: 40px 16px; text-align: center; color: var(--sub); }

/* ---------- Budget bars ---------- */
.budget-fill { transition: width 1s cubic-bezier(.22, .61, .36, 1); }

/* ---------- Skip link ---------- */
.skip-link {
  position: fixed; top: -56px; left: 16px; z-index: 60;
  padding: 10px 16px; border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
  font-size: 14px; font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus-visible { top: 12px; }

/* Focus ring: 2px accent + 2px offset — visible on both themes, meets WCAG 2.2
   focus appearance. Dark mode adds a contrasting light outer ring. Kept last so
   it wins over component focus box-shadows. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.dark :focus-visible {
  box-shadow: 0 0 0 4px rgb(241 245 249 / .18);
}

/* ---------- Reduced motion: no count-up, bar grow, or hover lifts ---------- */
@media (prefers-reduced-motion: reduce) {
  .card-lift, .card-lift:hover { transform: none; }
  .budget-fill { transition: none; }
  .skip-link { transition: none; }
}
