@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&display=swap');

/* Page background - controlled by inline styles now */
html,
body {
    background-color: #0f172a;
    /* Fix for bottom white line */
    color: #e6eef8;
    font-family: 'Plus Jakarta Sans', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    transition: background 0.5s ease;
    /* Smooth theme switch */
}

/* Prevent background scrolling when chat panel is open */
body.chat-open {
    overflow: hidden;
}

body.chat-open #main-scroll-container {
    overflow: hidden;
}

/* Mesh Gradient Background for Light Mode */
.light-theme {
    background:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    /* Default dark mesh (optional overrides for dark theme if needed) */
}

/* Override with Vibrant Premium Light Mesh */
/* Professional Corporate Light Theme Background */
div.light-theme {
    background-color: #f8fafc;
    /* Slate 50 - Ultra Clean */
    background-image: none;
    color: #334155;
    /* Slate 700 for ease of reading */
}


/* Glass card */
.glass {
    background: rgba(16, 20, 30, 0.6);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    margin-bottom: 24px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.12);
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: #ffffff;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.kpis {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.kpi {
    flex: 1 1 200px;
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
}

.kpi:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-6px) scale(1.05);
    box-shadow:
        0 20px 40px -5px rgba(109, 93, 252, 0.6),
        0 0 15px rgba(139, 92, 246, 0.4),
        inset 0 0 20px rgba(255, 255, 255, 0.05);
    border-color: rgba(167, 139, 250, 0.9);
    z-index: 10;
}

.controls-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.small-muted {
    color: #94a3b8;
    font-size: 14px;
}

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

.chart-slot {
    margin-bottom: 16px;
    min-height: 400px;
    /* Prevent collapse during re-render */
    transition: opacity 0.15s ease-in-out;
    /* Smooth transition */
}

/* Prevent chart container from collapsing */
.chart-slot .js-plotly-plot,
.chart-slot .plot-container {
    min-height: 350px;
}

/* App Header & Logo */
.app-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: rgba(18, 12, 36, 0.6);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: none !important;
    transition: all 0.3s ease;
    margin-left: 280px;
    /* Aligns with fixed sidebar */
    width: auto;
    position: relative;
    z-index: 2200;
    /* Above chat panel (2100) */
}

.app-logo {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

/* Light Mode KPI separation and color */
/* Light Mode KPI separation and color */
.light-theme .kpi {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    color: #475569;
    /* Slate 600 */
    border-radius: 8px;
    flex: 1 1 200px;
    margin: 4px;
    transition: all 0.2s ease;
}

.light-theme .kpi:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: #cbd5e1;
}

/* Add crisp top accents to Light Mode KPIs */
.light-theme .kpi:nth-child(1) {
    border-top: 4px solid #3b82f6;
    border-bottom: none;
}

.light-theme .kpi:nth-child(2) {
    border-top: 4px solid #8b5cf6;
    border-bottom: none;
}

.light-theme .kpi:nth-child(3) {
    border-top: 4px solid #ec4899;
    border-bottom: none;
}

.light-theme .kpi:nth-child(4) {
    border-top: 4px solid #10b981;
    border-bottom: none;
}

/* Override KPI Value Text for clarity */
.light-theme .kpi h4 {
    background: none !important;
    -webkit-text-fill-color: #0f172a !important;
    /* Solid Slate 900 */
    color: #0f172a !important;
    font-weight: 700;
}

.kpi h4 {
    margin: 0 0 8px 0;
    font-size: 28px;
    background: linear-gradient(135deg, #4ade80 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.light-theme .app-header {
    background: #ffffff !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

.light-theme .app-logo {
    background: none !important;
    -webkit-background-clip: border-box !important;
    background-clip: border-box !important;
    -webkit-text-fill-color: #0f172a !important;
    /* Slate 900 - Professional Dark */
    color: #0f172a !important;
}

.footer {
    text-align: center;
    margin-top: 40px;
    color: #64748b;
    font-size: 14px;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-primary:hover {
    filter: brightness(110%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.light-theme .btn-primary {
    background: #3b82f6 !important;
    /* Solid Brand Blue */
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%) !important;
    /* Subtle Depth */
    color: #ffffff !important;
    border: 1px solid #1d4ed8 !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
    font-weight: 600;
}

.light-theme .btn-primary:hover {
    background: #2563eb !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(-1px);
    filter: none !important;
}

.remove-btn {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-radius: 6px;
    padding: 6px 12px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    cursor: pointer;
    transition: all 0.2s;
}

/* New Button System */
.custom-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    margin-bottom: 12px;
}

/* Secondary Button (Data Studio) */
.btn-secondary {
    background: transparent;
    border: 1px solid rgba(141, 132, 255, 0.4);
    color: #8f84ff;
}

.btn-secondary:hover {
    background: rgba(141, 132, 255, 0.1);
    transform: translateY(-2px);
}

.light-theme .btn-secondary {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.light-theme .btn-secondary:hover {
    background: #f8fafc !important;
    border-color: #94a3b8 !important;
    color: #1e293b !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
    transform: translateY(-1px);
}

/* Danger Button (Reset All) */
.btn-danger {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #f472b6;
}

.btn-danger:hover {
    background: rgba(244, 63, 94, 0.2);
    transform: translateY(-2px);
}

.light-theme .btn-danger {
    background: #ffffff !important;
    border: 1px solid #fecaca !important;
    color: #dc2626 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.light-theme .btn-danger:hover {
    min-height: auto;
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

.remove-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ffffff;
}

.light-theme .remove-btn {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border: 1px solid #fecaca !important;
}

.light-theme .remove-btn:hover {
    background: #fecaca !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.1);
}

/* Chat Styles */
.chat-container {
    flex: 1;
    min-height: 0;
    /* Crucial for nested flex scrolling */
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Chat Bottom Anchor Spacer */
.chat-container::before {
    content: '';
    flex: 1;
    min-height: 0;
    /* Allows shrinking when content grows */
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.5;
    font-size: 15px;
}

/* STAND OUT: Vibrant User Bubble (Deep Violet) */
.chat-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    /* Violet -> Indigo */
    color: white;
    border-bottom-right-radius: 2px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Light Theme User Bubble (Blue instead of Pink/Red) */
.light-theme .chat-user {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    /* Blue -> Indigo */
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* STAND OUT: Premium AI Bubble (Dark Mode - Cyan/Teal) */
.chat-ai {
    align-self: flex-start;
    /* Cyan-Teal Glass */
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(16, 185, 129, 0.2));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #f0fdf4;
    /* Mint White */
    border-bottom-left-radius: 2px;

    /* Crisp Typography */
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    letter-spacing: 0.3px;
    font-weight: 400;

    /* Distinct Glow */
    box-shadow: 0 5px 20px rgba(16, 185, 129, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(45, 212, 191, 0.3);
    /* Teal Border */
}

/* Light Theme AI Bubble (Clean White) */
.light-theme .chat-ai {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    background-image: none !important;
    /* Remove gradient */
}

.light-theme .chat-ai code {
    background: #f1f5f9 !important;
    color: #ef4444 !important;
    /* Red for inline code like GitHub */
    border: 1px solid #e2e8f0 !important;
}

/* Beautiful Code Blocks */
.chat-ai pre {
    background: rgba(15, 23, 42, 0.7) !important;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(45, 212, 191, 0.2);
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chat-ai code {
    background: rgba(16, 185, 129, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
    color: #ccfbf1;
    border: 1px solid rgba(45, 212, 191, 0.2);
}


/* Chat Send Button Styles */
.chat-send-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%) !important;
    transform: translateY(-50%) scale(1.1) !important;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.6) !important;
}

.chat-send-btn:active {
    transform: translateY(-50%) scale(0.95) !important;
}


/* Custom Dropdown Overrides for Clarity (Theme-aware) */
.light-theme .Select-control {
    background-color: #f1f5f9 !important;
    /* Light background */
    border: 1px solid #cbd5e1 !important;
    color: #000000 !important;
    /* Black font */
}

.light-theme .Select-value-label {
    color: #000000 !important;
}

.light-theme .Select-input>input {
    color: #000000 !important;
}

.light-theme .Select-placeholder {
    color: #475569 !important;
}

.light-theme .Select-menu-outer {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #cbd5e1 !important;
}

.light-theme .Select-option {
    background-color: #ffffff !important;
    color: #000000 !important;
}

.light-theme .Select-option.is-focused,
.light-theme .Select-option:hover {
    background-color: #e2e8f0 !important;
    color: #000000 !important;
    cursor: pointer;
}

/* Dark Mode Dropdown Styles - Cross-browser compatible (Safari 16.2+, Chrome, Firefox, Edge) */
.dark-theme .Select-control {
    background-color: #1f2937 !important;
    border: 1px solid #334155 !important;
    color: #e2e8f0 !important;
}

.dark-theme .Select-value-label {
    color: #e2e8f0 !important;
}

.dark-theme .Select-value {
    color: #e2e8f0 !important;
}

.dark-theme .Select-input>input {
    color: #e2e8f0 !important;
}

.dark-theme .Select-placeholder {
    color: #94a3b8 !important;
}

.dark-theme .Select-menu-outer {
    background-color: #1f2937 !important;
    color: #e2e8f0 !important;
    border: 1px solid #334155 !important;
}

.dark-theme .Select-option {
    background-color: #1f2937 !important;
    color: #e2e8f0 !important;
}

.dark-theme .Select-option.is-focused,
.dark-theme .Select-option:hover {
    background-color: #334155 !important;
    color: #f8fafc !important;
    cursor: pointer;
}

/* Additional dark mode dropdown fixes for Safari compatibility */
.dark-theme .Select--single>.Select-control .Select-value {
    color: #e2e8f0 !important;
}

.dark-theme .Select-input input {
    color: #e2e8f0 !important;
}

/* Ensure dropdown arrow is visible in dark mode */
.dark-theme .Select-arrow {
    border-top-color: #94a3b8 !important;
}

/* Pulse animation for floating AI button */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(109, 93, 252, 0.7), 0 8px 24px rgba(109, 93, 252, 0.4);
    }

    50% {
        box-shadow: 0 0 0 12px rgba(109, 93, 252, 0), 0 8px 24px rgba(109, 93, 252, 0.4);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(109, 93, 252, 0), 0 8px 24px rgba(109, 93, 252, 0.4);
    }
}

/* Light Theme Overrides */
.light-theme {
    background: linear-gradient(135deg, #f0f9ff 0%, #dbeafe 100%) !important;
    color: #050505 !important;
}

/* Force dark text on almost all elements in light mode */
.light-theme div,
.light-theme span,
.light-theme p,
.light-theme label,
.light-theme h1,
.light-theme h2,
.light-theme h3,
.light-theme h4,
.light-theme h5,
.light-theme h6,
.light-theme a,
.light-theme li,
.light-theme td,
.light-theme th,
.light-theme button,
.light-theme input,
.light-theme textarea,
.light-theme select {
    color: #050505 !important;
}

.light-theme .glass {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.06) !important;
    border-radius: 12px;
}

.light-theme .glass:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
}

.light-theme .app-header {
    background: rgba(255, 255, 255, 0.85) !important;
    border-bottom: none !important;
}

.light-theme .app-header div {
    color: #1e293b !important;
}

.light-theme h1,
.light-theme h2,
.light-theme h3,
.light-theme h4,
.light-theme h5,
.light-theme h6,
.light-theme .small-muted {
    color: #000000 !important;
    /* Pure black for headers */
    font-weight: 700 !important;
}

.light-theme #file-meta {
    color: #1e293b !important;
    font-weight: 800 !important;
}

/* Specific component overrides for light theme */
.light-theme .sidebar-container {
    background: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
}

/* Fix for sidebar general text */
/* Fix for sidebar general text labels using class */
.light-theme .sidebar-text {
    color: #475569 !important;
    /* Slate 600 - Professional Label */
    font-weight: 600 !important;
}

/* Auto-swap icons for Light Theme */
.light-theme #folder-icon {
    content: url('/assets/folder_icon_light.png');
}

