/**
 * MAIN DASHBOARD — Design System V1.0
 * Ultra-dark premium SaaS theme with glassmorphism and neon accents.
 * NEW design system — NOT a copy of Workana CSS.
 * Structural layout replication, independent visual identity.
 */

/* ─── CSS Reset & Design Tokens ──────────────────────────────────────── */
:root {
    /* Layout Dimensions */
    --mini-sidebar-width: 60px;
    --sidebar-width: 256px;

    /* Sizing & Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    /* Fonts */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Outfit', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Motion */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --transition: all 0.3s var(--ease);
    --transition-fast: all 0.15s var(--ease);
}

/* Theme Mappings */
html[data-theme="dark"] {
    /* Surfaces */
    --bg-root: #09090b;
    --bg-body: #09090b;
    --bg-surface: #111113;
    --bg-card: #111113;
    --card-bg: #111113;
    --bg-card-hover: #1a1a1e;
    --bg-input: #1a1a1e;
    --bg-elevated: #1a1a1e;

    /* Sidebars */
    --mini-sidebar-bg: #09090b;
    --sidebar-bg: #111113;
    --bg-topbar: rgba(9, 9, 11, 0.8);
    --bg-nav-content: rgba(0, 0, 0, 0.2);

    /* Borders */
    --border: #27272a;
    --border-accent: rgba(139, 92, 246, 0.15);
    --border-hover: #3f3f46;
    --border-subtle: #1c1c1e;

    /* Text */
    --text: #fafafa;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);

    /* Accent & Semantics */
    --accent: #8b5cf6;
    --accent-rgb: 139, 92, 246;
    --accent-hover: #7c3aed;
    --accent-dim: rgba(139, 92, 246, 0.1);
    --accent-glow: rgba(139, 92, 246, 0.2);
    --accent-strong: rgba(139, 92, 246, 0.35);

    --cyan: #00f5ff;
    --cyan-dim: rgba(0, 245, 255, 0.1);
    --orange: #ff8c00;
    --orange-dim: rgba(255, 140, 0, 0.1);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.1);
    --purple: #b266ff;
    --purple-dim: rgba(178, 102, 255, 0.1);
    --yellow: #f59e0b;
    --yellow-dim: rgba(245, 158, 11, 0.1);
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.1);
    --green: #22c55e;
    --green-rgb: 34, 197, 94;
    --green-dim: rgba(34, 197, 94, 0.1);

    /* Subtle highlights in dark mode */
    --kpi-purple-bg: var(--bg-surface);
    --kpi-purple-border: rgba(139, 92, 246, 0.25);
    --kpi-purple-text: #a78bfa;

    --kpi-cyan-bg: var(--bg-surface);
    --kpi-cyan-border: rgba(6, 182, 212, 0.25);
    --kpi-cyan-text: #22d3ee;

    --kpi-orange-bg: var(--bg-surface);
    --kpi-orange-border: rgba(249, 115, 22, 0.25);
    --kpi-orange-text: #fb923c;

    --kpi-green-bg: var(--bg-surface);
    --kpi-green-border: rgba(34, 197, 94, 0.25);
    --kpi-green-text: #4ade80;

    --kpi-yellow-bg: var(--bg-surface);
    --kpi-yellow-border: rgba(234, 179, 8, 0.25);
    --kpi-yellow-text: #fef08a;

    --kpi-blue-bg: var(--bg-surface);
    --kpi-blue-border: rgba(59, 130, 246, 0.25);
    --kpi-blue-text: #93c5fd;
}

html[data-theme="light"] {
    /* Surfaces */
    --bg-root: #f1eff9;
    --bg-body: #f1eff9;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --card-bg: #ffffff;
    --bg-card-hover: #f5f6fe;
    --bg-input: #ffffff;
    --bg-elevated: #fbfbfe;

    /* Sidebars */
    --mini-sidebar-bg: #f1eff9;
    --sidebar-bg: #ffffff;
    --bg-topbar: rgba(241, 239, 249, 0.8);
    --bg-nav-content: rgba(99, 102, 241, 0.03);

    /* Borders */
    --border: #dbd9ed;
    --border-accent: rgba(99, 102, 241, 0.15);
    --border-hover: #cbd5e1;
    --border-subtle: #f0f2fc;

    /* Text */
    --text: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(99, 102, 241, 0.05);
    --shadow-md: 0 10px 25px rgba(99, 102, 241, 0.05), 0 2px 6px rgba(99, 102, 241, 0.03);
    --shadow-lg: 0 16px 40px rgba(99, 102, 241, 0.08), 0 4px 16px rgba(99, 102, 241, 0.05);

    /* Accent & Semantics */
    --accent: #6366f1;
    --accent-rgb: 99, 102, 241;
    --accent-hover: #4f46e5;
    --accent-dim: rgba(99, 102, 241, 0.08);
    --accent-glow: rgba(99, 102, 241, 0.15);
    --accent-strong: rgba(99, 102, 241, 0.25);

    --cyan: #0891b2;
    --cyan-dim: rgba(8, 145, 178, 0.1);
    --orange: #ea580c;
    --orange-dim: rgba(234, 88, 12, 0.1);
    --red: #e11d48;
    --red-dim: rgba(225, 29, 72, 0.1);
    --purple: #7c3aed;
    --purple-dim: rgba(124, 58, 237, 0.1);
    --yellow: #d97706;
    --yellow-dim: rgba(217, 119, 6, 0.1);
    --blue: #2563eb;
    --blue-dim: rgba(37, 99, 235, 0.1);
    --green: #16a34a;
    --green-rgb: 22, 163, 74;
    --green-dim: rgba(22, 163, 74, 0.1);

    /* Pastel Accents for KPI cards in light mode */
    --kpi-purple-bg: linear-gradient(135deg, #f5f3ff 0%, #e0e7ff 100%);
    --kpi-purple-border: #c7d2fe;
    --kpi-purple-text: #4f46e5;

    --kpi-cyan-bg: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
    --kpi-cyan-border: #a5f3fc;
    --kpi-cyan-text: #0891b2;

    --kpi-orange-bg: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    --kpi-orange-border: #fed7aa;
    --kpi-orange-text: #ea580c;

    --kpi-green-bg: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    --kpi-green-border: #bbf7d0;
    --kpi-green-text: #16a34a;

    --kpi-yellow-bg: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    --kpi-yellow-border: #fde68a;
    --kpi-yellow-text: #b45309;

    --kpi-blue-bg: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    --kpi-blue-border: #bfdbfe;
    --kpi-blue-text: #1d4ed8;
}

/* --- SIDEBAR GROUPS / ACCORDION --- */
.nav-group {
    margin-bottom: 6px;
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition);
}

