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

:root {
    --primary: #0a0a0f;
    --secondary: #13131a;
    --tertiary: #1a1a24;
    --accent: #2d5ee5;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --text: #ffffff;
    --text-muted: #9ca3af;
    --text-dark: #6b7280;
    --border: #2a2a35;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --gradient: #a855f7;
    
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --transition: all 0.3s ease;
}

/* Light Theme Variables */
body.light-theme {
    --primary: #f5f5f7;
    --secondary: #ffffff;
    --tertiary: #f8f8f8;
    --text: #1a1a1f;
    --text-muted: #6b7280;
    --text-dark: #9ca3af;
    --border: #d1d5db;
}

/* ========== Ocean Theme (deep teal) ========== */
body.theme-ocean {
    --primary: #061a24;
    --secondary: #0a2935;
    --tertiary: #133847;
    --accent: #06b6d4;
    --accent-light: #22d3ee;
    --accent-dark: #0891b2;
    --text: #e0f7ff;
    --text-muted: #7ba3b8;
    --text-dark: #5d8499;
    --border: #1d4456;
    --gradient: #0ea5e9;
}
body.theme-ocean .top-header { background: rgba(6, 26, 36, 0.8); }

/* ========== Forest Theme (deep emerald) ========== */
body.theme-forest {
    --primary: #0a1410;
    --secondary: #122318;
    --tertiary: #1a3326;
    --accent: #10b981;
    --accent-light: #34d399;
    --accent-dark: #059669;
    --text: #ecfdf5;
    --text-muted: #86b09a;
    --text-dark: #5d8674;
    --border: #1f3d2c;
    --gradient: #14b8a6;
}
body.theme-forest .top-header { background: rgba(10, 20, 16, 0.8); }

/* ========== Royal Theme (deep purple) ========== */
body.theme-royal {
    --primary: #0f0a1f;
    --secondary: #1a1130;
    --tertiary: #251a45;
    --accent: #a855f7;
    --accent-light: #c084fc;
    --accent-dark: #9333ea;
    --text: #f5f3ff;
    --text-muted: #a89bc4;
    --text-dark: #7c70a0;
    --border: #382454;
    --gradient: #1d4ed8;
}
body.theme-royal .top-header { background: rgba(15, 10, 31, 0.8); }

/* ========== Midnight Theme (electric blue) ========== */
body.theme-midnight {
    --primary: #050816;
    --secondary: #0a0f24;
    --tertiary: #111933;
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --accent-dark: #2563eb;
    --text: #e6ebff;
    --text-muted: #6b7a99;
    --text-dark: #4a5777;
    --border: #1f2845;
    --gradient: #1d4ed8;
}
body.theme-midnight .top-header { background: rgba(5, 8, 22, 0.8); }

/* ========== Cyberpunk Theme (neon pink/cyan) ========== */
body.theme-cyberpunk {
    --primary: #0a0014;
    --secondary: #14001f;
    --tertiary: #1f0033;
    --accent: #ec4899;
    --accent-light: #f472b6;
    --accent-dark: #db2777;
    --text: #f5e6ff;
    --text-muted: #b59ec7;
    --text-dark: #846f96;
    --border: #2d0a47;
    --gradient: #06b6d4;
}
body.theme-cyberpunk .top-header { background: rgba(10, 0, 20, 0.8); }

/* ========== Dracula Theme ========== */
body.theme-dracula {
    --primary: #282a36;
    --secondary: #383a4c;
    --tertiary: #44475a;
    --accent: #bd93f9;
    --accent-light: #ff79c6;
    --accent-dark: #9580d4;
    --text: #f8f8f2;
    --text-muted: #c4c4d0;
    --text-dark: #6272a4;
    --border: #44475a;
    --gradient: #ff79c6;
}
body.theme-dracula .top-header { background: rgba(40, 42, 54, 0.8); }

/* ========== Nord Theme (cool blue-gray) ========== */
body.theme-nord {
    --primary: #2e3440;
    --secondary: #3b4252;
    --tertiary: #434c5e;
    --accent: #88c0d0;
    --accent-light: #8fbcbb;
    --accent-dark: #5e81ac;
    --text: #eceff4;
    --text-muted: #d8dee9;
    --text-dark: #a4adc4;
    --border: #4c566a;
    --gradient: #5e81ac;
}
body.theme-nord .top-header { background: rgba(46, 52, 64, 0.8); }

/* ========== Slate Theme (sophisticated slate-blue) ========== */
body.theme-slate {
    --primary: #0f172a;
    --secondary: #1e293b;
    --tertiary: #334155;
    --accent: #06b6d4;
    --accent-light: #22d3ee;
    --accent-dark: #0891b2;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dark: #64748b;
    --border: #334155;
    --gradient: #0ea5e9;
}
body.theme-slate .top-header { background: rgba(15, 23, 42, 0.8); }

/* ========== Mocha Theme (warm rich brown) ========== */
body.theme-mocha {
    --primary: #1c1410;
    --secondary: #2a1f17;
    --tertiary: #3d2e22;
    --accent: #d4a574;
    --accent-light: #e8c598;
    --accent-dark: #a8855a;
    --text: #f5ede0;
    --text-muted: #c0a896;
    --text-dark: #8a7866;
    --border: #4a3828;
    --gradient: #b8865a;
}
body.theme-mocha .top-header { background: rgba(28, 20, 16, 0.8); }