.light-theme #chart-icon {
    content: url('/assets/chart_icon_light.png');
}

/* Fix for Main Scroll Container overlapping with Fixed Sidebar on Desktop */
#main-scroll-container {
    margin-left: 280px;
    /* Default sidebar width */
    width: auto;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom Data Table Styling */
.custom-data-table {
    width: 100%;
    border-collapse: collapse;
    width: 100%;
    margin-top: 8px;
    font-size: 14px;
}

.custom-data-table th,
.custom-data-table td {
    padding: 14px 16px;
    text-align: left;
}

.custom-data-table th {
    font-weight: 600;
    color: #ffffff;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.custom-data-table td {
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.custom-data-table th:last-child,
.custom-data-table td:last-child {
    border-right: none;
}

.custom-data-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.custom-data-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

/* Light Theme overrides for table */
/* Light Theme overrides for table */
.light-theme .custom-data-table {
    background: #ffffff !important;
}

.light-theme .custom-data-table th {
    background: #ffffff !important;
    color: #0f172a !important;
    border-bottom: 2px solid #cbd5e1 !important;
    border-right: 1px solid #e2e8f0 !important;
    /* Added for grid consistency */
    font-weight: 700;
}

.light-theme .custom-data-table td {
    color: #334155 !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-right: 1px solid #e2e8f0 !important;
    /* Added for grid consistency */
}

.light-theme .custom-data-table th:last-child,
.light-theme .custom-data-table td:last-child {
    border-right: none !important;
}

.light-theme .custom-data-table tr:nth-child(even) {
    background: #f8fafc !important;
}

.light-theme .custom-data-table tr:hover {
    background: #f1f5f9 !important;
}

/* Empty State Card - Light Theme Fix */
.light-theme #empty-state-card {
    background: rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 10px 40px -10px rgba(148, 163, 184, 0.2) !important;
}

/* Upload area in light theme */
/* Upload area in light theme */
.light-theme #upload-data {
    border: 2px dashed #cbd5e1 !important;
    background: #f8fafc !important;
    /* Extremely light slate */
    transition: all 0.2s ease;
}

.light-theme #upload-data:hover {
    border-color: #3b82f6 !important;
    background: #eff6ff !important;
    /* Light Blue Tint */
}

.light-theme #upload-data div {
    color: #475569 !important;
}

/* App Footer */
.app-footer {
    margin-top: 64px;
    padding: 32px 0 16px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.app-footer h5 {
    color: #e2e8f0;
}

.light-theme .app-footer {
    border-top: 1px solid #cbd5e1 !important;
    color: #334155 !important;
}

.light-theme .app-footer h5 {
    color: #000000 !important;
    font-weight: 800 !important;
}

.light-theme .app-footer a,
.light-theme .app-footer div {
    color: #0f172a !important;
    font-weight: 600 !important;
}


/* =========================================
   Welcome Page Styles (Dashboard Themed)
   ========================================= */

/* Main Background with Deep Data Theme */
.welcome-bg {
    background: radial-gradient(circle at 50% 10%, #1e1b4b 0%, #0f172a 100%);
    position: relative;
    overflow: hidden;
}

/* Perspective Grid (Data Floor) */
.dashboard-grid {
    position: absolute;
    bottom: -20%;
    left: -50%;
    width: 200%;
    height: 100%;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.1) 1px, transparent 1px);
    background-size: 40px 40px;
    transform: perspective(500px) rotateX(60deg);
    animation: gridMove 20s linear infinite;
    opacity: 0.3;
}

@keyframes gridMove {
    0% {
        transform: perspective(500px) rotateX(60deg) translateY(0);
    }

    100% {
        transform: perspective(500px) rotateX(60deg) translateY(40px);
    }
}

/* Background Animated Bar Charts */
.bg-chart-container {
    position: absolute;
    bottom: 20%;
    left: 10%;
    display: flex;
    align-items: flex-end;
    gap: 15px;
    opacity: 0.2;
    z-index: 1;
    transform: skewY(-5deg);
}

