/**
 * Design system for the dashboard.
 *
 * Tokens are declared once and consumed by every component, so light/dark and
 * RTL/LTR are a single `data-*` attribute flip on <html> rather than a second
 * stylesheet. Colours are chosen for contrast on both surfaces; the accent is
 * the same hue family as the Flutter app so the two clients look like one
 * product.
 */

:root {
  /* Neutrals - light */
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --bg-sunken: #eef0f6;
  --bg-hover: #f2f4f9;

  --border: #e3e7ef;
  --border-strong: #cfd6e4;

  --text: #131722;
  --text-muted: #5b6478;
  --text-subtle: #8a93a6;
  --text-inverse: #ffffff;

  /* Brand: indigo → violet, matching the Flutter app */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --accent-contrast: #ffffff;

  --success: #0f9d58;
  --success-soft: #e7f6ee;
  --warning: #b45309;
  --warning-soft: #fdf3e3;
  --danger: #d92d20;
  --danger-soft: #fdeceb;
  --info: #0e7490;
  --info-soft: #e5f6fa;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  --sidebar-w: 260px;
  --topbar-h: 64px;

  --font-sans: "Inter", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 180ms;
}

[data-theme="dark"] {
  --bg: #0b0d13;
  --bg-elevated: #12151e;
  --bg-sunken: #0e1017;
  --bg-hover: #1a1f2b;

  --border: #232936;
  --border-strong: #323b4d;

  --text: #eef1f8;
  --text-muted: #9aa3b8;
  --text-subtle: #6b7488;
  --text-inverse: #0b0d13;

  --accent: #7c7bef;
  --accent-hover: #9391f5;
  --accent-soft: #1c1d3a;
  --accent-contrast: #ffffff;

  --success: #34d399;
  --success-soft: #10281f;
  --warning: #fbbf24;
  --warning-soft: #2a2110;
  --danger: #f87171;
  --danger-soft: #2c1315;
  --info: #38bdf8;
  --info-soft: #0d2430;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

/* Arabic needs looser leading and no negative tracking; the script has deeper
   descenders and its glyphs join, so tracking would sever the strokes. */
html[lang="ar"] body {
  font-family: "IBM Plex Sans Arabic", var(--font-sans);
  line-height: 1.7;
  letter-spacing: 0;
}

/* Numerals stay Latin everywhere: Arabic-Indic digits inside tables of money
   are harder to compare at a glance, and the ledger uses Latin digits too. */
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

h1, h2, h3, h4, p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid var(--bg);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}

/* --------------------------------------------------------------- utilities */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.stack {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  align-items: center;
}

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.muted {
  color: var(--text-muted);
}

.subtle {
  color: var(--text-subtle);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