/* ========== Crimson Theme (deep red sophistication) ========== */
body.theme-crimson {
    --primary: #1a0a0d;
    --secondary: #2a1118;
    --tertiary: #3d1a23;
    --accent: #dc2626;
    --accent-light: #ef4444;
    --accent-dark: #b91c1c;
    --text: #fdf4f5;
    --text-muted: #c9a4ac;
    --text-dark: #997a82;
    --border: #4a1d28;
    --gradient: #f43f5e;
}
body.theme-crimson .top-header { background: rgba(26, 10, 13, 0.8); }

/* ========== Aurora Theme (northern lights green/purple) ========== */
body.theme-aurora {
    --primary: #0a0f1c;
    --secondary: #131b2e;
    --tertiary: #1c2640;
    --accent: #10b981;
    --accent-light: #6ee7b7;
    --accent-dark: #059669;
    --text: #ecfeff;
    --text-muted: #94a3b8;
    --text-dark: #6b7c99;
    --border: #1f2d4d;
    --gradient: #a855f7;
}
body.theme-aurora .top-header { background: rgba(10, 15, 28, 0.8); }

/* ========== Rose Gold Theme (light pink/champagne) ========== */
body.theme-rose-gold {
    --primary: #fdf2f4;
    --secondary: #ffffff;
    --tertiary: #fce8ec;
    --accent: #e11d48;
    --accent-light: #fb7185;
    --accent-dark: #be123c;
    --text: #1f1213;
    --text-muted: #7a5560;
    --text-dark: #9c7d85;
    --border: #f5cdd5;
    --gradient: #f59e0b;
}
body.theme-rose-gold .top-header { background: rgba(253, 242, 244, 0.8); }

/* ========== Solarized Light Theme (warm cream/gold) ========== */
body.theme-solarized {
    --primary: #fdf6e3;
    --secondary: #ffffff;
    --tertiary: #f5eed0;
    --accent: #b58900;
    --accent-light: #cb9d28;
    --accent-dark: #93720b;
    --text: #073642;
    --text-muted: #586e75;
    --text-dark: #93a1a1;
    --border: #eee8d5;
    --gradient: #cb4b16;
}
body.theme-solarized .top-header { background: rgba(253, 246, 227, 0.8); }

/* ========== Mint Theme (soft sage green) ========== */
body.theme-mint {
    --primary: #f0fdf4;
    --secondary: #ffffff;
    --tertiary: #dcfce7;
    --accent: #059669;
    --accent-light: #10b981;
    --accent-dark: #047857;
    --text: #0f1f17;
    --text-muted: #4d6b5a;
    --text-dark: #7a9485;
    --border: #bbf7d0;
    --gradient: #14b8a6;
}
body.theme-mint .top-header { background: rgba(240, 253, 244, 0.8); }

/* ========== Sky Theme (pale blue) ========== */
body.theme-sky {
    --primary: #f0f9ff;
    --secondary: #ffffff;
    --tertiary: #e0f2fe;
    --accent: #0284c7;
    --accent-light: #38bdf8;
    --accent-dark: #0369a1;
    --text: #0c2540;
    --text-muted: #475569;
    --text-dark: #94a3b8;
    --border: #bae6fd;
    --gradient: #0ea5e9;
}
body.theme-sky .top-header { background: rgba(240, 249, 255, 0.8); }

/* ========== Lavender Theme (soft purple) ========== */
body.theme-lavender {
    --primary: #faf5ff;
    --secondary: #ffffff;
    --tertiary: #f3e8ff;
    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --accent-dark: #6d28d9;
    --text: #1f1338;
    --text-muted: #6b5694;
    --text-dark: #9b8bbe;
    --border: #e9d5ff;
    --gradient: #1d4ed8;
}
body.theme-lavender .top-header { background: rgba(250, 245, 255, 0.8); }

/* ========== Sand Theme (warm beige/amber) ========== */
body.theme-sand {
    --primary: #fef9f0;
    --secondary: #ffffff;
    --tertiary: #fef3e2;
    --accent: #d97706;
    --accent-light: #f59e0b;
    --accent-dark: #b45309;
    --text: #1f1610;
    --text-muted: #78604a;
    --text-dark: #a89178;
    --border: #fde9c8;
    --gradient: #ea580c;
}
body.theme-sand .top-header { background: rgba(254, 249, 240, 0.8); }

/* ========== Pearl Theme (neutral elegant) ========== */
body.theme-pearl {
    --primary: #f8f7fa;
    --secondary: #ffffff;
    --tertiary: #f0eef5;
    --accent: #6b46c1;
    --accent-light: #1d4ed8;
    --accent-dark: #553c9a;
    --text: #1a1625;
    --text-muted: #5a4f70;
    --text-dark: #8b7e9e;
    --border: #e0dbe8;
    --gradient: #6366f1;
}
body.theme-pearl .top-header { background: rgba(248, 247, 250, 0.8); }

