/* ==============================================================================
   Aneevarp DocAI — Enterprise Workspace Stylesheet (Light & Dark Dual Engine)
   Brand-aligned with Aneevarp Solutions (https://aneevarpsolutions.vercel.app/)
   ============================================================================== */

/* ==============================================================================
   1. CSS VARIABLES & THEME TOKENS
   ============================================================================== */

/* LIGHT MODE (Default: Ivory, Forest Sage, Deep Slate) */
:root, [data-theme="light"] {
    --bg-main: #FCFAF5;
    --bg-surface: #FFFFFF;
    --bg-surface-elevated: #F7F6F1;
    --bg-sidebar: #F5F4EE;
    --bg-navbar: #FCFAF5;
    
    --text-primary: #1A1F1F;
    --text-secondary: #354E3D;
    --text-muted: #526357;
    --text-dim: #738478;
    
    --primary: #476550;
    --primary-hover: #37503E;
    --primary-container: #7D9D85;
    --primary-fixed: #C9EBD0;
    --primary-light: #EBF3ED;
    --on-primary: #FFFFFF;
    
    --sage-muted: #A2BCA8;
    --border-color: rgba(71, 101, 80, 0.2);
    --border-hover: #476550;
    
    --card-shadow: 0 4px 20px rgba(26, 31, 31, 0.05);
    --card-shadow-hover: 0 10px 30px rgba(26, 31, 31, 0.09);
    
    --gcp-blue: #2563EB;
    --gemini-purple: #7C3AED;
    --success-color: #059669;
    --warning-color: #D97706;
    --danger-color: #DC2626;
    
    --user-msg-bg: #476550;
    --user-msg-text: #FFFFFF;
    --ai-msg-bg: #FFFFFF;
    --ai-msg-text: #1A1F1F;
    --ai-msg-border: rgba(71, 101, 80, 0.2);
    
    --input-bg: #FFFFFF;
    --input-border: rgba(71, 101, 80, 0.3);
    --input-text: #1A1F1F;
}

/* DARK MODE (Deep Forest Obsidian, Emerald Glow, Crisp White) */
[data-theme="dark"] {
    --bg-main: #0B100E;
    --bg-surface: #131C17;
    --bg-surface-elevated: #17221C;
    --bg-sidebar: #0E1612;
    --bg-navbar: #0B100E;
    
    --text-primary: #F8FAFC;
    --text-secondary: #C9EBD0;
    --text-muted: #94A3B8;
    --text-dim: #64748B;
    
    --primary: #476550;
    --primary-hover: #5A7D65;
    --primary-container: #7D9D85;
    --primary-fixed: #C9EBD0;
    --primary-light: rgba(71, 101, 80, 0.25);
    --on-primary: #FFFFFF;
    
    --sage-muted: #A2BCA8;
    --border-color: rgba(162, 188, 168, 0.2);
    --border-hover: #7D9D85;
    
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --card-shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.6);
    
    --gcp-blue: #60A5FA;
    --gemini-purple: #A78BFA;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    
    --user-msg-bg: rgba(71, 101, 80, 0.4);
    --user-msg-text: #F8FAFC;
    --ai-msg-bg: #131C17;
    --ai-msg-text: #F8FAFC;
    --ai-msg-border: rgba(162, 188, 168, 0.2);
    
    --input-bg: #131C17;
    --input-border: rgba(162, 188, 168, 0.25);
    --input-text: #F8FAFC;
}

/* ==============================================================================
   2. GLOBAL RESETS & TYPOGRAPHY
   ============================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Hanken Grotesk', 'Inter', system-ui, -apple-system, sans-serif;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4, .brand-title {
    font-family: 'Manrope', sans-serif;
}

.badge, .font-caps, .limit-info, .history-header, .prompts-title {
    font-family: 'IBM Plex Sans', sans-serif;
    letter-spacing: 0.04em;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==============================================================================
   3. TOP NAVIGATION BAR
   ============================================================================== */
