/* Modern Dark AI Tech Color Scheme */
:root {
    --primary: #4f8cff;         /* Soft Blue */
    --primary-dark: #2563eb;    /* Deeper Blue */
    --primary-light: #eaf2ff;   /* Very Light Blue */
    --secondary: #ffb86b;       /* Peachy Accent */
    --secondary-dark: #ff9f43;  /* Deeper Peach */
    --accent: #ffd166;          /* Soft Yellow */
    --success: #43aa8b;         /* Fresh Green */
    --warning: #ffbe76;         /* Light Orange */
    --danger: #ff6b6b;          /* Soft Red */
    --dark: #222;               /* For text on light bg */
    --dark-secondary: #555;     /* Muted text */
    --dark-surface: #f5f5f5;    /* Light surface */
    --light: #fff;              /* White */
    --background: #fff;         /* Main background */
    --body-bg: #fff;            /* Main background */
    --card-bg: #fff;            /* Card background */
    --text: #222;               /* Main text color */
    --text-light: #555;         /* Muted text color */
    --border: #e0e0e0;          /* Light border */
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -1px rgba(0,0,0,0.04);
    --navbar-height: 70px;      /* Top navigation height */
    --text-muted: #b0b0b0;
    --primary-hover: #2563eb;   /* Updated hover state */
    --info: #4f8cff;            /* Updated info */
    --bg-dark: #f5f5f5;
    --bg-card-dark: #fff;
    --border-dark: #e0e0e0;
    /* New layered surface colors for better depth */
    --surface-0: #fff;       /* Base surface */
    --surface-1: #f8f9fa;       /* First layer */
    --surface-2: #f5f5f5;       /* Second layer - cards, containers */
    --surface-3: #eaf2ff;       /* Third layer - elevated components */
}

/* Theme-specific variables */
[data-bs-theme="dark"] {
    --card-bg: #23272f;
    --body-bg: #181a1b;
    --text-color: #f9fafb;
    --border-color: #334155;
}

[data-bs-theme="light"] {
    --card-bg: #fff;
    --body-bg: #fff;
    --text-color: #222;
    --border-color: #e0e0e0;
}

/* Base Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-color);
    font-size: 0.95rem;
    line-height: 1.6; /* Increased for better readability */
    margin: 0;
    padding: 0;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-top: var(--navbar-height); /* Add space for fixed top navbar */
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Navigation Styles */
.top-navbar {
    height: var(--navbar-height);
    background: linear-gradient(135deg, var(--surface-1) 0%, var(--surface-2) 50%, var(--surface-1) 100%);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    transition: all 0.3s ease;
}

.top-navbar.loading {
    opacity: 0.8;
}

.top-navbar .navbar-brand {
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 1.5rem;
    color: var(--text) !important;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.top-navbar .navbar-brand:hover {
    transform: translateY(-1px);
    color: var(--primary) !important;
}

.top-navbar .navbar-brand i {
    color: var(--primary);
    font-size: 1.75rem;
    transition: transform 0.3s ease;
}

.top-navbar .navbar-brand:hover i {
    transform: rotate(360deg);
}

/* Custom navbar toggler for dark theme */
.top-navbar .navbar-toggler {
    border: none;
    padding: 0.25rem 0.5rem;
    background: var(--surface-3);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.top-navbar .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(106, 53, 216, 0.25);
}

.top-navbar .navbar-toggler-icon {
    background: none;
    width: auto;
    height: auto;
}

.top-navbar .navbar-toggler i {
    color: var(--text);
    font-size: 1.25rem;
}

/* Navigation Links */
.top-navbar .nav-link {
    color: var(--text-light) !important;
    font-weight: 500;
    padding: 0.75rem 1rem !important;
    border-radius: 8px;
    margin: 0 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.top-navbar .nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(106, 53, 216, 0.1), transparent);
    transition: width 0.3s ease;
    z-index: -1;
}

.top-navbar .nav-link:hover::before {
    width: 100%;
}

.top-navbar .nav-link:hover {
    color: var(--text) !important;
    background-color: rgba(106, 53, 216, 0.1);
    transform: translateY(-1px);
}

.top-navbar .nav-link.active {
    color: var(--primary) !important;
    background: linear-gradient(135deg, rgba(106, 53, 216, 0.2), rgba(106, 53, 216, 0.1));
    border: 1px solid rgba(106, 53, 216, 0.3);
    box-shadow: 0 2px 8px rgba(106, 53, 216, 0.2);
}

.top-navbar .nav-link i {
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}

.top-navbar .nav-link:hover i {
    transform: scale(1.1);
}

/* Dropdown Styles */
.top-navbar .dropdown-menu {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    margin-top: 0.5rem;
    overflow: hidden;
}

.top-navbar .dropdown-item {
    color: var(--text-light);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.top-navbar .dropdown-item:hover {
    background: var(--surface-3);
    color: var(--text);
    transform: translateX(4px);
}

.top-navbar .dropdown-item i {
    font-size: 1rem;
    width: 16px;
    text-align: center;
}

/* Main Content Layout */
.main-content {
    flex: 1;
    min-height: calc(100vh - var(--navbar-height));
    background: linear-gradient(135deg, var(--surface-0) 0%, var(--surface-1) 50%, var(--surface-0) 100%);
}

.main-content main {
    padding: 2rem;
    max-width: 100%;
}

/* Layout for different page types */
.main-container {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    background: linear-gradient(to right, var(--surface-0), var(--surface-2), var(--surface-0));
    position: relative;
}

/* Interactive page specific: prevent page scrolling */
body.interactive-page {
    height: 100vh;
    overflow: hidden;
}

body.interactive-page .main-container {
    height: calc(100vh - var(--navbar-height));
    max-height: calc(100vh - var(--navbar-height));
    min-height: calc(100vh - var(--navbar-height));
    overflow: hidden;
}

.data-view {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--navbar-height));
    overflow: hidden;
}

/* Data Display */
.data-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem;  /* Reduced from 1rem 1.5rem */
    border-bottom: 1px solid var(--border);
    background-color: var(--dark-secondary);
    margin-bottom: 1.25rem;     /* Reduced from 1.5rem */
    border-radius: 8px;
}

.data-title {
    font-size: 1.25rem;         /* Reduced from 1.35rem */
    margin: 0;
    font-weight: 600;
    color: var(--text);
}

.data-stats {
    display: flex;
    gap: 2.5rem;              /* Even more spacing for better visual separation */
    margin-left: 2rem;        /* Consistent spacing */
    align-items: center;      /* Center align items */
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: fit-content;   /* Ensure stats don't get crushed */
    white-space: nowrap;      /* Prevent text wrapping */
    padding: 0.5rem 0.75rem;  /* Add padding for better visual presence */
    border-radius: 8px;       /* Subtle rounded corners */
    background: rgba(99, 102, 241, 0.05); /* Very subtle background */
    transition: all 0.2s ease; /* Smooth transition */
}

.stat-item:hover {
    background: rgba(99, 102, 241, 0.1); /* Slightly more visible on hover */
    transform: translateY(-1px); /* Subtle lift effect */
}

.stat-value {
    font-size: 1.5rem;        /* Increased for better prominence */
    font-weight: 700;
    color: var(--primary) !important;
    line-height: 1.1;         /* Tighter line spacing for numbers */
    margin-bottom: 0.1rem;    /* Small gap before label */
}

.stat-label {
    font-size: 0.75rem;       /* Slightly smaller for better proportion */
    color: var(--text-light) !important;
    font-weight: 600;         /* Increased weight for better visibility */
    text-transform: uppercase; /* Make labels more prominent */
    letter-spacing: 0.5px;    /* Better letter spacing */
}

/* Grid Styling */
.grid-container {
    flex: 1;
    height: 100%;
    width: 100%;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    z-index: 1;
}

/* Ensure dropdowns appear above AG Grid */
.dropdown-menu {
    z-index: 10001 !important;
}

/* Force AG Grid to have lower z-index */
.ag-theme-alpine,
.ag-root-wrapper,
.ag-root,
.ag-body,
.ag-body-viewport {
    z-index: 1 !important;
}

/* AG Grid Custom Styling - Clean Dark Theme */
.ag-theme-alpine {
    /* Main colors - matching your dark theme */
    --ag-foreground-color: var(--text);
    --ag-background-color: var(--surface-2);
    --ag-header-foreground-color: var(--text);
    --ag-header-background-color: var(--surface-3);
    --ag-odd-row-background-color: var(--surface-2);
    --ag-even-row-background-color: var(--surface-2); /* Same as odd rows - no stripes */
    
    /* Borders and separators */
    --ag-header-column-separator-color: var(--border);
    --ag-border-color: var(--border);
    --ag-row-border-color: var(--border);
    
    /* Selection and focus colors */
    --ag-selected-row-background-color: rgba(106, 53, 216, 0.2);
    --ag-row-hover-color: rgba(106, 53, 216, 0.1);
    
    /* Font settings */
    --ag-font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --ag-font-size: 13px;
    --ag-font-weight: 500;
    
    /* Spacing and sizing */
    --ag-cell-horizontal-padding: 0.75rem;
    --ag-header-column-resize-handle-height: 50%;
    --ag-header-column-resize-handle-width: 3px;
    --ag-grid-size: 6px;
    --ag-row-height: 40px;
    --ag-header-height: 45px;
    
    /* Scrollbar colors */
    --ag-scrollbar-track-color: var(--surface-1);
    --ag-scrollbar-thumb-color: var(--border);
    --ag-scrollbar-thumb-hover-color: var(--primary);
}

/* Header styling */
.ag-header-row {
    font-weight: 600;
}

.ag-header-cell-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.ag-header-cell {
    border-bottom: 2px solid var(--border) !important;
}

/* Cell styling */
.ag-cell {
    color: var(--text) !important;
    font-weight: 500 !important;
}

.ag-cell span {
    color: var(--text) !important;
}

/* Remove quality indicator dots */
.ag-cell .quality-indicator {
    display: none !important; /* Hide the colored dots */
}

/* Ensure text takes up remaining space and is centered */
.ag-cell > span {
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: normal;
}

/* Red highlight for missing data cells - based on existing HTML structure */
.ag-cell .quality-indicator.missing + span,
.ag-cell .quality-indicator.warning + span {
    color: #fca5a5 !important; /* Lighter red text for missing data */
}

.ag-cell:has(.quality-indicator.missing),
.ag-cell:has(.quality-indicator.warning) {
    background-color: rgba(239, 68, 68, 0.2) !important; /* Light red background */
}

/* Fallback for browsers that don't support :has() */
.ag-cell .quality-indicator.missing {
    background-color: rgba(239, 68, 68, 0.2) !important;
}

.ag-cell .quality-indicator.warning {
    background-color: rgba(239, 68, 68, 0.2) !important;
}

/* Row styling - Force all rows to same dark color */
.ag-row {
    background-color: var(--surface-2) !important;
}

.ag-row.ag-row-even {
    background-color: var(--surface-2) !important; /* Force same as odd rows */
}

.ag-row.ag-row-odd {
    background-color: var(--surface-2) !important; /* Force same color */
}

/* Override AG Grid's built-in alternating colors */
.ag-theme-alpine .ag-row {
    background-color: var(--surface-2) !important;
}

.ag-theme-alpine .ag-row.ag-row-even {
    background-color: var(--surface-2) !important;
}

.ag-theme-alpine .ag-row.ag-row-odd {
    background-color: var(--surface-2) !important;
}

/* Row hover effect */
.ag-row:hover {
    background-color: rgba(106, 53, 216, 0.1);
}

/* Row with Issues */
.row-with-issues {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Selection styling */
.ag-row.ag-row-selected {
    background-color: rgba(106, 53, 216, 0.2);
}

/* Fix all remaining white areas in AG Grid */
.ag-theme-alpine .ag-root-wrapper,
.ag-theme-alpine .ag-root,
.ag-theme-alpine .ag-body,
.ag-theme-alpine .ag-body-viewport,
.ag-theme-alpine .ag-body-viewport-wrapper,
.ag-theme-alpine .ag-center-cols-clipper,
.ag-theme-alpine .ag-center-cols-container,
.ag-theme-alpine .ag-center-cols-viewport,
.ag-theme-alpine .ag-center-cols-viewport-wrapper {
    background-color: var(--surface-2) !important;
}

/* Fix header background */
.ag-theme-alpine .ag-header,
.ag-theme-alpine .ag-header-container,
.ag-theme-alpine .ag-header-row {
    background-color: var(--surface-3) !important;
}

/* Fix any remaining white borders or backgrounds */
.ag-theme-alpine .ag-cell,
.ag-theme-alpine .ag-cell-wrapper,
.ag-theme-alpine .ag-cell-value {
    background-color: transparent !important;
}

/* Fix pagination panel background */
.ag-theme-alpine .ag-paging-panel {
    background-color: var(--surface-2) !important;
    color: var(--text) !important;
}

/* Selection styling */
.ag-row.ag-row-selected {
    background-color: rgba(106, 53, 216, 0.2) !important;
}

.ag-row.ag-row-selected .ag-cell {
    color: var(--text) !important; /* Use your original text color */
}

/* Pagination styling */
.ag-paging-panel {
    background-color: var(--surface-2);
    border-top: 1px solid var(--border);
    color: var(--text);
}

.ag-paging-button {
    background-color: var(--surface-3);
    border: 1px solid var(--border);
    color: var(--text);
}

.ag-paging-button:hover {
    background-color: var(--primary);
    color: white;
}

.ag-paging-button:disabled {
    background-color: var(--surface-1);
    color: var(--text-muted);
    opacity: 0.5;
}

/* Filter panel styling */
.ag-filter-toolpanel-header {
    background-color: var(--surface-3);
    color: var(--text);
}

.ag-filter-toolpanel-header .ag-filter-toolpanel-header-title {
    color: var(--text);
}

/* Tooltip styling */
.ag-tooltip {
    background-color: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

/* Context menu styling */
.ag-menu {
    background-color: var(--surface-3);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.ag-menu-option {
    color: var(--text);
}

.ag-menu-option:hover {
    background-color: var(--primary);
    color: white;
}

/* Column resize handle */
.ag-header-column-resize-handle {
    background-color: var(--primary);
}

/* Loading overlay */
.ag-overlay-loading-wrapper {
    background-color: rgba(15, 23, 42, 0.8);
    color: var(--text);
}

/* Data type pill styling for headers */
.data-type-pill {
    background-color: var(--surface-1);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 8px;
    display: inline-block;
    border: 1px solid var(--border);
}

/* Debug: Add a subtle border to see cell boundaries */
.ag-theme-alpine .ag-cell {
    border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Hide all quality indicators */
.ag-theme-alpine .quality-indicator {
    display: none !important;
}

.ag-theme-alpine .quality-indicator.good,
.ag-theme-alpine .quality-indicator.warning,
.ag-theme-alpine .quality-indicator.missing {
    display: none !important;
}

/* Buttons */
.btn {
    border-radius: 6px;
    font-weight: 500;
    padding: 0.4rem 0.9rem;  /* Reduced from 0.5rem 1rem */
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;             /* Reduced from 0.5rem */
}

.btn i {
    font-size: 1em;          /* Reduced from 1.1em */
}

/* Updated primary button with new color scheme */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.12);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

.btn-secondary:hover, .btn-secondary:focus {
    background-color: var(--secondary-dark);
    border-color: var(--secondary-dark);
}

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

/* Outline button variants */
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
    background-color: transparent;
}

.btn-outline-primary:hover, .btn-outline-primary:focus {
    background-color: var(--primary);
    color: white;
}

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

.btn-outline-secondary:hover, .btn-outline-secondary:focus {
    background-color: var(--secondary);
    color: white;
}

/* Data Quality Indicators */
.quality-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.quality-good {
    background-color: var(--success);
}

.quality-warning {
    background-color: var(--warning);
}

.quality-error {
    background-color: var(--danger);
}

/* Upload Container */
.upload-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* File Upload Area */
.file-drop-area {
    max-width: 850px;
    width: 90%;
    min-height: 400px;
    padding: 4rem 2rem;
    border: 2px dashed var(--bs-border-color-translucent);
    border-radius: 0.75rem;
    text-align: center;
    background-color: var(--bs-tertiary-bg);
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.file-drop-area:hover {
    background-color: var(--bs-secondary-bg);
    border-color: var(--bs-primary);
}

.file-drop-area.highlight {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    border-color: var(--bs-primary);
}

.file-drop-area i {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
}

.file-drop-area h4 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.file-drop-area p {
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.file-drop-area button {
    padding: 0.75rem 1.75rem;
    font-size: 1.1rem;
}

.upload-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.upload-subtitle {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    color: var(--text-muted);
}

/* Chat Interface */
.chat-view {
    background-color: var(--light);
    border-left: 1px solid var(--border);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.chat-header h5 {
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.chat-header p {
    font-size: 0.9rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    position: relative; /* Needed for positioning */
    scroll-behavior: smooth; /* Smooth scrolling */
    min-height: 0; /* Allow flex shrinking */
    background: var(--light);
}

.message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    max-width: 90%;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.message:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.message.user {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: var(--text);
    align-self: flex-end;
    border-bottom-right-radius: 0;
}

.message.system {
    background: linear-gradient(135deg, var(--surface-1), var(--surface-2));
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 0;
}

.message.system.explanation {
    background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
    border: 1px solid var(--primary-light);
    border-left: 4px solid var(--primary);
    color: var(--text);
}

.message.error-message {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05)) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    border-left: 4px solid var(--danger) !important;
    color: #fecaca !important;
}

.message.error-message .message-header i {
    color: var(--danger) !important;
}

.explanation-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--bs-info);
}

.chat-form {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background-color: var(--surface-1);
    position: relative;
    z-index: 2;
}

.chat-form::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to top, var(--light), transparent);
    pointer-events: none;
    z-index: 1;
}

.chat-form textarea {
    resize: none;
    height: 80px;
    border-color: var(--border);
    background-color: var(--light);
    color: var(--text);
    padding-right: 65px;
}

.chat-form button {
    height: calc(80px - 1rem);
    width: 50px;
}

/* Badges for chat suggestions */
.badge {
    font-weight: 500;
    font-size: 0.8rem;
    opacity: 0.9;
    transition: all 0.2s ease;
    cursor: pointer;
    background-color: var(--dark-surface) !important;
    color: var(--text-light) !important;
}

.badge:hover {
    opacity: 1;
    transform: translateY(-1px);
    background-color: var(--primary) !important;
    color: white !important;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spinner-border {
    color: var(--primary);
    width: 3rem;
    height: 3rem;
}

.loading-text {
    margin-top: 1rem;
    color: var(--text);
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 992px) {
    .main-container {
        flex-direction: column;
    }
    
    .chat-view {
        width: 100%;
        height: 350px;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    
    .data-view {
        height: auto;
    }
    
    .grid-container {
        height: 500px;
    }
    
    /* Interactive page mobile: ensure no scrolling */
    body.interactive-page .main-container {
        height: calc(100vh - var(--navbar-height));
        max-height: calc(100vh - var(--navbar-height));
        overflow: hidden;
    }
    
    body.interactive-page .data-view {
        height: calc(60vh - var(--navbar-height));
        min-height: 0;
    }
    
    body.interactive-page .chat-view {
        height: calc(40vh);
        max-height: calc(40vh);
    }
}

@media (max-width: 768px) {
    .data-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .data-toolbar > div:first-child {
        width: 100%;
        justify-content: center; /* Center the title and stats */
    }
    
    .data-toolbar > div:last-child {
        align-self: center;      /* Center the buttons */
    }
    
    .data-stats {
        margin-left: 0;
        gap: 1rem;              /* Reduced gap for mobile */
    }
    
    .stat-item {
        padding: 0.4rem 0.6rem; /* Smaller padding on mobile */
    }
    
    .stat-value {
        font-size: 1.3rem;      /* Slightly smaller on mobile */
    }
    
    .stat-label {
        font-size: 0.7rem;      /* Smaller label on mobile */
    }
}

@media (max-width: 480px) {
    .data-stats {
        gap: 0.75rem;           /* Even smaller gap for very small screens */
    }
    
    .stat-item {
        padding: 0.3rem 0.5rem; /* Even smaller padding */
    }
    
    .stat-value {
        font-size: 1.2rem;      /* Smaller value text */
    }
    
    .stat-label {
        font-size: 0.65rem;     /* Smaller label text */
        letter-spacing: 0.3px;  /* Reduced letter spacing */
    }
} 

/* Additional styles for dark mode */
.form-control::placeholder {
    color: var(--text-light);
    opacity: 0.6;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-dark {
    color: var(--text) !important;
}

/* Make background elements dark */
.bg-light {
    background-color: var(--dark-surface) !important;
}

/* Theme Toggle */
#theme-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

#theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Connection Status Indicator */
.connection-status {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 10px;
    position: relative;
}

.connection-status::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid transparent;
    animation: none;
}

.connection-status.connected {
    background-color: #28a745;
}

.connection-status.disconnected {
    background-color: #dc3545;
}

.connection-status.connecting {
    background-color: #ffc107;
}

.connection-status.connecting::after {
    border-color: #ffc107;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Card styling */
.card {
    background-color: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 1.5rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: var(--surface-1);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    border-top-left-radius: 7px; /* Account for border */
    border-top-right-radius: 7px;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background-color: var(--surface-1);
    border-top: 1px solid var(--border);
    padding: 1rem 1.25rem;
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
}

/* Base layout for sidebar navigation */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar styles */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: linear-gradient(to bottom, var(--surface-0), var(--surface-2));
    border-right: 1px solid var(--border);
    transition: width 0.3s ease;
    overflow-x: hidden;
    z-index: 1030;
    display: flex;
    flex-direction: column;
}

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

.sidebar-header {
    padding: 18px;  /* Reduced from 24px */
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    color: white;
    font-weight: 600;
    font-size: 1.15rem;  /* Reduced from 1.25rem */
    text-decoration: none;
}

.sidebar-logo i {
    margin-right: 10px;  /* Reduced from 12px */
    font-size: 1.4rem;   /* Reduced from 1.5rem */
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.sidebar-toggle:hover {
    background-color: var(--surface-3);
    color: var(--text);
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
}

.sidebar-nav {
    padding: 16px 0;
}

.sidebar-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 18px;  /* Reduced from 12px 24px */
    color: var(--text-light);
    text-decoration: none;
    transition: background-color 0.2s;
    margin-bottom: 4px;
    height: 42px;  /* Reduced from 46px */
}

.sidebar-nav-item:hover {
    background-color: var(--surface-3);
    color: var(--text);
}

.sidebar-nav-item.active {
    color: var(--text);
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    border-left: 3px solid var(--primary);
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background-color: var(--primary);
}

.sidebar-nav-item i {
    margin-right: 12px;  /* Reduced from 16px */
    font-size: 16px;    /* Reduced from 18px */
    width: 20px;       /* Reduced from 24px */
    text-align: center;
}

.sidebar-nav-item .nav-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.3s;
}

.sidebar.collapsed .sidebar-nav-item .nav-text {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .sidebar-logo span {
    opacity: 0;
    width: 0;
    display: none;
}

.sidebar.collapsed .sidebar-logo i {
    margin-right: 0;
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

.sidebar-footer {
    padding: 12px 18px;  /* Reduced from 16px 24px */
    border-top: 1px solid var(--border);
    font-size: 0.75rem;  /* Reduced from 0.8rem */
    color: var(--text-muted);
}

/* Tooltip for collapsed sidebar */
.sidebar-nav-item .tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--surface-3);
    color: var(--text);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

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

/* Adjust main content when sidebar is present */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
    min-height: 100vh;
    padding: 0 10px;  /* Add padding to main content */
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed);
    width: calc(100% - var(--sidebar-collapsed));
}

@media (min-width: 992px) {
    .main-content {
        padding: 0 20px;  /* More padding on larger screens */
    }
    
    .container {
        max-width: 1240px;  /* Slightly wider container */
    }
}

/* Mobile sidebar adjustments */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    }
    
    .sidebar.mobile-visible {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1025;
        display: none;
    }
    
    .sidebar-overlay.visible {
        display: block;
    }
}

/* Mobile button to show sidebar */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background-color: var(--primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    z-index: 1020;
    align-items: center;
    justify-content: center;
}

@media (max-width: 992px) {
    .mobile-sidebar-toggle {
        display: flex;
    }
}

/* Interactive page connection enhancements */
/* Create a shared visual background and connection between data and chat */
.main-container {
    position: relative;
    background: linear-gradient(to right, var(--surface-0), var(--surface-2), var(--surface-0));
}

/* Visual connector between data grid and chat */
.data-chat-connector {
    position: absolute;
    top: 50%;
    right: 350px; /* Align with left edge of chat panel */
    width: 16px;
    height: 80px;
    background: linear-gradient(90deg, transparent, var(--primary-light));
    opacity: 0.4;
    border-radius: 4px 0 0 4px;
    transform: translateY(-50%);
    pointer-events: none; /* Don't block interactions */
    z-index: 5;
}