.nav-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
    text-align: left;
    border-radius: 12px;
}

.nav-group-header:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-group-header i.fa-chevron-down {
    font-size: 0.65rem;
    transition: transform 0.3s var(--ease);
    opacity: 0.5;
}

.nav-group.active .nav-group-header i.fa-chevron-down {
    transform: rotate(180deg);
    opacity: 1;
}

.nav-group.active .nav-group-header {
    background: transparent;
    color: var(--text-primary);
}

.nav-group.active .nav-group-header i:first-child {
    color: var(--accent);
}

.nav-group-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s var(--ease), opacity 0.3s var(--ease);
    opacity: 0;
    overflow: hidden;
    background: var(--bg-nav-content);
    border-radius: 0 0 12px 12px;
}

.nav-group.active .nav-group-content {
    grid-template-rows: 1fr;
    opacity: 1;
}

.nav-group-content-inner {
    min-height: 0;
    padding: 6px 8px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* --- Level 1 Items & Level 2 Nested Submenus --- */
.nav-item-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Submenu container (Level 2) */
.sub-nav-content {
    margin-left: 21px;
    padding-left: 14px;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 2px;
    margin-bottom: 4px;
}

.sub-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 6px;
    transition: var(--transition-fast);
    cursor: pointer;
}

.sub-nav-item i {
    font-size: 0.75rem;
    opacity: 0.5;
    width: 14px;
    text-align: center;
}

.sub-nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.sub-nav-item.active {
    color: var(--accent) !important;
    font-weight: 700;
}

.sub-nav-item.active i {
    opacity: 1;
}

/* --- KANBAN / CRM --- */
.crm-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    align-items: start;
    min-height: calc(100vh - 300px);
}

.kanban-column {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 16px;
    min-height: 500px;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.kanban-column-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kanban-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 400px;
}

.lead-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    cursor: grab;
    transition: all 0.2s ease;
}

.lead-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.lead-card:active {
    cursor: grabbing;
}

.lead-card-header {
    margin-bottom: 10px;
}

.lead-card-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 2px;
}

.lead-card-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.lead-card-body {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.lead-card-actions {
    display: flex;
    gap: 8px;
}

.badge-wa {
    background: #25d36622;
    color: #25d366;
    border: 1px solid #25d36644;
}

.dragging {
    opacity: 0.5;
}

[data-status="captado"] h3 { color: var(--yellow); }
/* --- AI CHAT FLOATING --- */
#ai-chat-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(var(--accent-rgb), 0.3);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#ai-chat-trigger:hover {
    transform: scale(1.1) rotate(10deg);
}

#ai-chat-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 360px;
    height: 500px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    z-index: 9998;
    box-shadow: 0 12px 48px rgba(0,0,0,0.4);
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#ai-chat-container.active,
#ai-chat-container.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#ai-chat-trigger.active,
#ai-chat-trigger.open {
    background: var(--bg-surface);
    color: var(--accent);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.4);
}

.ai-chat-header {
    padding: 16px 20px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
}

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.ai-message.bot {
    align-self: flex-start;
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    border-bottom-left-radius: 2px;
}

.ai-message.user {
    align-self: flex-end;
    background: var(--accent);
    color: #000;
    border-bottom-right-radius: 2px;
}



.ai-chat-footer button {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: #000;
}

/* ─── Design System v2.0 Standardized Components ─────────────────────── */

/* Buttons */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-weight: 500;
    font-size: var(--font-size-body);
    border-radius: var(--radius-sm) !important;
    padding: var(--space-2) var(--space-4);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
    gap: 8px;
}

.btn-primary, button:not(.btn-secondary):not(.btn-danger):not([background]):not(#ai-chat-close):not(.btn-outline):not(.btn-icon) {
    background: var(--accent) !important;
    color: #ffffff !important;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover, button:not(.btn-secondary):not(.btn-danger):not([background]):not(#ai-chat-close):not(.btn-outline):not(.btn-icon):hover {
    background: var(--accent-hover) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: transparent !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
}

.btn-secondary:hover {
    background: var(--bg-card-hover) !important;
    border-color: var(--border-hover) !important;
}

.btn-danger {
    background: var(--red) !important;
    color: #ffffff !important;
}

.btn-danger:hover {
    background: #b91c1c !important;
    transform: translateY(-1px);
}

/* Cards */
.card, .dashboard-card, .leads-card, .crm-card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    padding: var(--space-4);
    box-shadow: var(--shadow-md);
    transition: var(--transition-normal);
}

.card:hover, .dashboard-card:hover, .leads-card:hover:not(.dragging) {
    border-color: var(--border-hover) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Inputs, Selects, Textareas */
input, select, textarea, .input {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    padding: var(--space-2) var(--space-3);
    color: var(--text-primary) !important;
    font-family: var(--font);
    outline: none;
    transition: var(--transition-fast);
}

input:focus, select:focus, textarea:focus, .input:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--accent-dim) !important;
}

/* Tables */
table, .table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-body);
}

th, td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    text-align: left;
    color: var(--text-primary);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-surface);
}

tr:hover td {
    background: var(--bg-card-hover);
}

/* Badges / Tags */
.badge, .tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: var(--font-size-small);
    font-weight: 500;
    border-radius: var(--radius-full);
    gap: 4px;
}

.badge-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(22, 163, 74, 0.2); }
.badge-warning { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(217, 119, 6, 0.2); }
.badge-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(220, 38, 38, 0.2); }
.badge-info { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(37, 99, 235, 0.2); }

