* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: auto;  /* Allow horizontal scroll when content is wider than window */
    position: relative;
    /* Optimize for laptop screens */
    font-size: clamp(14px, 1vw, 16px);  /* Responsive font sizing */
    /* Add subtle grid pattern overlay */
    background-image: 
        linear-gradient(135deg, #667eea 0%, #764ba2 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"><path d="M 20 0 L 0 0 0 20" fill="none" stroke="rgba(255,255,255,0.025)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    background-blend-mode: overlay;
}

/* Lucide icon base styles */
[data-lucide] {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
}

/* Button icons */
.button-icon [data-lucide] {
    width: 1rem;
    height: 1rem;
    margin-right: 0.25rem;
}

/* Menu icons */
.menu-icon [data-lucide] {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
}

/* Toggle icons */
.toggle-icon [data-lucide] {
    width: 1rem;
    height: 1rem;
}

/* Warning icons */
.warning-icon [data-lucide] {
    width: 0.875rem;
    height: 0.875rem;
    color: #f59e0b;
}

/* Utility classes to replace inline styles */
.hidden {
    display: none !important;
}

.flex-input-container {
    display: flex;
    gap: 0.5rem;
}

.flex-input {
    flex: 1;
}

.share-stats {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.share-stats-title {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #6c757d;
}

.share-stats-content {
    display: flex;
    gap: 2rem;
    font-size: 0.9rem;
}

.share-warning {
    margin-top: 1rem;
    padding: 1rem;
    background: #fff3cd;
    border-radius: 6px;
    border: 1px solid #ffeaa7;
}

.share-warning-text {
    font-size: 0.9rem;
    color: #856404;
}

/* Password Protection Indicators */
.password-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #d1edff;
    border: 1px solid #3b82f6;
    border-radius: 6px;
    color: #1e40af;
    font-size: 0.85rem;
    font-weight: 500;
}

.password-status i {
    width: 14px;
    height: 14px;
}