.top-navbar {
    height: 72px;
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 28px;
    z-index: 100;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Manrope', sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--on-primary);
    box-shadow: 0 4px 15px rgba(71, 101, 80, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.brand-logo:hover {
    transform: scale(1.05);
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.brand-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
}

.badge-gcp {
    background: rgba(37, 99, 235, 0.1);
    color: var(--gcp-blue);
    border: 1px solid rgba(37, 99, 235, 0.25);
}

.badge-gemini {
    background: rgba(124, 58, 237, 0.1);
    color: var(--gemini-purple);
    border: 1px solid rgba(124, 58, 237, 0.25);
}

.badge-firebase {
    background: rgba(217, 119, 6, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(217, 119, 6, 0.25);
}

.brand-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.brand-subtitle strong {
    color: var(--primary);
    font-weight: 700;
}

/* User & Controls Section */
.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* THEME TOGGLE BUTTON */
.theme-toggle-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'IBM Plex Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--card-shadow);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--card-shadow-hover);
}

.theme-toggle-btn i {
    font-size: 0.95rem;
    color: var(--primary);
}

.nav-landing-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'IBM Plex Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--primary-light);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.nav-landing-link:hover {
    background: rgba(71, 101, 80, 0.18);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.google-auth-btn {
    background: #FFFFFF;
    color: #1F2937;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'IBM Plex Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.google-auth-btn img {
    width: 18px;
    height: 18px;
}

.google-auth-btn:hover {
    background: #F8FAFC;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.user-profile {
    position: relative;
}

.profile-avatar-wrapper {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 50%;
    padding: 2px;
    border: 2px solid var(--primary);
    transition: all 0.2s ease;
}

.profile-avatar-wrapper:hover {
    transform: scale(1.05);
}

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

.online-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: var(--success-color);
    border-radius: 50%;
    border: 2px solid var(--bg-main);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 240px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px;
    box-shadow: var(--card-shadow-hover);
    animation: dropdownFadeIn 0.2s ease;
    z-index: 200;
}

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

.dropdown-header {
    padding: 8px 10px;
}

.dropdown-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dropdown-email {
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

.dropdown-item {
    padding: 8px 10px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.dropdown-logout-btn {
    width: 100%;
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger-color);
    border: 1px solid rgba(220, 38, 38, 0.25);
    padding: 9px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'IBM Plex Sans', sans-serif;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.dropdown-logout-btn:hover {
    background: rgba(220, 38, 38, 0.16);
}

/* ==============================================================================
   4. MAIN APP LAYOUT (SIDEBAR + CHAT AREA)
   ============================================================================== */
.app-container {
    display: flex;
    flex: 1;
    width: 100%;
    height: calc(100vh - 72px);
    overflow: hidden;
    position: relative;
}

/* SIDEBAR */
.sidebar {
    width: 320px;
    min-width: 320px;
    max-width: 320px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

/* Sidebar Navigation Tabs */
.sidebar-tabs {
    display: flex;
    padding: 16px 16px 0;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 14px;
    font-size: 0.86rem;
    font-weight: 700;
    font-family: 'IBM Plex Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(71, 101, 80, 0.06);
}

.tab-btn.active {
    color: var(--primary);
    background: var(--bg-surface);
    border-bottom: 3px solid var(--primary);
}

.history-count {
    background: rgba(71, 101, 80, 0.15);
    color: var(--primary);
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 800;
}

.tab-btn.active .history-count {
    background: var(--primary);
    color: white;
}

/* Tab Content */
.tab-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* UPLOAD SECTION */
.section-label {
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-label i {
    color: var(--primary);
}

.limit-info {
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--primary-light);
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-color);
    font-weight: 700;
}
.limit-info i {
    color: var(--primary);
}

.file-upload-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.file-upload-wrapper input[type="file"] { 
    display: none; 
}

.file-upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    background: var(--bg-surface);
    border: 2px dashed rgba(71, 101, 80, 0.35);
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.file-upload-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.upload-icon-pulse {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.upload-prompt {
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--text-primary);
}

.upload-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.file-name-container {
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--primary-light);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

#file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.primary-btn {
    width: 100%;
    background: var(--primary);
    color: var(--on-primary) !important;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    font-family: 'IBM Plex Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(71, 101, 80, 0.28);
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(71, 101, 80, 0.4);
}

.primary-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    box-shadow: none;
}

.secondary-btn {
    width: 100%;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 12px;
    font-weight: 700;
    font-family: 'IBM Plex Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    font-size: 0.85rem;
}

.secondary-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* SUCCESS SECTION */
.hidden { display: none !important; }

#success-section {
    text-align: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 22px 18px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    animation: fadeIn 0.3s ease;
}