/* Skeletons */
.skeleton-shimmer {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        var(--bg-surface) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: var(--radius-sm);
    height: 18px;
    width: 100%;
    display: inline-block;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* ─── CSS Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg-root);
    color: var(--text);
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

/* ─── MINI SIDEBAR (Integrations Layer) ──────────────────────────────── */
#mini-sidebar {
    width: var(--mini-sidebar-width);
    min-width: var(--mini-sidebar-width);
    background: var(--mini-sidebar-bg);
    border-right: 1px solid rgba(255,255,255,0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    height: 100vh;
    gap: 8px;
    z-index: 300;
    position: relative;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
}

#mini-sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, transparent, rgba(var(--accent-rgb), 0.08), transparent);
}

.mini-nav-item {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    border: 1px solid transparent;
    position: relative;
    font-size: 1.15rem;
}

/* C1: Workana Colorful Icon Fix (Removing white background via blending) */
.workana-icon-mini {
    width: 20px;
    height: 20px;
    object-fit: contain;
    filter: brightness(1.1) contrast(1.1);
    mix-blend-mode: screen; /* In dark mode, this makes white/light backgrounds disappear */
    transition: var(--transition);
}

.mini-nav-item:hover .workana-icon-mini {
    transform: scale(1.1);
    filter: brightness(1.3) contrast(1.2);
}

.mini-nav-item i {
    transition: var(--transition);
}

.mini-nav-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.mini-nav-item.active {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: rgba(var(--accent-rgb), 0.15);
    box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.06);
}

.mini-nav-item .tooltip {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 5px 12px;
    border-radius: var(--radius-xs);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-fast);
    border: 1px solid var(--border);
    z-index: 999;
}

.mini-nav-item:hover .tooltip {
    opacity: 1;
}

.mini-divider {
    width: 28px;
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.mini-spacer { flex: 1; }

/* ─── MODULE SWITCHER ───────────────────────────────────────────────── */
.module-switcher {
    display: flex;
    gap: 8px;
    padding: 0 10px;
    margin-bottom: 24px;
}

.module-opt {
    flex: 1;
    height: 48px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    color: var(--text-muted);
}

.module-opt:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.module-opt.active {
    background: var(--bg-card);
    border-color: rgba(var(--accent-rgb), 0.25);
    color: var(--accent);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.module-opt i { font-size: 1.15rem; }

.module-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: transparent;
    transition: var(--transition);
}

.module-opt.active .module-dot {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

/* ─── MAIN SIDEBAR (Core System) ─────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    height: 100vh;
    z-index: 200;
    box-shadow: 10px 0 40px rgba(0,0,0,0.3);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 10px;
    margin-bottom: 36px;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-dim), rgba(var(--accent-rgb), 0.02));
    border: 1px solid rgba(var(--accent-rgb), 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.sidebar-brand-text small {
    font-size: 0.55rem;
    opacity: 0.35;
    letter-spacing: 2px;
    margin-left: 5px;
    font-weight: 500;
}

.sidebar-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 10px;
    margin-top: 8px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.88rem;
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
}

.nav-item i {
    font-size: 0.95rem;
    opacity: 0.55;
    transition: var(--transition);
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.025);
    color: var(--text);
}

.nav-item:hover i { opacity: 0.85; }

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: rgba(var(--accent-rgb), 0.1);
}

.nav-item.active i { opacity: 1; color: var(--accent); }

.nav-spacer { flex: 1; }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 12px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

/* ─── Pulse Dot ──────────────────────────────────────────────────────── */
.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s infinite;
    flex-shrink: 0;
}

.pulse-dot.orange { background: var(--orange); animation-name: pulse-orange; }
.pulse-dot.red { background: var(--red); animation-name: pulse-red; }
.pulse-dot.purple { background: var(--purple); animation-name: pulse-purple; }

@keyframes pulse {
    0%   { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.55); }
    70%  { transform: scale(1);   box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

@keyframes pulse-orange {
    0%   { box-shadow: 0 0 0 0 rgba(255, 140, 0, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(255, 140, 0, 0); }
}

@keyframes pulse-red {
    0%   { box-shadow: 0 0 0 0 rgba(255, 56, 96, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(255, 56, 96, 0); }
}

@keyframes pulse-purple {
    0%   { box-shadow: 0 0 0 0 rgba(178, 102, 255, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(178, 102, 255, 0); }
}

#status-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

/* ─── Main Content ───────────────────────────────────────────────────── */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-body);
    position: relative;
}

#topbar {
    height: 64px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-topbar);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 100;
    flex-shrink: 0;
}

#page-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

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

.topbar-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--bg-card);
    padding: 5px 13px;
    border-radius: 50px;
    font-size: 0.68rem;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.topbar-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

#app {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ─── Page Transitions ───────────────────────────────────────────────── */
.page-container {
    animation: pageIn 0.35s var(--ease);
}

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

/* ─── KPI Cards ──────────────────────────────────────────────────────── */
.section-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--text-muted);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
}

.section-label i { font-size: 0.8rem; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    padding: 22px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

html[data-theme="light"] .kpi-card:not(.purple):not(.cyan):not(.orange):not(.green):not(.yellow):not(.blue) {
    background: linear-gradient(135deg, #f5f6ff 0%, #ffffff 100%) !important;
    border-color: rgba(99, 102, 241, 0.12) !important;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.25s;
}

.kpi-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-accent);
    box-shadow: 0 8px 28px rgba(var(--accent-rgb), 0.05);
}

.kpi-card:hover::before { opacity: 1; }

.kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
}

.kpi-icon.green  { background: var(--accent-dim); color: var(--accent); }
.kpi-icon.cyan   { background: var(--cyan-dim); color: var(--cyan); }
.kpi-icon.orange { background: var(--orange-dim); color: var(--orange); }
.kpi-icon.purple { background: var(--purple-dim); color: var(--purple); }
.kpi-icon.yellow { background: var(--yellow-dim); color: var(--yellow); }
.kpi-icon.red    { background: var(--red-dim); color: var(--red); }
.kpi-icon.blue   { background: var(--blue-dim); color: var(--blue); }

