/* ==========================================================================
   Vesh Admin Panel — token-first styles on Bootstrap 5.3.

   All color/space decisions live in the two token blocks below; component
   rules only ever reference tokens. Dark mode = redefining tokens under
   [data-bs-theme="dark"] (Bootstrap 5.3 themes its own components natively).
   Adding a component must not require a matching dark override.
   ========================================================================== */

:root {
  /* layout */
  --sidebar-w: 244px;
  --header-h: 60px;
  --radius: 0.75rem;

  /* palette */
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e9ecef;
  --text-muted: #6b7280;
  --accent: #14b8a6;
  --accent-hover: #0d9488;
  --accent-soft: rgba(20, 184, 166, 0.12);
  --up: #10b981;
  --down: #ef4444;

  /* sidebar (deliberately dark in BOTH themes — it is the brand anchor) */
  --sidebar-bg: #0f1729;
  --sidebar-fg: #cbd5e1;
  --sidebar-fg-active: #ffffff;
  --sidebar-muted: #64748b;
  --sidebar-line: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] {
  --bg: #0b1220;
  --surface: #111827;
  --surface-2: #0f172a;
  --border: #1f2937;
  --text-muted: #94a3b8;
  --sidebar-bg: #060b16;
  /* Bootstrap component alignment */
  --bs-body-bg: var(--bg);
  --bs-body-color: #e2e8f0;
  --bs-border-color: var(--border);
  --bs-tertiary-bg: var(--surface-2);
  --bs-secondary-bg: var(--surface);
}

html, body { height: 100%; }
body { background: var(--bg); font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 0.92rem; }

a { text-decoration: none; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--sidebar-bg); color: var(--sidebar-fg);
  display: flex; flex-direction: column; z-index: 1030; overflow-y: auto;
}
.sidebar .brand {
  padding: 1.1rem 1.25rem; font-size: 1.1rem; font-weight: 700; color: #fff;
  border-bottom: 1px solid var(--sidebar-line); display: flex; align-items: center; gap: 0.5rem;
}
.sidebar .brand .dot { color: var(--accent); }
.sidebar .nav-section {
  padding: 0.85rem 1.25rem 0.3rem; font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--sidebar-muted);
}
.sidebar a.nav-link {
  color: var(--sidebar-fg); padding: 0.5rem 1.25rem; font-size: 0.875rem;
  display: flex; align-items: center; gap: 0.7rem; border-left: 3px solid transparent; transition: all 0.15s ease;
}
.sidebar a.nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.sidebar a.nav-link.active {
  color: var(--sidebar-fg-active); background: var(--accent-soft); border-left-color: var(--accent);
}
.sidebar a.nav-link i { width: 18px; text-align: center; font-size: 1rem; }

/* ── Main frame ──────────────────────────────────────────────────────── */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.5rem; position: sticky; top: 0; z-index: 100;
}
.app-content { flex: 1; padding: 1.5rem; }

/* ── Page header ─────────────────────────────────────────────────────── */
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-sub { color: var(--text-muted); font-size: 0.85rem; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card { border-radius: var(--radius); border-color: var(--border); background: var(--surface); }
.card .card-header { background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 600; }

/* ── Stat cards ──────────────────────────────────────────────────────── */
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 0.7rem;
  display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-trend { font-size: 0.74rem; font-weight: 600; }
.stat-card .stat-trend.up   { color: var(--up); }
.stat-card .stat-trend.down { color: var(--down); }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table { font-size: 0.86rem; }
.table thead th {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
.table tbody td { vertical-align: middle; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }

/* ── Chat bubbles ────────────────────────────────────────────────────── */
.chat-thread { display: flex; flex-direction: column; gap: 0.25rem; max-height: 60vh; overflow-y: auto; }
.chat-bubble {
  max-width: 72%; border-radius: 1rem; padding: 0.5rem 0.85rem; word-break: break-word;
  font-size: 0.86rem; background: var(--surface-2); border: 1px solid var(--border);
  border-bottom-left-radius: 0.25rem;
}
.chat-bubble-mine {
  background: var(--accent); border-color: var(--accent); color: #fff;
  border-radius: 1rem; border-bottom-right-radius: 0.25rem; border-bottom-left-radius: 1rem;
}
.chat-meta { font-size: 0.68rem; opacity: 0.7; margin-top: 0.15rem; }

/* ── Login page ──────────────────────────────────────────────────────── */
.login-page {
  background: linear-gradient(135deg, #0f1729 0%, #042f2e 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card { width: 100%; max-width: 400px; border-radius: 1rem; }
.brand-badge { width: 56px; height: 56px; background: var(--accent); }
.otp-input { letter-spacing: 0.5rem; text-align: center; font-size: 1.25rem; }

/* ── Misc ────────────────────────────────────────────────────────────── */
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; opacity: 0.4; }
.font-monospace, .text-mono { font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; }
kbd {
  font-family: ui-monospace, Consolas, monospace; padding: 0.05rem 0.35rem; border-radius: 0.25rem;
  border: 1px solid var(--border); background: var(--surface-2); color: inherit; font-size: 0.72rem;
}

/* Accent → Bootstrap primary */
.btn-primary {
  --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-hover); --bs-btn-hover-border-color: var(--accent-hover);
  --bs-btn-active-bg: var(--accent-hover); --bs-btn-active-border-color: var(--accent-hover);
}
.text-accent { color: var(--accent) !important; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); width: 240px; }
  .app-main { margin-left: 0; }
}