.bg-chart-container.right {
    left: auto;
    right: 10%;
    bottom: 30%;
    transform: skewY(5deg);
}

.bg-bar {
    width: 20px;
    background: linear-gradient(to top, #4f46e5, #818cf8);
    border-radius: 4px 4px 0 0;
    animation: barPulse 3s ease-in-out infinite alternate;
}

.bg-bar:nth-child(1) {
    height: 60px;
    animation-duration: 2.2s;
}

.bg-bar:nth-child(2) {
    height: 100px;
    animation-duration: 2.5s;
}

.bg-bar:nth-child(3) {
    height: 40px;
    animation-duration: 1.8s;
}

.bg-bar:nth-child(4) {
    height: 80px;
    animation-duration: 3s;
}

.bg-bar:nth-child(5) {
    height: 120px;
    animation-duration: 2.7s;
}

@keyframes barPulse {
    0% {
        transform: scaleY(1);
        opacity: 0.5;
    }

    100% {
        transform: scaleY(1.3);
        opacity: 0.8;
    }
}

/* Floating Donut/Pie Charts */
.bg-donut {
    position: absolute;
    border-radius: 50%;
    border: 8px solid transparent;
    border-top-color: #ec4899;
    /* Pink */
    border-right-color: #8b5cf6;
    /* Purple */
    opacity: 0.15;
    animation: spinDonut 10s linear infinite;
}

.donut-1 {
    top: 15%;
    left: 15%;
    width: 120px;
    height: 120px;
}

.donut-2 {
    top: 25%;
    right: 20%;
    width: 80px;
    height: 80px;
    border-width: 6px;
    animation-duration: 15s;
    animation-direction: reverse;
    border-top-color: #06b6d4;
    border-right-color: #3b82f6;
}

@keyframes spinDonut {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Floating Data Lines (Graph segments) */
.bg-graph-line {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, transparent, #38bdf8, transparent);
    width: 200px;
    top: 40%;
    left: 5%;
    transform: rotate(-15deg);
    opacity: 0.2;
    animation: flowLine 4s infinite ease-in-out;
}

@keyframes flowLine {
    0% {
        width: 100px;
        transform: rotate(-15deg) translateX(-20px);
        opacity: 0;
    }

    50% {
        width: 250px;
        opacity: 0.3;
    }

    100% {
        width: 100px;
        transform: rotate(-15deg) translateX(20px);
        opacity: 0;
    }
}

/* Enhanced Central Glass Card */
.welcome-card-glass {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 40px 100px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 60px;
    max-width: 700px;
    width: 90%;
    text-align: center;
    position: relative;
    z-index: 10;
    transition: transform 0.3s ease;
}

.welcome-card-glass:hover {
    transform: translateY(-5px);
    box-shadow: 0 50px 120px rgba(0, 0, 0, 0.6);
}

/* Button Glow Override */
.btn-glow {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    box-shadow: 0 0 25px rgba(79, 70, 229, 0.4);
    transition: all 0.3s ease;
}

.btn-glow:hover {
    box-shadow: 0 0 40px rgba(124, 58, 237, 0.6);
    transform: scale(1.05);
}


/* =========================================
   FLOATING PILL CHATBOX - ChatGPT Style
   ========================================= */

/* Container that holds both collapsed and expanded states */
.chat-pill-container {
    position: fixed;
    bottom: 24px;
    left: 304px;
    /* Sidebar width (280px) + 24px padding */
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Collapsed Pill View - Full Width */
.chat-pill-collapsed {
    width: 100%;
    animation: pillFadeIn 0.3s ease;
}

@keyframes pillFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-pill-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    padding: 8px 8px 8px 16px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(99, 102, 241, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.chat-pill-inner:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(99, 102, 241, 0.2),
        0 0 30px rgba(99, 102, 241, 0.1);
}

.chat-pill-inner:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.5),
        0 0 0 2px rgba(99, 102, 241, 0.3),
        0 0 40px rgba(99, 102, 241, 0.15);
}

.chat-pill-icon {
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.chat-pill-input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    color: #e2e8f0 !important;
    font-size: 15px !important;
    padding: 10px 0 !important;
    outline: none !important;
    box-shadow: none !important;
    min-width: 200px;
}

.chat-pill-input::placeholder {
    color: #64748b !important;
}

.chat-pill-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-pill-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5);
}

.chat-pill-send-btn:active {
    transform: scale(0.95);
}

/* Light Theme Collapsed Pill */
.light-theme .chat-pill-inner {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(99, 102, 241, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.light-theme .chat-pill-inner:hover {
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(99, 102, 241, 0.15);
}

.light-theme .chat-pill-inner:focus-within {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.15),
        0 0 0 2px rgba(99, 102, 241, 0.2);
}

.light-theme .chat-pill-input {
    color: #1e293b !important;
}

.light-theme .chat-pill-input::placeholder {
    color: #94a3b8 !important;
}

/* =========================================
   EXPANDED FLOATING CHAT PANEL
   ========================================= */

.chat-panel-floating {
    position: fixed;
    top: 80px;
    /* Below header with some spacing */
    /* Below header */
    bottom: 0;
    left: 280px;
    /* Sidebar width */
    right: 0;
    width: auto;
    height: auto;
    max-height: none;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
    z-index: 2100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatPanelSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatPanelSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Chat Panel Header */
.chat-float-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.chat-float-minimize-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-float-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Chat Panel Body */
.chat-float-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
    /* Ensure it doesn't exceed viewport */
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
}

/* Custom scrollbar for chat */
.chat-float-body::-webkit-scrollbar {
    width: 6px;
}

.chat-float-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.chat-float-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chat-float-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-float-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: min-content;
    /* Allow shrinking */
}

/* Chat Panel Footer */
.chat-float-footer {
    padding: 16px 20px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: transparent;
}

.chat-float-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent !important;
    background-color: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    padding: 6px 6px 6px 16px;
    transition: all 0.2s ease;
}

/* Force transparent on any Bootstrap form controls inside chat */
.chat-float-input-container .form-control,
.chat-float-footer .form-control,
.chat-panel-floating .form-control,
#chat-panel .form-control {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.chat-float-input-container:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: transparent !important;
}

.chat-float-input,
.chat-float-input.form-control,
#ai-prompt {
    flex: 1;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    color: #e2e8f0 !important;
    font-size: 14px !important;
    padding: 10px 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

.chat-float-input::placeholder,
#ai-prompt::placeholder {
    color: #64748b !important;
}

.chat-float-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-float-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5);
}

.chat-float-disclaimer {
    text-align: center;
    color: #64748b;
    font-size: 11px;
    margin-top: 10px;
}

/* Light Theme Floating Panel */
.light-theme .chat-panel-floating {
    background: rgba(255, 255, 255, 0.98);
    border: none;
    border-left: 1px solid #e2e8f0;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.08);
}

.light-theme .chat-float-header {
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid #e2e8f0;
}

.light-theme .chat-float-header div {
    color: #1e293b !important;
}

.light-theme .chat-float-minimize-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid #e2e8f0;
    color: #64748b;
}

.light-theme .chat-float-minimize-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #1e293b;
}

.light-theme .chat-float-footer {
    border-top: 1px solid #e2e8f0;
    background: transparent;
}

.light-theme .chat-float-input-container {
    background: transparent !important;
    border: 1px solid #cbd5e1;
}

.light-theme .chat-float-input-container:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: transparent !important;
}

.light-theme .chat-float-input,
.light-theme .chat-float-input.form-control,
.light-theme #ai-prompt {
    background: transparent !important;
    background-color: transparent !important;
    color: #1e293b !important;
}

.light-theme .chat-float-input::placeholder,
.light-theme #ai-prompt::placeholder {
    color: #94a3b8 !important;
}

/* Floating Scroll/Feather Button */
.fab-scroll-btn {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
    z-index: 1600;
    overflow: hidden;
    transition: all 0.3s ease;
}

.fab-scroll-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.6);
}

/* Legacy fab-chat-btn - hidden, kept for compatibility */
.fab-chat-btn {
    display: none !important;
}