.kpi-value {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.kpi-value.accent { color: var(--accent); }
.kpi-value.cyan   { color: var(--cyan); }
.kpi-value.orange { color: var(--orange); }
.kpi-value.purple { color: var(--purple); }

.kpi-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Colorized KPI card variants */
.kpi-card.purple {
    background: var(--kpi-purple-bg) !important;
    border-color: var(--kpi-purple-border) !important;
}
.kpi-card.purple .kpi-value {
    color: var(--kpi-purple-text) !important;
}
.kpi-card.purple .kpi-icon {
    background: var(--kpi-purple-text) !important;
    color: #ffffff !important;
}

.kpi-card.cyan {
    background: var(--kpi-cyan-bg) !important;
    border-color: var(--kpi-cyan-border) !important;
}
.kpi-card.cyan .kpi-value {
    color: var(--kpi-cyan-text) !important;
}
.kpi-card.cyan .kpi-icon {
    background: var(--kpi-cyan-text) !important;
    color: #ffffff !important;
}

.kpi-card.orange {
    background: var(--kpi-orange-bg) !important;
    border-color: var(--kpi-orange-border) !important;
}
.kpi-card.orange .kpi-value {
    color: var(--kpi-orange-text) !important;
}
.kpi-card.orange .kpi-icon {
    background: var(--kpi-orange-text) !important;
    color: #ffffff !important;
}

.kpi-card.green {
    background: var(--kpi-green-bg) !important;
    border-color: var(--kpi-green-border) !important;
}
.kpi-card.green .kpi-value {
    color: var(--kpi-green-text) !important;
}
.kpi-card.green .kpi-icon {
    background: var(--kpi-green-text) !important;
    color: #ffffff !important;
}

.kpi-card.yellow {
    background: var(--kpi-yellow-bg) !important;
    border-color: var(--kpi-yellow-border) !important;
}
.kpi-card.yellow .kpi-value {
    color: var(--kpi-yellow-text) !important;
}
.kpi-card.yellow .kpi-icon {
    background: var(--kpi-yellow-text) !important;
    color: #ffffff !important;
}

.kpi-card.blue {
    background: var(--kpi-blue-bg) !important;
    border-color: var(--kpi-blue-border) !important;
}
.kpi-card.blue .kpi-value {
    color: var(--kpi-blue-text) !important;
}
.kpi-card.blue .kpi-icon {
    background: var(--kpi-blue-text) !important;
    color: #ffffff !important;
}

/* Welcome Banner Gradient Card */
.welcome-banner {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin-bottom: 28px;
    color: #ffffff !important;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

html[data-theme="dark"] .welcome-banner {
    background: linear-gradient(135deg, #1e1b4b 0%, #311042 50%, #4c0519 100%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.05);
}

.welcome-banner h2 {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: #ffffff !important;
}

.welcome-banner p {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.9rem;
    margin: 0;
}

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.card-header h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
}

.card-body { padding: 22px; }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    letter-spacing: 0.2px;
}

.btn-accent {
    background: var(--accent);
    color: #000;
    box-shadow: 0 4px 18px var(--accent-glow);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(var(--accent-rgb), 0.3);
    filter: brightness(1.08);
}

.btn-accent:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(255, 56, 96, 0.18);
}

.btn-danger:hover { background: rgba(255, 56, 96, 0.18); }

.btn-icon-danger {
    color: var(--red);
    background: rgba(255, 56, 96, 0.05);
    border: 1px solid rgba(255, 56, 96, 0.15);
}

.btn-icon-danger:hover {
    background: var(--red);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 56, 96, 0.25);
}

.btn-sm { padding: 5px 13px; font-size: 0.75rem; border-radius: var(--radius-xs); }

/* ─── Form Controls ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* Global Reset for Interactive Elements */
input, textarea, select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.88rem;
    transition: var(--transition);
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Alias for backward compatibility and semantic clarity */
.form-control, .input-field {
    display: block;
    width: 100%;
}

select.form-control, select.input-field, select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7a92' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    padding-right: 40px;
}

