/* =====================================================
   مدعوم - WhatsApp Business API Dashboard
   Design System & Global Styles
   ===================================================== */

/* الخط الموحد مع لوحة الإدارة - Cairo فقط */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

/* ─── CSS Variables - موحدة مع admin-dashboard ─── */
:root {
  /* Brand Colors - متطابقة مع styles.css الرئيسي */
  --brand-primary: #0077CC;
  --brand-secondary: #003366;
  --brand-accent: #0055AA;
  --brand-whatsapp: #25D366;
  --brand-whatsapp-dark: #128C7E;

  /* Dark Theme - متطابق مع admin-dashboard */
  --bg-base: #0E0E10;
  --bg-surface: #1A1A1A;
  --bg-card: #1e2a3a;
  --bg-card-hover: #243347;
  --bg-sidebar: #0a1628;
  --bg-elevated: #162236;
  --bg-glass: rgba(14, 30, 54, 0.85);

  /* Borders - لون أزرق بدلاً من أبيض شفاف */
  --border-subtle: rgba(0, 119, 204, 0.12);
  --border-default: rgba(0, 119, 204, 0.20);
  --border-strong: rgba(0, 119, 204, 0.35);
  --border-brand: rgba(0, 119, 204, 0.40);

  /* Text - متطابق مع admin-dashboard dark mode */
  --text-primary: #E0E0E0;
  --text-secondary: #B0B0B0;
  --text-muted: #808080;
  --text-brand: #0077CC;
  --text-accent: #0088DD;

  /* Status Colors - متطابقة مع styles.css */
  --status-success: #4CAF50;
  --status-warning: #FFB300;
  --status-error: #F44336;
  --status-info: #0088DD;
  --status-pending: #9C27B0;

  /* Shadows - بلون أزرق مطابق للوحة الإدارة */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-brand: 0 4px 20px rgba(0, 119, 204, 0.25);
  --shadow-glow: 0 0 30px rgba(0, 119, 204, 0.20);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Typography - Cairo فقط كما في admin-dashboard */
  --font-primary: 'Cairo', sans-serif;
  --font-secondary: 'Cairo', sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 15px;
  --font-size-md: 17px;
  --font-size-lg: 20px;
  --font-size-xl: 24px;
  --font-size-2xl: 30px;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 64px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Light Theme ─── */
[data-wa-theme="light"] {
  /* Light Background Colors */
  --bg-base: #FFFFFF;
  --bg-surface: #F5F5F5;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F9F9F9;
  --bg-sidebar: #F8F8F8;
  --bg-elevated: #F0F0F0;
  --bg-glass: rgba(255, 255, 255, 0.95);

  /* Light Borders */
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.18);
  --border-brand: rgba(0, 119, 204, 0.2);

  /* Light Text */
  --text-primary: #1A1A1A;
  --text-secondary: #555555;
  --text-muted: #999999;
  --text-brand: #0077CC;
  --text-accent: #0055AA;

  /* Light Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
  --shadow-brand: 0 4px 20px rgba(0, 119, 204, 0.1);
  --shadow-glow: 0 0 30px rgba(0, 119, 204, 0.08);
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  direction: rtl;
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  /* تدرج أزرق مطابق لألوان لوحة الإدارة */
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(0, 119, 204, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 85, 170, 0.04) 0%, transparent 50%);
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ─── Typography ─── */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.3; }
h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
p { line-height: 1.7; color: var(--text-secondary); font-size: var(--font-size-base); }

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

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar-header {
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-height);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
  font-size: 18px;
  font-weight: 900;
  color: #FFFFFF;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand-name {
  font-size: var(--font-size-md);
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.3px;
}

.sidebar-brand-tag {
  font-size: var(--font-size-xs);
  color: var(--brand-primary);
  font-weight: 600;
  background: rgba(0, 119, 204, 0.12);
  padding: 1px 8px;
  border-radius: 99px;
  width: fit-content;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: var(--space-4) var(--space-3) var(--space-2);
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  margin-bottom: 2px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}

.nav-item.active {
  background: rgba(0, 119, 204, 0.12);
  border-color: var(--border-brand);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--brand-primary);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  transition: all var(--transition);
  background: var(--bg-elevated);
}

.nav-item.active .nav-icon {
  background: rgba(0, 119, 204, 0.15);
  color: var(--brand-primary);
}

.nav-item:hover .nav-icon {
  transform: scale(1.05);
}

.nav-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.nav-item.active .nav-label { color: var(--text-primary); }
.nav-item:hover .nav-label { color: var(--text-primary); }

.nav-badge {
  margin-right: auto;
  margin-left: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--brand-primary);
  color: #FFFFFF;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border-subtle);
}

.user-card:hover { background: var(--bg-card-hover); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
  flex-shrink: 0;
}

.user-info { overflow: hidden; }
.user-name { font-size: var(--font-size-sm); font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: var(--font-size-xs); color: var(--text-muted); }

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-right var(--transition);
}

/* عند صفحة الرسائل - منع الـ scroll وإخفاء الـ overflow */
.main-content:has(#page-messages.active) {
  overflow: hidden;
  height: 100vh;
}

