/* Ritme admin panel — self-contained RTL stylesheet.
   The production server has no international connectivity, so everything here
   (including the webfont) ships with the image; nothing is loaded from a CDN.

   Design: a deep-rose gradient "spine" on the trailing edge, a warm lavender
   canvas, white paper cards, and turquoise reserved for data/numbers. */

/* ---------- Font (served through /admin/fonts/*, see routes/admin.php) ---------- */
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f4f9;
  --bg-tint: #efeaf4;
  --surface: #ffffff;
  --surface-2: #faf8fc;
  --border: #eae5f0;
  --border-strong: #ddd5e6;
  --text: #1e1a24;
  --text-muted: #6f6880;

  --primary: #e11d67;
  --primary-dark: #a8114b;
  --primary-soft: #fdeaf1;
  --primary-ring: rgba(225, 29, 103, .18);

  --accent: #0d9488;          /* turquoise — data & numbers */
  --accent-soft: #e0f5f2;

  --success: #12855a;
  --success-soft: #e3f5ec;
  --warning: #a9740a;
  --warning-soft: #fdf3dd;
  --danger: #cf2f3a;
  --danger-soft: #fce9ea;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --shadow-sm: 0 1px 2px rgba(30, 20, 45, .05);
  --shadow: 0 1px 2px rgba(30, 20, 45, .04), 0 6px 20px -6px rgba(30, 20, 45, .10);
  --shadow-lg: 0 2px 6px rgba(30, 20, 45, .06), 0 24px 48px -18px rgba(30, 20, 45, .22);

  --sidebar-w: 264px;
  --spine: linear-gradient(200deg, #f2588f 0%, #e11d67 42%, #a8114b 100%);

  --font: Vazirmatn, "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;

  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }

/* Layout classes below set `display: flex`, which outranks the UA stylesheet's
   `[hidden] { display: none }` — so without this, setting `element.hidden` on a
   .field or .check-item does nothing. Any script that filters a form (e.g. the
   recommendation sub-phase picker) relies on it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.75;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* A soft rose bloom behind the canvas so the page never reads as flat grey. */
body::before {
  content: '';
  position: fixed;
  inset-block-start: -220px;
  inset-inline-end: -120px;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(225, 29, 103, .10), transparent 68%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3 { letter-spacing: -.015em; }

/* ---------- Layout shell ---------- */
.layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ---------- Sidebar: the rose spine ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--spine);
  color: #fff;
  padding: 22px 14px 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .35) transparent;
  box-shadow: -18px 0 44px -28px rgba(168, 17, 75, .8);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .3); border-radius: 999px; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 20px;
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -.02em;
  color: #fff;
}
.brand .dot {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .35);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45);
}
.brand .dot::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, .9);
}
.brand small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .04em;
  opacity: .75;
  line-height: 1.2;
}

.nav-group-title {
  font-size: 10.5px;
  color: rgba(255, 255, 255, .62);
  font-weight: 700;
  padding: 16px 12px 7px;
  letter-spacing: .09em;
}
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .88);
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: background .16s var(--ease), color .16s var(--ease), transform .16s var(--ease);
}
.nav-link svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .82; }
.nav-link:hover {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  text-decoration: none;
}
.nav-link:active { transform: scale(.985); }
.nav-link.active {
  background: rgba(255, 255, 255, .96);
  color: var(--primary-dark);
  font-weight: 700;
  box-shadow: 0 6px 16px -8px rgba(80, 0, 35, .7);
}
.nav-link.active svg { opacity: 1; }
/* Rail sits on the sidebar's outer edge (the window edge in RTL), not the
   content edge — otherwise it bleeds over the page. */
.nav-link.active::before {
  content: '';
  position: absolute;
  inset-inline-start: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
}
.nav-link .badge { margin-inline-start: auto; }
.nav-link.danger { color: rgba(255, 255, 255, .8); }
.nav-link.danger:hover { background: rgba(0, 0, 0, .18); color: #fff; }

.sidebar-sep { height: 1px; background: rgba(255, 255, 255, .18); margin: 16px 10px 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar (translucent, content scrolls under) ---------- */
.topbar {
  min-height: 64px;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid rgba(234, 229, 240, .9);
  display: flex;
  align-items: center;
  padding: 0 26px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 800; }
.topbar .spacer { flex: 1; }
.topbar .who {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  box-shadow: var(--shadow-sm);
}
.topbar .who .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--spine);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.content { padding: 26px; max-width: 1280px; width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden;
}
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 800; }
.card-head .spacer { flex: 1; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ---------- Hero greeting (dashboard) ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--spine);
  color: #fff;
  padding: 26px 28px;
  margin-bottom: 22px;
  box-shadow: 0 18px 40px -22px rgba(168, 17, 75, .9);
}
.hero::after {
  content: '';
  position: absolute;
  inset-block-start: -90px;
  inset-inline-start: -40px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 65%);
  pointer-events: none;
}
.hero h2 { margin: 0 0 6px; font-size: 23px; font-weight: 800; letter-spacing: -.02em; }
.hero p { margin: 0; opacity: .88; font-size: 13.5px; max-width: 62ch; }
.hero .hero-meta { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; position: relative; }
.hero .chip {
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 600;
}