/* Global fix for dropdown options readability on dark themes */
select option {
    background-color: #12121c; /* Fallback dark */
    background-color: var(--bg-surface, #12121c);
    color: #ffffff;
    color: var(--text, #ffffff);
    padding: 10px;
}

textarea.form-control, textarea.input-field, textarea {
    min-height: 100px;
    resize: vertical;
}

::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}
/* ─── Tables ─────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    padding: 13px 20px;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.008);
}

td {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.85rem;
}

tr:hover td { background: rgba(255, 255, 255, 0.012); }

/* ─── Badges ─────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-green  { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(var(--accent-rgb), 0.18); }
.badge-cyan   { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(0,212,255,0.18); }
.badge-orange { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(255,140,0,0.18); }
.badge-red    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,56,96,0.18); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(178,102,255,0.18); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(255,204,0,0.18); }

/* ─── Score Bar ──────────────────────────────────────────────────────── */
.score-bar-wrap { display: flex; align-items: center; gap: 9px; }

.score-bar {
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.score-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.score-bar-fill.high   { background: var(--accent); }
.score-bar-fill.medium { background: var(--orange); }
.score-bar-fill.low    { background: var(--red); }

.score-number {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 28px;
    text-align: right;
}

/* ─── Terminal / Log ─────────────────────────────────────────────────── */
.terminal {
    background: #040407;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.terminal-header {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.015);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.terminal-body {
    padding: 14px 18px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 500px;
    min-height: 280px;
}

.log-line {
    display: flex;
    gap: 10px;
    padding: 2px 7px;
    border-left: 2px solid transparent;
    border-radius: 0 3px 3px 0;
}

.log-time { color: var(--text-muted); min-width: 65px; flex-shrink: 0; font-size: 0.7rem; }
.log-msg { color: #b0b0c8; word-break: break-word; }

.log-line.log-success { border-left-color: var(--accent); }
.log-line.log-success .log-msg { color: var(--accent); font-weight: 600; }
.log-line.log-warning { border-left-color: var(--orange); }
.log-line.log-warning .log-msg { color: var(--orange); }
.log-line.log-error { border-left-color: var(--red); background: rgba(255,56,96,0.03); }
.log-line.log-error .log-msg { color: var(--red); font-weight: 700; }
.log-line.log-alert { border-left-color: var(--cyan); background: rgba(0,212,255,0.03); }
.log-line.log-alert .log-msg { color: var(--cyan); font-weight: 700; }

/* ─── Toast ──────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 13px 18px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.85rem;
    font-weight: 500;
    animation: toastIn 0.35s var(--ease);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    max-width: 380px;
    backdrop-filter: blur(8px);
}

.toast.toast-success { border-left: 3px solid var(--accent); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--cyan); }
.toast.toast-warning { border-left: 3px solid var(--orange); }
.toast.hide { animation: toastOut 0.25s ease-in forwards; }

@keyframes toastIn { from { transform: translateX(80px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(80px); opacity: 0; } }

/* ─── Proposal Card ──────────────────────────────────────────────────── */
.proposal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 14px;
    transition: var(--transition);
}

.proposal-card:hover { border-color: var(--border-accent); box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.03); }
.proposal-card.pending { border-left: 3px solid var(--orange); }
.proposal-card.approved { border-left: 3px solid var(--accent); }
.proposal-card.sent { border-left: 3px solid var(--cyan); }
.proposal-card.skipped { border-left: 3px solid var(--text-muted); opacity: 0.6; }

.proposal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.proposal-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.proposal-body {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 180px;
    overflow-y: auto;
}

.proposal-actions {
    display: flex;
    gap: 9px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ─── Progress Ring ──────────────────────────────────────────────────── */
.progress-ring-wrap { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; }
.progress-ring { width: 120px; height: 120px; }
.progress-ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.progress-ring .bg { stroke: rgba(255, 255, 255, 0.05); }
.progress-ring .fg { stroke: var(--accent); transition: stroke-dashoffset 0.7s ease; }

/* ─── Grid Layouts ───────────────────────────────────────────────────── */
.col-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.col-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.col-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.col-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }

.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

/* ─── Alert Banner ───────────────────────────────────────────────────── */
.alert-banner {
    background: linear-gradient(135deg, rgba(0,212,255,0.06), rgba(var(--accent-rgb),0.06));
    border: 1px solid rgba(var(--accent-rgb), 0.12);
    border-radius: var(--radius);
    padding: 14px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
    animation: alertPulse 3s infinite;
}

@keyframes alertPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.08); }
    50%      { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.04); }
}

.alert-banner .alert-icon { font-size: 1.4rem; flex-shrink: 0; }
.alert-banner .alert-text { font-size: 0.85rem; font-weight: 500; }
.alert-banner .alert-text strong { color: var(--accent); }

/* ─── Empty State ────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 14px; opacity: 0.25; }
.empty-state h4 { font-family: var(--font-display); font-size: 1.05rem; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 0.82rem; }

/* ─── Stat Boxes (Runner) ────────────────────────────────────────────── */
.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-box:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.2); }

.stat-label { font-size: 0.62rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; }
.stat-val { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1; }

/* ─── Spinner ────────────────────────────────────────────────────────── */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.06);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ─── Chart Container ────────────────────────────────────────────────── */
.chart-container { position: relative; height: 270px; }

/* ─── Tags & Pills ───────────────────────────────────────────────────── */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.footer-pills { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

.pill {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ─── Switches & Toggles ─────────────────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    transition: .35s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .35s;
}

input:checked + .slider { background-color: var(--accent-dim); border-color: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); background-color: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* ─── Scheduling Slots ───────────────────────────────────────────────── */
.sched-slot-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
    transition: var(--transition);
}

.sched-slot-card:hover { border-color: var(--border-hover); background: rgba(255, 255, 255, 0.03); }

.slot-icon {
    width: 38px; height: 38px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; flex-shrink: 0;
}

.slot-info { flex: 1; }
.slot-name { font-size: 0.82rem; font-weight: 700; margin-bottom: 2px; }
.slot-time { font-size: 0.7rem; color: var(--text-secondary); }

/* ─── Decorative Elements ─── */
.bg-blur {
    position: absolute;
    width: 600px;
    height: 600px;
    filter: blur(150px);
    z-index: 0;
    opacity: 0.08;
    pointer-events: none;
}

.bg-blur.purple {
    top: -100px;
    right: -100px;
    background: var(--accent);
}

.bg-blur.cyan {
    bottom: -150px;
    left: 20%;
    background: var(--secondary);
}

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

@media (max-width: 768px) {
    #mini-sidebar { display: none; }
    #sidebar { width: 200px; min-width: 200px; }
    .kpi-grid { grid-template-columns: 1fr; }
}

/* ─── Modals ─────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

/* ─── Modals ─────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    padding: 20px;
    animation: fadeIn 0.3s var(--ease);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    position: relative;
    padding: 32px;
    box-shadow: 0 40px 100px rgba(0,0,0,0.6);
    animation: modalIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text);
}

/* ─── AI Chat Assistant ──────────────────────────────────────────────── */
#ai-chat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.3);
    z-index: 4000;
    transition: var(--transition);
}

#ai-chat-trigger:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 12px 32px rgba(var(--accent-rgb), 0.5);
}

#ai-chat-container {
    position: fixed;
    bottom: 94px;
    right: 24px;
    width: 380px;
    height: 550px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: none; /* Controlled by .open class */
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    z-index: 4000;
    overflow: hidden;
    animation: chatIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.ai-chat-header {
    padding: 16px 20px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
}

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.5;
    position: relative;
}

.ai-message.bot {
    align-self: flex-start;
    background: rgba(255,255,255,0.05);
    color: var(--text);
    border-bottom-left-radius: 2px;
}

.ai-message.user {
    align-self: flex-end;
    background: var(--accent);
    color: #000;
    border-bottom-right-radius: 2px;
    font-weight: 500;
}