.success-icon-badge {
    width: 48px;
    height: 48px;
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin: 0 auto 12px;
    border: 1.5px solid rgba(16, 185, 129, 0.3);
}

.success-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-family: 'Manrope', sans-serif;
}

.success-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
    word-break: break-word;
}

/* STATUS SPINNER */
.status-hidden { display: none !important; }
#status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    padding: 14px;
    background: var(--bg-surface);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(71, 101, 80, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* HISTORY LIST */
.history-header {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: 'IBM Plex Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin-bottom: 12px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: var(--card-shadow);
}

.history-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateX(2px);
}

.history-item.active {
    background: var(--primary-light);
    border-color: var(--primary);
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}

.history-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 0.74rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.history-delete-btn:hover {
    color: var(--danger-color);
    background: rgba(220, 38, 38, 0.1);
}

.history-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
}
.history-empty i {
    font-size: 2.2rem;
    margin-bottom: 12px;
    opacity: 0.5;
}
.history-empty p {
    font-size: 0.84rem;
    line-height: 1.5;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tech-pill {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-surface);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* ==============================================================================
   5. MAIN CHAT AREA
   ============================================================================== */
.chat-area {
    flex: 1;
    min-width: 0;
    width: calc(100% - 320px);
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-main);
    overflow: hidden;
}

.chat-header {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: var(--bg-navbar);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.chat-header-details {
    min-width: 0;
}

.glow-dot {
    width: 10px;
    height: 10px;
    background: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success-color);
    animation: pulse 2s infinite;
    flex-shrink: 0;
}

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

.chat-header-details h2 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.model-badge {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
}

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

.icon-action-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--card-shadow);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.icon-action-btn:hover {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.icon-action-btn.export-btn {
    border-color: rgba(71, 101, 80, 0.35);
    color: var(--primary);
    background: rgba(71, 101, 80, 0.06);
}

.icon-action-btn.export-btn:hover {
    background: var(--primary);
    color: #FFFFFF !important;
    border-color: var(--primary);
}

.icon-action-btn.purge-btn {
    border-color: rgba(220, 38, 38, 0.3);
    color: var(--danger-color);
}

.icon-action-btn.purge-btn:hover {
    background: rgba(220, 38, 38, 0.12);
    border-color: var(--danger-color);
}

.sidebar-compliance-note {
    width: 100%;
    margin-top: 10px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.85;
}

/* AI STATUTORY LABELS (MeitY AI Compliance) */
.ai-statutory-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'IBM Plex Sans', sans-serif;
}

.shimmer-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 280px;
}

.shimmer-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(162, 188, 168, 0.2) 25%, rgba(162, 188, 168, 0.45) 50%, rgba(162, 188, 168, 0.2) 75%);
    background-size: 200% 100%;
    animation: shimmerAnim 1.4s infinite;
}

.line-1 { width: 90%; }
.line-2 { width: 75%; }
.line-3 { width: 50%; }