/* ---------- Stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.stat::before {
  content: '';
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 3px;
  background: var(--spine);
  opacity: .85;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat .label {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
}
.stat .label svg { width: 15px; height: 15px; color: var(--primary); }
.stat .value {
  font-size: 34px;
  font-weight: 800;
  margin-top: 8px;
  line-height: 1.1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.stat .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat.is-alert .value { color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td {
  padding: 13px 18px;
  text-align: start;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: .02em;
  position: sticky;
  top: 0;
}
table.data tbody tr { transition: background .14s var(--ease); }
table.data tbody tr:hover { background: var(--primary-soft); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.wrap { white-space: normal; }
table.data td { font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--bg-tint);
  color: var(--text-muted);
  border: 1px solid transparent;
}
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.pink { background: var(--primary-soft); color: var(--primary-dark); }
.badge.teal { background: var(--accent-soft); color: var(--accent); }
/* Inside the rose spine, badges need their own contrast. */
.sidebar .badge { background: rgba(255, 255, 255, .22); color: #fff; }
.nav-link.active .badge { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 17px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .14s var(--ease), border-color .14s var(--ease),
              transform .12s var(--ease), box-shadow .14s var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary-dark); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--spine);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(168, 17, 75, .9);
}
.btn.primary:hover { color: #fff; filter: brightness(1.06); border-color: transparent; }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.danger:hover { color: #fff; filter: brightness(.94); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--primary); padding-inline: 9px; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Inline filter/search controls sit in a row — they must not stretch to 100%
   like they do inside a .field column. */
.card-head input, .card-head select, .page-actions input, .page-actions select,
.btn-row input, .btn-row select { width: auto; padding-block: 8px; }
.card-head form.btn-row { flex-wrap: nowrap; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.field label { font-weight: 700; font-size: 12.5px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-muted); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=search], input[type=tel], select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease), background .14s var(--ease);
}
input::placeholder, textarea::placeholder { color: #a49ab3; }
input:hover, select:hover, textarea:hover { border-color: #c9bfd6; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.9; }
.field .err { color: var(--danger); font-size: 12.5px; font-weight: 600; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; }

.switch-row { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--primary); }

/* Multi-select grid (e.g. the article phase picker) */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .14s var(--ease);
}
.check-item:hover { background: var(--surface); }
.check-item input { width: 17px; height: 17px; accent-color: var(--primary); flex: 0 0 auto; }
.check-item:has(input:checked) { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }

input[type=file] {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 13px;
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
input[type=file]:hover { border-color: var(--primary); background: var(--primary-soft); }
input[type=file]::file-selector-button {
  margin-inline-end: 10px;
  padding: 6px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Rich-text editor (bundled CKEditor 4) ---------- */
.cke.cke_chrome {
  max-width: 100%;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-sm);
  box-shadow: none;
  overflow: hidden;
}
.cke_top, .cke_bottom { background: var(--surface-2) !important; border-color: var(--border) !important; }
.cke_button__source_label, .cke_button_label { font-family: var(--font); }

/* ---------- Alerts ---------- */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-weight: 600;
  border: 1px solid transparent;
  border-inline-start-width: 4px;
}
.alert.success { background: var(--success-soft); color: var(--success); border-inline-start-color: var(--success); }
.alert.error { background: var(--danger-soft); color: var(--danger); border-inline-start-color: var(--danger); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
  background: var(--spine);
}
/* Two soft blooms give the rose field depth without a busy pattern. */
.login-wrap::before,
.login-wrap::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.login-wrap::before {
  width: 720px; height: 720px;
  inset-block-start: -260px; inset-inline-end: -200px;
  background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 62%);
}
.login-wrap::after {
  width: 560px; height: 560px;
  inset-block-end: -220px; inset-inline-start: -160px;
  background: radial-gradient(circle, rgba(13, 148, 136, .30), transparent 64%);
}
.login-card { width: 100%; max-width: 400px; position: relative; z-index: 1; }
.login-card .card {
  border: 1px solid rgba(255, 255, 255, .5);
  box-shadow: var(--shadow-lg);
  margin-bottom: 0;
}
.login-card .card-body { padding: 30px 28px; }
.login-card .brand {
  justify-content: center;
  font-size: 25px;
  padding: 4px 0 12px;
  color: var(--primary-dark);
}
.login-card .brand .dot {
  background: var(--spine);
  border-color: transparent;
  box-shadow: 0 8px 18px -8px rgba(168, 17, 75, .9);
  width: 34px; height: 34px;
}
.login-sub { text-align: center; color: var(--text-muted); margin: -4px 0 22px; font-size: 13px; }
.login-foot { text-align: center; margin-top: 18px; font-size: 12px; color: rgba(255, 255, 255, .8); }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.empty { text-align: center; padding: 46px 20px; color: var(--text-muted); }
/* `table.data td` sets text-align:start and outranks .empty on its own. */
table.data td.empty { text-align: center; white-space: normal; }
.page-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-actions .spacer { flex: 1; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tab {
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text-muted);
  transition: background .14s var(--ease), color .14s var(--ease);
}
.tab:hover { text-decoration: none; color: var(--primary); border-color: var(--primary); }
.tab.active { background: var(--spine); color: #fff; border-color: transparent; }
.tab.active:hover { color: #fff; }
.pagination { display: flex; gap: 6px; margin: 18px 20px 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
}
.pagination a:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.pagination .active span { background: var(--spine); color: #fff; border-color: transparent; }

/* Mobile drawer scrim */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 45, .42);
  backdrop-filter: blur(2px);
  z-index: 40;
}
.menu-toggle { display: none; }

@media (max-width: 900px) {
  .content { padding: 18px; }
  .topbar { padding: 0 16px; }
  .topbar .who span.name { display: none; }
  .sidebar {
    position: fixed;
    inset-inline-end: calc(-1 * var(--sidebar-w) - 20px);
    transition: inset-inline-end .32s var(--ease);
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { inset-inline-end: 0; }
  .sidebar.open ~ .scrim, body.nav-open .scrim { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex !important; }
  .hero { padding: 22px 20px; }
  .hero h2 { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .stat:hover { transform: none; }
}