.password-status .text-link {
    background: none;
    border: none;
    color: #1e40af;
    cursor: pointer;
    font-size: 0.8rem;
    text-decoration: underline;
    padding: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.password-status .text-link:hover {
    color: #1d4ed8;
}

.password-status .text-link.remove {
    color: #dc2626;
}

.password-status .text-link.remove:hover {
    color: #b91c1c;
}

.password-indicator {
    color: #059669;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.password-indicator i {
    width: 14px;
    height: 14px;
}

.change-password-form {
    margin-top: 12px;
}

/* Improved Password Status Layout */
.password-status-improved {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #d1edff;
    border: 1px solid #3b82f6;
    border-radius: 6px;
    color: #1e40af;
    font-size: 0.85rem;
    font-weight: 500;
}

.password-status-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.password-status-content i {
    width: 14px;
    height: 14px;
}

.password-status-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.password-status-actions .text-link {
    background: none;
    border: none;
    color: #1e40af;
    cursor: pointer;
    font-size: 0.8rem;
    text-decoration: underline;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.password-status-actions .text-link:hover {
    color: #1d4ed8;
}

.password-status-actions .text-link.remove {
    color: #dc2626;
}

.password-status-actions .text-link.remove:hover {
    color: #b91c1c;
}

.template-description {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #6c757d;
}

.footer-copyright {
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

.login-footer-copyright {
    margin-top: 10px;
    font-size: 0.8rem;
}

/* Empty state icons */
.empty-icon [data-lucide] {
    width: 3rem;
    height: 3rem;
    color: #9ca3af;
}

/* Connect icons */
.connect-icon [data-lucide] {
    width: 3rem;
    height: 3rem;
    color: #667eea;
}

/* Spreadsheet icons */
.spreadsheet-icon [data-lucide] {
    width: 2rem;
    height: 2rem;
    color: #10b981;
}

/* Action buttons in tables */
.action-btn [data-lucide] {
    width: 0.875rem;
    height: 0.875rem;
}

.container {
    max-width: 95vw;  /* Use 95% of viewport width instead of fixed 1200px */
    min-width: 800px; /* Reduced minimum width for laptops - was 1200px */
    margin: 0 auto;
    padding: 1rem;  /* Use rem for better scaling */
    min-height: 100vh;
    /* Ensure container takes full screen on laptops */
    width: calc(100vw - 2rem); /* Account for padding */
    overflow: visible;  /* Ensure dropdowns can extend beyond container */
}

/* Modern Header Bar - Optimized for laptops */
.modern-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(25px);
    border-radius: 16px;
    padding: 0.5rem 1.5rem;  /* Further reduced padding */
    margin-bottom: 0.5rem;  /* Reduced margin */
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    min-height: 3rem;  /* Further reduced height */
    position: relative;  /* Create stacking context for dropdown */
    z-index: 1000;  /* Higher z-index to appear above all content */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;  /* Ensure dropdown can extend beyond header */
}

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

.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-icon [data-lucide] {
    width: 1.5rem;
    height: 1.5rem;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2c3e50;
    letter-spacing: -0.02em;
}

/* Main Navigation */
.main-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    text-decoration: none;  /* Remove underline from links */
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #374151;
    text-decoration: none;  /* Ensure no underline on hover */
}

.nav-btn.active {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    text-decoration: none;  /* Ensure no underline when active */
}

.nav-icon {
    font-size: 1rem;
}

.nav-icon [data-lucide] {
    width: 1rem;
    height: 1rem;
}

.nav-text {
    font-weight: inherit;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.05);
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.connected {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.status-dot.disconnected {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
}

.status-text {
    color: #6b7280;
}

.header-right {
    display: flex;
    align-items: center;
    overflow: visible;  /* Ensure dropdown can extend beyond */
}

.user-section {
    display: flex;
    align-items: center;
    gap: 16px;
    overflow: visible;  /* Ensure dropdown can extend beyond */
}

.user-name {
    color: #374151;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.user-menu-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 10;  /* Relative to header's stacking context */
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.875rem;
    color: #374151;
}

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

.dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.dropdown-icon {
    font-size: 1rem;
    opacity: 0.7;
}

/* Laptop-optimized responsive adjustments */
@media (max-width: 1366px) and (min-width: 1024px) {
    /* Specific optimizations for common laptop screens (1366x768, 1440x900) */
    .container {
        min-width: 900px;
        padding: 0.75rem;
    }
    
    .modern-header {
        padding: 0.5rem 1rem;
        min-height: 3rem;
    }
    
    .chat-container-full {
        height: calc(100vh - 140px);  /* Reduced from 180px */
        min-height: calc(75vh - 120px);  /* Increased minimum */
    }
    
    .explore-view {
        height: calc(100vh - 120px);  /* Reduced from 160px */
        min-height: calc(100vh - 140px);  /* Increased minimum */
    }
}

/* Tablet and smaller laptop screens */
@media (max-width: 1023px) {
    .modern-header {
        padding: 0.5rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
        min-height: auto;
        position: relative; /* Remove sticky on smaller screens */
    }
    
    .header-left {
        gap: 1rem;
    }
    
    .app-title {
        font-size: 1.1rem;
    }
    
    .connection-status {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
    
    .container {
        min-width: auto;
        width: 100vw;
        padding: 0.5rem;
    }
}

/* Mobile phones */
@media (max-width: 768px) {
    .modern-header {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .chat-container-full,
    .explore-view {
        height: calc(100vh - 120px);  /* Further optimized */
        min-height: calc(100vh - 140px);  /* Better minimum */
    }
}

.content-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 20px;  /* Reduced padding */
    margin-bottom: 0;  /* Remove bottom margin */
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.1),
        0 5px 15px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.connect-card {
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.connect-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.connect-card h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #1f2937;
}

.connect-card p {
    font-size: 1.1rem;
    color: #6b7280;
    margin-bottom: 30px;
}

.primary-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.secondary-button {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.secondary-button:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

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

.section-header h2 {
    margin: 0;
    color: #1f2937;
    font-size: 1.8rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #1f2937;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
    padding: 5px;
}

.close-button:hover {
    color: #374151;
}

.modal-body {
    padding: 20px 30px;
    flex: 1;
    overflow-y: auto;
}

/* Search container for modals */
.search-container {
    margin-bottom: 20px;
}

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

.search-input {
    width: 100%;
    padding: 12px 16px;
    padding-right: 45px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: white;
}

.search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-input::placeholder {
    color: #9ca3af;
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    color: #6b7280;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.search-clear-btn [data-lucide] {
    width: 16px;
    height: 16px;
}

.modal-footer {
    padding: 20px 0;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Delete Dashboard Modal Styles */
.delete-warning {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin-bottom: 20px;
}

.delete-warning .warning-icon {
    color: #dc2626;
    flex-shrink: 0;
    margin-top: 2px;
}

.delete-warning .warning-icon [data-lucide] {
    width: 24px;
    height: 24px;
}

.delete-warning .warning-content h4 {
    margin: 0 0 8px 0;
    color: #dc2626;
    font-size: 16px;
    font-weight: 600;
}

.delete-warning .warning-content p {
    margin: 4px 0;
    color: #374151;
}

.delete-warning .warning-text {
    color: #6b7280;
    font-size: 14px;
}

.btn-delete {
    background: #dc2626;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-delete:hover {
    background: #b91c1c;
}

.btn-delete:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #6b7280;
    font-style: italic;
}

/* Spreadsheet and Tab Selection */
.spreadsheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.spreadsheet-card {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.spreadsheet-card:hover {
    border-color: #667eea;
    background: #f8fafc;
    transform: translateY(-2px);
}

.spreadsheet-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.spreadsheet-info h4 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: #1f2937;
}

.spreadsheet-info p {
    margin: 0;
    color: #6b7280;
    font-size: 0.9rem;
}

.tab-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tab-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-checkbox:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.tab-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.tab-checkbox input[type="checkbox"]:checked + .checkmark + .tab-name {
    font-weight: 600;
    color: #667eea;
}

.tab-name {
    font-size: 1rem;
    color: #374151;
}

/* Connected Sources */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
}

.empty-state p {
    margin: 0;
    font-size: 1rem;
}

.error {
    text-align: center;
    padding: 40px;
    color: #dc2626;
    background: #fef2f2;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #6b7280;
    font-style: italic;
}

/* Sources Title Header (separate from table header) */
.sources-title-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sources-title-header h3 {
    margin: 0;
    color: #1f2937;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Streamlined Sources Table */
.sources-table {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.sources-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 120px;
    gap: 20px;
    padding: 15px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
}

.sources-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 120px;
    gap: 20px;
    padding: 15px 20px;
    border-bottom: 1px solid #f3f4f6;
    align-items: center;
    transition: background-color 0.2s;
}

.sources-row:hover {
    background: #f9fafb;
}

.sources-row:last-child {
    border-bottom: none;
}

.col-spreadsheet .spreadsheet-name {
    font-weight: 500;
    color: #1f2937;
    font-size: 0.95rem;
}

.col-tab .tab-name {
    color: #374151;
    font-size: 0.9rem;
}

.warning-icon {
    margin-left: 8px;
    font-size: 14px;
    cursor: help;
}

.col-stats .stats-text {
    color: #6b7280;
    font-size: 0.85rem;
}

.col-updated .update-time {
    color: #6b7280;
    font-size: 0.85rem;
}

.col-updated .update-time.expired {
    color: #dc2626;
    font-weight: 500;
}

.col-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.action-btn {
    background: none;
    border: 1px solid #e5e7eb;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.action-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: translateY(-1px);
}

.action-btn.preview-btn:hover {
    background: #eff6ff;
    border-color: #3b82f6;
}

.action-btn.refresh-btn:hover {
    background: #f0fdf4;
    border-color: #22c55e;
}

.action-btn.delete-btn:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

/* Chat Interface */
.chat-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    height: calc(100vh - 280px);  /* Dynamic height based on viewport */
    min-height: 400px;  /* Minimum height for usability */
    max-height: 70vh;   /* Maximum height to prevent overflow */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.1),
        0 5px 15px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.chat-messages {
    flex: 1;
    padding: 16px;  /* Reduced from 20px */
    overflow-y: auto;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;  /* Reduced from 15px */
}

.chat-message {
    max-width: 100%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.chat-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.chat-message.assistant {
    align-self: flex-start;
    background: white;
    border: 1px solid #e5e7eb;
    color: #374151;
}

.chat-message .message-time {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 4px;
}

/* Markdown content styling within chat messages */
.chat-message .message-content {
    line-height: 1.5;
}

.chat-message .message-content h1,
.chat-message .message-content h2,
.chat-message .message-content h3,
.chat-message .message-content h4,
.chat-message .message-content h5,
.chat-message .message-content h6 {
    margin: 8px 0 4px 0;
    font-weight: 600;
}

.chat-message .message-content h1 { font-size: 1.25rem; }
.chat-message .message-content h2 { font-size: 1.15rem; }
.chat-message .message-content h3 { font-size: 1.1rem; }
.chat-message .message-content h4,
.chat-message .message-content h5,
.chat-message .message-content h6 { font-size: 1rem; }

.chat-message .message-content p {
    margin: 6px 0;
}

.chat-message .message-content strong {
    font-weight: 600;
}

.chat-message .message-content em {
    font-style: italic;
}

.chat-message .message-content ul,
.chat-message .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-message .message-content li {
    margin: 2px 0;
}

.chat-message .message-content code {
    background: rgba(0, 0, 0, 0.08);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.chat-message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.chat-message .message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid #667eea;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.chat-message.user .message-content pre {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.chat-message .message-content blockquote {
    border-left: 3px solid #667eea;
    padding-left: 12px;
    margin: 8px 0;
    font-style: italic;
    opacity: 0.9;
}

.chat-message.user .message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
}

.chat-input-area {
    border-top: 1px solid #e5e7eb;
    padding: 20px;
    background: white;
}

.chat-input-container {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-send-btn:hover {
    transform: translateY(-1px);
}

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.chat-loading {
    align-self: flex-start;
    background: white;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    font-style: italic;
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
}

/* Chart styling within chat messages */
.chart-container {
    margin: 10px 0;
    padding: 15px;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.chat-message.assistant .chart-container {
    background: #f9fafb;
}

.chat-message.user .chart-container {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.chart-description {
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: #374151;
}

.chart-buttons {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.chart-action-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.chart-action-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Dropdown-style "Add to Dashboard" button styles */
.chart-dropdown-container {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.chart-dropdown-container:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.dropdown-add-btn {
    border-radius: 0;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    margin: 0;
    border: none;
    padding: 8px 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.dropdown-add-btn:hover {
    transform: none;
    box-shadow: none;
}

.dropdown-dashboard-btn {
    border-radius: 0;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    margin: 0;
    border: none;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.dropdown-dashboard-btn:hover {
    transform: none;
    box-shadow: none;
}

.dashboard-name {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    transition: background-color 0.15s;
}

.dropdown-arrow:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 2px);
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
    min-width: 220px;
    max-width: 280px;
    z-index: 9999;
    overflow: visible;
}

.dropdown-menu.hidden {
    display: none;
}

.dropdown-menu.visible {
    display: block;
    animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.9rem;
    color: #374151;
    transition: background-color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.dropdown-item:hover {
    background-color: #f9fafb;
}

/* Current dashboard styles removed - no longer needed since current dashboard doesn't appear in list */

.dropdown-item.dropdown-disabled {
    color: #9ca3af;
    cursor: not-allowed;
    font-style: italic;
}

.dropdown-item.dropdown-disabled:hover {
    background-color: transparent;
}

.chart-error {
    text-align: center;
    padding: 20px;
    color: #dc2626;
    background: #fef2f2;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

/* Chart canvas sizing */
.chart-container canvas {
    max-width: 100%;
    height: auto !important;
    max-height: 400px;
}

/* Chart description styling - appears below charts now */
.chart-description {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    line-height: 1.6;
}


/* Responsive adjustments */
/* Improved responsive design for different screen sizes */
@media (max-width: 1200px) {
    .sources-header, .sources-row {
        grid-template-columns: 2fr 1fr 1fr 100px;
        gap: 12px;
    }
}

@media (max-width: 900px) {
    .sources-header, .sources-row {
        grid-template-columns: 2fr 1fr 80px;
        gap: 10px;
    }
    
    .col-stats {
        display: none;
    }
}

@media (max-width: 768px) {
    .sources-header, .sources-row {
        grid-template-columns: 2fr 80px;
        gap: 8px;
    }
    
    .col-stats, .col-updated {
        display: none;
    }
    
    .action-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .chat-message {
        max-width: 95%;
    }
    
    .chat-input-container {
        flex-direction: column;
        gap: 8px;
    }
    
    .chat-input {
        width: 100%;
    }
}

/* ===== DASHBOARD LAYOUT STYLES ===== */

/* Split layout: Chat (left) + Dashboard (right) */
.dashboard-layout {
    display: flex;
    gap: 30px;  /* Increased gap for better separation */
    margin-top: 30px;
    min-height: 700px;  /* Increased height for large screens */
    min-width: 1100px;  /* Ensure proper chat + dashboard layout */
}

/* Left panel: Chat section (fixed width for large screens) */
.chat-panel {
    flex: 0 0 550px;  /* Increased from 450px to 550px */
    min-width: 500px;  /* Increased from 400px to 500px */
    max-width: 600px;  /* Increased from 500px to 600px */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: flex-basis 0.3s ease, min-width 0.3s ease;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.1),
        0 5px 15px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Collapsed chat panel */
.chat-panel.collapsed {
    flex: 0 0 50px;  /* Collapsed width */
    min-width: 50px;
    max-width: 50px;
}

.chat-panel.collapsed .chat-container {
    display: none;  /* Hide chat content when collapsed */
}

.chat-panel.collapsed .panel-header {
    padding: 12px 8px;  /* Reduced padding */
}

.chat-panel.collapsed .chat-header-left h3 {
    display: none;  /* Hide title when collapsed */
}

.chat-panel.collapsed .secondary-button {
    display: none;  /* Hide clear button when collapsed */
}

/* Right panel: Dashboard section (take remaining space) */
.dashboard-panel {
    flex: 1;  /* Take all remaining space */
    min-width: 600px;  /* Minimum width but allow scrolling when needed */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.1),
        0 5px 15px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Panel headers */
.panel-header {
    padding: 16px 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
}

/* Dashboard header specific styles */
.dashboard-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

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

/* Chat header specific styles */
.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-toggle-btn {
    background: none;
    border: none;
    font-size: 14px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background-color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

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

.dashboard-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-selector label {
    font-weight: 500;
    color: #374151;
    font-size: 0.9rem;
}

.dashboard-dropdown {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    min-width: 200px;
}

/* Small button variant */
.secondary-button.small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Chat container within panel */
.chat-panel .chat-container {
    flex: 1;
    border: none;
    border-radius: 0;
    height: auto;
}

/* Dashboard content area */
.dashboard-content {
    flex: 1;
    padding: 20px;
    overflow: auto;  /* Allow both horizontal and vertical scrolling */
    min-height: 0;  /* Allow flexbox to shrink */
}

/* Empty state */
.dashboard-empty {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state {
    text-align: center;
    color: #6b7280;
    max-width: 400px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    color: #374151;
}

.empty-state p {
    margin: 0;
    line-height: 1.5;
}

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(400px, 1fr));  /* 3 columns with minimum 400px each */
    gap: 25px;
    min-height: 100%;
    min-width: 1200px;  /* Ensure proper 3-column layout (3 × 400px + gaps) */
}

/* Dashboard item */
.dashboard-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    position: relative;
    transition: box-shadow 0.2s, transform 0.2s;
    max-height: 450px;  /* Set maximum height */
    display: flex;
    flex-direction: column;
}

.dashboard-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.dashboard-item-header {
    display: flex;
    justify-content: between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.dashboard-item-title {
    font-weight: 600;
    color: #374151;
    font-size: 1rem;
    margin: 0;
    flex: 1;
    line-height: 1.3;
}

.dashboard-item-menu {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.dashboard-item:hover .dashboard-item-menu {
    opacity: 1;
}

.dashboard-item-menu:hover {
    background: #f3f4f6;
}

/* Chart within dashboard item */
.dashboard-item .chart-container {
    margin: 0;
    padding: 12px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
    flex: 1;  /* Take remaining space in flex container */
    min-height: 250px;  /* Minimum height */
    max-height: 350px;  /* Maximum height */
    overflow: hidden;
}

.dashboard-item canvas {
    max-width: 100%;
    height: auto !important;
    max-height: 320px;  /* Increased height for better visibility */
}

/* Context menu */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 160px;
    padding: 4px 0;
    left: var(--menu-x, 0px);
    top: var(--menu-y, 0px);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background: #f3f4f6;
}

.context-menu-item.danger {
    color: #dc2626;
}

.context-menu-item.danger:hover {
    background: #fef2f2;
}

.menu-icon {
    font-size: 0.8rem;
}

/* Form styles for modals */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Responsive dashboard layout */
@media (max-width: 1024px) {
    .dashboard-layout {
        flex-direction: column;
        gap: 15px;
    }
    
    .chat-panel {
        flex: none;
        min-height: 400px;
    }
    
    .dashboard-panel {
        flex: none;
        min-height: 500px;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .dashboard-layout {
        margin-top: 20px;
    }
    
    .panel-header {
        padding: 12px 16px;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .dashboard-header-left,
    .dashboard-header-right {
        justify-content: center;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .dashboard-dropdown {
        min-width: auto;
        width: 100%;
    }
    
    .dashboard-content {
        padding: 15px;
    }
}

/* Data Preview Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.data-preview-modal {
    background: white;
    border-radius: 12px;
    max-width: 900px;
    width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    position: relative;
}

.data-preview-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

.data-preview-modal .modal-header h3 {
    margin: 0;
    color: #1f2937;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    color: #6b7280;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.data-preview-modal .modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.preview-section {
    margin-bottom: 24px;
}

.preview-section:last-child {
    margin-bottom: 0;
}

.preview-section h4 {
    margin: 0 0 12px 0;
    color: #374151;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-section h4 i {
    color: #6366f1;
}

.file-info {
    background: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #e5e7eb;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 500;
    color: #6b7280;
}

.columns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.column-item {
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.column-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.column-type {
    font-size: 0.875rem;
    color: #6366f1;
    font-weight: 500;
    margin-bottom: 4px;
}

.column-description {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.4;
}

.table-container {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.data-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-preview-table th {
    background: #f8fafc;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.data-preview-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-preview-table tbody tr:hover {
    background: #f9fafb;
}

.data-preview-table tbody tr:last-child td {
    border-bottom: none;
}

/* Table loading/empty state cell styling */
.table-loading-cell {
    text-align: center;
    padding: 20px;
    color: #6b7280;
    font-style: italic;
}

.data-preview-modal .modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
}

/* Responsive adjustments for data preview */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
    }
    
    .data-preview-modal {
        width: 95vw;
        max-height: 90vh;
    }
    
    .columns-grid {
        grid-template-columns: 1fr;
    }
    
    .info-row {
        flex-direction: column;
        gap: 4px;
    }
    
    .data-preview-table th,
    .data-preview-table td {
        padding: 8px 6px;
        max-width: 150px;
    }
}

/* Laptop Optimization Utilities */
.laptop-optimized {
    /* Utility class for laptop-specific optimizations */
    height: calc(100vh - 200px);
    max-height: 80vh;
    min-height: 400px;
}

.laptop-header-compact {
    /* Compact header for laptops */
    padding: 0.5rem 1rem !important;
    min-height: 3rem !important;
}

.laptop-content-fit {
    /* Content that fits laptop screen well */
    height: calc(100vh - 180px);
    overflow-y: auto;
    scrollbar-width: thin;
}

/* Optional Collapsible Sidebar for Future Enhancement */
.sidebar-toggle {
    display: none; /* Hidden by default, can be enabled via JavaScript */
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 0 8px 8px 0;
    padding: 12px 8px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.sidebar-panel {
    position: fixed;
    left: -300px; /* Hidden by default */
    top: 0;
    width: 280px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    transition: left 0.3s ease;
    z-index: 999;
    padding: 2rem 1rem;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
}

.sidebar-panel.open {
    left: 0;
}

.sidebar-panel.open ~ .container {
    margin-left: 300px;
    width: calc(100vw - 300px);
}

/* Smooth scrolling for better UX */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar for webkit browsers */
.chat-messages::-webkit-scrollbar,
.dashboard-content::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.dashboard-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb,
.dashboard-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.dashboard-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* App Footer */
.app-footer {
    text-align: center;
    margin-top: 1rem;  /* Reduced from 2.5rem */
    padding: 0.75rem 0;  /* Reduced padding */
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
}

.app-footer p {
    margin: 0;
}

/* Explore Data Section Styles */
/* Consolidated Header */
.consolidated-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;  /* Reduced padding */
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 0.5rem;  /* Reduced margin */
    min-height: 44px;  /* Reduced height */
}

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

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

/* Control Groups */
.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Compact Icon Buttons */
.icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #6b7280;
}

.icon-button:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

.icon-button [data-lucide] {
    width: 16px;
    height: 16px;
}

/* Data Source Info - Compact */
.consolidated-header .data-source-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #e0f2fe;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #0369a1;
}

/* Info icon styling - inside data source container */
.data-source-info .info-icon {
    width: 20px !important;
    height: 20px !important;
    background: transparent !important;
    border: none !important;
    color: #0369a1 !important;
    opacity: 0.8;
    padding: 2px !important;
    border-radius: 50% !important;
}

.data-source-info .info-icon:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.3) !important;
}

.data-source-info .info-icon [data-lucide] {
    width: 14px !important;
    height: 14px !important;
}

/* Dashboard Selector - Compact */
.consolidated-header .dashboard-selector select {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.875rem;
    color: #374151;
    min-width: 140px;
}

/* View Toggle - Compact version for consolidated header */
.consolidated-header .view-toggle {
    display: flex;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
}

.toggle-btn:hover {
    color: #374151;
}

.toggle-btn.active {
    background: white;
    color: #3b82f6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toggle-icon {
    font-size: 1rem;
}

.toggle-text {
    font-weight: inherit;
}

/* Explore Views - Optimized for laptop screens */
.explore-view {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    min-height: calc(100vh - 250px);  /* Dynamic height based on available space */
    height: calc(100vh - 200px);      /* Optimal height for laptop viewing */
    max-height: 80vh;                 /* Prevent excessive height on large screens */
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.1),
        0 5px 15px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Full-width Chat View */
.chat-fullwidth {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header-bar {
    padding: 16px 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

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

.chat-header-bar h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
}

/* Data Source Info */
.data-source-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.source-count {
    font-size: 0.875rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.chat-container-full {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(80vh - 140px);  /* Increased minimum height */
    max-height: calc(100vh - 140px);  /* Use more viewport height */
    height: calc(100vh - 160px);  /* Optimized for reduced header spacing */
}

/* Full-width Dashboard View */
.dashboard-fullwidth {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.dashboard-header-bar {
    padding: 16px 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header-bar h3 {
    margin: 0 16px 0 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
}

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

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

.dashboard-content-full {
    flex: 1;
    padding: 1.25rem;
    overflow: auto;
    min-height: calc(70vh - 200px);  /* Dynamic minimum height */
    height: calc(100vh - 220px);     /* Optimal height for laptop screens */
}

/* Data Sources Selection Modal */
.select-all-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 12px;
}

.select-all-container label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
}

.sources-selection-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.sources-selection-item:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.sources-selection-item.selected {
    background: #eff6ff;
    border-color: #3b82f6;
}

.source-checkbox {
    margin-top: 2px;
}

.source-details {
    flex: 1;
}

.source-name {
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.source-meta {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 4px;
}

.source-updated {
    font-size: 0.8rem;
    color: #9ca3af;
}

.source-warnings {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: #f59e0b;
    margin-top: 4px;
}

/* Responsive adjustments for new layout */
@media (max-width: 768px) {
    .consolidated-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        padding: 12px;
    }
    
    .header-section-left {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .consolidated-header .view-toggle {
        justify-content: center;
    }
    
    .control-group {
        justify-content: center;
        gap: 8px;
    }
    
    .consolidated-header .data-source-info {
        text-align: center;
    }
    
    .dashboard-header-bar {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .dashboard-header-left,
    .dashboard-header-right {
        justify-content: center;
    }
}

/* Calculated Fields Management Styles */
#calculated-fields-modal .modal-content {
    max-width: 700px;
}

.chat-tools {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    padding: 0 4px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.tool-icon {
    display: flex;
    align-items: center;
}

.tool-text {
    font-weight: 500;
}

/* Calculated Fields Modal Styles */
.fields-header {
    margin-bottom: 20px;
}

.fields-description {
    color: #666;
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

.fields-list {
    max-height: 400px;
    overflow-y: auto;
}

.field-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.field-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.field-item.field-error {
    background: #fff5f5;
    border-color: #fed7d7;
}

.field-info {
    flex: 1;
    margin-right: 16px;
}

.field-name {
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #e2e8f0;
    color: #4a5568;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.field-type-badge.type-filtering {
    background: #fed7e2;
    color: #97266d;
}

.field-type-badge.type-calculation {
    background: #bee3f8;
    color: #2b6cb0;
}

.field-description {
    color: #718096;
    font-size: 14px;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.field-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #a0aec0;
}

.field-source {
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-created {
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-error-message {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #e53e3e;
    font-size: 13px;
    margin-top: 8px;
    padding: 8px;
    background: rgba(229, 62, 62, 0.1);
    border-radius: 4px;
}

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

.field-delete-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 6px;
    color: #c53030;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.field-delete-btn:hover {
    background: #fed7d7;
    color: #9b2c2c;
}

.no-fields-message {
    text-align: center;
    padding: 40px 20px;
    color: #718096;
}

.no-fields-icon {
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-fields-icon [data-lucide] {
    width: 48px;
    height: 48px;
}

.no-fields-message h4 {
    color: #4a5568;
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
}

.no-fields-message p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Status indicators */
.field-status-icon {
    display: flex;
    align-items: center;
    margin-left: 8px;
}

.field-status-icon.status-error {
    color: #e53e3e;
}

.field-status-icon.status-valid {
    color: #38a169;
}

/* Data Processing Progress Modal */
.progress-modal {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.progress-modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: progressModalSlideIn 0.3s ease-out;
}

@keyframes progressModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.progress-header {
    padding: 32px 32px 24px 32px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

.progress-icon {
    margin-bottom: 16px;
}

.processing-icon {
    width: 48px;
    height: 48px;
    color: #667eea;
    animation: processingSpin 2s linear infinite;
}

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

.progress-header h3 {
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    color: #1f2937;
    font-weight: 600;
}

.progress-header p {
    margin: 0;
    color: #6b7280;
    font-size: 0.95rem;
}

.progress-steps {
    padding: 24px 32px;
    max-height: 400px;
    overflow-y: auto;
}

.progress-step {
    display: flex;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid #f3f4f6;
    transition: all 0.3s ease;
}

.progress-step:last-child {
    border-bottom: none;
}

.progress-step.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.05) 0%, rgba(102, 126, 234, 0.02) 100%);
    border-radius: 8px;
    margin: 0 -16px;
    padding: 16px 16px;
}

.progress-step.completed {
    opacity: 0.7;
}

.step-icon {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
}

.step-icon i {
    width: 20px;
    height: 20px;
    color: #9ca3af;
    transition: color 0.3s ease;
}

.progress-step.active .step-icon i {
    color: #667eea;
}

.progress-step.completed .step-icon i {
    color: #10b981;
}

.step-spinner {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.step-info {
    flex: 1;
}

.step-title {
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.step-description {
    color: #6b7280;
    font-size: 0.85rem;
    line-height: 1.4;
}

.progress-step.active .step-title {
    color: #667eea;
    font-weight: 600;
}

.step-status {
    margin-left: 12px;
}

.status-waiting i {
    width: 16px;
    height: 16px;
    color: #9ca3af;
}

.status-processing i {
    width: 16px;
    height: 16px;
    color: #667eea;
}

.status-completed i {
    width: 16px;
    height: 16px;
    color: #10b981;
}

.progress-bar-container {
    padding: 20px 32px;
    border-top: 1px solid #e5e7eb;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text {
    text-align: center;
    color: #6b7280;
    font-size: 0.9rem;
    font-weight: 500;
}

.progress-footer {
    padding: 16px 32px 24px 32px;
    text-align: center;
}

.processing-note {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 0.85rem;
    gap: 8px;
}

.processing-note i {
    width: 16px;
    height: 16px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .progress-modal {
        padding: 16px;
    }
    
    .progress-modal-content {
        max-width: 100%;
    }
    
    .progress-header,
    .progress-steps,
    .progress-bar-container,
    .progress-footer {
        padding-left: 20px;
        padding-right: 20px;
    }
    
    .progress-step {
        padding: 12px 0;
    }
    
    .step-icon {
        width: 36px;
        height: 36px;
        margin-right: 12px;
    }
}

/* ===== MODERN NOTIFICATION SYSTEM ===== */

/* Toast Container */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
    max-width: 420px;
    width: 100%;
}

/* Toast Base Styles */
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #ffffff;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #e5e7eb;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    overflow: hidden;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(100%);
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    max-height: 0;
}

/* Toast Icon */
.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

/* Toast Content */
.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-message {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
    word-wrap: break-word;
}

/* Toast Actions */
.toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.toast-action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toast-action-primary {
    background: #667eea;
    color: white;
}

.toast-action-primary:hover {
    background: #5a6fd8;
}

.toast-action-secondary {
    background: #f3f4f6;
    color: #374151;
}

.toast-action-secondary:hover {
    background: #e5e7eb;
}

/* Toast Dismiss Button */
.toast-dismiss {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-dismiss:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #6b7280;
}

/* Toast Type Variants */
.toast--success {
    border-left-color: #10b981;
}

.toast--success .toast-icon {
    color: #10b981;
}

.toast--error {
    border-left-color: #ef4444;
}

.toast--error .toast-icon {
    color: #ef4444;
}

.toast--warning {
    border-left-color: #f59e0b;
}

.toast--warning .toast-icon {
    color: #f59e0b;
}

.toast--info {
    border-left-color: #3b82f6;
}

.toast--info .toast-icon {
    color: #3b82f6;
}

/* Progress bar for timed toasts */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.1);
    transition: width linear;
}

.toast--success .toast-progress {
    background: #10b981;
}

.toast--error .toast-progress {
    background: #ef4444;
}

.toast--warning .toast-progress {
    background: #f59e0b;
}

.toast--info .toast-progress {
    background: #3b82f6;
}

/* ===== CONFIRMATION MODAL SYSTEM ===== */

.confirmation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
}

.confirmation-overlay.show {
    opacity: 1;
    visibility: visible;
}

.confirmation-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.confirmation-overlay.show .confirmation-modal {
    transform: scale(1) translateY(0);
}

.confirmation-header {
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.confirmation-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 12px;
}

.confirmation-title-icon {
    width: 24px;
    height: 24px;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirmation-title-icon--danger {
    background: #fef2f2;
    color: #ef4444;
}

.confirmation-title-icon--info {
    background: #eff6ff;
    color: #3b82f6;
}

.confirmation-description {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

.confirmation-body {
    padding: 16px 24px;
}

.confirmation-message {
    margin: 0;
    color: #374151;
    font-size: 14px;
    line-height: 1.6;
}

.confirmation-actions {
    padding: 16px 24px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirmation-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.confirmation-btn-cancel {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.confirmation-btn-cancel:hover {
    background: #e5e7eb;
}

.confirmation-btn-confirm {
    background: #667eea;
    color: white;
}

.confirmation-btn-confirm:hover {
    background: #5a6fd8;
}

.confirmation-btn-confirm:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

.confirmation-btn-confirm:disabled:hover {
    background: #9ca3af;
}

.confirmation-btn-danger {
    background: #ef4444;
    color: white;
}

.confirmation-btn-danger:hover {
    background: #dc2626;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .toast-container {
        left: 16px;
        right: 16px;
        top: 16px;
        max-width: none;
    }
    
    .confirmation-overlay {
        padding: 16px;
    }
    
    .confirmation-modal {
        max-width: none;
    }
    
    .confirmation-actions {
        flex-direction: column-reverse;
    }
    
    .confirmation-btn {
        width: 100%;
    }
}

/* Accessibility */
.toast:focus-visible,
.confirmation-modal:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .toast,
    .confirmation-overlay,
    .confirmation-modal {
        transition: none;
    }
}

/* Legacy animation for backward compatibility */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== CHART REORDER SIDEBAR ===== */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.reorder-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    height: 100vh;
    background: white;
    border-left: 1px solid #e0e0e0;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.reorder-sidebar:not(.hidden) {
    transform: translateX(0);
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.sidebar-close-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.reorder-instructions {
    padding: 16px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

.reorder-chart-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.reorder-item {
    padding: 0 24px;
    margin-bottom: 2px;
}

.reorder-item-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.reorder-item-content:hover {
    background: #f8f9fa;
    border-color: #e0e0e0;
}

.reorder-item-info {
    flex: 1;
    min-width: 0;
}

.reorder-item-title {
    font-weight: 500;
    color: #333;
    font-size: 14px;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reorder-item-position {
    font-size: 12px;
    color: #888;
}

.reorder-item-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-left: 12px;
}

.reorder-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #666;
}

.reorder-btn:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #bbb;
    color: #333;
}

.reorder-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f9f9f9;
}

.reorder-btn svg {
    width: 16px;
    height: 16px;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}

.sidebar-footer .confirmation-btn {
    width: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .reorder-sidebar {
        width: 100vw;
        right: 0;
    }
    
    .reorder-item {
        padding: 0 16px;
    }
    
    .sidebar-header,
    .reorder-instructions,
    .sidebar-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* =============================================================================
   DASHBOARD CHAT OVERLAY
   ============================================================================= */

/* Main chat overlay container */
.dashboard-chat-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.dashboard-chat-overlay.hidden {
    display: none;
}

/* Chat toggle button (collapsed state) */
.chat-toggle-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    user-select: none;
}

.chat-toggle-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.4);
}

.chat-toggle-button i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.chat-toggle-text {
    white-space: nowrap;
}

/* Chat panel (expanded state) */
.chat-panel {
    width: 90%; /* Increased from 80% to use more screen space */
    max-width: 850px; /* Increased from 700px for better width */
    min-width: 520px; /* Slightly increased from 500px */
    height: 550px; /* Increased from 500px for more vertical space */
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.chat-panel.hidden {
    display: none;
}

/* Chat header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.chat-header-left i {
    width: 20px;
    height: 20px;
}

.chat-title {
    font-weight: 600;
    font-size: 15px;
}

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

.chat-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chat-header-btn i {
    width: 16px;
    height: 16px;
}

/* Chat messages area */
.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
}

/* Welcome message */
.chat-welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    color: #666;
    gap: 16px;
}


.welcome-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.welcome-text h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.welcome-text p {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
    max-width: 280px;
}

.welcome-subtext {
    margin-top: 8px !important;
    font-size: 12px !important;
    color: #999 !important;
}

.analyze-dashboard-btn {
    margin: 16px 0 8px 0;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.analyze-dashboard-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.analyze-dashboard-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.analyze-dashboard-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.analyze-dashboard-btn i {
    width: 16px;
    height: 16px;
}

.quick-analyze-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.quick-analyze-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.quick-analyze-btn:active {
    transform: scale(0.98);
}

.quick-analyze-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.quick-analyze-btn i {
    width: 18px;
    height: 18px;
}

/* =============================================================================
   DASHBOARD CHAT - DEDICATED STYLES
   ============================================================================= */

/* Dashboard chat messages - override generic chat styles */
.dashboard-chat-overlay .chat-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    width: 100%; /* Use full width of chat area */
}

.dashboard-chat-overlay .chat-message-user {
    align-items: flex-end;
}

.dashboard-chat-overlay .chat-message-assistant {
    align-items: flex-start;
}

/* Dashboard chat message content with improved widths */
.dashboard-chat-overlay .chat-message-content {
    background: white;
    padding: 16px 20px;
    border-radius: 16px;
    max-width: 85%; /* Increased from 80% for better space usage */
    word-wrap: break-word;
    font-size: 15px; /* Slightly larger for better readability */
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.dashboard-chat-overlay .chat-message-user .chat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.2);
}

.dashboard-chat-overlay .chat-message-assistant .chat-message-content {
    background: #ffffff;
    color: #2d3748;
    border: 1px solid #e2e8f0;
}

/* Enhanced markdown styling for dashboard chat */
.dashboard-chat-overlay .chat-message-content h1,
.dashboard-chat-overlay .chat-message-content h2,
.dashboard-chat-overlay .chat-message-content h3,
.dashboard-chat-overlay .chat-message-content h4,
.dashboard-chat-overlay .chat-message-content h5,
.dashboard-chat-overlay .chat-message-content h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.dashboard-chat-overlay .chat-message-content h1 { font-size: 1.4rem; }
.dashboard-chat-overlay .chat-message-content h2 { font-size: 1.25rem; }
.dashboard-chat-overlay .chat-message-content h3 { font-size: 1.15rem; }

.dashboard-chat-overlay .chat-message-content p {
    margin: 8px 0;
    line-height: 1.6;
}

.dashboard-chat-overlay .chat-message-content strong {
    font-weight: 600;
    color: #1a202c;
}

.dashboard-chat-overlay .chat-message-user .chat-message-content strong {
    color: rgba(255, 255, 255, 0.95);
}

.dashboard-chat-overlay .chat-message-content ul,
.dashboard-chat-overlay .chat-message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.dashboard-chat-overlay .chat-message-content li {
    margin: 4px 0;
    line-height: 1.5;
}

.dashboard-chat-overlay .chat-message-content code {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.dashboard-chat-overlay .chat-message-user .chat-message-content code {
    background: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.9);
}

.dashboard-chat-overlay .chat-message-content pre {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    margin: 12px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    line-height: 1.4;
}

.dashboard-chat-overlay .chat-message-user .chat-message-content pre {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    border-left-color: rgba(255, 255, 255, 0.6);
    color: rgba(255, 255, 255, 0.9);
}

.dashboard-chat-overlay .chat-message-content blockquote {
    border-left: 4px solid #667eea;
    padding: 8px 0 8px 16px;
    margin: 12px 0;
    font-style: italic;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 0 6px 6px 0;
}

.dashboard-chat-overlay .chat-message-user .chat-message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
}

/* Dashboard chat messages area - improved layout */
.dashboard-chat-overlay .chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px; /* Increased padding for better spacing */
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    gap: 0; /* Remove gap, use margin on messages instead */
}

/* Chat input area */
.chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.chat-message-input:focus {
    border-color: #667eea;
    background: white;
}

.chat-message-input:disabled {
    background: #f0f0f0;
    color: #999;
    cursor: not-allowed;
}

.send-chat-message-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-chat-message-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.send-chat-message-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.send-chat-message-btn i {
    width: 18px;
    height: 18px;
}

/* Loading states */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
    gap: 8px;
}