/* Light Theme Overrides */
.light-theme .chatgpt-header {
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid #e2e8f0;
    color: #0f172a;
}

.light-theme .chatgpt-close-btn {
    color: #64748b;
}

.light-theme .chatgpt-close-btn:hover {
    color: #0f172a;
    background: rgba(0, 0, 0, 0.05);
}

.light-theme .chatgpt-footer {
    border-top: 1px solid #e2e8f0;
}

.light-theme .chatgpt-input-container {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.light-theme .chatgpt-input-container:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.light-theme .chatgpt-input {
    color: #0f172a !important;
}

.light-theme .chatgpt-input::placeholder {
    color: #94a3b8 !important;
}

/* Vibrant AI Footer Bar for Light Mode (Aurora Style) */
.light-theme .fab-chat-btn {
    background: linear-gradient(90deg, #4ade80, #3b82f6, #9333ea);
    /* Green -> Blue -> Purple */
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 -4px 30px rgba(59, 130, 246, 0.2);
    color: white;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Hover state for vibrant bar */
.light-theme .fab-chat-btn:hover {
    box-shadow: 0 -6px 35px rgba(147, 51, 234, 0.4);
    transform: translateY(-2px);
}

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

    50% {
        background-position: 100% 50%
    }

    100% {
        background-position: 0% 50%
    }
}

/* Dynamic Robot Visual - Pure CSS Animation */
.robot-visual-container {
    height: 120px;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.2) 0%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.robot-eye {
    width: 60px;
    height: 60px;
    background: #000;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: robotFloat 3s ease-in-out infinite;
}

.eye-core {
    width: 20px;
    height: 20px;
    background: #60a5fa;
    border-radius: 50%;
    box-shadow: 0 0 15px #60a5fa;
    animation: eyeBlink 4s infinite, eyeScan 6s ease-in-out infinite alternate;
}

.eye-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(96, 165, 250, 0.3);
    border-top-color: #60a5fa;
    animation: ringSpin 2s linear infinite;
}

@keyframes robotFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes eyeBlink {

    0%,
    96%,
    98% {
        transform: scaleY(1);
    }

    97% {
        transform: scaleY(0.1);
    }
}

@keyframes eyeScan {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px);
    }

    75% {
        transform: translateX(8px);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes ringSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.light-theme .chat-panel {
    background: rgba(255, 241, 242, 0.95) !important;
    /* Soft Pinkish White */
    border: 1px solid #fecdd3 !important;
    /* Rose border */
    box-shadow: 0 20px 50px rgba(225, 29, 72, 0.15);
}

.light-theme .robot-visual-container {
    background: linear-gradient(180deg, rgba(244, 63, 94, 0.15) 0%, transparent 100%);
    border-bottom: 1px solid #ffe4e6;
}

.light-theme .eye-core {
    background: #f43f5e !important;
    /* Rose eye */
    box-shadow: 0 0 15px #f43f5e !important;
}

.light-theme .eye-ring {
    border: 2px solid rgba(244, 63, 94, 0.3) !important;
    border-top-color: #f43f5e !important;
}

.light-theme .chat-user {
    background: #e11d48 !important;
    /* Rose-600 */
    color: white !important;
}

/* STAND OUT: Light Theme AI Bubble (Professional Deep Slate) */
.light-theme .chat-ai {
    /* Professional Deep Corporate Blue/Slate */
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
    color: #ffffff !important;
    border: 1px solid rgba(71, 85, 105, 0.5);

    /* Typography Match */
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 15px !important;
    line-height: 1.65 !important;
    letter-spacing: 0.2px !important;
    font-weight: 400 !important;

    /* Professional Shadow (Subtle depth, no neon glow) */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    transform: none;
}




/* Ensure links in vibrant bubble are white/underlined */
.light-theme .chat-ai a {
    color: #ffffff !important;
    text-decoration: underline;
    font-weight: 700;
}


/* =========================================
   DESKTOP COLLAPSE LOGIC (> 768px)
   ========================================= */
@media screen and (min-width: 769px) {
    .sidebar-collapsed {
        width: 90px !important;
        padding: 24px 12px !important;
    }

    .sidebar-collapsed .sidebar-text {
        display: none !important;
        opacity: 0;
    }

    .sidebar-collapsed .custom-btn {
        justify-content: center !important;
        padding: 12px 0 !important;
        text-align: center;
    }

    /* Rotation for toggle button when collapsed */
    .sidebar-collapsed .desktop-only-btn {
        transform: rotate(180deg);
    }

    /* Fix Upload Icon in Collapsed Sidebar */
    /* Fix Upload Icon in Collapsed Sidebar */
    #app-sidebar.sidebar-collapsed #upload-data,
    body:has(.sidebar-collapsed) #upload-data {
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        width: 100% !important;
        /* Use available width */
        height: auto !important;
        min-height: 40px !important;
        margin: 0 !important;
        overflow: visible !important;
        /* Don't clip */
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    #app-sidebar.sidebar-collapsed #upload-data img,
    body:has(.sidebar-collapsed) #upload-data img {
        width: 32px !important;
        height: 32px !important;
        margin: 0 !important;
        object-fit: contain !important;
    }

    /* Adjust Layout Sibling Elements */
    #app-sidebar.sidebar-collapsed~#main-scroll-container {
        margin-left: 90px !important;
        width: auto !important;
    }

    /* Adjust Chat Panel & Button Position */
    /* Adjust Chat Panel & Button Position */
    /* Using :has() for robust selection since elements are not siblings */
    #app-sidebar.sidebar-collapsed~#btn-open-chat,
    body:has(#app-sidebar.sidebar-collapsed) #btn-open-chat {
        left: 90px !important;
        right: 0 !important;
        width: auto !important;
        border-radius: 0 !important;
    }

    #app-sidebar.sidebar-collapsed~.chat-panel,
    body:has(#app-sidebar.sidebar-collapsed) .chat-panel {
        left: 90px !important;
    }

    /* Fix Header when Sidebar Collapsed */
    body:has(#app-sidebar.sidebar-collapsed) .app-header {
        margin-left: 90px !important;
    }

    /* Visibility Control */
    .desktop-only-btn {
        display: flex !important;
    }

    .mobile-only-btn {
        display: none !important;
    }
}


/* =========================================
   CUSTOM LOADING ENGINE (PREMIUM)
   Replaces default Dash spinners with
   Theme-Aware Data Bars Animation
   ========================================= */

/* Parent Container Override */
.vecdash-loader {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    /* Ensure space for loader */
    width: 100%;
}

/* Hide Default Dash Spinner */
.vecdash-loader .dash-spinner,
.vecdash-loader .dash-default-spinner {
    display: none !important;
    visibility: hidden;
    opacity: 0;
}

