/* ========================================================================
   VOOB WhatsApp — Dashboard Design System (لايت مود، RTL)
   متناسق مع صفحة الهبوط: أبيض/أخضر، Plus Jakarta Sans
   ======================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');
:root {
  --bg: #f6f8f7;             /* خلفية المحتوى */
  --bg-mint: #ecfdf5;
  --surface: #ffffff;
  --surface-2: #f4f7f5;
  --surface-3: #eef2f0;
  --elevated: #ffffff;
  --border: #e4ebe7;
  --border-soft: #eef2f0;

  --text: #0f1b16;
  --text-2: #51635b;
  --muted: #8a9a92;

  --accent: #16a34a;
  --accent-2: #25d366;
  --accent-ink: #064e2b;
  --accent-soft: #dcfce7;
  --accent-glow: rgba(22,163,74,.22);

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --info: #0891b2;
  --info-bg: #ecfeff;

  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;
  --sh-1: 0 1px 3px rgba(16,40,28,.06), 0 1px 2px rgba(16,40,28,.04);
  --sh-2: 0 8px 24px rgba(16,40,28,.08);
  --sh-3: 0 20px 50px rgba(16,40,28,.14);
  --sh-glow: 0 10px 28px rgba(22,163,74,.25);

  --t-fast: .15s cubic-bezier(.4,0,.2,1);
  --t: .22s cubic-bezier(.4,0,.2,1);
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, Tahoma, sans-serif;
  font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