/* Create pulsing effect for the send button when input has content */
.send-ready {
    animation: pulse-send 2s infinite;
}

@keyframes pulse-send {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--bs-primary-rgb), 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(var(--bs-primary-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--bs-primary-rgb), 0);
    }
}

/* Data highlighting effect when chat mentions columns */
.highlight-column {
    background-color: rgba(var(--bs-primary-rgb), 0.15) !important;
    color: #000000 !important; /* Changed from var(--primary-light) to black */
    font-weight: 600 !important;
}

/* Ensure text in highlighted columns remains black */
.highlight-column .ag-cell,
.highlight-column .ag-cell span {
    color: #000000 !important;
}

/* Message header styling */
.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* flex-wrap: wrap; */
    max-width: 100%;
}

.message-time {
    opacity: 0.7;
    font-size: 0.7rem;
}

/* Typing indicator animation */
.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 4px 0;
}

.typing-indicator .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-light);
    margin-right: 4px;
    animation: typing-bounce 1.4s infinite ease-in-out;
    opacity: 0.7;
}

.typing-indicator .dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* Processing message style */
.message.processing {
    background: linear-gradient(135deg, var(--dark-surface), var(--surface-1));
    border: 1px dashed var(--border);
    position: relative; /* Ensure proper position in flow */
}

/* Column highlighting */
.highlight-column {
    background-color: rgba(var(--bs-primary-rgb), 0.15) !important;
    border-bottom: 2px solid var(--bs-primary) !important;
}

.highlight-cell {
    background-color: rgba(var(--ag-selected-row-background-color-rgb), 0.3); /* Example: Light blue */
    /* animation: cell-highlight 1.5s ease-out; */
}

.column-highlighted-header {
    background-color: rgba(var(--bs-primary-rgb), 0.2) !important; /* Example: light primary color */
    transition: background-color 0.3s ease;
}

.column-highlighted-cell {
    background-color: rgba(var(--bs-warning-rgb), 0.15) !important; /* Example: light warning color */
    font-weight: bold;
    transition: background-color 0.3s ease;
}

@keyframes cell-highlight {
    0% { background-color: rgba(var(--ag-selected-row-background-color-rgb), 0.7); }
    100% { background-color: transparent; }
}

/* Undo / Redo Button Styling */
#undoBtn,
#redoBtn {
    background-color: var(--primary); /* Use primary purple color */
    color: var(--text); /* Ensure text is light for contrast */
    border: 1px solid var(--primary-dark); /* Border to match */
    padding: 0.5rem 1rem; /* Increased padding */
    min-width: 90px; /* Minimum width to help text fit */
    border-radius: 0.375rem; 
    font-size: 0.85rem; /* Slightly smaller font if needed, or adjust min-width */
    line-height: 1.4;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, color 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center; /* Center content */
    gap: 0.4rem; 
    cursor: pointer;
    text-align: center;
}

#undoBtn:hover,
#redoBtn:hover {
    background-color: var(--primary-dark); /* Darker purple on hover */
    border-color: var(--primary);
    color: var(--text);
}

#undoBtn:disabled,
#redoBtn:disabled {
    background-color: var(--surface-1);
    color: var(--text-muted);
    border-color: var(--surface-2);
    cursor: not-allowed;
    opacity: 0.6; /* Standard opacity for disabled */
}