/* The Animated Element (Data Bars) */
.vecdash-loader::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;

    /* 5 Bars Construction using Gradients */
    background:
        linear-gradient(to top, var(--loader-c1, #8b5cf6), var(--loader-c2, #6366f1)) 0% 50% / 4px 20%,
        linear-gradient(to top, var(--loader-c1, #8b5cf6), var(--loader-c2, #6366f1)) 25% 50% / 4px 40%,
        linear-gradient(to top, var(--loader-c1, #8b5cf6), var(--loader-c2, #6366f1)) 50% 50% / 4px 100%,
        linear-gradient(to top, var(--loader-c1, #8b5cf6), var(--loader-c2, #6366f1)) 75% 50% / 4px 60%,
        linear-gradient(to top, var(--loader-c1, #8b5cf6), var(--loader-c2, #6366f1)) 100% 50% / 4px 30%;

    background-repeat: no-repeat;
    animation: dataWaves 1.2s infinite ease-in-out alternate;
}

/* Theme Awareness: Light Mode Colors */
.light-theme .vecdash-loader::after {
    --loader-c1: #2563eb;
    /* Blue */
    --loader-c2: #0ea5e9;
    /* Sky */
}

/* Theme Awareness: Dark Mode Defaults (Purple/Indigo) */
/* (Fallback already in background property, but explicit variables here) */
.vecdash-loader::after {
    --loader-c1: #8b5cf6;
    --loader-c2: #6366f1;
}


/* Fixed Chat Input Footer */
.chat-input-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px 5% 40px 5%;
    z-index: 200;
    background: rgba(15, 23, 42, 0.95);
    /* Dark theme match */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Light Mood Footer Override */
.light-theme .chat-input-footer {
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid #e2e8f0;
}

/* Chat Input Field (The Textbox) */
.chat-input-field {
    border-radius: 24px !important;
    padding: 16px 60px 16px 24px !important;
    font-size: 16px !important;
    width: 100% !important;
    transition: all 0.2s ease !important;

    /* Dark Mode Defaults */
    background: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.chat-input-field:focus {
    border-color: #6366f1 !important;
    /* Indigo Focus */
    background: #0f172a !important;
    outline: none !important;
}

/* Light Mode Input Override */
.light-theme .chat-input-field {
    background: #ffffff !important;
    /* Pure White */
    border: 1px solid #cbd5e1 !important;
    /* Slate 300 */
    color: #1e293b !important;
    /* Slate 800 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
}

.light-theme .chat-input-field:focus {
    background: #ffffff !important;
    border-color: #3b82f6 !important;
    /* Blue Focus */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

.light-theme .chat-input-field::placeholder {
    color: #94a3b8 !important;
}

@keyframes dataWaves {
    0% {
        background-size:
            4px 20%,
            4px 100%,
            4px 30%,
            4px 60%,
            4px 20%;
    }

    25% {
        background-size:
            4px 60%,
            4px 40%,
            4px 80%,
            4px 20%,
            4px 50%;
    }

    50% {
        background-size:
            4px 30%,
            4px 80%,
            4px 100%,
            4px 40%,
            4px 70%;
    }

    75% {
        background-size:
            4px 90%,
            4px 30%,
            4px 50%,
            4px 100%,
            4px 40%;
    }

    100% {
        background-size:
            4px 50%,
            4px 70%,
            4px 20%,
            4px 80%,
            4px 100%;
    }
}

/* =========================================
   AI CHAT LOADING (SUBTLE TYPING INDICATOR)
   Context-specific loader for chat interface
   ========================================= */

/* Parent Wrapper in Layout */
.chat-loading-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Critical for nested flex scroll */
    overflow: visible !important;
    /* Allow bubble to hang out at bottom */
}

/* Fix Dash Loading Internal Wrapper breaking Flexbox */
.chat-loading-wrapper>div:not(.dash-spinner) {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    opacity: 1 !important;
    /* Don't fade out chat history */
    transition: none !important;
}

/* Override Dash Spinner Container Position & Style as Bubble */
.chat-loading-wrapper .dash-spinner {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    /* Align dots left */
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    bottom: -40px !important;
    /* Push into the padding area below messages */
    left: 24px !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;

    /* Bubble Styling */
    width: 60px !important;
    height: 32px !important;
    padding-left: 12px !important;
    background: rgba(30, 41, 59, 0.8) !important;
    /* Slate 800 */
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);

    z-index: 150;
    /* Visible but below input bar */
    pointer-events: none;
}

/* Light Theme Bubble */
.light-theme .chat-loading-wrapper .dash-spinner {
    background: rgba(241, 245, 249, 0.9) !important;
    /* Slate 100 */
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Hide Default SVG Spinner */
.chat-loading-wrapper .dash-spinner * {
    display: none !important;
}

/* Create Mini Data Bars (Dashboard Theme) */
.chat-loading-wrapper .dash-spinner::after {
    content: '';
    display: block;
    width: 24px;
    height: 14px;
    margin-left: 8px;
    /* Center inside bubble */

    /* Define Colors locally or inherit */
    --mini-bar-c1: #8b5cf6;
    /* Purple */
    --mini-bar-c2: #d946ef;
    /* Fuchsia/Pink Pop */

    /* 3 Mini Bars via Gradients */
    background:
        linear-gradient(to top, var(--mini-bar-c1), var(--mini-bar-c2)) 0% 50% / 4px 50%,
        linear-gradient(to top, var(--mini-bar-c1), var(--mini-bar-c2)) 50% 50% / 4px 100%,
        linear-gradient(to top, var(--mini-bar-c1), var(--mini-bar-c2)) 100% 50% / 4px 50%;

    background-repeat: no-repeat;
    animation: miniDataWaves 1s infinite ease-in-out alternate;
    box-shadow: none;
    /* Remove old dot shadows */
    border-radius: 0;
    /* Bars are rectangular */
}

@keyframes miniDataWaves {
    0% {
        background-size:
            4px 30%,
            4px 100%,
            4px 30%;
    }

    50% {
        background-size:
            4px 100%,
            4px 30%,
            4px 100%;
    }

    100% {
        background-size:
            4px 50%,
            4px 70%,
            4px 50%;
    }
}

/* Theme Awareness for Chat Loader */
.light-theme .chat-loading-wrapper .dash-spinner::after {
    --chat-dot-primary: #334155;
    --chat-dot-secondary: rgba(51, 65, 85, 0.6);
    --chat-dot-tertiary: rgba(51, 65, 85, 0.3);
}

.dark-theme .chat-loading-wrapper .dash-spinner::after {
    --chat-dot-primary: #f0fdf4;
    /* Mint */
    --chat-dot-secondary: rgba(240, 253, 244, 0.6);
    --chat-dot-tertiary: rgba(240, 253, 244, 0.3);
}



/* =========================================
   ROBUST RESPONSIVE ENGINE
   Supports: Android, iPhone (Mini to Pro Max), Foldables
   ========================================= */

/* 1. TABLET & SMALL LAPTOP (769px - 1024px) */
/* Adjust layout but keep side-by-side if screen permits */
@media screen and (max-width: 1024px) {
    #app-sidebar {
        width: 240px !important;
    }

    #main-scroll-container {
        margin-left: 240px !important;
        /* Proper margin override */
        left: auto !important;
        width: auto !important;
        padding: 24px !important;
        padding-bottom: 100px !important;
        /* Safety clearance for AI Bar */
    }

    /* Fix Header Margin & Wrapping for Tablet */
    .app-header {
        margin-left: 240px !important;
        flex-wrap: wrap !important;
        /* Allow controls to stack if needed */
        height: auto !important;
        min-height: 60px !important;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }

    /* Scrollable Tables on Tablet */
    #preview-div,
    #preprocessing-page .glass {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        display: block !important;
    }

    /* Force 2-column grid for KPIs on Tablet to prevent weird uneven rows */
    .kpis {
        gap: 16px !important;
        justify-content: center;
    }

    .kpi {
        flex: 1 1 45% !important;
        /* 2 per row */
        min-width: 280px !important;
        max-width: 100%;
        margin-bottom: 16px;
    }

    /* Allow generic rows to wrap for charts */
    .row {
        flex-wrap: wrap !important;
    }

    /* Ensure charts don't overflow */
    .js-plotly-plot,
    .plot-container {
        min-width: 0 !important;
        /* Flexbox trick */
    }

    /* Welcome Page Tablet Fixes */
    .hero-heading-text {
        font-size: 56px !important;
    }

    #welcome-page [style*="minWidth: 300px"] {
        min-width: 100% !important;
        /* Stack hero columns on narrower tablets */
        margin-bottom: 40px;
    }

    /* ----------------------------------------------------
       CRITICAL: TEXT SAFETY & CONTROL VISIBILITY
       Applies to Tablet & Mobile (Cascades down)
       ---------------------------------------------------- */

    /* 1. Theme Toggle Protection */
    .theme-toggle,
    .light-dark-toggle {
        flex-shrink: 0 !important;
        /* NEVER shrink */
        min-width: 130px !important;
        /* Ensure label + switch fit */
        display: flex !important;
        align-items: center !important;
        white-space: nowrap !important;
        /* Keep label one line */
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* 2. Text Wrapping & Safety */
    .app-header .app-logo,
    .app-header .dataset-status,
    .sidebar-text,
    .card-text,
    p,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        white-space: normal !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
    }

    /* Keep table headers single line for scrollability */
    .custom-data-table th,
    .custom-data-table td {
        white-space: nowrap !important;
    }

    /* 3. Container Expansion */
    .glass,
    .kpi,
    .card {
        height: auto !important;
        /* Never fix height */
        min-height: 0 !important;
    }
}

/* 2. MOBILE & FOLDABLES (Max Width 768px) */
/* The main "Stacking" breakpoint */
@media screen and (max-width: 768px) {

    /* Global Reset for Safety */
    html,
    body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        /* CRITICAL: Enable vertical scroll */
        height: auto !important;
        /* CRITICAL: Allow body to grow */
        min-height: 100vh !important;
        width: 100% !important;
        position: relative;
        overflow-wrap: break-word;
        /* Prevent text overlap */
    }

    /* Unlock Root Containers specifically */
    #theme-wrapper,
    #dashboard-page,
    #main-layout-container {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: visible !important;
    }

    * {
        box-sizing: border-box;
    }

    /* Fix Empty State Card to prevent text issues */
    #empty-state-card {
        max-width: 100% !important;
        width: 100% !important;
        padding: 24px 16px !important;
    }

    /* Stack Sidebar Collapsed by Default */
    #app-sidebar {
        width: 100% !important;
        height: auto !important;
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        padding: 16px !important;
        padding-top: max(16px, env(safe-area-inset-top)) !important;
        display: flex;
        flex-direction: column;
        gap: 12px;
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        overflow: visible !important;
        z-index: 100;
    }

    /* Expanded State - Full Screen Overlay */
    #app-sidebar.mobile-open {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        background: rgba(15, 23, 42, 0.98) !important;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 10000 !important;
        overflow-y: auto !important;
        padding-bottom: 40px !important;
        flex-direction: column !important;
        /* Stack vertically when expanded */
    }

    /* Show all content when expanded */
    #app-sidebar.mobile-open>div {
        display: block !important;
    }

    /* Keep theme toggle in top right even when expanded */
    #app-sidebar.mobile-open #theme-menu-toggle {
        position: absolute !important;
        top: 16px !important;
        right: 16px !important;
    }

    /* Reduce padding for content boxes on mobile */
    .glass {
        padding: 16px !important;
        border-radius: 16px !important;
    }

    /* Small Layout Tweaks */
    .chat-panel {
        z-index: 10001 !important;
        /* Above sidebar */
    }

    /* Show Menu Button */
    .mobile-only-btn {
        display: flex !important;
    }


    /* Fix Main Layout Direction on Mobile */
    #main-layout-container {
        flex-direction: column !important;
        min-height: auto !important;
    }

    /* Content Stacking & Scrolling */
    #main-scroll-container {
        margin-left: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        /* Allow growing */
        overflow-y: visible !important;
        /* Let body scroll */
        padding: 16px !important;
        padding-bottom: 120px !important;
        /* Extra space for buttons */
        margin-top: 0 !important;
    }

    /* Chat Panel Full Screen Overlay on Mobile */
    .chat-panel-floating {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-height: none !important;
        border-radius: 0 !important;
        border: none !important;
        z-index: 99999 !important;
    }

    /* Pill Container on Mobile - Full Width */
    .chat-pill-container {
        left: 16px !important;
        right: 16px !important;
        bottom: 24px !important;
    }

    .chat-pill-collapsed {
        width: 100% !important;
    }

    .chat-pill-inner {
        width: 100% !important;
    }

    .chat-pill-input {
        min-width: unset !important;
        flex: 1 !important;
    }

    /* Floating Buttons Thumb Friendly & True FAB */
    .fab-scroll-btn {
        right: 16px !important;
        bottom: 100px !important;
        width: 48px !important;
        height: 48px !important;
    }

    /* Legacy fab-chat-btn hidden on mobile too */
    .fab-chat-btn {
        display: none !important;
    }

    /* Flex Containers Wrap */
    .row,
    .kpis,
    .controls-row {
        flex-direction: column !important;
        width: 100% !important;
    }

    .kpi {
        width: 100% !important;
        margin-bottom: 10px;
        flex: 1 1 auto !important;
    }

    /* Hero Text Resize */
    .hero-heading-text {
        font-size: 36px !important;
        /* Safe for small mobiles */
        line-height: 1.2 !important;
        margin-bottom: 16px !important;
    }

    /* Scale down paragraph text */
    .load-reveal p {
        font-size: 16px !important;
        line-height: 1.5 !important;
    }

    /* Tables Scrollable Wrapper */
    #preview-div,
    #preprocessing-page .glass {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        display: block !important;
        /* Ensure it's not flex forcing squeeze */
    }

    /* Ensure preprocessing page has no left margin/padding */
    #preprocessing-page {
        margin-left: 0 !important;
        padding-left: 0 !important;
        width: 100% !important;
    }

    #preprocessing-page .glass {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .custom-data-table {
        min-width: 600px;
        /* Force scroll */
    }

    /* Charts Fluid */
    .js-plotly-plot,
    .plot-container {
        width: 100% !important;
    }

    /* Chat Input Padding */
    #ai-prompt {
        padding: 12px 45px 12px 16px !important;
        /* Smaller padding */
        font-size: 14px !important;
    }

    /* App Header Mobile */
    .app-header {
        padding: 0 16px !important;
        margin-left: 0 !important;
        /* Full width on mobile */
        position: relative !important;
        /* For absolute positioning of theme toggle */
    }

    /* Position theme toggle in top right corner on mobile */
    .app-header #theme-menu-toggle {
        position: absolute !important;
        right: 16px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    /* Hide dataset status text on mobile  to make room */
    .app-header .dataset-status {
        max-width: 120px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* Prevent images/inputs from breaking layout */
    img,
    input,
    .dcc-upload {
        max-width: 100% !important;
    }

    /* Fix chart-header alignment in light theme on mobile */
    .light-theme .chart-header {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
        margin: 10px !important;
    }

    .light-theme .chart-header>div:first-child {
        display: flex !important;
        align-items: center !important;
        flex: 1 !important;
    }

    .light-theme .chart-header .remove-btn {
        flex-shrink: 0 !important;
        align-self: center !important;
    }
}