/* ─── Top Header ─── */
.top-header {
  height: var(--header-height);
  background: rgba(10, 22, 40, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title { font-size: var(--font-size-md); font-weight: 700; color: var(--text-primary); }
.header-subtitle { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 2px; }

.header-actions { display: flex; align-items: center; gap: var(--space-3); }

.icon-btn {
  width: 38px; height: 38px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.icon-btn:hover { background: var(--bg-card-hover); border-color: var(--border-default); color: var(--text-primary); }
.icon-btn svg { width: 20px; height: 20px; }

.notif-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--brand-primary);
  border-radius: 99px;
  border: 1.5px solid var(--bg-surface);
}
/* ─── Page Content ─── */
.page-content {
  flex: 1;
  padding: var(--space-8);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* صفحة الرسائل - إزالة الـ padding وتمرير الارتفاع */
.page-content:has(#page-messages.active) {
  padding: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.page { display: none; animation: pageFadeIn 0.3s ease; }
.page.active { display: block; }

/* صفحة الرسائل تحتاج display: flex لتمرير الارتفاع للأبناء */
#page-messages.page.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Page Header ─── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap: var(--space-4);
}

.page-header-text h2 { font-size: var(--font-size-xl); font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); }
.page-header-text p { font-size: var(--font-size-sm); color: var(--text-secondary); margin-top: 4px; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 119, 204, 0.3), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover { border-color: var(--border-default); background: var(--bg-card-hover); }
.card:hover::before { opacity: 1; }

/* ─── Toast Animations ─── */
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -20px); }
}

.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: all var(--transition);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, transparent 60%, rgba(255,255,255,0.015));
  pointer-events: none;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-default);
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon.green { background: rgba(0, 119, 204, 0.12); }
.stat-icon.teal { background: rgba(0, 85, 170, 0.10); }
.stat-icon.blue { background: rgba(0, 136, 221, 0.10); }
.stat-icon.purple { background: rgba(156, 39, 176, 0.10); }
.stat-icon.orange { background: rgba(255, 152, 0, 0.10); }

.stat-info { flex: 1; }
.stat-value { font-size: var(--font-size-xl); font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: var(--font-size-xs); color: var(--text-secondary); margin-top: 4px; }
.stat-change {
  font-size: var(--font-size-xs);
  font-weight: 600;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 99px;
  width: fit-content;
}
.stat-change.up { background: rgba(0, 119, 204, 0.10); color: var(--brand-primary); }
.stat-change.down { background: rgba(255, 71, 87, 0.1); color: var(--status-error); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 15px rgba(30, 60, 114, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(30, 60, 114, 0.50);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-default);
  color: var(--text-secondary);
}

.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-whatsapp {
  background: linear-gradient(135deg, var(--brand-whatsapp), var(--brand-whatsapp-dark));
  color: #fff;
  font-size: var(--font-size-base);
  padding: 14px var(--space-8);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 25px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 35px rgba(37, 211, 102, 0.45);
}

.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger { background: rgba(255, 71, 87, 0.1); border-color: rgba(255, 71, 87, 0.3); color: var(--status-error); }
.btn-danger:hover { background: rgba(255, 71, 87, 0.2); }

.btn-sm { padding: 7px var(--space-3); font-size: var(--font-size-xs); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 14px var(--space-8); font-size: var(--font-size-base); }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ─── Form Elements ─── */
.form-group { margin-bottom: var(--space-5); }
.form-label { display: block; font-size: var(--font-size-sm); font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-2); }
.form-label span { color: var(--status-error); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px var(--space-4);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: var(--font-size-sm);
  transition: all var(--transition);
  outline: none;
  direction: rtl;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.15);
  background: var(--bg-card);
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-card); color: var(--text-primary); }
.form-textarea { min-height: 120px; resize: vertical; }

/* ─── Badges / Status ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge.success { background: rgba(0, 119, 204, 0.10); color: var(--brand-primary); }
.badge.success::before { background: var(--brand-primary); box-shadow: 0 0 5px var(--brand-primary); animation: pulse-dot 2s infinite; }
.badge.warning { background: rgba(255, 179, 0, 0.1); color: var(--status-warning); }
.badge.warning::before { background: var(--status-warning); }
.badge.error { background: rgba(255, 71, 87, 0.1); color: var(--status-error); }
.badge.error::before { background: var(--status-error); }
.badge.info { background: rgba(33, 150, 243, 0.1); color: var(--status-info); }
.badge.info::before { background: var(--status-info); }
.badge.pending { background: rgba(156, 39, 176, 0.1); color: var(--status-pending); }
.badge.pending::before { background: var(--status-pending); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Tables ─── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}

.table th {
  background: var(--bg-elevated);
  padding: 16px var(--space-6);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.table td {
  padding: 18px var(--space-6);
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: background var(--transition);
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-elevated); }

/* ─── Section Card (كان مستخدم كـ class بدون تعريف، والتنسيق كله inline) ─── */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.section-card-header {
  padding: 16px var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.section-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
}
.section-card-title svg { width: 18px; height: 18px; color: var(--brand-primary); }
.section-card.danger { border: 1px solid var(--status-error); background: rgba(239, 68, 68, 0.05); }
.section-card-body { padding: var(--space-6); }
.section-card-body.no-padding { padding: 0; }