.ai-chat-footer textarea {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--font);
    resize: none;
    min-height: 42px;
    max-height: 150px;
    line-height: 1.5;
    transition: var(--transition);
}

.ai-chat-footer textarea:focus {
    border-color: var(--accent);
    outline: none;
}

.ai-chat-footer {
    padding: 16px;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
}

.ai-chat-footer button {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    color: #000;
    cursor: pointer;
    transition: var(--transition);
}

.ai-chat-footer button:hover { background: #fff; }

/* ─── Toast Notifications ────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 22px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 99999;
    animation: toastIn 0.35s var(--ease);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.toast.hide {
    animation: toastOut 0.3s var(--ease) forwards;
}

.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--accent); }
.toast-warning { border-left: 3px solid var(--orange); }

.toast-success i { color: var(--green); }
.toast-error i   { color: var(--red); }
.toast-info i    { color: var(--accent); }
.toast-warning i { color: var(--orange); }

@keyframes toastIn {
    from { transform: translateX(100px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100px); opacity: 0; }
}

/* ─── Client Card Interactions ───────────────────────────────────────── */
.client-card {
    transition: var(--transition);
}

.client-card:hover {
    border-color: rgba(var(--accent-rgb), 0.25) !important;
    box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.06);
    transform: translateY(-2px);
}

/* ─── Kanban Drag States ─────────────────────────────────────────────── */
.lead-card {
    cursor: grab;
    transition: var(--transition);
}

.lead-card:active { cursor: grabbing; }

.lead-card.dragging {
    opacity: 0.2;
    transform: scale(0.9) rotate(1deg);
    cursor: grabbing;
}

.kanban-column.drag-over {
    background: rgba(var(--accent-rgb), 0.08) !important;
    border: 1px dashed var(--accent) !important;
    transform: scale(1.01);
}

.kanban-list {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    min-height: 400px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kanban-list {
    transition: background 0.2s ease;
    border-radius: var(--radius-sm);
    padding: 4px;
}

.kanban-list:has(.lead-card.dragging) {
    background: rgba(var(--accent-rgb), 0.03);
}

@keyframes pulse-accent {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(139, 92, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* ─── Footer Pills ───────────────────────────────────────────────────── */
.footer-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.pill {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.pill i {
    font-size: 0.8rem;
    color: var(--accent);
}

.pill:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-dim);
    color: var(--text);
    transform: translateY(-1px);
}

/* ─── WhatsApp Hub Panel ────────────────────────────────────────── */
#whatsapp-chat-panel {
    position: fixed;
    top: 0;
    left: 64px; /* Width of mini-sidebar */
    bottom: 0;
    width: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    z-index: 99;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 20px 0 60px rgba(0,0,0,0.5);
}

#whatsapp-chat-panel.open {
    width: 800px;
}

.wa-panel-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.wa-panel-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: var(--bg-main);
}

.wa-chats-sidebar {
    width: 280px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-surface);
}

.wa-chat-item {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.wa-chat-item:hover { background: rgba(255, 255, 255, 0.02); }
.wa-chat-item.active { background: rgba(var(--accent-rgb), 0.1); border-left: 3px solid var(--accent); }

.wa-chat-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--bg-input);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 1.2rem;
}

.wa-chat-info { flex: 1; overflow: hidden; }
.wa-chat-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-chat-last-msg { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wa-chat-meta { text-align: right; }
.wa-chat-time { font-size: 0.65rem; color: var(--text-muted); }

.wa-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: url('https://w0.peakpx.com/wallpaper/818/148/HD-wallpaper-whatsapp-dark-stetho-cool-dark-grey-lock-screen-minimal-pattern-scary-skeleton-vector-whatsapp-chat.jpg');
    background-size: cover;
    background-blend-mode: overlay;
    background-color: rgba(10, 10, 18, 0.95);
}

.wa-chat-header {
    height: 60px; padding: 0 20px;
    border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; justify-content: center;
    background: rgba(10, 10, 18, 0.8);
    backdrop-filter: blur(10px);
}

.wa-chat-messages {
    flex: 1; padding: 20px;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px;
}

.wa-msg-bubble {
    max-width: 80%; padding: 10px 14px; border-radius: 12px;
    font-size: 0.85rem; line-height: 1.4; position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.wa-msg-bubble.incoming {
    background: var(--bg-surface); align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.wa-msg-bubble.outgoing {
    background: #056162; color: #fff; align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.wa-msg-time {
    font-size: 0.6rem; opacity: 0.6; margin-top: 4px; text-align: right;
}

.wa-chat-input-area {
    padding: 16px; background: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex; gap: 12px; align-items: flex-end;
}

#wa-chat-input {
    flex: 1; min-height: 44px; max-height: 120px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 22px; padding: 12px 20px; color: var(--text);
    font-size: 0.85rem; resize: none; overflow-y: auto;
}

#wa-send-btn {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent); border: none; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition);
}

#wa-send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }

/* ═══════════════════════════════════════════════════════════════════════ */
/*  WHATSAPP HUB — Module Styles                                         */
/* ═══════════════════════════════════════════════════════════════════════ */

