/* ============================================================
   نواکال — سامانه مرکز تماس | سیستم طراحی RTL
   ============================================================ */

:root {
  --font: Vazirmatn, Vazir, "IRANSansX", "IRANSans", "Segoe UI", Tahoma, Arial, sans-serif;

  /* پالت روشن */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --border: #dfe5ee;
  --text: #1c2433;
  --text-2: #5a6579;
  --text-3: #8b95a7;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #dbeafe;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --info: #0891b2;
  --info-soft: #cffafe;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --shadow: 0 1px 3px rgb(16 24 40 / .07), 0 1px 2px rgb(16 24 40 / .04);
  --shadow-lg: 0 10px 30px rgb(16 24 40 / .12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
}

[data-theme="dark"] {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1e2739;
  --border: #2a3550;
  --text: #e7ecf5;
  --text-2: #a7b1c5;
  --text-3: #6f7a92;
  --primary: #3b82f6;
  --primary-strong: #60a5fa;
  --primary-soft: #1e3a5f;
  --success: #34d399;
  --success-soft: #113a2b;
  --danger: #f87171;
  --danger-soft: #431a1e;
  --warning: #fbbf24;
  --warning-soft: #3d2e10;
  --info: #22d3ee;
  --info-soft: #0e3a44;
  --purple: #a78bfa;
  --purple-soft: #2b2350;
  --shadow: 0 1px 3px rgb(0 0 0 / .4);
  --shadow-lg: 0 10px 30px rgb(0 0 0 / .5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

/* ---------- اسپلش بوت ---------- */
.boot-splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}
.boot-logo { font-size: 46px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.92); } }

/* ---------- چیدمان اصلی ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-inline-start: none;
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  border-radius: 10px;
  font-size: 19px;
}
.brand-name { font-weight: 800; font-size: 16px; }
.brand-sub { font-size: 11px; color: var(--text-3); }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label {
  font-size: 11px; color: var(--text-3);
  padding: 12px 12px 4px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-item .nav-ico { width: 20px; text-align: center; font-size: 16px; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 800;
  flex-shrink: 0;
}
.sf-name { font-size: 13px; font-weight: 700; }
.sf-role { font-size: 11px; color: var(--text-3); }
.sf-grow { flex: 1; min-width: 0; overflow: hidden; }

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

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; font-weight: 800; flex: 1; }
.topbar .live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
}
.live-dot .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); }
.live-dot.on .dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

.content { padding: 22px 24px 40px; max-width: 1360px; width: 100%; margin: 0 auto; }

/* ---------- کارت‌ها ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card, .card + .grid, .grid + .card { margin-top: 18px; }
.card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 800; flex: 1; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) {
  .grid.cols-4, .grid.cols-6 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .grid.cols-2, .grid.cols-4, .grid.cols-6 { grid-template-columns: 1fr; }
}

/* ---------- کاشی آمار ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
  position: relative;
  overflow: hidden;
}
.stat-label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.stat-sub { font-size: 11px; color: var(--text-3); }
.stat-ico {
  position: absolute; inset-inline-end: 14px; top: 14px;
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px;
}
.stat.accent-primary .stat-ico { background: var(--primary-soft); color: var(--primary); }
.stat.accent-success .stat-ico { background: var(--success-soft); color: var(--success); }
.stat.accent-danger  .stat-ico { background: var(--danger-soft); color: var(--danger); }
.stat.accent-warning .stat-ico { background: var(--warning-soft); color: var(--warning); }
.stat.accent-info    .stat-ico { background: var(--info-soft); color: var(--info); }
.stat.accent-purple  .stat-ico { background: var(--purple-soft); color: var(--purple); }

/* ---------- فرم‌ها ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.field .hint { font-size: 11px; color: var(--text-3); }

input[type="text"], input[type="password"], input[type="number"],
input[type="datetime-local"], input[type="date"], select, textarea {
  font-family: var(--font);
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input::placeholder { color: var(--text-3); }
input[dir="ltr"], .ltr { direction: ltr; text-align: left; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
}
.filters .actions { display: flex; gap: 8px; }

/* ---------- دکمه‌ها ---------- */
.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: filter .15s, background .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-strong); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-icon { padding: 7px 9px; }

/* ---------- جدول ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 640px;
}
table.data th {
  text-align: right;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 700;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; unicode-bidi: embed; }
.table-empty {
  padding: 36px;
  text-align: center;
  color: var(--text-3);
}

/* ---------- نشان‌ها ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info    { background: var(--info-soft); color: var(--info); }
.badge-muted   { background: var(--surface-2); color: var(--text-2); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-purple  { background: var(--purple-soft); color: var(--purple); }

/* ---------- صفحه‌بندی ---------- */
.pager {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
}
.pager .spacer { flex: 1; }

/* ---------- ورود ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 20px;
  background:
    radial-gradient(700px 340px at 85% -10%, var(--primary-soft), transparent),
    radial-gradient(600px 300px at 10% 110%, var(--purple-soft), transparent),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.auth-head { text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.auth-head .brand-icon { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; }
.auth-title { font-size: 18px; font-weight: 800; margin-top: 8px; }
.auth-sub { font-size: 12px; color: var(--text-3); }

/* ---------- مودال ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgb(9 12 20 / .55);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
  animation: fadein .15s ease;
}
.modal {
  width: 100%; max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: slideup .18s ease;
}
.modal-header {
  display: flex; align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
}
.modal-header .close {
  margin-inline-start: auto;
  background: none; border: none;
  font-size: 20px; cursor: pointer; color: var(--text-3);
}
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-start;
}
@keyframes fadein { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(14px); opacity: 0; } }

/* ---------- توست ---------- */
#toasts {
  position: fixed;
  bottom: 20px; inset-inline-start: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  max-width: 360px;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: slideup .2s 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); }

/* ---------- نمودار ---------- */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; padding-top: 10px; font-size: 12px; color: var(--text-2); }
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 11px; height: 11px; border-radius: 3px; }

/* ---------- متفرقه ---------- */
.muted { color: var(--text-3); font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; direction: ltr; unicode-bidi: embed; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; }
.mt { margin-top: 16px; }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { padding: 40px; text-align: center; color: var(--text-3); }
.error-block {
  padding: 14px 16px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.callout {
  padding: 12px 16px;
  background: var(--info-soft);
  color: var(--info);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
audio.player { width: 100%; height: 38px; }

/* دیوارنگار: تماس‌های فعال */
.live-call {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}
.live-call:last-child { border-bottom: none; }
.live-call .pulse {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.live-call.ringing .pulse { background: var(--warning); animation: pulse 1s infinite; }
.live-call.answered .pulse { background: var(--success); }

/* موبایل */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset-inline-start: 0; z-index: 50; transform: translateX(100%); transition: transform .2s; }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex !important; }
  .content { padding: 16px 14px 40px; }
}
.menu-toggle { display: none; }
