/* Ritme admin panel — self-contained RTL stylesheet (no external assets:
   the production server has no international connectivity, so no CDN fonts). */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --border: #e6e6ec;
  --text: #1d1d23;
  --text-muted: #6b6b78;
  --primary: #e11d67;
  --primary-dark: #b3134f;
  --primary-soft: #fdeaf1;
  --success: #159a5a;
  --success-soft: #e5f5ec;
  --warning: #b8860b;
  --warning-soft: #fdf3dd;
  --danger: #d13438;
  --danger-soft: #fce8e8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .04), 0 4px 16px rgba(20, 20, 40, .05);
  --font: Vazirmatn, "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
}

* { 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.7;
  direction: rtl;
}

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

/* ---------- Layout shell ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  font-weight: 800;
  font-size: 20px;
  color: var(--primary);
}
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); }

.nav-group-title {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  padding: 14px 12px 6px;
  letter-spacing: .02em;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
.nav-link .badge { margin-inline-start: auto; }

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

.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-muted); font-size: 13px; }

.content { padding: 24px; max-width: 1200px; width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.card-head .spacer { flex: 1; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ---------- Stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--text-muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td {
  padding: 12px 16px;
  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: 12.5px;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.wrap { white-space: normal; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-muted);
}
.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); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.94); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); padding-inline: 8px; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 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: 600; font-size: 13px; }
.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], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.8; }
.field .err { color: var(--danger); font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.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: 5px 6px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.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: 600; }

input[type=file] {
  width: 100%;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 13px;
}
input[type=file]::file-selector-button {
  margin-inline-end: 10px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- Rich-text editor (bundled CKEditor 4) ---------- */
.cke.cke_chrome {
  max-width: 100%;
  border: 1px solid var(--border) !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: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 600; }
.alert.success { background: var(--success-soft); color: var(--success); }
.alert.error { background: var(--danger-soft); color: var(--danger); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; font-size: 24px; padding-top: 6px; }
.login-sub { text-align: center; color: var(--text-muted); margin: -6px 0 20px; }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.page-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-actions .spacer { flex: 1; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tab { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 13px; color: var(--text-muted); }
.tab.active { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary-soft); }
.pagination { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-size: 13px; }
.pagination .active span { background: var(--primary); color: #fff; border-color: var(--primary); }

@media (max-width: 820px) {
  .sidebar { position: fixed; inset-inline-start: -260px; transition: inset-inline-start .2s; z-index: 50; box-shadow: var(--shadow); }
  .sidebar.open { inset-inline-start: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }
