/* ============================================
   WhatsApp Event Invitation Dashboard — Premium Styles v2
   Complete UI/UX Overhaul with Dark Mode, Glassmorphism & Animations
   ============================================ */

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

:root {
  --primary: #25D366;
  --primary-dark: #128C7E;
  --primary-light: #DCF8C6;
  --primary-glow: rgba(37, 211, 102, 0.15);
  --primary-glow-strong: rgba(37, 211, 102, 0.3);
  --bg: #f0f2f5;
  --bg-secondary: #e4e6e9;
  --surface: #ffffff;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #596970;
  --text-muted: #6b7b84;
  --border: #e9edef;
  --border-light: #f0f2f5;
  --sidebar-bg: #111b21;
  --sidebar-text: #e9edef;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active-bg: rgba(37, 211, 102, 0.12);
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --teal: #14b8a6;
  --green: #22c55e;
  --yellow: #eab308;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 6px 10px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 50px rgba(0,0,0,0.15);
  --shadow-glow: 0 0 20px rgba(37, 211, 102, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-blur: blur(12px);
  --sidebar-width: 260px;
  --sidebar-width-mobile: 56px;
}

/* ── Dark Mode ── */
[data-theme="dark"] {
  --bg: #0b141a;
  --bg-secondary: #111b21;
  --surface: #1f2c34;
  --card-bg: #1f2c34;
  --text: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;
  --border: #2a3942;
  --border-light: #233138;
  --sidebar-bg: #111b21;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active-bg: rgba(37, 211, 102, 0.15);
  --shadow: 0 1px 3px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.15);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.15);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.35), 0 6px 10px rgba(0,0,0,0.2);
  --shadow-xl: 0 20px 50px rgba(0,0,0,0.45);
  --glass-bg: rgba(31, 44, 52, 0.8);
  --glass-border: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

[data-theme="dark"] .login-screen {
  background: linear-gradient(135deg, #0b141a 0%, #111b21 30%, #1a3a2a 70%, #0b141a 100%);
}

[data-theme="dark"] .login-card {
  background: rgba(31, 44, 52, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
}

[data-theme="dark"] .login-card h1 { color: var(--text); }

[data-theme="dark"] th { background: #1a2730; color: var(--text-secondary); }
[data-theme="dark"] tr:hover { background: rgba(255,255,255,0.03); }

[data-theme="dark"] .insight-success { background: rgba(34, 197, 94, 0.1); }
[data-theme="dark"] .insight-warning { background: rgba(245, 158, 11, 0.1); }
[data-theme="dark"] .insight-info { background: rgba(59, 130, 246, 0.1); }
[data-theme="dark"] .insight-danger { background: rgba(239, 68, 68, 0.1); }

[data-theme="dark"] .ai-result {
  background: rgba(37, 211, 102, 0.05);
  border-color: rgba(37, 211, 102, 0.1);
}

[data-theme="dark"] .quality-metric,
[data-theme="dark"] .analysis-score-item { background: rgba(255,255,255,0.04); }

[data-theme="dark"] .score-box { background: rgba(255,255,255,0.05); }
[data-theme="dark"] .score-box-good { background: rgba(37, 211, 102, 0.1); }

[data-theme="dark"] .suggestion-item { background: rgba(59, 130, 246, 0.1); }

[data-theme="dark"] .hint code { background: rgba(255,255,255,0.08); color: var(--text-secondary); }

[data-theme="dark"] .dup-group { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .suggestion-group { border-color: var(--border); }

[data-theme="dark"] .loading-overlay { background: rgba(11, 20, 26, 0.8); }

[data-theme="dark"] .toast { background: #2a3942; }

[data-theme="dark"] .group-tab { border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] .group-tab:hover:not(.active) { background: rgba(255,255,255,0.04); }

[data-theme="dark"] .btn-outline { border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] .btn-outline:hover { background: rgba(255,255,255,0.05); border-color: var(--text-muted); }

[data-theme="dark"] .select-sm { background: var(--surface); border-color: var(--border); color: var(--text); }

[data-theme="dark"] .empty-state-card { background: var(--surface); }
[data-theme="dark"] .empty-state-card svg { opacity: 0.6; }

[data-theme="dark"] .mobile-hamburger { color: var(--text); }
[data-theme="dark"] .breadcrumb span { color: var(--text-muted); }
[data-theme="dark"] .breadcrumb .breadcrumb-current { color: var(--text); }

/* ── Scrollbar Styling ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.25);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

/* ── Body ── */
body {
  font-family: 'Segoe UI', Tahoma, 'Noto Sans Arabic', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ── Login Screen ── */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #075e54 0%, #128C7E 30%, #25D366 70%, #34eb7a 100%);
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
  position: relative;
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  top: -200px; right: -200px;
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
}
.login-screen::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  border-radius: 50%;
  animation: float 8s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-30px) rotate(5deg); }
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.login-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 3rem 2.5rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 420px;
  text-align: center;
  border: 1px solid var(--glass-border);
  position: relative;
  z-index: 1;
  animation: loginSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo { font-size: 4rem; margin-bottom: 0.5rem; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1)); }
.login-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; color: var(--text); }
.login-subtitle { color: var(--text-secondary); margin-bottom: 2rem; font-size: 0.9rem; }
.error-text { color: var(--red); margin-top: 1rem; font-size: 0.85rem; }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width); min-height: 100vh;
  background: linear-gradient(180deg, #111b21 0%, #0b141a 100%);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: fixed; right: 0; top: 0; bottom: 0;
  z-index: 100;
  border-left: 1px solid rgba(255,255,255,0.05);
  transition: var(--transition);
  overflow: hidden;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
}
.sidebar-header .logo { font-size: 1.8rem; }
.sidebar-header h2 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }

.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: var(--transition);
  font-size: 0.9rem;
  border-right: 3px solid transparent;
  position: relative;
  margin: 1px 0;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  padding-right: calc(1.5rem + 4px);
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  border-right-color: var(--primary);
  color: var(--primary);
  box-shadow: inset -2px 0 12px rgba(37, 211, 102, 0.08);
}
.nav-item .nav-shortcut {
  margin-right: auto;
  margin-left: 0;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.4);
  font-family: monospace;
  letter-spacing: 0.02em;
}
.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0.75rem 1.5rem;
}

.nav-section-label {
  display: block;
  padding: 0.25rem 1.5rem 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; flex-direction: column; gap: 0.75rem;
  background: rgba(0,0,0,0.15);
}

.sidebar-footer-top {
  display: flex; align-items: center; justify-content: space-between;
}

.user-info { font-size: 0.85rem; opacity: 0.8; }

.dark-mode-toggle {
  display: flex; align-items: center; gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  transition: var(--transition);
}
.dark-mode-toggle:hover {
  background: rgba(255,255,255,0.1);
}
.dark-mode-toggle .toggle-icon { font-size: 1rem; }
.dark-mode-toggle .toggle-text { flex: 1; text-align: right; }
.dark-mode-toggle .toggle-key {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.4);
  font-family: monospace;
}

/* ── Mobile Hamburger ── */
.mobile-hamburger {
  display: none;
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 150;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  font-size: 1.2rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}
.mobile-hamburger:hover { box-shadow: var(--shadow-lg); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  padding: 1.5rem 2rem;
  min-height: 100vh;
  transition: margin 0.3s ease;
  overflow-x: hidden;
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}
.breadcrumb span { color: var(--text-muted); }
.breadcrumb .breadcrumb-sep { margin: 0 0.15rem; }
.breadcrumb .breadcrumb-current { color: var(--text); font-weight: 500; }

/* ── Pages ── */
.page { display: none; animation: pageIn 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.page.active { display: block; }

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

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

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.card-header h3 { font-size: 1.1rem; }

.mb-3 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* ── Grid Layouts ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
}

.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 1rem;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
  border-top: 3px solid var(--border);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; right: 0; left: 0;
  height: 3px;
  transition: height 0.3s ease;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.04;
  transition: var(--transition);
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.stat-card:hover::before { height: 4px; }
.stat-card:hover::after { transform: scale(1.3); opacity: 0.07; }

.stat-icon { font-size: 1.5rem; margin-bottom: 0.25rem; opacity: 0.8; }
.stat-number { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; }
.stat-label { color: var(--text-secondary); font-size: 0.78rem; margin-top: 0.15rem; }

.stat-blue { border-top-color: var(--blue); color: var(--blue); }
.stat-blue .stat-number { color: var(--blue); }
.stat-blue::before { background: var(--blue); }
.stat-green { border-top-color: var(--green); color: var(--green); }
.stat-green .stat-number { color: var(--green); }
.stat-green::before { background: var(--green); }
.stat-purple { border-top-color: var(--purple); color: var(--purple); }
.stat-purple .stat-number { color: var(--purple); }
.stat-purple::before { background: var(--purple); }
.stat-cyan { border-top-color: var(--cyan); color: var(--cyan); }
.stat-cyan .stat-number { color: var(--cyan); }
.stat-cyan::before { background: var(--cyan); }
.stat-orange { border-top-color: var(--orange); color: var(--orange); }
.stat-orange .stat-number { color: var(--orange); }
.stat-orange::before { background: var(--orange); }
.stat-red { border-top-color: var(--red); color: var(--red); }
.stat-red .stat-number { color: var(--red); }
.stat-red::before { background: var(--red); }
.stat-yellow { border-top-color: var(--yellow); color: var(--yellow); }
.stat-yellow .stat-number { color: var(--yellow); }
.stat-yellow::before { background: var(--yellow); }
.stat-teal { border-top-color: var(--teal); color: var(--teal); }
.stat-teal .stat-number { color: var(--teal); }
.stat-teal::before { background: var(--teal); }

/* ── Daily Chart ── */
.daily-chart {
  display: flex; align-items: flex-end; gap: 0.5rem;
  height: 150px; margin-top: 1.5rem; padding: 0 0.5rem; padding-bottom: 1.5rem;
}
.chart-bar {
  flex: 1; background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-radius: 6px 6px 0 0;
  min-height: 4px; position: relative;
  transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.chart-bar:hover { opacity: 0.85; transform: scaleY(1.02); transform-origin: bottom; }
.chart-bar .bar-label {
  position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%);
  font-size: 0.65rem; color: var(--text-muted); white-space: nowrap;
}
.chart-bar .bar-value {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  font-size: 0.7rem; font-weight: 700; color: var(--text);
}

/* ── AI Insights ── */
.insights-list { display: flex; flex-direction: column; gap: 0.5rem; }
.insight-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  transition: var(--transition);
}
.insight-item:hover { transform: translateX(-2px); }
.insight-success { background: #f0fdf4; border-right: 3px solid var(--green); }
.insight-warning { background: #fffbeb; border-right: 3px solid var(--orange); }
.insight-info { background: #eff6ff; border-right: 3px solid var(--blue); }
.insight-danger { background: #fef2f2; border-right: 3px solid var(--red); }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--primary-glow);
  color: var(--primary-dark);
}

/* ── Tables ── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.7rem 0.85rem; text-align: right; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th {
  font-weight: 600; color: var(--text-secondary); font-size: 0.8rem;
  background: #fafbfc; position: sticky; top: 0; z-index: 1;
  text-transform: uppercase; letter-spacing: 0.02em;
}
tr { transition: background 0.15s; }
tr:nth-child(even) { background: rgba(0,0,0,0.015); }
[data-theme="dark"] tr:nth-child(even) { background: rgba(255,255,255,0.015); }
tr:hover { background: rgba(37, 211, 102, 0.04); }
tr:last-child td { border-bottom: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.88rem; cursor: pointer;
  transition: var(--transition); font-family: inherit;
  text-decoration: none; font-weight: 500;
  position: relative; overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s;
}
.btn:hover::after { background: rgba(255,255,255,0.1); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97) translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,211,102,0.3); }
.btn-secondary { background: var(--blue); color: #fff; }
.btn-secondary:hover { background: #2563eb; box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); border-color: var(--text-secondary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(239,68,68,0.3); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; padding: 0.7rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.88rem; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem; font-family: inherit;
  transition: var(--transition);
  background: var(--card-bg);
  color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), 0 0 12px rgba(37,211,102,0.1);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
.form-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}
.input-full { width: 100%; padding: 0.6rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.88rem; font-family: inherit; background: var(--card-bg); color: var(--text); }
.input-full:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.hint { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.3rem; display: block; }
.hint code { background: #f1f3f5; padding: 2px 6px; border-radius: 4px; font-size: 0.78rem; }

.select-sm {
  padding: 0.35rem 0.7rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.8rem; font-family: inherit;
  background: var(--card-bg); color: var(--text);
}
.select-sm:focus { outline: none; border-color: var(--primary); }

.radio-group { display: flex; gap: 1.5rem; margin-top: 0.5rem; }
.radio-group label { display: flex; align-items: center; gap: 0.4rem; font-weight: 400; cursor: pointer; font-size: 0.88rem; }

/* ── Drag & Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(37, 211, 102, 0.02);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(37, 211, 102, 0.06);
}
.drop-zone .drop-icon { font-size: 2rem; margin-bottom: 0.5rem; display: block; }
.drop-zone .drop-text { color: var(--text-secondary); font-size: 0.88rem; }
.drop-zone .drop-hint { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.3rem; }
.drop-zone .file-name {
  margin-top: 0.5rem;
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 0.85rem;
}

/* ── Modals ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: modalBgIn 0.25s ease;
  padding: 1rem;
}
@keyframes modalBgIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--border-light);
}
@keyframes modalSlideIn {
  from { transform: translateY(30px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-sm { max-width: 380px; }
.modal-lg { max-width: 640px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border-light);
}
.modal-header h2 { font-size: 1.2rem; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: none; border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer; color: var(--text-secondary);
  transition: var(--transition);
  line-height: 1;
}
.modal-close:hover { background: var(--red); color: #fff; transform: rotate(90deg); }

.modal-body { padding: 1rem 2rem; }
.modal-footer {
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid var(--border-light);
}

/* Backwards compat: modals without body/footer structure */
.modal-content > form { padding: 0 2rem 2rem; }
.modal-content > form:first-child { padding-top: 2rem; }

/* ── Events Grid ── */
.events-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.event-card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid var(--border-light);
  border-right: 4px solid var(--primary);
}
.event-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.event-card h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.event-meta { color: var(--text-secondary); font-size: 0.82rem; margin-bottom: 0.6rem; }
.event-meta span { display: inline-flex; align-items: center; gap: 0.3rem; margin-left: 0.75rem; }
.event-stats { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.6rem 0; }
.event-stat-badge {
  padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.72rem; font-weight: 600;
}
.badge-sent { background: #dcfce7; color: #166534; }
.badge-delivered { background: #dbeafe; color: #1e40af; }
.badge-read { background: #fef3c7; color: #92400e; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #f3f4f6; color: #374151; }

[data-theme="dark"] .badge-sent { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="dark"] .badge-delivered { background: rgba(59,130,246,0.15); color: #60a5fa; }
[data-theme="dark"] .badge-read { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="dark"] .badge-failed { background: rgba(239,68,68,0.15); color: #f87171; }
[data-theme="dark"] .badge-pending { background: rgba(255,255,255,0.08); color: var(--text-secondary); }

.event-progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.75rem 0 0.5rem;
  display: flex;
}
.event-progress .ep-read { background: var(--green); }
.event-progress .ep-delivered { background: var(--blue); }
.event-progress .ep-sent { background: var(--cyan); }
.event-progress .ep-failed { background: var(--red); }
.event-progress .ep-pending { background: var(--border); }

.event-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

/* ── Status Badges ── */
.status-badge {
  display: inline-block; padding: 0.2rem 0.7rem; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.01em;
}
.status-pending { background: #f3f4f6; color: #374151; }
.status-sent { background: #dcfce7; color: #166534; }
.status-delivered { background: #dbeafe; color: #1e40af; }
.status-read { background: #fef3c7; color: #92400e; }
.status-failed { background: #fee2e2; color: #991b1b; }
.status-retry { background: #fff7ed; color: #9a3412; }
.status-draft { background: #f3f4f6; color: #374151; }
.status-sending { background: #dbeafe; color: #1e40af; }
.status-completed { background: #dcfce7; color: #166534; }

[data-theme="dark"] .status-pending { background: rgba(255,255,255,0.08); color: var(--text-secondary); }
[data-theme="dark"] .status-sent { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="dark"] .status-delivered { background: rgba(59,130,246,0.15); color: #60a5fa; }
[data-theme="dark"] .status-read { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="dark"] .status-failed { background: rgba(239,68,68,0.15); color: #f87171; }
[data-theme="dark"] .status-retry { background: rgba(249,115,22,0.15); color: #fb923c; }
[data-theme="dark"] .status-draft { background: rgba(255,255,255,0.08); color: var(--text-secondary); }
[data-theme="dark"] .status-sending { background: rgba(59,130,246,0.15); color: #60a5fa; }
[data-theme="dark"] .status-completed { background: rgba(34,197,94,0.15); color: #4ade80; }

/* ── Group Tabs ── */
.group-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.group-tab {
  padding: 0.3rem 0.8rem; border-radius: 20px;
  border: 1.5px solid var(--border); background: transparent;
  cursor: pointer; font-size: 0.78rem; font-family: inherit;
  transition: var(--transition); color: var(--text);
}
.group-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(37,211,102,0.25); }
.group-tab:hover:not(.active) { background: var(--bg); border-color: var(--text-secondary); }

.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }

/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 0.4rem; margin-top: 1rem;
}
.pagination .page-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0.5rem;
}
.pagination button {
  padding: 0.3rem 0.65rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card-bg);
  cursor: pointer; font-family: inherit; font-size: 0.82rem;
  transition: var(--transition); color: var(--text);
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(37,211,102,0.2); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination button:hover:not(:disabled):not(.active) { background: var(--bg); transform: translateY(-1px); }

/* ── Toast ── */
.toast {
  position: fixed; top: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--text); padding: 0.75rem 1.5rem;
  border-radius: var(--radius); font-size: 0.88rem;
  box-shadow: var(--shadow-xl); z-index: 9999;
  animation: toastSlideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--border);
  max-width: 90vw;
}
.toast.error { border-color: var(--red); }
.toast.error::before { content: ''; width: 4px; height: 100%; position: absolute; right: 0; top: 0; background: var(--red); border-radius: 0 var(--radius) var(--radius) 0; }
.toast.success { border-color: var(--primary); }
.toast.success::before { content: ''; width: 4px; height: 100%; position: absolute; right: 0; top: 0; background: var(--primary); border-radius: 0 var(--radius) var(--radius) 0; }

.toast-dismiss {
  animation: toastDismiss 0.3s ease forwards;
}

@keyframes toastSlideDown {
  from { transform: translateX(-50%) translateY(-30px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@keyframes toastDismiss {
  from { transform: translateX(-50%) translateY(0); opacity: 1; }
  to { transform: translateX(-50%) translateY(-30px); opacity: 0; }
}

/* ── Loading Overlay ── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section Loading (per-page) ── */
.section-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.section-loading .spinner-sm {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Skeleton Loading ── */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text { height: 14px; margin-bottom: 0.5rem; border-radius: 4px; }
.skeleton-text:last-child { width: 60%; }

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

/* ── Empty States ── */
.empty-state-card {
  text-align: center;
  padding: 3rem 2rem;
  grid-column: 1 / -1;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}
.empty-state-card svg {
  width: 120px;
  height: 120px;
  margin: 0 auto 1rem;
  opacity: 0.5;
}
.empty-state-card .empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text);
}
.empty-state-card .empty-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ── AI Assistant Styles ── */
.ai-result {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8fdf9;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(37,211,102,0.15);
  animation: fadeIn 0.3s ease;
}

.message-preview {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  direction: rtl;
}

.score-compare {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.score-box {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  background: #f3f4f6;
  text-align: center;
  min-width: 80px;
}
.score-box-good { background: #f0fdf4; }
.score-label { display: block; font-size: 0.75rem; color: var(--text-secondary); }
.score-value { display: block; font-size: 1.5rem; font-weight: 800; color: var(--primary-dark); }
.score-arrow { font-size: 1.5rem; color: var(--primary); }

.suggestions-list {
  margin-top: 0.75rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.suggestion-item {
  padding: 0.5rem 0.75rem;
  background: #eff6ff;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border-right: 2px solid var(--blue);
}

.analysis-scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.analysis-score-item {
  text-align: center;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: #f8f9fa;
}
.analysis-score-item .score-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary-dark);
}
.analysis-score-item .score-name {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* ── AI Page Tabs ── */
.ai-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
.ai-tab {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: var(--transition);
  white-space: nowrap;
  color: var(--text);
}
.ai-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37,211,102,0.2);
}
.ai-tab:hover:not(.active) { background: var(--bg); }

/* ── Analytics Styles ── */
.analytics-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.overview-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--border-light);
  transition: var(--transition);
}
.overview-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.overview-card .ov-value {
  font-size: 2rem; font-weight: 800;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.overview-card .ov-label { color: var(--text-secondary); font-size: 0.8rem; margin-top: 0.15rem; }

/* ── Funnel Chart ── */
.funnel-chart {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1rem 0;
}
.funnel-step {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0;
}
.funnel-bar {
  height: 32px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 0.75rem;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 50px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.funnel-label { min-width: 60px; font-size: 0.82rem; color: var(--text-secondary); text-align: right; }

/* ── Hourly Chart ── */
.hourly-chart {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
  margin-top: 0.75rem;
}
.hour-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.55rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.hour-cell:hover { transform: scale(1.15); z-index: 1; }
.hour-cell[title]::after {
  content: attr(title);
  display: none;
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 2px 6px; border-radius: 4px;
  font-size: 0.65rem; white-space: nowrap;
}
.hour-cell:hover[title]::after { display: block; }

/* ── Quality Dashboard ── */
.quality-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.quality-metric {
  text-align: center;
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: #f8f9fa;
  transition: var(--transition);
}
.quality-metric:hover { transform: translateY(-2px); }
.quality-metric .q-value { font-size: 1.6rem; font-weight: 800; }
.quality-metric .q-label { font-size: 0.78rem; color: var(--text-secondary); }
.quality-metric.good .q-value { color: var(--green); }
.quality-metric.warn .q-value { color: var(--orange); }
.quality-metric.bad .q-value { color: var(--red); }

/* ── Scheduler Styles ── */
.scheduler-metric {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.scheduler-metric:last-child { border-bottom: none; }
.scheduler-metric .sm-label { color: var(--text-secondary); }
.scheduler-metric .sm-value { font-weight: 700; }

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width 0.6s ease;
}

/* ── Duplicate & Intelligence Cards ── */
.dup-group {
  margin-bottom: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: var(--transition);
}
.dup-group:hover { box-shadow: var(--shadow); }
.dup-group .dup-primary { font-weight: 600; color: var(--primary-dark); }
.dup-group .dup-item { font-size: 0.85rem; color: var(--text-secondary); padding: 0.2rem 0; }

.suggestion-group {
  margin-bottom: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: space-between;
  transition: var(--transition);
}
.suggestion-group:hover { box-shadow: var(--shadow); }
.suggestion-group .sg-name { font-weight: 600; }
.suggestion-group .sg-reason { font-size: 0.82rem; color: var(--text-secondary); }
.suggestion-group .sg-count { font-size: 0.82rem; color: var(--text-muted); }

.phone-issue {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.phone-issue:last-child { border-bottom: none; }
.phone-issue .pi-problems { color: var(--red); font-size: 0.82rem; }

/* ── Optimal Time Display ── */
.optimal-time-display {
  text-align: center;
  padding: 1rem;
}
.optimal-hour {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.optimal-reason {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-top: 0.5rem;
}

/* ── Tooltip ── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: #1a1a2e;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 500;
}
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}
[data-theme="dark"] [data-tooltip]::before {
  background: #2a3942;
}

/* ── Copy Feedback ── */
.copy-feedback {
  position: relative;
}
.copy-feedback.copied::after {
  content: 'تم النسخ!';
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-dark);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  animation: copyPop 1s ease forwards;
  white-space: nowrap;
}
@keyframes copyPop {
  0% { opacity: 0; top: -20px; }
  20% { opacity: 1; top: -28px; }
  80% { opacity: 1; top: -28px; }
  100% { opacity: 0; top: -36px; }
}

/* ── Online/Offline Indicator ── */
.connection-status {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 0.4rem;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 3000;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}
.connection-status.visible { transform: translateY(0); }
.connection-status.offline { background: var(--red); color: #fff; }
.connection-status.online { background: var(--green); color: #fff; }

/* ── Confirmation Dialog ── */
.confirm-dialog {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 2500;
  animation: modalBgIn 0.2s ease;
}
.confirm-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.confirm-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.confirm-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.4rem; }
.confirm-text { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 1.25rem; }
.confirm-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* ── Footer ── */
.app-footer {
  padding: 1.5rem 0 1rem;
  margin-top: 3rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.app-footer span { margin: 0 0.3rem; }

/* ── Settings Page ── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.settings-card { padding: 1.5rem; }
.settings-card h3 { margin-bottom: 1rem; font-size: 1rem; }
.settings-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
}
.settings-item:last-child { border-bottom: none; }
.settings-item .si-label { color: var(--text-secondary); }
.settings-item .si-value { font-weight: 500; }

/* ── Search with clear ── */
.search-wrapper {
  position: relative;
}
.search-wrapper input { padding-left: 2rem; }
.search-clear {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
  display: none;
  transition: var(--transition);
}
.search-clear:hover { color: var(--red); }
.search-wrapper input:not(:placeholder-shown) + .search-clear { display: block; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
    width: var(--sidebar-width);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-hamburger { display: block; }
  .sidebar-header h2 { display: block; }
  .nav-text { display: inline; }
  .sidebar-footer .user-info { display: block; }
  .nav-section-label, .nav-divider { display: block; }
  .nav-item { border-right: 3px solid transparent; }
  .nav-item.active { border-right-color: var(--primary); }
  .nav-item .nav-shortcut { display: none; }
  .main-content { margin-right: 0; padding: 1rem; padding-top: 3.5rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .events-grid { grid-template-columns: 1fr; }
  .ai-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header h1 { font-size: 1.3rem; }
  .header-actions { justify-content: flex-end; }
  .hourly-chart { grid-template-columns: repeat(12, 1fr); }
  .breadcrumb { font-size: 0.75rem; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .ai-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal-content { margin: 0.5rem; border-radius: var(--radius-lg); }
  .modal-header { padding: 1.25rem 1.5rem 0.75rem; }
  .modal-body { padding: 0.75rem 1.25rem; }
  .modal-footer { padding: 0.75rem 1.25rem 1rem; }
  .modal-content > form { padding: 0 1.5rem 1.5rem; }
  .main-content { padding: 0.75rem; padding-top: 3.5rem; }
  .ai-tabs { gap: 0.3rem; }
  .ai-tab { padding: 0.4rem 0.75rem; font-size: 0.78rem; }
  .hourly-chart { grid-template-columns: repeat(8, 1fr); }
}


/* ══════════════════════════════════════════════
   INBOX / CONVERSATIONS — WhatsApp-style Chat
   ══════════════════════════════════════════════ */

/* Nav badge */
.nav-badge {
  margin-right: auto;
  margin-left: 0.3rem;
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Inbox Layout */
.inbox-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1rem;
  height: calc(100vh - 180px);
  min-height: 500px;
}

.inbox-list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 !important;
}

.inbox-list-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}
.inbox-count { font-weight: 600; }
.inbox-unread { color: var(--primary); font-weight: 600; font-size: 0.8rem; }

.inbox-conversations {
  flex: 1;
  overflow-y: auto;
}

/* Conversation Item */
.conv-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border-light);
  position: relative;
}
.conv-item:hover { background: var(--bg); }
.conv-item.active { background: var(--primary-glow); border-right: 3px solid var(--primary); }

.conv-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.conv-info, .conv-details { flex: 1; min-width: 0; }
.conv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.conv-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 2px;
}
.conv-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-name .conv-time,
.conv-top .conv-time {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.conv-preview {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.conv-unread-badge, .conv-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.conv-status-indicator, .conv-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.conv-status-indicator.open, .conv-status-dot.status-open { background: var(--green); }
.conv-status-indicator.closed, .conv-status-dot.status-closed { background: var(--text-muted); }
.conv-item.unread {
  background: var(--primary-glow);
  border-right: 3px solid var(--primary);
}
.conv-item.unread .conv-name { color: var(--text); font-weight: 700; }
.conv-item.unread .conv-preview { color: var(--text); font-weight: 500; }


/* Chat Area */
.inbox-chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 !important;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}
.chat-empty .empty-title { font-size: 1.1rem; font-weight: 600; margin-top: 1rem; }
.chat-empty .empty-desc { color: var(--text-muted); font-size: 0.88rem; margin-top: 0.3rem; }

.chat-active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}
.chat-contact-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.chat-name { font-weight: 600; font-size: 0.95rem; }
.chat-phone { font-size: 0.78rem; color: var(--text-secondary); direction: ltr; text-align: right; }

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg);
}
[data-theme="dark"] .chat-messages { background: #0b141a; }

.chat-msg {
  max-width: 75%;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
  animation: fadeIn 0.2s ease;
}
.chat-msg.inbound {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  align-self: flex-start;
  border-bottom-right-radius: 4px;
}
.chat-msg.outbound {
  background: var(--primary-light);
  color: #1a1a2e;
  align-self: flex-end;
  border-bottom-left-radius: 4px;
}
[data-theme="dark"] .chat-msg.outbound {
  background: rgba(37, 211, 102, 0.15);
  color: var(--text);
}

.chat-msg-bubble { /* wrapper inside chat-msg */ }
.chat-msg-content { /* wrapper for message content */ }
.chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
}
.chat-msg.outbound .chat-msg-meta { justify-content: flex-end; }
.chat-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  display: inline;
}
.chat-msg.outbound .chat-msg-time { justify-content: flex-end; }

.chat-msg-status { font-size: 0.7rem; }

.chat-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-msg-media {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
}
.chat-msg-media-icon { font-size: 1.2rem; }
[data-theme="dark"] .chat-msg-media { background: rgba(255,255,255,0.05); }

.chat-msg-location {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem;
  font-size: 0.85rem;
}

.chat-msg-interactive {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--primary-glow);
  color: var(--primary-dark);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

.chat-date-divider {
  text-align: center;
  padding: 0.5rem 0;
}
.chat-date-divider span {
  background: var(--bg-secondary);
  padding: 0.2rem 0.75rem;
  border-radius: 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
[data-theme="dark"] .chat-date-divider span { background: rgba(255,255,255,0.06); }

/* Chat Input */
.chat-input {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}
.chat-reply-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.chat-reply-form textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
  max-height: 120px;
  transition: var(--transition);
}
.chat-reply-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.btn-chat-send {
  padding: 0.6rem 1.2rem;
  flex-shrink: 0;
}

/* Template Cards */
.template-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  transition: var(--transition);
}
.template-card:hover { box-shadow: var(--shadow); }
.template-info { flex: 1; min-width: 0; }
.template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.template-name { font-weight: 600; font-size: 0.9rem; }
.template-category {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.template-body {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 0.2rem;
}
.template-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.template-status, .badge-approved, .badge-rejected, .badge-pending {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}
.template-status.APPROVED, .badge-approved { background: #dcfce7; color: #166534; }
.template-status.PENDING, .badge-pending { background: #fef3c7; color: #92400e; }
.template-status.REJECTED, .badge-rejected { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .template-status.APPROVED, [data-theme="dark"] .badge-approved { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="dark"] .template-status.PENDING, [data-theme="dark"] .badge-pending { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="dark"] .template-status.REJECTED, [data-theme="dark"] .badge-rejected { background: rgba(239,68,68,0.15); color: #f87171; }

/* Responsive: Inbox */
@media (max-width: 768px) {
  .inbox-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .inbox-list { max-height: 300px; }
  .inbox-chat { min-height: 400px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .inbox-layout { grid-template-columns: 280px 1fr; }
}

/* ── Focus States for Accessibility ── */
.btn:focus-visible,
.nav-item:focus-visible,
.modal-close:focus-visible,
.group-tab:focus-visible,
.ai-tab:focus-visible,
.pagination button:focus-visible,
.dark-mode-toggle:focus-visible,
.mobile-hamburger:focus-visible,
.conv-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
