/* Shared design tokens and base components (RTL, Persian). Page-specific styles: book.css, admin.css */
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --text: #1c2030;
  --text-muted: #646b82;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-contrast: #ffffff;
  --primary-soft: #eef0ff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --success: #15803d;
  --success-soft: #e8f6ee;
  --warning: #b45309;
  --warning-soft: #fdf3e2;
  --busy: #f97316;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --font: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1220;
    --surface: #171b2e;
    --surface-2: #1f2440;
    --border: #2b3152;
    --text: #e8eaf4;
    --text-muted: #9aa1bd;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-contrast: #0f1220;
    --primary-soft: #23284a;
    --danger: #f87171;
    --danger-soft: #3a1d24;
    --success: #4ade80;
    --success-soft: #16301f;
    --warning: #fbbf24;
    --warning-soft: #352a12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
/* Chosen in the theme switch (static/theme.js); without a choice the system setting applies. */
:root[data-theme="dark"] {
  --bg: #0f1220;
  --surface: #171b2e;
  --surface-2: #1f2440;
  --border: #2b3152;
  --text: #e8eaf4;
  --text-muted: #9aa1bd;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-contrast: #0f1220;
  --primary-soft: #23284a;
  --danger: #f87171;
  --danger-soft: #3a1d24;
  --success: #4ade80;
  --success-soft: #16301f;
  --warning: #fbbf24;
  --warning-soft: #352a12;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  direction: rtl;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--text-muted); }
.ltr { direction: ltr; unicode-bidi: embed; text-align: left; }
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .5em 1em; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--primary); color: var(--primary-contrast);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); }
.btn-sm { padding: .25em .7em; font-size: .9em; }

label { display: block; font-weight: 600; margin-bottom: .25em; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=url], input[type=search],
input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .45em .7em;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
.field { margin-bottom: 12px; }
.field .hint { font-size: .85em; color: var(--text-muted); margin-top: .2em; }
.checkbox { display: flex; align-items: center; gap: .5em; font-weight: 500; }

table.table { width: 100%; border-collapse: collapse; }
table.table th, table.table td { padding: .55em .6em; border-bottom: 1px solid var(--border); text-align: right; vertical-align: top; }
table.table th { color: var(--text-muted); font-weight: 600; font-size: .9em; }

.badge { display: inline-block; padding: .05em .6em; border-radius: 999px; font-size: .8em; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

.alert { border-radius: var(--radius-sm); padding: .7em 1em; margin-bottom: 12px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--primary-soft); color: var(--primary); }

[hidden] { display: none !important; }
.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;
}

/* icons */
.ic { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.ic-sm { width: 14px; height: 14px; vertical-align: -2px; }
.ic-fill { fill: currentColor; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  cursor: pointer; font: inherit;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* theme switch: shows the icon of the current choice (auto / light / dark) */
.theme-toggle .ic { display: none; }
:root:not([data-theme-choice]) .theme-toggle .ti-auto, :root[data-theme-choice="auto"] .theme-toggle .ti-auto,
:root[data-theme-choice="light"] .theme-toggle .ti-light, :root[data-theme-choice="dark"] .theme-toggle .ti-dark { display: inline-block; }

@media (max-width: 640px) {
  body { font-size: 14px; }
  .container { padding: 12px; }
}
