/* Omni Valve Support - Main Application Styles
   Color Scheme: Monochrome Greys + Dusty Dark Blue
*/

:root {
    /* Dusty Dark Blue */
    --blue-darkest: #1e2a3a;
    --blue-dark: #2d3e50;
    --blue-medium: #3d5167;
    --blue-light: #4a6278;
    --blue-muted: #5a7289;
    
    /* Monochrome Greys */
    --grey-900: #1a1a1a;
    --grey-800: #2d2d2d;
    --grey-700: #404040;
    --grey-600: #525252;
    --grey-500: #6b6b6b;
    --grey-400: #8a8a8a;
    --grey-300: #a3a3a3;
    --grey-200: #d4d4d4;
    --grey-100: #e8e8e8;
    --grey-50: #f5f5f5;
    
    /* Functional Colors */
    --bg-primary: #f0f0f0;
    --bg-card: #ffffff;
    --bg-chat: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #525252;
    --text-muted: #6b6b6b;
    --border-color: #d4d4d4;
    --border-light: #e8e8e8;
    
    /* Accent Colors */
    --accent-primary: #3d5167;
    --accent-hover: #2d3e50;
    --accent-light: rgba(61, 81, 103, 0.1);
    
    /* Status Colors (muted versions) */
    --success: #4a6355;
    --success-light: #e8f0eb;
    --danger: #8b4a4a;
    --danger-light: #f5e8e8;
}

/* ==================== DARK MODE ==================== */
[data-theme="dark"] {
    /* Dusty Dark Blue - adjusted for dark mode */
    --blue-darkest: #0d1520;
    --blue-dark: #1a2633;
    --blue-medium: #4a6a8a;
    --blue-light: #5a7a9a;
    --blue-muted: #6a8aaa;
    
    /* Monochrome Greys - inverted for dark mode */
    --grey-900: #f5f5f5;
    --grey-800: #e8e8e8;
    --grey-700: #d4d4d4;
    --grey-600: #a3a3a3;
    --grey-500: #8a8a8a;
    --grey-400: #6b6b6b;
    --grey-300: #525252;
    --grey-200: #404040;
    --grey-100: #2d2d2d;
    --grey-50: #1a1a1a;
    
    /* Functional Colors - dark mode */
    --bg-primary: #0f1419;
    --bg-card: #1a2028;
    --bg-chat: #12171d;
    --text-primary: #e8e8e8;
    --text-secondary: #a3a3a3;
    --text-muted: #8a8a8a;
    --border-color: #2d3a47;
    --border-light: #232d38;
    
    /* Accent Colors - dark mode */
    --accent-primary: #4a6a8a;
    --accent-hover: #5a7a9a;
    --accent-light: rgba(74, 106, 138, 0.2);
    
    /* Status Colors - dark mode */
    --success: #5a8a6a;
    --success-light: rgba(90, 138, 106, 0.15);
    --danger: #aa6a6a;
    --danger-light: rgba(170, 106, 106, 0.15);
}

/* Dark mode specific overrides */
[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #1a2633 0%, #0d1520 100%);
}

[data-theme="dark"] .app-container {
    box-shadow: 0 0 60px rgba(0,0,0,0.4);
}

[data-theme="dark"] .message-content {
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="dark"] .welcome-screen {
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

[data-theme="dark"] .data-table-container {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-theme="dark"] .login-container {
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

[data-theme="dark"] .login-body {
    background: linear-gradient(135deg, #1a2633 0%, #0d1520 100%);
}

[data-theme="dark"] .pdf-thumbnail-wrapper {
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] .pdf-thumbnail-wrapper:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

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

[data-theme="dark"] .chip {
    background: var(--grey-100);
    border-color: var(--border-color);
}

[data-theme="dark"] .chip:hover {
    background: var(--accent-light);
    border-color: var(--blue-medium);
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, var(--grey-100) 25%, var(--grey-200) 50%, var(--grey-100) 75%);
    background-size: 200% 100%;
}

/* Dark mode toggle button styles */
.theme-toggle {
    padding: 8px 14px;
    background: var(--grey-100);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
}

.theme-toggle:hover {
    background: var(--grey-200);
    transform: translateY(-1px);
}

.theme-toggle:active {
    transform: translateY(0);
}

[data-theme="dark"] .theme-toggle {
    background: var(--grey-200);
    border-color: var(--border-color);
}

[data-theme="dark"] .theme-toggle:hover {
    background: var(--grey-300);
}

/* Smooth transition for theme changes */
body,
.app-container,
.sidebar,
.main-content,
.chat-header,
.chat-messages,
.message-content,
.welcome-screen,
.data-table-container,
input,
textarea,
.chip,
.reset-btn,
.theme-toggle {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.app-container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-card);
    box-shadow: 0 0 60px rgba(0,0,0,0.08);
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 300px;
    background: linear-gradient(180deg, var(--blue-dark) 0%, var(--blue-darkest) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-light);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-logo {
    width: 50px;
    height: auto;
    flex-shrink: 0;
}

.sidebar-brand {
    flex: 1;
    min-width: 0;
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    color: white;
}

.sidebar-header p {
    font-size: 12px;
    color: var(--grey-400);
}

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

.category-section {
    margin-bottom: 32px;
    padding: 0 24px;
}

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

.category-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--grey-400);
}

.back-btn {
    font-size: 11px;
    padding: 4px 10px;
    background: rgba(61, 81, 103, 0.3);
    color: var(--grey-200);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-weight: 600;
}

.back-btn:hover {
    background: rgba(61, 81, 103, 0.5);
}

