/* ==========================================================================
   SariGram (ساری‌گرام) — Main Stylesheet
   Persian/Farsi RTL Instagram management web app
   ========================================================================== */

/* ─── Theme Tokens ───────────────────────────────────────────────────────── */
:root {
  /* ─── Theme: Light (default) — warm cream + teal ─────────────────────── */
  --bg: #faf9f7;
  --bg-subtle: #f3f0eb;
  --surface: #ffffff;
  --surface-2: #f8f6f3;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e0d8;
  --border-strong: #c9c1b6;

  --primary: #0d9488;
  --primary-hover: #0b7d72;
  --primary-fg: #ffffff;
  --primary-soft: #d4ede9;

  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-soft: #fed7aa;

  --danger: #dc2626;
  --danger-hover: #b21d1d;
  --danger-soft: #fee2e2;

  --success: #059669;
  --success-soft: #d1fae5;

  --warning: #d97706;
  --warning-soft: #fef3c7;

  --info: #0284c7;
  --info-soft: #dbeafe;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow: 0 1px 3px rgba(15, 30, 28, 0.06), 0 1px 2px rgba(15, 30, 28, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 30, 28, 0.08), 0 2px 4px rgba(15, 30, 28, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 30, 28, 0.12);

  --font: 'Vazirmatn', 'Segoe UI', 'Tahoma', 'Iranian Sans', sans-serif;
  --font-mono: 'SF Mono', 'Consolas', 'Menlo', monospace;

  --sidebar-w: 240px;
  --nav-h: 60px;

  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
  /* ─── Theme: Dark — deep slate + teal ────────────────────────────────── */
  --bg: #0c1116;
  --bg-subtle: #131922;
  --surface: #1a212b;
  --surface-2: #222a36;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --border: #2d333b;
  --border-strong: #3d444d;

  --primary: #14b8a6;
  --primary-hover: #2dd4bf;
  --primary-fg: #052e2b;
  --primary-soft: #134e4a;

  --accent: #fb923c;
  --accent-hover: #fdba74;
  --accent-soft: #431407;

  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-soft: #450a0a;

  --success: #34d399;
  --success-soft: #052e16;

  --warning: #fbbf24;
  --warning-soft: #422006;

  --info: #38bdf8;
  --info-soft: #082f49;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6), 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.7);
}

/* ─── Theme: Ocean (distinct light — cool blue-teal) ──────────────────────── */
[data-theme="ocean"] {
  --bg: #f0f9ff;
  --bg-subtle: #e0f2fe;
  --surface: #ffffff;
  --surface-2: #f0f9ff;
  --text: #0c4a6e;
  --text-muted: #0369a1;
  --border: #bae6fd;
  --border-strong: #7dd3fc;

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-fg: #ffffff;
  --primary-soft: #e0f2fe;

  --accent: #e11d48;
  --accent-hover: #be123c;
  --accent-soft: #fecdd3;

  --danger: #e11d48;
  --danger-hover: #be123c;
  --danger-soft: #fecdd3;

  --success: #0d9488;
  --success-soft: #ccfbf1;

  --warning: #ca8a04;
  --warning-soft: #fef3c7;

  --info: #7c3aed;
  --info-soft: #ede9fe;
}

/* ─── Theme: Midnight (distinct dark — deep indigo/violet) ──────────────── */
[data-theme="forest"] {
  --bg: #0d0b1f;
  --bg-subtle: #15122e;
  --surface: #1c1838;
  --surface-2: #251f4a;
  --text: #e0d9f5;
  --text-muted: #9b91c4;
  --border: #2e2655;
  --border-strong: #3d3366;

  --primary: #a78bfa;
  --primary-hover: #c4b5fd;
  --primary-fg: #1c1838;
  --primary-soft: #2e1f5c;

  --accent: #f472b6;
  --accent-hover: #f9a8d4;
  --accent-soft: #3d1530;

  --danger: #fb7185;
  --danger-hover: #fda4af;
  --danger-soft: #3d0f1a;

  --success: #34d399;
  --success-soft: #0a2e1f;

  --warning: #fbbf24;
  --warning-soft: #2f2410;

  --info: #60a5fa;
  --info-soft: #0a1f3d;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.65);
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6 { margin: 0 0 0.5em; font-weight: 700; line-height: 1.35; color: var(--text); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }
img, video { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

::selection { background: var(--primary-soft); color: var(--primary-hover); }

/* Scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Nav ────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.nav-brand { display: flex; align-items: center; gap: 0.75rem; }
.nav-brand-link { display: flex; align-items: center; gap: 0.5rem; color: var(--text); font-weight: 700; font-size: 1.05rem; }
.nav-brand-link:hover { color: var(--primary); }
.nav-brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
}
.nav-brand-name { white-space: nowrap; }
.nav-actions { display: flex; align-items: center; gap: 0.5rem; }

.nav-theme-btn, .nav-bell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  color: var(--text);
  position: relative;
  transition: all var(--transition);
}
.nav-theme-btn:hover, .nav-bell:hover { background: var(--surface-2); border-color: var(--border-strong); }
.theme-icon-dark { display: none; }
body.is-dark .theme-icon-light { display: none; }
body.is-dark .theme-icon-dark { display: inline; }
.nav-bell-count {
  position: absolute;
  top: -4px;
  inset-inline-end: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-user-menu { position: relative; }
.nav-user-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
.nav-user-summary::-webkit-details-marker { display: none; }
.nav-user-summary:hover { background: var(--surface-2); }
.nav-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 700;
  font-size: 0.85rem;
}
.nav-user-name { font-size: 0.9rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  min-width: 200px;
  max-width: calc(100vw - 1.5rem);
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 200;
}
.nav-user-item {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  background: none;
  border: 0;
  width: 100%;
  text-align: start;
}
.nav-user-item:hover { background: var(--surface-2); color: var(--primary); }
.nav-user-item-danger:hover { background: var(--danger-soft); color: var(--danger); }
.nav-user-form { margin: 0; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 9px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.nav-toggle span { display: block; height: 2px; width: 100%; background: var(--text); border-radius: 2px; transition: var(--transition); }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.dash-layout {
  display: flex;
  flex: 1;
  align-items: stretch;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar {
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  padding: 1rem 0.75rem;
  position: sticky;
  top: var(--nav-h);
  align-self: flex-start;
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  background: none;
  border: 0;
  width: 100%;
  text-align: start;
  cursor: pointer;
  transition: all var(--transition);
}
.sidebar-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar-item.active { background: var(--primary-soft); color: var(--primary-hover); font-weight: 600; }
.sidebar-icon { font-size: 1.05rem; display: inline-flex; width: 22px; justify-content: center; }
.sidebar-item-admin { color: var(--accent-hover); }
body.is-dark .sidebar-item-admin { color: var(--accent); }
.sidebar-item-admin.active { background: var(--accent-soft); }
.sidebar-item-danger:hover { background: var(--danger-soft); color: var(--danger); }
.sidebar-divider { height: 1px; background: var(--border); margin: 0.75rem 0; }
.sidebar-logout-form { margin: 0; }

.dash-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem;
}

.dash-header {
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.dash-title { font-size: 1.5rem; margin: 0; }
.dash-subtitle { color: var(--text-muted); margin: 4px 0 0; font-size: 0.92rem; }

/* ─── Public layout (no sidebar) ─────────────────────────────────────────── */
.public-layout .dash-layout { max-width: 1200px; }
.public-layout .dash-content { padding: 0; flex: 1; }
.public-layout .nav-toggle { display: none; }

/* ─── Hero (public landing) ──────────────────────────────────────────────── */
.hero {
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  background:
    radial-gradient(circle at 20% 20%, var(--primary-soft) 0%, transparent 50%),
    radial-gradient(circle at 80% 30%, var(--accent-soft) 0%, transparent 50%);
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}
.hero-tagline { font-size: clamp(1rem, 2.5vw, 1.25rem); color: var(--text-muted); margin-bottom: 2rem; max-width: 600px; margin-inline: auto; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.hero-actions .btn { font-size: 1.05rem; padding: 0.85rem 1.75rem; }

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  padding: 2rem 1.5rem 4rem;
  max-width: 1100px;
  margin: 0 auto;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.feature-card-icon { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
.feature-card h3 { margin-bottom: 0.4rem; color: var(--text); }
.feature-card p { color: var(--text-muted); margin: 0; font-size: 0.92rem; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1.05rem; margin: 0; font-weight: 600; }

/* ─── Stat Grid ──────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-label { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-card.stat-accent::before { background: var(--accent); }
.stat-card.stat-success::before { background: var(--success); }
.stat-card.stat-warning::before { background: var(--warning); }
.stat-card.stat-danger::before { background: var(--danger); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--bg-subtle); }
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-fg); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }

.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }

.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { min-height: 34px; padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn-lg { min-height: 50px; padding: 0.85rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.form-label .req { color: var(--danger); margin-inline-start: 2px; }
.form-input, .form-textarea, .form-select {
  display: block;
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  line-height: 1.5;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); opacity: 0.7; }
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-textarea { min-height: 100px; resize: vertical; font-family: inherit; }
.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6b69' d='M6 9L1 4h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 0.85rem center; padding-inline-start: 2.25rem; }
.form-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-check { display: flex; align-items: center; gap: 0.5rem; }
.form-check input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.form-check label { cursor: pointer; font-size: 0.92rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-inline { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; }
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.form-card { max-width: 460px; margin-inline: auto; }

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab {
  padding: 0.65rem 1.1rem;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--surface);
}
.table th, .table td {
  padding: 0.7rem 0.9rem;
  text-align: start;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th { background: var(--surface-2); color: var(--text-muted); font-weight: 600; font-size: 0.82rem; text-transform: none; }
.table tbody tr:nth-child(odd) { background: var(--surface); }
.table tbody tr:nth-child(even) { background: var(--surface-2); }
.table tbody tr:hover { background: var(--primary-soft); }
.table td strong { color: var(--text); }
.table .table-actions form { display: inline-block; margin: 0 2px; vertical-align: middle; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1.4;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary-hover); border-color: transparent; }

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert-container { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.alert {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--text-muted);
  font-size: 0.92rem;
}
.alert-icon { font-weight: 700; flex-shrink: 0; }
.alert-text { flex: 1; }
.alert-close { background: none; border: 0; color: var(--text-muted); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0; }
.alert-success { border-inline-start-color: var(--success); background: var(--success-soft); }
.alert-success .alert-icon { color: var(--success); }
.alert-error { border-inline-start-color: var(--danger); background: var(--danger-soft); }
.alert-error .alert-icon { color: var(--danger); }
.alert-warning { border-inline-start-color: var(--warning); background: var(--warning-soft); }
.alert-warning .alert-icon { color: var(--warning); }
.alert-info { border-inline-start-color: var(--info); background: var(--info-soft); }
.alert-info .alert-icon { color: var(--info); }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1rem;
  inset-inline-start: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--info);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.92rem;
  animation: slideIn 0.25s ease;
}
.toast-success { border-inline-start-color: var(--success); }
.toast-error { border-inline-start-color: var(--danger); }
.toast-warning { border-inline-start-color: var(--warning); }
.toast.removing { opacity: 0; transform: translateX(20px); transition: all 0.3s; }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty-state-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.85; }
.empty-state h2 { margin-bottom: 0.5rem; color: var(--text); }
.empty-state p { color: var(--text-muted); margin-bottom: 1rem; }

/* ─── Hero grid (media) ──────────────────────────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  display: block;
  color: var(--text);
}
.media-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); color: var(--text); }
.media-thumb {
  width: 100%;
  height: 200px;
  background: var(--bg-subtle);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}
.media-info { padding: 0.75rem; }
.media-type { color: var(--text-muted); font-size: 0.78rem; }
.media-stats { margin-top: 4px; font-size: 0.85rem; color: var(--text); }

/* ─── DM thread ──────────────────────────────────────────────────────────── */
.thread-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 480px;
  overflow-y: auto;
  padding: 0.5rem;
}
.thread-msg {
  padding: 0.55rem 0.85rem;
  margin-bottom: 0.4rem;
  border-radius: var(--radius);
  max-width: 75%;
  word-wrap: break-word;
}
.thread-msg.incoming {
  background: var(--surface-2);
  margin-inline-end: auto;
  border-start-start-radius: 4px;
}
.thread-msg.outgoing {
  background: var(--primary);
  color: var(--primary-fg);
  margin-inline-start: auto;
  border-start-end-radius: 4px;
}
.thread-meta { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; }
.thread-msg.outgoing .thread-meta { color: rgba(255,255,255,0.85); }

/* ─── Progress bars (server stats) ───────────────────────────────────────── */
.bar {
  width: 100%;
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.6s ease;
}
.bar-fill.danger { background: linear-gradient(90deg, var(--danger), var(--accent)); }
.bar-fill.warning { background: linear-gradient(90deg, var(--warning), var(--accent)); }

/* ─── Code box ───────────────────────────────────────────────────────────── */
.code-box {
  font-family: var(--font-mono);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  direction: ltr;
  text-align: center;
  display: inline-block;
  min-width: 180px;
}

/* ─── Settings ───────────────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
.settings-section-title { font-size: 1.05rem; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); color: var(--primary-hover); }

/* ─── Footer (sticky) ────────────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.footer-muted { opacity: 0.7; }

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }

/* ─── Utility ────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; }
.flex { display: flex; } .flex-between { display: flex; justify-content: space-between; align-items: center; } .flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ─── Error pages ────────────────────────────────────────────────────────── */
.error-page {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
.error-code {
  font-size: clamp(5rem, 18vw, 9rem);
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dash-content { padding: 1.25rem; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-user-name { display: none; }
  .nav-actions .btn { padding: 0.45rem 0.85rem; }

  .dash-content { padding: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .hero { padding: 2.5rem 1rem 2rem; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .nav-brand-name { display: none; }
  .features-grid { grid-template-columns: 1fr; }
  .dash-title { font-size: 1.2rem; }
  .footer-inner { flex-direction: column; text-align: center; }
  .table th, .table td { padding: 0.5rem 0.6rem; font-size: 0.85rem; }
  .thread-msg { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ─── v2 additions: 2FA, hashtags, automation, api-keys, approval, page-header ─── */

.hidden { display: none !important; }
.mt-2 { margin-top: 1rem !important; }

/* Page header (title + subtitle) */
.page-header { margin-bottom: 1.25rem; }
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.25rem; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

/* Form row (inline input + button) */
.form-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.form-input-sm { padding: 0.4rem 0.6rem !important; font-size: 0.85rem !important; }

/* Code block */
.code-block {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-family: 'Menlo', 'Consolas', 'Vazirmatn', monospace;
  font-size: 0.875rem;
  overflow-x: auto;
}
.code-box {
  font-family: 'Menlo', 'Consolas', 'Vazirmatn', monospace;
  letter-spacing: 0.2em;
  text-align: center;
  font-size: 1.25rem;
}

/* Info card (callout) */
.info-card { border-inline-start: 4px solid var(--accent); }
.info-card .card-title { font-size: 1rem; margin-bottom: 0.5rem; }
.info-card p { color: var(--text-muted); line-height: 1.7; font-size: 0.9rem; }
.info-card ul { color: var(--text-muted); padding-inline-start: 1.5rem; line-height: 1.8; font-size: 0.9rem; }
.info-card code { background: var(--bg-subtle); padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.85em; }

/* Alert card (inside-card emphasis) */
.alert-card { border-inline-start: 4px solid currentColor; }
.alert-success.alert-card { border-inline-start-color: var(--success); }

/* Badges — extended palette */
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.badge-accent { background: rgba(245, 158, 11, 0.15); color: #b45309; }
[data-theme="dark"] .badge-warning,
[data-theme="dark"] .badge-accent { color: #fbbf24; }

/* Empty state (uniform across pages) */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state-icon, .empty-state > div:first-child { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state h2 { font-size: 1.2rem; color: var(--text); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; }

/* Table actions (compact button row) */
.table-actions { white-space: nowrap; display: flex; gap: 0.25rem; flex-wrap: wrap; }
.table-actions form { display: inline; }

/* Tabs — already defined; ensure new tab styles inherit */
.tab-panel { animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Sentiment badges */
.badge-sentiment-positive { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-sentiment-negative { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-sentiment-neutral  { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

/* Pending approval highlight row */
tr:has(.badge-warning) td { background: rgba(245, 158, 11, 0.04); }

/* QR code container (2FA setup) */
#twofa-qr-container img { max-width: 220px; height: auto; }
#twofa-backup-list { font-size: 1.1rem; font-weight: 600; }

/* ═══ Premium UI/UX v3 ═══════════════════════════════════════════════════════
   Additional polish: gradient cards, glassmorphism nav, smooth animations,
   session cards with geo + map, theme palette, premium buttons. */

/* ─── Gradient nav + brand ────────────────────────────────────────────────── */
.nav {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.nav-brand-link {
  font-size: 1.15rem; font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

/* ─── Premium stat cards with gradient accents ────────────────────────────── */
.stat-card {
  position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 0%, var(--primary-soft) 100%);
  opacity: 0.5; pointer-events: none;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card.stat-success::before { background: linear-gradient(135deg, transparent 0%, var(--success-soft) 100%); }
.stat-card.stat-accent::before  { background: linear-gradient(135deg, transparent 0%, var(--accent-soft) 100%); }
.stat-card.stat-warning::before { background: linear-gradient(135deg, transparent 0%, var(--warning-soft) 100%); }
.stat-card .stat-value { position: relative; z-index: 1; }
.stat-card .stat-label { position: relative; z-index: 1; }

/* ─── Premium buttons ─────────────────────────────────────────────────────── */
.btn {
  font-weight: 600; letter-spacing: -0.01em;
  transition: all var(--transition);
  position: relative; overflow: hidden;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.4);
  transform: translateY(-1px);
}
.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-hover) 100%);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}
.btn-ghost:hover { background: var(--bg-subtle); }

/* ─── Cards with hover lift ───────────────────────────────────────────────── */
.card {
  transition: box-shadow var(--transition), transform var(--transition);
  border-radius: var(--radius);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.5rem;
}

/* ─── Sidebar premium ─────────────────────────────────────────────────────── */
.sidebar {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border-inline-start: 1px solid var(--border);
}
.sidebar-item {
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-weight: 500;
}
.sidebar-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
  transform: translateX(-3px);
  text-decoration: none;
}
.sidebar-item.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: var(--primary-fg);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}
.sidebar-item.active .sidebar-icon { transform: scale(1.1); }

/* ─── Theme palette (4 themes) ────────────────────────────────────────────── */
.theme-palette-wrapper { position: relative; }
.theme-palette {
  position: absolute; top: 100%; inset-inline-end: 0; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow-lg);
  display: none; gap: 12px; z-index: 100; min-width: 200px;
}
.theme-palette.open { display: flex; flex-wrap: wrap; }
.theme-dot {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 3px solid var(--border); transition: all var(--transition);
  position: relative;
}
.theme-dot:hover { transform: scale(1.15); }
.theme-dot.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.theme-dot[data-theme="light"]  { background: linear-gradient(135deg, #f7f9f9 50%, #0d9488 50%); }
.theme-dot[data-theme="dark"]   { background: linear-gradient(135deg, #0e1614 50%, #14b8a6 50%); }
.theme-dot[data-theme="ocean"]  { background: linear-gradient(135deg, #ecfeff 50%, #0891b2 50%); }
.theme-dot[data-theme="forest"] { background: linear-gradient(135deg, #0d0b1f 50%, #a78bfa 50%); }
.theme-palette-label {
  font-size: 0.7rem; color: var(--text-muted); text-align: center;
  margin-top: 4px;
}

/* ─── Session card (rich) ─────────────────────────────────────────────────── */
.session-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 1rem;
  align-items: center; padding: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 0.75rem;
  transition: all var(--transition);
}
.session-card:hover { box-shadow: var(--shadow-md); }
.session-card.current { border-color: var(--primary); border-width: 2px; }
.session-card.risky { border-color: var(--danger); }
.session-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary-soft); display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.session-icon.vpn { background: var(--warning-soft); }
.session-icon.risky { background: var(--danger-soft); }
.session-info { min-width: 0; }
.session-info strong { display: block; margin-bottom: 2px; }
.session-meta {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  font-size: 0.8rem; color: var(--text-muted); margin-top: 4px;
}
.session-meta span { display: inline-flex; align-items: center; gap: 4px; }
.session-map {
  margin-top: 0.75rem; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border); height: 160px; background: var(--bg-subtle);
}
.session-map iframe { width: 100%; height: 100%; border: 0; display: block; }
.risk-bar {
  width: 80px; height: 6px; border-radius: 3px; background: var(--bg-subtle);
  overflow: hidden; display: inline-block; vertical-align: middle;
}
.risk-bar-fill { height: 100%; background: var(--success); transition: width 0.3s; }
.risk-bar-fill.medium { background: var(--warning); }
.risk-bar-fill.high { background: var(--danger); }

/* ─── Notification bell (improved) ────────────────────────────────────────── */
.notif-bell {
  position: relative; padding: 8px; border-radius: 50%;
  cursor: pointer; transition: background var(--transition);
}
.notif-bell:hover { background: var(--bg-subtle); }
.notif-badge {
  position: absolute; top: 2px; inset-inline-end: 2px;
  background: var(--danger); color: white;
  font-size: 0.65rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid var(--surface);
}
.notif-dropdown {
  position: absolute; top: 100%; inset-inline-end: 0; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 340px; max-width: calc(100vw - 1.5rem); box-sizing: border-box;
  max-height: 480px; overflow-y: auto; z-index: 100;
  display: none;
}
.notif-dropdown.open { display: block; }
.notif-item {
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
}
.notif-item:hover { background: var(--bg-subtle); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--primary-soft); }
.notif-item-title { font-weight: 600; font-size: 0.9rem; }
.notif-item-body { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.notif-item-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }
.notif-header {
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 0.9rem;
}
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); }
.notif-skeleton { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.skeleton-line {
  height: 10px; border-radius: 4px; margin-bottom: 6px;
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-subtle, var(--border)) 37%, var(--border) 63%);
  background-size: 400% 100%;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
.skeleton-line:last-child { margin-bottom: 0; }
@keyframes skeleton-pulse {
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ─── Page header (premium) ───────────────────────────────────────────────── */
.page-header {
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--accent-soft) 100%);
  border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}
.page-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.25rem; }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

/* ─── Tabs (premium) ──────────────────────────────────────────────────────── */
.tabs {
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem; gap: 0.25rem;
}
.tab {
  padding: 0.6rem 1.2rem; border: none; background: transparent; cursor: pointer;
  border-bottom: 3px solid transparent; color: var(--text-muted);
  font-family: inherit; font-weight: 600; font-size: 0.9rem;
  transition: all var(--transition); margin-bottom: -2px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary); border-bottom-color: var(--primary);
}

/* ─── Code block (premium) ────────────────────────────────────────────────── */
.code-block {
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.75rem 1rem;
  font-family: var(--font-mono); font-size: 0.875rem;
  overflow-x: auto; direction: ltr; text-align: left;
}

/* ─── Risk badge ──────────────────────────────────────────────────────────── */
.risk-low { background: var(--success-soft); color: var(--success); }
.risk-medium { background: var(--warning-soft); color: var(--warning); }
.risk-high { background: var(--danger-soft); color: var(--danger); }

/* ─── Smooth page transitions ─────────────────────────────────────────────── */
main { animation: fadeInUp 0.25s ease; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Empty state (premium) ───────────────────────────────────────────────── */
.empty-state {
  padding: 3rem 1.5rem; text-align: center;
  background: var(--bg-subtle); border-radius: var(--radius);
  border: 2px dashed var(--border);
}

/* ─── Alert premium ───────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.875rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); border-inline-start: 4px solid var(--primary);
  background: var(--surface);
}
.alert-success { border-inline-start-color: var(--success); background: var(--success-soft); }
.alert-error   { border-inline-start-color: var(--danger);  background: var(--danger-soft); }
.alert-warning { border-inline-start-color: var(--warning); background: var(--warning-soft); }
.alert-info    { border-inline-start-color: var(--info);    background: var(--info-soft); }

/* ═══ v15 additions ═══════════════════════════════════════════════════════
   Clickable stat cards, auto-dismiss alerts with progress bar, feature cards */

/* Clickable stat card */
.stat-card-link {
  text-decoration: none !important;
  color: inherit !important;
  display: block;
  cursor: pointer;
  position: relative;
}
.stat-card-link:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  text-decoration: none !important;
}
.stat-card .stat-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  position: relative;
  z-index: 1;
}

/* Feature card */
.feature-card {
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition), transform var(--transition);
}
.feature-card:hover { box-shadow: var(--shadow-md); }

/* Auto-dismiss alert with progress bar */
.alert {
  position: relative;
  overflow: hidden;
}
.alert-progress {
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.5;
  animation: alert-deplete 5s linear forwards;
}
@keyframes alert-deplete {
  from { width: 100%; }
  to { width: 0%; }
}
.alert-success .alert-progress { background: var(--success); }
.alert-error .alert-progress { background: var(--danger); }
.alert-warning .alert-progress { background: var(--warning); }
.alert-info .alert-progress { background: var(--info); }

/* Alert slide-in animation */
.alert-container .alert {
  animation: alert-slide-in 0.3s ease;
}
@keyframes alert-slide-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══ v17: Mobile responsive fixes + theme/notif overflow fix ══════════════ */

/* Mobile: nav actions don't overflow */
@media (max-width: 768px) {
  .nav-actions {
    flex-wrap: nowrap;
    gap: 0.25rem;
  }
  .nav-actions .btn { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
  .nav-theme-btn, .notif-bell { padding: 4px !important; }
  .theme-palette { 
    right: 0; left: auto; 
    min-width: 180px;
    max-width: 90vw;
  }
  .notif-dropdown {
    right: 0; left: auto;
    width: 300px;
    max-width: 90vw;
  }
  /* Hamburger menu works */
  .dash-layout { flex-direction: column; }
  .dash-content { padding: 1rem; width: 100%; }
  
  /* Dashboard stat cards stack on mobile */
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 0.5rem; }
  .stat-card { padding: 0.75rem; }
  .stat-value { font-size: 1.3rem; }
  
  /* Feature grid stack on mobile */
  .feature-grid { grid-template-columns: 1fr !important; gap: 1rem; }
  
  /* Tables scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table th, .table td { white-space: nowrap; font-size: 0.8rem; padding: 0.4rem; }
  
  /* Page header smaller */
  .page-title { font-size: 1.2rem; }
  .page-subtitle { font-size: 0.8rem; }
  
  /* Tabs scroll */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; padding: 0.4rem 0.8rem; font-size: 0.8rem; }
  
  /* Forms full width */
  .form-input, .form-textarea, .form-select { font-size: 16px; } /* prevent iOS zoom */
  
  /* Session card stack */
  .session-card { grid-template-columns: 1fr; gap: 0.5rem; }
  .session-map { height: 120px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr !important; }
  .nav-brand-name { display: none; }
  .dash-title { font-size: 1.1rem; }
  .footer-inner { flex-direction: column; gap: 0.5rem; }
}

/* Fix theme palette overflow on all screens */
.theme-palette-wrapper { position: relative; }
.theme-palette {
  position: absolute;
  top: 100%; left: auto; right: 0;
  margin-top: 8px;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}

/* Fix notif dropdown overflow */
.nav-actions > div[style*="position:relative"] {
  position: relative;
}
.notif-dropdown {
  position: absolute;
  top: 100%; left: auto; right: 0;
  margin-top: 8px;
  z-index: 200;
}

/* Hamburger button visible on mobile */
.nav-toggle {
  display: none;
}
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 30px; height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
  }
  .nav-toggle span {
    width: 100%; height: 3px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.3s;
  }
}

/* ═══ v18: Final mobile + dropdown + theme fixes ═══════════════════════════ */

/* Force nav-toggle visible on mobile when authenticated */
@media (max-width: 768px) {
  body:not(.public-layout) .nav-toggle { 
    display: flex !important; 
    z-index: 101;
  }
}

/* Dropdown containers — prevent overflow */
.nav-actions > div,
.theme-palette-wrapper,
.nav-actions div[style*="position:relative"] {
  position: relative;
}

/* Theme palette: right-aligned, within viewport */
.theme-palette {
  position: absolute !important;
  top: calc(100% + 8px);
  right: 0 !important;
  left: auto !important;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Notification dropdown: right-aligned */
.notif-dropdown {
  position: absolute !important;
  top: calc(100% + 8px);
  right: 0 !important;
  left: auto !important;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}

/* User menu dropdown */
.nav-user-dropdown {
  right: 0 !important;
  left: auto !important;
}

/* Mobile: compact stat grid — 2 columns, not 1 */
@media (max-width: 768px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }
  .stat-card {
    padding: 0.6rem !important;
    text-align: center;
  }
  .stat-card .stat-value { font-size: 1.2rem !important; }
  .stat-card .stat-label { font-size: 0.7rem !important; }
  .stat-card .stat-sub { font-size: 0.65rem !important; }
}
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Mobile: feature grid — 1 column but compact */
@media (max-width: 768px) {
  .feature-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  .feature-card { padding: 0.75rem !important; }
}

/* Midnight theme fix — ensure dark background applies */
[data-theme="forest"] {
  background-color: var(--bg) !important;
  color: var(--text) !important;
}
[data-theme="forest"] body,
[data-theme="forest"] .nav,
[data-theme="forest"] .sidebar,
[data-theme="forest"] .card,
[data-theme="forest"] .stat-card {
  background-color: var(--surface) !important;
  color: var(--text) !important;
}
[data-theme="forest"] .dash-content { background-color: var(--bg); }

/* ═══ v19: Final hamburger + dropdown + mobile compact ═════════════════════ */

/* Hamburger menu button — ALWAYS visible on mobile when authenticated */
@media (max-width: 768px) {
  body:not(.public-layout) .nav-toggle {
    display: flex !important;
    flex-direction: column;
    justify-content: space-around;
    width: 32px; height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
  }
  
  /* ═══ FINAL sidebar rule — the only .sidebar mobile definition left ═══
     Overlay is keyed off body.sidebar-open (set by the JS toggle) rather
     than .sidebar itself, because .sidebar has a `transform`, and per the
     CSS spec, an element with `transform` becomes the containing block for
     its own `position:fixed` children/pseudo-elements — so a `::before`
     overlay attached to .sidebar can never actually cover the full
     viewport, only its own 280px-wide box. That was the real cause of the
     "sidebar looks open with no dimmed background" bug. `body` never has a
     transform, so this is fixed-position-safe. */
  .sidebar {
    position: fixed !important;
    top: 0; right: 0; bottom: 0;
    width: 280px;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
  }
  .sidebar.open { transform: translateX(0) !important; }
  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
  }
}

/* ALL dropdowns: right-aligned, never overflow */
.theme-palette,
.notif-dropdown,
.nav-user-dropdown {
  position: absolute !important;
  top: calc(100% + 8px);
  right: 0 !important;
  left: auto !important;
  z-index: 9999;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

/* Mobile stat grid: 2 columns compact */
@media (max-width: 768px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }
  .stat-card { padding: 0.5rem !important; }
  .stat-card .stat-value { font-size: 1.1rem !important; }
  .stat-card .stat-label { font-size: 0.65rem !important; }
  .stat-card .stat-sub { font-size: 0.6rem !important; }
}

/* Mobile: prevent body scroll when sidebar open */
@media (max-width: 768px) {
  body:not(.public-layout).sidebar-open {
    overflow: hidden;
  }
}

/* ─── Custom confirm modal (replaces native confirm()) ────────────────────── */
.confirm-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  padding: 1rem;
}
.confirm-modal-overlay.open { opacity: 1; pointer-events: auto; }
.confirm-modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 1.5rem; width: 100%; max-width: 360px;
  text-align: center; transform: translateY(10px); transition: transform 0.2s;
}
.confirm-modal-overlay.open .confirm-modal { transform: translateY(0); }
.confirm-modal-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.confirm-modal-msg { color: var(--text); margin-bottom: 1.25rem; font-size: 0.95rem; }
.confirm-modal-actions { display: flex; gap: 0.5rem; }
.confirm-modal-actions .btn { flex: 1; }

/* ─── Mobile bottom nav ──────────────────────────────────────────────────── */
.bottom-nav { display: none; }
@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; inset-inline: 0; z-index: 90;
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .bottom-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 0.5rem 0.25rem; color: var(--text-muted);
    font-size: 0.68rem; background: none; border: none; cursor: pointer;
    font-family: inherit;
  }
  .bottom-nav-item.active { color: var(--primary); font-weight: 600; }
  .bottom-nav-icon { font-size: 1.15rem; }
  /* Leave room so page content doesn't sit underneath the fixed bar */
  .dash-content { padding-bottom: calc(1rem + 56px + env(safe-area-inset-bottom, 0)); }
}

/* ─── Nav consolidation: bottom-nav replaces the hamburger on mobile ────────
   The bottom-nav's "بیشتر" button already opens the exact same sidebar the
   hamburger did, so showing both was a redundant, confusing double control.
   Keeping the hamburger for desktop-width authenticated pages (it's the
   only nav-open control there — no bottom-nav exists above 768px). */
@media (max-width: 768px) {
  body:not(.public-layout) .nav-toggle {
    display: none !important;
  }
}