.chat-loading i {
    animation: spin 2s linear infinite;
}

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

/* Responsive adjustments for chat overlay */
@media (max-width: 768px) {
    .dashboard-chat-overlay {
        bottom: 10px;
        right: 10px;
        left: 10px;
        width: auto;
    }
    
    .chat-panel {
        width: 100%;
        height: 400px;
    }
    
    .chat-toggle-button {
        width: 100%;
        justify-content: center;
        margin: 0 auto;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .chat-panel {
        height: 350px;
        border-radius: 12px;
    }
    
    .chat-messages-area {
        padding: 12px;
    }
    
    .chat-input-area {
        padding: 12px;
    }
    
    .chat-message-content {
        max-width: 90%;
        font-size: 13px;
    }
}

/* =============================================================================
   THINKING INDICATOR (Phase 2)
   ============================================================================= */

.thinking-indicator {
    display: flex !important;
    align-items: center;
    gap: 12px;
    background: #f8f9fa !important;
    border: 1px solid #e9ecef;
    color: #6c757d !important;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c757d;
    animation: thinking-bounce 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.thinking-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.thinking-text {
    font-style: italic;
    font-size: 13px;
}

@keyframes thinking-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   ADMIN USERS SPECIFIC STYLES
   ======================================== */

/* File Upload Section */
.upload-section {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 2rem;
}

.upload-section.dragover {
    border-color: #667eea;
    background-color: rgba(102, 126, 234, 0.05);
}

.file-input {
    display: none;
}

.upload-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
}

/* Users Table */
.users-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.users-table th,
.users-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e1e5e9;
}

.users-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.users-table tbody tr:hover {
    background: #f8f9fa;
}

/* Status and Role Badges */
.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

.role-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.role-admin {
    background: #d1ecf1;
    color: #0c5460;
}

.role-user {
    background: #e2e3e5;
    color: #383d41;
}

/* Editable Fields */
.editable {
    background: transparent;
    border: 1px solid transparent;
    padding: 0.25rem;
    border-radius: 4px;
}

.editable:focus {
    border-color: #667eea;
    outline: none;
    background: white;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

/* Success/Error Messages */
.success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
}

.error-list {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
}

.error-list ul {
    margin: 0;
    padding-left: 1.5rem;
}

/* Large Admin Modal Variant - Specific to user preview */
.admin-modal-large .modal-content {
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    min-height: 600px;
}

.admin-modal-large .modal-body {
    max-height: 60vh;
    overflow-y: auto;
    padding: 1.5rem 2rem;
}

.admin-modal-large .users-table {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.admin-modal-large .users-table th,
.admin-modal-large .users-table td {
    padding: 0.75rem;
}

.admin-modal-large .editable {
    min-width: 120px;
    font-size: 0.875rem;
}

.admin-modal-large .modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e5e7eb;
}

.admin-modal-large .modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}