/* 3. SMALL MOBILE / FOLDED (Max Width 480px) */
/* Extreme space constraints */
@media screen and (max-width: 480px) {
    h1 {
        font-size: 22px !important;
    }

    h2 {
        font-size: 18px !important;
    }

    .logo-text {
        font-size: 18px !important;
    }

    /* Refine spacing for small screens */
    #app-sidebar {
        padding: 16px !important;
    }

    #main-scroll-container {
        /* Top: 24px (Breathable) | Right: 16px | Bottom: 150px (Avoid FAB overlap) | Left: 16px */
        padding: 24px 16px 150px 16px !important;
    }

    /* Make buttons full width */
    .custom-btn {
        width: 100% !important;
        margin: 4px 0 !important;
    }
}





.light-theme .chat-ai p,
.light-theme .chat-ai span,
.light-theme .chat-ai div {
    color: #ffffff !important;
    /* Force all children to be white */
}




.light-theme .kpi:hover {
    background: #ffffff !important;
    transform: translateY(-6px) scale(1.05) !important;
    box-shadow:
        0 20px 40px -10px rgba(99, 102, 241, 0.4),
        0 0 15px rgba(99, 102, 241, 0.2) !important;
    border-color: #6366f1 !important;

    z-index: 10;
}

/* Welcome Page Button Hovers */
.btn-welcome-primary:hover {
    background-color: #7c3aed !important;
    /* darker purple */
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn-welcome-secondary:hover {
    background-color: rgba(139, 92, 246, 0.1) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

@keyframes barGrow {
    0% {
        transform: scaleY(0.5);
        opacity: 0.7;
    }

    100% {
        transform: scaleY(1);
        opacity: 1;
    }
}

/* Feature Card Hover Effects */
.feature-card:hover {
    transform: translateY(-8px);
    background-color: #2e3b52 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 15px rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Hero Heading Typography */
.hero-heading-text {
    font-family: 'Outfit', sans-serif !important;
    font-weight: 800;
    line-height: 1.1;
    background: linear-gradient(to right, #ffffff 20%, #c084fc 60%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Force Dropdown Option Visibility (VirtualizedSelect Interaction) */
.light-theme .VirtualizedSelectOption {
    color: #000000 !important;
    background-color: #ffffff !important;
    font-size: 14px;
    padding: 8px 12px;
}

.light-theme .VirtualizedSelectFocusedOption {
    background-color: #e2e8f0 !important;
    color: #000000 !important;
}

.light-theme .Select-value-label {
    color: #000000 !important;
}

.light-theme .Select--single>.Select-control .Select-value,
.light-theme .Select-placeholder {
    color: #000000 !important;
}

.light-theme .Select-menu-outer {
    z-index: 9999 !important;
    background-color: #ffffff !important;
}

.dark-theme .VirtualizedSelectOption {
    color: #e2e8f0 !important;
    background-color: #1f2937 !important;
    font-size: 14px;
    padding: 8px 12px;
}

.dark-theme .VirtualizedSelectFocusedOption {
    background-color: #334155 !important;
    color: #f8fafc !important;
}

.dark-theme .Select-value-label {
    color: #e2e8f0 !important;
}

.dark-theme .Select--single>.Select-control .Select-value,
.dark-theme .Select-placeholder {
    color: #e2e8f0 !important;
}

.dark-theme .Select-menu-outer {
    z-index: 9999 !important;
    background-color: #1f2937 !important;
}

/* UNIVERSAL DROPDOWN FIX */
.light-theme .Select-control,
.light-theme .Select-menu-outer,
.light-theme .Select-value,
.light-theme .Select-placeholder,
.light-theme .Select-input input {
    color: #000000 !important;
    text-shadow: none !important;
}

.dark-theme .Select-control,
.dark-theme .Select-menu-outer,
.dark-theme .Select-value,
.dark-theme .Select-placeholder,
.dark-theme .Select-input input {
    color: #e2e8f0 !important;
    text-shadow: none !important;
}

.light-theme .Select-control {
    background-color: #ffffff !important;
    border: 1px solid #ccc !important;
}

.dark-theme .Select-control {
    background-color: #1f2937 !important;
    border: 1px solid #334155 !important;
}

.light-theme .Select-menu-outer {
    background-color: #ffffff !important;
    border: 1px solid #ccc !important;
}

.dark-theme .Select-menu-outer {
    background-color: #1f2937 !important;
    border: 1px solid #334155 !important;
}

.light-theme .VirtualizedSelectOption {
    color: #000000 !important;
    background-color: #ffffff !important;
}

.dark-theme .VirtualizedSelectOption {
    color: #e2e8f0 !important;
    background-color: #1f2937 !important;
}

.light-theme .VirtualizedSelectFocusedOption {
    background-color: #e2e8f0 !important;
    color: #000000 !important;
}

.dark-theme .VirtualizedSelectFocusedOption {
    background-color: #334155 !important;
    color: #f8fafc !important;
}

/* Ensure the selected value is visible */
.light-theme .Select-value-label {
    color: #000000 !important;
}

.dark-theme .Select-value-label {
    color: #e2e8f0 !important;
}

/* Ensure placeholder is visible but distinct */
.light-theme .Select-placeholder {
    color: #555555 !important;
}

.dark-theme .Select-placeholder {
    color: #94a3b8 !important;
}

/* Scroll Reveal Animation */
.scroll-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
    will-change: opacity, transform;
}

.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Load Reveal Animation (runs immediately) */
.load-reveal {
    animation: fadeSlideUp 1.2s ease-out forwards;
    opacity: 0;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------------------------------------------- */
/* PRETTY BUTTONS FOR DATA STUDIO (LIGHT THEME) */
/* ---------------------------------------------------- */

/* 1. Promote Header (Purple) */
/* UNIFIED BUTTON STYLES FOR DATA STUDIO */
.btn-studio-action {
    background: #6366f1;
    /* Primary Indigo/Purple default for Dark Mode */
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-studio-action:hover {
    filter: brightness(110%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.3);
}

/* Light Theme Overrides - Unified Blue */
.light-theme .btn-studio-action {
    background: #3b82f6 !important;
    /* Solid Blue */
    color: white !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.light-theme .btn-studio-action:hover {
    background: #2563eb !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

/* 6. Back Button (Neutral) */
.light-theme #back-to-dash {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.light-theme #back-to-dash:hover {
    background: #f1f5f9 !important;
    color: #1e293b !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* AI Prompt Placeholder Styling */
#ai-prompt::placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
    opacity: 1;
}

#ai-prompt::-webkit-input-placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

#ai-prompt::-moz-placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

#ai-prompt::-ms-input-placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Force AI Input to be Dark with White Text in Light Mode */


/* User-Requested Enhancements for Small Mobile (iPhone SE etc.) */
@media screen and (max-width: 400px) {

    /* --- 1. Empty State Fixes --- */
    .empty-state,
    .no-charts,
    .dashboard-empty {
        display: block !important;
        text-align: center;
        padding: 24px 16px !important;
        margin-top: 24px !important;
        height: auto !important;
    }

    .empty-state h2,
    .empty-state h3 {
        margin-top: 16px !important;
        margin-bottom: 8px !important;
    }

    .empty-state p {
        margin-top: 0 !important;
        line-height: 1.4;
    }

    /* --- 2. Hero/Visual Adjustments --- */
    .hero-image,
    .hero-graphic,
    .welcome-visual,
    .landing-illustration {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 320px !important;
        overflow: hidden !important;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 32px !important;
    }

    .hero-image img,
    .hero-graphic img,
    .welcome-visual img,
    .landing-illustration img {
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
    }

    /* --- 3. Header & Navigation --- */
    .header,
    .top-bar,
    .navbar,
    .app-header {
        height: auto !important;
        min-height: unset !important;
        padding: 12px 16px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
    }

    .header-status,
    .dataset-status,
    .no-dataset-text {
        font-size: 12px !important;
        line-height: 1.3 !important;
        white-space: normal !important;
    }

    /* --- 4. Light/Dark Toggle Enhancement (Required Fix) --- */
    .theme-toggle,
    .light-dark-toggle {
        align-self: flex-end !important;
        margin-top: 8px !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        min-width: 130px !important;
        /* Increased for safety */
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        flex-shrink: 0 !important;
        /* NEVER shrink */
        white-space: nowrap !important;
    }

    /* Enforce Switch Size */
    .theme-toggle .form-check,
    .theme-toggle .form-switch,
    .theme-toggle input {
        width: 50px !important;
        height: 28px !important;
        min-width: 50px !important;
        cursor: pointer !important;
    }

    /* --- 5. AI Assistant Pill Chatbox (Mobile) --- */
    .chat-pill-container {
        left: 12px !important;
        right: 12px !important;
        bottom: 16px !important;
    }

    .chat-panel-floating {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
    }

    /* Legacy fab-chat-btn - hidden */
    .fab-chat-btn {
        display: none !important;
    }

    #main-scroll-container {
        /* Padding to ensure content clears the pill chatbox */
        padding-bottom: 120px !important;
        padding-top: 24px !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

/* Remove decoration from Theme Toggle */
.btn-no-deco,
.btn-no-deco:hover,
.btn-no-deco:focus,
.btn-no-deco:active,
.btn-no-deco.btn-link {
    text-decoration: none !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Ensure caret is gone if using default bootstrap class */
.btn-no-deco::after {
    display: none !important;
}

/* =========================================
   FORCE TRANSPARENT CHAT INPUT (FINAL OVERRIDE)
   ========================================= */
#ai-prompt,
#ai-prompt-pill,
.chat-float-input,
.chat-pill-input,
#chat-panel input,
.chat-panel-floating input,
.chat-float-footer input,
.chat-pill-container input,
input.chat-float-input,
input.chat-pill-input {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* Light theme force transparent */
.light-theme #ai-prompt,
.light-theme #ai-prompt-pill,
.light-theme .chat-float-input,
.light-theme .chat-pill-input,
.light-theme #chat-panel input,
.light-theme .chat-panel-floating input,
.light-theme .chat-float-footer input,
.light-theme .chat-pill-container input {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    color: #1e293b !important;
    /* Dark text for visibility */
}

/* Light theme placeholder text */
.light-theme #ai-prompt::placeholder,
.light-theme #ai-prompt-pill::placeholder,
.light-theme .chat-float-input::placeholder,
.light-theme .chat-pill-input::placeholder,
.light-theme #chat-panel input::placeholder,
.light-theme .chat-panel-floating input::placeholder,
.light-theme .chat-float-footer input::placeholder,
.light-theme .chat-pill-container input::placeholder {
    color: #64748b !important;
    /* Slate placeholder text */
    opacity: 1 !important;
}

/* Mobile Chart Fix */
@media screen and (max-width: 768px) {

    /* Fix Plotly Clipping on Mobile */
    .js-plotly-plot .plotly .main-svg {
        position: static !important;
    }


}

/* =========================================
   CUSTOM EXIT WARNING MODAL (Force White Theme)
   Matches "We Respect Your Privacy" Screenshot
   ========================================= */

#exit-warning-modal .modal-content {
    background-color: #ffffff !important;
    color: #1e293b !important;
    /* Slate 800 */
    border: none !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}

#exit-warning-modal .modal-header {
    border-bottom: 1px solid #e2e8f0 !important;
    background-color: #ffffff !important;
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
}

#exit-warning-modal .modal-footer {
    border-top: 1px solid #e2e8f0 !important;
    background-color: #ffffff !important;
    border-bottom-left-radius: 12px !important;
    border-bottom-right-radius: 12px !important;
}

#exit-warning-modal h4,
#exit-warning-modal h5,
#exit-warning-modal .modal-title {
    color: #1e293b !important;
    font-weight: 700 !important;
}

#exit-warning-modal p,
#exit-warning-modal div {
    color: #475569 !important;
    /* Slate 600 */
}

/* Ensure Close button (X) is visible on white background */
#exit-warning-modal .btn-close {
    filter: none !important;
    /* Remove any invert filters for dark mode */
    color: #000000 !important;
    opacity: 0.5;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat !important;
}

#exit-warning-modal .btn-close:hover {
    opacity: 0.75;
}

/* =========================================
   DYNAMIC STEP CARDS (How It Works)
   ========================================= */

.step-card {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    cursor: default;
}

/* Hover Effect: Lift, Glow, and Border Highlight */
.step-card:hover {
    transform: translateY(-10px) scale(1.02) !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(139, 92, 246, 0.5) !important;
    /* Soft Purple Border */
    box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.4), 0 0 20px rgba(139, 92, 246, 0.2);
}

/* Internal Number Glow on Hover */
.step-card:hover div:first-child {
    color: rgba(255, 255, 255, 0.15) !important;
    transform: scale(1.1);
    transition: all 0.4s ease;
}

/* Add a subtle shine effect */
.step-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.05), transparent);
    transform: skewX(-25deg);
    transition: 0.5s;
}

