/* =========================================================
   Theme tokens + base components (shared by site and admin)
   Dark blue is the default theme; light mode via [data-theme="light"].
   ========================================================= */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #061128;
  --bg-elev: #081734;
  --surface: #0c1f45;
  --surface-2: #10285a;
  --surface-3: #15326c;
  --border: #1b376c;
  --border-strong: #2a4b8a;
  --text: #e9effc;
  --text-2: #b9c7e3;
  --muted: #8598c0;
  --primary: #3d7bff;
  --primary-hover: #5b8fff;
  --primary-ink: #ffffff;
  --primary-soft: rgba(61, 123, 255, 0.16);
  --accent: #3dd6f5;
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.15);
  --warning: #f5a524;
  --warning-soft: rgba(245, 165, 36, 0.15);
  --danger: #f05252;
  --danger-soft: rgba(240, 82, 82, 0.15);
  --info-soft: rgba(61, 214, 245, 0.14);
  --img-bg: radial-gradient(120% 90% at 50% 15%, #173a7a 0%, #0d2250 55%, #0a1a3d 100%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.45);
  --input-bg: #0a1b3d;
  --skeleton: #132d61;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fc;
  --bg-elev: #e9eff9;
  --surface: #ffffff;
  --surface-2: #f3f7fe;
  --surface-3: #e7eefa;
  --border: #dbe4f3;
  --border-strong: #c2d0ea;
  --text: #0a1a3d;
  --text-2: #34486f;
  --muted: #5f7298;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: rgba(29, 78, 216, 0.09);
  --accent: #0891b2;
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.1);
  --warning: #c27803;
  --warning-soft: rgba(245, 165, 36, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --info-soft: rgba(8, 145, 178, 0.1);
  --img-bg: radial-gradient(120% 90% at 50% 15%, #ffffff 0%, #eef3fc 60%, #e2eaf8 100%);
  --shadow-sm: 0 1px 3px rgba(15, 35, 80, 0.08);
  --shadow: 0 10px 30px rgba(15, 35, 80, 0.1);
  --shadow-lg: 0 24px 60px rgba(15, 35, 80, 0.16);
  --input-bg: #ffffff;
  --skeleton: #e6edf9;
}

/* Brand navy stays the same in both modes (header, footer, hero, sidebar) */
:root {
  --navy-950: #040c1f;
  --navy-900: #071531;
  --navy-800: #0a1f4a;
  --navy-700: #0f2d6b;
  --navy-600: #173d8f;
  --on-navy: #eaf0ff;
  --on-navy-2: #a9bbe0;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --container: 1240px;
  --header-h: 72px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden; /* fallback */
  overflow-x: clip;   /* off-canvas drawers must not create horizontal scroll (esp. in RTL) */
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }

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

.icon { flex-shrink: 0; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

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

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 20px; }
.container-narrow { max-width: 820px; }

/* Theme toggle icon visibility */
[data-theme="dark"] .only-light,
[data-theme="light"] .only-dark { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600; font-size: 14.5px; white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.1s, box-shadow 0.18s;
  background: var(--surface-2); color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 18px -6px rgba(61, 123, 255, 0.6); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn-light { background: #fff; color: var(--navy-800); }
.btn-light:hover { background: #e9f0ff; }
.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.45); }
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.1); border-color: #fff; }
.btn-success { background: #1fa855; color: #fff; }
.btn-success:hover { background: #1a9149; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 15.5px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.6; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: inherit;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; line-height: 1.4; letter-spacing: 0.02em;
}
.badge-new { background: #3dd6f5; color: #04263a; }
.badge-sale { background: var(--danger); color: #fff; }
.badge-muted { background: var(--surface-3); color: var(--text-2); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--primary-soft); color: var(--primary); }

.cond {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
}
.cond::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.cond-like_new { color: var(--success); background: var(--success-soft); }
.cond-excellent { color: var(--accent); background: var(--info-soft); }
.cond-good { color: var(--warning); background: var(--warning-soft); }
.cond-fair { color: #f97316; background: rgba(249, 115, 22, 0.13); }

/* ---------- Cards & alerts ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; margin: 16px 0;
  border-radius: var(--radius-sm);
  border: 1px solid; font-weight: 500;
}
.alert .icon { margin-top: 3px; }
.alert-success { background: var(--success-soft); border-color: rgba(34, 197, 94, 0.35); color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: rgba(240, 82, 82, 0.35); color: var(--danger); }
.alert-info { background: var(--primary-soft); border-color: rgba(61, 123, 255, 0.35); color: var(--primary); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small, .hint { font-size: 12.5px; color: var(--muted); }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"],
input[type="search"], input[type="url"], input[type="datetime-local"], textarea, select {
  width: 100%; min-height: 44px; padding: 10px 14px;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color 0.18s, box-shadow 0.18s;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); }

.select { position: relative; display: block; }
.select select { appearance: none; -webkit-appearance: none; padding-inline-end: 38px; cursor: pointer; }
.select::after {
  content: ""; position: absolute; inset-inline-end: 15px; top: 50%;
  width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}
.select-sm select { min-height: 38px; padding-block: 6px; font-size: 14px; }

.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-size: 14.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.check small { margin-inline-start: auto; color: var(--muted); font-size: 12.5px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 40px; height: 22px; flex-shrink: 0;
  border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong);
  transition: background 0.2s;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s var(--ease);
}
.switch input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + .switch-track::after { transform: translateX(-18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }

.chip-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check span {
  display: inline-block; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: all 0.15s;
}
.chip-check input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-check input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Tables ---------- */
.table { width: 100%; font-size: 14px; }
.table th, .table td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }
