/* ============================================================
   style.css — مواعيدي | Modern appointment app
   Multi-theme system with CSS variables
   ============================================================ */

/* ---------- Theme: Aurora (default) ---------- */
:root,
[data-theme="aurora"] {
  --bg: #0f0e17;
  --bg-2: #1a1825;
  --surface: #1e1b2e;
  --surface-2: #26233a;
  --surface-3: #2e2a45;
  --border: #2d2a44;
  --border-2: #3a3656;
  --text: #f5f3ff;
  --text-2: #b8b3d4;
  --text-3: #8a85a8;
  --primary: #8b5cf6;
  --primary-2: #a78bfa;
  --primary-glow: rgba(139, 92, 246, 0.35);
  --accent: #ec4899;
  --accent-2: #f472b6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --grad-1: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  --grad-2: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --grad-hero: radial-gradient(ellipse at top right, rgba(139,92,246,.18), transparent 60%),
               radial-gradient(ellipse at bottom left, rgba(236,72,153,.12), transparent 55%);
  --shadow: 0 8px 32px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.45);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
}

/* ---------- Theme: Sunset ---------- */
[data-theme="sunset"] {
  --bg: #1a0f14;
  --bg-2: #241419;
  --surface: #2b1a20;
  --surface-2: #362028;
  --surface-3: #42262f;
  --border: #3d242c;
  --border-2: #52303a;
  --text: #fff5f2;
  --text-2: #d9b8b0;
  --text-3: #a8857d;
  --primary: #f97316;
  --primary-2: #fb923c;
  --primary-glow: rgba(249, 115, 22, 0.35);
  --accent: #e11d48;
  --accent-2: #f43f5e;
  --success: #10b981;
  --warning: #fbbf24;
  --danger: #dc2626;
  --info: #0ea5e9;
  --grad-1: linear-gradient(135deg, #f97316 0%, #e11d48 100%);
  --grad-2: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  --grad-hero: radial-gradient(ellipse at top right, rgba(249,115,22,.2), transparent 60%),
               radial-gradient(ellipse at bottom left, rgba(225,29,72,.14), transparent 55%);
}

/* ---------- Theme: Ocean ---------- */
[data-theme="ocean"] {
  --bg: #0a1929;
  --bg-2: #0f2438;
  --surface: #122b42;
  --surface-2: #173351;
  --surface-3: #1d3c5e;
  --border: #1f3c5c;
  --border-2: #2a4d74;
  --text: #eef6ff;
  --text-2: #9fc0d9;
  --text-3: #6b8fad;
  --primary: #06b6d4;
  --primary-2: #22d3ee;
  --primary-glow: rgba(6, 182, 212, 0.35);
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #6366f1;
  --grad-1: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --grad-2: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
  --grad-hero: radial-gradient(ellipse at top right, rgba(6,182,212,.18), transparent 60%),
               radial-gradient(ellipse at bottom left, rgba(59,130,246,.12), transparent 55%);
}

/* ---------- Theme: Forest ---------- */
[data-theme="forest"] {
  --bg: #0d1a14;
  --bg-2: #122218;
  --surface: #16291f;
  --surface-2: #1c3328;
  --surface-3: #234032;
  --border: #21402f;
  --border-2: #2d5240;
  --text: #f0fdf4;
  --text-2: #a8c9b4;
  --text-3: #779c87;
  --primary: #22c55e;
  --primary-2: #4ade80;
  --primary-glow: rgba(34, 197, 94, 0.35);
  --accent: #eab308;
  --accent-2: #facc15;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --grad-1: linear-gradient(135deg, #22c55e 0%, #eab308 100%);
  --grad-2: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  --grad-hero: radial-gradient(ellipse at top right, rgba(34,197,94,.18), transparent 60%),
               radial-gradient(ellipse at bottom left, rgba(234,179,8,.12), transparent 55%);
}

/* ---------- Theme: Midnight ---------- */
[data-theme="midnight"] {
  --bg: #080a0f;
  --bg-2: #0d1018;
  --surface: #111620;
  --surface-2: #161c28;
  --surface-3: #1c2333;
  --border: #1c2433;
  --border-2: #283248;
  --text: #eef2f8;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --accent: #0ea5e9;
  --accent-2: #38bdf8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #8b5cf6;
  --grad-1: linear-gradient(135deg, #6366f1 0%, #0ea5e9 100%);
  --grad-2: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  --grad-hero: radial-gradient(ellipse at top right, rgba(99,102,241,.18), transparent 60%),
               radial-gradient(ellipse at bottom left, rgba(14,165,233,.12), transparent 55%);
}

/* ---------- Theme: Rose ---------- */
[data-theme="rose"] {
  --bg: #1a0f1a;
  --bg-2: #241424;
  --surface: #2b1a2b;
  --surface-2: #362036;
  --surface-3: #422642;
  --border: #3d263d;
  --border-2: #523052;
  --text: #fff2f8;
  --text-2: #d9b0c9;
  --text-3: #a87d97;
  --primary: #ec4899;
  --primary-2: #f472b6;
  --primary-glow: rgba(236, 72, 153, 0.35);
  --accent: #a855f7;
  --accent-2: #c084fc;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --grad-1: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  --grad-2: linear-gradient(135deg, #db2777 0%, #ec4899 100%);
  --grad-hero: radial-gradient(ellipse at top right, rgba(236,72,153,.18), transparent 60%),
               radial-gradient(ellipse at bottom left, rgba(168,85,247,.12), transparent 55%);
}

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

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .4s ease, color .4s ease;
  overflow-x: hidden;
  /* safe area for notch/home-indicator */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--grad-hero);
  pointer-events: none;
  z-index: 0;
  transition: background .4s ease;
}

#app { position: relative; z-index: 1; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-weight: 800; line-height: 1.3; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all .25s ease; white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--grad-1); color: #fff;
  box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-primary:hover { box-shadow: 0 6px 28px var(--primary-glow); transform: translateY(-1px); }
.btn-ghost {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--border-2); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-icon {
  width: 42px; height: 42px; padding: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 16px 32px; font-size: 17px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Inputs ---------- */
.input, .select, .textarea {
  width: 100%; padding: 12px 16px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 15px; transition: all .25s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 80px; }
.select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a85a8' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 16px center; padding-left: 40px;
}
label { display: block; font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Auth screen ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; position: relative;
}
.auth-card {
  width: 100%; max-width: 440px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 40px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.auth-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--grad-1);
}
.auth-logo {
  width: 72px; height: 72px; border-radius: 20px; background: var(--grad-1);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 20px;
  font-size: 32px; color: #fff; box-shadow: 0 8px 30px var(--primary-glow);
}
.auth-title { text-align: center; font-size: 26px; font-weight: 900; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--text-3); font-size: 14px; margin-bottom: 28px; }
.auth-tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 5px; border-radius: 12px; margin-bottom: 24px; }
.auth-tab {
  flex: 1; padding: 10px; text-align: center; border-radius: 8px; cursor: pointer;
  font-weight: 700; font-size: 14px; color: var(--text-3); transition: all .25s; border: none; background: none; font-family: inherit;
}
.auth-tab.active { background: var(--grad-1); color: #fff; box-shadow: 0 4px 14px var(--primary-glow); }
.auth-error {
  background: rgba(239,68,68,.12); color: var(--danger); padding: 12px 16px;
  border-radius: 10px; font-size: 14px; margin-bottom: 16px; border: 1px solid rgba(239,68,68,.25);
  display: none;
}
.auth-error.show { display: block; }

/* ---------- App layout ---------- */
.app-layout { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: 260px; background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 16px; position: sticky; top: 0;
  height: 100vh; flex-shrink: 0; transition: transform .3s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; padding: 0 8px; }
.sidebar-brand .logo-mini {
  width: 40px; height: 40px; border-radius: 12px; background: var(--grad-1);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.sidebar-brand span { font-size: 20px; font-weight: 900; }
.nav-section { margin-bottom: 16px; }
.nav-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; padding: 0 12px; margin-bottom: 8px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 14px; transition: all .2s;
  border: none; background: none; font-family: inherit; width: 100%; text-align: right;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--grad-1); color: #fff; box-shadow: 0 4px 14px var(--primary-glow); }
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.nav-item .badge { margin-right: auto; background: var(--surface-3); color: var(--text-2); padding: 2px 8px; border-radius: 8px; font-size: 11px; }
.nav-item.active .badge { background: rgba(255,255,255,.25); color: #fff; }

.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.theme-picker { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 4px; }
.theme-swatch {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; border: 2px solid transparent;
  transition: all .2s; position: relative;
}
.theme-swatch.active { border-color: var(--text); transform: scale(1.1); }
.theme-swatch:hover { transform: scale(1.1); }
.theme-swatch[data-t="aurora"] { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.theme-swatch[data-t="sunset"] { background: linear-gradient(135deg, #f97316, #e11d48); }
.theme-swatch[data-t="ocean"] { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.theme-swatch[data-t="forest"] { background: linear-gradient(135deg, #22c55e, #eab308); }
.theme-swatch[data-t="midnight"] { background: linear-gradient(135deg, #6366f1, #0ea5e9); }
.theme-swatch[data-t="rose"] { background: linear-gradient(135deg, #ec4899, #a855f7); }

.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px;
  background: var(--surface-2); margin-top: 10px; cursor: pointer; transition: all .2s;
}
.user-chip:hover { background: var(--surface-3); }
.user-avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--grad-2); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.user-chip .uinfo { flex: 1; min-width: 0; }
.user-chip .uname { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .uemail { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Main content ---------- */
.main { flex: 1; min-width: 0; padding: 24px 32px; max-width: 100%; }
.topbar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.topbar h1 { font-size: 24px; font-weight: 900; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }

/* ---------- Bottom Navigation (mobile) ---------- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(0,0,0,.3);
}
.bottom-nav-inner {
  display: flex;
  align-items: stretch;
  height: 58px;
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: none; background: none; color: var(--text-3); font-family: inherit;
  font-size: 10px; font-weight: 700; cursor: pointer; transition: all .2s;
  padding: 8px 4px; -webkit-tap-highlight-color: transparent;
}
.bn-item i { font-size: 18px; transition: all .2s; }
.bn-item.active { color: var(--primary-2); }
.bn-item.active i { transform: translateY(-2px); }
.bn-fab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: none; background: none; font-family: inherit;
  font-size: 10px; font-weight: 700; cursor: pointer; padding: 4px;
  -webkit-tap-highlight-color: transparent;
}
.bn-fab-circle {
  width: 48px; height: 48px; border-radius: 50%; background: var(--grad-1);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; box-shadow: 0 4px 16px var(--primary-glow);
  margin-top: -18px; border: 3px solid var(--bg); transition: transform .2s;
}
.bn-fab:active .bn-fab-circle { transform: scale(0.92); }
.bn-fab-label { color: var(--text-3); font-size: 10px; font-weight: 700; margin-top: 2px; }

/* ---------- Stats cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; position: relative; overflow: hidden; transition: all .25s;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--border-2); box-shadow: var(--shadow); }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 14px; }
.stat-card .stat-val { font-size: 32px; font-weight: 900; line-height: 1; }
.stat-card .stat-label { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.stat-card.upcoming .stat-icon { background: rgba(139,92,246,.15); color: var(--primary); }
.stat-card.today .stat-icon { background: rgba(245,158,11,.15); color: var(--warning); }
.stat-card.done .stat-icon { background: rgba(16,185,129,.15); color: var(--success); }
.stat-card.week .stat-icon { background: rgba(59,130,246,.15); color: var(--info); }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.panel-title { font-size: 17px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.panel-title i { color: var(--primary); }

/* ---------- Appointment cards ---------- */
.appt-list { display: flex; flex-direction: column; gap: 12px; }
.appt-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; gap: 16px; align-items: flex-start; transition: all .25s;
  position: relative; overflow: hidden;
}
.appt-card:hover { border-color: var(--border-2); transform: translateX(-3px); box-shadow: var(--shadow); }
.appt-card::before { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 4px; background: var(--grad-1); }
.appt-card.status-done { opacity: .65; }
.appt-card.status-done .appt-title { text-decoration: line-through; }
.appt-card.status-cancelled { opacity: .5; }
.appt-card.status-cancelled .appt-title { text-decoration: line-through; }

.appt-date-block {
  width: 64px; flex-shrink: 0; text-align: center; background: var(--surface-2);
  border-radius: 12px; padding: 10px 6px;
}
.appt-date-block .d-num { font-size: 24px; font-weight: 900; line-height: 1; color: var(--primary-2); }
.appt-date-block .d-month { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.appt-date-block .d-day { font-size: 11px; color: var(--text-2); margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }

.appt-body { flex: 1; min-width: 0; }
.appt-title { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.appt-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.appt-meta span { display: inline-flex; align-items: center; gap: 5px; }
.appt-desc { font-size: 13px; color: var(--text-2); margin-bottom: 8px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.appt-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.tag-cat { background: var(--surface-3); color: var(--text-2); }
.tag-repeat { background: rgba(139,92,246,.15); color: var(--primary-2); }
.tag-reminder { background: rgba(245,158,11,.15); color: var(--warning); }
.tag-status-done { background: rgba(16,185,129,.15); color: var(--success); }
.tag-status-cancelled { background: rgba(239,68,68,.15); color: var(--danger); }
.tag-status-upcoming { background: rgba(59,130,246,.15); color: var(--info); }

.appt-actions { display: flex; gap: 6px; flex-shrink: 0; }
.appt-actions .btn-icon { width: 36px; height: 36px; font-size: 14px; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.search-box { flex: 1; min-width: 200px; position: relative; }
.search-box i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-box .input { padding-right: 40px; }

/* Quick filter tabs */
.filter-tabs {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px;
  padding: 6px; background: var(--surface-2); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.filter-tab {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--text-2); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .2s; font-family: inherit;
}
.filter-tab i { font-size: 15px; opacity: .8; }
.filter-tab:hover { background: var(--surface-3); color: var(--text); }
.filter-tab.active {
  background: var(--grad-1); color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.filter-tab.active i { opacity: 1; }
.tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-2);
  transition: all .2s;
}
.filter-tab.active .tab-count { background: rgba(255,255,255,.25); color: #fff; }
@media (max-width: 640px) {
  .filter-tab { padding: 8px 12px; font-size: 13px; }
  .filter-tab span:not(.tab-count) { display: none; }
  .filter-tab .tab-count { font-size: 13px; }
}

/* ---------- FAB ---------- */
.fab {
  position: fixed; bottom: 28px; left: 28px; width: 60px; height: 60px; border-radius: 50%;
  background: var(--grad-1); border: none; color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 8px 30px var(--primary-glow); z-index: 50; transition: all .25s;
  display: flex; align-items: center; justify-content: center;
}
.fab:hover { transform: scale(1.08) rotate(90deg); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 90vh; max-height: 90dvh; overflow-y: auto; padding: 28px;
  box-shadow: var(--shadow-lg); transform: scale(.95); transition: transform .25s; position: relative;
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.modal-title { font-size: 20px; font-weight: 900; display: flex; align-items: center; gap: 10px; }
.modal-title i { color: var(--primary); }
.modal-close { background: var(--surface-2); border: none; color: var(--text-3); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 16px; transition: all .2s; }
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-lg { max-width: 720px; }

/* ---------- Voice recording ---------- */
.voice-area {
  background: var(--surface-2); border: 2px dashed var(--border-2); border-radius: var(--radius);
  padding: 32px 20px; text-align: center; margin-bottom: 18px; transition: all .25s;
}
.voice-area.recording { border-color: var(--danger); background: rgba(239,68,68,.06); }
.mic-btn {
  width: 80px; height: 80px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--grad-1); color: #fff; font-size: 30px; transition: all .25s;
  box-shadow: 0 8px 30px var(--primary-glow); position: relative;
}
.mic-btn:hover { transform: scale(1.06); }
.mic-btn.recording { background: var(--danger); animation: pulse 1.5s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  70% { box-shadow: 0 0 0 20px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
.voice-hint { color: var(--text-3); font-size: 14px; margin-top: 14px; min-height: 20px; }

/* مؤشر صوتي متحرك (موجات صوتية) بدلاً من عرض النص الخام */
.wave-container { display: none; justify-content: center; align-items: flex-end; gap: 4px; height: 56px; margin-top: 18px; }
.wave-container.active { display: flex; }
.wave-bars { display: flex; align-items: flex-end; gap: 5px; height: 100%; }
.wave-bars span {
  display: block; width: 5px; height: 10px; border-radius: 3px;
  background: linear-gradient(var(--primary), var(--primary-2));
  animation: wave 1.1s ease-in-out infinite;
  opacity: .85;
}
.wave-bars span:nth-child(1) { animation-delay: 0s;    }
.wave-bars span:nth-child(2) { animation-delay: .1s;   }
.wave-bars span:nth-child(3) { animation-delay: .2s;   }
.wave-bars span:nth-child(4) { animation-delay: .3s;   }
.wave-bars span:nth-child(5) { animation-delay: .4s;   }
.wave-bars span:nth-child(6) { animation-delay: .15s;  }
.wave-bars span:nth-child(7) { animation-delay: .25s;  }
.wave-bars span:nth-child(8) { animation-delay: .35s;  }
.wave-bars span:nth-child(9) { animation-delay: .05s;  }
@keyframes wave {
  0%, 100% { height: 10px; }
  50% { height: 46px; }
}

/* صندوق "الذكاء الاصطناعي يفكر" أثناء التحليل */
.ai-thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--primary-2); font-weight: 700; font-size: 14px; }
.ai-thinking-box { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 36px 20px; color: var(--text-3); font-weight: 600; font-size: 15px; }

/* عرض النص المفهوم والمصحح بواسطة الذكاء الاصطناعي */
.understood-text {
  background: linear-gradient(135deg, rgba(99,102,241,.08), rgba(168,85,247,.08));
  border: 1px solid var(--border-2); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px;
}
.understood-label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 800; color: var(--primary-2); margin-bottom: 8px; }
.understood-label i { font-size: 14px; }
.understood-content { font-size: 15px; line-height: 1.8; color: var(--text); font-weight: 600; }

.recording-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--danger); font-weight: 700; }
.recording-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- Parse preview ---------- */
.parse-preview {
  background: var(--surface-3); border-radius: var(--radius); padding: 18px; margin: 18px 0;
  border: 1px solid var(--border-2);
}
.parse-confidence { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.confidence-bar { flex: 1; height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; }
.confidence-fill { height: 100%; background: var(--grad-1); border-radius: 3px; transition: width .5s; }

.reminder-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-removable {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border-2); font-size: 13px; font-weight: 600;
}
.chip-removable button { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 0; font-size: 14px; }
.chip-removable button:hover { color: var(--danger); }
.chip-add {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px;
  background: var(--grad-1); color: #fff; border: none; cursor: pointer; font-size: 13px; font-weight: 700; font-family: inherit;
}

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state i { font-size: 56px; margin-bottom: 16px; color: var(--border-2); }
.empty-state h3 { font-size: 18px; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: 14px; }

/* ---------- Charts ---------- */
.chart-wrap { position: relative; height: 260px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 28px; right: 28px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface-3); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 14px 20px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600; min-width: 250px; animation: slideIn .3s ease;
}
.toast.success { border-right: 4px solid var(--success); }
.toast.error { border-right: 4px solid var(--danger); }
.toast.info { border-right: 4px solid var(--info); }
.toast i { font-size: 18px; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.info i { color: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { to { transform: translateX(100%); opacity: 0; } }

/* ---------- Loading ---------- */
.loader { display: flex; align-items: center; justify-content: center; padding: 40px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border-2); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Section views ---------- */
.view { display: none; animation: fadeIn .3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .chart-grid { grid-template-columns: 1fr; }
  .sidebar { position: fixed; right: 0; top: 0; z-index: 90; transform: translateX(100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .main { padding: 20px 18px; }
}
@media (max-width: 768px) {
  /* إخفاء FAB وإظهار bottom nav */
  .fab { display: none !important; }
  .bottom-nav { display: block; }
  /* تعديل padding السفلي للمحتوى ليترك مساحة لـ bottom nav */
  .main { padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
  /* إخفاء زر "موعد جديد" من الـ topbar */
  .topbar .btn-ghost.btn-sm { display: none; }
}
@media (max-width: 640px) {
  .main { padding: 14px 12px; padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
  .topbar { margin-bottom: 16px; gap: 10px; }
  .topbar h1 { font-size: 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-val { font-size: 22px; }
  .field-row { grid-template-columns: 1fr; }
  .modal { padding: 16px; border-radius: 20px 20px 0 0; margin: 0; align-self: flex-end; max-height: 92dvh; }
  .modal-overlay { align-items: flex-end; }
  .appt-card { flex-wrap: wrap; gap: 8px; }
  .appt-actions { width: 100%; justify-content: flex-end; }
  .toolbar .input, .toolbar .select { width: 100%; min-width: 0; }
  .filter-tabs { gap: 6px; }
  .filter-tab { padding: 7px 10px; font-size: 12px; }
}
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { padding: 14px; }
}

/* backdrop for mobile sidebar */
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 80; display: none; }
.sidebar-backdrop.show { display: block; }

/* segmented control */
.seg { display: flex; background: var(--bg-2); padding: 4px; border-radius: 10px; gap: 4px; }
.seg button { flex: 1; padding: 8px; border: none; background: none; color: var(--text-3); font-family: inherit; font-weight: 700; font-size: 13px; border-radius: 7px; cursor: pointer; transition: all .2s; }
.seg button.active { background: var(--surface-3); color: var(--text); }

/* divider */
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* share modal */
.share-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.share-opt {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: all .2s; border: none; font-family: inherit; color: var(--text-2); font-size: 12px; font-weight: 600;
}
.share-opt:hover { background: var(--surface-3); border-color: var(--border-2); color: var(--text); transform: translateY(-2px); }
.share-opt i { font-size: 22px; }
.share-opt.wa i { color: #25d366; }
.share-opt.tg i { color: #29a6ea; }
.share-opt.copy i { color: var(--primary); }
.share-opt.ical i { color: var(--warning); }