/* ========== Matcha Theme (earthy green) ========== */
body.theme-matcha {
    --primary: #f7faf3;
    --secondary: #ffffff;
    --tertiary: #ecf3e0;
    --accent: #65a30d;
    --accent-light: #84cc16;
    --accent-dark: #4d7c0f;
    --text: #1a2010;
    --text-muted: #5a6745;
    --text-dark: #8a9670;
    --border: #d6e3bc;
    --gradient: #84cc16;
}
body.theme-matcha .top-header { background: rgba(247, 250, 243, 0.8); }

/* ========== Champagne Theme (elegant gold) ========== */
body.theme-champagne {
    --primary: #faf8f0;
    --secondary: #ffffff;
    --tertiary: #f5f1e0;
    --accent: #ca8a04;
    --accent-light: #eab308;
    --accent-dark: #a16207;
    --text: #1f1810;
    --text-muted: #6b5a3a;
    --text-dark: #998a6a;
    --border: #ede4c5;
    --gradient: #eab308;
}
body.theme-champagne .top-header { background: rgba(250, 248, 240, 0.8); }

/* ========== Glacier Theme (icy pale blue) ========== */
body.theme-glacier {
    --primary: #f0f7fa;
    --secondary: #ffffff;
    --tertiary: #e1edf3;
    --accent: #0e7490;
    --accent-light: #06b6d4;
    --accent-dark: #155e75;
    --text: #0c1f24;
    --text-muted: #475569;
    --text-dark: #94a3b8;
    --border: #c5dde6;
    --gradient: #0891b2;
}
body.theme-glacier .top-header { background: rgba(240, 247, 250, 0.8); }

/* ========== Blush Theme (modern magenta) ========== */
body.theme-blush {
    --primary: #fdf2f8;
    --secondary: #ffffff;
    --tertiary: #fce7f3;
    --accent: #db2777;
    --accent-light: #ec4899;
    --accent-dark: #be185d;
    --text: #2a0a1f;
    --text-muted: #7a4a6a;
    --text-dark: #b08395;
    --border: #f9c5dc;
    --gradient: #d946ef;
}
body.theme-blush .top-header { background: rgba(253, 242, 248, 0.8); }

/* Theme color swatch (visual preview in dropdown) */
.theme-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}
body.light-theme .theme-swatch,
body.theme-rose-gold .theme-swatch,
body.theme-solarized .theme-swatch,
body.theme-mint .theme-swatch,
body.theme-sky .theme-swatch,
body.theme-lavender .theme-swatch,
body.theme-sand .theme-swatch,
body.theme-pearl .theme-swatch,
body.theme-matcha .theme-swatch,
body.theme-champagne .theme-swatch,
body.theme-glacier .theme-swatch,
body.theme-blush .theme-swatch {
    border-color: rgba(0, 0, 0, 0.15);
}

.theme-dropdown-section {
    padding: 6px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    opacity: 0.7;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--primary);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
    min-height: var(--header-height);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-decoration: none;
    color: var(--text);
    /* Bounded slot for the logo. Dimensions are set by an aspect-ratio
       modifier class (.logo--wide / .logo--medium / .logo--square) that
       JS adds once the image's natural size is known. The base values
       below act as a safe fallback for the brief moment before that
       class is applied (and as the absolute upper bound — JS can only
       pick smaller buckets). */
    flex: 0 0 auto;
    max-width: 200px;
    height: 36px;
    max-height: 36px;
    overflow: hidden;
    transition: height 0.18s ease, max-width 0.18s ease;
}

/* Aspect-ratio buckets. JS picks one based on the image's natural
   width/height. Hard caps on width AND height in every bucket make
   sure the page layout cannot break, no matter what shape the logo
   has. */
/* Reference height for every logo: the default crms.am wordmark
   (973×168) rendered at the 200px width cap is ~34.5px tall. We use
   that as the uniform max-height across all buckets so no logo — wide,
   medium or square — ever renders taller than the crms.am logo, and
   the sidebar header stays compact. Width still varies per bucket so
   wordmarks can use the full width while square logos don't get a
   needlessly wide slot. The image itself never upscales past its
   natural size (see width/height:auto on .logo img below). */
.logo.logo--wide {
    /* Wordmarks / banners (aspect ≥ 2.5), e.g. crms.am 973×168.
       Width is the binding constraint: fills up to 200px wide, which
       lands at ~35px tall. */
    max-width: 200px;
    height: 36px;
    max-height: 36px;
}
.logo.logo--medium {
    /* Balanced rectangles (1.2 ≤ aspect < 2.5), e.g. a ~2:1 logo.
       Height-bound at 36px → renders ~72px wide. */
    max-width: 200px;
    height: 36px;
    max-height: 36px;
}
.logo.logo--square {
    /* Square / portrait logos (aspect < 1.2). Height-bound at 36px,
       so a square logo renders ~36×36. */
    max-width: 100px;
    height: 36px;
    max-height: 36px;
}

/* Custom company logo (or default site logo) inside the sidebar.
   `object-fit: contain` scales the image down to fit the slot while
   preserving aspect ratio — wordmarks fill horizontally, square logos
   fill vertically, nothing gets stretched or clipped. */
.sidebar-logo-img,
.logo img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: left center;
}