/* ─── Tag (نفس class المستخدم بالفعل في صفحات التقارير) ─── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.tag-primary { background: rgba(0, 119, 204, 0.1); color: var(--brand-primary); border-color: rgba(0, 119, 204, 0.2); }
.tag-success { background: rgba(76, 175, 80, 0.1); color: var(--status-success); }
.tag-success .tag-dot { background: var(--status-success); }
.tag-danger { background: rgba(244, 67, 54, 0.1); color: var(--status-error); }

/* ─── Dropdown menu ─── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 100;
  display: none;
}
.dropdown-menu a {
  display: block;
  padding: 12px 16px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.2s;
}
.dropdown-menu a:hover { background: rgba(255, 255, 255, 0.05); }
.dropdown-menu.show { display: block; }

/* ─── حقل بحث بأيقونة ─── */
.input-icon-wrap { position: relative; }
.input-icon-wrap .form-input { padding-inline-end: 40px; }
.inp-icon {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--text-muted);
  display: flex;
  pointer-events: none;
}
.inp-icon svg { width: 18px; height: 18px; }

/* ─── Segmented tabs (فلتر الحالة في تفاصيل الحملة) ─── */
.segment-tabs { background: var(--bg-elevated); padding: 4px; border-radius: 10px; display: flex; gap: 4px; }
.seg-tab { padding: 6px 16px; font-size: 12px; font-weight: 700; cursor: pointer; border-radius: 8px; transition: all var(--transition); color: var(--text-secondary); }

/* ─── بطاقات إحصائيات تقرير الحملة ─── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-5); }
.report-stat-card {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
.report-stat-card.accent-success { border-inline-end: 4px solid var(--status-success); }
.report-stat-card.accent-danger { border-inline-end: 4px solid var(--status-error); }
.report-stat-card-head { display: flex; justify-content: space-between; align-items: center; }
.report-stat-card-head span { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.report-stat-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.report-stat-icon svg { width: 18px; height: 18px; }
.report-stat-icon.primary { background: rgba(0, 119, 204, 0.1); color: var(--brand-primary); }
.report-stat-icon.success { background: rgba(76, 175, 80, 0.1); color: var(--status-success); }
.report-stat-icon.danger { background: rgba(244, 67, 54, 0.1); color: var(--status-error); }
.report-stat-icon.info { background: rgba(0, 136, 221, 0.1); color: var(--status-info); }
.report-stat-value { font-size: 28px; font-weight: 800; color: var(--text-primary); }
.report-stat-value.success { color: var(--status-success); }
.report-stat-value.danger { color: var(--status-error); }
.report-stat-value.primary { color: var(--brand-primary); }

/* ─── صف بيانات بسيط (مستخدم في الشريط الجانبي لإرسال الرسائل) ─── */
.split-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
}
.split-row .label { font-size: 13px; color: var(--text-secondary); }
.split-row .value { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.split-row .value.success { color: var(--status-success); }
.split-row .value.danger { color: var(--status-error); }
.split-row .value.primary { color: var(--brand-primary); }
.split-row.success .label { color: var(--status-success); }
.split-row.danger .label { color: var(--status-error); }

/* ─── عناصر قائمة الأرقام المستلمة ─── */
.recipient-item {
  font-size: 12px;
  padding: 8px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.window-badge { font-size: 10px; font-weight: 600; color: var(--text-muted); }
.window-badge.open { color: var(--status-success); }
.window-badge.closed { color: var(--status-error); }

/* ─── بطاقة اختيار قالب (بدلاً من onmouseover/onmouseout) ─── */
.template-select-item {
  padding: 12px;
  margin-bottom: 8px;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
}
.template-select-item:hover { border-color: var(--brand-primary); background: var(--bg-elevated); }
.template-select-item .t-name { font-weight: 600; margin-bottom: 4px; }
.template-select-item .t-cat { font-size: 12px; color: var(--text-secondary); }
.template-select-item.disabled { border: 1px solid var(--border-subtle); opacity: 0.6; cursor: default; }

/* ─── حالات فارغة / تحميل داخل الصفحة ─── */
.page-loading-state { padding: 40px; text-align: center; color: var(--text-secondary); }
.page-loading-state .spinner { margin: 0 auto 15px; }
.page-empty-state { text-align: center; padding: 60px 20px; }
.page-empty-state .icon { width: 48px; height: 48px; margin: 0 auto 20px; color: var(--text-muted); }
.page-empty-state .icon svg { width: 100%; height: 100%; }
.page-empty-state h3 { font-size: 18px; color: var(--text-primary); margin-bottom: 8px; }
.page-empty-state p { color: var(--text-secondary); max-width: 320px; margin: 0 auto 20px; }

/* ─── Toast Notifications ─── */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  left: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
  backdrop-filter: blur(20px);
}

.toast.hiding { animation: toastOut 0.3s ease forwards; }

.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-size: var(--font-size-sm); font-weight: 700; color: var(--text-primary); }
.toast-msg { font-size: var(--font-size-xs); color: var(--text-secondary); margin-top: 2px; }