@keyframes shimmerAnim {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.error-bubble {
    color: var(--danger-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

/* CHAT WINDOW STREAM */
.chat-window {
    flex: 1;
    padding: 16px 28px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    background: var(--bg-main);
    position: relative;
}

.chat-window::-webkit-scrollbar {
    width: 6px;
}
.chat-window::-webkit-scrollbar-thumb {
    background: var(--sage-muted);
    border-radius: 3px;
}

.message {
    max-width: 82%;
    animation: fadeIn 0.35s ease;
}

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

.user-msg {
    align-self: flex-end;
}
.user-msg .msg-content {
    background: var(--user-msg-bg);
    color: var(--user-msg-text);
    padding: 14px 20px;
    border-radius: 18px 18px 4px 18px;
    font-size: 0.96rem;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(71, 101, 80, 0.25);
    line-height: 1.5;
}

.ai-msg {
    align-self: flex-start;
}
.ai-msg .msg-content {
    background: var(--ai-msg-bg);
    color: var(--ai-msg-text);
    border: 1px solid var(--ai-msg-border);
    padding: 22px 26px;
    border-radius: 18px 18px 18px 4px;
    line-height: 1.7;
    font-size: 0.96rem;
    box-shadow: var(--card-shadow);
}

.ai-msg .msg-content ul, 
.ai-msg .msg-content ol {
    margin: 10px 0 10px 20px;
}

.ai-msg .msg-content li {
    margin-bottom: 6px;
}

.ai-msg .msg-content b, 
.ai-msg .msg-content strong {
    color: var(--primary);
    font-weight: 800;
}

.ai-msg .msg-content a {
    color: var(--gcp-blue);
    text-decoration: underline;
}

.ai-msg .msg-content code {
    background: var(--primary-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88rem;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.ai-msg .msg-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 0.88rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-msg .msg-content th {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 800;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1.5px solid var(--border-color);
}

.ai-msg .msg-content td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.ai-msg .msg-content tr:nth-child(even) {
    background: rgba(162, 188, 168, 0.08);
}

.ai-msg .msg-content tr:hover {
    background: rgba(162, 188, 168, 0.16);
}

.system-msg {
    align-self: center;
    max-width: 90%;
}
.system-msg .msg-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 22px 28px;
    border-radius: 18px;
    color: var(--text-primary);
    font-size: 0.94rem;
    line-height: 1.6;
    box-shadow: var(--card-shadow);
}

.system-welcome-title {
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Manrope', sans-serif;
}
.system-welcome-title i {
    color: var(--primary);
}

/* WORKSPACE CLEAN HERO (MODERN CARD-LESS GREETING) */
.workspace-hero-clean {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: auto;
    max-width: 780px;
    width: 100%;
    padding: 8px 12px;
    animation: fadeIn 0.35s ease;
}

.hero-brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.12);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: 'IBM Plex Sans', sans-serif;
    margin-bottom: 12px;
}

.hero-main-title {
    font-size: 1.55rem;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.4px;
    font-family: 'Manrope', sans-serif;
}

.hero-main-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 600px;
    margin-bottom: 20px;
}

.hero-active-doc-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.94rem;
    color: var(--text-primary);
    box-shadow: var(--card-shadow);
    margin-bottom: 12px;
}

.hero-capabilities-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
}

@media (max-width: 768px) {
    .hero-capabilities-grid {
        grid-template-columns: 1fr;
    }
}

.hero-cap-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    box-shadow: var(--card-shadow);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.hero-cap-card.clickable {
    cursor: pointer;
}

.hero-cap-card.clickable:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.cap-icon-box {
    width: 36px;
    height: 36px;
    background: rgba(71, 101, 80, 0.10);
    color: var(--primary);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.hero-cap-card.clickable:hover .cap-icon-box {
    background: var(--primary);
    color: #FFFFFF;
}

.cap-card-info {
    flex: 1;
    overflow: hidden;
}

.cap-card-name {
    font-size: 0.86rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 1px;
}

.cap-card-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cap-arrow {
    font-size: 0.82rem;
    color: var(--text-muted);
    opacity: 0.3;
    transition: all 0.2s ease;
}

.hero-cap-card.clickable:hover .cap-arrow {
    color: var(--primary);
    opacity: 1;
    transform: translateX(3px);
}

/* Sidebar Feature Box */
.sidebar-feature-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 14px;
    margin-top: 10px;
    box-shadow: var(--card-shadow);
}

