/* Light Theme (Default) */
:root {
    /* Primary Brand Colors */
    --theme-primary: #4A90E2;
    --theme-primary-dark: #3A7BD5;
    --theme-primary-light: #5BA7F7;
    --theme-accent: #4A90E2;
    --theme-secondary-dark: #D2691E;
    --theme-secondary-light: #FF8C42;
    --theme-primary-light: #4DD0E1;
    --theme-primary-dark: #00ACC1;
    
    /* Neutral Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-dark: #0f172a;
    --bg-sidebar: #f8fafc;
    
    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Border Colors */
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    --border-dark: #94a3b8;
    
    /* Interactive Colors */
    --hover-bg: #f1f5f9;
    --active-bg: #e2e8f0;
    --focus-ring: #4A90E2;
    
    /* Status Colors */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Spacing */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 60px;
    --header-height: 60px;
    
    /* Mermaid Theme Variables - Light Theme */
    --mermaid-edge-text-color: #000000;
    --mermaid-edge-bg-color: #ffffff;
    --mermaid-edge-border-color: #000000;
    
    /* Campaign Theme Variables - Light Theme */
    --campaign-bg-start: transparent;
    --campaign-bg-end: transparent;
    --campaign-text: var(--text-primary);
    --campaign-icon: #ff8c42;  /* Orange bullhorn */
    --campaign-cta-bg: var(--theme-primary);
    --campaign-cta-text: #ffffff;
    --campaign-dismiss-bg: var(--bg-secondary);
    --campaign-dismiss-border: var(--border-light);
    --input-bg: var(--bg-primary);
}

/* Mermaid Edge Label Fallback Styles */
/* Provides global fallback for edge labels before themeCSS is injected */
.mermaid-diagram .edgeLabel text,
.mermaid-diagram .edge-label text,
.mermaid-diagram g.edgeLabel text,
.mermaid-diagram g[class*="edgeLabel"] text {
    fill: var(--mermaid-edge-text-color) !important;
    color: var(--mermaid-edge-text-color) !important;
    stroke: none !important;
}

.mermaid-diagram .edgeLabel rect,
.mermaid-diagram .edge-label rect,
.mermaid-diagram g.edgeLabel rect,
.mermaid-diagram g[class*="edgeLabel"] rect {
    fill: var(--mermaid-edge-bg-color) !important;
    stroke: var(--mermaid-edge-border-color) !important;
    stroke-width: 1px !important;
    opacity: 1 !important;
}

/* Mermaid SVG Cleanup */
/* Hide debug elements and empty artifacts */
.mermaid-diagram svg title,
.mermaid-diagram svg desc,
.diagram-container svg title,
.diagram-container svg desc,
svg[id*="mermaid"] title,
svg[id*="mermaid"] desc {
    display: none !important;
}

/* Hide any floating span elements from Mermaid */
.mermaid-diagram > span,
.diagram-container > span {
    display: none !important;
}

/* Hide only EMPTY edge label foreignObjects (not node labels!) */
.mermaid-diagram svg g.edgeLabel foreignObject[width="4"],
.diagram-container svg g.edgeLabel foreignObject[width="4"],
.mermaid-diagram svg g[class*="edgeLabel"] foreignObject[width="4"] {
    display: none !important;
}

/* Hide empty spans in edge labels */
.mermaid-diagram svg g.edgeLabel span.edgeLabel:empty,
.diagram-container svg g.edgeLabel span.edgeLabel:empty {
    display: none !important;
}

/* Dark Theme - Python/Cursor Inspired Colors */
[data-theme="dark"] {
    /* Primary Colors - Adjusted for dark theme */
    --theme-primary: #5BA7F7;
    
    /* Mermaid Theme Variables - Dark Theme */
    --mermaid-edge-text-color: #ffffff;
    --mermaid-edge-bg-color: #1a1a1a;
    --mermaid-edge-border-color: #5BA7F7;
    --theme-primary-dark: #4A90E2;
    --theme-primary-light: #7BB3F0;
    --theme-accent: #5BA7F7;
    
    /* Cursor-inspired accent colors */
    --editor-primary: #4ec9b0;         /* Teal accent for special elements */
    --editor-success: #6a9955;        /* Green for success/positive */
    --editor-warning: #dcdcaa;       /* Yellow for highlights */
    --editor-info: #ce9178;       /* Orange for strings/warm accents */
    --editor-special: #c586c0;       /* Purple for keywords */
    
    /* Background Colors - Python/Cursor Dark Theme */
    --bg-primary: #1e1e1e;          /* Main background */
    --bg-secondary: #252526;        /* Secondary panels */
    --bg-tertiary: #2d2d30;         /* Tertiary elements */
    --bg-dark: #0c0c0c;            /* Darkest elements */
    --bg-sidebar: #252526;          /* Sidebar background */
    
    /* Text Colors - High contrast for readability */
    --text-primary: #d4d4d4;        /* Primary text - light gray */
    --text-secondary: #cccccc;      /* Secondary text */
    --text-muted: #969696;          /* Muted text */
    --text-light: #6a6a6a;         /* Light text */
    
    /* Chat-specific colors */
    --chat-user-bg: #2d2d30;        /* User message background */
    --chat-assistant-bg: #252526;   /* Assistant message background */
    --chat-user-text: #4ec9b0;      /* User text - teal */
    --chat-assistant-text: #d4d4d4; /* Assistant text - standard */
    
    /* Border Colors - Subtle borders */
    --border-light: #3e3e42;        /* Light borders */
    --border-medium: #464647;       /* Medium borders */
    --border-dark: #5a5a5a;         /* Dark borders */
    
    /* Interactive Colors */
    --hover-bg: #2a2d2e;           /* Hover background */
    --active-bg: #37373d;          /* Active background */
    --focus-ring: #4ec9b0;         /* Focus ring - teal */
    
    /* Status Colors */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    
    /* Input/Search Colors */
    --input-bg: #3c3c3c;           /* Input background */
    --input-border: #464647;       /* Input border */
    --input-focus: #4ec9b0;        /* Input focus - teal */
    
    /* Shadows - Darker shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    
    /* Campaign Theme Variables - Dark Theme */
    --campaign-bg-start: transparent;
    --campaign-bg-end: transparent;
    --campaign-text: var(--text-primary);
    --campaign-icon: #4ec9b0;  /* Teal bullhorn (Cursor-inspired) */
    --campaign-cta-bg: var(--theme-primary);
    --campaign-cta-text: #ffffff;
    --campaign-dismiss-bg: var(--bg-secondary);
    --campaign-dismiss-border: var(--border-light);
    --input-bg: var(--bg-secondary);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Top Navigation */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

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

.sidebar-toggle {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

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

.logo {
    height: 32px;
    width: auto;
    object-fit: contain; /* Ensure consistent visual sizing for light/dark logos */
    max-height: 32px;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: inline;
}

.app-title:empty {
    visibility: hidden;
}

.app-title-mobile {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: none;
}

.app-title-mobile:empty {
    visibility: hidden;
}

/* Mobile devices (phones and small tablets): Show mobile tagline */
@media (max-width: 1365px) {
    .app-title {
        display: none;
    }
    
    .app-title-mobile {
        display: inline;
    }
}

.nav-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.main-nav {
    display: flex;
    gap: 32px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--theme-primary);
    background: var(--hover-bg);
}

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

.nav-button {
    background: var(--theme-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
    font-size: 14px;
}

.nav-button:hover {
    background: var(--theme-primary-dark);
    color: white;
}

.demo-btn {
    background: transparent;
    color: var(--theme-primary);
    border: 1px solid var(--theme-primary);
}

/* Enhanced button styles - primary/secondary */
.nav-button-primary {
    background: #4A90E2 !important;
    color: white !important;
    border: 2px solid #4A90E2 !important;
}

.nav-button-primary:hover {
    background: #3A7BD5 !important;
    border-color: #3A7BD5 !important;
    box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3);
}

.nav-button-secondary {
    background: transparent !important;
    color: #4A90E2 !important;
    border: 2px solid #4A90E2 !important;
}

.nav-button-secondary:hover {
    background: rgba(74, 144, 226, 0.1) !important;
}

/* Text only style - plain link, no decoration */
.nav-button-text {
    background: transparent !important;
    color: var(--text-primary) !important;
    border: none !important;
    padding: 10px 12px !important;
    font-weight: 500;
}

.nav-button-text:hover {
    color: #4A90E2 !important;
    text-decoration: underline;
}

/* Sortable states */
.sortable-ghost {
    opacity: 0.3;
}

.sortable-chosen {
    opacity: 0.8;
}

.demo-btn:hover {
    background: var(--theme-primary);
    color: white;
}

.trial-btn {
    background: var(--theme-primary);
    color: white;
}

.trial-btn:hover {
    background: var(--theme-primary-dark);
}

.login-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-weight: 500;
}

.login-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.user-avatar:hover {
    background: var(--hover-bg);
}

/* Main Container */
.main-container {
    display: flex;
    margin-top: var(--header-height);
    height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    overflow: hidden;
    z-index: 1000;  /* Below input bar (1001) on mobile */
}

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

/* Preload collapsed state - applied before JavaScript runs */
.sidebar-collapsed-preload .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed-preload .sidebar .sidebar-header h3,
.sidebar-collapsed-preload .sidebar .section-header h4,
.sidebar-collapsed-preload .sidebar .chat-item span {
    display: none;
}

.sidebar-collapsed-preload .sidebar .chat-item {
    justify-content: center;
    padding-left: 20px;
    padding-right: 20px;
}

.sidebar-collapsed-preload .sidebar .section-header,
.sidebar-collapsed-preload .sidebar .sidebar-header {
    justify-content: center;
}

.sidebar-collapsed-preload .sidebar .footer-button {
    width: 40px;
    height: 40px;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0 auto 8px auto;
    text-align: center;
    display: flex;
}

.sidebar-collapsed-preload .sidebar .footer-button span {
    display: none;
}

.sidebar-collapsed-preload .sidebar .footer-button i {
    margin: 0;
    width: auto;
    text-align: center;
}