.toast.success { border-color: rgba(0, 119, 204, 0.35); }
.toast.error { border-color: rgba(255, 71, 87, 0.3); }
.toast.warning { border-color: rgba(255, 179, 0, 0.3); }
.toast.info { border-color: rgba(0, 136, 221, 0.3); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-20px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-20px); }
}

/* ─── Loading Skeleton ─── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ─── Divider ─── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-5) 0;
}

/* ─── Grid Layouts ─── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-5); }

/* ─── Flex utilities ─── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.flex-1 { flex: 1; }

/* ─── Text utilities ─── */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-brand { color: var(--brand-primary); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }

/* ─── Spacing utilities ─── */
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-auto { margin-top: auto; }

/* ─── Responsive ─── */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar-brand, .nav-label, .nav-section-label, .nav-badge, .user-info { display: none; }
  .main-content { margin-right: var(--sidebar-collapsed); }
  .sidebar-header { justify-content: center; padding: var(--space-4); }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item.active::before { right: auto; left: 0; }
  .user-card { justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .page-content { padding: var(--space-4); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .top-header { padding: 0 var(--space-4); }
}

/* ─── Page-Specific Styles ─── */

/* Dashboard Overview */
.welcome-banner {
  background: linear-gradient(135deg, rgba(30, 60, 114, 0.15) 0%, rgba(42, 82, 152, 0.08) 100%);
  border: 1px solid var(--border-brand);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-10);
  margin-bottom: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  position: relative;
  overflow: hidden;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(0, 119, 204, 0.10), transparent 70%);
  pointer-events: none;
}

.welcome-title { font-size: var(--font-size-2xl); color: var(--text-primary); font-weight: 800; }
.welcome-title span { color: var(--brand-primary); }
.welcome-sub { font-size: var(--font-size-base); color: var(--text-secondary); margin-top: 6px; }

.welcome-graphic { font-size: 80px; opacity: 0.8; flex-shrink: 0; }

/* WhatsApp Connect Page */
.connect-hero {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  position: relative;
}

.connect-icon {
  width: 100px; height: 100px;
  background: linear-gradient(135deg, rgba(0, 119, 204, 0.15), rgba(0, 85, 170, 0.05));
  border: 2px solid rgba(0, 119, 204, 0.30);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 50px;
  margin: 0 auto var(--space-6);
  position: relative;
}

.connect-icon::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(0, 119, 204, 0.12);
  animation: pulse-ring 3s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.05); opacity: 0.1; }
}

.connect-hero h2 { font-size: var(--font-size-2xl); margin-bottom: var(--space-3); }
.connect-hero p { font-size: var(--font-size-base); max-width: 480px; margin: 0 auto; }

.connect-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin: var(--space-10) 0;
}

.step-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  position: relative;
  transition: all var(--transition);
}

.step-card:hover { transform: translateY(-3px); border-color: var(--border-brand); }

.step-num {
  width: 36px; height: 36px;
  background: rgba(0, 119, 204, 0.12);
  border: 1px solid var(--border-brand);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--brand-primary);
  margin: 0 auto var(--space-3);
}

.step-icon { font-size: 28px; margin-bottom: var(--space-3); }
.step-title { font-size: var(--font-size-sm); font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.step-desc { font-size: var(--font-size-xs); color: var(--text-secondary); line-height: 1.6; }

/* OAuth States */
.state-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.9);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.state-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-10);
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.state-icon { font-size: 64px; margin-bottom: var(--space-5); }
.state-title { font-size: var(--font-size-xl); font-weight: 800; color: var(--text-primary); margin-bottom: var(--space-3); }
.state-message { font-size: var(--font-size-sm); color: var(--text-secondary); line-height: 1.7; }

.spinner {
  width: 56px; height: 56px;
  border: 3px solid var(--border-default);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto var(--space-5);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Template Cards */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-5); }

.template-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.template-card:hover { border-color: var(--border-brand); transform: translateY(-2px); box-shadow: var(--shadow-brand); }
.template-card.selected { border-color: var(--brand-primary); background: rgba(0, 119, 204, 0.05); }

.template-type-badge {
  position: absolute;
  top: var(--space-3); left: var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
}