.category-item {
    padding: 10px 14px;
    margin-bottom: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color:#E1E1E1;
    border-left: 3px solid transparent;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-item:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: var(--grey-300);
}

.category-item.active {
    background: rgba(61, 81, 103, 0.4);
    border-left-color: var(--grey-200);
    color: white;
}

.product-row {
    padding: 8px 12px;
    margin-bottom: 3px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    font-size: 12px;
    color: var(--grey-300);
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-row:hover {
    background: rgba(255,255,255,0.08);
    border-left-color: var(--grey-300);
}

.product-row.selected {
    background: rgba(61, 81, 103, 0.3);
    border-left-color: var(--grey-200);
    color: white;
}

.product-row strong {
    display: block;
    font-size: 13px;
    color: white;
    margin-bottom: 3px;
}

.view-more-btn {
    margin: 8px 0 0 0;
    padding: 8px 12px;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 500;
    color: var(--grey-300);
    border: 1px solid rgba(255,255,255,0.15);
}

.view-more-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.25);
}

.loading-spinner {
    text-align: center;
    padding: 20px;
    color: var(--grey-400);
    font-size: 13px;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    min-width: 0; /* Prevent flex item from overflowing */
    overflow: hidden; /* Contain scrolling to chat-messages */
}

/* Chat Header */
.chat-header {
    padding: 24px 32px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.chat-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--blue-dark);
}

.filter-indicator {
    font-size: 13px;
    color: var(--blue-medium);
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
    padding: 4px 12px;
    background: var(--accent-light);
    border-radius: 12px;
    display: inline-block;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--success-light);
    border-radius: 20px;
    font-size: 13px;
    color: var(--success);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.reset-btn {
    padding: 8px 16px;
    background: var(--blue-light);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.reset-btn:hover {
    background: var(--grey-700);
    transform: translateY(-1px);
}

.reset-btn:active {
    transform: translateY(0);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== SMOOTH TRANSITIONS & ANIMATIONS ==================== */

/* Fade in animation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Slide up and fade in */
@keyframes slideUp {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Slide down and fade in */
@keyframes slideDown {
    from { 
        opacity: 0; 
        transform: translateY(-10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Scale in */
@keyframes scaleIn {
    from { 
        opacity: 0; 
        transform: scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* Fade out */
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Skeleton loading shimmer */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Typing dots bounce */
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Smooth content swap */
@keyframes contentSwap {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}

/* ==================== CHAT MESSAGES ==================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px;
    background: var(--bg-chat);
    min-height: 0; /* Critical for flexbox scrolling */
}

.welcome-screen {
    text-align: center;
    max-width: 600px;
    margin: 60px auto;
    padding: 40px;
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid var(--border-light);
    animation: scaleIn 0.4s ease-out;
}

.welcome-screen.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.8;
}

.welcome-screen h2 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--grey-600);
}

.welcome-screen p {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 24px;
}

.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--grey-50);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.feature-icon {
    opacity: 0.7;
}

.suggestion-chips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 24px;
    max-width: 500px;
}

.chip {
    padding: 12px 16px;
    background: var(--grey-50);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: left;
}

.chip:hover {
    background:#F8FAFD;
    border-color:#cccccc;
    color: var(--blue-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(61, 81, 103, 0.15);
}

.chip:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ==================== MESSAGES ==================== */
.message {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideUp 0.4s ease-out;
    animation-fill-mode: both;
}

/* Staggered message animation for multiple messages */
.message:nth-child(1) { animation-delay: 0s; }
.message:nth-child(2) { animation-delay: 0.05s; }
.message:nth-child(3) { animation-delay: 0.1s; }
.message:nth-child(4) { animation-delay: 0.15s; }
.message:nth-child(5) { animation-delay: 0.2s; }

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

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.avatar.user {
    background: var(--blue-dark);
    color: white;
}

.avatar.bot {
    background: var(--grey-600);
    color: white;
}

.message-author {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.message-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

.message-content {
    padding: 16px 20px;
    background: var(--bg-card);
    border-radius: 12px;
    line-height: 1.6;
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-left: 42px;
    max-width: calc(100vw - 400px);
    overflow: hidden;
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.message-content a {
    color: var(--blue-medium);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.message-content a:hover {
    border-bottom-color: var(--blue-medium);
}

.message.user .message-content {
    background: var(--blue-dark);
    color: white;
    border: none;
}

/* ==================== DATA TABLES ==================== */
.data-table-container {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin: 20px 0;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--border-light);
    animation: fadeIn 0.4s ease-out;
}

.data-table-container.loading {
    position: relative;
    min-height: 200px;
}

.data-table-container.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.data-table-scroll {
    overflow-x: auto !important;
    overflow-y: auto !important;
    width: 100%;
    display: block !important;
    max-width: 100%;
    max-height: 500px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    -webkit-overflow-scrolling: touch;
}

.data-table-scroll::-webkit-scrollbar {
    height: 20px;
    width: 12px;
    background: var(--grey-100);
}

.data-table-scroll::-webkit-scrollbar-thumb {
    background: var(--grey-400);
    border-radius: 6px;
}

.data-table-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--grey-500);
}

.data-table {
    width: auto;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: auto;
    display: table !important;
}

.data-table thead {
    background: var(--grey-100);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    min-width: 100px;
}

/* Sortable table headers */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 28px;
    transition: background 0.15s ease;
}

.data-table th.sortable:hover {
    background: var(--grey-200);
}

.data-table th.sortable .sort-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

.data-table th.sortable .sort-icon::before,
.data-table th.sortable .sort-icon::after {
    content: '';
    position: absolute;
    left: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
}

.data-table th.sortable .sort-icon::before {
    bottom: 2px;
    border-bottom: 5px solid var(--text-secondary);
}

.data-table th.sortable .sort-icon::after {
    top: 2px;
    border-top: 5px solid var(--text-secondary);
}

.data-table th.sortable:hover .sort-icon {
    opacity: 0.6;
}

.data-table th.sortable.sort-asc .sort-icon {
    opacity: 1;
}

.data-table th.sortable.sort-asc .sort-icon::before {
    border-bottom-color: var(--blue-medium);
}

.data-table th.sortable.sort-asc .sort-icon::after {
    opacity: 0.3;
}

.data-table th.sortable.sort-desc .sort-icon {
    opacity: 1;
}

.data-table th.sortable.sort-desc .sort-icon::after {
    border-top-color: var(--blue-medium);
}

.data-table th.sortable.sort-desc .sort-icon::before {
    opacity: 0.3;
}

/* Dark mode sortable */
[data-theme="dark"] .data-table th.sortable:hover {
    background: var(--grey-700);
}

[data-theme="dark"] .data-table th.sortable .sort-icon::before {
    border-bottom-color: var(--text-secondary);
}

[data-theme="dark"] .data-table th.sortable .sort-icon::after {
    border-top-color: var(--text-secondary);
}

[data-theme="dark"] .data-table th.sortable.sort-asc .sort-icon::before {
    border-bottom-color: var(--blue-light);
}

[data-theme="dark"] .data-table th.sortable.sort-desc .sort-icon::after {
    border-top-color: var(--blue-light);
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    white-space: nowrap;

}

/* Sticky first column */
.data-table th:first-child,
.data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
}

.data-table th:first-child {
    background: var(--grey-100);
}

.data-table td:first-child {
    background: var(--bg-primary, #ffffff);
}

.data-table tbody tr:hover td:first-child {
    background: var(--grey-50);
}

/* Dark mode sticky column - using !important to override */
[data-theme="dark"] .data-table thead,
[data-theme="dark"] .data-table thead th {
    background: #1e2a38 !important;
}

[data-theme="dark"] .data-table th:first-child {
    background: #1e2a38 !important;
}

[data-theme="dark"] .data-table td:first-child {
    background: var(--bg-card, #1a2028) !important;
}

[data-theme="dark"] .data-table tbody tr:hover td:first-child {
    background: var(--grey-700, #2d3a47) !important;
}

/* Add shadow to sticky column for visual separation */
.data-table th:first-child::after,
.data-table td:first-child::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    bottom: 0;
    width: 8px;
    background: linear-gradient(to right, rgba(0,0,0,0.08), transparent);
    pointer-events: none;
}

[data-theme="dark"] .data-table th:first-child::after,
[data-theme="dark"] .data-table td:first-child::after {
    background: linear-gradient(to right, rgba(0,0,0,0.3), transparent);
}

/* Ensure sticky header first cell is on top */
.data-table thead th:first-child {
    z-index: 15;
}

.data-table tbody tr:hover {
    background: var(--grey-50);
}

.data-table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.data-table-info {
    font-size: 13px;
    color: var(--text-muted);
}

.view-more-table-btn {
    padding: 8px 16px;
    background: var(--blue-dark);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.view-more-table-btn:hover:not(:disabled) {
    background: var(--blue-darkest);
    transform: translateY(-1px);
}

.view-more-table-btn:disabled {
    background: var(--grey-400);
    cursor: not-allowed;
}

/* ==================== PDF GALLERY ==================== */
.pdf-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    align-items: flex-start;
}

.pdf-gallery > * {
    animation: scaleIn 0.3s ease-out;
    animation-fill-mode: both;
}

.pdf-gallery > *:nth-child(1) { animation-delay: 0s; }
.pdf-gallery > *:nth-child(2) { animation-delay: 0.05s; }
.pdf-gallery > *:nth-child(3) { animation-delay: 0.1s; }
.pdf-gallery > *:nth-child(4) { animation-delay: 0.15s; }
.pdf-gallery > *:nth-child(5) { animation-delay: 0.2s; }
.pdf-gallery > *:nth-child(6) { animation-delay: 0.25s; }

.pdf-card {
    background: var(--grey-50);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pdf-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.pdf-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
    border-color: var(--blue-medium);
}

.pdf-thumbnail-wrapper {
    width: 100px;
    height: 150px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    position: relative;
}

.pdf-thumbnail {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.pdf-icon-placeholder {
    font-size: 48px;
    color: var(--grey-400);
}

.pdf-info {
    padding: 12px;
}

.pdf-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.pdf-download-btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--blue-dark);
    color: white !important;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    margin-right: 8px;
    margin-bottom: 8px;
}

.pdf-download-btn:hover {
    background: var(--blue-darkest);
    transform: translateY(-1px);
}

/* Download button wrapper with tooltip */
.download-btn-wrapper {
    position: relative;
    display: inline-block;
}

.download-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--grey-900);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 9999;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.download-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--grey-900);
}

.download-btn-wrapper:hover .download-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Dark mode tooltip */
[data-theme="dark"] .download-tooltip {
    background: var(--grey-200);
    color: var(--grey-900);
}

[data-theme="dark"] .download-tooltip::after {
    border-top-color: var(--grey-200);
}

/* Download buttons container */
.download-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ==================== LIGHTBOX ==================== */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 10px;
}

.lightbox.active {
    display: flex;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    z-index: 10000;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: var(--grey-400);
}

.lightbox-content {
    max-width: 95%;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.lightbox-info {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    border-radius: 6px;
    margin-top: 12px;
    text-align: center;
    max-width: 600px;
}

.lightbox-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 14px;
}

.lightbox-pages {
    font-size: 12px;
    color: var(--text-muted);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 48px;
    color: white;
    cursor: pointer;
    padding: 20px;
    transition: all 0.2s;
    user-select: none;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 8px;
    z-index: 1001;
}

.lightbox-nav:hover {
    color: white;
    background: rgba(0, 0, 0, 0.6);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    color: var(--grey-400);
    font-size: 13px;
    margin-top: 4px;
}

/* Mobile lightbox adjustments */
@media (max-width: 768px) {
    .lightbox-nav {
        font-size: 32px;
        padding: 12px;
        top: auto;
        bottom: 100px;
        transform: none;
        background: rgba(0, 0, 0, 0.5);
    }
    
    .lightbox-prev {
        left: 20%;
    }
    
    .lightbox-next {
        right: 20%;
    }
    
    .lightbox-content {
        padding: 10px;
    }
    
    .lightbox-info {
        padding: 12px;
    }
    
    .lightbox-title {
        font-size: 14px;
    }
    
    .lightbox-pages,
    .lightbox-counter {
        font-size: 12px;
    }
}

/* Touch device hint */
@media (hover: none) and (pointer: coarse) {
    .lightbox-nav {
        display: none;
    }
    
    .lightbox-counter::after {
        content: ' • Swipe to navigate';
        color: var(--grey-500);
    }
}

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator {
    display: none;
    padding: 16px 20px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-left: 42px;
    width: fit-content;
    border: 1px solid var(--border-light);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.typing-indicator.active {
    display: flex;
    gap: 6px;
    opacity: 1;
    transform: translateY(0);
    animation: slideUp 0.3s ease-out;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--blue-medium);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ==================== CHAT INPUT ==================== */
.chat-input-container {
    padding: 24px 32px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    flex-shrink: 0; /* Prevent input area from shrinking */
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: 900px;
    margin: 0 auto;
}

#messageInput {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    overflow-y: auto;
    transition: border-color 0.2s;
    background: var(--bg-card);
    color: var(--text-primary);
}

#messageInput:focus {
    outline: none;
    border-color: var(--blue-medium);
}

#messageInput::placeholder {
    color: var(--grey-400);
}

#sendButton {
    padding: 14px 24px;
    background: var(--blue-dark);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#sendButton:hover:not(:disabled) {
    background: var(--blue-darkest);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 62, 80, 0.3);
}

#sendButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==================== SCROLLBARS ==================== */
.sidebar-content::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

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

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--grey-100);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--grey-400);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--grey-500);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
    }
    
    .message-content {
        max-width: calc(100vw - 80px);
    }
}

@media (max-width: 600px) {
    .chat-header {
        padding: 16px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .chat-input-container {
        padding: 16px;
    }
    
    .welcome-screen {
        padding: 24px;
        margin: 20px auto;
    }
    
    .suggestion-chips {
        grid-template-columns: 1fr;
        max-width: 100%;
    }
    
    .pdf-thumbnail-wrapper {
        width: 80px;
        height: 120px;
    }
}

/* ==================== SPEC RESULTS STYLING ==================== */

.spec-results {
    background: linear-gradient(135deg, var(--grey-50) 0%, var(--bg-card) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin: 8px 0;
}

.spec-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.spec-icon {
    font-size: 28px;
    line-height: 1;
}

.spec-title-group {
    flex: 1;
}

.spec-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--blue-dark);
    margin: 0 0 4px 0;
}

.spec-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.spec-table-wrapper {
    overflow-x: auto;
    margin: 0 -8px;
    padding: 0 8px;
}

.spec-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.spec-table thead {

    background: var(--blue-dark);
    color: white;
}

.spec-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.spec-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    white-space: nowrap;
}

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

.spec-table tbody tr.even {
    background: var(--grey-50);
}

.spec-table tbody tr.odd {
    background: white;
}

.spec-table tbody tr:hover {
    background: var(--accent-light);
}

.spec-table td:first-child {
    font-weight: 600;
    color: var(--blue-dark);
}

.spec-note {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin: 12px 0 0 0;
    font-style: italic;
}

.spec-footer {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}

.spec-tip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--grey-100);
    padding: 8px 14px;
    border-radius: 6px;
}

.spec-tip strong {
    color: var(--blue-dark);
}

.spec-suggestions {
    margin-top: 16px;
    padding: 14px;
    background: var(--grey-50);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

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

.suggestions-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 2;
}

.suggestion-chip {
    display: inline-block;
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--blue-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 2px 4px 2px 0;
}