.sidebar-collapsed-preload .sidebar .info-icon {
    display: none;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70px;
}

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.add-section-btn {
    background: none;
    border: none;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.add-section-btn:hover {
    background: var(--hover-bg);
    color: var(--theme-primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.section {
    margin-bottom: 24px;
}

.section-header {
    padding: 16px 20px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.section-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Info Icon and Tooltip Styles */
.info-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    cursor: help;
    color: var(--text-light);
    transition: all 0.2s ease;
}

.info-icon:hover {
    color: var(--theme-primary);
}

.info-icon i {
    font-size: 12px;
}

/* Tooltip */
.info-icon::after {
    content: attr(data-tooltip);
    position: fixed;
    top: var(--tooltip-top, 50px);
    left: calc(var(--sidebar-width) + 20px);
    background: var(--bg-dark);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.2s ease;
    z-index: 15000;
    box-shadow: var(--shadow-lg);
    max-width: 300px;
    min-width: 250px;
    white-space: normal;
    line-height: 1.5;
}

/* Tooltip arrow */
.info-icon::before {
    content: '';
    position: fixed;
    top: var(--arrow-top, 58px);
    left: calc(var(--sidebar-width) + 14px);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid var(--bg-dark);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.2s ease;
    z-index: 15000;
}

.info-icon:hover::after,
.info-icon:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Mobile tooltip styling - DOM-based approach */
.mobile-tooltip {
    position: fixed;
    background: var(--bg-dark);
    color: white;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: tooltipFadeIn 0.3s ease;
    max-width: calc(100vw - 40px);
}

.mobile-tooltip-content {
    padding: 16px 20px;
    font-size: 14px;
    line-height: 1.6;
    text-align: left;
}

.mobile-tooltip-close {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 8px;
    font-style: italic;
}

/* Dark theme mobile tooltip */
[data-theme="dark"] .mobile-tooltip {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

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

/* Mobile info icon styling */
@media (max-width: 768px) {
    .info-icon {
        cursor: pointer;
        padding: 6px;
        border-radius: 50%;
        transition: all 0.2s ease;
        min-width: 24px;
        min-height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .info-icon:active {
        background: var(--hover-bg);
        transform: scale(0.9);
    }
    
    .info-icon.tooltip-active {
        background: var(--theme-primary-light);
        color: white;
    }
    
    /* Hide desktop hover tooltips on mobile */
    .info-icon:hover::after,
    .info-icon:hover::before {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }
}


/* Collapsed sidebar adjustments */
.sidebar.collapsed .info-icon {
    display: none;
}

.section-items {
    list-style: none;
    padding: 0;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

.chat-item:hover {
    background: var(--hover-bg);
}

.chat-item.active {
    background: var(--active-bg);
    border-right: 3px solid var(--theme-primary);
}

.chat-item i {
    color: var(--text-light);
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.chat-item span {
    color: var(--text-secondary);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   SIDEBAR FOOTER - USER PROFILE CARD
   Cross-platform compatible (Mac, Windows, Linux)
   Cross-browser compatible (Chrome, Safari, Edge, Firefox)
   Mobile-responsive with touch support
   ======================================== */

.sidebar-footer {
    padding: 0;
    border-top: 1px solid var(--border-light);
    margin-top: auto; /* Push to bottom */
    position: relative;
    background: var(--bg-sidebar);
}

/* User Profile Card Container */
.user-profile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 12px;
    position: relative;
    background: var(--bg-sidebar);
    transition: background-color 0.2s ease;
}

/* Main Profile Area (clickable) */
.profile-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0; /* Allow text truncation */
    cursor: pointer;
    padding: 4px;
    margin: -4px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    /* Ensure proper click target on all touch devices */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.profile-main:hover {
    background: var(--hover-bg);
}

.profile-main:active {
    background: var(--active-bg);
}

/* Profile Avatar */
.profile-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4A90E2, #5BA7F7);
    color: white;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
    /* Cross-browser smooth rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.profile-avatar i {
    font-size: 18px;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar .user-avatar-initials {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

/* Profile Info Text */
.profile-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.profile-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Dropdown Trigger Button */
.profile-dropdown-trigger {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    /* Touch-friendly on mobile */
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    margin: 0;
}

.profile-dropdown-trigger:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.profile-dropdown-trigger:active {
    background: var(--active-bg);
}

.profile-dropdown-trigger i {
    font-size: 14px;
    transition: transform 0.2s ease;
}

.profile-dropdown-trigger.active i {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.profile-dropdown-menu {
    position: fixed;
    z-index: 1100;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 6px;
    /* Will be positioned via JavaScript for cross-platform compatibility */
}

.dropdown-item {
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.15s ease;
    font-family: inherit;
    /* Touch-friendly */
    -webkit-tap-highlight-color: transparent;
}

.dropdown-item:hover {
    background: var(--hover-bg);
}

.dropdown-item:active {
    background: var(--active-bg);
}

.dropdown-item i {
    font-size: 14px;
    width: 16px;
    text-align: center;
    color: var(--text-muted);
}

/* Dark Theme Support */
[data-theme="dark"] .profile-dropdown-menu {
    background: var(--bg-dark);
    border-color: var(--border-dark);
}

[data-theme="dark"] .profile-dropdown-trigger:hover {
    color: var(--editor-primary);
}

/* Mobile Responsive Styles */
@media (max-width: 768px),
       (max-device-width: 768px),
       screen and (max-width: 768px) and (orientation: portrait),
       screen and (max-width: 768px) and (orientation: landscape) {
    
    .user-profile-card {
        padding: 10px 12px;
    }
    
    .profile-avatar {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        font-size: 16px;
    }
    
    .profile-avatar i {
        font-size: 16px;
    }
    
    .profile-avatar .user-avatar-initials {
        font-size: 14px;
    }
    
    .profile-name {
        font-size: 14px;
    }
    
    .profile-subtitle {
        font-size: 11px;
    }
    
    .profile-dropdown-trigger {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
    
    .profile-dropdown-menu {
        min-width: 160px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .profile-name {
        font-size: 13px;
    }
    
    .profile-subtitle {
        font-size: 10px;
    }
}

/* Cross-browser compatibility fixes */

/* Safari-specific fixes */
@supports (-webkit-appearance: none) {
    .profile-avatar {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Firefox-specific fixes */
@-moz-document url-prefix() {
    .profile-dropdown-trigger {
        padding: 2px;
    }
}

/* Edge/IE compatibility */
@supports (-ms-ime-align: auto) {
    .profile-main {
        display: -ms-flexbox;
    }
}

/* Windows high contrast mode support */
@media (prefers-contrast: high) {
    .profile-dropdown-menu {
        border-width: 2px;
    }
}

/* Reduced motion support (accessibility) */
@media (prefers-reduced-motion: reduce) {
    .profile-main,
    .profile-dropdown-trigger,
    .profile-dropdown-trigger i,
    .dropdown-item {
        transition: none !important;
    }
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 80%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.chat-header {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.action-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    padding-bottom: 280px;  /* Large space for fixed input bar (accounts for expanded textarea) */
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.message-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: var(--theme-secondary-dark);
    color: white;
    padding: 0;
    overflow: hidden;
}

.user-message .message-avatar i {
    font-size: 20px; /* Make the avatar icon fill the circle better */
}

.assistant-message .message-avatar {
    background: var(--bg-tertiary);
    padding: 4px;
}

.assistant-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
}

.message-content {
    flex: 1;
    padding-top: 0; /* Remove top padding to eliminate extra space */
    overflow-x: auto; /* Handle horizontal overflow */
    max-width: 100%; /* Ensure content doesn't exceed container */
    font-size: var(--typo-base-size, 14px);  /* Uses typography setting */
    letter-spacing: -0.01em;  /* Slight tightening for Inter */
}

/* Ensure proper block-level display for all headers */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    display: block;
    width: 100%;
    text-indent: 0;
    padding-left: 0;
    margin-left: 0;
}

.message-content p {
    margin-bottom: calc(12px * var(--typo-spacing-scale, 1));
    color: var(--text-primary);
    line-height: calc(1.6 * var(--typo-spacing-scale, 1));
    font-weight: 400; /* Normal weight, not bold */
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 12px 0;
}

.message-content ul {
    margin: 12px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: calc(8px * var(--typo-spacing-scale, 1));
    color: var(--text-secondary);
    line-height: calc(1.6 * var(--typo-spacing-scale, 1));
}

/* Light theme chat message styling - LLM-style */
.user-message .message-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-left: 8px;
    border-left: 3px solid var(--theme-secondary-dark);
}

.user-message .message-content p {
    font-weight: 400; /* Normal weight */
    color: var(--text-primary);
}

.assistant-message .message-content {
    background: var(--bg-tertiary) !important;
    border-radius: 12px;
    padding: 16px;
    margin-left: 8px;
    border-left: 3px solid var(--theme-primary-light) !important;
}

.assistant-message .message-content p {
    font-weight: 400; /* Normal weight */
    color: var(--text-primary);
}

.assistant-message .message-content h1,
.assistant-message .message-content h2,
.assistant-message .message-content h3,
.assistant-message .message-content h4 {
    font-weight: 500; /* Medium weight for headers */
}

.assistant-message .message-content li {
    font-weight: 400; /* Normal weight for list items */
}

.assistant-message .message-wrapper {
    margin-left: 8px;
}

/* Dark theme chat message styling - LLM-style */
[data-theme="dark"] .user-message .message-content {
    background: var(--chat-user-bg);
    border-left: 3px solid var(--editor-primary);
}

[data-theme="dark"] .user-message .message-avatar {
    background: #4b5563;
    color: #e5e7eb;
}

[data-theme="dark"] .user-message .message-content p {
    color: #e5e7eb;  /* Light text for user messages */
    font-weight: 400; /* Normal weight, not bold */
}

[data-theme="dark"] .assistant-message .message-content {
    background: var(--chat-assistant-bg);
    border-left: 3px solid var(--theme-primary-light) !important;
}

/* Dark theme uses teal colors for user messages */
[data-theme="dark"] .user-message .message-content {
    border-left: 3px solid var(--theme-primary-dark);
}

[data-theme="dark"] .send-button {
    background: var(--send-button-bg, var(--theme-primary-light));
    color: var(--send-icon-color, white);
}

[data-theme="dark"] .send-button:disabled {
    background: var(--send-button-bg, var(--theme-primary-light));
    color: var(--send-icon-color, white);
    opacity: 0.6;
}

[data-theme="dark"] .send-button:not(:disabled) {
    background: var(--send-button-bg, var(--theme-primary-light));
    color: var(--send-icon-color, white);
}

[data-theme="dark"] .send-button.has-text:not(:disabled) {
    background: var(--send-button-hover, var(--theme-primary-dark));
    color: var(--send-icon-color, white);
}

[data-theme="dark"] .send-button:hover:not(:disabled) {
    background: var(--send-button-hover, var(--theme-primary-dark));
    color: var(--send-icon-color, white);
}

[data-theme="dark"] .user-message .message-avatar {
    background: var(--theme-primary-dark);
    color: white;
}

/* Duplicate dark theme rule removed - see line ~2126 for main dark theme input styling */

[data-theme="dark"] .assistant-message .message-wrapper {
    margin-left: 8px;
}

[data-theme="dark"] .assistant-message .message-content p {
    color: #f3f4f6;  /* Mostly white text for assistant */
    font-weight: 400; /* Normal weight, not bold */
}

[data-theme="dark"] .assistant-message .message-content h4 {
    color: #f3f4f6;  /* White for headers */
    font-weight: 500; /* Medium weight */
}

[data-theme="dark"] .assistant-message .message-content li {
    color: #e5e7eb;  /* Light gray for list items */
    font-weight: 400; /* Normal weight */
}

/* Enhanced message formatting - Balanced LLM-style */
.message-content h1 {
    font-size: 17px;  /* Reduced from 20px */
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 4px 0 8px 0;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 4px;
    padding-left: 0;
}

/* First header in message should have no top margin */
.message-content h1:first-child {
    margin-top: 0;
}

.message-content h2 {
    font-size: 15px;  /* Reduced from 18px */
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 16px 0 12px 0;
    border-bottom: none;
    padding: 0;
    clear: both;
}

.message-content h3 {
    font-size: 14px;  /* Reduced from 16px */
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 12px 0 10px 0;
    padding: 0;
}

.message-content h4 {
    font-size: 13px;  /* Reduced from 15px */
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 10px 0 8px 0;
    padding: 0;
}

.message-content p {
    margin-bottom: 8px; /* Reduced spacing between paragraphs */
    margin-top: 0px; /* Zero top margin for tighter spacing after headers */
    margin-left: 0; /* Explicit zero left margin for alignment */
    padding: 0; /* Zero padding for consistent alignment with headers */
    text-indent: 0; /* No text indentation */
    line-height: 1.4; /* More readable line height */
    color: var(--text-primary);
    font-weight: 400; /* Normal weight */
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Enhanced list styling - Compact LLM-style */
.message-content .message-list {
    margin: 0px 0; /* Zero margin around lists for ultra-tight spacing */
    margin-left: 0; /* Explicit zero left margin for alignment */
    padding-left: 20px; /* Standard list indentation */
    text-indent: 0; /* No text indentation */
}

.message-content .message-list li {
    margin-bottom: 5px; /* Add 5px spacing between bullet items */
    margin-left: 0; /* Explicit zero left margin for alignment */
    line-height: 1.2; /* Slightly more relaxed line height */
    color: var(--text-secondary);
    font-weight: 400; /* Normal weight */
    margin-top: 0px; /* Zero top margin */
    padding: 0px; /* Zero padding */
    text-indent: 0; /* No text indentation */
}

.message-content ul.message-list {
    list-style-type: disc;
    margin-bottom: 10px; /* Add 10px space after unordered lists */
}

.message-content ol.message-list {
    list-style-type: decimal;
    margin-bottom: 10px; /* Add 10px space after ordered lists */
}

/* Checkbox list styling */
.message-content ul.checkbox-list {
    list-style-type: none;
    padding-left: 0;
    margin: 2px 0 10px 0; /* Top/side margins tight, 10px bottom spacing */
}

.message-content ul.checkbox-list li {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1px; /* Very compact spacing */
    padding-left: 0;
    line-height: 1.3; /* Tighter line height */
}

.message-content .checkbox-icon {
    margin-right: 8px;
    font-size: 14px;
    line-height: 1.5;
    flex-shrink: 0;
}

/* Dark theme checkbox styling */
[data-theme="dark"] .message-content ul.checkbox-list li {
    color: #e5e7eb;
}

/* Horizontal rule styling for section separators */
.message-content hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 16px 0;
    opacity: 0.6;
}

[data-theme="dark"] .message-content hr {
    border-top-color: var(--border-medium);
}

/* Code formatting */
.message-content code {
    background: var(--bg-tertiary);
    color: var(--theme-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    border: 1px solid var(--border-light);
}

.message-content .inline-code {
    background: var(--bg-secondary);
    color: var(--theme-primary-dark);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 500;
}

.message-content .code-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
    overflow-x: auto;
    position: relative;
}

.message-content .code-block::before {
    content: attr(data-language);
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 500;
}

.message-content .code-block code {
    background: none;
    color: var(--text-primary);
    padding: 0;
    border: none;
    font-size: 13px;
    line-height: 1.3;
}

/* Links */
.message-content a {
    color: var(--theme-primary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.message-content a:hover {
    border-bottom-color: var(--theme-primary);
    background: rgba(74, 144, 226, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    margin: -2px -4px;
}

/* Email links - use same color as regular links in light theme */
.message-content a[href^="mailto:"] {
    color: var(--theme-primary);
}

.message-content a[href^="mailto:"]:hover {
    border-bottom-color: var(--theme-primary);
    background: rgba(74, 144, 226, 0.1);
}

/* External links indicator */
.message-content a[target="_blank"]::after {
    content: " ↗";
    font-size: 12px;
    opacity: 0.7;
    margin-left: 2px;
}

/* Text formatting - LLM-style */
.message-content strong {
    font-weight: 500; /* Medium weight instead of bold */
    color: var(--text-primary);
}

/* Technical section headers (like "Real-Time Sync:", "Bidirectional Flow:") */
.message-content strong:has(+ br),
.message-content p:has(strong:contains(":")) {
    margin-bottom: 4px;
}

.message-content strong[contains=":"] {
    display: block;
    margin: 8px 0 4px 0;
    color: var(--text-primary);
}

/* Section headers like Challenge:, Solution:, Results: need proper spacing */
.message-content .section-header {
    display: block;
    margin: 16px 0 6px 0; /* Balanced spacing: 16px top, 6px bottom for section headers with colons */
    padding: 0; /* Zero padding for alignment */
    margin-left: 0; /* Explicit zero left margin */
    text-indent: 0; /* No text indentation */
    font-weight: 600; /* Slightly bolder for section headers */
    color: var(--text-primary);
}

/* Headers that appear before lists should align with list content */
.message-content h2 + .message-list,
.message-content h3 + .message-list {
    margin-top: 8px; /* Add some space between header and list */
}

/* Reduce general header bottom spacing to align better with content */

/* Dark theme strong text */
[data-theme="dark"] .message-content strong {
    color: #f9fafb; /* Near white for emphasis */
    font-weight: 500; /* Medium weight */
}

.message-content em {
    font-style: italic;
    color: var(--text-secondary);
}

/* Dark theme enhancements - LLM-style */
[data-theme="dark"] .message-content h1 {
    border-bottom-color: var(--border-medium);
    color: #f9fafb;  /* Near white for main headers */
    font-weight: 600; /* Less bold */
}

[data-theme="dark"] .message-content h2 {
    border-bottom-color: var(--border-medium);
    color: #f3f4f6;  /* White for section headers */
    font-weight: 500; /* Medium weight */
}

[data-theme="dark"] .message-content h3,
[data-theme="dark"] .message-content h4 {
    color: #f3f4f6;  /* White for sub-headers */
    font-weight: 500; /* Medium weight */
}

[data-theme="dark"] .message-content code {
    background: var(--bg-tertiary);
    color: var(--editor-primary);
    border-color: var(--border-medium);
}

[data-theme="dark"] .message-content .inline-code {
    background: var(--bg-tertiary);
    color: var(--editor-primary);
}

[data-theme="dark"] .message-content .code-block {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
}

[data-theme="dark"] .message-content a {
    color: var(--theme-primary);  /* Use branding primary color (teal/brand color) */
    font-weight: 400; /* Normal weight */
    text-decoration: underline; /* Ensure links are visible */
}

/* Ensure all links in dark mode are visible */
[data-theme="dark"] a {
    color: var(--theme-primary);
    text-decoration: underline;
}

/* Specifically for modal content links in dark mode */
[data-theme="dark"] .modal-content-body a,
[data-theme="dark"] .modal-content-display a {
    color: var(--theme-primary) !important;
    text-decoration: underline !important;
}

[data-theme="dark"] .message-content a:hover {
    border-bottom-color: var(--theme-primary, #60a5fa);
    background: rgba(96, 165, 250, 0.1);
    color: var(--theme-accent, #93c5fd); /* Use brand accent on hover */
}

[data-theme="dark"] .message-content a[href^="mailto:"] {
    color: var(--theme-primary-light, #34d399);  /* Use branding teal for email links */
}

[data-theme="dark"] .message-content a[href^="mailto:"]:hover {
    border-bottom-color: var(--theme-primary-light, #34d399);
    background: rgba(52, 211, 153, 0.1);
    color: var(--theme-primary-dark, #6ee7b7); /* Lighter teal on hover */
}

[data-theme="dark"] .message-content .message-list li {
    color: #e5e7eb;  /* Light gray for list items, not orange */
}

/* Conversation Details Modal - Override all other modal styles */
.conversation-details-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 99999 !important; /* Extremely high z-index to appear above everything */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(4px) !important;
}

.conversation-details-modal .modal-content {
    max-width: 900px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    position: relative !important;
    z-index: 99999 !important; /* Ensure modal content is on top */
    background: var(--bg-primary) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-lg) !important;
}

.conversation-details-modal .modal-overlay {
    z-index: 99998; /* Just below modal content but above everything else */
}

.conversation-meta {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

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

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-item label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-item span {
    color: var(--text-primary);
    font-weight: 500;
}

.conversation-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.conversation-section {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
}

.conversation-section h4 {
    background: var(--bg-tertiary);
    margin: 0;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
}

.conversation-text {
    padding: 16px;
    background: var(--bg-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
}

.conversation-text.user-prompt {
    background: var(--bg-secondary);
    border-left: 3px solid var(--theme-secondary-dark);
    font-style: italic;
}

.conversation-text.llm-response {
    background: var(--bg-primary);
    border-left: 3px solid var(--theme-primary);
}

.conversation-text.error-text {
    background: #fef2f2;
    border-left: 3px solid #ef4444;
    color: #dc2626;
}

.context-list {
    padding: 16px;
    background: var(--bg-primary);
}

.context-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.relevance-score {
    background: var(--theme-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.clickable-row:hover {
    background: var(--bg-secondary);
}

.error-section h4 {
    background: #fef2f2;
    color: #dc2626;
}

/* Dark theme conversation modal */
[data-theme="dark"] .conversation-text.user-prompt {
    background: var(--chat-user-bg);
    border-left-color: var(--theme-primary-dark);
}

[data-theme="dark"] .conversation-text.error-text {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: #ef4444;
    color: #fca5a5;
}

[data-theme="dark"] .error-section h4 {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

/* API Configuration Styling */
.config-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-light);
}

.config-section h6 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-section h6 i {
    color: var(--theme-primary);
}

.api-key-input {
    position: relative;
    display: flex;
    align-items: center;
}

.api-key-input input {
    flex: 1;
    padding-right: 45px;
}

.toggle-visibility {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toggle-visibility:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.form-help {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 4px;
    font-style: italic;
}

/* Dark theme API config */
[data-theme="dark"] .config-section {
    background: var(--bg-primary);
    border-color: var(--border-dark);
}

[data-theme="dark"] .config-section h6 i {
    color: var(--editor-primary);
}

/* Message Action Buttons - v1.6.1: Always visible for improved accessibility */
.message-actions {
    display: flex;
    gap: 8px;
    opacity: 1; /* Changed from 0 to 1 - always visible like mobile */
    transition: opacity 0.2s ease;
    margin-top: 8px;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.message-action-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.message-action-btn i {
    font-size: 11px;
}

.copy-btn:hover {
    color: var(--theme-primary);
    border-color: var(--theme-primary);
}

.email-btn:hover {
    color: var(--theme-primary-light);
    border-color: var(--theme-primary-light);
}

/* v1.6.1: Updated to match copy/email button hover colors for consistency */
.react-btn:hover {
    color: var(--theme-primary); /* Changed from --editor-special to match copy button */
    border-color: var(--theme-primary);
}

.forward-btn:hover {
    color: var(--theme-primary-light); /* Changed from --editor-success to match email button */
    border-color: var(--theme-primary-light);
}

/* Dark theme action button styling */
[data-theme="dark"] .message-action-btn {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
    color: var(--text-muted);
}

[data-theme="dark"] .message-action-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

[data-theme="dark"] .copy-btn:hover {
    color: var(--editor-primary);
    border-color: var(--editor-primary);
}

[data-theme="dark"] .email-btn:hover {
    color: #14b8a6;
    border-color: #14b8a6;
}

[data-theme="dark"] .react-btn:hover {
    color: var(--editor-primary);
    border-color: var(--editor-primary);
}

[data-theme="dark"] .forward-btn:hover {
    color: #14b8a6;
    border-color: #14b8a6;
}

/* Chat Input */
/* OLD .chat-input-container removed - now using .input-bar-fixed */

/* New fixed input bar - viewport-level positioning */
.input-bar-fixed {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width, 280px);
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
    padding: 24px 24px 16px 24px;  /* Increased top padding: 16px → 24px for more separation */
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));  /* iPhone X+ safe area */
    z-index: 100;  /* Above content, below modals */
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);  /* Stronger shadow for better separation */
    transition: left 0.3s ease;  /* Smooth sidebar toggle */
}

.input-bar-content {
    max-width: 1200px;
    margin: 0 auto;
}

/* Responsive breakpoints for input bar */
@media (max-width: 932px) {
    /* On mobile/tablet: input bar ALWAYS full width, sidebar ALWAYS overlays */
    .input-bar-fixed {
        left: 0 !important;  /* Always full width on mobile - sidebar overlays */
        padding: 16px 16px 12px 16px;
        z-index: 1001 !important;  /* Above sidebar overlay (1000) */
    }
    
    .chat-messages {
        padding-bottom: 220px;  /* Space for input bar */
    }
    
    /* Sidebar needs bottom padding so menu items aren't cut off by input bar */
    .sidebar-content,
    .sections-container {
        padding-bottom: 120px;  /* Space for overlaying input bar */
    }
}

/* Landscape mobile: more padding needed due to shorter height */
@media (max-width: 932px) and (orientation: landscape) {
    .sidebar-content,
    .sections-container {
        padding-bottom: 160px;  /* Extra space in landscape */
    }
    
    .chat-messages {
        padding-bottom: 240px;  /* Extra space in landscape */
    }
    
    /* Ensure chat content fits within viewport (no horizontal scroll) */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    .main-container {
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .main-content {
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .chat-container {
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .chat-messages {
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    .input-bar-fixed {
        left: 0 !important;  /* Always full width on mobile */
        padding: 12px 12px 10px 12px;
        z-index: 1001 !important;  /* Above sidebar (1000) on mobile */
    }
    
    .chat-messages {
        padding: 16px;
        padding-bottom: 200px;  /* Increased for mobile */
    }
}

/* Sidebar collapsed state */
.sidebar.collapsed ~ .input-bar-fixed {
    left: var(--sidebar-collapsed-width, 60px);
}

.chat-input-wrapper {
    position: relative;
    background: var(--input-bg, var(--bg-secondary));
    border: 2px solid var(--input-border, var(--theme-secondary-dark));
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 0 0 1px var(--input-border, rgba(210, 105, 30, 0.1));
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.chat-input-wrapper:focus-within {
    border-color: var(--input-border, var(--theme-secondary-dark));
    box-shadow: 0 0 0 2px rgba(210, 105, 30, 0.2);
}

.chat-input {
    flex: 1 0 auto;
    min-width: 0;
    max-width: 100%;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    min-height: 44px;
    height: 44px;
    max-height: 200px;
    box-sizing: border-box;
}

.chat-input::placeholder {
    color: var(--input-placeholder, var(--text-muted));
}

.chat-input:focus {
    border: none;
    outline: none;
    box-shadow: none;
}

/* Dark theme chat input styling - CONSISTENT 2px border with light theme */
[data-theme="dark"] .chat-input-wrapper {
    background: var(--input-bg, var(--bg-secondary));
    border: 2px solid var(--input-border, var(--editor-primary)); /* Same 2px as light theme */
    box-shadow: 0 0 0 1px rgba(78, 201, 176, 0.2);
}

[data-theme="dark"] .chat-input-wrapper:focus-within {
    border: 2px solid var(--input-border, var(--editor-primary)); /* Explicit 2px on focus too */
    box-shadow: 0 0 0 2px rgba(78, 201, 176, 0.3);
}

[data-theme="dark"] .chat-input {
    color: var(--input-text, var(--text-primary));
}

[data-theme="dark"] .chat-input::placeholder {
    color: var(--input-placeholder, var(--text-muted));
}

[data-theme="dark"] .chat-input {
    border: none;
    outline: none;
}

[data-theme="dark"] .chat-input:focus {
    border: none;
    outline: none;
    box-shadow: none;
}

/* History Navigation Arrows (inside input bar) */
.history-navigation {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-right: 4px;
    flex-shrink: 0;
}

.history-nav-btn {
    background: transparent;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    width: 22px;
    height: 18px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.15s ease;
    font-size: 10px;
}

.history-nav-btn:hover:not(:disabled) {
    background: var(--hover-bg, #f0f0f0);
    border-color: var(--theme-secondary-light, #D2691E);
    color: var(--theme-secondary-light, #D2691E);
}

.history-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.history-nav-btn:active:not(:disabled) {
    transform: scale(0.95);
}

/* Dark theme history navigation */
[data-theme="dark"] .history-nav-btn {
    border-color: var(--border-color, #444);
    color: var(--text-muted);
}

[data-theme="dark"] .history-nav-btn:hover:not(:disabled) {
    background: var(--hover-bg, #333);
    border-color: var(--editor-primary, #4EC9B0);
    color: var(--editor-primary, #4EC9B0);
}

/* Prompt History Settings Section */
.prompt-history-settings {
    padding: 10px 0;
}

.prompt-history-description {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.send-button {
    background: var(--send-button-bg, var(--theme-secondary-light));
    color: var(--send-icon-color, white);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:disabled {
    background: var(--send-button-bg, var(--theme-secondary-light));
    color: var(--send-icon-color, white);
    cursor: not-allowed;
    opacity: 0.6;
}

.send-button:not(:disabled) {
    background: var(--send-button-bg, var(--theme-secondary-light));
}

.send-button.has-text:not(:disabled) {
    background: var(--send-button-hover, var(--theme-secondary-dark));
}

.send-button:hover:not(:disabled) {
    background: var(--send-button-hover, #B8651A);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.show {
    display: flex;
}

/* Modal overlay (for diagram viewer and other full-screen modals) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    align-items: center;
    justify-content: center;
    z-index: 17000; /* Above full response modal (16000) */
    display: none; /* Hidden by default, shown via style.display = 'flex' */
}

.modal-overlay[style*="display: flex"] {
    display: flex !important;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 400px;
    max-height: 90vh;  /* Never taller than 90% of viewport */
    display: flex;
    flex-direction: column;
    overflow: hidden;  /* Keep for rounded corners */
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;  /* Don't shrink header */
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--hover-bg);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;  /* Scrollable content */
    flex: 1;           /* Takes remaining space between header and footer */
    -webkit-overflow-scrolling: touch;  /* Smooth scrolling on iOS */
}

.modal-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
}

.modal-input:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-shrink: 0;  /* Don't shrink footer */
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    /* Default styling - outlined button */
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
}

.modal-btn.cancel {
    background: none;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
}

.modal-btn.cancel:hover {
    background: var(--hover-bg);
}

.modal-btn.confirm {
    background: var(--theme-primary);
    border: none;
    color: white;
}

.modal-btn.confirm:hover {
    background: var(--theme-primary-dark);
}

/* Contact Form Modal Styles */
.contact-modal {
    max-width: 500px;
    width: 95%;
}

/* Thank You Modal Styles */
.thank-you-body {
    text-align: center;
    padding: 2rem 1rem;
}

.thank-you-icon {
    font-size: 4rem;
    color: var(--success-color);
    margin-bottom: 1.5rem;
}

.thank-you-icon i {
    animation: checkmark-bounce 0.6s ease-in-out;
}

@keyframes checkmark-bounce {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.thank-you-message {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.thank-you-support {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 1rem;
}

.support-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.support-link:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.support-link:visited {
    color: var(--accent-color);
}

/* Welcome Message HTML Formatting */
.welcome-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.welcome-text {
    line-height: 1.6;
    color: var(--text-primary);
}

.welcome-text b,
.welcome-text strong {
    font-weight: 600;
    color: var(--text-primary);
}

.welcome-text i,
.welcome-text em {
    font-style: italic;
}

.welcome-text br {
    line-height: 1.6;
}

.welcome-text p {
    margin-bottom: 1rem;
}

.welcome-text p:last-child {
    margin-bottom: 0;
}

/* Professional Table Styling for Chat Messages */
.table-wrapper {
    overflow-x: auto;
    margin: 1.5rem 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-light);
    max-width: 100%;
    width: fit-content;
    min-width: 100%;
    box-sizing: border-box;
    background: transparent;
    position: relative;
}

/* Mobile: table wrapper fits chat area - EXTENDED to 932px for landscape phones */
@media (max-width: 932px) {
    /* Force message-content to full width so cards can expand */
    .message-content {
        width: 100%;  /* Force full width (was: auto, causing cards to shrink) */
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: visible !important;  /* CRITICAL: Don't clip bubble borders/radius when cards are present */
    }
    
    /* Ensure assistant message styling persists on mobile */
    .assistant-message .message-content {
        background: var(--bg-tertiary) !important;
        border-radius: 12px !important;
        padding: 16px !important;
        margin-left: 8px !important;
        border-left: 3px solid var(--theme-primary-light) !important;
        overflow-x: visible !important;  /* CRITICAL: Prevent clipping of bubble styling */
    }
    
    /* Dark theme assistant message on mobile */
    [data-theme="dark"] .assistant-message .message-content {
        background: var(--chat-assistant-bg) !important;
        border-left: 3px solid var(--theme-primary-light) !important;
    }
    
    .table-wrapper {
        width: 100%;  /* Full width of available space */
        min-width: auto;  /* Don't force minimum */
        max-width: 100%;  /* Respect container */
        overflow: visible;  /* No scroll for cards */
        box-sizing: border-box;
        margin: 0.5rem 0;  /* Vertical margin only - stay within bubble padding */
        box-shadow: none;  /* Remove shadow from wrapper, cards have their own */
        border: none;  /* Remove border from wrapper, cards have their own */
    }
}

.message-table {
    width: 100%;
    min-width: 400px;
    max-width: 100%;
    border-collapse: collapse;
    margin: 0;
    background: var(--bg-primary);
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed;
    box-sizing: border-box;
    font-size: 13px;  /* Smaller table font */
}

.message-table thead {
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
    color: white !important;
}

.message-table th {
    padding: 10px 10px;  /* Reduced from 14px 12px */
    text-align: left;
    font-weight: 600;  /* Reduced from 700 */
    font-size: 11px;  /* Smaller header text */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 2px solid var(--table-header-gradient-end, var(--theme-primary-dark));  /* Reduced from 3px */
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    color: white !important;
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
    box-sizing: border-box;
}

.message-table th:last-child {
    border-right: none;
}

.message-table td {
    padding: 10px 10px;  /* Reduced from 14px 12px */
    border-bottom: 1px solid var(--table-cell-border, var(--theme-primary-light));
    border-right: 1px solid var(--table-cell-border, var(--theme-primary-light));
    vertical-align: top;
    line-height: 1.5;  /* Tightened from 1.6 */
    color: var(--table-body-text, var(--text-primary));
    background: var(--bg-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    font-size: 13px;  /* Explicit smaller size */
    box-sizing: border-box;
}

.message-table td:last-child {
    border-right: none;
}

.message-table tbody tr:nth-child(even) {
    background: var(--table-row-even-bg, var(--bg-secondary));
}

.message-table tbody tr:hover {
    background: var(--table-row-hover, rgba(0, 0, 0, 0.03));
    transition: background 0.2s ease;
    /* No transform, no shadow, no border-color change - keeps borders visible */
}

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

/* Special styling for checkmark/cross cells */
.message-table td:has(.fas.fa-check),
.message-table td:has(.fas.fa-times) {
    text-align: center;
    width: 60px;
    font-size: 1.1rem;
}

/* Enhanced visual separation - Light theme (blue) */
.message-table th:first-child {
    border-left: 4px solid var(--theme-primary-dark);
    font-weight: 800;
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
    color: white !important;
}

.message-table td:first-child {
    border-left: 4px solid var(--table-first-column, var(--theme-primary-light));
    font-weight: 600;
    background: var(--table-first-column-bg, rgba(91, 167, 247, 0.1)) !important;
    color: var(--table-first-column-text, var(--text-primary)) !important;
}

/* Better icon styling in tables */
.message-table .fas {
    font-size: 1.2rem;
    margin: 0 4px;
}

.message-table .fa-check-circle,
.message-table .fa-check,
.message-table .fa-check-square {
    color: #10b981 !important;
}

.message-table .fa-times-circle,
.message-table .fa-times {
    color: #ef4444 !important;
}

.message-table .fa-exclamation-triangle {
    color: #f59e0b !important;
}

/* Dark theme table styling - uses customizable colors from branding */
[data-theme="dark"] .message-table thead {
    background: linear-gradient(135deg, var(--table-header-gradient-start, #14b8a6), var(--table-header-gradient-end, #0d9488));
    color: white;
}

[data-theme="dark"] .message-table th {
    background: linear-gradient(135deg, var(--table-header-gradient-start, #14b8a6), var(--table-header-gradient-end, #0d9488)) !important;
    color: white !important;
    border-bottom: 3px solid var(--table-header-gradient-end, #0d9488);
}

/* ========================================
   RESPONSIVE TABLE SYSTEM
   ======================================== */

/* Large Tablets & Landscape Phones (iPad Mini, iPhone Pro Max landscape) */
@media (max-width: 1024px) {
    /* Ensure bubble styling on landscape phones and tablets */
    .assistant-message .message-content {
        background: var(--bg-tertiary) !important;
        border-radius: 12px !important;
        padding: 16px !important;
        margin-left: 8px !important;
        border-left: 3px solid var(--theme-primary-light) !important;
        overflow-x: visible !important;
    }
    
    /* Prevent horizontal overflow on tablets */
    .chat-container {
        width: 100% !important;  /* Override desktop 80% - use full available width */
        max-width: none !important;  /* Remove 1200px desktop constraint */
        padding: 0 16px !important;  /* Tighter padding */
        margin: 0 !important;  /* Remove auto margins */
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .chat-messages {
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .message-content {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    [data-theme="dark"] .assistant-message .message-content {
        background: var(--chat-assistant-bg) !important;
        border-left: 3px solid var(--theme-primary-light) !important;
    }
}

/* Tablet Optimization */
@media (max-width: 768px) {
    .message-table {
        min-width: 350px;  /* Reduce from 400px */
        font-size: 0.8rem;
    }
    
    .message-table th,
    .message-table td {
        padding: 10px 8px;
        font-size: 0.75rem;
    }
    
    .message-table th {
        font-size: 0.7rem;
    }
    
    /* Ensure bubble styling on tablets too */
    .assistant-message .message-content {
        background: var(--bg-tertiary) !important;
        border-radius: 12px !important;
        padding: 16px !important;
        margin-left: 8px !important;
        border-left: 3px solid var(--theme-primary-light) !important;
        overflow-x: visible !important;
    }
    
    [data-theme="dark"] .assistant-message .message-content {
        background: var(--chat-assistant-bg) !important;
        border-left: 3px solid var(--theme-primary-light) !important;
    }
}

/* Mobile Optimization - Base Styles - EXTENDED to 932px */
@media (max-width: 932px) {
    .table-wrapper {
        margin: 1rem 0;
        border-radius: 6px;
    }
    
    .message-table {
        min-width: 300px;  /* Further reduce for mobile */
        font-size: 0.7rem;
    }
    
    .message-table th,
    .message-table td {
        padding: 8px 6px;
        font-size: 0.65rem;
        word-break: break-word;
    }
    
    .message-table th {
        font-size: 0.6rem;
        letter-spacing: 0.3px;
    }
}

/* ========================================
   MOBILE TABLE STRATEGY (≤640px)
   ALL TABLES: Card transform for maximum readability
   ======================================== */

/* Card Transform for ALL Tables on Mobile - EXTENDED to 932px */
@media (max-width: 932px) {
    /* CRITICAL: Preserve bubble styling when cards transform */
    .assistant-message .message-content {
        background: var(--bg-tertiary) !important;
        border-radius: 12px !important;
        padding: 16px !important;
        margin-left: 8px !important;
        border-left: 3px solid var(--theme-primary-light) !important;
        overflow-x: visible !important;
    }
    
    [data-theme="dark"] .assistant-message .message-content {
        background: var(--chat-assistant-bg) !important;
        border-left: 3px solid var(--theme-primary-light) !important;
    }
    
    /* Hide thead for ALL card-style tables */
    .message-table[data-columns="2"] thead,
    .message-table[data-columns="3"] thead,
    .message-table[data-columns="4"] thead,
    .message-table[data-columns="5"] thead,
    .message-table[data-columns="6"] thead,
    .message-table[data-columns="7"] thead,
    .message-table[data-columns="8"] thead,
    .message-table[data-columns="9"] thead,
    .message-table[data-columns="10"] thead {
        display: none !important;  /* Force hide with !important */
    }
    
    .message-table[data-columns="2"] thead tr,
    .message-table[data-columns="3"] thead tr,
    .message-table[data-columns="4"] thead tr,
    .message-table[data-columns="5"] thead tr,
    .message-table[data-columns="6"] thead tr,
    .message-table[data-columns="7"] thead tr,
    .message-table[data-columns="8"] thead tr,
    .message-table[data-columns="9"] thead tr,
    .message-table[data-columns="10"] thead tr,
    .message-table[data-columns="2"] th,
    .message-table[data-columns="3"] th,
    .message-table[data-columns="4"] th,
    .message-table[data-columns="5"] th,
    .message-table[data-columns="6"] th,
    .message-table[data-columns="7"] th,
    .message-table[data-columns="8"] th,
    .message-table[data-columns="9"] th,
    .message-table[data-columns="10"] th {
        display: none !important;  /* Force hide all header elements */
    }
    
    /* Transform table structure for ALL column counts */
    .message-table[data-columns="2"],
    .message-table[data-columns="3"],
    .message-table[data-columns="4"],
    .message-table[data-columns="5"],
    .message-table[data-columns="6"],
    .message-table[data-columns="7"],
    .message-table[data-columns="8"],
    .message-table[data-columns="9"],
    .message-table[data-columns="10"] {
        display: block;
        width: 100%;  /* Span full width of container */
        max-width: 100%;  /* Don't exceed container */
        min-width: 0 !important;  /* Force override ALL min-width rules (400px, 350px, 300px) */
        border: none;
        box-sizing: border-box;
    }
    
    .message-table[data-columns="2"] tbody,
    .message-table[data-columns="3"] tbody,
    .message-table[data-columns="4"] tbody,
    .message-table[data-columns="5"] tbody,
    .message-table[data-columns="6"] tbody,
    .message-table[data-columns="7"] tbody,
    .message-table[data-columns="8"] tbody,
    .message-table[data-columns="9"] tbody,
    .message-table[data-columns="10"] tbody {
        display: block;
    }
    
    /* Each row becomes a card (ALL columns) - no border, cells handle borders */
    .message-table[data-columns="2"] tbody tr,
    .message-table[data-columns="3"] tbody tr,
    .message-table[data-columns="4"] tbody tr,
    .message-table[data-columns="5"] tbody tr,
    .message-table[data-columns="6"] tbody tr,
    .message-table[data-columns="7"] tbody tr,
    .message-table[data-columns="8"] tbody tr,
    .message-table[data-columns="9"] tbody tr,
    .message-table[data-columns="10"] tbody tr {
        display: block;
        width: calc(100% - 16px);  /* Slightly narrower to show bubble around edges */
        max-width: 100%;  /* Don't exceed */
        box-sizing: border-box;  /* Include padding/border in width */
        margin: 0 8px 12px 8px;  /* Add horizontal margin to reveal bubble edges */
        border: none;  /* No card border - cells have their own */
        border-radius: 8px;
        padding: 0;  /* Remove padding - let cells handle spacing */
        overflow: visible;  /* Don't clip - allow borders to show */
        background: var(--bg-secondary);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);  /* Subtle card shadow */
    }
    
    /* Stack cells vertically (ALL columns) - 1px borders with negative margin to collapse */
    .message-table[data-columns="2"] td,
    .message-table[data-columns="3"] td,
    .message-table[data-columns="4"] td,
    .message-table[data-columns="5"] td,
    .message-table[data-columns="6"] td,
    .message-table[data-columns="7"] td,
    .message-table[data-columns="8"] td,
    .message-table[data-columns="9"] td,
    .message-table[data-columns="10"] td {
        display: block;
        text-align: left;
        padding: 12px 16px;  /* Better padding for card sections */
        border: 1px solid var(--theme-primary-light) !important;  /* 1px borders on all 4 sides */
        margin-top: -1px !important;  /* Collapse adjacent borders */
        max-width: none !important;  /* Remove base 150px limit */
        width: 100% !important;      /* Force full card width */
        box-sizing: border-box !important;
        font-size: 0.85rem;
    }
    
    /* First cell: no negative margin, 4px left border accent, background fill */
    .message-table[data-columns] td:first-child {
        margin-top: 0 !important;  /* First cell doesn't need negative margin */
        border: 1px solid var(--theme-primary-light) !important;  /* Set all borders first */
        border-left: 4px solid var(--theme-primary-light) !important;  /* Then override left with 4px */
        background: var(--table-first-column-bg, rgba(91, 167, 247, 0.1)) !important;  /* Light blue background fill */
        background-color: var(--table-first-column-bg, rgba(91, 167, 247, 0.1)) !important;  /* Ensure background color */
        font-weight: 600 !important;  /* Bold first column */
        color: var(--table-first-column-text, var(--text-primary)) !important;  /* Text color */
    }
    
    /* Last cell: override desktop rule that removes right border */
    .message-table[data-columns="2"] td:last-child,
    .message-table[data-columns="3"] td:last-child,
    .message-table[data-columns="4"] td:last-child,
    .message-table[data-columns="5"] td:last-child,
    .message-table[data-columns="6"] td:last-child,
    .message-table[data-columns="7"] td:last-child,
    .message-table[data-columns="8"] td:last-child,
    .message-table[data-columns="9"] td:last-child,
    .message-table[data-columns="10"] td:last-child {
        border-right: 1px solid var(--theme-primary-light) !important;  /* Restore right border in card mode */
    }
    
    
    /* Add labels using data attributes (ALL columns) */
    .message-table[data-columns="2"] td::before,
    .message-table[data-columns="3"] td::before,
    .message-table[data-columns="4"] td::before,
    .message-table[data-columns="5"] td::before,
    .message-table[data-columns="6"] td::before,
    .message-table[data-columns="7"] td::before,
    .message-table[data-columns="8"] td::before,
    .message-table[data-columns="9"] td::before,
    .message-table[data-columns="10"] td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--theme-primary-dark);
        display: block;
        margin-bottom: 4px;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    [data-theme="dark"] .message-table[data-columns="2"] td::before,
    [data-theme="dark"] .message-table[data-columns="3"] td::before,
    [data-theme="dark"] .message-table[data-columns="4"] td::before,
    [data-theme="dark"] .message-table[data-columns="5"] td::before,
    [data-theme="dark"] .message-table[data-columns="6"] td::before,
    [data-theme="dark"] .message-table[data-columns="7"] td::before,
    [data-theme="dark"] .message-table[data-columns="8"] td::before,
    [data-theme="dark"] .message-table[data-columns="9"] td::before,
    [data-theme="dark"] .message-table[data-columns="10"] td::before {
        color: #14b8a6;
    }
    
    /* Dark theme: use teal for all cell borders */
    [data-theme="dark"] .message-table[data-columns="2"] td,
    [data-theme="dark"] .message-table[data-columns="3"] td,
    [data-theme="dark"] .message-table[data-columns="4"] td,
    [data-theme="dark"] .message-table[data-columns="5"] td,
    [data-theme="dark"] .message-table[data-columns="6"] td,
    [data-theme="dark"] .message-table[data-columns="7"] td,
    [data-theme="dark"] .message-table[data-columns="8"] td,
    [data-theme="dark"] .message-table[data-columns="9"] td,
    [data-theme="dark"] .message-table[data-columns="10"] td {
        border-color: #14b8a6 !important;  /* Teal borders in dark mode */
    }
    
    /* Dark theme: teal accent and background on first cell */
    [data-theme="dark"] .message-table[data-columns] td:first-child {
        border-color: #14b8a6 !important;  /* Teal borders */
        border-left-color: #14b8a6 !important;  /* Teal accent in dark mode */
        background: var(--table-first-column-bg, rgba(20, 184, 166, 0.15)) !important;  /* Teal background fill */
        background-color: var(--table-first-column-bg, rgba(20, 184, 166, 0.15)) !important;  /* Ensure background color */
        color: var(--table-first-column-text, #ffffff) !important;  /* White text */
    }
    
    /* Dark theme: teal right border on last cell */
    [data-theme="dark"] .message-table[data-columns="2"] td:last-child,
    [data-theme="dark"] .message-table[data-columns="3"] td:last-child,
    [data-theme="dark"] .message-table[data-columns="4"] td:last-child,
    [data-theme="dark"] .message-table[data-columns="5"] td:last-child,
    [data-theme="dark"] .message-table[data-columns="6"] td:last-child,
    [data-theme="dark"] .message-table[data-columns="7"] td:last-child,
    [data-theme="dark"] .message-table[data-columns="8"] td:last-child,
    [data-theme="dark"] .message-table[data-columns="9"] td:last-child,
    [data-theme="dark"] .message-table[data-columns="10"] td:last-child {
        border-right-color: #14b8a6 !important;  /* Teal right border in dark mode */
    }
    
    .message-table[data-columns="2"] tbody tr:hover,
    .message-table[data-columns="3"] tbody tr:hover,
    .message-table[data-columns="4"] tbody tr:hover,
    .message-table[data-columns="5"] tbody tr:hover,
    .message-table[data-columns="6"] tbody tr:hover,
    .message-table[data-columns="7"] tbody tr:hover,
    .message-table[data-columns="8"] tbody tr:hover,
    .message-table[data-columns="9"] tbody tr:hover,
    .message-table[data-columns="10"] tbody tr:hover {
        background: rgba(0, 0, 0, 0.03);  /* Subtle neutral gray */
        /* No transform or shadow - keeps table stable */
    }
    
    /* ========================================
       OLD: ULTRA-COMPACT TABLE MODE (4-5 columns) - DISABLED
       Now using card view for ALL tables on mobile
       Code retained for reference if reverting needed
       ======================================== */
    
    /* DISABLED - 4-5 column tables now use card view above
    .message-table[data-columns="4"],
    .message-table[data-columns="5"] {
        font-size: 0.55rem;
        min-width: 0 !important;
        display: table;
    }
    
    .message-table[data-columns="4"] th,
    .message-table[data-columns="5"] th {
        font-size: 0.45rem;
        padding: 3px 2px;
        letter-spacing: 0.2px;
        line-height: 1.2;
        word-break: break-word;
    }
    
    .message-table[data-columns="4"] td,
    .message-table[data-columns="5"] td {
        font-size: 0.5rem;
        padding: 4px 3px;
        line-height: 1.3;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    */
}

/* Extra Small Mobile (iPhone SE, etc) */
@media (max-width: 480px) {
    .message-table {
        min-width: 280px;
        font-size: 0.65rem;
    }
    
    .message-table th,
    .message-table td {
        padding: 6px 4px;
        font-size: 0.6rem;
    }
    
    /* Card view adjustments for tiny screens (ALL columns) */
    .message-table[data-columns="2"] tbody tr,
    .message-table[data-columns="3"] tbody tr,
    .message-table[data-columns="4"] tbody tr,
    .message-table[data-columns="5"] tbody tr,
    .message-table[data-columns="6"] tbody tr,
    .message-table[data-columns="7"] tbody tr,
    .message-table[data-columns="8"] tbody tr,
    .message-table[data-columns="9"] tbody tr,
    .message-table[data-columns="10"] tbody tr {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .message-table[data-columns="2"] td,
    .message-table[data-columns="3"] td,
    .message-table[data-columns="4"] td,
    .message-table[data-columns="5"] td,
    .message-table[data-columns="6"] td,
    .message-table[data-columns="7"] td,
    .message-table[data-columns="8"] td,
    .message-table[data-columns="9"] td,
    .message-table[data-columns="10"] td {
        font-size: 0.8rem;
        padding: 5px 0;
    }
    
    .message-table[data-columns="2"] td::before,
    .message-table[data-columns="3"] td::before,
    .message-table[data-columns="4"] td::before,
    .message-table[data-columns="5"] td::before,
    .message-table[data-columns="6"] td::before,
    .message-table[data-columns="7"] td::before,
    .message-table[data-columns="8"] td::before,
    .message-table[data-columns="9"] td::before,
    .message-table[data-columns="10"] td::before {
        font-size: 0.65rem;
    }
    
    /* OLD: Ultra-compact for 4-5 columns - DISABLED (now using card view above)
    .message-table[data-columns="4"],
    .message-table[data-columns="5"] {
        font-size: 0.5rem;
        min-width: 270px;
    }
    
    .message-table[data-columns="4"] th,
    .message-table[data-columns="5"] th {
        font-size: 0.4rem;
        padding: 2px 1px;
    }
    
    .message-table[data-columns="4"] td,
    .message-table[data-columns="5"] td {
        font-size: 0.45rem;
        padding: 3px 2px;
    }
    */
}

/* OLD: Scroll indicator for wide tables - DISABLED (all tables now use cards)
@media (max-width: 640px) {
    .table-wrapper:not(:has(.message-table[data-columns="2"])):not(:has(.message-table[data-columns="3"]))::after {
        content: "← Swipe to see more →";
        display: block;
        text-align: center;
        font-size: 0.65rem;
        color: var(--text-muted);
        padding: 6px;
        background: var(--bg-tertiary);
        border-top: 1px solid var(--border-light);
        font-style: italic;
    }
*/
    
/* Mobile: All tables use card view (no scroll indicator needed) */
@media (max-width: 640px) {
    
    /* Diagram containers also constrained */
    .diagram-container,
    .diagram-section {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* SVG diagrams scale to fit */
    .diagram-container svg,
    .mermaid svg {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    /* CRITICAL: Final bubble styling - must be LAST to override all other 640px rules */
    .assistant-message .message-content {
        background: var(--bg-tertiary) !important;
        border-radius: 12px !important;
        padding: 16px !important;
        margin-left: 8px !important;
        border-left: 3px solid var(--theme-primary-light) !important;
        overflow-x: visible !important;
    }
    
    [data-theme="dark"] .assistant-message .message-content {
        background: var(--chat-assistant-bg) !important;
        border-left: 3px solid var(--theme-primary-light) !important;
    }
}

[data-theme="dark"] .message-table th:first-child {
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
    color: white !important;
    border-left: 4px solid #0d9488;
}

[data-theme="dark"] .message-table td:first-child {
    background: var(--table-first-column-bg, rgba(20, 184, 166, 0.15)) !important;
    color: var(--table-first-column-text, #ffffff) !important;
    border-left: 4px solid var(--table-first-column, #14b8a6);
}

[data-theme="dark"] .message-table td {
    border-bottom: 1px solid var(--table-cell-border, #14b8a6);
    border-right: 1px solid var(--table-cell-border, #14b8a6);
    color: var(--table-body-text, var(--text-primary));
}

/* OLD responsive table code removed - was conflicting with new card transform system */

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-input {
    padding: 12px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-input:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

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

/* Phone number formatting */
.form-input[type="tel"] {
    font-family: 'Courier New', monospace;
}

/* Form validation styles */
.form-input:invalid {
    border-color: #ef4444;
}

.form-input:invalid:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Required field indicator */
.form-group label::after {
    content: '';
}

.form-group:has(input[required]) label::after,
.form-group:has(textarea[required]) label::after,
.form-group:has(select[required]) label::after {
    content: ' *';
    color: #ef4444;
}

/* Mobile responsive form */
@media (max-width: 768px) {
    .contact-modal {
        max-width: 95%;
        margin: 20px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 20px;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 12px;
    }
    
    .modal-btn {
        width: 100%;
    }
}

/* About modal styles removed - feature deprecated */

/* Settings Modal Styles */
.settings-modal {
    max-width: 600px;
    width: 95%;
}

.settings-modal-body {
    padding: 0;
    max-height: 70vh;
    overflow-y: auto;
}

.settings-section {
    padding: 24px;
    border-bottom: 1px solid var(--border-light);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-selection {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.theme-description {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    margin: 0;
    max-width: 400px;
    line-height: 1.5;
}

/* Typography Settings Styles */
.typography-settings {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.typography-setting {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.typography-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.typography-options {
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.typography-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    font-weight: 600;
}

.typography-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.typography-btn.active {
    background: var(--theme-primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.typography-description {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin: 8px 0 0 0;
    max-width: 350px;
    line-height: 1.4;
}

/* Typography Scaling CSS Variables */
:root {
    /* Default typography scale */
    --typo-base-size: 14px;
    --typo-scale: 1;
    --typo-spacing-scale: 1;
}

/* Font Size: Extra Small (10px) */
[data-font-size="xsmall"] {
    --typo-base-size: 10px;
    --typo-scale: 0.714;
}

/* Font Size: Small (12px) */
[data-font-size="small"] {
    --typo-base-size: 12px;
    --typo-scale: 0.857;
}

/* Font Size: Default (14px) */
[data-font-size="default"] {
    --typo-base-size: 14px;
    --typo-scale: 1;
}

/* Font Size: Large (16px) */
[data-font-size="large"] {
    --typo-base-size: 16px;
    --typo-scale: 1.143;
}

/* Font Size: Extra Large (18px) */
[data-font-size="xlarge"] {
    --typo-base-size: 18px;
    --typo-scale: 1.286;
}

/* Density: Compact */
[data-density="compact"] {
    --typo-spacing-scale: 0.75;
}

/* Density: Default */
[data-density="default"] {
    --typo-spacing-scale: 1;
}

/* Density: Relaxed */
[data-density="relaxed"] {
    --typo-spacing-scale: 1.35;
}

/* Apply typography scaling to chat content */
.message-content,
.json-response {
    font-size: var(--typo-base-size, 14px);
}

.message-content h1,
.json-response-title {
    font-size: calc(17px * var(--typo-scale, 1));
}

.message-content h2 {
    font-size: calc(15px * var(--typo-scale, 1));
}

.message-content h3 {
    font-size: calc(14px * var(--typo-scale, 1));
}

.message-content h4 {
    font-size: calc(13px * var(--typo-scale, 1));
}

.message-content p,
.json-paragraph,
.json-text-section {
    line-height: calc(1.65 * var(--typo-spacing-scale, 1));
    margin-bottom: calc(12px * var(--typo-spacing-scale, 1));
}

.message-content li {
    margin-bottom: calc(8px * var(--typo-spacing-scale, 1));
}

.message-table td,
.message-table th {
    padding: calc(10px * var(--typo-spacing-scale, 1)) calc(10px * var(--typo-spacing-scale, 1));
}

/* User Profile Styles */
.user-profile-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.profile-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.profile-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.profile-value {
    font-size: 14px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
}

/* Avatar Settings Styles */
.avatar-selection {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.avatar-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.avatar-preview .message-avatar {
    background: #e5e7eb;
    color: #374151;
}

[data-theme="dark"] .avatar-preview .message-avatar {
    background: #4b5563;
    color: #e5e7eb;
}

.avatar-preview span {
    font-size: 12px;
    color: var(--text-muted);
}

.avatar-options {
    display: flex;
    gap: 20px;
}

.avatar-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar-option input[type="radio"] {
    margin: 0;
}

.avatar-option label {
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

.avatar-config {
    width: 100%;
    max-width: 300px;
}

.icon-selector,
.initials-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.icon-selector label,
.initials-input label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.user-avatar-initials {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.user-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.setting-label {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.setting-label i {
    color: var(--text-light);
    width: 16px;
    text-align: center;
}

.setting-label span {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.setting-control {
    display: flex;
    align-items: center;
}

/* Theme Toggle Styles */
.theme-toggle {
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.theme-toggle input[type="radio"] {
    display: none;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
}

.theme-option:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.theme-toggle input[type="radio"]:checked + .theme-option {
    background: var(--theme-primary);
    color: white;
}

.theme-option i {
    font-size: 14px;
}

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-medium);
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--theme-primary);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Mobile responsive for settings modal */
@media (max-width: 768px) {
    .settings-modal {
        width: 95vw;
        margin: 20px;
    }
    
    .settings-modal-body {
        max-height: 60vh;  /* Reduced from 70vh for mobile viewport fit */
    }
    
    .settings-section {
        padding: 16px;
    }
    
    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .setting-control {
        width: 100%;
        justify-content: flex-end;
    }
    
    .theme-toggle {
        width: 100%;
        justify-content: center;
    }
}

/* Admin Interface Styles */
.admin-section {
    border-top: 2px solid var(--theme-primary);
    background: var(--bg-secondary);
}

.admin-login {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 8px;
}

.admin-tab {
    flex: 1;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.admin-tab.active {
    background: var(--theme-primary);
    color: white;
}

.admin-tab:hover:not(.active) {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.admin-content {
    min-height: 300px;
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

.admin-tab-content h5 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

/* Visitor Tabs (inside Manage Visitors admin tab) */
.visitor-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-light);
}

.visitor-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.visitor-tab.active {
    color: var(--theme-primary);
    border-bottom-color: var(--theme-primary);
    font-weight: 600;
}

.visitor-tab:hover:not(.active) {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.visitor-tab-content {
    display: none;
}

.visitor-tab-content.active {
    display: block;
}

/* Edit Visitor Modal (nested inside admin modal) */
#editVisitorModal {
    z-index: 15000 !important;  /* Above admin modal (10000) */
}

#editVisitorModal .modal-content {
    max-width: 900px;
    max-height: 80vh;  /* Slightly shorter to fit better */
    overflow-y: auto;
}

/* Field Management Modal (above Edit Visitor Modal) */
#fieldManagementModal {
    z-index: 16000 !important;  /* Above Edit Visitor Modal (15000) */
}

/* Field Management Modal (above Edit Visitor Modal) */
#fieldManagementModal {
    z-index: 16000 !important;  /* Above Edit Visitor Modal (15000) */
}

/* Field Builder Modal (above Field Management Modal) */
#fieldBuilderModal {
    z-index: 18000 !important;  /* Above Field Management Modal (16000) - highest in stack */
}

#apiKeyGenerateModal,
#apiKeyDetailsModal,
#apiKeyRotateModal,
#apiKeyRevokeModal {
    z-index: 18000 !important;  /* Same as Field Builder - highest in modal stack */
}

/* Generic Modal System (v1.1 Modal Manager) */
#genericConfirmModal,
#genericAlertModal,
#genericSuccessModal,
#genericErrorModal,
#twoStepConfirmStep1,
#twoStepConfirmStep2 {
    z-index: 19000 !important;  /* Above all other modals */
}

/* Modal Theme Classes */
.modal-theme-danger {
    --modal-accent: #ef4444;
    --modal-bg-gradient: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
}

.modal-theme-warning {
    --modal-accent: #f59e0b;
    --modal-bg-gradient: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
}

.modal-theme-success {
    --modal-accent: #10b981;
    --modal-bg-gradient: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
}

.modal-theme-info {
    --modal-accent: var(--theme-primary);
    --modal-bg-gradient: linear-gradient(135deg, rgba(17, 163, 240, 0.1) 0%, rgba(17, 163, 240, 0.05) 100%);
}

/* Modal Button Variants */
.modal-btn.danger {
    background: #ef4444;
    color: white;
    border: none;
}

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

.modal-btn.warning {
    background: #f59e0b;
    color: white;
    border: none;
}

.modal-btn.warning:hover {
    background: #d97706;
}

.modal-btn.success {
    background: #10b981;
    color: white;
    border: none;
}

.modal-btn.success:hover {
    background: #059669;
}

/* Two-step confirmation input styling */
#twoStepConfirmInput {
    width: 100%;
    padding: 12px;
    border: 2px solid #ef4444;
    border-radius: 6px;
    font-size: 14px;
    font-family: monospace;
    text-transform: uppercase;
    background: var(--bg-primary);
    color: var(--text-primary);
}

#twoStepConfirmInput:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Field category sections */
.field-category-section {
    margin-bottom: 24px;
}

.fields-grid {
    display: grid;
    gap: 12px;
}

.rag-upload {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 2px dashed var(--border-medium);
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.upload-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.rag-upload input[type="file"] {
    width: 100%;
}

.rag-documents,
.memory-sessions {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 12px;
    background: var(--bg-primary);
}

.document-item,
.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

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

.document-item:last-child,
.session-item:last-child {
    border-bottom: none;
}

.document-title,
.session-title {
    font-weight: 500;
    color: var(--text-primary);
}

.document-meta,
.session-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.delete-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

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

/* Dark theme admin styles */
[data-theme="dark"] .admin-section {
    background: var(--bg-tertiary);
    border-top-color: var(--editor-primary);
}

[data-theme="dark"] .admin-tabs {
    background: var(--bg-primary);
}

[data-theme="dark"] .admin-tab.active {
    background: var(--editor-primary);
    color: var(--bg-primary);
}

[data-theme="dark"] .rag-upload {
    background: var(--bg-primary);
    border-color: var(--border-medium);
}

/* Admin Interface Improvements */
.admin-tab-content h5 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.admin-tab-content textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    margin-bottom: 16px;
}

.admin-tab-content .modal-btn {
    margin-top: 0;
}

/* Collections Interface Styles */
.collections-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.collection-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s ease;
}

.collection-card:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-sm);
}

.collection-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.collection-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.collection-info h6 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.collection-description {
    font-size: 13px;
    color: var(--text-muted);
    margin: 4px 0 12px 0;
    line-height: 1.4;
}

.collection-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.collection-count {
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.collection-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.collection-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.collection-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

/* Upload Type Tabs Styles - Matching Branding Tab Pattern */
.upload-type-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-light);
}

.upload-type-tab {
    padding: 12px 24px;
    background: #f5f5f5;
    border: none;
    border-left: 3px solid transparent;
    border-bottom: 3px solid transparent;
    color: #666;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-type-tab:hover {
    background: rgba(74, 144, 226, 0.08);
    color: #4A90E2;
}

.upload-type-tab.active {
    background: rgba(74, 144, 226, 0.12);
    color: #4A90E2;
    border-left: 3px solid #4A90E2;
    border-bottom: 3px solid #4A90E2;
    font-weight: 600;
}

/* Image Grid Styles */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.image-card {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary);
    transition: all 0.2s ease;
}

.image-card:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-md);
}

.image-card-preview {
    position: relative;
    height: 200px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
}

.image-card-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Image Hover Overlay */
.image-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 15px;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
}

.image-card-preview:hover .image-hover-overlay {
    display: flex;
}

.image-hover-overlay h6 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: white;
}

.image-hover-overlay p {
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.9);
}

.image-hover-overlay .keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.image-hover-overlay .keyword-tag {
    background: rgba(74, 144, 226, 0.3);
    border: 1px solid rgba(74, 144, 226, 0.6);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
}

/* Image Card Info */
.image-card-info {
    padding: 15px;
}

.image-card-info .image-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-card-info .image-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.image-card-info .image-keywords {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.image-card-actions button {
    flex: 1;
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid var(--border-light);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.image-card-actions button:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.image-card-actions button.delete:hover {
    background: #fee;
    color: #ef4444;
    border-color: #ef4444;
}

/* Images Empty State */
.images-empty-state {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

.images-empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--theme-primary);
    opacity: 0.5;
}

.images-empty-state p {
    font-size: 14px;
    margin-bottom: 8px;
}

.images-empty-state p:last-child {
    font-size: 13px;
    color: var(--text-muted);
}

/* Responsive: Mobile */
@media (max-width: 768px) {
    .images-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .upload-type-tabs {
        gap: 5px;
    }
    
    .upload-type-tab {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .image-card-preview {
        height: 150px;
    }
}

/* Activity Reports Styles */
.reports-filters {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.filter-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.reports-dashboard {
    min-height: 400px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 20px;
}

.reports-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
}

.reports-loading i {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--theme-primary);
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.report-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.report-card h6 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.report-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--theme-primary);
    margin: 0 0 4px 0;
}

.report-label {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.activity-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-light);
}

.activity-table th,
.activity-table td {
    padding: 12px;
    text-align: left;
}

/* Toaster notifications */
@keyframes toastSlideDown {
    from { transform: translateY(-100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.toast {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Hover effects - preserve position transform */
.toast[data-position="upper-left"]:hover,
.toast[data-position="upper-right"]:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2) !important;
}

.toast[data-position="upper-middle"]:hover {
    transform: translateX(-50%) translateY(-2px) !important;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2) !important;
}

/* Sortable table headers */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 24px;
    transition: background-color 0.2s ease;
}

/* NO HOVER EFFECTS AT ALL */
.sortable:hover {
    filter: none !important;
    transform: none !important;
}

.sortable .sort-icon,
.sortable i {
    color: white;
    opacity: 0.7;
}

/* Sorted columns - YELLOW TEXT (light) or BLACK TEXT (dark) - ALL TABLES */
[data-theme="light"] .sortable.active,
[data-theme="light"] .sortable.asc,
[data-theme="light"] .sortable.desc {
    background: var(--theme-primary) !important;  /* Same teal background */
    color: #fbbf24 !important;  /* YELLOW TEXT for light theme */
    font-weight: 800;
}

[data-theme="dark"] .sortable.active,
[data-theme="dark"] .sortable.asc,
[data-theme="dark"] .sortable.desc {
    background: var(--theme-primary) !important;  /* Same teal background */
    color: #000000 !important;  /* BLACK TEXT for dark theme */
    font-weight: 800;
}

/* Sort icons match text color */
[data-theme="light"] .sortable.active .sort-icon,
[data-theme="light"] .sortable.active i,
[data-theme="light"] .sortable.asc .sort-icon,
[data-theme="light"] .sortable.asc i,
[data-theme="light"] .sortable.desc .sort-icon,
[data-theme="light"] .sortable.desc i {
    color: #fbbf24 !important;  /* Yellow icon to match text */
    opacity: 1;
}

[data-theme="dark"] .sortable.active .sort-icon,
[data-theme="dark"] .sortable.active i,
[data-theme="dark"] .sortable.asc .sort-icon,
[data-theme="dark"] .sortable.asc i,
[data-theme="dark"] .sortable.desc .sort-icon,
[data-theme="dark"] .sortable.desc i {
    color: #000000 !important;  /* Black icon to match text */
    opacity: 1;
}

.sort-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-muted);
    transition: color 0.2s ease;
    pointer-events: none;
}

.activity-table th,
.activity-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

.activity-table th {
    background: var(--theme-primary) !important;  /* Solid, no gradients */
    font-weight: 700;
    color: white !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 12px;
    position: relative;
}

/* Sortable column states for activity tables */
.activity-table th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 30px;  /* Room for sort icon */
}

/* NO HOVER EFFECTS AT ALL */
.activity-table th.sortable:hover {
    background: var(--theme-primary) !important;  /* No change on hover */
    filter: none;
    transform: none;
}

/* Sorted column styling inherits from .sortable rules above - no need to duplicate */

.activity-table td {
    color: var(--text-secondary);
}

.activity-table tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

.activity-table tr:hover {
    background: rgba(20, 184, 166, 0.1);
    transform: translateY(-1px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-id {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
}

.activity-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.activity-type.chat_message {
    background: var(--theme-primary);
    color: white;
}

.activity-type.anonymous,
.activity-type.user-type-anonymous {
    background: var(--text-muted);
    color: white;
}

.activity-type.known,
.activity-type.user-type-known {
    background: #10b981;
    color: white;
}

.response-time {
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

/* Dark theme admin styles */
[data-theme="dark"] .collection-card {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
}

[data-theme="dark"] .reports-filters {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
}

[data-theme="dark"] .reports-dashboard {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
}

[data-theme="dark"] .report-card {
    background: var(--bg-primary);
    border-color: var(--border-medium);
}

[data-theme="dark"] .report-value {
    color: var(--editor-primary);
}

/* Admin table styles - high specificity to prevent conflicts */
.admin-panel .admin-table-container,
#adminPanel .admin-table-container {
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.admin-panel .admin-table,
#adminPanel .admin-table,
.admin-table-container .admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary);
    table-layout: fixed !important;
}

.admin-table thead {
    background: var(--theme-primary) !important;  /* Solid, no gradient */
    border-bottom: 2px solid var(--border-light);
}

.admin-table th {
    padding: 16px 12px;
    text-align: left;
    background: var(--theme-primary) !important;  /* Solid, no gradient */
    color: white !important;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

/* Light theme - dark text on light gradient */
[data-theme="light"] .admin-table th {
    color: #1e293b;  /* Dark slate text */
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

/* Sortable hover - theme-aware */
.admin-table th.sortable:hover {
    background: rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .admin-table th.sortable:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Sortable active columns - theme-aware */
.admin-table th.sortable.active {
    background: rgba(251, 191, 36, 0.25) !important;
    font-weight: 800;
}

/* Dark theme sorted - bright yellow */
/* Sorted column colors handled by universal .sortable rules - no admin-table specific overrides needed */

.admin-table th:last-child {
    border-right: none;
}

.admin-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s ease;
}

.admin-table tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

.admin-table tbody tr:hover {
    background: rgba(20, 184, 166, 0.1);
    transform: translateY(-1px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.admin-table tbody tr.dragging {
    opacity: 0.5;
    background: var(--editor-primary-light);
}

/* Segments table column sizing for better description readability */
.admin-table th.icon-column,
.admin-table td.icon-column {
    width: 35px;
    text-align: center;
}

.admin-table th.name-column,
.admin-table td.name-column {
    width: 180px;
}

.admin-table th.type-column,
.admin-table td.type-column {
    width: 80px;
    text-align: center;
}

.admin-table th.members-column,
.admin-table td.members-column {
    width: 70px;
    text-align: center;
}

/* Campaigns table specific styles - increased specificity */
.admin-panel .campaigns-table th,
.admin-panel .campaigns-table td,
#adminPanel .campaigns-table th,
#adminPanel .campaigns-table td {
    padding: 8px 6px !important;
    font-size: 11px;
}

.admin-panel .campaigns-table,
#adminPanel .campaigns-table {
    table-layout: fixed !important;
    width: 100%;
}

.admin-panel .campaigns-table td:last-child,
#adminPanel .campaigns-table td:last-child {
    white-space: nowrap;
    min-width: 160px;
}

.admin-panel .admin-table-container,
#adminPanel .admin-table-container {
    overflow-x: auto;
}

.admin-panel .campaigns-table th,
#adminPanel .campaigns-table th {
    font-size: 10px;
    padding: 12px 6px !important;
}

.campaigns-table .text-center {
    text-align: center;
}

.campaigns-table tbody td {
    vertical-align: middle;
}

/* Campaign table column widths (9 columns total)
   Name = 2 units, others = 1 unit each, Actions = fixed
   Total: 2 + 7 = 9 units for flexible columns
   Name gets ~22%, others get ~11% each */
.campaigns-table th:nth-child(1),
.campaigns-table td:nth-child(1) {
    width: 22%;  /* Name - 2x wider */
}

.campaigns-table th:nth-child(2),
.campaigns-table td:nth-child(2),
.campaigns-table th:nth-child(3),
.campaigns-table td:nth-child(3),
.campaigns-table th:nth-child(4),
.campaigns-table td:nth-child(4),
.campaigns-table th:nth-child(5),
.campaigns-table td:nth-child(5),
.campaigns-table th:nth-child(6),
.campaigns-table td:nth-child(6),
.campaigns-table th:nth-child(7),
.campaigns-table td:nth-child(7),
.campaigns-table th:nth-child(8),
.campaigns-table td:nth-child(8) {
    width: 10%;  /* Equal width for Type, Status, Priority, Delivered, Form%, Max, Cool */
}

.campaigns-table th:nth-child(9),
.campaigns-table td:nth-child(9) {
    width: 8%;  /* Actions - slightly narrower */
    min-width: 100px;
}

.admin-table th.description-column,
.admin-table td.description-column {
    min-width: 300px;
    max-width: 400px;
    white-space: normal;
    line-height: 1.4;
}

.admin-table th.created-column,
.admin-table td.created-column,
.admin-table th.updated-column,
.admin-table td.updated-column {
    width: 160px;
    white-space: nowrap;
    font-size: 13px;
}

.admin-table th.actions-column,
.admin-table td.actions-column {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    text-align: center !important;
}

.admin-table td {
    padding: 16px 12px;
    vertical-align: middle;
    border-right: 1px solid var(--border-light);
}

.admin-table td:last-child {
    border-right: none;
}

/* Table column widths */
.drag-column {
    width: 30px;
    text-align: center;
    cursor: grab;
    color: var(--text-tertiary);
}

.drag-column:active {
    cursor: grabbing;
}

.icon-column {
    width: 50px;
    text-align: center;
}

.name-column {
    width: 200px;
    font-weight: 500;
}

.type-column {
    width: 100px;
}

.category-column {
    width: 120px;
}

.url-column {
    width: 250px;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prompt-column {
    width: 300px;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.description-column {
    width: 200px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.usage-column {
    width: 80px;
    text-align: center;
}

.actions-column {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    text-align: center !important;
}

.table-actions {
    display: flex;
    justify-content: center;  /* Center action buttons */
    align-items: center;
    gap: 8px;
}

/* Table cell content styles */
.table-icon {
    font-size: 16px;
    color: var(--editor-primary);
}

.table-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* Consistent table cell styling for Manage Users & Manage Visitors */
.table-cell {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 400;
}

.table-cell-code {
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: help;
    max-width: none;
    white-space: nowrap;
}

.default-badge {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-left: 6px;
    font-weight: 400;
}

.table-type {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.table-type.link {
    background: var(--cursor-blue-light);
    color: var(--cursor-blue);
}

.table-type.contact_modal {
    background: var(--editor-success-light);
    color: var(--editor-success);
}

.table-type.video_gallery {
    background: var(--editor-special-light);
    color: var(--editor-special);
}

.table-type.custom {
    background: var(--editor-special-light);
    color: var(--editor-special);
}

.table-url {
    color: var(--text-secondary);
    font-size: 12px;
}

.table-prompt {
    color: var(--text-secondary);
    font-size: 12px;
    font-style: italic;
}

.table-description {
    color: var(--text-tertiary);
    font-size: 12px;
}

.table-category {
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.table-usage {
    font-weight: 600;
    color: var(--editor-primary);
}

.table-actions {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.table-action-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.table-action-btn.edit {
    background: var(--cursor-blue-light);
    color: var(--cursor-blue);
}

.table-action-btn.edit:hover {
    background: var(--cursor-blue);
    color: white;
}

.table-action-btn.delete {
    background: var(--cursor-red-light);
    color: var(--cursor-red);
}

.table-action-btn.delete:hover {
    background: var(--cursor-red);
    color: white;
}

.table-action-btn.test {
    background: var(--editor-success-light);
    color: var(--editor-success);
}

.table-action-btn.test:hover {
    background: var(--editor-success);
    color: white;
}

/* Drag handle styling */
.drag-handle {
    cursor: grab;
    color: var(--text-tertiary);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.drag-handle:hover {
    color: var(--editor-primary);
    background: var(--editor-primary-light);
}

.drag-handle:active {
    cursor: grabbing;
}

/* Responsive table */
@media (max-width: 1200px) {
    .url-column,
    .prompt-column,
    .description-column {
        max-width: 150px;
    }
}

@media (max-width: 900px) {
    .admin-table-container {
        overflow-x: auto;
    }
    
    .admin-table {
        min-width: 800px;
    }
}

/* Admin Modal Styles */
.admin-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 10000;  /* Base z-index for admin panel */
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.admin-modal {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 95vw;
    max-width: 1400px; /* Increased from 1200px to accommodate more tabs */
    height: 85vh;
    max-height: 900px; /* Increased height for better usability */
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-medium);
    animation: slideUp 0.3s ease;
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
    border-radius: 12px 12px 0 0;
}

.admin-modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
}

.admin-modal-header h2 i {
    color: var(--theme-primary);
    margin-right: 8px;
}

.admin-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.admin-modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

/* Admin Authentication */
.admin-auth {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.admin-auth-content {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.admin-auth-icon {
    font-size: 48px;
    color: var(--theme-primary);
    margin-bottom: 20px;
}

.admin-auth-content h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.admin-auth-content p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 16px;
}

.admin-login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.admin-login-form .form-group {
    text-align: left;
}

.admin-login-form .modal-btn {
    margin-top: 8px;
    padding: 12px 24px;
    font-size: 16px;
}

/* Admin Panel in Modal */
.admin-modal .admin-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-modal .admin-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    padding: 0 24px;
    gap: 4px;
    overflow-x: auto; /* Allow horizontal scrolling if needed */
    flex-wrap: nowrap; /* Keep tabs on one line */
    scrollbar-width: thin; /* Thin scrollbar for Firefox */
}

.admin-modal .admin-tab {
    background: none;
    border: none;
    padding: 16px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-modal .admin-tab:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.admin-modal .admin-tab.active {
    background: var(--bg-primary);
    color: var(--theme-primary);
    border-bottom: 2px solid var(--theme-primary);
}

.admin-modal .admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.admin-modal .admin-tab-content {
    display: none;
}

.admin-modal .admin-tab-content.active {
    display: block;
}

.admin-modal .admin-tab-content h5 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.admin-modal .tab-description {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.5;
}

.admin-modal .admin-tab-content textarea {
    width: 100%;
    min-height: 200px;
    resize: vertical;
    margin-bottom: 16px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.admin-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
    border-radius: 0 0 12px 12px;
}

/* Dark theme admin modal */
[data-theme="dark"] .admin-modal {
    background: var(--bg-tertiary);
    border-color: var(--border-dark);
}

[data-theme="dark"] .admin-modal-header {
    background: var(--bg-primary);
}

[data-theme="dark"] .admin-modal .admin-tabs {
    background: var(--bg-primary);
}

[data-theme="dark"] .admin-modal .admin-tab.active {
    background: var(--bg-tertiary);
    color: var(--editor-primary);
    border-bottom-color: var(--editor-primary);
}

[data-theme="dark"] .admin-modal-footer {
    background: var(--bg-primary);
}

/* Dark theme admin table headers - keep teal for dark theme */
/* Light theme - solid blue headers */
[data-theme="light"] .admin-table thead,
[data-theme="light"] .admin-table th,
[data-theme="light"] .activity-table th {
    background: #4A90E2 !important;  /* Blue for light theme */
}

/* Dark theme - solid teal headers */
[data-theme="dark"] .admin-table thead,
[data-theme="dark"] .admin-table th,
[data-theme="dark"] .activity-table th {
    background: #14b8a6 !important;  /* Teal for dark theme */
}

/* Video Modal Styles */
.video-modal {
    width: 95%;
    max-width: 1360px; /* Reduced by 15% from 1600px */
    max-height: 90vh;
}

.video-modal-body {
    padding: 0;
}

.video-player {
    width: 100%;
    height: 765px; /* Reduced by 15% from 900px */
    background: #000;
    position: relative;
}

.video-player iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Responsive video modal */
@media (max-width: 1400px) {
    .video-modal {
        max-width: 1020px; /* Reduced by 15% from 1200px */
    }
    
    .video-player {
        height: 574px; /* Reduced by 15% from 675px */
    }
}

@media (max-width: 1024px) {
    .video-modal {
        width: 90%;
        max-width: 765px; /* Reduced by 15% from 900px */
    }
    
    .video-player {
        height: 425px; /* Reduced by 15% from 500px */
    }
}

@media (max-width: 768px) {
    .video-modal {
        width: 95%;
        max-width: none;
    }
    
    .video-player {
        height: 255px; /* Reduced by 15% from 300px */
    }
}

@media (max-width: 480px) {
    .video-modal {
        width: 98%;
        margin: 10px;
    }
    
    .video-player {
        height: 187px; /* Reduced by 15% from 220px */
    }
}

/* React Report Modal Styles */
.react-report-modal {
    width: 95%;
    max-width: 1400px;
    max-height: 90vh;
}

.react-report-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 70vh;
    min-height: 500px;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header-actions .print-btn {
    background: linear-gradient(135deg, var(--theme-primary-light), var(--theme-primary-dark));
    color: white;
    border: 2px solid var(--theme-primary-dark);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(91, 167, 247, 0.3);
}

.modal-header-actions .print-btn:hover {
    background: linear-gradient(135deg, var(--theme-primary-dark), var(--theme-primary));
    border-color: var(--theme-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.react-report-description {
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.react-report-container {
    flex: 1;
    padding: 0;
    padding-bottom: 24px;
    overflow: auto;
    background: var(--bg-primary);
    border-radius: 8px;
    margin: 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* List styles for React report modal - fixes bullet indentation */
.react-report-container ul,
#reactReportContainer ul {
    padding-left: 20px;
    margin: 12px 0;
    list-style-type: disc;
}

#reactReportContainer li {
    margin-bottom: 8px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Ensure tables in React report modal use correct colors */
.react-report-container .message-table thead {
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
    color: white !important;
}

.react-report-container .message-table th {
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
    color: white !important;
    border-bottom: 3px solid rgb(45, 100, 180) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.react-report-container .message-table th:first-child {
    border-left: 4px solid var(--theme-primary-dark);
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
}

.react-report-container .message-table td {
    border-bottom: 1px solid var(--theme-primary-light);
    border-right: 1px solid var(--theme-primary-light);
}

.react-report-container .message-table td:first-child {
    border-left: 4px solid var(--theme-primary-light);
    background: rgba(91, 167, 247, 0.1) !important; /* Light blue with alpha */
    font-weight: 600;
}

.react-report-container .message-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.03);  /* Subtle neutral gray */
    /* No shadow or transform - keeps borders visible */
}

.react-report-error {
    padding: 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin: 20px;
    color: #dc2626;
}

.react-report-error h4 {
    margin: 0 0 10px 0;
    color: #dc2626;
}

.react-report-error pre {
    background: #f9fafb;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
    margin: 10px 0;
}

/* Dark theme React report modal */
[data-theme="dark"] .react-report-description {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

[data-theme="dark"] .react-report-container {
    background: var(--bg-secondary);
}

[data-theme="dark"] .react-report-error {
    background: #2d1b1b;
    border-color: #5b2c2c;
    color: #f87171;
}

[data-theme="dark"] .react-report-error pre {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Dark theme tables in React report modal */
[data-theme="dark"] .react-report-container .message-table thead {
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
    color: white !important;
}

[data-theme="dark"] .react-report-container .message-table th {
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
    color: white !important;
    border-bottom: 3px solid #0d9488 !important;
}

[data-theme="dark"] .react-report-container .message-table th:first-child {
    border-left: 4px solid #0d9488;
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
}

[data-theme="dark"] .react-report-container .message-table td {
    border-bottom: 1px solid #14b8a6;
    border-right: 1px solid #14b8a6;
}

[data-theme="dark"] .react-report-container .message-table td:first-child {
    border-left: 4px solid #14b8a6;
    background: rgba(20, 184, 166, 0.15) !important;
}

[data-theme="dark"] .react-report-container .message-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);  /* Subtle white tint for dark theme */
}

/* Dark theme: Subtle table hover for all tables */
[data-theme="dark"] .message-table tbody tr:hover,
[data-theme="dark"] .json-table tbody tr:hover {
    background: var(--table-row-hover, rgba(255, 255, 255, 0.05)) !important;
    /* No transform, shadow, or border changes */
}

[data-theme="dark"] .message-table tbody tr:nth-child(even) {
    background: var(--table-row-even-bg, #2d2d30);
}

/* React Fallback Styles */
.react-fallback-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

.react-fallback-notice {
    background: var(--accent-light);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.react-fallback-notice i {
    color: var(--accent-color);
    margin-top: 2px;
    font-size: 18px;
}

.react-fallback-notice strong {
    display: block;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.react-fallback-notice p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.4;
}

.react-code-display {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 15px;
    overflow: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.react-fallback-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.react-fallback-actions .modal-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.react-fallback-actions .modal-btn:hover {
    background: var(--accent-hover);
}

/* Dark theme fallback styles */
[data-theme="dark"] .react-fallback-notice {
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
}

[data-theme="dark"] .react-code-display {
    background: var(--bg-tertiary);
    border-color: var(--border-dark);
    color: var(--text-muted);
}

[data-theme="dark"] .react-fallback-actions {
    border-color: var(--border-dark);
}

/* Responsive React report modal */
@media (max-width: 768px) {
    .react-report-modal {
        width: 98%;
        max-width: none;
    }
    
    .react-report-body {
        height: 60vh;
    }
    
    .react-fallback-actions {
        flex-direction: column;
    }
    
    .react-fallback-actions .modal-btn {
        width: 100%;
        justify-content: center;
    }
    
    .modal-header-actions .print-btn {
        padding: 8px 14px;
        font-size: 12px;
    }
}

/* Dark theme print button */
[data-theme="dark"] .modal-header-actions .print-btn {
    background: linear-gradient(135deg, var(--theme-primary-light), var(--theme-primary-dark));
    border-color: var(--theme-primary-dark);
    box-shadow: 0 3px 10px rgba(77, 208, 225, 0.3);
}

[data-theme="dark"] .modal-header-actions .print-btn:hover {
    background: linear-gradient(135deg, var(--theme-primary-dark), #0f766e);
    border-color: #0f766e;
    box-shadow: 0 6px 20px rgba(0, 172, 193, 0.4);
}

/* Data Sheet Styles */
.data-sheet {
    padding: 20px;
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.data-sheet-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--accent-color);
}

.data-sheet-header h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-color);
}

.data-sheet-header p {
    margin: 0;
    font-size: 16px;
    color: var(--text-muted);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 8px;
}

.metric-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stat Card Styles (for segment/activity analytics) */
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-card i {
    font-size: 24px;
    color: var(--theme-primary);
    margin-bottom: 12px;
    display: block;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--theme-primary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Dark theme stat cards */
[data-theme="dark"] .stat-card {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
}

[data-theme="dark"] .stat-card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .stat-card i,
[data-theme="dark"] .stat-value {
    color: var(--editor-primary);
}

.metric-trend {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 14px;
}

.metric-trend.up {
    color: #10b981;
}

.metric-trend.down {
    color: #ef4444;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.chart-wrapper {
    background: var(--chart-canvas-bg, #ffffff);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 20px;
}

.chart-wrapper h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
    max-height: 250px;
    overflow: hidden;
    background: var(--chart-canvas-bg, #ffffff);
}

.chart-wrapper canvas {
    max-width: 100% !important;
    max-height: 250px !important;
    height: 250px !important;
    width: 100% !important;
}

.features-grid {
    margin-top: 40px;
}

.features-grid h3 {
    margin: 0 0 30px 0;
    font-size: 24px;
    font-weight: 700;
    color: #3b82f6;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 3px solid #3b82f6;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.feature-card {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-left: 5px solid #3b82f6;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
    border-left-color: #1d4ed8;
}

.feature-icon {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    font-size: 18px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    flex-shrink: 0;
}

.feature-content h4 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
    color: #3b82f6;
    line-height: 1.3;
}

.feature-content p {
    margin: 0;
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Dark theme styles */
[data-theme="dark"] .metric-card,
[data-theme="dark"] .feature-card {
    background: var(--bg-tertiary);
    border-color: var(--border-dark);
}

/* Chart wrapper uses --chart-canvas-bg in both themes */
[data-theme="dark"] .chart-wrapper {
    border-color: var(--border-dark);
}

[data-theme="dark"] .metric-card:hover,
[data-theme="dark"] .chart-wrapper:hover,
[data-theme="dark"] .feature-card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

/* Responsive design */
@media (max-width: 768px) {
    .data-sheet {
        padding: 15px;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .metric-card {
        padding: 15px;
    }
    
    .metric-value {
        font-size: 24px;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .chart-wrapper {
        padding: 15px;
    }
    
    .feature-card {
        padding: 15px;
    }
}

/* Data Sheet Modal Styles */
.datasheet-modal-content {
    padding: 30px;
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    overflow-y: auto;
    line-height: 1.6;
}

.datasheet-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 25px 25px 25px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border-radius: 12px;
    margin: -10px -10px 40px -10px;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.report-logo-container {
    margin-bottom: 20px;
}

.report-logo {
    height: 60px;
    max-width: 200px;
    object-fit: contain;
}

/* Print-specific logo sizing - 75% reduction (25% of original) */
@media print {
    .report-logo {
        height: 15px !important;        /* 25% of original 60px */
        max-width: 50px !important;     /* 25% of original 200px */
    }
    
    /* Also reduce mobile logo size for print */
    .datasheet-header .report-logo {
        height: 11.25px !important;     /* 25% of mobile 45px */
    }
}

.datasheet-header h2 {
    margin: 0 0 15px 0;
    font-size: 32px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.datasheet-header p {
    margin: 0;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.datasheet-content {
    max-width: 100%;
    overflow-x: auto;
}

.datasheet-content h1,
.datasheet-content h2,
.datasheet-content h3,
.datasheet-content h4 {
    margin-top: 35px;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 8px;
}

.datasheet-content h1 {
    font-size: 28px;
    color: #3b82f6;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.datasheet-content h2 {
    font-size: 24px;
    color: #3b82f6;
}

.datasheet-content h3 {
    font-size: 20px;
    color: #3b82f6;
}

.datasheet-content h4 {
    font-size: 18px;
    color: #2563eb;
}

.datasheet-content p {
    margin: 15px 0;
    line-height: 1.7;
}

.datasheet-content ul,
.datasheet-content ol {
    margin: 15px 0;
    padding-left: 25px;
}

.datasheet-content li {
    margin: 8px 0;
    line-height: 1.6;
}

.datasheet-content .table-wrapper {
    margin: 25px 0;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
    /* Ensure proper containment */
    contain: layout;
}

.datasheet-content .message-table {
    font-size: 15px;
    min-width: 400px;
    max-width: 100%;
    table-layout: fixed;
    width: 100%;
    box-sizing: border-box;
}

.datasheet-content .message-table th {
    background: linear-gradient(135deg, rgb(62, 128, 216), rgb(45, 100, 180));
    color: white;
    font-size: 14px;
    padding: 14px 12px;
    max-width: 150px;
    word-wrap: break-word;
}

.datasheet-content .message-table td {
    padding: 14px 12px;
    max-width: 150px;
    word-wrap: break-word;
    font-size: 14px;
    border-bottom: 1px solid var(--theme-primary-light);
    border-right: 1px solid var(--theme-primary-light);
}

[data-theme="dark"] .datasheet-content .message-table td {
    border-bottom: 1px solid #14b8a6;
    border-right: 1px solid #14b8a6;
}

.datasheet-content .message-table th {
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
    color: white !important;
    border-bottom: 3px solid rgb(45, 100, 180) !important;
}

.datasheet-content .message-table th:first-child {
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
    color: white !important;
    font-weight: 700;
    border-left: none;
}

.datasheet-content .message-table td:first-child {
    background: rgba(91, 167, 247, 0.1) !important; /* Light blue with alpha */
    color: var(--text-primary) !important;
    font-weight: 600;
    border-left: 4px solid var(--theme-primary-light);
}

.datasheet-content strong {
    color: var(--accent-color);
    font-weight: 600;
}

.datasheet-content .section-header {
    background: var(--accent-light);
    padding: 12px 20px;
    margin: 25px -15px 15px -15px;
    border-left: 5px solid var(--accent-color);
    border-radius: 0 8px 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-color);
}

/* Better emoji and icon spacing in datasheet */
.datasheet-content h1:before,
.datasheet-content h2:before,
.datasheet-content h3:before,
.datasheet-content h4:before {
    margin-right: 10px;
}

/* Clean up checklist items */
.datasheet-content li {
    position: relative;
}

.datasheet-content li:has(.fa-check),
.datasheet-content li:has(.fa-check-circle) {
    list-style: none;
    padding-left: 0;
}

.datasheet-content li .fa-check,
.datasheet-content li .fa-check-circle {
    color: #10b981;
    margin-right: 8px;
    font-size: 16px;
}

/* Quote styling */
.datasheet-content blockquote,
.datasheet-content p:has(em:only-child) {
    border-left: 4px solid var(--accent-color);
    padding: 15px 20px;
    margin: 20px 0;
    background: var(--accent-light);
    font-style: italic;
    border-radius: 0 8px 8px 0;
}

/* Link styling in datasheet */
.datasheet-content a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: border-bottom 0.2s ease;
}

.datasheet-content a:hover {
    border-bottom: 1px solid var(--accent-color);
}

/* Dark theme datasheet styles */
[data-theme="dark"] .datasheet-modal-content {
    background: var(--bg-secondary);
}

/* Responsive datasheet */
@media (max-width: 768px) {
    .datasheet-modal-content {
        padding: 20px 15px;
    }
    
    .datasheet-header {
        padding: 20px 15px;
        margin: -10px -5px 30px -5px;
    }
    
    .report-logo {
        height: 45px;
    }
    
    .datasheet-header h2 {
        font-size: 24px;
    }
    
    .datasheet-header p {
        font-size: 16px;
    }
    
    .datasheet-content h1 {
        font-size: 22px;
    }
    
    .datasheet-content h2 {
        font-size: 20px;
    }
    
    .datasheet-content h3 {
        font-size: 18px;
    }
    
    .datasheet-content .message-table {
        font-size: 12px;
        min-width: 350px;
    }
    
    .datasheet-content .message-table th,
    .datasheet-content .message-table td {
        padding: 10px 8px;
        max-width: 120px;
        font-size: 12px;
    }
}

/* ============================================================================
   JSON RESPONSE STYLING - Consistent spacing system
   ============================================================================
   
   SPACING SCALE (CSS Variables for consistency):
   --json-spacing-xs: 4px   - Minimal gaps (inside elements)
   --json-spacing-sm: 8px   - Small gaps (list items, inline)
   --json-spacing-md: 12px  - Medium gaps (paragraphs, sections)
   --json-spacing-lg: 20px  - Large gaps (major sections)
   --json-spacing-xl: 28px  - Extra large (page sections)
   
   SCOPING: All rules prefixed with .json-response or .message-content
   to avoid affecting campaigns, modals, toasters, etc.
   ============================================================================ */

/* Spacing variables */
:root {
    --json-spacing-xs: 4px;
    --json-spacing-sm: 8px;
    --json-spacing-md: 12px;
    --json-spacing-lg: 20px;
    --json-spacing-xl: 28px;
}

/* JSON Response container - integrated with chat messages */
.json-response {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: var(--typo-base-size, 14px);  /* Uses typography setting */
    font-weight: 400;
    line-height: calc(1.65 * var(--typo-spacing-scale, 1));
    letter-spacing: -0.01em;  /* Slight tightening for Inter */
    /* Remove separate container styling to integrate with message content */
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
}

/* Title at top of JSON response */
.json-response-title {
    color: var(--text-primary);
    font-size: 17px;  /* Reduced from 20px */
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: var(--json-spacing-xs) 0 var(--json-spacing-md) 0;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: var(--json-spacing-xs);
}

/* JSON Response Error Handling */
.json-response-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    color: #dc2626;
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .json-response-error {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}

.json-response-error h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.json-response-error p {
    margin: 8px 0;
    font-size: 14px;
}

.section-error {
    background: #fef3cd;
    border: 1px solid #fde047;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    color: #a16207;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .section-error {
    background: #451a03;
    border-color: #a16207;
    color: #fbbf24;
}

.json-fallback {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    overflow-x: auto;
    white-space: pre-wrap;
    box-shadow: var(--shadow-sm);
}

.json-raw {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    padding: 8px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
}

.fallback-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
}

/* Paragraph in JSON response */
.json-paragraph {
    margin: 0 0 calc(var(--json-spacing-md) * var(--typo-spacing-scale, 1)) 0;
    color: var(--text-primary);
    line-height: calc(1.7 * var(--typo-spacing-scale, 1));
}

.json-paragraph:last-child {
    margin-bottom: 0;
}

/* Text section wrapper */
.json-text-section {
    margin: var(--json-spacing-md) 0;
    color: var(--text-primary);
    line-height: 1.7;
}

/* First text section after title needs less top margin */
.json-response-title + .json-text-section {
    margin-top: var(--json-spacing-sm);
}

/* Paragraphs inside text sections */
.json-text-section .json-paragraph {
    margin: 0 0 var(--json-spacing-md) 0;
}

.json-text-section .json-paragraph:last-child {
    margin-bottom: 0;
}

/* Legacy support for p tags (from formatAssistantMessage) */
.json-text-section p {
    margin: 0 0 var(--json-spacing-md) 0;
}

.json-text-section p:last-child {
    margin-bottom: 0;
}

/* Section headers like "Challenge:", "Solution:" */
.json-section-header {
    display: inline;
    color: var(--text-primary);
    font-weight: 600;
}

/* When section header is at start of paragraph, add top spacing */
.json-paragraph:has(.json-section-header:first-child) {
    margin-top: var(--json-spacing-lg);
}

/* Heading elements in JSON */
.json-heading {
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: var(--json-spacing-lg) 0 var(--json-spacing-md) 0;
}

/* Heading sizes - refined hierarchy */
.json-heading.h1 { font-size: 17px; }
.json-heading.h2 { font-size: 15px; }
.json-heading.h3 { font-size: 14px; }
.json-heading.h4 { font-size: 13px; font-weight: 500; }

/* First heading needs less top margin */
.json-text-section > .json-heading:first-child,
.json-response > .json-heading:first-child {
    margin-top: 0;
}

/* Quote/blockquote styling */
.json-quote {
    border-left: 3px solid var(--accent-color);
    padding: var(--json-spacing-sm) var(--json-spacing-md);
    margin: var(--json-spacing-md) 0;
    background: var(--accent-light);
    font-style: italic;
    font-size: 13px;
    border-radius: 0 6px 6px 0;
}

/* Inline code */
.json-code,
.inline-code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

/* Code block */
.json-code-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: var(--json-spacing-md);
    margin: var(--json-spacing-md) 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.json-code-block code {
    background: none;
    padding: 0;
}

/* Bullet and numbered lists in JSON text */
.json-bullet-list,
.json-numbered-list {
    margin: var(--json-spacing-sm) 0 var(--json-spacing-md) 0;
    padding-left: var(--json-spacing-lg);
}

.json-bullet-list li,
.json-numbered-list li {
    margin: var(--json-spacing-xs) 0;
    line-height: 1.6;
}

/* Legacy: Old .json-code style */
.json-response .json-code:not(.inline-code) {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* JSON List Styling */
.json-list {
    margin: 15px 0;
    padding-left: 25px;
}

.json-checklist {
    list-style: none;
    margin: 15px 0;
    padding-left: 0;
}

.json-checklist li {
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.json-checklist li.checked {
    color: #10b981;
}

.json-checklist li i {
    width: 16px;
    color: var(--accent-color);
}

/* JSON Table Styling */
.json-table-title {
    color: var(--accent-color);
    font-size: 18px;
    font-weight: 600;
    margin: 20px 0 15px 0;
}

.json-table {
    /* Ensure json-table inherits all message-table styles */
    width: 100% !important;
    min-width: 400px !important;
    max-width: 100% !important;
    border-collapse: collapse !important;
    margin: 0 !important;
    background: var(--bg-primary) !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    table-layout: fixed !important;
    box-sizing: border-box !important;
}

.json-table thead {
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
    color: white !important;
}

.json-table th {
    padding: 14px 12px !important;
    text-align: left !important;
    font-weight: 700 !important;
    font-size: 0.85rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    border-right: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-bottom: 3px solid var(--table-header-gradient-end, var(--theme-primary-dark)) !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 150px !important;
    color: white !important;
    background: linear-gradient(135deg, var(--table-header-gradient-start, var(--theme-primary-light)), var(--table-header-gradient-end, var(--theme-primary-dark))) !important;
    box-sizing: border-box !important;
}

.json-table th:last-child {
    border-right: none !important;
}

.json-table td {
    padding: 14px 12px !important;
    border-bottom: 1px solid var(--table-cell-border, var(--theme-primary-light)) !important;
    border-right: 1px solid var(--table-cell-border, var(--theme-primary-light)) !important;
    color: var(--table-body-text, var(--text-primary)) !important;
    vertical-align: top !important;
    line-height: 1.6 !important;
    background: var(--bg-primary) !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 150px !important;
    font-size: 0.9rem !important;
    box-sizing: border-box !important;
}

.json-table td:last-child {
    border-right: none !important;
}

.json-table tbody tr:nth-child(even) {
    background: var(--table-row-even-bg, var(--bg-secondary)) !important;
}

.json-table tbody tr:hover {
    background: var(--table-row-hover, rgba(0, 0, 0, 0.03)) !important;
    transition: background 0.2s ease !important;
    /* No transform, shadow, or border changes - keeps borders visible */
}

.json-table td:first-child {
    border-left: 4px solid var(--table-first-column, var(--theme-primary-light)) !important;
    font-weight: 600 !important;
    background: var(--table-first-column-bg, rgba(91, 167, 247, 0.1)) !important;
    color: var(--table-first-column-text, var(--text-primary)) !important;
}

[data-theme="dark"] .json-table td:first-child {
    background: var(--table-first-column-bg, rgba(20, 184, 166, 0.15)) !important;
    color: var(--table-first-column-text, #ffffff) !important;
    border-left: 4px solid var(--table-first-column, #14b8a6) !important;
}

[data-theme="dark"] .json-table td {
    border-bottom: 1px solid var(--table-cell-border, #14b8a6) !important;
    border-right: 1px solid var(--table-cell-border, #14b8a6) !important;
    color: var(--table-body-text, var(--text-primary)) !important;
}

[data-theme="dark"] .json-table tbody tr:nth-child(even) {
    background: var(--table-row-even-bg, #2d2d30) !important;
}

/* Error Message Styling */
.error-message {
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    color: #c33;
}

.error-message h4 {
    margin: 0 0 8px 0;
    color: #a00;
}

.error-message details {
    margin-top: 12px;
}

.error-message pre {
    background: #f8f8f8;
    padding: 8px;
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
}

[data-theme="dark"] .error-message {
    background: #4a1a1a;
    border-color: #6a2a2a;
    color: #ff6b6b;
}

[data-theme="dark"] .error-message h4 {
    color: #ff5555;
}

[data-theme="dark"] .error-message pre {
    background: #2a2a2a;
    color: #ccc;
}

/* Diagram Styling */
.diagram-section {
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.diagram-title {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.diagram-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 16px 0;
    line-height: 1.4;
}

.diagram-container {
    background: transparent;
    border-radius: 6px;
    padding: 20px;
    min-height: 450px; /* Even larger for better readability */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible; /* Allow diagrams to use full space */
    position: relative; /* For absolute positioning of expand button */
}

/* White background only for successfully rendered diagrams */
.diagram-container.diagram-rendered {
    background: white;
}

/* Diagram expand button (top-right corner) */
.diagram-expand-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--theme-primary, #4A90E2); /* Fallback for first load */
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    pointer-events: auto; /* Ensure button receives clicks */
}

.diagram-expand-btn:hover {
    background: var(--theme-primary-dark, #3A7BD5); /* Fallback */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
}

.diagram-expand-btn i {
    font-size: 13px;
}

[data-theme="dark"] .diagram-expand-btn {
    background: var(--theme-primary-light, #4DD0E1); /* Fallback */
    color: var(--bg-primary, #1e1e1e); /* Fallback */
}

[data-theme="dark"] .diagram-expand-btn:hover {
    background: var(--theme-primary-dark, #00ACC1); /* Fallback */
}

/* Diagram Viewer Modal - Sized to fit chat area */
.diagram-viewer-modal {
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    background: var(--bg-primary);
    border: 2px solid var(--border-light);
    /* Width: 90% of chat container (chat is 80vw max 1200px, so 90% of that) */
    max-width: 1080px; /* 90% of 1200px */
    width: 72vw; /* 90% of 80vw */
    /* Height: fit between header and input bar */
    height: calc(100vh - var(--header-height, 60px) - 120px); /* header + input bar space */
    max-height: calc(100vh - 180px);
    /* Subtle shadow on desktop */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Mobile: Fit within viewport with generous padding and shadow */
@media (max-width: 768px) {
    .diagram-viewer-modal {
        /* More generous padding with requested size reduction */
        /* Width: Reduced by 5% from original */
        max-width: calc(95vw - 40px); /* Was 100vw - 40px */
        width: calc(95vw - 40px);
        /* Height: Reduced by 15% from original */
        max-height: calc(85vh - 74px); /* Was 100vh - 74px */
        height: calc(85vh - 74px);
        border-radius: 12px;
        border: 1px solid var(--border-light);
        /* Shadow effect with extra compensation padding */
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 
                    0 4px 16px rgba(0, 0, 0, 0.1),
                    0 2px 8px rgba(0, 0, 0, 0.08);
        /* Position to ensure branding/header is visible */
        margin-top: 50px;
        margin-bottom: 24px;
    }
    
    .diagram-viewer-modal .modal-header {
        border-radius: 12px 12px 0 0;
        padding: 14px 18px;
    }
    
    .diagram-viewer-modal .modal-header h3 {
        font-size: 16px;
    }
    
    .diagram-viewer-controls {
        padding: 12px 14px;
        gap: 8px !important;
    }
    
    .diagram-viewer-controls .modal-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .diagram-viewer-controls .modal-btn i {
        margin-right: 4px;
    }
}

.diagram-viewer-modal .modal-header {
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--diagram-viewer-header-start, var(--theme-primary)), var(--diagram-viewer-header-end, var(--theme-primary-dark)));
    color: white;
    padding: 16px 24px;
    border-radius: 12px 12px 0 0;
}

.diagram-viewer-modal .modal-header h3 {
    color: white !important;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.diagram-viewer-modal .modal-close {
    color: white;
    opacity: 0.9;
}

.diagram-viewer-modal .modal-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.diagram-viewer-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    background: white; /* Always white canvas for diagram (like chat) */
    padding: 25px; /* Spacing for drop-shadow - white extends full width */
    box-sizing: border-box;
}

.diagram-viewer-body:active {
    cursor: grabbing;
}

.diagram-viewer-body .mermaid-diagram {
    width: 100%;
    height: 100%;
    display: block; /* Changed from flex to prevent shrink-wrapping */
    position: relative;
    background: white; /* White background on diagram wrapper too */
}

.diagram-viewer-body svg {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
}

.diagram-viewer-controls {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    flex-shrink: 0;
    background: var(--diagram-viewer-controls-bg, var(--bg-secondary));
    border-top: 2px solid var(--border-light);
}

.diagram-viewer-controls .modal-btn {
    font-size: 13px;
    padding: 10px 16px;
    font-weight: 500;
    border: 1px solid var(--border-light);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    /* Prevent double-tap zoom on mobile */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Mobile only: Active/Focus states match base state to prevent color sticking */
@media (hover: none) and (pointer: coarse) {
    .diagram-viewer-controls .modal-btn:active,
    .diagram-viewer-controls .modal-btn:focus {
        background: var(--bg-primary);
        color: var(--text-primary);
        border-color: var(--border-light);
        outline: none;
    }
}

/* Desktop: Hover works always, even after button is clicked/focused */
@media (hover: hover) and (pointer: fine) {
    .diagram-viewer-controls .modal-btn:hover {
        background: var(--theme-primary);
        color: white;
        border-color: var(--theme-primary);
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
    
    /* Remove focus outline on desktop (hover provides enough feedback) */
    .diagram-viewer-controls .modal-btn:focus {
        outline: none;
    }
}

.diagram-viewer-controls .modal-btn i {
    margin-right: 6px;
}

.diagram-viewer-controls .modal-btn:last-child {
    background: var(--theme-primary);
    color: white;
    border-color: var(--theme-primary);
}

/* Mobile only: Close button active/focus states match base state (blue) */
@media (hover: none) and (pointer: coarse) {
    .diagram-viewer-controls .modal-btn:last-child:active,
    .diagram-viewer-controls .modal-btn:last-child:focus {
        background: var(--theme-primary);
        border-color: var(--theme-primary);
        color: white;
        outline: none;
    }
}

/* Desktop: Hover works always for close button */
@media (hover: hover) and (pointer: fine) {
    .diagram-viewer-controls .modal-btn:last-child:hover {
        background: var(--theme-primary-dark);
        border-color: var(--theme-primary-dark);
    }
    
    /* Remove focus outline on desktop */
    .diagram-viewer-controls .modal-btn:last-child:focus {
        outline: none;
    }
}

[data-theme="dark"] .diagram-viewer-modal {
    background: var(--bg-primary);
    border-color: var(--border-medium);
}

[data-theme="dark"] .diagram-viewer-modal .modal-header {
    background: linear-gradient(135deg, var(--diagram-viewer-header-start, var(--theme-primary-light)), var(--diagram-viewer-header-end, var(--theme-primary-dark)));
}

[data-theme="dark"] .diagram-viewer-body {
    background: white; /* Keep canvas white even in dark theme (like chat) */
}

[data-theme="dark"] .diagram-viewer-controls {
    background: var(--diagram-viewer-controls-bg, var(--bg-tertiary));
    border-color: var(--border-medium);
}

/* Mobile only: Dark theme button active/focus states match base state (prevent teal sticking) */
@media (hover: none) and (pointer: coarse) {
    [data-theme="dark"] .diagram-viewer-controls .modal-btn:active,
    [data-theme="dark"] .diagram-viewer-controls .modal-btn:focus {
        background: var(--bg-primary);
        color: var(--text-primary);
        border-color: var(--border-light);
        outline: none;
    }
}

/* Desktop: Dark theme hover works always */
@media (hover: hover) and (pointer: fine) {
    [data-theme="dark"] .diagram-viewer-controls .modal-btn:hover {
        background: var(--theme-primary-light);
        border-color: var(--theme-primary-light);
    }
    
    /* Remove focus outline on desktop */
    [data-theme="dark"] .diagram-viewer-controls .modal-btn:focus {
        outline: none;
    }
}

[data-theme="dark"] .diagram-viewer-controls .modal-btn:last-child {
    background: var(--theme-primary-light);
    border-color: var(--theme-primary-light);
}

/* Mobile only: Dark theme close button active/focus states match base state (teal) */
@media (hover: none) and (pointer: coarse) {
    [data-theme="dark"] .diagram-viewer-controls .modal-btn:last-child:active,
    [data-theme="dark"] .diagram-viewer-controls .modal-btn:last-child:focus {
        background: var(--theme-primary-light);
        border-color: var(--theme-primary-light);
        color: white;
        outline: none;
    }
}

/* Desktop: Dark theme close button hover works always */
@media (hover: hover) and (pointer: fine) {
    [data-theme="dark"] .diagram-viewer-controls .modal-btn:last-child:hover {
        background: var(--theme-primary-dark);
        border-color: var(--theme-primary-dark);
    }
    
    /* Remove focus outline on desktop */
    [data-theme="dark"] .diagram-viewer-controls .modal-btn:last-child:focus {
        outline: none;
    }
}

/* Mobile: Hide text labels on zoom buttons to save space */
@media (max-width: 768px) {
    .diagram-viewer-controls .modal-btn {
        padding: 8px 10px;
    }
    
    .diagram-viewer-controls .modal-btn i {
        margin: 0;
    }
    
    .diagram-viewer-controls .modal-btn:not(:last-child) {
        /* Hide text, keep icons */
    }
    
    .diagram-viewer-controls .modal-btn:not(:last-child)::after {
        content: '';
    }
}

.diagram-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.diagram-loading i {
    color: var(--theme-primary);
}

.mermaid-diagram {
    width: 100%;
    text-align: center;
}

.mermaid-diagram svg {
    max-width: 100%;
    width: 100%;
    height: auto;
    min-height: 400px; /* Larger minimum height */
    border-radius: 4px;
}

/* Clean Mermaid diagram container styling (no color overrides - let themeCSS handle it!) */
.mermaid-diagram svg {
    padding: 20px;
    background: white !important;
    border-radius: 4px;
    font-family: 'Inter', Arial, sans-serif;
    font-size: 14px;
}

.diagram-fallback,
.diagram-error {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.diagram-fallback i,
.diagram-error i {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--theme-primary);
}

.diagram-error i {
    color: #ff6b6b;
}

.diagram-fallback details,
.diagram-error details {
    margin-top: 12px;
    text-align: left;
}

.diagram-fallback pre,
.diagram-error pre {
    background: var(--bg-tertiary);
    padding: 8px;
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* Dark theme diagram styling */
[data-theme="dark"] .diagram-container {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .diagram-fallback pre,
[data-theme="dark"] .diagram-error pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
}

.retry-diagram-btn, .retry-btn {
    background: var(--theme-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin: 8px 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.retry-diagram-btn:hover, .retry-btn:hover {
    background: var(--theme-primary-dark);
}

/* JSON Metrics Styling */
.json-metrics-title {
    color: var(--accent-color);
    font-size: 18px;
    font-weight: 600;
    margin: 20px 0 15px 0;
}

.json-metrics-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    margin: 20px auto;
    width: 100%;
    max-width: 1000px;
}

.json-metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;  /* Reduced from 20px */
    text-align: center;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 180px;  /* Reduced from 220px */
    min-height: 110px;  /* Increased from 100px to allow 3-line labels */
    height: auto;  /* Changed from fixed 100px to auto */
    max-height: 140px;  /* Cap the max height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    flex-shrink: 0;
}

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

.json-metric-card .metric-value {
    font-size: 24px;  /* Default, overridden by dynamic sizing in JavaScript */
    font-weight: 700;
    color: var(--accent-color);
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.json-metric-card .metric-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.json-metric-card .metric-label-medium {
    font-size: 10px;
}

.json-metric-card .metric-label-small {
    font-size: 9px;
    letter-spacing: 0.3px;
}

.json-metric-card .metric-unit {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.2;
}

.json-metric-card .metric-trend {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 14px;
}

.trend-up { color: #10b981; }
.trend-down { color: #ef4444; }
.trend-neutral { color: var(--text-muted); }

/* JSON Placeholders */
.json-chart-placeholder,
.json-image-placeholder {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-light);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    margin: 20px 0;
    color: var(--text-muted);
}

.chart-placeholder,
.image-placeholder {
    font-size: 48px;
    margin-bottom: 15px;
}

.image-caption {
    font-style: italic;
    color: var(--text-muted);
    margin-top: 10px;
}

/* Image sections in chat responses */
.json-image-section {
    margin: 20px 0;
    text-align: center;
}

.json-image-section img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
    .json-image-section img {
        max-height: 300px;
    }
}

/* Dark theme JSON styling */
[data-theme="dark"] .json-metric-card {
    background: var(--bg-tertiary);
    border-color: var(--border-dark);
}

[data-theme="dark"] .json-chart-placeholder,
[data-theme="dark"] .json-image-placeholder {
    background: var(--bg-tertiary);
    border-color: var(--border-dark);
}

/* Global Action Bar Styling */
.global-actions-container {
    padding: 15px 0;
    border-top: 1px solid var(--border-light);
    background: var(--bg-primary);
    margin-bottom: 10px;
}

.global-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.global-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--bg-secondary);
    border: 2px solid var(--theme-primary-light);
    border-radius: 10px;
    color: var(--theme-primary-light);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
    min-width: 120px;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.global-action-btn:hover {
    background: var(--theme-primary-light);
    border-color: var(--theme-primary-light);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(91, 167, 247, 0.3);
}

.global-action-btn:active {
    transform: translateY(0);
}

.global-action-btn i {
    font-size: 16px;
}

/* Special styling for report button */
.global-action-btn.report-btn {
    background: linear-gradient(135deg, var(--theme-primary-light), var(--theme-primary-dark));
    color: white;
    border-color: var(--theme-primary-dark);
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(91, 167, 247, 0.4);
}

.global-action-btn.report-btn:hover {
    background: linear-gradient(135deg, var(--theme-primary-dark), var(--theme-primary));
    border-color: var(--theme-primary);
    color: white;
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.5);
    transform: translateY(-3px);
}

/* Dark theme global actions */
[data-theme="dark"] .global-actions-container {
    background: var(--bg-secondary);
    border-color: var(--border-dark);
}

[data-theme="dark"] .global-action-btn {
    background: var(--bg-tertiary);
    border-color: #14b8a6;
    color: #14b8a6;
}

[data-theme="dark"] .global-action-btn:hover {
    background: #14b8a6;
    border-color: #14b8a6;
    color: white;
    box-shadow: 0 6px 20px rgba(20, 184, 166, 0.3);
}

[data-theme="dark"] .global-action-btn.report-btn {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    border-color: #0d9488;
    box-shadow: 0 4px 15px rgba(20, 184, 166, 0.4);
}

[data-theme="dark"] .global-action-btn.report-btn:hover {
    background: linear-gradient(135deg, #0d9488, #0f766e);
    border-color: #0f766e;
    box-shadow: 0 8px 25px rgba(13, 148, 136, 0.5);
}

/* Mobile Header Optimizations - Enhanced mobile detection */
@media (max-width: 768px), 
@media (max-device-width: 768px),
@media screen and (max-width: 768px) and (orientation: portrait),
@media screen and (max-width: 768px) and (orientation: landscape) {
    /* Hide top header buttons on mobile */
    .nav-right {
        display: none;
    }
    
    /* Force sidebar footer to be visible on mobile - enhanced */
    .sidebar .sidebar-footer {
        display: grid !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        flex-shrink: 0 !important;
        margin-top: auto !important;
        background: var(--bg-secondary) !important;
        /* border: 2px solid orange !important; /* Mobile debug border removed */
    }
    
    /* Adjust app title for mobile */
    .app-title {
        font-size: 16px !important;
        font-weight: 600;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Responsive global actions */
    .global-actions {
        gap: 8px;
    }
    
    .global-action-btn {
        padding: 8px 12px;
        font-size: 12px;
        min-width: 80px;
    }
    
    .global-action-btn i {
        font-size: 14px;
    }
    
    /* Mobile Chat Messages - Add space for fixed input bar */
    .chat-messages {
        padding-bottom: 140px !important;  /* Space for fixed input bar + safe area */
    }
    
    /* Mobile Chat Input - Enhanced keyboard handling */
    .chat-input-container {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom)); /* Handle iPhone notch */
        background: var(--bg-primary);
        border-top: 2px solid var(--border-light);
        z-index: 1000;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        box-sizing: border-box;
        
        /* Enhanced mobile keyboard support */
        transform: translateY(0);
        transition: transform 0.2s ease-out;
        will-change: transform;
    }
    
    .chat-input-wrapper {
        padding: 12px;
        border-radius: 25px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 20px;
        max-height: 120px;
    }
    
    /* Landscape-specific: Ensure full width span */
    @media (max-width: 932px) and (orientation: landscape) {
        .chat-input-container {
            position: fixed !important;
            bottom: 0 !important;
            left: 0 !important;
            right: 0 !important;
            top: auto !important;
            width: 100vw !important;
            min-width: 100vw !important;
            max-width: 100vw !important;
            margin: 0 !important;
            padding-left: 16px !important;
            padding-right: 16px !important;
        }
        
        .chat-input-wrapper {
            width: 100% !important;
            max-width: 100% !important;
            margin: 0 !important;
        }
    }
    
    /* Adjust main content to account for fixed input */
    .main-content {
        padding-bottom: 80px; /* Space for fixed input */
    }
    
    .chat-messages {
        padding-bottom: 20px;
    }
    
    /* Keyboard open state enhancements */
    body.keyboard-open .chat-input-container {
        /* Enhanced shadow when keyboard is open */
        box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.2);
    }
    
    /* Prevent content jumping when keyboard opens */
    body.keyboard-open .chat-messages {
        /* Use CSS custom property set by JavaScript */
        max-height: var(--viewport-height, 100vh);
        overflow-y: auto;
    }
    
    /* Smooth transitions for keyboard state changes */
    .chat-messages {
        transition: max-height 0.2s ease-out;
    }
}

/* Modal Content Display Styles */
.modal-content-display {
    max-width: 100%;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: 8px;
    overflow: hidden;
}

.modal-content-header {
    padding: 0; /* Remove padding for perfect centering */
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    text-align: center;
    height: 120px; /* Fixed height for consistent sizing */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0; /* No gap - tight spacing between logo and date */
    height: 100%;
    justify-content: center;
}

.modal-logo {
    width: 240px; /* Increased 50% from 160px */
    height: 240px;
    object-fit: contain;
    margin: 0;
    margin-top: 30px;
}

.content-timestamp {
    margin: 10px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* Remove unused meta styles */
.modal-content-meta {
    text-align: center;
    margin: 0;
}

.modal-content-meta h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-content-body {
    padding: 0 24px 24px 24px; /* No top padding - tight against header */
    line-height: 1.6;
    color: var(--text-primary);
}

.modal-content-body p {
    margin: 0 0 16px 0;
    line-height: 1.8;
}

.modal-content-body ul,
.modal-content-body ol {
    margin: 0 0 16px 0;
    line-height: 1.8;
}

.modal-content-body strong {
    font-weight: 600;
    color: var(--text-primary);
}

/* Ensure JSON response elements display correctly in modal */
.modal-content-body .json-metrics-grid,
.modal-content-display .json-metrics-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
    justify-content: center !important;
}

.modal-content-body .json-metric-card,
.modal-content-display .json-metric-card {
    display: flex !important;
    flex-direction: column !important;
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 8px !important;
    padding: 20px !important;
}

.modal-content-body .json-table,
.modal-content-display .json-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.modal-content-body .json-list,
.modal-content-display .json-list {
    margin: 16px 0;
}

.modal-content-body .diagram-container,
.modal-content-display .diagram-container {
    margin: 20px 0;
    width: 100%;
}

/* Code View Fallback Styling */
.code-view-fallback {
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    max-width: 100%;
    box-sizing: border-box;
}

.fallback-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--accent-color);
}

.fallback-header i {
    font-size: 24px;
}

.fallback-header h3 {
    margin: 0;
    font-size: 18px;
}

.fallback-reason {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 4px;
}

[data-theme="dark"] .fallback-reason {
    background: rgba(255, 193, 7, 0.1);
    border-left-color: #ffc107;
}

.fallback-reason p {
    margin: 8px 0;
    color: var(--text-primary);
}

.fallback-content {
    margin: 16px 0;
    max-width: 100%;
    overflow: hidden;
}

.fallback-content pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 16px;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

.fallback-content pre code {
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
}

.fallback-actions {
    margin-top: 16px;
    font-style: italic;
    color: var(--text-muted);
}

.modal-paragraph {
    margin-bottom: 16px;
}

.modal-list {
    margin-bottom: 16px;
    padding-left: 24px;
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.modal-table th,
.modal-table td {
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    text-align: left;
}

.modal-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.modal-quote {
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-secondary);
    border-left: 4px solid var(--theme-primary);
    border-radius: 4px;
}

/* Theme-aware header styling for modal content */
.modal-content-body h1,
.modal-content-body h2,
.modal-content-body h3,
.modal-content-body h4,
.modal-content-body h5,
.modal-content-body h6 {
    color: var(--theme-primary);
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
}

.modal-content-body h1 {
    font-size: 28px;
    border-bottom: 2px solid var(--theme-primary);
    padding-bottom: 8px;
}

.modal-content-body h2 {
    font-size: 24px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 6px;
}

.modal-content-body h3 {
    font-size: 20px;
}

.modal-content-body h4 {
    font-size: 18px;
}

.modal-content-body h5,
.modal-content-body h6 {
    font-size: 16px;
}

.modal-content-footer {
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.content-attribution {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.content-attribution a {
    color: var(--theme-primary);
    text-decoration: none;
}

.content-attribution a:hover {
    text-decoration: underline;
}

/* Modal diagram styling */
.modal-content-display .diagram-section {
    margin: 16px 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
}

.modal-content-display .diagram-container {
    background: white;
    min-height: 250px;
}

.modal-content-display .mermaid-diagram svg {
    max-width: 100%;
    max-height: 400px;
}

[data-theme="dark"] .modal-content-display .diagram-container {
    background: var(--bg-tertiary);
}

/* Print-specific styles for modal content */
@media print {
    /* ============================================================
       TYPOGRAPHY - Honor user's font size and density settings
       ============================================================ */
    body,
    .message-content,
    .json-response,
    .json-text-section,
    .json-paragraph {
        font-size: var(--typo-base-size, 14px) !important;
        line-height: calc(1.6 * var(--typo-spacing-scale, 1)) !important;
    }
    
    .message-content h1,
    .json-response-title {
        font-size: calc(17px * var(--typo-scale, 1)) !important;
    }
    
    .message-content h2 {
        font-size: calc(15px * var(--typo-scale, 1)) !important;
    }
    
    .message-content h3 {
        font-size: calc(14px * var(--typo-scale, 1)) !important;
    }
    
    .message-content p,
    .json-paragraph {
        margin-bottom: calc(12px * var(--typo-spacing-scale, 1)) !important;
    }
    
    .message-content li {
        margin-bottom: calc(8px * var(--typo-spacing-scale, 1)) !important;
        line-height: calc(1.6 * var(--typo-spacing-scale, 1)) !important;
    }
    
    .message-table td,
    .message-table th {
        padding: calc(10px * var(--typo-spacing-scale, 1)) !important;
        font-size: var(--typo-base-size, 14px) !important;
    }
    
    /* ============================================================
       MERMAID SVG PRINT STYLES - Comprehensive coverage
       ============================================================ */
    
    /* NODE BACKGROUNDS - Blue fill for all node types */
    svg rect:not(.edgeLabel rect):not(.labelBox),
    svg .node rect,
    svg .node polygon,
    svg g.node rect,
    svg g[class*="node"] rect {
        fill: #4A90E2 !important;
        stroke: #357ABD !important;
        stroke-width: 2px !important;
    }
    
    /* CLUSTER/SUBGRAPH backgrounds - Light gray */
    svg .cluster rect,
    svg g.cluster rect {
        fill: #f8f9fa !important;
        stroke: #357ABD !important;
        stroke-width: 1px !important;
    }
    
    /* SEQUENCE DIAGRAM - Actor boxes */
    svg .actor,
    svg .actor rect,
    svg g.actor rect {
        fill: #4A90E2 !important;
        stroke: #357ABD !important;
        stroke-width: 2px !important;
    }
    
    /* NODE TEXT - White on blue boxes (critical!) */
    svg .node text,
    svg .node tspan,
    svg .nodeLabel,
    svg .nodeLabel text,
    svg .nodeLabel tspan,
    svg g.node text,
    svg g[class*="node"] text,
    svg rect + text,
    svg polygon + text {
        fill: #ffffff !important;
        color: #ffffff !important;
        font-weight: 600 !important;
    }
    
    /* SEQUENCE DIAGRAM - Actor text (white on blue) */
    svg .actor text,
    svg .actor tspan,
    svg g.actor text,
    svg g.actor tspan,
    svg text.actor {
        fill: #ffffff !important;
        color: #ffffff !important;
        font-weight: 600 !important;
    }
    
    /* foreignObject labels (modern Mermaid) - handle both node and edge */
    svg .node foreignObject div,
    svg .node foreignObject span,
    svg .nodeLabel foreignObject div,
    svg .nodeLabel foreignObject span,
    svg g.node foreignObject div,
    svg g.node foreignObject span {
        color: #ffffff !important;
        font-weight: 600 !important;
    }
    
    /* CLUSTER/SUBGRAPH LABELS - Black text */
    svg .cluster text,
    svg .cluster tspan,
    svg .cluster-label text,
    svg .cluster-label tspan,
    svg g.cluster text {
        fill: #000000 !important;
        color: #000000 !important;
        font-weight: 600 !important;
    }
    
    /* EDGE/CONNECTION LABELS - Black text */
    svg .edgeLabel text,
    svg .edgeLabel tspan,
    svg .edgeLabel span,
    svg g.edgeLabel text,
    svg .messageText,
    svg text.messageText,
    svg .labelText {
        fill: #000000 !important;
        color: #000000 !important;
        font-weight: 500 !important;
    }
    
    /* Edge label backgrounds - transparent */
    svg .edgeLabel rect,
    svg g.edgeLabel rect,
    svg .labelBox {
        fill: transparent !important;
        opacity: 0 !important;
    }
    
    /* ARROWS AND LINES */
    svg path.flowchart-link,
    svg .edgePath path,
    svg line.messageLine0,
    svg line.messageLine1 {
        stroke: #357ABD !important;
        stroke-width: 2px !important;
    }
    
    /* ALL generic paths (fallback) */
    svg path {
        stroke: #357ABD !important;
        stroke-width: 2px !important;
    }
    
    /* Pie chart slices - preserve colors */
    svg path.slice,
    svg g[class*="pie"] path {
        fill: inherit !important;
        stroke: #ffffff !important;
    }
    
    /* ARROWHEADS */
    svg marker path,
    svg marker polygon,
    svg .arrowMarkerPath {
        fill: #357ABD !important;
        stroke: #357ABD !important;
    }
    
    /* Circles, polygons, ellipses (fallbacks) */
    svg circle:not(.actor) {
        fill: #4A90E2 !important;
        stroke: #357ABD !important;
    }
    
    svg polygon:not(.arrowMarkerPath) {
        fill: #4A90E2 !important;
        stroke: #357ABD !important;
    }
    
    svg ellipse {
        fill: #4A90E2 !important;
        stroke: #357ABD !important;
    }
    
    svg line {
        stroke: #357ABD !important;
    }
    
    /* NOTES (yellow boxes in sequence diagrams) */
    svg .note rect {
        fill: #fff8e1 !important;
        stroke: #ffc107 !important;
    }
    
    svg .note text,
    svg .noteText {
        fill: #000000 !important;
    }
    
    /* Activation boxes in sequence diagrams */
    svg .activation0,
    svg .activation1,
    svg .activation2 {
        fill: #e3f2fd !important;
        stroke: #357ABD !important;
    }
    
    /* Loop/alt boxes in sequence diagrams */
    svg .loopLine {
        stroke: #357ABD !important;
    }
    
    svg .loopText,
    svg text.loopText {
        fill: #000000 !important;
    }
    
    .modal-content-display {
        box-shadow: none;
        border: none;
    }
    
    .modal-content-header,
    .modal-content-footer {
        background: white !important;
        color: black !important;
    }
    
    .content-attribution a {
        color: black !important;
    }
    
    /* Make logo much smaller for print - more specific selector */
    .modal-content-display .modal-logo,
    .modal-header-content .modal-logo,
    #reactReportContainer .modal-logo {
        width: 32px !important;
        height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
    }
    
    /* Tighten spacing for print */
    .modal-content-header {
        padding: 2px 4px !important; /* Minimal print padding */
        height: 50px !important; /* Smaller for 32px logo */
    }
    
    .modal-header-content {
        gap: 2px !important; /* Small gap for print */
    }
    
    /* Force small logo size with multiple selectors */
    .modal-logo,
    [class*="logo"] {
        width: 32px !important;
        height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
    }
    
    /* Professional table styling for print */
    .modal-table,
    table {
        border-collapse: collapse !important;
        border: 2px solid black !important;
        width: 100% !important;
        margin: 16px 0 !important;
    }
    
    .modal-table th,
    .modal-table td,
    table th,
    table td {
        border: 1px solid black !important;
        padding: 8px 12px !important;
        text-align: left !important;
    }
    
    .modal-table th,
    table th {
        background: black !important;
        color: white !important;
        font-weight: bold !important;
        text-align: center !important;
    }
    
    .modal-table td,
    table td {
        background: white !important;
        color: black !important;
    }
    
    /* Alternating row colors for better readability */
    .modal-table tr:nth-child(even) td,
    table tr:nth-child(even) td {
        background: #f5f5f5 !important;
    }
    
    /* Professional list styling for print */
    .modal-list,
    ul,
    ol {
        margin: 12px 0 !important;
        padding-left: 20px !important;
    }
    
    .modal-list li,
    ul li,
    ol li {
        margin-bottom: 4px !important;
        color: black !important;
    }
    
    /* Quote/blockquote styling for print */
    .modal-quote,
    blockquote {
        border-left: 4px solid black !important;
        background: #f9f9f9 !important;
        padding: 12px 16px !important;
        margin: 16px 0 !important;
        color: black !important;
        font-style: italic;
    }
    
    /* Header styling for print */
    .modal-content-body h1,
    .modal-content-body h2,
    .modal-content-body h3,
    .modal-content-body h4,
    .modal-content-body h5,
    .modal-content-body h6,
    h1, h2, h3, h4, h5, h6 {
        color: black !important;
        font-weight: bold !important;
        margin-top: 20px !important;
        margin-bottom: 10px !important;
    }
    
    .modal-content-body h1,
    h1 {
        font-size: 24px !important;
        border-bottom: 2px solid black !important;
        padding-bottom: 6px !important;
    }
    
    .modal-content-body h2,
    h2 {
        font-size: 20px !important;
        border-bottom: 1px solid black !important;
        padding-bottom: 4px !important;
    }
    
    /* Paragraph and text styling */
    .modal-paragraph,
    p {
        color: black !important;
        margin-bottom: 12px !important;
        line-height: 1.4 !important;
    }
    
    /* Strong/bold text */
    strong, b {
        color: black !important;
        font-weight: bold !important;
    }
    
    /* Links for print */
    a {
        color: black !important;
        text-decoration: underline !important;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .admin-modal {
        width: 95vw;
        height: 90vh;
        margin: 20px;
    }
    
    .admin-modal .admin-tabs {
        flex-wrap: wrap;
        padding: 0 16px;
    }
    
    .admin-modal .admin-tab {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .admin-modal .admin-content {
        padding: 16px;
    }
    
    .content-source {
        text-align: center;
        margin: 8px 0;
        padding: 4px 8px;
        background: var(--bg-secondary);
        border-radius: 4px;
        border: 1px solid var(--border-light);
    }
    
    .content-source small {
        color: var(--text-muted);
        font-size: 11px;
    }
    
    .content-source i {
        margin-right: 4px;
        color: var(--theme-primary);
    }
    
    .about-claude-content {
        padding: 16px;
    }
    
    .claude-content {
        margin-top: 16px;
    }
    
    [data-theme="dark"] .content-source {
        background: var(--bg-tertiary);
        border-color: var(--border-medium);
    }
    
    .section-subtitle {
        color: var(--text-secondary);
        font-size: 14px;
        margin-bottom: 20px;
        font-style: italic;
    }
    
    .advisors-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 16px;
    }
    
    .leader.advisor {
        background: var(--bg-secondary);
        padding: 12px;
        border-radius: 8px;
        border: 1px solid var(--border-light);
    }
    
    .leader.advisor h4 {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .leader.advisor .title {
        font-size: 12px;
        line-height: 1.3;
    }
    
    [data-theme="dark"] .leader.advisor {
        background: var(--bg-tertiary);
        border-color: var(--border-medium);
    }
    
    /* Admin Items Styling */
    .admin-item {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 16px;
        border: 1px solid var(--border-light);
        border-radius: 8px;
        margin-bottom: 12px;
        background: var(--bg-secondary);
    }
    
    .item-info {
        flex: 1;
        margin-right: 16px;
    }
    
    .item-header {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
    }
    
    .item-header i {
        color: var(--theme-primary);
        width: 16px;
    }
    
    .item-header h6 {
        font-size: 16px;
        font-weight: 600;
        color: var(--text-primary);
        margin: 0;
        flex: 1;
    }
    
    .item-type, .item-category {
        background: var(--bg-tertiary);
        color: var(--text-secondary);
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 500;
        text-transform: uppercase;
    }
    
    .usage-count {
        background: var(--editor-success);
        color: white;
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 500;
    }
    
    .item-description {
        color: var(--text-secondary);
        font-size: 14px;
        margin: 4px 0;
        line-height: 1.4;
    }
    
    .item-url {
        color: var(--theme-primary);
        font-size: 12px;
        font-family: monospace;
        margin: 4px 0;
        word-break: break-all;
    }
    
    .item-prompt {
        color: var(--text-muted);
        font-size: 13px;
        font-style: italic;
        margin: 4px 0;
        line-height: 1.3;
    }
    
    .item-actions {
        display: flex;
        gap: 8px;
        flex-shrink: 0;
    }
    
    .admin-btn {
        background: var(--bg-tertiary);
        border: 1px solid var(--border-light);
        color: var(--text-secondary);
        padding: 6px 12px;
        border-radius: 4px;
        font-size: 12px;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .admin-btn:hover {
        background: var(--hover-bg);
        color: var(--text-primary);
    }
    
    .admin-btn.edit {
        color: var(--theme-primary);
    }
    
    .admin-btn.edit:hover {
        background: rgba(37, 99, 235, 0.1);
    }
    
    .admin-btn.delete {
        color: #ef4444;
    }
    
    .admin-btn.delete:hover {
        background: rgba(239, 68, 68, 0.1);
    }
    
    .admin-btn.test {
        color: var(--editor-success);
    }
    
    .admin-btn.test:hover {
        background: rgba(16, 185, 129, 0.1);
    }
    
    .no-items {
        text-align: center;
        color: var(--text-muted);
        font-style: italic;
        padding: 40px 20px;
    }
    
    .admin-actions {
        display: flex;
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .favorite-form, .prompt-form {
        background: var(--bg-tertiary);
        border: 1px solid var(--border-light);
        border-radius: 8px;
        padding: 20px;
        margin-top: 20px;
    }
    
    .favorite-form h6, .prompt-form h6 {
        font-size: 18px;
        font-weight: 600;
        color: var(--text-primary);
        margin: 0 0 16px 0;
        border-bottom: 1px solid var(--border-light);
        padding-bottom: 8px;
    }
    
    .form-actions {
        display: flex;
        gap: 12px;
        margin-top: 20px;
        justify-content: flex-end;
    }
    
    .checkbox-group {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-top: 8px;
    }
    
    .checkbox-group input[type="checkbox"] {
        width: auto;
        margin: 0;
    }
    
    .checkbox-group label {
        font-size: 14px;
        color: var(--text-secondary);
        cursor: pointer;
        margin: 0;
    }
    
    /* Icon selector styling */
    select optgroup {
        font-weight: 600;
        color: var(--text-primary);
        background: var(--bg-secondary);
        padding: 4px 0;
    }
    
    select option {
        padding: 6px 12px;
        color: var(--text-primary) !important;
        background: var(--bg-primary) !important;
    }
    
    select option:hover {
        background: var(--bg-secondary) !important;
        color: var(--text-primary) !important;
    }
    
    select option:checked {
        background: var(--theme-primary) !important;
        color: white !important;
    }
    
    [data-theme="dark"] select optgroup {
        background: var(--bg-tertiary);
        color: var(--text-primary);
    }
    
    [data-theme="dark"] select option {
        background: var(--bg-primary);
        color: var(--text-secondary);
    }
    
    /* Privacy Notice Styling */
    .privacy-notice {
        margin-top: 16px;
        padding: 12px;
        background: var(--bg-secondary);
        border-radius: 6px;
        border: 1px solid var(--border-light);
    }
    
    .privacy-notice p {
        margin: 0;
        font-size: 13px;
        line-height: 1.4;
        color: var(--text-secondary);
    }
    
    .privacy-notice a {
        color: var(--editor-primary);
        text-decoration: none;
        font-weight: 500;
    }
    
    .privacy-notice a:visited {
        color: var(--editor-primary);
    }
    
    .privacy-notice a:hover {
        text-decoration: underline;
        color: var(--theme-primary);
    }
    
    [data-theme="dark"] .privacy-notice {
        background: var(--bg-tertiary);
        border-color: var(--border-medium);
    }
    
    [data-theme="dark"] .privacy-notice a {
        color: var(--editor-primary);
    }
    
    [data-theme="dark"] .privacy-notice a:visited {
        color: var(--editor-primary);
    }
    
    [data-theme="dark"] .privacy-notice a:hover {
        color: var(--editor-success);
    }
    
    /* Dark theme admin items */
    [data-theme="dark"] .admin-item {
        background: var(--bg-tertiary);
        border-color: var(--border-medium);
    }
    
    [data-theme="dark"] .item-type, 
    [data-theme="dark"] .item-category {
        background: var(--bg-primary);
        color: var(--text-secondary);
    }
    
    [data-theme="dark"] .favorite-form, 
    [data-theme="dark"] .prompt-form {
        background: var(--bg-primary);
        border-color: var(--border-medium);
    }
    
    /* Sortable/Drag-and-Drop Styling */
    .sortable-list {
        position: relative;
    }
    
    .admin-item {
        cursor: move;
        transition: all 0.2s ease;
        position: relative;
    }
    
    .admin-item:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }
    
    .admin-item.dragging {
        opacity: 0.5;
        transform: rotate(2deg);
        z-index: 1000;
    }
    
    .admin-item.drag-over {
        border-top: 3px solid var(--theme-primary);
    }
    
    .drag-handle {
        position: absolute;
        left: 8px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-muted);
        cursor: grab;
        font-size: 14px;
        opacity: 0;
        transition: opacity 0.2s ease;
    }
    
    .admin-item:hover .drag-handle {
        opacity: 1;
    }
    
    .drag-handle:active {
        cursor: grabbing;
    }
    
    .sort-indicator {
        position: absolute;
        right: 8px;
        top: 8px;
        background: var(--bg-tertiary);
        color: var(--text-muted);
        font-size: 11px;
        padding: 2px 6px;
        border-radius: 12px;
        font-weight: 500;
    }
    
    /* Dark theme drag styling */
    [data-theme="dark"] .admin-item.drag-over {
        border-top-color: var(--editor-primary);
    }
    
    [data-theme="dark"] .sort-indicator {
        background: var(--bg-primary);
    }
    
    .nav-center {
        display: none;
    }
    
    /* Mobile Sidebar - Improved with scrolling and browser UI accommodation */
    .sidebar {
        position: fixed;
        left: -280px;
        top: var(--header-height);
        height: calc(100vh - var(--header-height) - env(safe-area-inset-bottom)); /* Account for safe areas and browser UI */
        z-index: 1500;
        box-shadow: var(--shadow-lg);
        width: 280px;
        background: var(--bg-sidebar);
        display: flex;
        flex-direction: column;
    }
    
    .sidebar.open {
        left: 0;
        transform: translateX(0);
    }
    
    /* Simple scrollable sidebar content */
    .sidebar-content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 12px 0;
        padding-bottom: calc(100px + env(safe-area-inset-bottom)); /* Increased padding + safe area for modern phones */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        height: calc(100vh - var(--header-height) - env(safe-area-inset-bottom)); /* Account for safe areas and browser UI */
    }
    
    /* Hide original footer completely on mobile */
    .sidebar-footer {
        display: none !important;
    }
}

/* Additional mobile device targeting via JavaScript class */
.mobile-device .sidebar-footer {
    display: none !important;
}


/* Continue mobile styles */
@media screen and (max-width: 768px),
@media screen and (max-device-width: 768px),
@media screen and (max-width: 768px) and (orientation: portrait),
@media screen and (max-width: 768px) and (orientation: landscape),
@media (hover: none) and (pointer: coarse) {
    
    /* Mobile Accordion Menu Styling */
    .accordion-header {
        cursor: pointer;
        user-select: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-radius: 8px;
        transition: background-color 0.2s ease;
    }
    
    .accordion-header:hover {
        background: var(--hover-bg);
    }
    
    
    
    
    
    /* Remove highlighting on mobile menu items */
    .chat-item,
    .mobile-link,
    .mobile-section-header {
        -webkit-tap-highlight-color: transparent !important;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        outline: none !important;
    }
    
    /* Additional bottom clearance for different mobile browsers */
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        .sidebar-content {
            padding-bottom: calc(120px + env(safe-area-inset-bottom)) !important; /* Extra clearance for browsers with larger UI */
        }
    }
    

}

/* Desktop - Ensure accordion styles don't interfere with normal menu (exclude tablets) */
@media screen and (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    .accordion-header {
        cursor: default !important;
        padding: 20px !important;
    }
    
    .accordion-header:hover {
        background: none !important;
    }
    
    .accordion-icon {
        display: none !important;
    }
    
    .accordion-content {
        display: block !important;
    }
    
    .accordion-section[data-section-id="quick-links"],
    .accordion-section[data-section-id="settings"] {
        display: none !important;
    }
    
    /* Restore highlighting behavior on desktop */
    .chat-item:hover,
    .quick-link:hover,
    .accordion-header:hover {
        background: var(--hover-bg) !important;
    }
    
    /* Restore user selection on desktop */
    .chat-item,
    .quick-link,
    .accordion-header {
        -webkit-user-select: text;
        user-select: text;
    }
}

/* Continue mobile styles - Enhanced mobile detection */
@media screen and (max-width: 768px),
@media screen and (max-device-width: 768px),
@media screen and (max-width: 768px) and (orientation: portrait),
@media screen and (max-width: 768px) and (orientation: landscape),
@media (hover: none) and (pointer: coarse) {
    .main-content {
        margin-left: 0;
        height: calc(100vh - var(--header-height));
        overflow-y: auto;
        overflow-x: hidden;  /* Prevent horizontal scroll */
        max-width: 100vw;
    }
    
    .chat-container {
        width: 100%;
        max-width: 100%;
        padding: 0 16px;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow-x: hidden;  /* Prevent horizontal scroll */
        box-sizing: border-box;
    }
    
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;  /* Prevent horizontal scroll */
        padding-bottom: 100px; /* Extra space for fixed input */
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Mobile sidebar overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1400;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar.open + .sidebar-overlay,
    .sidebar.open ~ .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
    
    /* Improved mobile sections with reduced spacing */
    .sidebar-section {
        margin-bottom: 12px;
    }
    
    .section-header {
        padding: 8px 16px 4px 16px;
    }
    
    .section-header h4 {
        font-size: 13px;
        margin: 0;
    }
    
    .section-items {
        padding: 0 8px;
    }
    
    /* Reduce padding for Settings section items on mobile */
    [data-section-id="settings"] .section-items {
        padding: 0 8px 8px 8px;
    }
    
    [data-section-id="settings"] {
        margin-bottom: 8px;
    }
    
    .chat-item {
        padding: 8px 16px;
        margin: 1px 8px;
        border-radius: 6px;
        font-size: 13px;
        line-height: 1.3;
    }
    
    .chat-item i {
        font-size: 16px;
        margin-right: 12px;
        width: 20px;
        text-align: center;
    }
    
    /* Always show message actions on mobile */
    .message-actions {
        opacity: 1 !important;
        margin-top: 12px;
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .message-action-btn {
        flex: 1;
        min-width: 70px;
        justify-content: center;
        font-size: 11px;
        padding: 8px 10px;
    }
    
    .message-action-btn i {
        font-size: 12px;
    }
}

/* Mobile Portrait: Left-justify section headers (Prompt Library, Favorites, Settings) */
@media (max-width: 1180px) and (orientation: portrait) {
    .section-header {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 12px !important;
    }
    
    .section-header h4 {
        text-align: left !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .info-icon {
        flex: 0 0 auto !important;
        margin-left: auto !important;
    }
}

/* Mobile landscape mode - compact spacing to fit all content */
@media screen and (max-height: 500px) and (orientation: landscape),
       screen and (max-device-height: 500px) and (orientation: landscape) {
    
    /* Reduce all section spacing in landscape */
    .sidebar-section {
        margin-bottom: 4px !important;
    }
    
    [data-section-id="settings"] {
        margin-bottom: 2px !important;
    }
    
    .section-header {
        padding: 4px 12px 2px 12px !important;
    }
    
    .section-header h4 {
        font-size: 12px !important;
    }
    
    .section-items {
        padding: 0 4px !important;
    }
    
    [data-section-id="settings"] .section-items {
        padding: 0 4px 4px 4px !important;
    }
    
    .chat-item {
        padding: 6px 12px !important;
        margin: 0px 4px !important;
        font-size: 12px !important;
    }
    
    .chat-item i {
        font-size: 14px !important;
        margin-right: 8px !important;
    }
    
    /* Reduce footer profile card in landscape */
    .user-profile-card {
        padding: 6px 8px !important;
    }
    
    .profile-avatar {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        font-size: 14px !important;
    }
    
    .profile-name {
        font-size: 12px !important;
    }
    
    .profile-subtitle {
        font-size: 10px !important;
    }
    
    .profile-dropdown-trigger {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }
    
    /* Ensure sidebar content fits in landscape */
    .sidebar-content {
        padding: 4px 0 !important;
    }
}

/* Extra small mobile devices (phones) */
@media (max-width: 480px) {
    /* App title for phones - larger since it's shorter */
    .app-title {
        font-size: 14px !important;
        font-weight: 600;
        max-width: 120px;
    }
    
    /* Logo adjustments for phones */
    .logo {
        height: 28px;
        width: auto;
        object-fit: contain;
        max-height: 28px;
    }
    
    /* Sidebar adjustments for phones */
    .sidebar {
        width: 260px; /* Slightly narrower on phones */
    }
    
    .sidebar.open {
        left: 0;
    }
    
    
    
    /* Even more compact menu items for phones */
    .chat-item {
        padding: 6px 12px;
        margin: 0px 6px;
        font-size: 12px;
    }
    
    .section-header {
        padding: 6px 12px 2px 12px;
    }
    
    .section-header h4 {
        font-size: 12px;
    }
    
    /* Adjust sidebar content spacing for phones */
    .sidebar-content {
        padding: 8px 0; /* Reduced top/bottom padding */
    }
    
    /* Chat input adjustments for phones */
    .chat-input-container {
        padding: 8px 12px;
    }
    
    .chat-input-wrapper {
        padding: 10px;
        border-radius: 20px;
    }
    
    .send-button {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .send-button i {
        font-size: 14px;
    }
    
    /* Message adjustments for phones */
    .message {
        gap: 12px;
    }
    
    .message-avatar {
        width: 30px;
        height: 30px;
    }
    
    /* Generic message content sizing (applies to all messages) */
    .message-content {
        font-size: 14px;
    }
    
    /* User message padding for phones */
    .user-message .message-content {
        padding: 12px;
    }
    
    /* Assistant message - preserve bubble styling with adjusted padding */
    .assistant-message .message-content {
        padding: 12px !important;
        /* Explicitly preserve bubble styling on smallest screens */
        background: var(--bg-tertiary) !important;
        border-radius: 12px !important;
        margin-left: 8px !important;
        border-left: 3px solid var(--theme-primary-light) !important;
    }
    
    /* Dark theme assistant message bubble on phones */
    [data-theme="dark"] .assistant-message .message-content {
        background: var(--chat-assistant-bg) !important;
        border-left: 3px solid var(--theme-primary-light) !important;
    }
    
    /* Touch-friendly interactions */
    .chat-item {
        min-height: 44px; /* Apple's recommended touch target */
    }
    
    .footer-button {
        min-height: 44px;
    }
    
    /* Phone-specific message actions */
    .message-actions {
        opacity: 1 !important;
        margin-top: 10px;
        gap: 4px;
    }
    
    .message-action-btn {
        min-height: 36px;
        padding: 6px 8px;
        font-size: 10px;
        min-width: 60px;
        flex: 1;
    }
    
    .message-action-btn i {
        font-size: 11px;
    }
    
    /* Welcome message dismiss button - compact, left-aligned with chat bubble */
    .welcome-message .message-actions {
        justify-content: flex-start;
    }
    
    .welcome-message .message-action-btn {
        flex: 0 0 auto;
        min-width: 85px;
        max-width: 110px;
        padding: 7px 14px;
        font-size: 11px;
    }
    
    /* Mobile diagram adjustments */
    .diagram-section {
        margin: 12px 0;
        padding: 12px;
    }
    
    .diagram-container {
        padding: 16px;
        min-height: 250px; /* Larger for mobile readability */
    }
    
    /* Mobile diagram text improvements */
    .mermaid-diagram svg text {
        font-size: 12px !important;
    }
    
    .mermaid-diagram svg .node text {
        font-size: 12px !important;
        font-weight: 600 !important;
    }
    
    .diagram-title {
        font-size: 16px;
    }
    
    .diagram-description {
        font-size: 13px;
    }
    
    .mermaid-diagram svg {
        max-width: 100%;
        overflow: visible;
    }
}

/* Mobile-specific improvements for touch */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    /* This targets touch devices specifically */
    .chat-item:active {
        background: var(--hover-bg);
        transform: scale(0.98);
        transition: all 0.1s ease;
    }
    
    .footer-button:active {
        transform: scale(0.95);
        transition: all 0.1s ease;
    }
    
    .global-action-btn:active {
        transform: translateY(0) scale(0.95);
    }
    
    .message-action-btn:active {
        transform: scale(0.95);
        transition: all 0.1s ease;
    }
}

/* Collapsed Sidebar Styles */
.sidebar.collapsed .sidebar-header h3,
.sidebar.collapsed .section-header h4,
.sidebar.collapsed .chat-item span {
    display: none;
}

.sidebar.collapsed .chat-item {
    justify-content: center;
    padding-left: 20px;
    padding-right: 20px;
}

.sidebar.collapsed .section-header,
.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .remove-section,
.sidebar.collapsed .add-section-btn {
    display: none;
}

/* Footer button collapsed styles - applies to both <a> and <button> elements */
.sidebar.collapsed .footer-button {
    width: 40px;
    height: 40px;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0 auto 8px auto;
    text-align: center;
    display: flex;
}

.sidebar.collapsed .footer-button span {
    display: none;
}

.sidebar.collapsed .footer-button i {
    margin: 0;
    width: auto;
    text-align: center;
}

/* Collapsed sidebar: Show tooltips on hover for menu items (desktop only) */
.sidebar.collapsed .chat-item {
    position: relative;
}

.sidebar.collapsed .chat-item:hover::after {
    content: attr(title);
    position: fixed;
    left: calc(var(--sidebar-collapsed-width) + 12px);
    top: var(--tooltip-top, 50%);
    transform: translateY(-50%);
    background: var(--bg-dark);
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease forwards;
}

/* Tooltip arrow pointing left */
.sidebar.collapsed .chat-item:hover::before {
    content: '';
    position: fixed;
    left: var(--sidebar-collapsed-width);
    top: var(--tooltip-top, 50%);
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--bg-dark);
    pointer-events: none;
    z-index: 10001;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease forwards;
}

/* Dark theme tooltips */
[data-theme="dark"] .sidebar.collapsed .chat-item:hover::after {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

[data-theme="dark"] .sidebar.collapsed .chat-item:hover::before {
    border-right-color: var(--bg-tertiary);
}

/* Hide tooltips on mobile (sidebar expands, no need for tooltips) */
@media (max-width: 768px) {
    .sidebar.collapsed .chat-item:hover::after,
    .sidebar.collapsed .chat-item:hover::before {
        display: none !important;
    }
}

/* Scrollbar Styling */
.sidebar-content::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

/* Animation for smooth transitions */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: slideIn 0.3s ease;
}

/* Typing indicator styles */
.typing-container {
    display: flex;
    align-items: flex-start; /* Changed from center to flex-start for multi-line support */
    justify-content: space-between;
    padding: 12px 0;
    width: 100%;
    gap: 8px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    align-self: center; /* Vertically center when text wraps */
    flex-shrink: 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* Small phones - bubble styling */
@media (max-width: 480px) and (orientation: portrait) {
    /* CRITICAL: Force bubble styling in portrait mode (iPhone 16 Pro Max = 430px portrait) */
    .assistant-message .message-content {
        background: var(--bg-tertiary) !important;
        border-radius: 12px !important;
        padding: 16px !important;
        margin-left: 8px !important;
        border-left: 3px solid var(--theme-primary-light) !important;
        overflow-x: visible !important;
    }
    
    [data-theme="dark"] .assistant-message .message-content {
        background: var(--chat-assistant-bg) !important;
        border-left: 3px solid var(--theme-primary-light) !important;
    }
}

/* Stop button styling - uses customizable color */
.stop-button {
    background: var(--indicator-stop-button, #ef4444);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 10px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
    flex-shrink: 0;
    align-self: center; /* Vertically center when text wraps */
}

.stop-button:hover {
    background: #dc2626;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.stop-button:active {
    transform: scale(0.95);
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Loading progress bar (indeterminate animation) - uses customizable colors */
.loading-progress-bar {
    flex: 0 0 100px;
    height: 4px;
    background: var(--indicator-background-color, rgba(74, 144, 226, 0.2));
    border-radius: 2px;
    overflow: hidden;
    margin: 0 12px;
    align-self: center; /* Vertically center when text wraps */
}

.loading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--indicator-progress-color, #4A90E2), var(--indicator-progress-color, #5BA7F7));
    animation: indeterminate 1.5s infinite;
    border-radius: 2px;
}

@keyframes indeterminate {
    0% {
        transform: translateX(-100%);
        width: 30%;
    }
    50% {
        transform: translateX(50%);
        width: 50%;
    }
    100% {
        transform: translateX(200%);
        width: 30%;
    }
}

/* Loading message text */
.loading-message-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    margin: 0 12px;
    transition: opacity 0.3s ease;
    line-height: 1.4;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    align-self: center; /* Vertically center when single or multi-line */
}

/* Mobile responsiveness for loading messages */
@media (max-width: 768px) {
    .loading-progress-bar {
        flex: 0 0 50px; /* Slightly smaller on mobile */
        margin: 0 8px 0 8px;
        align-self: center; /* Center vertically when text wraps */
    }
    
    .loading-message-text {
        font-size: 12px;
        margin: 0 6px;
        /* Allow wrapping to 2-3 lines on mobile */
        max-height: 3.6em; /* ~3 lines at 1.4 line-height */
        overflow: hidden;
        white-space: normal; /* Override the nowrap from desktop */
    }
    
    .typing-container {
        gap: 6px;
        align-items: flex-start; /* Container aligns to top, children can override */
    }
    
    .typing-dots {
        /* Inherits align-self: center from base style */
    }
    
    .stop-button {
        /* Inherits align-self: center from base style */
    }
}

/* Focus states for accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* ========================================
   Collection Edit Modal Styles
   ======================================== */

/* Large modal for collection editing */
.modal-large {
    max-width: 900px;
    width: 90%;
}

/* Collection info section */
.collection-edit-info {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.collection-edit-info h5 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

/* Form row for side-by-side inputs */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Icon selector with preview */
.icon-selector-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.icon-preview {
    width: 45px;
    height: 45px;
    min-width: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: 6px;
    font-size: 22px;
    transition: all 0.2s ease;
}

.icon-preview i {
    color: var(--theme-primary-light);
}

.icon-selector-container select {
    flex: 1;
}

/* Collection documents section */
.collection-edit-documents {
    margin-top: 20px;
}

.collection-edit-documents h5 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

/* Documents table container with scrolling */
.collection-documents-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-primary);
}

.collection-documents-table-container::-webkit-scrollbar {
    width: 8px;
}

.collection-documents-table-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.collection-documents-table-container::-webkit-scrollbar-thumb {
    background: var(--theme-primary-light);
    border-radius: 4px;
}

.collection-documents-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--theme-primary-dark);
}

/* Reassign button in Documents tab - matches delete button size */
.reassign-btn {
    padding: 8px 16px;
    margin-right: 8px;
    background: var(--theme-primary-light);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 115px;
    justify-content: center;
}

.reassign-btn:hover {
    background: var(--theme-primary-dark);
    transform: translateY(-1px);
}

.reassign-btn i {
    font-size: 12px;
}

/* Match delete button size to reassign button */
.document-actions .delete-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 115px;
    justify-content: center;
}

.document-actions .delete-btn i {
    font-size: 12px;
}

/* Campaign modal tabs */
.campaign-modal-tabs {
    display: flex;
    gap: 10px;
    margin-top: 0;  /* Remove any top margin */
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 0;
    /* Sticky positioning - tabs stay at top while content scrolls */
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-primary);
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
    padding-top: 0;  /* Tight against header */
    transition: box-shadow 0.2s ease;
}

/* Add subtle shadow when scrolled (makes sticky effect more obvious) */
.campaign-modal-tabs.scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Dark theme sticky tabs */
[data-theme="dark"] .campaign-modal-tabs {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .campaign-modal-tabs.scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.campaign-tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.campaign-tab:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.campaign-tab.active {
    color: var(--theme-primary-light);
    border-bottom-color: var(--theme-primary-light);
    font-weight: 600;
}

.campaign-tab i {
    font-size: 14px;
}

.campaign-tab-content {
    display: none;
    padding: 20px;  /* Add padding so content doesn't touch edges */
}

.campaign-tab-content.active {
    display: block;
}

/* Targeting option radio labels */
.targeting-option {
    display: block;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.targeting-option:hover {
    border-color: var(--theme-primary-light);
    background: var(--bg-secondary);
}

.targeting-option input[type="radio"] {
    margin-right: 10px;
}

.targeting-option input[type="radio"]:checked + strong {
    color: var(--theme-primary-light);
}

/* Ensure z-index layering is correct */
#collectionEditModal {
    z-index: 12000 !important; /* Above admin modal (10000) */
}

#reassignDocumentModal {
    z-index: 11500 !important; /* Above admin modal, below collection edit */
}

#campaignEditModal {
    z-index: 12500 !important; /* Above collection edit */
}

#campaignDisplayModal {
    z-index: 14000 !important; /* Above everything */
}

/* Campaign Display Modal - Mobile Optimizations */
#campaignDisplayModal .modal-content {
    max-width: 600px;  /* Wider than default for campaign content */
}

/* Mobile Portrait - 85% viewport height */
@media (max-width: 768px) and (orientation: portrait) {
    #campaignDisplayModal .modal-content {
        width: 95%;
        max-width: none;
        max-height: 85vh;  /* 85% on portrait (conservative for URL bars) */
    }
    
    #campaignDisplayModal .modal-body {
        max-height: calc(85vh - 140px);  /* Viewport - header - footer */
    }
}

/* Mobile Landscape - 90% viewport height */
@media (max-width: 932px) and (orientation: landscape),
       (max-height: 500px) and (orientation: landscape) {
    #campaignDisplayModal .modal-content {
        width: 90%;
        max-width: 700px;
        max-height: 90vh;  /* 90% on landscape (use more vertical space) */
    }
    
    #campaignDisplayModal .modal-body {
        max-height: calc(90vh - 120px);  /* Reduced header/footer on landscape */
    }
    
    #campaignDisplayModal .modal-header,
    #campaignDisplayModal .modal-footer {
        padding: 12px 20px;  /* Reduce vertical padding on landscape */
    }
}

/* DQL Report Sortable Columns */
th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    position: relative;
}

th.sortable:hover {
    background: var(--hover-bg);
}

th.sortable.active {
    color: var(--theme-primary-light) !important;  /* Use light variant for visibility in both themes */
    font-weight: 600;
    background: rgba(74, 144, 226, 0.08);
}

th.sortable i {
    margin-left: 6px;
    font-size: 12px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

th.sortable.active i {
    opacity: 1;
    color: var(--theme-primary-light) !important;
}

.dql-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

@media (max-width: 768px) {
    .dql-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive adjustments for collection edit */
@media (max-width: 768px) {
    .modal-large {
        width: 95%;
        max-width: none;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .collection-documents-table-container {
        max-height: 300px;
    }
    
    .action-btn {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* ================================================
   TOKEN PICKER
   ================================================ */

.token-picker {
    position: fixed;
    width: 300px;
    max-height: 350px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 15000;
    overflow: hidden;
    animation: fadeInScale 0.15s ease-out;
}

[data-theme="dark"] .token-picker {
    background: rgba(26, 26, 26, 0.98);
    border-color: #333;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

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

.token-picker-search {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    outline: none;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.token-picker-search:focus {
    border-bottom-color: var(--theme-primary);
}

.token-picker-search::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.token-picker-list {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
}

.token-picker-list::-webkit-scrollbar {
    width: 6px;
}

.token-picker-list::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

.token-category {
    padding: 8px 12px 4px 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.token-category:first-child {
    margin-top: 0;
}

.token-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    color: var(--text-primary);
    transition: all 0.1s ease;
    user-select: none;
}

.token-item:hover {
    background: rgba(74, 144, 226, 0.1);
}

.token-item.selected {
    background: var(--theme-primary);
    color: white;
}

.token-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================
   Form Field Drag & Drop Accordion Styles
   ============================================ */

/* Drag handle hover effect */
.drag-handle {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Field card hover effect */
.form-field-card:hover .drag-handle {
    color: #4A90E2 !important;
}

/* Ghost element (preview while dragging) */
.field-ghost {
    opacity: 0.4 !important;
    background: #e3f2fd !important;
    border: 2px dashed #4A90E2 !important;
}

/* Element being dragged */
.field-drag {
    opacity: 0.8;
    transform: rotate(2deg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.25) !important;
}

/* Element when grabbed (before drag starts) */
.field-chosen {
    background: #ffffff !important;
    border-color: #4A90E2 !important;
}

/* Smooth transitions for field cards */
.form-field-card {
    transition: all 0.2s ease, max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Expanded field styling */
.form-field-card.expanded {
    border: 2px solid #4A90E2 !important;
}

.form-field-card.expanded .field-header {
    background: var(--bg-primary) !important;
    border-bottom: 1px solid var(--border-light);
}

/* Collapsed field hover */
.form-field-card:not(.expanded):hover {
    border-color: var(--border-medium) !important;
}

/* Chevron rotation */
.field-chevron {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-field-card.expanded .field-chevron {
    transform: rotate(180deg);
}

/* Field content collapse animation */
.field-content {
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
    overflow: hidden;
}

.form-field-card:not(.expanded) .field-content {
    max-height: 0 !important;
    padding: 0 !important;
}

/* Drop indicator line */
.sortable-drag {
    opacity: 0.6;
}

.sortable-ghost {
    opacity: 0.3;
    background: #e3f2fd;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .drag-handle {
        font-size: 20px;
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .field-header {
        min-height: 60px;
    }
}

/* ============================================
   API KEYS PANEL STYLES
   ============================================ */

.api-keys-panel {
    padding: 20px;
    color: var(--text-primary);
}

.api-keys-panel .panel-header h2 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-size: 24px;
}

.api-keys-panel .panel-header p {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.api-keys-panel .panel-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.api-keys-info .info-box {
    background: var(--bg-tertiary);
    border-left: 4px solid var(--theme-primary);
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 4px;
    color: var(--text-primary);
}

.api-keys-info .info-box i {
    margin-right: 8px;
    color: var(--theme-primary);
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 64px;
    color: var(--text-tertiary);
    margin-bottom: 20px;
    display: block;
}

.empty-state h3 {
    margin: 16px 0;
    color: var(--text-primary);
    font-size: 20px;
}

.empty-state p {
    margin-bottom: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.api-key-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.api-key-card.active {
    border-color: var(--theme-primary);
}

.api-key-card.revoked {
    opacity: 0.6;
    border-color: var(--border-light);
}

.key-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.key-title h3 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-size: 18px;
}

.key-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.key-status.status-active {
    background: #10b981;
    color: white;
}

.key-status.status-revoked {
    background: #ef4444;
    color: white;
}

.key-status.status-expired {
    background: #f59e0b;
    color: white;
}

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

.key-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.key-prefix {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: monospace;
    color: var(--text-primary);
}

.key-display {
    background: var(--bg-tertiary);
    padding: 6px 12px;
    border-radius: 4px;
    color: var(--theme-primary);
    font-weight: 600;
}

.key-hidden {
    color: var(--text-tertiary);
}

.key-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    gap: 12px;
    align-items: center;
}

.info-item i {
    color: var(--theme-primary);
    font-size: 18px;
}

.info-item small {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
}

.info-item strong {
    display: block;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.key-permissions strong,
.key-ip-whitelist strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.permission-tags,
.ip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.permission-tag {
    background: var(--theme-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.permission-tag.none {
    background: var(--text-tertiary);
}

.ip-tag {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

.key-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* Badge styles for status indicators */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: #10b981;
    color: white;
}

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

.badge-warning {
    background: #f59e0b;
    color: white;
}

.badge-secondary {
    background: var(--text-tertiary);
    color: white;
}

/* Customer badge - pill style with theme-aware colors */
.customer-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 6px;
    white-space: nowrap;
    color: white;
}

/* Light theme - blue */
:root .customer-badge {
    background: #4A90E2;
}

/* Dark theme - green/teal */
[data-theme="dark"] .customer-badge {
    background: #10b981;
}

/* DQL badge - Discussion Qualified Lead - 2025-11-26 */
.dql-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 6px;
    white-space: nowrap;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    color: white;
    animation: dql-glow 2s ease-in-out infinite alternate;
}

@keyframes dql-glow {
    from { box-shadow: 0 0 3px rgba(245, 158, 11, 0.3); }
    to { box-shadow: 0 0 8px rgba(245, 158, 11, 0.6); }
}


/* ==============================================
   CRM SYNC PANEL STYLES
   ============================================== */

.connections-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
}

.connection-provider {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

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

.section-header h6 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-actions {
    display: flex;
    gap: 10px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

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

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.empty-state-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 30px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--border-dark);
}

.btn-icon.btn-danger:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #ef4444;
}

.connection-details {
    display: grid;
    gap: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.detail-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.detail-value {
    font-size: 14px;
    color: var(--text-primary);
}

.error-text {
    color: #ef4444;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.sync-logs-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 20px;
    min-height: 200px;
}

.status-success {
    background: #10b981;
}

.status-error {
    background: #ef4444;
}

.status-warning {
    background: #f59e0b;
}

.btn-primary {
    background: var(--brand-blue);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--brand-dark-blue);
}

.btn-primary i {
    margin-right: 6px;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-secondary i {
    margin-right: 6px;
}

/* CRM Sync Panel Responsive Scaling */
.connections-container table {
    width: 100%;
    table-layout: auto;
}

.connections-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1200px) {
    .connections-container table {
        font-size: 13px;
    }
    
    .action-buttons {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .connections-container {
        font-size: 12px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .section-actions {
        width: 100%;
    }
    
    .section-actions button {
        flex: 1;
    }
}

.crm-provider-content {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==============================================
   SEARCHABLE DROPDOWN COMPONENT
   ============================================== */

.searchable-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 38px;
}

.dropdown-trigger:hover {
    border-color: var(--border-dark);
    background: var(--bg-hover);
}

.dropdown-trigger.open {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.dropdown-display {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    font-size: 12px;
    color: var(--text-tertiary);
    transition: transform 0.2s;
}

.dropdown-trigger.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.dropdown-search {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    border-radius: 8px 8px 0 0;
}

.dropdown-search i {
    color: var(--text-tertiary);
    font-size: 14px;
}

.dropdown-search-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    color: var(--text-primary);
}

.dropdown-search-input::placeholder {
    color: var(--text-tertiary);
}

.dropdown-options {
    overflow-y: auto;
    max-height: 300px;
    padding: 4px;
}

.dropdown-options::-webkit-scrollbar {
    width: 8px;
}

.dropdown-options::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.dropdown-options::-webkit-scrollbar-thumb {
    background: var(--brand-blue);
    border-radius: 4px;
}

.dropdown-options::-webkit-scrollbar-thumb:hover {
    background: var(--brand-dark-blue);
}

.dropdown-group-label {
    padding: 8px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.dropdown-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
    font-size: 13px;
    color: var(--text-primary);
}

.dropdown-option:hover {
    background: var(--bg-hover);
}

.dropdown-option.selected {
    background: rgba(74, 144, 226, 0.1);
    color: var(--brand-blue);
    font-weight: 600;
}

.dropdown-option i {
    font-size: 12px;
    width: 16px;
    flex-shrink: 0;
}

.dropdown-option.selected i {
    color: var(--brand-blue);
}

.dropdown-option span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-hint {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.dropdown-hint i {
    color: var(--brand-blue);
}

.dropdown-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.dropdown-empty i {
    font-size: 32px;
    opacity: 0.3;
}

.dropdown-empty span {
    font-size: 13px;
}

/* ============================================
   AI SCORING PANEL STYLES
   ============================================ */

.scoring-panel-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.scoring-header {
    margin-bottom: 30px;
}

.scoring-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.scoring-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Dashboard Tiles */
.scoring-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.score-tile {
    background: var(--bg-primary);
    border: 2px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.score-tile.average-score {
    border-color: #4A90E2;
    background: linear-gradient(135deg, #fff 0%, #f0f7ff 100%);
}

.score-tile.hot-leads {
    border-color: #ff6b6b;
    background: linear-gradient(135deg, #fff 0%, #fff5f5 100%);
}

.score-tile.trending {
    border-color: #51cf66;
    background: linear-gradient(135deg, #fff 0%, #f3faf4 100%);
}

.score-tile.scored-visitors {
    border-color: #4A90E2;
    background: linear-gradient(135deg, #fff 0%, #f0f7ff 100%);
}

.tile-content {
    flex: 1;
}

.tile-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--text-primary);
    line-height: 1;
}

.tile-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.tile-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Scoring Section */
.scoring-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

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

.section-header h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin: 0;
}

/* Top Visitors List */
.top-visitors-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.visitor-score-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    transition: all 0.2s;
}

.visitor-score-card:hover {
    border-color: var(--theme-primary);
    box-shadow: var(--shadow-md);
}

.visitor-info {
    flex: 1;
}

.visitor-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.visitor-email {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.visitor-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.visitor-meta span {
    margin-right: 12px;
}

.visitor-score {
    display: flex;
    align-items: center;
    gap: 12px;
}

.score-badge {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 20px;
    min-width: 70px;
    text-align: center;
}

.score-badge.score-high {
    background: #d4edda;
    color: #155724;
}

.score-badge.score-medium {
    background: #fff3cd;
    color: #856404;
}

.score-badge.score-low {
    background: #f8d7da;
    color: #721c24;
}

.trend-up {
    color: #28a745;
    font-size: 12px;
    margin-left: 4px;
}

.trend-down {
    color: #dc3545;
    font-size: 12px;
    margin-left: 4px;
}

.trend-neutral {
    color: #6c757d;
    font-size: 12px;
    margin-left: 4px;
}

/* Configuration Section */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-item label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.config-item input[type="number"],
.config-item input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 14px;
}

.config-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.config-help {
    font-size: 12px;
    color: var(--text-muted);
}

.config-actions {
    display: flex;
    gap: 12px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state p {
    margin: 8px 0;
}

.help-text {
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================
   SCORE DETAIL MODAL STYLES
   ============================================ */

.score-modal {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

.score-summary {
    text-align: center;
    padding: 30px;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 30px;
}

.score-total {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 20px 40px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.score-total.score-high {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.score-total.score-medium {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    color: #856404;
}

.score-total.score-low {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

.score-value {
    font-size: 64px;
    font-weight: bold;
    line-height: 1;
}

.score-label {
    font-size: 32px;
    font-weight: 600;
    opacity: 0.7;
}

.confidence-badge {
    display: inline-block;
    padding: 6px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Score Breakdown */
.score-breakdown {
    margin-bottom: 30px;
}

.score-breakdown h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.breakdown-bar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.breakdown-item {
    display: grid;
    grid-template-columns: 120px 1fr 60px;
    gap: 12px;
    align-items: center;
}

.breakdown-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.breakdown-progress {
    background: var(--bg-secondary);
    border-radius: 8px;
    height: 24px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--theme-primary) 0%, var(--theme-primary-light) 100%);
    transition: width 0.3s ease;
}

.breakdown-item.engagement .progress-fill {
    background: linear-gradient(90deg, #4A90E2 0%, #5BA7F7 100%);
}

.breakdown-item.behavioral .progress-fill {
    background: linear-gradient(90deg, #51cf66 0%, #69db7c 100%);
}

.breakdown-item.firmographic .progress-fill {
    background: linear-gradient(90deg, #ff6b6b 0%, #ff8787 100%);
}

.breakdown-item.demographic .progress-fill {
    background: linear-gradient(90deg, #9775fa 0%, #b197fc 100%);
}

.breakdown-value {
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
    font-size: 14px;
}

/* LLM Analysis */
.llm-analysis {
    margin-bottom: 30px;
}

.llm-analysis h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.analysis-text {
    padding: 16px;
    background: var(--bg-secondary);
    border-left: 4px solid var(--theme-primary);
    border-radius: 6px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Intent Signals */
.intent-signals {
    margin-bottom: 30px;
}

.intent-signals h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.signals-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.signal-badge {
    padding: 6px 12px;
    background: var(--theme-primary);
    color: white;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

/* Key Factors */
.key-factors {
    margin-bottom: 30px;
}

.key-factors h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.factors-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.factors-list li {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--theme-primary);
    border-radius: 4px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.factors-list li:before {
    content: "✓";
    color: var(--theme-primary);
    font-weight: bold;
    margin-right: 8px;
}

/* Score History */
.score-history {
    margin-bottom: 30px;
}

.score-history h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-entry {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.history-date {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 100px;
}

.history-score {
    font-weight: 600;
    color: var(--text-primary);
}

.history-change {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.history-change.positive {
    color: #28a745;
    background: #d4edda;
}

.history-change.negative {
    color: #dc3545;
    background: #f8d7da;
}

/* Recent Activities */
.recent-activities {
    margin-bottom: 30px;
}

.recent-activities h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

/* Dark Theme Overrides */
[data-theme="dark"] .score-tile {
    background: var(--bg-secondary);
}

[data-theme="dark"] .score-tile.average-score {
    background: linear-gradient(135deg, #1a1a1a 0%, #1a2430 100%);
    border-color: #5BA7F7;
}

[data-theme="dark"] .score-tile.hot-leads {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a1f1f 100%);
    border-color: #ff6b6b;
}

[data-theme="dark"] .score-tile.trending {
    background: linear-gradient(135deg, #1a1a1a 0%, #1f2a1f 100%);
    border-color: #51cf66;
}

[data-theme="dark"] .score-tile.scored-visitors {
    background: linear-gradient(135deg, #1a1a1a 0%, #1a2430 100%);
    border-color: #5BA7F7;
}

[data-theme="dark"] .visitor-score-card {
    background: var(--bg-secondary);
}

[data-theme="dark"] .score-badge.score-high {
    background: #1e3a2e;
    color: #90ee90;
}

[data-theme="dark"] .score-badge.score-medium {
    background: #3a3a1e;
    color: #ffd700;
}

[data-theme="dark"] .score-badge.score-low {
    background: #3a1e1e;
    color: #ff6b6b;
}

[data-theme="dark"] .analysis-text,
[data-theme="dark"] .factors-list li,
[data-theme="dark"] .history-entry {
    background: var(--bg-tertiary);
}

/* Activity Timeline Styles */
.activities-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--theme-primary);
    border-radius: 6px;
}

.activity-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-primary);
    color: white;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-description {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.activity-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 12px;
}

.activity-time {
    color: var(--text-muted);
}

.activity-impact {
    color: var(--theme-primary);
    font-weight: 600;
    padding: 2px 8px;
    background: rgba(74, 144, 226, 0.1);
    border-radius: 4px;
}

.history-reason {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
}

/* Dark theme */
[data-theme="dark"] .activity-item {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .activity-impact {
    background: rgba(91, 167, 247, 0.2);
}

/* AI Score Slider Styles */
.ai-score-slider {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: var(--border-light);
    border-radius: 5px;
    outline: none;
}

.ai-score-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--theme-primary);
    cursor: not-allowed;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ai-score-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--theme-primary);
    cursor: not-allowed;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ai-score-slider::-webkit-slider-track {
    background: linear-gradient(to right, 
        #dc3545 0%, 
        #ffc107 40%, 
        #28a745 70%);
    border-radius: 5px;
}

.ai-score-slider::-moz-range-track {
    background: linear-gradient(to right, 
        #dc3545 0%, 
        #ffc107 40%, 
        #28a745 70%);
    border-radius: 5px;
}

/* ============================================================================
   LEGAL PANEL STYLES
   ============================================================================ */

/* Legal Panel Container */
.legal-panel-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.legal-panel-header {
    margin-bottom: 30px;
}

.legal-panel-header h2 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
}

.legal-panel-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Document Tabs */
.legal-document-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.legal-tab-button {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.legal-tab-button:hover {
    color: var(--theme-primary);
    background: var(--bg-secondary);
}

.legal-tab-button.active {
    color: var(--theme-primary);
    border-bottom-color: var(--theme-primary);
}

/* Document Editor */
.legal-document-editor {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 30px;
}

.legal-editor-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Settings Section */
.legal-settings-section {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.legal-settings-section h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--text-primary);
}

.legal-settings-row {
    display: flex;
    gap: 30px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.legal-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
}

.legal-checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

.legal-input-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.legal-number-input {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

/* Content Section */
.legal-content-section h3 {
    margin: 0 0 20px 0;
    font-size: 16px;
    color: var(--text-primary);
}

.legal-input-group {
    margin-bottom: 20px;
}

.legal-input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.legal-title-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-light);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: border-color 0.2s;
}

.legal-title-input:focus {
    outline: none;
    border-color: var(--theme-primary);
}

.legal-textarea-container {
    position: relative;
}

.legal-content-textarea {
    width: 100%;
    min-height: 400px;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    resize: vertical;
    transition: border-color 0.2s;
}

.legal-content-textarea:focus {
    outline: none;
    border-color: var(--theme-primary);
}

.legal-number-input {
    width: 80px;
    padding: 6px 10px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
}

.legal-number-input:focus {
    outline: none;
    border-color: var(--theme-primary);
}

.legal-textarea-help {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
}

.legal-help-text {
    color: var(--text-secondary);
}

.legal-help-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
}

.legal-char-count {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Translations Section */
.legal-translations-section h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--text-primary);
}

.legal-translations-info {
    margin-bottom: 15px;
}

.legal-no-translations {
    color: var(--text-secondary);
    font-style: italic;
    margin: 10px 0;
}

.legal-translations-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.legal-translation-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.legal-translation-lang {
    font-weight: 600;
    color: var(--theme-primary);
    min-width: 150px;
}

.legal-translation-title {
    flex: 1;
    color: var(--text-primary);
}

.legal-btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.legal-btn-icon:hover {
    opacity: 1;
}

/* Statistics Section */
.legal-stats-section h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--text-primary);
}

.legal-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.legal-stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.legal-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legal-stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.legal-status-active {
    color: #10b981;
}

.legal-status-inactive {
    color: #ef4444;
}

/* Action Buttons */
.legal-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.legal-actions-right {
    display: flex;
    gap: 10px;
}

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

.legal-btn-primary {
    background: var(--theme-primary);
    color: white;
}

.legal-btn-primary:hover {
    background: var(--theme-primary-dark);
}

.legal-btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.legal-btn-secondary:hover {
    background: var(--bg-tertiary);
}

/* Unsaved Changes Warning */
.legal-unsaved-warning {
    padding: 12px 16px;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 6px;
    color: #92400e;
    font-size: 14px;
    font-weight: 500;
    margin-top: 15px;
}

/* Select Input */
.legal-select-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
}

/* Translation Help */
.legal-translation-help {
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-top: 15px;
}

.legal-translation-help p {
    margin: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Loading State */
.legal-document-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

/* Dark Theme Support */
[data-theme="dark"] .legal-panel-container {
    color: var(--text-primary);
}

[data-theme="dark"] .legal-content-textarea,
[data-theme="dark"] .legal-title-input,
[data-theme="dark"] .legal-number-input,
[data-theme="dark"] .legal-select-input {
    background: var(--bg-dark);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .legal-settings-section,
[data-theme="dark"] .legal-translation-item {
    background: var(--bg-secondary);
}

[data-theme="dark"] .legal-unsaved-warning {
    background: #78350f;
    border-color: #b45309;
    color: #fef3c7;
}

/* Responsive Design */
@media (max-width: 768px) {
    .legal-panel-container {
        padding: 15px;
    }
    
    .legal-document-tabs {
        flex-wrap: wrap;
    }
    
    .legal-tab-button {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .legal-document-editor {
        padding: 20px;
    }
    
    .legal-settings-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .legal-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .legal-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .legal-actions-right {
        width: 100%;
    }
    
    .legal-btn {
        width: 100%;
    }
}

/* Token Modal Styles */
.legal-btn-link {
    background: none;
    border: none;
    color: var(--theme-primary);
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    font-size: inherit;
}

.legal-btn-link:hover {
    color: var(--theme-primary-dark);
}

.token-category {
    margin-bottom: 30px;
}

.token-category h4 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.token-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.token-table thead {
    background: var(--bg-secondary);
}

.token-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.token-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.token-table tr:last-child td {
    border-bottom: none;
}

.token-table code {
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    color: var(--theme-primary);
}

.token-example {
    color: var(--text-secondary);
    font-style: italic;
}

.legal-btn-copy {
    background: none;
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.legal-btn-copy:hover {
    background: var(--bg-secondary);
    border-color: var(--theme-primary);
}

.modal-description {
    margin: 0 0 20px 0;
    padding: 15px;
    background: var(--bg-secondary);
    border-left: 4px solid var(--theme-primary);
    border-radius: 4px;
    color: var(--text-primary);
}

/* Dark theme support for token modal */
[data-theme="dark"] .token-table {
    background: var(--bg-dark);
}

[data-theme="dark"] .token-table th,
[data-theme="dark"] .token-table td {
    color: var(--text-primary);
}

[data-theme="dark"] .token-table code {
    background: var(--bg-tertiary);
    color: var(--theme-primary-light);
}

/* ============================================================================
   LEGAL DOCUMENT VIEWER MODAL STYLES
   ============================================================================ */

.legal-viewer-overlay {
    z-index: 100000 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
}

.legal-viewer-modal {
    pointer-events: auto !important;
}

.legal-viewer-modal {
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    z-index: 100001 !important;
    position: relative !important;
    background: var(--bg-primary) !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
}

.legal-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid var(--border-color);
}

.legal-viewer-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legal-viewer-icon {
    font-size: 24px;
}

.legal-viewer-title h3 {
    margin: 0;
    font-size: 20px;
    color: var(--text-primary);
}

.legal-viewer-meta {
    display: flex;
    align-items: center;
    gap: 20px;
}

.legal-viewer-language {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legal-viewer-language label {
    font-size: 14px;
    color: var(--text-secondary);
}

.legal-viewer-select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
}

.legal-viewer-version {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 10px;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.legal-viewer-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    max-height: calc(85vh - 180px);
}

.legal-viewer-content {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
    color: var(--text-primary);
    font-size: 15px;
}

.legal-viewer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-top: 2px solid var(--border-color);
    gap: 20px;
}

.legal-viewer-footer-left {
    flex: 1;
}

.legal-viewer-footer-right {
    display: flex;
    gap: 10px;
}

.legal-acknowledgement-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

.legal-acknowledgement-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.legal-viewer-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.legal-viewer-btn-primary {
    background: var(--theme-primary);
    color: white;
}

.legal-viewer-btn-primary:hover:not(:disabled) {
    background: var(--theme-primary-dark);
}

.legal-viewer-btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.legal-viewer-btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.legal-viewer-btn-secondary:hover {
    background: var(--bg-tertiary);
}

/* Dark theme support */
[data-theme="dark"] .legal-viewer-modal {
    background: var(--bg-dark);
}

[data-theme="dark"] .legal-viewer-content {
    color: var(--text-primary);
}

[data-theme="dark"] .legal-viewer-select {
    background: var(--bg-dark);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Responsive design */
@media (max-width: 768px) {
    .legal-viewer-modal {
        max-width: 95vw;
        max-height: 90vh;
    }
    
    .legal-viewer-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .legal-viewer-meta {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .legal-viewer-body {
        padding: 20px;
    }
    
    .legal-viewer-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    .legal-viewer-footer-right {
        width: 100%;
        flex-direction: column;
    }
    
    .legal-viewer-btn {
        width: 100%;
    }
}

/* ============================================================================
   LEGAL FOOTER COMPONENT STYLES (For Forms)
   ============================================================================ */

.legal-footer-container {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.legal-footer-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 10px;
}

.legal-link {
    color: var(--theme-primary);
    text-decoration: none;
    font-weight: 500;
}

.legal-link:hover {
    text-decoration: underline;
}

.legal-footer-checkbox {
    margin-top: 8px;
}

.legal-footer-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
}

.legal-footer-checkbox-label input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.legal-footer-checkbox-label span {
    line-height: 1.5;
}

/* Dark theme support */
[data-theme="dark"] .legal-footer-text {
    color: var(--text-secondary);
}

[data-theme="dark"] .legal-link {
    color: var(--theme-primary-light);
}

[data-theme="dark"] .legal-footer-checkbox-label {
    color: var(--text-primary);
}

/* Form integration helpers */
.form-with-legal-footer {
    display: flex;
    flex-direction: column;
}

.form-with-legal-footer .legal-footer-container {
    order: 999; /* Ensure footer appears at bottom */
}

/* Submit button styling when disabled by legal footer */
button[disabled].legal-disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* ============================================================================
   LEGAL PANEL LIGHT THEME IMPROVEMENTS
   ============================================================================ */

/* Legal Panel with better contrast */
.legal-panel-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.legal-settings-section,
.legal-content-section,
.legal-translations-section,
.legal-stats-section {
    background: var(--bg-primary);
    border: 2px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

/* Subtle background tints for section distinction */
.legal-settings-section {
    background: var(--bg-secondary);
}

.legal-content-section {
    background: var(--bg-primary);
    border-color: #e0e7ff;
}

.legal-translations-section {
    background: var(--bg-secondary);
}

.legal-stats-section {
    background: var(--bg-primary);
    border-color: #fef3c7;
}

.legal-settings-section h3,
.legal-content-section h3,
.legal-translations-section h3,
.legal-stats-section h3 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 12px;
}

/* Dark theme */
[data-theme="dark"] .legal-settings-section,
[data-theme="dark"] .legal-content-section,
[data-theme="dark"] .legal-translations-section,
[data-theme="dark"] .legal-stats-section {
    background: var(--bg-secondary);
    border-color: var(--border-medium);
}

/* Token Autocomplete Dropdown */
.token-autocomplete-dropdown {
    position: absolute;
    background: white;
    border: 2px solid #3b82f6;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-height: 300px;
    overflow-y: auto;
    min-width: 400px;
}

.token-autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.15s;
}

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

.token-autocomplete-item:hover {
    background: #eff6ff;
}

.token-autocomplete-item code {
    color: #1e40af;
    font-weight: 600;
    font-size: 13px;
}

.token-autocomplete-item .token-desc {
    color: #6b7280;
    font-size: 12px;
    font-style: italic;
}

/* Dark theme autocomplete */
[data-theme="dark"] .token-autocomplete-dropdown {
    background: #1f2937;
    border-color: #3b82f6;
}

[data-theme="dark"] .token-autocomplete-item {
    border-bottom-color: #374151;
}

[data-theme="dark"] .token-autocomplete-item:hover {
    background: #374151;
}

[data-theme="dark"] .token-autocomplete-item code {
    color: #60a5fa;
}

[data-theme="dark"] .token-autocomplete-item .token-desc {
    color: #9ca3af;
}

/* Legal Translation Modal - High z-index to appear over admin panel */
#translation-modal-overlay {
    z-index: 100000 !important;
}

#tokens-modal-overlay {
    z-index: 100000 !important;
}

/* Ensure modal dialogs inside these overlays are also high */
#translation-modal-overlay .modal-dialog,
#tokens-modal-overlay .modal-dialog {
    z-index: 100001 !important;
    position: relative;
}

/* ============================================ */
/* GPTWeb Logo Theme Awareness */
/* ============================================ */

/* Light theme: Show light logo, hide dark logo */
:root .light-theme-only,
[data-theme="light"] .light-theme-only {
    display: inline-block;
}

:root .dark-theme-only,
[data-theme="light"] .dark-theme-only {
    display: none;
}

/* Dark theme: Hide light logo, show dark logo */
[data-theme="dark"] .light-theme-only {
    display: none;
}

[data-theme="dark"] .dark-theme-only {
    display: inline-block;
}

/* Admin logo styling */
.admin-logo {
    height: 56px;
    width: auto;
    object-fit: contain;
    max-width: 300px;
}