.feature-box-title {
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    font-family: 'IBM Plex Sans', sans-serif;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.feature-item {
    font-size: 0.76rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    line-height: 1.3;
}

.feature-item:last-child {
    margin-bottom: 0;
}

.feature-item i {
    color: #10B981;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Source Image Visual Grounding */
.source-image-wrapper {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.source-label {
    font-size: 0.82rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.source-image-wrapper img {
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform 0.3s;
}

.source-image-wrapper img:hover {
    transform: scale(1.02);
}

/* ==============================================================================
   6. INPUT AREA
   ============================================================================== */
.chat-input-area {
    padding: 14px 28px 18px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-main);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.input-wrapper {
    max-width: 860px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 16px;
    padding: 6px 8px 6px 20px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(71, 101, 80, 0.2);
}

.input-wrapper input {
    flex: 1;
    font-size: 0.96rem;
    background: transparent;
    border: none;
    color: var(--input-text);
    outline: none;
    padding: 10px 0;
    font-weight: 500;
}

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

.send-btn {
    background: var(--primary);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: var(--on-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(71, 101, 80, 0.3);
    flex-shrink: 0;
}

.send-btn:disabled, .input-wrapper input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(71, 101, 80, 0.5);
}

/* Mobile Workspace View Switcher (< 768px devices) */
.mobile-view-switcher {
    display: none;
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 12px;
    gap: 8px;
    z-index: 20;
}

.view-switch-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.86rem;
    font-family: 'IBM Plex Sans', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.view-switch-btn.active {
    background: var(--primary);
    color: #FFFFFF !important;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(71, 101, 80, 0.3);
}

/* ==============================================================================
   6.5 MODAL BACKDROPS & SOFT PAYWALL DIALOGS
   ============================================================================== */
.legal-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 16, 14, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.legal-modal-backdrop.active {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
}

.legal-modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.92) translateY(15px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.legal-modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.legal-modal-header h3 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.legal-modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.legal-modal-close-btn:hover {
    color: var(--danger-color);
    background: rgba(220, 38, 38, 0.1);
}

.legal-modal-body {
    padding: 24px;
    color: var(--text-primary);
}

/* ==============================================================================
   6.6 TOAST NOTIFICATIONS
   ============================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-item {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 14px 20px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    animation: toastSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
}

.toast-item.success {
    border-color: var(--primary);
    border-left: 4px solid var(--primary);
}

.toast-item.error {
    border-color: var(--danger-color);
    border-left: 4px solid var(--danger-color);
}

@keyframes toastSlide {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==============================================================================
   7. RESPONSIVE QUERIES (Ultra-Wide, Tablet, Mobile & Foldables)
   ============================================================================== */
@media (min-width: 1440px) {
    .app-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }
    .top-navbar {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 900px) {
    .sidebar { width: 300px; }
    .brand-subtitle { display: none; }
}

@media (max-width: 768px) {
    .mobile-view-switcher {
        display: flex;
    }
    .top-navbar {
        height: auto;
        min-height: 56px;
        padding: 8px 12px;
    }
    .brand-title-row .badge {
        display: none;
    }
    .brand-title {
        font-size: 1rem;
    }
    .theme-toggle-btn span {
        display: none;
    }
    .nav-landing-link span {
        display: none;
    }
    .google-auth-btn span {
        display: none;
    }
    .google-auth-btn {
        padding: 7px 10px;
    }
    
    .app-container {
        flex-direction: column;
        height: calc(100vh - 116px);
    }
    
    /* Toggle between full-screen sidebar and full-screen chat on mobile */
    body.mobile-view-docs .sidebar {
        display: flex !important;
        width: 100%;
        height: 100%;
        max-height: none;
        border-right: none;
        border-bottom: none;
    }
    body.mobile-view-docs .chat-area {
        display: none !important;
    }
    
    body.mobile-view-chat .sidebar {
        display: none !important;
    }
    body.mobile-view-chat .chat-area {
        display: flex !important;
        width: 100%;
        height: 100%;
    }

    .chat-header {
        padding: 10px 14px;
    }
    .chat-header-details h2 {
        font-size: 0.95rem;
    }
    .model-badge {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
    .chat-input-area {
        padding: 10px 12px;
    }
    .input-wrapper {
        padding: 4px 6px 4px 14px;
    }
    .input-wrapper input {
        font-size: 0.88rem;
    }
    .send-btn {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
    }
    .prompts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .brand-title {
        font-size: 0.92rem;
    }
    .nav-right {
        gap: 6px;
    }
    .chat-header-actions span {
        display: none;
    }
}