/* ─── 3-Column Inbox Layout ───────────────────────────────────────────── */
.wa-inbox {
    display: grid;
    grid-template-columns: 220px 320px 1fr;
    gap: 0;
    height: calc(100vh - 140px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}

.wa-col { display: flex; flex-direction: column; overflow: hidden; }
.wa-col + .wa-col { border-left: 1px solid var(--border); }

.wa-col-header {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.wa-col-header i { margin-right: 8px; opacity: 0.7; }

.wa-col-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ─── Search Bar ──────────────────────────────────────────────────────── */
.wa-search-bar {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.wa-search-bar i { color: var(--text-muted); font-size: 0.8rem; }

.wa-search-bar input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.82rem;
    padding: 6px 0;
    outline: none;
}

/* ─── Instance List ───────────────────────────────────────────────────── */
.wa-instance-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.wa-instance-item:hover { background: rgba(255,255,255,0.03); }
.wa-instance-item.active { background: var(--accent-dim); border-left: 3px solid var(--accent); }

.wa-instance-name { font-weight: 700; font-size: 0.85rem; color: var(--text); }
.wa-instance-status { font-size: 0.68rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }

.wa-instance-actions { display: flex; gap: 4px; }

.pulse-dot-sm {
    width: 6px; height: 6px; border-radius: 50%; display: inline-block;
}
.pulse-dot-sm.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.pulse-dot-sm.orange { background: var(--orange); }
.pulse-dot-sm.red { background: var(--red); }

.btn-icon {
    width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
    background: none; color: var(--text-muted); cursor: pointer; display: flex;
    align-items: center; justify-content: center; font-size: 0.7rem;
    transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ─── Chat List ───────────────────────────────────────────────────────── */
.wa-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.wa-chat-item:hover { background: rgba(255,255,255,0.03); }
.wa-chat-item.active { background: var(--accent-dim); }

.wa-chat-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,0.06); display: flex;
    align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 0.9rem; flex-shrink: 0;
}

.wa-chat-info { flex: 1; min-width: 0; }
.wa-chat-name { font-weight: 700; font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-chat-preview { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.wa-chat-meta { text-align: right; flex-shrink: 0; }
.wa-chat-time { font-size: 0.62rem; color: var(--text-muted); }

.wa-unread-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; border-radius: 50%;
    background: #25d366; color: #000; font-size: 0.6rem; font-weight: 800;
    margin-top: 4px; padding: 0 4px;
}

/* ─── Messages Area ───────────────────────────────────────────────────── */
.wa-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0,0,0,0.15);
}

.wa-msg { display: flex; }
.wa-msg-sent { justify-content: flex-end; }
.wa-msg-received { justify-content: flex-start; }

.wa-msg-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.wa-msg-sent .wa-msg-bubble {
    background: rgba(var(--accent-rgb), 0.2);
    color: var(--text);
    border-bottom-right-radius: 4px;
}

.wa-msg-received .wa-msg-bubble {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border-bottom-left-radius: 4px;
}

.wa-msg-time {
    display: block;
    font-size: 0.58rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
}

.wa-media-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,0.06); padding: 2px 8px;
    border-radius: 4px; font-size: 0.7rem; color: var(--text-muted);
    margin-right: 6px;
}

/* ─── Chat Input ──────────────────────────────────────────────────────── */
.wa-chat-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.wa-chat-input-area textarea {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    border-radius: 20px;
    padding: 10px 18px;
    resize: none;
    font-size: 0.85rem;
}

/* ─── Empty / Loading States ──────────────────────────────────────────── */
.wa-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-muted);
    gap: 12px;
    padding: 40px;
    text-align: center;
}

.wa-empty-state i { font-size: 2.5rem; opacity: 0.3; }
.wa-empty-state p { font-size: 0.85rem; }

.wa-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 100px;
}

/* ─── Workflow Cards V2 — Modern Redesign ─────────────────────────────── */
.wa-wf-card-v2 {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.wa-wf-card-v2:hover {
    transform: translateY(-4px);
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(139, 92, 246, 0.06);
}

.wa-wf-card-v2__glow {
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #f97316, var(--accent));
    background-size: 200% 100%;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.wa-wf-card-v2.is-active .wa-wf-card-v2__glow {
    opacity: 1;
    animation: wf-glow-slide 3s ease infinite;
}

.wa-wf-card-v2.is-paused .wa-wf-card-v2__glow {
    background: linear-gradient(90deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    opacity: 0.3;
}

@keyframes wf-glow-slide {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.wa-wf-card-v2__body {
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Header */
.wa-wf-card-v2__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.wa-wf-card-v2__info {
    flex: 1;
    min-width: 0;
}

.wa-wf-card-v2__name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.wa-wf-card-v2__name {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.wa-wf-card-v2__instance {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* ─── Pulsing dots indicator for active automations ─────────────────── */
.wa-wf-card-v2__live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 20px;
}

.wa-wf-pulse-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
    animation: wf-pulse-bounce 1.4s ease-in-out infinite;
}

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

@keyframes wf-pulse-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Trigger Badge */
.wa-wf-card-v2__trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    width: fit-content;
}

.wa-wf-card-v2__trigger i {
    font-size: 0.75rem;
    opacity: 0.8;
}

.wa-wf-card-v2.is-paused .wa-wf-card-v2__trigger {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

/* Actions */
.wa-wf-card-v2__actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.wa-wf-card-v2__btn-metrics {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 10px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.wa-wf-card-v2__btn-metrics:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(139, 92, 246, 0.2));
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.15);
}

.wa-wf-card-v2__btn-settings {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.wa-wf-card-v2__btn-settings:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text);
    transform: rotate(45deg);
}

/* Paused state muting */
.wa-wf-card-v2.is-paused {
    opacity: 0.7;
}

.wa-wf-card-v2.is-paused:hover {
    opacity: 1;
}

.wa-wf-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ─── Step Row (Workflow Builder) ─────────────────────────────────────── */
.wa-step-row select,
.wa-step-row input,
.wa-step-row textarea {
    font-size: 0.82rem;
}

/* Media Messages */
.wa-msg-image { margin-bottom: 8px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); transition: transform 0.2s; }
.wa-msg-image:hover { transform: scale(1.02); }
.wa-msg-image img { width: 100%; display: block; max-height: 300px; object-fit: cover; }
.wa-msg-caption { font-size: 0.9rem; line-height: 1.4; color: var(--text); }
.wa-msg-audio { width: 100%; max-width: 250px; height: 32px; filter: invert(0.8) hue-rotate(180deg); margin-top: 4px; }

.wa-attachment-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--accent-dim);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--accent);
    margin-right: 10px;
    border: 1px solid var(--accent);
}
.wa-attachment-preview button { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0 4px; }
.wa-attachment-preview button:hover { color: var(--red); }

/* Workflow Grid */
.wa-workflows-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}
.wa-wf-stat {
    background: rgba(255,255,255,0.05);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}