.template-type-badge.marketing { background: rgba(255, 152, 0, 0.15); color: #FFA000; }
.template-type-badge.utility { background: rgba(33, 150, 243, 0.15); color: var(--status-info); }
.template-type-badge.auth { background: rgba(156, 39, 176, 0.15); color: var(--status-pending); }
.template-type-badge.support { background: rgba(0, 119, 204, 0.15); color: var(--brand-primary); }

.template-name { font-size: var(--font-size-base); font-weight: 700; color: var(--text-primary); margin-bottom: var(--space-2); margin-top: var(--space-6); }
.template-preview {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-footer { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }

/* WA Message Preview */
.wa-phone-mock {
  background: #111B21;
  border-radius: 30px;
  padding: 20px 16px;
  border: 6px solid #1F2C34;
  max-width: 300px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.wa-header-bar {
  background: #1F2C34;
  border-radius: 12px 12px 0 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1px;
}

.wa-avatar { width: 36px; height: 36px; background: var(--brand-whatsapp); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.wa-chat-name { font-size: 13px; font-weight: 700; color: #E9EBF0; }
.wa-status { font-size: 10px; color: #8696A0; }

.wa-chat-area {
  background: #0B141A;
  min-height: 200px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wa-bubble {
  background: #1F2C34;
  border-radius: 8px 0 8px 8px;
  padding: 10px 12px;
  max-width: 85%;
  align-self: flex-start;
  position: relative;
}

.wa-bubble-text { font-size: 12px; color: #E9EBF0; line-height: 1.5; direction: rtl; }
.wa-time { font-size: 10px; color: #8696A0; margin-top: 4px; text-align: left; }

/* Status Indicators */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.status-row:last-child { border-bottom: none; }
.status-row-label { font-size: var(--font-size-sm); color: var(--text-secondary); display: flex; align-items: center; gap: var(--space-3); }
.status-row-label .icon { font-size: 18px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: var(--font-size-md); font-weight: 800; }
.modal-close { width: 32px; height: 32px; background: var(--bg-elevated); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 14px; color: var(--text-secondary); transition: all var(--transition); }
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.modal-body { padding: var(--space-6); }
.modal-footer { padding: var(--space-5) var(--space-6); border-top: 1px solid var(--border-subtle); display: flex; gap: var(--space-3); justify-content: flex-end; }

/* Quick Actions */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-8); }

.quick-action {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.quick-action:hover { border-color: var(--border-brand); transform: translateY(-2px); background: var(--bg-card-hover); }
.quick-action-icon { font-size: 28px; margin-bottom: var(--space-3); }
.quick-action-label { font-size: var(--font-size-xs); font-weight: 600; color: var(--text-secondary); }

/* ─── Sidebar Toggle for mobile ─── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200;
  width: 40px; height: 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

@media (max-width: 640px) { .sidebar-toggle { display: flex; } }

/* ─── Charts placeholder ─── */
.chart-container {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border-default);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  flex-direction: column;
  gap: var(--space-3);
}

/* Messages page */
.message-list { display: flex; flex-direction: column; gap: var(--space-3); }

.message-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  cursor: pointer;
  transition: all var(--transition);
}

.message-item:hover { border-color: var(--border-default); background: var(--bg-card-hover); }
.message-item.unread { border-right: 3px solid var(--brand-primary); }

.message-avatar {
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.message-info { flex: 1; overflow: hidden; }
.message-name { font-size: var(--font-size-sm); font-weight: 700; color: var(--text-primary); }
.message-text { font-size: var(--font-size-xs); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.message-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.message-time { font-size: var(--font-size-xs); color: var(--text-muted); }
.message-count { background: var(--brand-primary); color: #0A0E1A; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }

/* Settings */
.settings-section { margin-bottom: var(--space-8); }
.settings-section-title { font-size: var(--font-size-base); font-weight: 700; color: var(--text-primary); margin-bottom: var(--space-5); display: flex; align-items: center; gap: var(--space-3); }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  gap: var(--space-4);
  transition: all var(--transition);
}

.setting-row:hover { border-color: var(--border-default); }
.setting-info h4 { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); }
.setting-info p { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 3px; }

/* Toggle Switch */
.toggle {
  width: 44px; height: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 99px;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
  flex-shrink: 0;
}

.toggle.on { background: var(--brand-primary); border-color: var(--brand-primary); }
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; right: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.toggle.on::after { transform: translateX(-20px); }

/* Professional WhatsApp-style Inbox */
.whatsapp-inbox-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}
.wa-inbox-loading {
  color: var(--text-secondary); text-align: center; padding: 32px 18px;
}
.wa-chat-state.error { color: var(--status-error); }
.wa-inbox-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  flex: 1;
  overflow: hidden;
  background: var(--bg-card);
  border: none;
  border-radius: 0;
  box-shadow: none;
  height: 100%;
}
.wa-inbox-sidebar {
  display: flex; flex-direction: column; min-width: 0;
  background: rgba(18, 18, 18, 0.94);
  border-left: 1px solid var(--border-subtle);
}
.wa-inbox-sidebar-head, .wa-chat-header {
  min-height: 74px; padding: 14px 18px; display: flex; align-items: center; gap: 12px;
  background: rgba(36, 36, 36, 0.92); border-bottom: 1px solid var(--border-subtle);
}
.wa-inbox-sidebar-head { justify-content: space-between; flex-direction: column; align-items: flex-start; min-height: auto; gap: 12px; }
.wa-inbox-sidebar-head > div:first-child { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.wa-user-section { display: flex; align-items: center; gap: 12px; width: 100%; }
.wa-user-avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-whatsapp-dark), var(--brand-primary)); color: white; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.wa-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wa-user-info strong { color: #fff; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-user-info span { color: var(--text-muted); font-size: 12px; }
.wa-user-actions { display: flex; gap: 8px; }
.wa-action-btn { width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--bg-elevated); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; font-size: 16px; transition: all var(--transition); border: 1px solid transparent; }
.wa-action-btn:hover { background: rgba(37, 211, 102, 0.18); color: #fff; }
.wa-inbox-sidebar-head h2 { font-size: 19px; color: #fff; margin: 0; }
.wa-inbox-sidebar-head p, .wa-chat-title span { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.wa-inbox-header { padding: 12px 18px; background: rgba(18, 18, 18, 0.82); border-bottom: 1px solid var(--border-subtle); }
.wa-inbox-header h2 { font-size: 18px; color: #fff; margin: 0 0 4px; }
.wa-inbox-header p { font-size: 12px; color: var(--text-muted); margin: 0; }
.wa-icon-action {
  width: 38px; height: 38px; border-radius: var(--radius-full); color: var(--text-secondary);
  background: var(--bg-elevated); display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--transition); font-size: 18px;
}
.wa-icon-action:hover { color: #fff; background: rgba(37, 211, 102, 0.18); }
.wa-search { padding: 10px 12px; background: rgba(18, 18, 18, 0.82); border-bottom: 1px solid var(--border-subtle); }
.wa-search input {
  width: 100%; height: 40px; border: 1px solid var(--border-subtle); border-radius: var(--radius-full);
  background: var(--bg-elevated); color: var(--text-primary); padding: 0 16px; outline: none; font-family: inherit;
}
.wa-search input:focus { border-color: rgba(37, 211, 102, 0.45); box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.08); }
.wa-conversations { flex: 1; overflow-y: auto; }
.wa-conversation {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  color: inherit; text-align: right; border-bottom: 1px solid rgba(255,255,255,0.045);
  transition: all var(--transition); position: relative; cursor: pointer;
}
.wa-conversation:hover { background: rgba(255,255,255,0.08); }
.wa-conversation.active { background: rgba(37, 211, 102, 0.12); border-left: 3px solid var(--brand-whatsapp); }
.wa-conversation.active::before {
  content: ''; position: absolute; inset-block: 10px; right: 0; width: 3px; border-radius: 99px;
  background: var(--brand-whatsapp);
}
.wa-conversation-avatar, .wa-chat-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-whatsapp-dark), var(--brand-primary));
  color: white; font-weight: 800; box-shadow: 0 8px 22px rgba(0,0,0,0.28);
}
.wa-conversation-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.wa-conversation-top, .wa-conversation-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wa-conversation-top strong { color: var(--text-primary); font-size: 14px; direction: ltr; unicode-bidi: plaintext; }
.wa-conversation-top time { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.wa-conversation-bottom span { color: var(--text-secondary); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wa-unread { min-width: 21px; height: 21px; padding: 0 7px; border-radius: var(--radius-full); background: var(--brand-whatsapp); color: #07140c; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.wa-chat-window { display: flex; flex-direction: column; min-width: 0; background: #0b141a; position: relative; }
.wa-chat-window::before {
  content: ''; position: absolute; inset: 74px 0 70px; opacity: 0.08; pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, #fff 1px, transparent 0); background-size: 24px 24px;
}
.wa-chat-header { position: relative; z-index: 1; justify-content: space-between; align-items: center; }
.wa-chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.wa-chat-title strong { display: block; color: #fff; direction: ltr; unicode-bidi: plaintext; }
.wa-chat-title span { display: block; color: var(--text-muted); font-size: 12px; }
.wa-chat-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.wa-chat-placeholder-title { color: var(--text-secondary); font-weight: 700; }
.wa-messages { flex: 1; overflow-y: auto; padding: 24px clamp(14px, 3vw, 42px); position: relative; z-index: 1; display: flex; flex-direction: column; gap: 8px; }
.wa-bubble {
  width: fit-content; 
  max-width: min(68%, 620px); 
  padding: 10px 12px 8px; 
  border-radius: 14px;
  color: #e9edef; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.18); 
  position: relative; 
  overflow: visible;
  display: flex; 
  flex-direction: column; 
  gap: 4px;
  min-width: 80px;
}
.wa-bubble.inbound { align-self: flex-start; background: #202c33; border-top-left-radius: 4px; }
.wa-bubble.outbound { align-self: flex-end; background: #0a3a6e; border-top-right-radius: 4px; }
.wa-bubble-text { 
  white-space: pre-wrap; 
  word-wrap: break-word; 
  word-break: break-word; 
  overflow-wrap: break-word; 
  font-size: 15px; 
  line-height: 1.6; 
  color: inherit !important; 
  margin: 0; 
  display: block;
  min-height: 1.6em;
  width: 100%;
}
.wa-bubble-meta { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 4px; color: rgba(233,237,239,0.7); font-size: 11px; }
.wa-delivery.read { color: #53bdeb; }
.wa-media-preview { display: block; margin: -2px -4px 7px; border-radius: 10px; overflow: hidden; background: rgba(0,0,0,0.16); }
.wa-image-preview img { max-height: 340px; min-width: 180px; object-fit: cover; }
.wa-video-preview video { width: min(460px, 62vw); max-height: 360px; display: block; }
.wa-audio-player { display: flex; align-items: center; gap: 10px; min-width: 260px; }
.wa-audio-player audio { width: 240px; max-width: 48vw; height: 34px; }
.wa-audio-icon { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.12); display: inline-flex; align-items: center; justify-content: center; }
.wa-document-preview {
  display: flex; align-items: center; gap: 10px; min-width: 250px; padding: 12px; border-radius: 10px;
  background: rgba(255,255,255,0.08); color: #fff;
}
.wa-doc-icon { font-size: 22px; }
.wa-doc-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wa-doc-download { color: var(--brand-whatsapp); font-weight: 700; font-size: 12px; }
.wa-typing { padding: 7px 18px; color: var(--brand-whatsapp); font-size: 12px; position: relative; z-index: 1; }
.wa-composer { position: relative; z-index: 1; background: #202c33; border-top: 1px solid rgba(255,255,255,0.06); padding: 10px 14px; }
.wa-composer-form { display: flex; align-items: flex-end; gap: 10px; }
.wa-composer-form textarea {
  flex: 1; resize: none; min-height: 43px; max-height: 130px; border: none; outline: none; border-radius: 22px;
  background: #2a3942; color: #e9edef; padding: 11px 16px; font-family: inherit; line-height: 1.5;
}
.wa-composer-btn, .wa-send-btn {
  min-width: 43px; height: 43px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #d1d7db; background: transparent; transition: all var(--transition); font-size: 18px;
}
.wa-composer-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.wa-composer-btn.disabled { opacity: .45; pointer-events: none; }
.wa-send-btn { border-radius: 22px; padding: 0 18px; background: var(--brand-whatsapp-dark); color: #fff; font-size: 13px; font-weight: 800; }
.wa-send-btn:hover { background: var(--brand-whatsapp); color: #07140c; }
.wa-send-btn:disabled, .wa-composer-form textarea:disabled { opacity: .55; cursor: not-allowed; }
.wa-composer-previews { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.wa-composer-previews span { background: rgba(255,255,255,0.08); border: 1px solid var(--border-subtle); border-radius: 99px; padding: 5px 10px; color: var(--text-secondary); font-size: 12px; }
.wa-composer-previews button { color: var(--status-error); margin-inline-start: 6px; }
.wa-emoji-panel {
  position: absolute; bottom: 66px; right: 14px; display: grid; grid-template-columns: repeat(6, 36px); gap: 6px;
  padding: 10px; border-radius: var(--radius-lg); background: #202c33; border: 1px solid var(--border-subtle); box-shadow: var(--shadow-lg);
}
.wa-emoji-panel button { width: 36px; height: 36px; border-radius: 10px; font-size: 20px; }
.wa-emoji-panel button:hover { background: rgba(255,255,255,0.08); }
.wa-skeleton { height: 74px; margin: 12px; border-radius: var(--radius-md); background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.08), rgba(255,255,255,.04)); animation: waPulse 1.4s infinite; }
@keyframes waPulse { 0% { opacity: .5; } 50% { opacity: 1; } 100% { opacity: .5; } }
@media (max-width: 980px) {
  .wa-inbox-shell { grid-template-columns: 1fr; }
  .wa-inbox-sidebar { max-height: 240px; border-left: none; border-bottom: 1px solid var(--border-subtle); }
  .wa-chat-window { flex: 1; min-height: 0; }
  .wa-bubble { max-width: 88%; }
}

/* WhatsApp Inbox refinements - ألوان موحدة مع admin-dashboard */
.wa-inbox-shell { border-radius: 0; border: none; }
.wa-inbox-sidebar { background: #0a1628; }
.wa-inbox-sidebar-head, .wa-chat-header { background: #0d1f3c; }
.wa-conversation { min-height: 72px; padding: 12px 16px; }
.wa-conversation.active { background: #162236; }
.wa-conversation-avatar, .wa-chat-avatar { background: linear-gradient(135deg, #1e3c72, #2a5298); }
.wa-messages { scroll-behavior: smooth; scrollbar-color: rgba(0, 119, 204, 0.35) transparent; }
.wa-bubble { padding: 10px 12px 8px; border-radius: 12px; }
.wa-bubble.inbound { border-top-left-radius: 3px; }
.wa-bubble.outbound { border-top-right-radius: 3px; background: var(--wa-bubble-outgoing); }
.wa-bubble[data-message-id] { animation: waMessageIn .16s ease-out; }
@keyframes waMessageIn { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.wa-delivery { letter-spacing: -2px; font-weight: 800; }
.wa-delivery:not(.read) { color: rgba(233,237,239,.65); }
.wa-media-preview { border: 0; padding: 0; color: inherit; cursor: zoom-in; text-align: inherit; }
.wa-image-preview img { width: 100%; max-width: 360px; border-radius: 10px; background: rgba(0,0,0,.2); }
.wa-video-preview video { border-radius: 10px; background: #000; }
.wa-audio-player { min-width: 280px; padding: 9px 10px; border-radius: 14px; background: rgba(255,255,255,.07); }
.wa-audio-wave { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, #1e3c72, #2a5298); display: inline-flex; align-items: center; justify-content: center; gap: 2px; flex: 0 0 auto; }
.wa-audio-wave i { width: 3px; border-radius: 3px; background: #fff; display: block; }
.wa-audio-wave i:nth-child(1) { height: 12px; }
.wa-audio-wave i:nth-child(2) { height: 20px; }
.wa-audio-wave i:nth-child(3) { height: 15px; }
.wa-audio-wave i:nth-child(4) { height: 24px; }
.wa-audio-body { min-width: 0; flex: 1; }
.wa-audio-body strong { display: block; margin-bottom: 4px; color: #e9edef; font-size: 12px; }
.wa-audio-body audio { width: 100%; }
.wa-document-preview { border: 1px solid rgba(0, 119, 204, 0.15); }
.wa-composer { padding: 10px 12px 12px; }
.wa-composer-form { align-items: center; }
.wa-composer-form textarea { box-shadow: inset 0 0 0 1px rgba(0, 119, 204, 0.08); }
.wa-composer-btn.recording { background: rgba(244,67,54,.16); color: #ff8a80; animation: waRecording 1s infinite; }
@keyframes waRecording { 50% { box-shadow: 0 0 0 6px rgba(244,67,54,.12); } }
.wa-emoji-panel { z-index: 20; max-width: min(320px, calc(100vw - 32px)); }
.wa-composer-previews { padding: 0 54px 8px 54px; }
.wa-attachment-preview { display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 360px; padding: 8px; border-radius: 14px; background: #0a1628; border: 1px solid rgba(0, 119, 204, 0.22); }
.wa-attachment-thumb { width: 54px; height: 54px; border-radius: 11px; overflow: hidden; background: #0d1f3c; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.wa-attachment-thumb img, .wa-attachment-thumb video { width: 100%; height: 100%; object-fit: cover; }
.wa-attachment-preview.audio { max-width: 420px; }
.wa-attachment-preview.audio .wa-attachment-thumb { width: 170px; background: transparent; }
.wa-attachment-preview.audio audio { width: 160px; height: 32px; }
.wa-attachment-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.wa-attachment-meta strong { color: #e9edef; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-attachment-meta small { color: #8696a0; font-size: 11px; }
.wa-attachment-preview > button { width: 28px; height: 28px; border-radius: 50%; color: #ff8a80; background: rgba(255,255,255,.06); font-size: 18px; }
.wa-file-preview-icon { font-size: 26px; }
.wa-lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(5,10,14,.88); display: flex; align-items: center; justify-content: center; padding: 28px; backdrop-filter: blur(8px); }
.wa-lightbox img { max-width: min(980px, 94vw); max-height: 88vh; border-radius: 14px; box-shadow: 0 18px 70px rgba(0,0,0,.55); }
.wa-lightbox-close { position: fixed; top: 18px; left: 18px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-size: 28px; }
.wa-lightbox-close:hover { background: rgba(255,255,255,.22); }
@media (max-width: 640px) {
  .wa-composer-previews { padding-inline: 0; }
  .wa-attachment-preview { min-width: 100%; }
  .wa-audio-player { min-width: 220px; }
}

/* ─── Interactive / OTP Message Styles ─── */

/* Card wrapper for interactive messages */
.wa-interactive-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
}

/* Header text */
.wa-interactive-header {
  font-size: 14px;
  font-weight: 700;
  color: inherit;
  line-height: 1.4;
}

/* Header image */
.wa-interactive-header-img {
  width: 100%;
  max-width: 360px;
  border-radius: 10px;
  margin-bottom: 4px;
}

/* Footer text */
.wa-interactive-footer {
  font-size: 11px;
  color: inherit;
  opacity: 0.7;
  line-height: 1.4;
  margin-top: 2px;
}

/* Template name label */
.wa-interactive-template-name {
  font-size: 11px;
  color: inherit;
  opacity: 0.6;
  font-style: italic;
}

/* Tag label (e.g. "📋 قالب") */
.wa-interactive-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-whatsapp);
  margin-bottom: 2px;
}

/* Buttons row */
.wa-interactive-buttons {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 6px;
}

/* Individual button chip */
.wa-interactive-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(0, 119, 204, 0.15);
  border: 1px solid rgba(0, 119, 204, 0.25);
  color: #53bdeb;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: default;
  transition: background 0.2s;
}

/* "More items" indicator */
.wa-interactive-more {
  font-size: 11px;
  color: rgba(233, 237, 239, 0.45);
  text-align: center;
  padding: 3px 0;
}

/* Button reply (inbound — user tapped a button) */
.wa-interactive-reply {
  display: flex;
  align-items: center;
  gap: 6px;
  color: inherit;
}

.wa-interactive-reply-icon {
  font-size: 14px;
}

/* Reaction bubble */
.wa-reaction-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wa-reaction-emoji {
  font-size: 22px;
  line-height: 1;
}

.wa-reaction-label {
  font-size: 12px;
  color: inherit;
  opacity: 0.8;
}

/* Location bubble */
.wa-location-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wa-location-link {
  color: #53bdeb;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* Contacts bubble */
.wa-contacts-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Unsupported fallback */
.wa-unsupported {
  color: inherit;
  opacity: 0.6;
  font-style: italic;
  font-size: 13px;
}

/* ─── Toast Animations ─── */
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -20px); }
}