.step-card:hover::after {
    left: 150%;
    transition: 0.7s ease-in-out;
}

/* =========================================
   SCROLLABLE STORYTELLING (How It Works)
   ========================================= */

@media screen and (max-width: 768px) {
    .step-row {
        flex-direction: column !important;
        text-align: center !important;
        gap: 30px !important;
    }

    .step-row img {
        width: 150px !important;
        margin: 0 auto;
    }

    .step-row h3 {
        font-size: 24px !important;
    }
}

/* =========================================
   ARROW VISIBILITY (Hide on Mobile)
   ========================================= */

@media screen and (max-width: 768px) {
    .step-arrow-container {
        display: none !important;
    }
}

/* =========================================
   RESPONSIVE HOW IT WORKS (Mobile Optimization)
   ========================================= */

@media screen and (max-width: 768px) {

    /* Stack cards vertically */
    .step-card {
        width: 100% !important;
        align-self: stretch !important;
        /* Use stretch or center */
        min-height: auto !important;
        padding: 30px !important;
        margin-bottom: 0px !important;
        /* Spacing handled by gap or arrows */
    }

    /* Adjust typography */
    .step-card h3 {
        font-size: 24px !important;
        margin-bottom: 12px !important;
    }

    .step-card p {
        font-size: 15px !important;
        line-height: 1.5 !important;
    }

    .step-card div:first-child {
        /* The number */
        font-size: 50px !important;
        margin-bottom: 10px !important;
    }

    /* Hide complex desktop zigzag arrows */
    .step-arrow-container {
        display: none !important;
    }

    /* Show simple mobile down arrows */
    .mobile-arrow-container {
        display: flex !important;
        justify-content: center;
        align-items: center;
        padding: 10px 0;
        margin-top: -30px;
        /* Pull closer to previous card */
        margin-bottom: 10px;
    }
}