/* WhatsApp Avatar Fix */
.wa-chat-avatar { overflow: hidden; border: 1px solid rgba(255,255,255,0.1); }
.wa-chat-avatar-img { width: 100%; height: 100%; object-fit: cover; }

/* WhatsApp Variable Chips */
.wa-var-chip {
    padding: 4px 12px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.wa-var-chip:hover {
    background: var(--accent);
    color: #000 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.wa-var-chip:active {
    transform: translateY(0);
}

/* ─── Global overrides for inline background transparencies ─── */
html[data-theme="light"] div[style*="background:rgba(0,0,0,"], 
html[data-theme="light"] div[style*="background: rgba(0,0,0,"],
html[data-theme="light"] div[style*="background:rgba(0, 0, 0,"], 
html[data-theme="light"] div[style*="background: rgba(0, 0, 0,"],
html[data-theme="light"] div[style*="background:rgba(255,255,255,0.0"], 
html[data-theme="light"] div[style*="background: rgba(255,255,255,0.0"],
html[data-theme="light"] div[style*="background:rgba(255, 255, 255, 0.0"], 
html[data-theme="light"] div[style*="background: rgba(255, 255, 255, 0.0"],
html[data-theme="light"] div[style*="background:rgba(255,255,255,0.1"], 
html[data-theme="light"] div[style*="background: rgba(255,255,255,0.1"],
html[data-theme="light"] div[style*="background:rgba(255, 255, 255, 0.1"], 
html[data-theme="light"] div[style*="background: rgba(255, 255, 255, 0.1"] {
    background: var(--bg-elevated) !important;
    border-color: var(--border) !important;
}

html[data-theme="light"] input[style*="background:rgba(0,0,0,"],
html[data-theme="light"] input[style*="background: rgba(0,0,0,"],
html[data-theme="light"] input[style*="background:rgba(0, 0, 0,"],
html[data-theme="light"] input[style*="background: rgba(0, 0, 0,"],
html[data-theme="light"] select[style*="background:rgba(0,0,0,"],
html[data-theme="light"] select[style*="background: rgba(0,0,0,"],
html[data-theme="light"] select[style*="background:rgba(0, 0, 0,"],
html[data-theme="light"] select[style*="background: rgba(0, 0, 0,"] {
    background: var(--bg-input) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

html[data-theme="light"] .sys-info-card,
html[data-theme="light"] .engine-tag,
html[data-theme="light"] .api-card,
html[data-theme="light"] .stack-item,
html[data-theme="light"] .section-card,
html[data-theme="light"] .project-card,
html[data-theme="light"] #gemini-kpis > div,
html[data-theme="light"] #groq-kpis > div {
    background: var(--bg-surface) !important;
    border-color: var(--border) !important;
}

html[data-theme="light"] .manifesto-card {
    background: linear-gradient(135deg, var(--accent-dim) 0%, var(--bg-surface) 100%) !important;
    border-color: var(--accent) !important;
    box-shadow: var(--shadow-sm) !important;
}

html[data-theme="light"] .modal-overlay,
html[data-theme="light"] #modal-overlay {
    background: rgba(15, 23, 42, 0.4) !important; /* Premium semi-transparent backdrop blur overlay */
    backdrop-filter: blur(8px) !important;
}

html[data-theme="light"] .modal-content {
    background: var(--bg-surface) !important;
    border-color: var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
}

html[data-theme="light"] .modal-header h2 {
    color: var(--text-primary) !important;
}

html[data-theme="light"] table, 
html[data-theme="light"] .table,
html[data-theme="light"] tbody,
html[data-theme="light"] tr,
html[data-theme="light"] td,
html[data-theme="light"] th {
    border-color: var(--border) !important;
}

/* ─── COMPREHENSIVE MOBILE RESPONSIVENESS OVERLAYS & LAYOUTS ─── */
@media (max-width: 768px) {
    /* 1. Sidebar Toggles & Drawer Layout */
    #sidebar-toggle {
        display: block !important;
    }
    
    #mini-sidebar {
        display: none !important;
    }
    
    #sidebar {
        position: fixed;
        top: 0;
        left: -260px; /* Hidden offscreen by default */
        bottom: 0;
        width: 260px;
        min-width: 260px;
        z-index: 5000;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex !important;
    }
    
    #sidebar.active {
        left: 0; /* Slide in drawer */
    }
    
    #topbar {
        padding: 0 16px !important;
    }
    
    /* 2. Grid & Content Layout Restructuring */
    #app {
        padding: 16px !important;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .col-2, .col-2-1, .grid-3 {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    /* 3. CRM Kanban Stacking */
    .kanban-board {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .kanban-column {
        min-height: auto !important;
    }
    
    /* 4. Table Scroll Wrapper */
    table, .table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* 5. Modals & Forms scaling */
    .modal-content {
        padding: 20px !important;
        width: 95% !important;
        max-height: 85vh !important;
    }
    
    /* 6. WhatsApp Hub Adaptive Mobile Panel */
    #whatsapp-chat-panel.open {
        width: 100% !important;
        left: 0 !important;
        z-index: 4001 !important; /* Above triggers, below sidebar drawer */
    }
    
    #wa-back-btn {
        display: block !important; /* Visible on mobile active chat */
    }
    
    /* Mobile Chat Switching (chats sidebar vs conversation main) */
    #whatsapp-chat-panel.open .wa-chats-sidebar {
        width: 100% !important;
        display: flex !important;
    }
    
    #whatsapp-chat-panel.open .wa-chat-main {
        display: none !important;
    }
    
    /* When active chat is opened, hide list and show conversation */
    #whatsapp-chat-panel.open.has-active-chat .wa-chats-sidebar {
        display: none !important;
    }
    
    #whatsapp-chat-panel.open.has-active-chat .wa-chat-main {
        display: flex !important;
        flex: 1 !important;
        width: 100% !important;
    }
    
    /* 7. AI Chat floating window adjustments */
    #ai-chat-container {
        width: calc(100% - 32px) !important;
        right: 16px !important;
        left: 16px !important;
        bottom: 90px !important;
        height: 70vh !important;
    }
}

