/* ========================================
   AI Data Analyser - Premium Dashboard Styles
   Modern, Dark Theme with Glassmorphism
   ======================================== */

/* CSS Custom Properties */
:root {
    /* Colors - Dark Theme */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-glass: rgba(30, 41, 59, 0.5);

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accent Colors */
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --accent-glow: rgba(99, 102, 241, 0.3);

    /* Status Colors */
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --info: #06b6d4;

    /* Borders */
    --border-color: rgba(148, 163, 184, 0.1);
    --border-hover: rgba(148, 163, 184, 0.2);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px var(--accent-glow);

    /* Spacing */
    --sidebar-width: 280px;
    --chat-width: 360px;
    --header-height: 70px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ========================================
   Sidebar Styles
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 22px;
    height: 22px;
    color: white;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* API Key Input */
.api-key-input {
    display: flex;
    gap: 8px;
}

.api-key-input input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    transition: var(--transition-fast);
}

.api-key-input input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.api-key-input input::placeholder {
    color: var(--text-muted);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--success);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-base);
}

.upload-area:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-area.dragover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    color: var(--text-muted);
}

.upload-icon svg {
    width: 100%;
    height: 100%;
}

.upload-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* File Info */
.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.file-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon svg {
    width: 18px;
    height: 18px;
    color: white;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-stats {
    font-size: 11px;
    color: var(--text-muted);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.action-btn:hover:not(:disabled) {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
}

/* ========================================
   Main Content Styles
   ======================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.main-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.stats-pills {
    display: flex;
    gap: 12px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 13px;
}

.stat-pill .value {
    font-weight: 600;
    color: var(--text-primary);
}

.stat-pill .label {
    color: var(--text-muted);
}

/* Welcome State */
.welcome-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.welcome-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

.welcome-content h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
}

.welcome-content p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.feature-highlights {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    transition: var(--transition-base);
}

.feature:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.feature-icon {
    font-size: 28px;
}

.feature span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Dashboard Content */
.dashboard-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 30px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    backdrop-filter: blur(10px);
    transition: var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 20px;
}

.stat-card .stat-icon.purple {
    background: rgba(139, 92, 246, 0.2);
}

.stat-card .stat-icon.blue {
    background: rgba(59, 130, 246, 0.2);
}

.stat-card .stat-icon.green {
    background: rgba(34, 197, 94, 0.2);
}

.stat-card .stat-icon.orange {
    background: rgba(249, 115, 22, 0.2);
}

.stat-card .stat-icon.pink {
    background: rgba(236, 72, 153, 0.2);
}

.stat-card .stat-icon.cyan {
    background: rgba(6, 182, 212, 0.2);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Section Card */
.section-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    backdrop-filter: blur(10px);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
}

.section-header h2 svg {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-ai {
    background: var(--accent-gradient);
    color: white;
}

/* Insights Section */
.insights-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.insight-summary {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-primary);
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.insight-card {
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.insight-card h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.insight-card ul {
    list-style: none;
}

.insight-card li {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.insight-card li:last-child {
    border-bottom: none;
}

.insight-card li::before {
    content: "•";
    color: var(--accent-primary);
    font-weight: bold;
}

/* Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.chart-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.chart-card .chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.chart-container {
    width: 100%;
    height: 300px;
}

/* Data Table Section */
.table-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.table-controls span {
    font-size: 13px;
    color: var(--text-muted);
}

/* Table Search Input */
.table-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    transition: var(--transition-fast);
}

.table-search:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.table-search svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.table-search input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    width: 150px;
}

.table-search input::placeholder {
    color: var(--text-muted);
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 450px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
}

.data-table td {
    color: var(--text-secondary);
}

.data-table tr:hover td {
    background: rgba(99, 102, 241, 0.05);
}

/* ========================================
   Chat Panel Styles
   ======================================== */
.chat-panel {
    width: var(--chat-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.chat-title svg {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.message.user .message-avatar {
    background: var(--accent-gradient);
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.5;
}

.message.assistant .message-content {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-bottom-left-radius: 4px;
}

.message.user .message-content {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 16px;
}

.message-content li {
    margin: 4px 0;
    color: var(--text-muted);
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* Chat Input */
.chat-input-container {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    transition: var(--transition-fast);
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
}

.chat-input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.chat-input-wrapper textarea:disabled {
    opacity: 0.5;
}

.send-btn {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* ========================================
   Utility Classes & Components
   ======================================== */

/* Buttons */
.btn-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.btn-icon:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-icon.btn-danger:hover {
    border-color: var(--error);
    color: var(--error);
}

.btn-secondary {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary svg {
    width: 16px;
    height: 16px;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s ease;
    min-width: 280px;
    max-width: 400px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.toast.info {
    border-left: 3px solid var(--info);
}

.toast-icon {
    font-size: 18px;
}

.toast-message {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive Adjustments */
@media (max-width: 1400px) {
    .chat-panel {
        width: 320px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .sidebar {
        width: 240px;
    }

    .chat-panel {
        position: fixed;
        right: -100%;
        top: 0;
        height: 100vh;
        width: 360px;
        z-index: 100;
        transition: var(--transition-base);
    }

    .chat-panel.open {
        right: 0;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 100;
        transition: var(--transition-base);
    }

    .sidebar.open {
        left: 0;
    }

    .dashboard-content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .main-header {
        padding: 16px;
    }

    .main-header h1 {
        font-size: 20px;
    }

    .stats-pills {
        display: none;
    }
}

/* ========================================
   Chat Result Display Styles
   ======================================== */

/* Result Value Card - for single values */
.result-value-card {
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin: 12px 0;
    text-align: center;
}

.result-value {
    font-size: 32px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Result Table Container */
.result-table-container {
    margin: 12px 0;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.result-table th,
.result-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.result-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.result-table td {
    color: var(--text-secondary);
}

.result-table tr:hover td {
    background: rgba(99, 102, 241, 0.08);
}

.result-table tr:last-child td {
    border-bottom: none;
}

.null-value {
    color: var(--text-muted);
    font-style: italic;
}

.table-info {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    margin: 0;
}

/* Success/Error Messages in Chat */
.success-msg {
    color: var(--success);
    font-size: 13px;
    padding: 8px 12px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

.error-msg {
    color: var(--error);
    font-size: 13px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

/* Chart Message in Chat */
.chart-message .message-content {
    max-width: 95%;
}

.chart-content {
    width: 100%;
}

.chart-title-text {
    margin-bottom: 8px;
}

.chat-chart {
    width: 100%;
    min-height: 250px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* Enhanced Message Content */
.message-content code {
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
    font-size: 11px;
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* ========================================
   Floating Chat Button (FAB)
   ======================================== */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-base);
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.5);
}

.chat-fab svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: var(--transition-fast);
}

.chat-fab .fab-icon-close {
    position: absolute;
}

.chat-fab.open .fab-icon-chat {
    opacity: 0;
    transform: rotate(90deg);
}

.chat-fab.open .fab-icon-close {
    opacity: 1;
    transform: rotate(0);
}

.chat-fab:not(.open) .fab-icon-close {
    opacity: 0;
    transform: rotate(-90deg);
}

.fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--error);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   Chat Popup Window
   ======================================== */
.chat-popup {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 550px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
}

.chat-popup.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.chat-popup-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-popup-avatar {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-popup-info {
    display: flex;
    flex-direction: column;
}

.chat-popup-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-popup-status {
    font-size: 12px;
    color: var(--success);
}

.chat-popup-actions {
    display: flex;
    gap: 8px;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.btn-icon-sm:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-icon-sm svg {
    width: 16px;
    height: 16px;
}

.chat-popup-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-popup-input {
    display: flex;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.chat-popup-input textarea {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    transition: var(--transition-fast);
}

.chat-popup-input textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-popup-input textarea:disabled {
    opacity: 0.5;
}

.chat-popup-input .send-btn {
    width: 42px;
    height: 42px;
}

/* Main content full width when chat is popup */
.main-content.full-width {
    flex: 1;
}

/* ========================================
   Download Preview Modal
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-base);
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.95);
    transition: var(--transition-base);
}

.modal-overlay.visible .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-header h3 svg {
    width: 22px;
    height: 22px;
    color: var(--accent-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.preview-info {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.preview-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-info-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-info-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.preview-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    max-height: 300px;
    overflow-y: auto;
}

.preview-table {
    min-width: 100%;
    width: max-content;
    border-collapse: collapse;
    font-size: 13px;
}

.preview-table th,
.preview-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.preview-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
}

.preview-table td {
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-primary svg {
    width: 18px;
    height: 18px;
}

/* Action buttons in chat */
.chat-action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.chat-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.chat-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.chat-action-btn.secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.chat-action-btn.secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: none;
}

.chat-action-btn svg {
    width: 14px;
    height: 14px;
}

/* Responsive adjustments for popup */
@media (max-width: 480px) {
    .chat-popup {
        width: calc(100% - 24px);
        right: 12px;
        bottom: 90px;
        height: 70vh;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}

/* ========================================
   Maximized Chat Popup
   ======================================== */
.chat-popup.maximized {
    width: 90vw;
    height: 85vh;
    max-width: 1200px;
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%) scale(1);
    border-radius: var(--radius-xl);
}

.chat-popup.maximized.visible {
    transform: translate(50%, 50%) scale(1);
}

.chat-popup.maximized .chat-popup-messages {
    padding: 24px;
    gap: 18px;
}

.chat-popup.maximized .message-content {
    max-width: 70%;
    padding: 16px 20px;
    font-size: 15px;
}

.chat-popup.maximized .chat-chart {
    min-height: 350px;
}

.chat-popup.maximized .result-table-container {
    max-height: 400px;
}

/* Icon toggle for maximize button */
#maximizeChat .icon-minimize {
    display: none;
}

#maximizeChat .icon-maximize {
    display: block;
}

.chat-popup.maximized~.chat-fab #maximizeChat .icon-maximize,
.chat-popup.maximized #maximizeChat .icon-maximize {
    display: none;
}

.chat-popup.maximized #maximizeChat .icon-minimize {
    display: block;
}

/* ========================================
   Result Widget with Toggle
   ======================================== */
.result-widget {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-top: 10px;
}

.result-toggle-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.result-toggle-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.result-toggle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.result-toggle-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.result-expand-btn {
    margin-left: auto;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.result-expand-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.result-view {
    display: none;
    padding: 12px;
}

.result-view.active {
    display: block;
}

.result-table-view .result-table-container {
    max-height: 200px;
    overflow-y: auto;
    overflow-x: auto;
}

.result-chart-view {
    padding: 8px;
}

.result-chart {
    width: 100%;
    min-height: 220px;
}

/* ========================================
   Modal View Toggle
   ======================================== */
.modal-view-toggle {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.modal-toggle-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.modal-toggle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.modal-toggle-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.modal-view {
    display: none;
}

.modal-view.active {
    display: block;
}

.modal-chart {
    width: 100%;
    min-height: 350px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    flex-wrap: wrap;
}