/* ==========================================================
   Froster — design system
   One stylesheet, two directions (RTL/LTR), two themes.
   Direction is handled with CSS logical properties, so there
   is no separate rtl.css to keep in sync.
   ========================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  --gold:        #C9A227;
  --gold-soft:   #E0BE4A;
  --gold-deep:   #9A7B18;

  --ok:      #2E9E6B;
  --warn:    #D9922B;
  --danger:  #D14343;
  --info:    #4A79C4;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.12);
  --shadow:    0 4px 16px rgba(0,0,0,.14);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.24);

  --ease: cubic-bezier(.22,.61,.36,1);
  --t-fast: .15s var(--ease);
  --t:      .28s var(--ease);

  --container: 1320px;
  --header-h: 68px;

  --font-body: "IBM Plex Sans Arabic", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Cormorant Garamond", "IBM Plex Sans Arabic", Georgia, serif;
}

/* Arabic headings look better in the sans face than in a Latin serif */
html[lang="ar"] { --font-display: "IBM Plex Sans Arabic", system-ui, sans-serif; }

/* ---------- 2. Themes ---------- */
html[data-theme="dark"] {
  --bg:        #0B0B0C;
  --surface:   #141416;
  --elevated:  #1C1C1F;
  --sunken:    #08080A;
  --text:      #F4F4F2;
  --text-2:    #C4C4C6;
  --muted:     #8E8E94;
  --border:    #2A2A2E;
  --border-2:  #3A3A40;
  --accent:    var(--gold-soft);
  --accent-ink:#0B0B0C;
  --overlay:   rgba(0,0,0,.7);
  --skeleton:  linear-gradient(90deg,#1A1A1D 25%,#232326 37%,#1A1A1D 63%);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg:        #FFFFFF;
  --surface:   #FAFAF8;
  --elevated:  #FFFFFF;
  --sunken:    #F3F3F0;
  --text:      #131315;
  --text-2:    #3C3C40;
  --muted:     #6E6E74;
  --border:    #E4E4E0;
  --border-2:  #D2D2CD;
  --accent:    var(--gold-deep);
  --accent-ink:#FFFFFF;
  --overlay:   rgba(10,10,12,.5);
  --skeleton:  linear-gradient(90deg,#EFEFEC 25%,#F7F7F5 37%,#EFEFEC 63%);
  color-scheme: light;
}

/* ---------- 3. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color var(--t), color var(--t);
  /* Off-canvas drawers sit outside the viewport via transform, which would
     otherwise add horizontal scroll. `clip` removes it WITHOUT creating a
     scroll container, so position:sticky keeps working (overflow:hidden
     would break the sticky sidebar and table headers). */
  overflow-x: clip;
}
img, picture, svg, video { display: block; max-width: 100%; }
/* Baseline for inline icons; component rules below are more specific and override it. */
svg { width: 1.15em; height: 1.15em; flex: none; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
table { border-collapse: collapse; width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.25; }
h1 { font-size: clamp(1.9rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.15rem); }
h3 { font-size: 1.2rem; }

/* ---------- 4. Layout ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 20px; }
.container-sm { max-width: 760px; }
.section { padding-block: clamp(40px, 6vw, 76px); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.section-head h2 { letter-spacing: .01em; }
.section-head .eyebrow { color: var(--accent); font-size: .78rem; letter-spacing: .18em; text-transform: uppercase; margin-bottom: 6px; }
.grid { display: grid; gap: 20px; }
/* Grid and flex children default to min-width:auto, so anything with a wide
   intrinsic size — a datetime-local input, a data table — refuses to shrink
   and pushes the whole layout sideways. Every grid container in the project
   opts its children out. */
.grid > *, .flex > * { min-width: 0; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-6{gap:6px}.gap-10{gap:10px}.gap-16{gap:16px}.gap-24{gap:24px}
.wrap { flex-wrap: wrap; }
.mt-8{margin-top:8px}.mt-16{margin-top:16px}.mt-24{margin-top:24px}.mt-32{margin-top:32px}
.mb-8{margin-bottom:8px}.mb-16{margin-bottom:16px}.mb-24{margin-bottom:24px}
.text-c { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny  { font-size: .76rem; }
.bold  { font-weight: 600; }
.hide  { display: none !important; }
.nowrap{ white-space: nowrap; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: var(--radius);
  font-size: .92rem; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: var(--accent); color: var(--accent-ink); }
.btn-gold { background: var(--accent); color: var(--accent-ink); }
.btn-gold:hover { filter: brightness(1.08); }
.btn-outline { border-color: var(--border-2); color: var(--text); background: transparent; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: .82rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 30px; font-size: 1rem; }
.btn-icon { padding: 9px; border-radius: var(--radius-pill); }

/* ---------- 6. Forms ---------- */
.field { margin-bottom: 16px; }
.field > label, .label {
  display: block; font-size: .84rem; font-weight: 600;
  margin-bottom: 7px; color: var(--text-2);
}
.label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; max-width: 100%; padding: 11px 14px;
  background: var(--elevated); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-2); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.textarea { min-height: 110px; resize: vertical; }
.select {
  appearance: none; padding-inline-end: 38px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E8E94' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 18px;
  background-position: right 12px center;
}
html[dir="rtl"] .select { background-position: left 12px center; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: .78rem; margin-top: 5px; }
.help-text { color: var(--muted); font-size: .78rem; margin-top: 5px; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: .88rem; }
.check input[type=checkbox], .check input[type=radio] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; flex: none; }
.input-group { display: flex; }
.input-group .input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group .btn { border-start-start-radius: 0; border-end-start-radius: 0; }

/* ---------- 7. Cards & surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.card-head h3 { font-family: var(--font-body); font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: .74rem; font-weight: 600; letter-spacing: .02em;
  background: var(--sunken); color: var(--text-2); border: 1px solid var(--border);
}
.badge-ok    { background: color-mix(in srgb, var(--ok) 16%, transparent);    color: var(--ok);    border-color: color-mix(in srgb, var(--ok) 32%, transparent); }
.badge-warn  { background: color-mix(in srgb, var(--warn) 16%, transparent);  color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.badge-danger{ background: color-mix(in srgb, var(--danger) 16%, transparent);color: var(--danger);border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.badge-info  { background: color-mix(in srgb, var(--info) 16%, transparent);  color: var(--info);  border-color: color-mix(in srgb, var(--info) 32%, transparent); }
.badge-accent{ background: color-mix(in srgb, var(--accent) 16%, transparent);color: var(--accent);border-color: color-mix(in srgb, var(--accent) 34%, transparent); }
.badge-muted { color: var(--muted); }

.alert { padding: 13px 16px; border-radius: var(--radius); border: 1px solid; display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; margin-bottom: 16px; }
.alert svg { width: 19px; height: 19px; flex: none; margin-top: 2px; }
.alert-success { background: color-mix(in srgb, var(--ok) 12%, transparent);     border-color: color-mix(in srgb, var(--ok) 34%, transparent);     color: var(--ok); }
.alert-error   { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 34%, transparent); color: var(--danger); }
.alert-warning { background: color-mix(in srgb, var(--warn) 12%, transparent);   border-color: color-mix(in srgb, var(--warn) 34%, transparent);   color: var(--warn); }
.alert-info    { background: color-mix(in srgb, var(--info) 12%, transparent);   border-color: color-mix(in srgb, var(--info) 34%, transparent);   color: var(--info); }

.empty-state { text-align: center; padding: 60px 20px; }
.empty-state svg { width: 62px; height: 62px; margin: 0 auto 18px; color: var(--muted); opacity: .55; }
.empty-state h3 { font-family: var(--font-body); margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin-bottom: 20px; }

/* ---------- 8. Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); }
.table { font-size: .88rem; }
.table th {
  text-align: start; padding: 12px 14px; font-weight: 600; font-size: .78rem;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  background: var(--sunken); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--elevated); }
.table .num { font-variant-numeric: tabular-nums; }

/* ---------- 9. Utilities ---------- */
.divider { height: 1px; background: var(--border); margin-block: 20px; border: 0; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border-2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: var(--skeleton); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