@media screen and (min-width: 769px) {
    .mobile-arrow-container {
        display: none !important;
    }
}

/* =========================================
   FEATURES GRID LAYOUT
   ========================================= */

.features-grid {
    display: grid !important;
    padding-top: 40px;
    gap: 24px;
    /* Default: Laptop/Desktop - 4 items in one row */
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 1fr;
    /* Force equal height rows */
    width: 100%;
}

.feature-card {
    height: 100%;
    /* Fill the grid cell */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-sizing: border-box;
    /* Ensure padding doesn't expand width */
}

/* Tablet & Mobile: 2x2 Grid */
@media screen and (max-width: 1100px) {
    .features-grid {
        /* Force 2 columns */
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px;
    }
}

/* Mobile Small: Ensure 2x2 stays, compact content */
@media screen and (max-width: 480px) {
    .features-grid {
        gap: 10px !important;
        grid-template-columns: repeat(2, 1fr) !important;
        /* Explicitly keep 2 cols */
    }

    .feature-card {
        padding: 12px !important;
        min-height: 140px;
        /* Ensure minimum height for consistency */
    }

    /* Shrink Icon/Emoji */
    .feature-card img,
    .feature-card div[style*="font-size: 64px"] {
        width: 40px !important;
        height: 40px !important;
        font-size: 32px !important;
        /* For the emoji */
        margin-bottom: 8px !important;
    }

    /* Shrink Title */
    .feature-card h3 {
        font-size: 14px !important;
        margin-bottom: 4px !important;
        white-space: normal !important;
        line-height: 1.2 !important;
    }

    /* Shrink Description */
    .feature-card p {
        font-size: 11px !important;
        line-height: 1.3 !important;
        display: block !important;
        opacity: 0.9;
    }

    /* Force visibility and disable animations on mobile to prevent hidden text */
    .feature-card .load-reveal {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
        visibility: visible !important;
    }

    /* Ensure text color is visible */
    .feature-card h3,
    .feature-card p {
        color: #e2e8f0 !important;
        text-shadow: none !important;
    }
}

/* =========================================
   Contact Form Styles
   ========================================= */
.contact-input {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    font-size: 16px !important;
    border-radius: 12px !important;
    padding: 16px 24px !important;
    transition: all 0.3s ease;
}

.contact-input:focus {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2) !important;
    outline: none;
}

.contact-input::placeholder {
    color: rgba(255, 255, 255, 0.8) !important;
    opacity: 1;
}

.contact-input::-webkit-input-placeholder {
    color: rgba(255, 255, 255, 0.8) !important;
}

.contact-input:-ms-input-placeholder {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Progress Bar Premium Styling */
.progress {
    background-color: rgba(0, 0, 0, 0.2) !important;
    border-radius: 20px !important;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    background: linear-gradient(90deg, #6366f1, #8b5cf6) !important;
    color: white !important;
    font-weight: 700 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: width 0.4s ease-out !important;
}

.light-theme .progress-bar {
    background: linear-gradient(90deg, #3b82f6, #2563eb) !important;
}

.progress-bar-striped {
    background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent) !important;
}