.sidebar.collapsed .logo,
.sidebar.collapsed .logo.logo--wide,
.sidebar.collapsed .logo.logo--medium,
.sidebar.collapsed .logo.logo--square {
    max-width: 40px;
    height: 40px;
    max-height: 40px;
    justify-content: center;
}
.sidebar.collapsed .sidebar-logo-img,
.sidebar.collapsed .logo img {
    object-position: center;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-text span {
    color: var(--accent);
}

.sidebar.collapsed .logo-text {
    display: none;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--tertiary);
}

/* Custom Scrollbar for Sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: var(--tertiary);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
    transition: var(--transition);
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--accent-light);
}

.sidebar-nav::-webkit-scrollbar-thumb:active {
    background: var(--accent-dark);
}

/* Hide scrollbar when not hovering (optional smooth appearance) */
.sidebar-nav {
    scrollbar-gutter: stable;
}

.sidebar:hover .sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--accent);
}

.sidebar .sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin: 4px 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition);
    position: relative;
}

.nav-link i:first-child {
    width: 20px;
    text-align: center;
    font-size: 18px;
}

.nav-link:hover {
    background: var(--tertiary);
    color: var(--text);
}

.nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-light);
}

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

.submenu-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: var(--transition);
}

.nav-item.has-submenu.open .submenu-arrow {
    transform: rotate(180deg);
}

.sidebar.collapsed .nav-link span,
.sidebar.collapsed .submenu-arrow {
    display: none;
}

/* Submenu */
.submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-item.has-submenu.open .submenu {
    /* Fallback cap for class-only toggles (e.g. auto-open on page load).
       JS sets an exact inline max-height = scrollHeight for smooth animation;
       this large value just guarantees long menus are never clipped. */
    max-height: 2000px;
}

.submenu li a {
    display: block;
    padding: 10px 16px 10px 48px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    border-radius: 8px;
    margin: 2px 0;
    transition: var(--transition);
}

.submenu li a:hover {
    background: var(--tertiary);
    color: var(--text);
}

.submenu li a.active {
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.1);
}

.sidebar.collapsed .submenu {
    display: none;
}

/* Nested submenu (3rd level, e.g. Marketing > Message Templates > Email/SMS) */
/* Selector is scoped through `.submenu li` so it out-specifies the generic
   `.submenu li a { display: block }` rule above — otherwise display:block wins
   and the long label pushes the inline chevron onto its own line below. */
.submenu li .submenu-group-link {
    display: flex;
    align-items: center;
    padding: 10px 16px 10px 48px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    border-radius: 8px;
    margin: 2px 0;
    cursor: pointer;
    transition: var(--transition);
}

/* Let the label take the free space and wrap inside its own box so the arrow
   stays pinned to the right edge on the same row as the text. */
.submenu li .submenu-group-link span {
    flex: 1;
    min-width: 0;
}

.submenu li .submenu-group-link:hover {
    background: var(--tertiary);
    color: var(--text);
}

.subsubmenu-arrow {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 11px;
    transition: var(--transition);
}

.nav-subitem.has-subsubmenu.open .subsubmenu-arrow {
    transform: rotate(180deg);
}

.subsubmenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-subitem.has-subsubmenu.open .subsubmenu {
    max-height: 1000px;  /* fallback cap; JS sets exact inline height — see .submenu */
}

.subsubmenu li a {
    display: block;
    padding: 9px 16px 9px 64px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    border-radius: 8px;
    margin: 2px 0;
    transition: var(--transition);
}

.subsubmenu li a:hover {
    background: var(--tertiary);
    color: var(--text);
}

.subsubmenu li a.active {
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.1);
}

.sidebar.collapsed .subsubmenu,
.sidebar.collapsed .submenu-group-link span,
.sidebar.collapsed .subsubmenu-arrow {
    display: none;
}

/* Nav Divider */
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 16px 24px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
    color: #ffffff;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar.collapsed .user-details {
    display: none;
}

.logout-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Top Header */
.top-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

body.light-theme .top-header {
    background: rgba(245, 245, 247, 0.8);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.breadcrumb {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-search {
    position: relative;
    display: flex;
    align-items: center;
}

.header-search i {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 14px;
}

.header-search input {
    width: 260px;
    padding: 10px 16px 10px 40px;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
}

.header-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--tertiary);
}

.header-search input::placeholder {
    color: var(--text-muted);
}

.header-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.1);
}

/* ─────────────────────────────────────────────────────────────────
   User-guide MODAL (in-page iframe popup, full height)
   Backdrop covers the whole viewport; the panel itself fills most
   of the screen so the guide content has room to breathe.
   ───────────────────────────────────────────────────────────────── */
.ug-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.18s ease;
}
.ug-modal-overlay.open {
    display: flex;
    opacity: 1;
    animation: ugModalFadeIn 0.22s ease;
}
@keyframes ugModalFadeIn { from { opacity: 0; } to { opacity: 1; } }

.ug-modal {
    width: 100%;
    max-width: 1280px;
    height: 100%;
    max-height: calc(100vh - 48px);
    background: var(--bg-primary, #ffffff);
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ugModalRise 0.24s cubic-bezier(.4, 0, .2, 1);
}
@keyframes ugModalRise {
    from { transform: translateY(20px) scale(0.985); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.ug-modal-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}
.ug-modal-title {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 700;
    color: white;
}
.ug-modal-title i {
    font-size: 18px;
    opacity: 0.95;
}

.ug-modal-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.ug-modal-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.15s, transform 0.1s;
}
.ug-modal-icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}
.ug-modal-icon-btn:active { transform: scale(0.94); }
.ug-modal-icon-btn.ug-modal-close { font-size: 16px; }