#undoBtn i,
#redoBtn i {
    font-size: 0.9em; 
    margin-right: 2px; /* Ensure a bit of space if gap isn't enough for icon centering */
}

/* Code Viewer Button Styling */
.code-viewer-btn {
    font-size: 0.85rem !important;
    padding: 0.35rem 0.9rem !important;
    border: 1px solid var(--info) !important;
    color: var(--info-dark, #0dcaf0) !important;
    background: var(--info-light, #e7f7fd) !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
    line-height: 1.2 !important;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.code-viewer-btn:hover {
    background: var(--info, #0dcaf0) !important;
    color: white !important;
    border-color: var(--info-dark, #0dcaf0) !important;
    transform: translateY(-1px);
}

.code-viewer-btn i {
    font-size: 0.8rem;
}

/* Reasoning Viewer Button Styling */
.reasoning-viewer-btn {
    font-size: 0.85rem !important;
    padding: 0.35rem 0.9rem !important;
    border: 1px solid var(--info) !important;
    color: var(--info-dark, #0dcaf0) !important;
    background: var(--info-light, #e7f7fd) !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
    line-height: 1.2 !important;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.reasoning-viewer-btn:hover {
    background: var(--info, #0dcaf0) !important;
    color: white !important;
    border-color: var(--info-dark, #0dcaf0) !important;
    transform: translateY(-1px);
}

.reasoning-viewer-btn i {
    font-size: 0.8rem;
}

/* Ensure code and reasoning buttons are visually aligned */
.code-viewer-btn, .reasoning-viewer-btn {
    min-width: 90px;
    text-align: center;
    box-sizing: border-box;
    flex: 0 1 auto;
    max-width: 100%;
}

/* Code Modal Styling */
#codeViewerModal .modal-content {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
}

#codeViewerModal .modal-header {
    background: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

#codeViewerModal pre {
    background: var(--surface-1) !important;
    border: 1px solid var(--bs-border-color) !important;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
}

#codeViewerModal code {
    color: var(--text) !important;
    background: transparent !important;
}

/* Explanation header improvements */
.explanation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Upload Progress Bar Styles */
.upload-progress-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: rgba(0, 0, 0, 0.9) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 999999 !important;
    transition: none !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.upload-progress-container {
    background-color: var(--surface-2);
    border-radius: 12px;
    padding: 2rem;
    min-width: 400px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

.upload-progress-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.upload-progress-header .upload-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

.upload-progress-header h5 {
    margin: 0;
    color: var(--text);
    font-weight: 600;
}

.upload-progress-header small {
    color: var(--text-muted);
    font-size: 0.85rem;
    word-break: break-all;
}

.upload-progress-bar-container {
    position: relative;
    margin-bottom: 1rem;
}

.upload-progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--surface-3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
    animation: progress-glow 2s ease-in-out infinite alternate;
}

@keyframes progress-glow {
    0% { box-shadow: 0 0 5px rgba(106, 53, 216, 0.3); }
    100% { box-shadow: 0 0 15px rgba(106, 53, 216, 0.6); }
}

.upload-progress-text {
    text-align: center;
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
}

.upload-progress-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.upload-progress-details span {
    color: var(--text-muted);
    font-size: 0.85rem;
}

#uploadSpeed {
    color: var(--secondary);
    font-weight: 500;
}

#uploadTimeLeft {
    color: var(--accent);
    font-weight: 500;
}

@media (max-width: 768px) {
    .upload-progress-container {
        min-width: 300px;
        padding: 1.5rem;
    }
    
    .upload-progress-details {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
} 

/* --- Datneat Channels Page Fixes (force white background, fix grid) --- */
body, .channels-page, .main-content, .container {
    background: #fff !important;
    background-color: #fff !important;
}

.channels-page .container {
  max-width: 100vw !important;
  width: 100vw !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

/* --- Datneat Channels Page: 2-column grid for channel cards --- */
.channels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
}

.channel-card {
  width: 100%;
  margin: 0;
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
}

@media (max-width: 700px) {
  .channels-grid {
    grid-template-columns: 1fr;
    max-width: 98vw;
    gap: 1.2rem;
  }
}

.loading-overlay {
    display: none !important;
} 