a { cursor: pointer; text-decoration: none; color: inherit; }
.muted { color: var(--muted); }
::selection { background: var(--accent-soft); }
.num, td, th, .card-num, .stat-num, .time { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cdd8d2; border-radius: var(--r-full); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #b4c2bb; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================ أزرار ============================ */
button, .btn {
  font-family: inherit; font-size: 14px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff; border: 0; padding: 10px 18px; border-radius: var(--r-sm);
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: transform var(--t-fast), box-shadow var(--t-fast), filter var(--t-fast);
  box-shadow: var(--sh-glow);
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(22,163,74,.35); }
button:active, .btn:active { transform: translateY(0); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.ghost { background: #fff; border: 1px solid var(--border); color: var(--text-2); box-shadow: var(--sh-1); }
button.ghost:hover { background: var(--surface-2); color: var(--accent); border-color: var(--accent); box-shadow: var(--sh-1); }
button.danger { background: linear-gradient(135deg, #ef4444, var(--danger)); box-shadow: 0 8px 20px rgba(220,38,38,.25); }
button.small { padding: 6px 12px; font-size: 13px; }
button.icon { padding: 8px; border-radius: var(--r-sm); }
button[disabled] { opacity: .55; cursor: default; box-shadow: none; }

/* ============================ حقول الإدخال ============================ */
input, textarea, select {
  background: #fff; border: 1px solid var(--border); color: var(--text);
  padding: 11px 14px; border-radius: var(--r-sm); font-family: inherit; font-size: 14px; width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
select { cursor: pointer; }
label { font-weight: 500; }

/* ============================ تسجيل الدخول ============================ */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background: radial-gradient(800px 500px at 80% -10%, var(--bg-mint), transparent 60%), var(--bg); }
.login-card {
  background: #fff; padding: 40px 34px; border-radius: var(--r-xl); width: 360px; max-width: 92vw;
  display: flex; flex-direction: column; gap: 16px; border: 1px solid var(--border); box-shadow: var(--sh-3);
  position: relative; overflow: hidden;
}
.login-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.login-card .logo { font-size: 24px; font-weight: 800; text-align: center; letter-spacing: -.5px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }
.logo span { color: var(--accent); }

/* ============================ التخطيط ============================ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #fff; border-left: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { font-size: 19px; font-weight: 800; padding: 6px 10px 18px; letter-spacing: -.5px; display: flex; align-items: center; gap: 8px; }
.sidebar .logo span { color: var(--accent); }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
nav a {
  padding: 10px 14px; border-radius: var(--r-sm); color: var(--text-2);
  display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 14px;
  transition: background var(--t-fast), color var(--t-fast); position: relative;
}
nav a svg { width: 19px; height: 19px; flex: 0 0 auto; opacity: .8; }
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
nav a.active::before { content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; border-radius: var(--r-full); background: var(--accent); }
nav a.active svg { opacity: 1; color: var(--accent); }
.logout { margin-top: 8px; background: #fff; border: 1px solid var(--border); color: var(--muted); justify-content: center; box-shadow: none; }
.logout:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); box-shadow: none; }

.content { flex: 1; padding: 24px 28px; max-width: 100%; overflow-x: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 14px; flex-wrap: wrap; }
.topbar h1 { font-size: 23px; margin: 0; font-weight: 800; letter-spacing: -.5px; }
.session-pick { display: flex; align-items: center; gap: 10px; background: #fff; padding: 6px 8px 6px 14px; border-radius: var(--r-full); border: 1px solid var(--border); box-shadow: var(--sh-1); }
.session-pick label { font-size: 13px; color: var(--muted); }
.session-pick select { width: auto; min-width: 150px; border: 0; background: transparent; padding: 4px 8px; border-radius: var(--r-sm); box-shadow: none; }
.session-pick select:focus { box-shadow: none; }

/* ============================ بطاقات الإحصاء ============================ */
.cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 1200px) { .cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--sh-1); transition: transform var(--t), box-shadow var(--t), border-color var(--t); }
.card:hover { transform: translateY(-3px); box-shadow: var(--sh-2); border-color: #cfe9d9; }
.card .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 14px; background: var(--accent-soft); color: var(--accent); }
.card .ico svg { width: 20px; height: 20px; }
.card .num { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -1px; color: var(--text); }
.card .label { color: var(--text-2); margin-top: 6px; font-size: 13px; font-weight: 500; }

/* ============================ ألواح ============================ */
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 22px; margin-bottom: 18px; box-shadow: var(--sh-1); }
.panel h3 { margin: 0 0 18px; font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.panel h3 svg { color: var(--accent); width: 18px; height: 18px; }
.count-pill { background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: var(--r-full); }
.superadmin-only { display: none; }
.lead-details { font-size: 13px; line-height: 1.7; max-width: 420px; }
.lead-details div { margin: 1px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ============================ جداول ============================ */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }

/* ============================ شارات ============================ */
.badge { padding: 4px 11px; border-radius: var(--r-full); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.connected { background: var(--ok-bg); color: var(--ok); }
.badge.qr, .badge.connecting { background: var(--warn-bg); color: var(--warn); }
.badge.disconnected, .badge.loggedout { background: var(--danger-bg); color: var(--danger); }

/* ============================ QR / اقتران ============================ */
.qr-box { text-align: center; padding: 24px; }
.qr-box img { background: #fff; padding: 14px; border-radius: var(--r-lg); width: 280px; max-width: 80vw; box-shadow: var(--sh-2); border: 1px solid var(--border); }
.pairing-code { font-size: 40px; letter-spacing: 8px; font-weight: 800; margin: 18px 0; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ============================ صندوق المحادثات ============================ */
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 130px); min-height: 0; }
.conv-list { background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); overflow-y: auto; min-height: 0; box-shadow: var(--sh-1); }
.conv-item { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: background var(--t-fast); display: flex; flex-direction: column; gap: 3px; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.conv-item .name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.conv-item .preview { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat { background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); display: flex; flex-direction: column; min-height: 0; overflow: hidden; box-shadow: var(--sh-1); }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex: 0 0 auto; background: var(--surface-2); }
.chat-body { flex: 1 1 auto; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; min-height: 0; background: var(--bg); background-image: radial-gradient(rgba(16,40,28,.025) 1px, transparent 1px); background-size: 22px 22px; }
.bubble { max-width: 72%; padding: 10px 14px; border-radius: var(--r-lg); line-height: 1.55; white-space: pre-wrap; word-break: break-word; box-shadow: var(--sh-1); animation: bubbleIn .2s ease-out; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bubble.in { background: #fff; align-self: flex-start; border-bottom-right-radius: 4px; border: 1px solid var(--border); }
.bubble.out { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; align-self: flex-end; border-bottom-left-radius: 4px; }
.bubble .time { font-size: 10px; opacity: .6; margin-top: 5px; }
.bubble.in .time { color: var(--muted); }
.chat-input { flex: 0 0 auto; padding: 14px; border-top: 1px solid var(--border); display: flex; gap: 10px; background: #fff; }
.chat-input input { flex: 1; border-radius: var(--r-full); }
.chat-input select { width: auto; min-width: 52px; border-radius: var(--r-full); }
.chat-input button { border-radius: var(--r-full); }
.meta-chips { font-size: 12px; color: var(--muted); margin-right: 8px; display: inline-flex; gap: 6px; align-items: center; }
.tag { background: var(--accent-soft); border: 1px solid #bbf7d0; color: var(--accent-ink); padding: 2px 9px; border-radius: var(--r-full); font-size: 11px; font-weight: 700; display: inline-block; margin: 1px; }

/* ============================ مخطط بياني (SVG) ============================ */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; max-height: 260px; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .bar { transition: opacity var(--t-fast); cursor: pointer; }
.chart .bar:hover { opacity: .82; }
.legend { display: flex; gap: 20px; margin-top: 14px; font-size: 13px; color: var(--text-2); justify-content: center; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ============================ توست ============================ */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 13px 22px; border-radius: var(--r);
  opacity: 0; transition: opacity var(--t), transform var(--t); pointer-events: none; z-index: 1000;
  box-shadow: var(--sh-3); border-right: 3px solid var(--accent-2); font-weight: 600;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-right-color: var(--danger); }

/* ============================ حالات فارغة / أكواد ============================ */
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty svg { width: 44px; height: 44px; opacity: .4; margin-bottom: 12px; }
code.key { background: var(--surface-3); padding: 10px 14px; border-radius: var(--r-sm); word-break: break-all; display: block; margin: 8px 0; font-family: 'Consolas', monospace; color: var(--accent-ink); border: 1px dashed var(--border); }

/* ============================ هيكل تحميل ============================ */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================ استجابة ============================ */
@media (max-width: 860px) {
  :root { --sidebar-w: 64px; }
  .sidebar { padding: 16px 8px; }
  .sidebar .logo span, nav a span, .logout span { display: none; }
  nav a { justify-content: center; padding: 12px; }
  nav a.active::before { display: none; }
  .inbox { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .content { padding: 16px 14px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