.ug-modal-body {
    flex: 1 1 auto;
    min-height: 0; /* lets the iframe fill remaining height in a flex column */
    background: var(--bg-secondary, #f8fafc);
}

.ug-modal-body iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: var(--bg-secondary, #f8fafc);
}

/* Mobile — let the modal go truly full-screen for readability. */
@media (max-width: 768px) {
    .ug-modal-overlay { padding: 0; }
    .ug-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    .ug-modal-header { padding: 12px 14px; }
    .ug-modal-title { font-size: 14px; }
    .ug-modal-title i { font-size: 16px; }
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Theme Selector */
.theme-selector {
    position: relative;
}

.theme-toggle-btn {
    position: relative;
}

.theme-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    z-index: 1000;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}
.theme-dropdown::-webkit-scrollbar { width: 6px; }
.theme-dropdown::-webkit-scrollbar-track { background: transparent; }
.theme-dropdown::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
    opacity: 0.6;
}

.theme-selector.open .theme-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.theme-option:hover {
    background: var(--tertiary);
    color: var(--text);
}

.theme-option.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-light);
}

.theme-option i {
    width: 18px;
    text-align: center;
}

/* Page Container */
.page-container {
    padding: 24px;
    min-height: calc(100vh - var(--header-height));
}

.page-loading {
    display: none;
    position: fixed;
    /* Cover the entire main-content area top → bottom (sidebar excluded
       via the `left: var(--sidebar-width)` offset). With z-index 9999
       this also paints OVER any page-level overlays such as automations'
       `.rp-edit-panel` (z-index 1000), so we don't need to manually hide
       those panels on every navigation. */
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    /* Match the current theme's primary background so the loader blends
       in instead of flashing bright white over a dark UI. Without this,
       navigating to any page made the dark-theme content area "snap to
       white" for the duration of the fetch — visually indistinguishable
       from a full page reload. */
    background: var(--primary);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition);
}

body.light-theme .page-loading {
    background: var(--primary);
}

body:not(.light-theme) .page-loading {
    background: var(--primary);
}

.sidebar.collapsed ~ .main-content .page-loading {
    left: var(--sidebar-collapsed-width);
}

.page-loading.active {
    display: flex;
}

/* ── Slide-over edit panel — default off-screen state ─────────────────────
   Used by automations / reports (and any future page that needs a full-
   screen slide-over editor). The default `transform: translateX(100%)`
   lives in this GLOBAL stylesheet on purpose: page-specific CSS
   (automations.css / reports.css) loads AFTER the page HTML is injected
   into pageContainer, which means there's a brief window where the
   panel element exists in DOM but its page-specific rules haven't
   arrived yet. Without these defaults applying immediately, the panel
   renders as a regular block element for that window and the browser
   then animates the transform change to 100% over 0.3s — which is the
   "panel flash" the user sees during a transition.
   Page-specific CSS still owns the visual styling (background colour)
   and the transition rule, so the slide-in / slide-out animation for
   user actions (open / close) still works exactly as before — that's a
   genuine class-toggle change, not a stylesheet-arrival change. */
.rp-edit-panel {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
}
.rp-edit-panel.rp-edit-panel-open {
    transform: translateX(0);
}

.page-loading i {
    font-size: 48px;
    color: var(--accent);
    animation: spin 1s linear infinite;
}

.page-loading span {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-muted);
}

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

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .header-search {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .page-container {
        padding: 16px;
    }

    .top-header {
        padding: 0 16px;
    }
}

/* Notifications Window (legacy - kept for compatibility) */
.notifications-window { display: none !important; }
.notifications-overlay { display: none !important; }

/* ── Notifications Panel (new slide-in) ── */

.notif-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.notif-panel-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.notif-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 390px;
    max-width: 100vw;
    height: 100vh;
    background: var(--secondary);
    border-left: 1px solid var(--border);
    box-shadow: -6px 0 28px rgba(0,0,0,0.18);
    z-index: 1999;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}

.notif-panel.open {
    right: 0;
}

.notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.notif-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.notif-panel-title i {
    color: var(--accent);
    font-size: 16px;
}

.notif-panel-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.notif-panel-close:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239,68,68,0.08);
}

.notif-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.notif-panel-body::-webkit-scrollbar {
    width: 4px;
}
.notif-panel-body::-webkit-scrollbar-track {
    background: transparent;
}
.notif-panel-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.notif-panel-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.notif-panel-loading i {
    color: var(--accent);
    font-size: 18px;
}

.notif-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
    color: var(--text-muted);
    gap: 10px;
}

.notif-empty i {
    font-size: 44px;
    opacity: 0.3;
    margin-bottom: 4px;
}