.suggestion-chip:hover {
    background: var(--blue-dark);
    color: white;
    border-color: var(--blue-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ==================== MOBILE RESPONSIVE ==================== */

/* Mobile Menu Toggle Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    background: var(--blue-dark);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

/* Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Tablet Styles (iPad, Surface, etc.) */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar {
        width: 220px;
        flex-shrink: 0;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    .sidebar-header {
        padding: 16px;
        flex-shrink: 0;
    }
    
    .sidebar-header h1 {
        font-size: 16px;
    }
    
    .sidebar-logo {
        width: 40px;
    }
    
    /* Make sidebar content scrollable */
    .sidebar-content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 12px 0;
        min-height: 0;
    }
    
    /* Compact sidebar items to fit more */
    .category-section {
        margin-bottom: 16px;
        padding: 0 12px;
    }
    
    .category-title {
        font-size: 10px;
        margin-bottom: 8px;
    }
    
    .category-item {
        padding: 8px 12px;
        font-size: 13px;
        margin-bottom: 2px;
    }
    
    .app-container {
        display: flex;
        flex-direction: row;
        height: 100vh;
        height: 100dvh;
    }
    
    .main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        margin-left: 0; /* No margin needed - using flexbox */
    }
    
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }
    
    .chat-input-container {
        flex-shrink: 0;
    }
    
    .chat-header {
        padding: 16px 20px;
        flex-shrink: 0;
    }
    
    .chat-header h2 {
        font-size: 16px;
    }
    
    .message-content {
        max-width: calc(100% - 50px);
    }
    
    /* Slightly smaller elements for tablet */
    .reset-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .theme-toggle {
        padding: 8px 12px;
        min-width: 40px;
    }
    
    .welcome-screen {
        margin: 40px auto;
        padding: 32px;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    /* Show mobile menu button */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Sidebar becomes a slide-out drawer */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    /* App container for mobile */
    .app-container {
        flex-direction: column;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }
    
    /* Main content takes full width and height */
    .main-content {
        margin-left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    /* Chat header adjustments */
    .chat-header {
        padding: 12px 16px 12px 60px; /* Space for hamburger */
        flex-wrap: wrap;
        gap: 8px;
        flex-shrink: 0; /* Prevent header from shrinking */
    }
    
    .chat-header h2 {
        font-size: 16px;
    }
    
    .chat-header-left {
        flex: 1;
        min-width: 0;
    }
    
    /* Header buttons */
    .reset-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .status-badge {
        display: none; /* Hide on very small screens */
    }
    
    /* Chat messages area - KEY FIX FOR SCROLLING */
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 16px;
        padding-bottom: 16px;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        overscroll-behavior: contain;
        min-height: 0; /* Important for flexbox scrolling */
    }
    
    /* Fixed input at bottom */
    .chat-input-container {
        flex-shrink: 0; /* Prevent input from shrinking */
        position: relative; /* Not fixed - part of flex layout */
        padding: 12px;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    .input-wrapper {
        gap: 8px;
    }
    
    .input-wrapper textarea {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 12px;
    }
    
    .input-wrapper button {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    /* Message bubbles */
    .message {
        max-width: 100%;
    }
    
    .message-content {
        padding: 12px;
        font-size: 14px;
        max-width: 100%;
        margin-left: 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Welcome screen */
    .welcome-screen {
        padding: 24px 16px;
        margin: 16px;
    }
    
    .welcome-screen h2 {
        font-size: 20px;
    }
    
    .welcome-screen p {
        font-size: 14px;
    }
    
    .suggestion-chips {
        flex-wrap: wrap;
    }
    
    .chip {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    /* Data tables */
    .data-table-container {
        margin: 12px -12px;
        border-radius: 0;
    }
    
    .data-table-scroll {
        max-height: 300px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 12px;
        min-width: 80px;
    }
    
    /* PDF Gallery */
    .pdf-gallery {
        gap: 6px;
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }
    
    .pdf-thumbnail-wrapper {
        width: 70px !important;
        height: 100px !important;
        flex-shrink: 0;
    }
    
    .pdf-thumbnail-wrapper img {
        width: 70px !important;
        height: 100px !important;
    }
    
    .pdf-download-btn {
        padding: 10px 14px;
        font-size: 12px;
        width: 100%;
        text-align: center;
        margin-bottom: 8px;
    }
    
    /* Sidebar content */
    .sidebar-header {
        padding: 16px;
        gap: 12px;
    }
    
    .sidebar-logo {
        width: 40px;
    }
    
    .sidebar-header h1 {
        font-size: 16px;
    }
    
    .sidebar-header p {
        font-size: 11px;
    }
    
    .category-item {
        padding: 14px 16px;
        font-size: 14px;
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    .category-title {
        font-size: 11px;
    }
    
    /* Lightbox */
    .lightbox-content {
        width: 98%;
        max-height: 95vh;
    }
    
    .lightbox-image {
        max-height: 82vh;
    }
    
    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
    
    /* Spec Results Mobile */
    .spec-results {
        padding: 16px;
        margin: 4px -8px;
        border-radius: 8px;
    }
    
    .spec-header {
        gap: 10px;
    }
    
    .spec-icon {
        font-size: 24px;
    }
    
    .spec-title {
        font-size: 16px;
    }
    
    .spec-table {
        font-size: 12px;
    }
    
    .spec-table th {
        padding: 10px 10px;
        font-size: 10px;
    }
    
    .spec-table td {
        padding: 8px 10px;
    }
    
    .spec-footer {
        margin-top: 12px;
        padding-top: 12px;
    }
    
    .spec-tip {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .spec-suggestions {
        margin-top: 12px;
        padding: 12px;
    }
    
    .suggestions-label {
        font-size: 11px;
        margin-bottom: 8px;
    }
    
    .suggestions-content {
        font-size: 12px;
    }
    
    .suggestion-chip {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* ==================== SKELETON LOADERS ==================== */
.skeleton {
    background: linear-gradient(90deg, var(--grey-100) 25%, var(--grey-50) 50%, var(--grey-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 100%;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

.skeleton-title {
    height: 20px;
    width: 40%;
    margin-bottom: 16px;
}

.skeleton-thumbnail {
    width: 100px;
    height: 150px;
    border-radius: 6px;
}

.skeleton-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

/* ==================== ANIMATION UTILITIES ==================== */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.4s ease-out;
}

.animate-slide-down {
    animation: slideDown 0.3s ease-out;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out;
}

.animate-fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

/* Content transition helper */
.content-transitioning {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Smooth scroll behavior */
.chat-messages {
    scroll-behavior: smooth;
}

/* Loading state for buttons */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Smooth category item transitions */
.category-item {
    transition: all 0.2s ease, background 0.15s ease, border-left-color 0.15s ease;
}

/* Smooth lightbox transitions */
.lightbox {
    transition: opacity 0.3s ease;
}

.lightbox.active {
    animation: fadeIn 0.3s ease-out;
}

.lightbox-content {
    transition: transform 0.3s ease;
}

.lightbox.active .lightbox-content {
    animation: scaleIn 0.3s ease-out;
}

/* Small phones */
@media (max-width: 400px) {
    .chat-header {
        padding: 10px 12px 10px 56px;
    }
    
    .reset-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .welcome-screen {
        padding: 20px 12px;
        margin: 12px;
    }
    
    .chip {
        padding: 8px 12px;
        font-size: 12px;
        flex: 1 1 45%;
    }
    
    .message-header {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .message-author {
        font-size: 12px;
    }
    
    .message-time {
        font-size: 10px;
    }
    
    .avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .category-item {
        min-height: 48px;
        padding: 14px 16px;
    }
    
    .chip {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .reset-btn {
        min-height: 40px;
    }
    
    .input-wrapper button {
        min-height: 44px;
        min-width: 70px;
    }
    
    /* Remove hover effects on touch devices */
    .category-item:hover {
        transform: none;
    }
    
    .chip:hover {
        transform: none;
    }
    
    /* Add active states instead */
    .category-item:active {
        background: rgba(255,255,255,0.15);
    }
    
    .chip:active {
        transform: scale(0.98);
        background: var(--grey-200);
    }
    
    .reset-btn:active {
        transform: scale(0.98);
    }
}

/* Sidebar Sub-items (nested document links) */
.category-item.sub-item {
    padding-left: 28px;
    font-size: 12px;
    background: rgba(255,255,255,0.02);
    border-left-color: rgba(255,255,255,0.1);
    color: var(--grey-300);
    margin-top: -2px;
}

.category-item.sub-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

/* PDF Document Display */
.pdf-doc-display {
    padding: 8px 0;
}

.pdf-doc-display h3 {
    font-size: 18px;
    font-weight: 600;
}

.pdf-doc-display .pdf-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.pdf-doc-display .pdf-thumbnail-wrapper {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.pdf-doc-display .pdf-thumbnail-wrapper:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    .pdf-doc-display .pdf-thumbnail-wrapper {
        width: 80px !important;
    }
    
    .pdf-doc-display .pdf-thumbnail-wrapper img {
        width: 80px !important;
        height: 120px !important;
    }
    
    .pdf-doc-display h3 {
        font-size: 16px;
    }
    
    .category-item.sub-item {
        padding-left: 24px;
        font-size: 12px;
        min-height: 40px;
    }
}

/* Login page mobile */
@media (max-width: 480px) {
    .login-container {
        padding: 32px 20px;
        margin: 16px;
        border-radius: 12px;
    }
    
    .login-logo {
        max-width: 140px;
        margin-bottom: 20px;
    }
    
    .login-icon {
        font-size: 40px;
    }
    
    .login-title {
        font-size: 20px;
    }
    
    .login-form .form-input {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 14px;
    }
    
    .login-btn {
        padding: 14px;
        font-size: 16px;
    }
}
.login-body {
    background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-darkest) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 48px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.login-logo {
    max-width: 180px;
    height: auto;
    margin-bottom: 24px;
}

.login-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--blue-dark);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.login-form .form-group {
    margin-bottom: 24px;
    text-align: left;
}

.login-form .form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.login-form .form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
    background: var(--bg-card);
    color: var(--text-primary);
}

.login-form .form-input:focus {
    outline: none;
    border-color: var(--blue-medium);
}

.login-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--blue-dark);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover {
    background: var(--blue-darkest);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 62, 80, 0.3);
}

.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 24px;
}

.login-footer {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 480px) {
    .login-container {
        padding: 32px 24px;
    }
}
/* 
 * Dark Mode Table Fix
 * Fixes alternating row text visibility in dark mode
 * Add this to your app.css file
 */

/* Ensure all table text is visible in dark mode */
[data-theme="dark"] .data-table tbody tr {
    color: var(--text-primary, #e4e4e7);
}

[data-theme="dark"] .data-table tbody tr td {
    color: var(--text-primary, #e4e4e7);
}

/* Alternating row backgrounds with proper text contrast */
[data-theme="dark"] .data-table tbody tr:nth-child(odd) {
    background-color: var(--bg-secondary, #293542);
    color: var(--text-primary, #e4e4e7);
}

[data-theme="dark"] .data-table tbody tr:nth-child(even) {
    background-color: var(--bg-tertiary, #2C3847);
    color: var(--text-primary, #e4e4e7);
}

/* Ensure hover states also have visible text */
[data-theme="dark"] .data-table tbody tr:hover {

    background-color: var(--bg-hover, #324055);
    color: var(--text-primary, #e4e4e7);
}

[data-theme="dark"] .data-table tbody tr:hover td {
    color: var(--text-primary, #e4e4e7);
}

/* Table header styling for dark mode */
[data-theme="dark"] .data-table thead th {
    background-color: var(--bg-tertiary, #48505B);
    color: var(--text-primary, #e4e4e7);
    border-bottom: 1px solid var(--border-color, #3d4a57);
}

/* Table cell borders in dark mode */
[data-theme="dark"] .data-table td,
[data-theme="dark"] .data-table th {
    border-color: var(--border-color, #3d4a57);
}

/* Message content cards/tables in dark mode */
[data-theme="dark"] .message-content table {
    color: var(--text-primary, #e4e4e7);
}

[data-theme="dark"] .message-content table tr {
    color: var(--text-primary, #e4e4e7);
}

[data-theme="dark"] .message-content table td {
    color: var(--text-primary, #e4e4e7);
}

/* ============================================
   SPEC TABLE Dark Mode Fix (AI Response Tables)
   ============================================ */

[data-theme="dark"] .spec-table {
    background: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Spec table header */
[data-theme="dark"] .spec-table thead {
    background: var(--blue-medium);
}

/* Force all spec-table text to be visible */
[data-theme="dark"] .spec-table td {
    color: var(--text-primary) !important;
    border-bottom-color: var(--border-color);
}

/* Alternating rows - even (these use .even class explicitly) */
[data-theme="dark"] .spec-table tbody tr.even {
    background: #1a2634 !important;
}

[data-theme="dark"] .spec-table tbody tr.even td {
    color: var(--text-primary) !important;
}

/* Alternating rows - odd */
[data-theme="dark"] .spec-table tbody tr.odd {
    background: #0f1820 !important;
}

[data-theme="dark"] .spec-table tbody tr.odd td {
    color: var(--text-primary) !important;
}

/* First column styling in dark mode */
[data-theme="dark"] .spec-table td:first-child {
    color: var(--blue-light) !important;
}

/* Hover state */
[data-theme="dark"] .spec-table tbody tr:hover {
    background: #2a3a4a !important;
}

[data-theme="dark"] .spec-table tbody tr:hover td {
    color: var(--text-primary) !important;
}

/* Spec footer and notes */
[data-theme="dark"] .spec-note {
    color: var(--text-muted);
}

[data-theme="dark"] .spec-footer {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .spec-tip {
    color: var(--text-secondary);
}

/* Load More Button for spec tables */
.load-more-btn {
    display: inline-block;
    padding: 10px 24px;
    background: var(--blue-dark);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.load-more-btn:hover {
    background: var(--blue-medium);
    transform: translateY(-1px);
}

.load-more-btn:active {
    transform: translateY(0);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

[data-theme="dark"] .load-more-btn {
    background: var(--blue-medium);
}

[data-theme="dark"] .load-more-btn:hover {
    background: var(--blue-light);
}
/* ==================== EXPLODED VIEW GALLERY ==================== */

/* ==================== TRAINING IMAGES GALLERY ==================== */
.training-images-gallery {
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 10px;
    padding: 14px;
    margin: 12px 0;
}

.training-images-gallery .gallery-title {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.training-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.training-image-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

    transition: transform 0.2s ease, box-shadow 0.2s ease;
    aspect-ratio: auto;
}

.training-image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.training-image-item img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    background: #fff;
}

.training-image-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

/* Dark mode */
[data-theme="dark"] .training-images-gallery {
    background: var(--bg-card, #2a2a2a);
}

[data-theme="dark"] .training-image-item {
    background: var(--bg-primary, #1a1a1a);
}

[data-theme="dark"] .training-image-item img {
    background: var(--bg-primary, #1a1a1a);
}

/* Mobile responsive */
@media (max-width: 600px) {
    .training-images-grid {
        grid-template-columns: 1fr;
    }
    
    .training-images-gallery {
        padding: 10px;
    }
}

/* ==================== INSTRUCTION STEPS (Installation/Removal) ==================== */

/* ==================== CLICKABLE QUERY LINKS ==================== */
.query-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.query-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-chat);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--text-primary);
}

.query-link:hover {
    background: var(--accent-light);
    border-color: var(--blue-medium);
    transform: translateX(4px);
}

.query-link:active {
    transform: translateX(2px);
}

/* Dark mode */
[data-theme="dark"] .query-link {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .query-link:hover {
    background: var(--accent-light);
    border-color: var(--blue-light);
}

/* Mobile responsive */
@media (max-width: 600px) {
    .query-link {
        padding: 10px 14px;
        font-size: 13px;
    }
}

.instruction-steps {
    counter-reset: step-counter;
    list-style: none;
    padding: 0;
    margin: 8px 0 4px 0;
}

.instruction-steps li {
    counter-increment: step-counter;
    position: relative;
    padding: 6px 8px 6px 32px;


    margin-bottom: 2px;
    background: var(--bg-chat);
    border-radius: 4px;
    border-left: 2px solid var(--blue-medium);
    line-height: 1.3;
    font-size: 14px;
}

.instruction-steps li:last-child {
    margin-bottom: 0;
}

/* Reduce gap between instruction steps and following content */
.instruction-steps + br,
.bullet-list + br {
    display: none;
}

.instruction-steps + br + br,
.bullet-list + br + br {
    display: none;
}

/* Tighten spacing in message content after instruction lists */
.message-content .instruction-steps ~ br:first-of-type,
.message-content .bullet-list ~ br:first-of-type {
    line-height: 0.5;
}

.message-content .pdf-gallery {
    margin-top: 10px;
}

.instruction-steps li::before {
    content: counter(step-counter);
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background: var(--blue-medium);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 9.5px;
    padding: 2px;
}

.instruction-steps li strong {
    color: var(--blue-dark);
}

/* Dark mode instruction steps */
[data-theme="dark"] .instruction-steps li {
    background: var(--bg-card);
    border-left-color: var(--blue-light);
}

[data-theme="dark"] .instruction-steps li::before {
    background: var(--blue-light);
}

[data-theme="dark"] .instruction-steps li strong {
    color: var(--blue-muted);
}

/* Mobile responsive */
@media (max-width: 600px) {
    .instruction-steps li {
        padding: 2px 6px 2px 26px;
        font-size: 13px;
    }
    
    .instruction-steps li::before {
        width: 12px;
        height: 12px;
        font-size: 8px;
        left: 5px;
    }
}

/* ==================== BULLET LISTS (Non-procedural) ==================== */
.bullet-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 8px 0;
}

.bullet-list li {
    position: relative;
    padding: 8px 12px 8px 28px;
    margin-bottom: 1px;
    line-height: 1.5;
    color: var(--text-primary);
}

.bullet-list li::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 15px;
    width: 6px;
    height: 6px;
    background: var(--blue-medium);
    border-radius: 50%;
}

.bullet-list li:last-child {
    margin-bottom: -5px;
}

/* Dark mode bullet list */
[data-theme="dark"] .bullet-list li::before {
    background: var(--blue-light);
}

/* Mobile responsive bullet list */
@media (max-width: 600px) {
    .bullet-list li {
        padding: 6px 10px 6px 24px;
        font-size: 14px;
    }
    
    .bullet-list li::before {
        left: 8px;
        top: 13px;
        width: 5px;
        height: 5px;
    }
}

.exploded-view-gallery {
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 10px;
    padding: 14px;
    margin: 8px 0;
}

.exploded-view-gallery .gallery-title {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.exploded-view-gallery .gallery-subtitle {
    margin: 0 0 12px 0;
    font-size: 12px;
    color: var(--text-secondary, #666);
}

.exploded-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.exploded-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.exploded-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
    padding: 4px;
}

.exploded-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    font-size: 9px;
    font-weight: 500;
    text-align: center;
}

.exploded-download {
    text-align: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

/* Dark mode for exploded views */
[data-theme="dark"] .exploded-view-gallery {
    background: var(--bg-secondary, #2a2a2a);
}

[data-theme="dark"] .exploded-item {
    background: var(--bg-primary, #1a1a1a);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .exploded-item img {
    background: var(--bg-primary, #1a1a1a);
}

/* Responsive for exploded views */
@media (max-width: 600px) {
    .exploded-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .exploded-view-gallery {
        padding: 12px;
    }
}

/* Image error state */
.exploded-item.img-error {
    background: var(--bg-secondary, #f0f0f0);
}

.exploded-item.img-error img {
    opacity: 0.5;
}

.exploded-item.img-error::after {
    content: '⚠️ Image not found';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    color: var(--text-muted, #999);
    text-align: center;
    pointer-events: none;
}
/* =============================================
   Quote Wizard Styles
   ============================================= */
.quote-wizard {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    padding: 20px;
    margin: 8px 0;
}

.quote-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light, #e8e8e8);
}

.quote-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary, #333);
}

.quote-progress {
    font-size: 12px;
    color: var(--text-muted, #888);
    background: var(--bg-secondary, #f5f5f5);
    padding: 4px 10px;
    border-radius: 12px;
}

.quote-step-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-primary, #3d5167);
    margin-bottom: 16px;
}

.quote-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.quote-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quote-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #555);
}

.quote-label .required {
    color: #dc3545;
}

.quote-input {
    padding: 10px 12px;
    border: 1px solid var(--border-color, #d4d4d4);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-input, #fff);
    color: var(--text-primary, #333);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.quote-input:focus {
    outline: none;
    border-color: var(--accent-primary, #3d5167);
    box-shadow: 0 0 0 3px rgba(61, 81, 103, 0.1);
}

.quote-textarea {
    min-height: 80px;
    resize: vertical;
}

.quote-buttons {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light, #e8e8e8);
}

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

.quote-btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
}

.quote-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-1px);
}

.quote-btn-secondary {
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-secondary, #555);
    border: 1px solid var(--border-color, #d4d4d4);
}

.quote-btn-secondary:hover {
    background: var(--bg-hover, #e8e8e8);
}

/* Success message */
.quote-success {
    text-align: center;
    padding: 24px;
}

.quote-success-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.quote-success-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin-bottom: 8px;
}

.quote-success-text {
    font-size: 14px;
    color: var(--text-secondary, #666);
    margin-bottom: 12px;
}

.quote-success-ref {
    font-size: 12px;
    color: var(--text-muted, #888);
    background: var(--bg-secondary, #f5f5f5);
    display: inline-block;
    padding: 6px 12px;
    border-radius: 4px;
}

/* Dark mode */
[data-theme="dark"] .quote-wizard {
    background: var(--bg-card, #1a2028);
    border-color: var(--border-color, #2d3a47);
}

[data-theme="dark"] .quote-input {
    background: var(--bg-input, #232b35);
    border-color: var(--border-color, #2d3a47);
    color: var(--text-primary, #e8e8e8);
}

[data-theme="dark"] .quote-input:focus {
    border-color: var(--accent-primary, #4a6a8a);
    box-shadow: 0 0 0 3px rgba(74, 106, 138, 0.2);
}

[data-theme="dark"] .quote-btn-secondary {
    background: var(--bg-secondary, #232b35);
    color: var(--text-primary, #e8e8e8);
    border-color: var(--border-color, #2d3a47);
}

/* Mobile responsive */
@media (max-width: 600px) {
    .quote-wizard {
        padding: 16px;
    }
    
    .quote-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .quote-buttons {
        flex-direction: column;
    }
    
    .quote-btn {
        width: 100%;
    }
}