.notif-empty p {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.notif-empty span {
    font-size: 13px;
    color: var(--text-muted);
}

/* Unread banner */
.notif-unread-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(45, 94, 229, 0.08);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.notif-unread-banner i {
    font-size: 14px;
    flex-shrink: 0;
}

/* Group */
.notif-group {
    padding: 0;
}

.notif-group-label {
    padding: 10px 20px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--tertiary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2;
}

.notif-group-label--today {
    color: var(--accent);
    background: rgba(45, 94, 229, 0.06);
}

/* Notification item */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    position: relative;
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item:hover {
    background: var(--tertiary);
}

.notif-item--today {
    background: rgba(45, 94, 229, 0.04);
}

.notif-item--today:hover {
    background: rgba(45, 94, 229, 0.09);
}

.notif-item--past {
    opacity: 0.72;
}

.notif-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
    background: rgba(100, 116, 139, 0.12);
    color: var(--text-muted);
}

.notif-icon--email { background: rgba(59,130,246,0.12); color: #3b82f6; }
.notif-icon--sms { background: rgba(34,197,94,0.12); color: #16a34a; }
.notif-icon--phone { background: rgba(245,158,11,0.12); color: #d97706; }
.notif-icon--whatsapp { background: rgba(34,197,94,0.12); color: #16a34a; }
.notif-icon--telegram { background: rgba(59,130,246,0.12); color: #3b82f6; }
.notif-icon--messenger { background: rgba(99,102,241,0.12); color: #6366f1; }
.notif-icon--instagram { background: rgba(236,72,153,0.12); color: #ec4899; }
.notif-icon--other { background: rgba(100,116,139,0.12); color: var(--text-muted); }

.notif-item-body {
    flex: 1;
    min-width: 0;
}

.notif-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-item-contact {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.notif-item-channel {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.notif-item-time {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.notif-item-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
    align-self: center;
}

.notif-badge--today {
    background: rgba(45, 94, 229, 0.12);
    color: var(--accent);
}

.notif-badge--past {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

@media (max-width: 768px) {
    .notif-panel {
        width: 100%;
        right: -100%;
    }

    .page-loading {
        left: 0;
        /* Match the desktop rule: cover the full main-content area on
           mobile too, so page-level overlays don't peek through during a
           navigation. */
        top: 0;
    }
}

/* ==================== AI CHAT WIDGET ==================== */
.chat-widget-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-widget-btn i {
    font-size: 26px;
}

.chat-widget-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.55);
}

.chat-widget-btn .chat-close-icon {
    display: none;
}

.chat-widget-btn.open .chat-open-icon {
    display: none;
}

.chat-widget-btn.open .chat-close-icon {
    display: flex;
}

.chat-window {
    position: fixed !important;
    bottom: 102px;
    right: 28px;
    width: 1010px;
    max-width: calc(100vw - 40px);
    height: 90vh;
    max-height: calc(100vh - 130px);
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 2999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.97);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
    overflow: hidden;
}

.chat-window.fullscreen {
    bottom: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    z-index: 9999 !important;
}

.chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    background: var(--secondary);
}

.chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

.chat-header-status {
    font-size: 12px;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
}

.chat-header-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-header-close:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.chat-header-fullscreen {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-right: 4px;
}

.chat-header-fullscreen:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.1);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.chat-header-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-header-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.chat-message {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 11px;
    flex-shrink: 0;
}

.chat-message.user .chat-message-avatar {
    background: var(--tertiary);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.chat-message-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-message.bot .chat-message-bubble {
    background: var(--tertiary);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-message.user .chat-message-bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-typing {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-typing-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 11px;
    flex-shrink: 0;
}

.chat-typing-bubble {
    padding: 12px 16px;
    background: var(--tertiary);
    border: 1px solid var(--border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.chat-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
    background: var(--secondary);
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 110px;
    line-height: 1.4;
    transition: border-color 0.2s ease;
    font-family: inherit;
    outline: none;
}

.chat-input:focus {
    border-color: var(--accent);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent);
    border: none;
    color: white;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    opacity: 0.88;
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chat-quick-actions {
    padding: 0 16px 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.chat-quick-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chat-quick-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.08);
}

@media (max-width: 768px) {
    .chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 90vh;
        max-height: 90vh;
        border-radius: 18px 18px 0 0;
    }

    .chat-widget-btn {
        bottom: 20px;
        right: 20px;
    }
}

/* ==================== UTILITY CLASSES ==================== */
.card {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px -10px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--tertiary);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

/* Grid System */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Stats Card */
.stat-card {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-light);
}

.stat-icon.success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-icon.info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-muted);
}

.stat-change {
    font-size: 12px;
    margin-top: 8px;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* Table Styles */
.table-container {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--tertiary);
}

.table th:first-child {
    border-radius: 8px 0 0 8px;
}

.table th:last-child {
    border-radius: 0 8px 8px 0;
}

.table tr:hover td {
    background: rgba(99, 102, 241, 0.05);
}

.table td {
    font-size: 14px;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-light);
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.chat-message-bubble ol{
    margin-left: 12px !important;
}

.chat-message-bubble ul{
    margin-left: 12px !important;
}

/* ========================================================================
   Active Call Popup — floating call notifier + custom alert/confirm modal.
   Driven by the ActiveCallPopup module in dashboard.js. Markup is injected
   dynamically (see dashboard.html for the static fallback).
   ======================================================================== */
.active-call-popup {
    position: fixed; bottom: 24px; right: 24px;
    width: 380px; max-width: calc(100vw - 32px);
    background: var(--bg-primary, #fff);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.05);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.06);
    animation: acp-slide-in .25s cubic-bezier(.4,0,.2,1);
}
.active-call-popup.is-open { display: flex; }
.active-call-popup.is-ended { box-shadow: 0 10px 40px rgba(34,197,94,.18); }

@keyframes acp-slide-in {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.acp-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: #fff; position: relative;
}
.acp-header.is-inbound  { background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); }
.acp-header.is-outbound { background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%); }
.acp-header.is-ended    { background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%); }

.acp-direction-icon {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0;
}
.acp-direction-label { font-size: 13px; font-weight: 600; line-height: 1.2; }
.acp-status-line { font-size: 11px; opacity: .85; margin-top: 2px; line-height: 1.2; }
.acp-pulse {
    display: inline-block; width: 7px; height: 7px;
    border-radius: 50%; background: #fff; margin-right: 5px;
    animation: acp-pulse 1.4s ease-in-out infinite;
    vertical-align: middle;
}
@keyframes acp-pulse {
    0%,100% { opacity: 1; transform: scale(1); }
    50%     { opacity: .35; transform: scale(.8); }
}

.acp-close-btn {
    background: transparent; border: 0; color: #fff;
    cursor: pointer; padding: 6px 8px; border-radius: 6px;
    font-size: 14px; line-height: 1;
}
.acp-close-btn:hover { background: rgba(255,255,255,.18); }

.acp-body { padding: 14px 16px 16px; }

.acp-contact-line {
    font-size: 15px; font-weight: 600;
    color: var(--text, #1e293b);
    line-height: 1.3; word-break: break-word;
}
.acp-contact-line .acp-new-badge {
    display: inline-block; font-size: 10px; font-weight: 600;
    padding: 2px 6px; border-radius: 999px;
    background: #fef3c7; color: #92400e;
    margin-left: 6px; vertical-align: middle;
}
.acp-phone-line {
    font-size: 13px; color: var(--text-muted, #64748b);
    margin-top: 2px; margin-bottom: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.acp-meta-row {
    display: flex; gap: 8px;
    padding: 10px 12px;
    background: var(--bg-secondary, #f8fafc);
    border-radius: 8px; margin-bottom: 14px; font-size: 13px;
}
.acp-meta-item { flex: 1; min-width: 0; }
.acp-meta-item .label {
    display: block; font-size: 11px;
    color: var(--text-muted, #64748b); margin-bottom: 2px;
}
.acp-meta-item .value {
    font-weight: 600; color: var(--text, #1e293b);
    font-variant-numeric: tabular-nums;
}

.acp-comment-label {
    display: block; font-size: 12px;
    color: var(--text-muted, #64748b); margin-bottom: 6px;
}
.acp-comment {
    width: 100%; min-height: 72px; max-height: 200px;
    padding: 9px 11px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px; resize: vertical;
    font-family: inherit; font-size: 13px; line-height: 1.45;
    background: var(--bg-primary, #fff); color: var(--text, #1e293b);
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}
.acp-comment:focus {
    outline: none; border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.acp-actions { display: flex; gap: 8px; margin-top: 12px; }
.acp-btn {
    flex: 1; height: 36px; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    cursor: pointer; border: 0;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; font-family: inherit;
    transition: background .15s, transform .05s;
}
.acp-btn:active { transform: translateY(1px); }
.acp-btn-primary { background: #3b82f6; color: #fff; }
.acp-btn-primary:hover:not(:disabled) { background: #2563eb; }
.acp-btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.acp-btn-secondary {
    background: var(--bg-secondary, #f1f5f9);
    color: var(--text, #1e293b);
    border: 1px solid var(--border-color, #e2e8f0);
}
.acp-btn-secondary:hover { background: var(--border-color, #e2e8f0); }

.acp-saved-toast {
    position: absolute; top: 10px; left: 50%;
    transform: translateX(-50%) translateY(-30px);
    background: #22c55e; color: #fff;
    padding: 6px 14px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    opacity: 0;
    transition: opacity .25s, transform .25s;
    pointer-events: none; z-index: 1;
}
.acp-saved-toast.is-visible {
    opacity: 1; transform: translateX(-50%) translateY(0);
}

.acp-queue-indicator {
    position: absolute; top: -8px; right: -8px;
    background: #ef4444; color: #fff;
    font-size: 11px; font-weight: 700;
    min-width: 22px; height: 22px; padding: 0 6px;
    border-radius: 999px; display: none;
    align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(239,68,68,.4);
}

body:not(.light-theme) .active-call-popup {
    background: #1e293b; border-color: rgba(255,255,255,.06);
}
body:not(.light-theme) .acp-comment {
    background: #0f172a; border-color: #334155; color: #f1f5f9;
}
body:not(.light-theme) .acp-meta-row { background: #0f172a; }
body:not(.light-theme) .acp-btn-secondary {
    background: #334155; color: #f1f5f9; border-color: #475569;
}
body:not(.light-theme) .acp-btn-secondary:hover { background: #475569; }

@media (max-width: 480px) {
    .active-call-popup { right: 8px; left: 8px; bottom: 8px; width: auto; }
}

/* ── ACP confirm/alert modal (replaces window.alert/confirm) ────── */
.acp-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
    padding: 16px;
}
.acp-modal-overlay.is-visible { opacity: 1; pointer-events: auto; }
.acp-modal {
    background: var(--bg-primary, #fff);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    width: 380px; max-width: 100%;
    padding: 22px 22px 18px;
    transform: translateY(16px) scale(.97);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
    border: 1px solid rgba(0,0,0,.06);
}
.acp-modal-overlay.is-visible .acp-modal {
    transform: translateY(0) scale(1);
}
.acp-modal-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    margin-bottom: 10px;
}
.acp-modal-icon.is-warn { background: #fef3c7; color: #b45309; }
.acp-modal-icon.is-info { background: #dbeafe; color: #1d4ed8; }
.acp-modal-icon.is-error { background: #fee2e2; color: #b91c1c; }
.acp-modal-title {
    margin: 0 0 6px;
    font-size: 15px; font-weight: 600;
    color: var(--text, #1e293b);
}
.acp-modal-msg {
    margin: 0 0 18px;
    font-size: 13px; line-height: 1.5;
    color: var(--text-muted, #64748b);
    white-space: pre-wrap;
}
.acp-modal-actions {
    display: flex; gap: 8px;
    justify-content: flex-end;
}
.acp-modal-actions .acp-btn {
    flex: 0 0 auto;
    min-width: 92px;
    padding: 0 14px;
}
body:not(.light-theme) .acp-modal {
    background: #1e293b;
    border-color: rgba(255,255,255,.06);
}
body:not(.light-theme) .acp-modal-icon.is-warn { background: rgba(180,83,9,.18); color: #fbbf24; }
body:not(.light-theme) .acp-modal-icon.is-info { background: rgba(29,78,216,.22); color: #93c5fd; }
body:not(.light-theme) .acp-modal-icon.is-error { background: rgba(185,28,28,.22); color: #fca5a5; }


/* ═══════════════════════════════════════════════════════════════════════════
   Notification detail popup — shared content styles
   ═══════════════════════════════════════════════════════════════════════════
   These styles were previously in `main.css`, which only loads on the home
   page. They're also used by the global bell-icon notification popup
   (rendered from dashboard.js → uses .notif-detail-overlay wrapper). When a
   user opened the bell popup from any OTHER page, main.css wasn't loaded so
   the inner layout (header, grid, fields, badges, sections) collapsed to
   browser defaults — that's the "misaligned" look the user reported.
   Lives here in dashboard.css now so it applies on every page.
   The wrapper styles (.notif-detail-overlay/.notif-detail-popup) and the
   status colors (.main-popup-status--*) stay inline in dashboard.html where
   they already were. Day-popup / main-detail-popup-overlay styles remain
   in main.css since they're truly main-page-only.
   ─────────────────────────────────────────────────────────────────────── */

/* ── Popup Header ── */

.main-popup-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 22px 22px 18px;
    border-bottom: 1px solid var(--border, #2a2d3e);
}

.main-popup-header--local {
    background: rgba(45, 94, 229, 0.06);
}

.main-popup-header--customer {
    background: rgba(245, 158, 11, 0.06);
}

.main-popup-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.main-popup-header--local .main-popup-header-icon {
    background: rgba(45, 94, 229, 0.14);
    color: var(--accent, #2d5ee5);
}

.main-popup-header--customer .main-popup-header-icon {
    background: rgba(245, 158, 11, 0.14);
    color: #f59e0b;
}

.main-popup-header-info {
    flex: 1;
    min-width: 0;
    padding-right: 32px;
}

.main-popup-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.main-popup-type-badge--local {
    background: rgba(45, 94, 229, 0.14);
    color: var(--accent, #2d5ee5);
}

.main-popup-type-badge--customer {
    background: rgba(245, 158, 11, 0.14);
    color: #f59e0b;
}

.main-popup-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text, #e2e8f0);
    margin: 0;
    line-height: 1.35;
    word-break: break-word;
}

/* ── Popup Grid (fields) ── */

.main-popup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border, #2a2d3e);
    border-bottom: 1px solid var(--border, #2a2d3e);
}

.main-popup-field {
    background: var(--secondary, #1e2130);
    padding: 12px 16px;
}

.main-popup-field-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted, #718096);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.main-popup-field-val {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #e2e8f0);
    display: flex;
    align-items: center;
}

.main-popup-overdue {
    color: var(--danger, #ef4444) !important;
}

.main-popup-priority {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
}

.main-popup-priority--urgent { background: rgba(239,68,68,0.12); color: var(--danger,#ef4444); }
.main-popup-priority--high { background: rgba(249,115,22,0.12); color: #f97316; }
.main-popup-priority--medium { background: rgba(245,158,11,0.12); color: #f59e0b; }
.main-popup-priority--low { background: rgba(100,116,139,0.12); color: var(--text-muted,#718096); }

.main-popup-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--text, #e2e8f0);
}

/* ── Popup sections (description/notes) ── */

.main-popup-section {
    padding: 14px 22px;
    border-bottom: 1px solid var(--border, #2a2d3e);
}

.main-popup-section:last-child {
    border-bottom: none;
}

.main-popup-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted, #718096);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.main-popup-description {
    font-size: 13px;
    color: var(--text, #e2e8f0);
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.main-popup-notes {
    font-size: 12px;
    color: var(--text-muted, #718096);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}
