/* OpenMind Unified Styles */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #0f0f15;
    --bg-tertiary: #151520;
    --bg-message-user: #2b2b2b;
    --bg-message-bot: #252525;
    --accent-red: #cc1a1a;
    --accent-red-dark: #aa1515;
    --accent-glow: rgba(204, 26, 26, 0.3);
    --text-primary: #b8b8c8;
    --text-secondary: #888898;
    --text-muted: #666666;
    --border-color: #222230;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Star background with blur and matte glass effect */
.star-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    overflow: hidden; z-index: 2; pointer-events: none;
    background: 
        radial-gradient(ellipse at top, rgba(204, 26, 26, 0.2), transparent 60%),
        radial-gradient(ellipse at bottom, rgba(204, 26, 26, 0.15), transparent 60%),
        radial-gradient(ellipse at right, rgba(204, 26, 26, 0.12), transparent 50%),
        radial-gradient(ellipse at left, rgba(204, 26, 26, 0.12), transparent 50%);
    backdrop-filter: blur(60px) saturate(120%);
    -webkit-backdrop-filter: blur(60px) saturate(120%);
}

/* Dark overlay for background */
.star-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg,
        rgba(10, 10, 15, 0.8) 0%,
        rgba(10, 10, 15, 0.6) 50%,
        rgba(10, 10, 15, 0.8) 100%
    );
    pointer-events: none;
    z-index: 1;
}

.star {
    position: absolute; background: white; border-radius: 50%;
    opacity: 0; animation: ignite 0.8s ease-out forwards;
    z-index: 3;
}

.star.twinkle {
    animation: ignite 0.8s ease-out forwards, twinkle 4s ease-in-out infinite;
    animation-delay: var(--ignite-delay), var(--ignite-delay);
    z-index: 3;
}

@keyframes ignite { from { opacity: 0; transform: scale(0); } to { opacity: var(--opacity); transform: scale(1); } }
@keyframes twinkle { 0%, 100% { opacity: var(--opacity); } 50% { opacity: calc(var(--opacity) * 0.4); } }

/* Navigation - Modern glassmorphism header with matte effect */
.navbar {
    position: fixed; top: 0; width: 100%; padding: 2px 3px;
    display: flex; justify-content: space-between; align-items: center;
    z-index: 1000;
    background: rgba(15, 15, 21, 0.7);
    backdrop-filter: blur(40px) saturate(120%);
    -webkit-backdrop-filter: blur(40px) saturate(120%);
    border-bottom: 1px solid rgba(204, 26, 26, 0.15);
    box-shadow: 0 4px 3px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.navbar-content { 
    max-width: 1200px; 
    margin: 0 auto; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    gap: 24px;
}

.logo {
    display: flex; 
    align-items: center; 
    gap: 10px;
    font-family: var(--font-mono); 
    font-weight: 700; 
    font-size: 1.3rem;
    color: var(--text-primary); 
    cursor: pointer;
    transition: transform 0.2s;
}

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

.logo-icon { 
    color: var(--accent-red); 
    font-size: 1.6rem; 
    text-shadow: 0 0 20px var(--accent-glow);
}

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

.logo .highlight { 
    color: var(--accent-red); 
    text-shadow: 0 0 20px var(--accent-glow);
}

.nav-links { 
    display: flex; 
    gap: 24px; 
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary); 
    font-size: 0.9rem; 
    font-weight: 500;
    transition: all 0.3s; 
    position: relative; 
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
}

.nav-links a::after {
    content: ''; 
    position: absolute; 
    bottom: 4px; 
    left: 50%; 
    width: 0; 
    height: 2px;
    background: var(--accent-red); 
    transition: all 0.3s;
    transform: translateX(-50%);
}

.nav-links a:hover { 
    color: var(--text-primary); 
    background: rgba(204, 26, 26, 0.1);
}

.nav-links a:hover::after { 
    width: 100%; 
}

.nav-links a.active {
    color: var(--accent-red);
    background: rgba(204, 26, 26, 0.15);
}

.nav-links a.active::after {
    width: 100%;
}

/* User info display */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: rgba(21, 21, 32, 0.6);
    border: 1px solid rgba(204, 26, 26, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-red), var(--accent-red-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

.auth-btn {
    padding: 8px 18px; 
    background: linear-gradient(135deg, var(--accent-red), var(--accent-red-dark));
    border: none;
    border-radius: 10px; 
    color: #fff; 
    font-size: 0.85rem; 
    font-weight: 600;
    cursor: pointer; 
    transition: all 0.3s;
    display: flex; 
    align-items: center; 
    gap: 6px;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.auth-btn:hover { 
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

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

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s;
    border-radius: 2px;
}

@media (max-width: 768px) {
    .navbar {
        padding: 2px 3px;
    }
    
    .nav-links {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .user-info {
        display: none;
    }
    
    .auth-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* Main container - Full height with glass effect */
.main-container {
    min-height: 100vh;
    padding-top: 50px;
    padding-bottom: 140px; /* Space for fixed input at bottom */

    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    z-index: 4;
    color: var(--text-primary);
}



.main-container::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: 
        linear-gradient(180deg, rgba(10, 10, 15, 0.08) 0%, rgba(10, 10, 15, 0.05) 50%, rgba(10, 10, 15, 0.08) 100%),
        rgba(10, 10, 15, 0.15);
    z-index: 2;
    pointer-events: none;
}

/* Chat container - Full width, no centering */
.chat-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Chat messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0; /* Important for flex scrolling */
    position: relative;
    z-index: 3;
}

.welcome-message {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    min-height: 300px;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
}

.logo-icon { font-size: 3rem; display: block; margin-bottom: 16px; }
.welcome-content h1 { font-size: 2.5rem; margin-bottom: 12px; }
.welcome-content p { color: var(--text-secondary); font-size: 1.1rem; }

.message {
    display: flex; gap: 10px; max-width: 80%;
    animation: fadeIn 0.3s ease;
    align-self: flex-start;
}

.message.user { align-self: flex-end; }
.message.bot { align-self: flex-start; }

.message-content {
    padding: 12px 16px; border-radius: 12px;
    font-size: 1rem; line-height: 1.5; word-wrap: break-word;
}

.message.user .message-content {
    background: var(--accent-red); color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: var(--bg-message-bot); color: #e0e0e0;
    border-bottom-left-radius: 4px; border: 1px solid rgba(255,255,255,0.1);
}

.message-image {
    max-width: 300px; max-height: 200px;
    border-radius: 8px; margin-bottom: 8px; display: block;
}

.bot-meta {
    font-size: 0.7rem; color: #888898;
    margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.1);
    font-family: var(--font-mono);
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
    max-width: 100%;
    width: auto;
    height: auto;
    min-height: auto;
    line-height: 1.4;
    align-self: flex-start;
}

.bot-meta .token-count {
    display: inline-block;
    background: rgba(204, 26, 26, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    color: #ff6b6b;
    font-weight: 600;
}

.bot-meta .reasoning-count {
    display: inline-block;
    background: rgba(100, 100, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    color: #8888ff;
    font-weight: 600;
}

.bot-meta .speed {
    color: var(--text-secondary);
    font-size: 0.65rem;
}

/* Typing indicator */
.typing-indicator {
    padding: 10px 20px; font-size: 0.9rem; color: var(--text-muted);
    display: none;
}

.typing-bubble {
    display: flex; gap: 5px; align-items: center;
}

.typing-bubble span {
    width: 8px; height: 8px; background: var(--accent-red);
    border-radius: 50%; animation: typing 1.4s infinite ease-in-out;
}

.typing-bubble span:nth-child(1) { animation-delay: 0s; }
.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

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

/* Reasoning bubble for thinking mode with matte glass effect */
.reasoning-indicator {
    padding: 12px 20px;
    display: none;
}

.reasoning-bubble {
    background: linear-gradient(135deg, rgba(42, 42, 58, 0.85), rgba(31, 31, 46, 0.85));
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    border: 1px solid rgba(100, 100, 255, 0.3);
    border-radius: 16px;
    padding: 16px;
    max-width: 80%;
    width: fit-content;
    animation: fadeIn 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Hide reasoning bubble when generation is complete */
.reasoning-bubble.hidden {
    display: none;
}

.reasoning-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.reasoning-icon {
    font-size: 1.5rem;
    animation: thinkPulse 1.5s ease-in-out infinite;
}

@keyframes thinkPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.reasoning-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    flex: 1;
}

/* Integrated mode selector at bottom */
.mode-selector-integrated {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-right: 8px;
}

.mode-selector-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    width: 45px;
    height: 45px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mode-selector-btn:hover {
    transform: translateY(-2px);
    border-color: var(--accent-red);
    background: linear-gradient(135deg, rgba(204, 26, 26, 0.2), rgba(204, 26, 26, 0.1));
    box-shadow: 0 6px 20px rgba(204, 26, 26, 0.4);
}

.mode-selector-btn.active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.1));
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3), 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mode-selector-btn.fast {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border-color: rgba(255, 255, 255, 0.15);
}

.mode-selector-btn.fast.active {
    background: linear-gradient(135deg, rgba(204, 26, 26, 0.35), rgba(204, 26, 26, 0.25));
    border-color: var(--accent-red);
    box-shadow: 0 0 25px var(--accent-glow), 0 4px 15px rgba(204, 26, 26, 0.4);
}

.mode-selector-btn.think {
    background: linear-gradient(135deg, rgba(100, 100, 255, 0.25), rgba(100, 100, 255, 0.2));
    border-color: rgba(100, 100, 255, 0.5);
    box-shadow: 0 4px 15px rgba(100, 100, 255, 0.3);
}

.mode-selector-btn.think.active {
    background: linear-gradient(135deg, rgba(100, 100, 255, 0.65), rgba(100, 100, 255, 0.55));
    border-color: #6464ff;
    box-shadow: 0 0 35px rgba(100, 100, 255, 0.9), 0 4px 15px rgba(100, 100, 255, 0.6);
}

.mode-selector-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.mode-selector-btn:disabled:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mode-selector-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mode-selector-btn:hover {
    transform: translateY(-3px);
    border-color: var(--accent-red);
    background: linear-gradient(135deg, rgba(204, 26, 26, 0.2), rgba(204, 26, 26, 0.1));
    box-shadow: 0 6px 20px rgba(204, 26, 26, 0.4);
}

.mode-selector-btn.active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.1));
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3), 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mode-selector-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.mode-selector-btn:disabled:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mobile-mode-selector {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 21, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(204, 26, 26, 0.2);
    border-radius: 12px;
    padding: 10px 16px;
    display: none;
    gap: 8px;
    z-index: 150;
}

@media (max-width: 768px) {
    .mode-selector-integrated {
        margin-right: 6px;
    }
    
    .mode-selector-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

.mobile-mode-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mobile-mode-btn:hover {
    background: rgba(204, 26, 26, 0.15);
    border-color: var(--accent-red);
}

.mobile-mode-btn.active {
    background: rgba(204, 26, 26, 0.25);
    border-color: var(--accent-red);
    box-shadow: 0 0 15px var(--accent-glow);
}

.mobile-mode-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

/* Image preview */
.image-preview {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: 12px; padding: 8px; z-index: 100;
}

.image-preview img { max-width: 200px; max-height: 150px; border-radius: 8px; }

.image-preview-remove {
    position: absolute; top: -8px; right: -8px;
    width: 24px; height: 24px; background: var(--accent-red);
    border: none; border-radius: 50%; color: white;
    cursor: pointer; font-size: 16px; line-height: 1;
}

/* Input area - Fixed at bottom with glass effect */
.input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 24px;
    background: rgba(15, 15, 21, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(204, 26, 26, 0.15);
    z-index: 100;
}

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

.image-upload-btn, .send-btn {
    width: 44px; height: 44px; border: none; border-radius: 10px;
    background: var(--bg-tertiary); color: var(--text-secondary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.3s; flex-shrink: 0;
}

.image-upload-btn:hover, .send-btn:hover { background: var(--accent-red); color: white; }

.send-btn { background: var(--accent-red); color: white; }
.send-btn:hover { background: var(--accent-red-dark); }

#messageInput {
    flex: 1; padding: 12px 16px; border: 1px solid var(--border-color);
    border-radius: 10px; background: var(--bg-tertiary); color: var(--text-primary);
    font-size: 1rem; font-family: var(--font-main); resize: vertical;
    min-height: 44px; max-height: 200px; outline: none;
    transition: border-color 0.3s;
    overflow-y: auto;
}

#messageInput:focus { border-color: var(--accent-red); }

/* Mode selector */
.mode-toggle { display: flex; gap: 8px; }

.mode-option {
    padding: 6px 16px; border: 1px solid var(--border-color);
    border-radius: 20px; background: transparent; color: var(--text-secondary);
    font-size: 0.85rem; cursor: pointer; transition: all 0.3s;
}

.mode-option:hover { border-color: var(--accent-red); }
.mode-option.active { background: var(--accent-red); border-color: var(--accent-red); color: white; }

/* Desktop mode selector */
.desktop-mode-selector {
    position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 12px;
    padding: 8px 16px; background: rgba(15, 15, 21, 0.9);
    border: 1px solid var(--border-color); border-radius: 25px;
    z-index: 99;
}

.desktop-mode-selector .mode-label {
    font-size: 0.85rem; color: var(--text-secondary);
}

.desktop-mode-selector .mode-btn {
    width: 36px; height: 36px; border: 1px solid var(--border-color);
    border-radius: 50%; background: transparent; color: var(--text-secondary);
    cursor: pointer; font-size: 1rem; transition: all 0.3s;
    display: flex; align-items: center; justify-content: center;
}

.desktop-mode-selector .mode-btn:hover {
    border-color: var(--accent-red);
    transform: scale(1.1);
}

.desktop-mode-selector .mode-btn.active {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
    box-shadow: 0 0 10px var(--accent-glow);
}

.mobile-mode-btn {
    padding: 8px 16px; border: 1px solid var(--border-color);
    border-radius: 8px; background: transparent; color: var(--text-secondary);
    font-size: 0.85rem; cursor: pointer; transition: all 0.3s;
}

.mobile-mode-btn.active { background: var(--accent-red); border-color: var(--accent-red); color: white; }

.mobile-mode-btn:disabled, .desktop-mode-selector .mode-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}

.mobile-mode-btn:disabled::after, .desktop-mode-selector .mode-btn:disabled::after {
    content: '🔒';
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
}

/* Token counter with matte glass effect */
.token-counter {
    position: fixed;
    top: 100px;
    right: 30px;
    background: linear-gradient(135deg, rgba(20, 20, 30, 0.85), rgba(30, 30, 40, 0.85));
    backdrop-filter: blur(30px) saturate(120%);
    -webkit-backdrop-filter: blur(30px) saturate(120%);
    border: 1px solid rgba(204, 26, 26, 0.3);
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    gap: 16px;
    align-items: center;
    z-index: 180;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.token-counter #tokenCount {
    font-weight: 600;
    color: var(--accent-red);
}

.token-counter #speed {
    color: var(--text-secondary);
}

/* Stop generation button */
.stop-btn {
    background: linear-gradient(135deg, rgba(204, 26, 26, 0.2), rgba(204, 26, 26, 0.1));
    border: 2px solid var(--accent-red);
    border-radius: 12px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1.5s ease-in-out infinite;
}

.stop-btn:hover {
    background: linear-gradient(135deg, rgba(204, 26, 26, 0.3), rgba(204, 26, 26, 0.2));
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent-glow);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(204, 26, 26, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(204, 26, 26, 0);
    }
}

/* Mobile mode selector */
.mobile-mode-selector {
    position: fixed; top: 70px; left: 0; right: 0;
    padding: 12px 24px; background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color); z-index: 99;
    display: none;
}

.mobile-mode-selector.active { display: flex; justify-content: center; gap: 12px; }

/* Popover menu */
.popover-menu {
    position: relative;
}

.popover-menu.active .popover-content { display: flex; }

.popover-content {
    position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 12px; padding: 8px; display: none; flex-direction: column;
    gap: 4px; min-width: 200px; z-index: 101;
}

.popover-content button {
    padding: 10px 16px; border: none; border-radius: 8px;
    background: transparent; color: var(--text-secondary);
    cursor: pointer; text-align: left; display: flex; align-items: center; gap: 8px;
    transition: all 0.3s;
}

.popover-content button:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.mobile-action-button {
    width: 44px; height: 44px; border: none; border-radius: 10px;
    background: var(--bg-tertiary); color: var(--text-secondary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* Sidebar */
.sidebar-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); z-index: 200;
    opacity: 0; visibility: hidden; transition: all 0.3s;
    z-index: 1002;
}

.sidebar-overlay.active { opacity: 1; visibility: visible; }

.sidebar {
    position: fixed; top: 72px; right: -320px; bottom: 0;
    width: 320px; background: var(--bg-secondary);
    z-index: 1001; transition: right 0.3s;
    display: flex; flex-direction: column;
}

.sidebar.active { right: 0; }

.sidebar-header {
    padding: 20px; border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
    z-index: 1004;
}

.sidebar-title {
    display: flex; align-items: center; gap: 10px;
    font-size: 1.1rem; font-weight: 600;
}

.sidebar-close {
    width: 32px; height: 32px; border: none; background: transparent;
    color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

.sidebar-actions {
    padding: 16px; border-bottom: 1px solid var(--border-color);
    display: flex; gap: 8px;
}

.sidebar-action-btn {
    flex: 1; padding: 10px; border: none; border-radius: 8px;
    background: var(--bg-tertiary); color: var(--text-secondary);
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 0.9rem; transition: all 0.3s;
}

.sidebar-action-btn:hover { background: var(--accent-red); color: white; }

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

.chat-history-item {
    padding: 12px; border-radius: 8px; cursor: pointer;
    margin-bottom: 8px; transition: all 0.3s;
}

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

.chat-history-item-title { font-weight: 500; margin-bottom: 4px; }
.chat-history-item-time { font-size: 0.8rem; color: var(--text-muted); }
.sidebar-empty { text-align: center; color: var(--text-muted); padding: 20px; }

/* Auth page */
.auth-container {
    background: var(--bg-secondary); border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px; padding: 40px; width: 100%; max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.auth-header { text-align: center; margin-bottom: 32px; }
.auth-header .logo {
    font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--text-secondary); font-size: 0.9rem; }

.form-group input {
    width: 100%; padding: 14px 16px; background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 10px;
    color: var(--text-primary); font-size: 1rem; transition: all 0.3s;
}

.form-group input:focus {
    outline: none; border-color: var(--accent-red);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, rgba(15, 15, 21, 0.95), rgba(20, 20, 35, 0.95));
}

.auth-header {
    margin-bottom: 40px;
    text-align: center;
}

.auth-header .logo {
    font-size: 2rem;
    justify-content: center;
}

.form-group {
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    background: rgba(21, 21, 32, 0.6);
    border: 1px solid rgba(204, 26, 26, 0.3);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-btn-block {
    width: 100%;
    max-width: 400px;
    padding: 14px;
    background: var(--accent-red);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 8px;
}

.auth-btn-block:hover { background: var(--accent-red-dark); transform: translateY(-2px); }

.success-msg {
    background: rgba(46, 204, 113, 0.1); border: 1px solid #2ecc71;
    border-radius: 8px; padding: 12px; margin-bottom: 16px;
    color: #2ecc71; font-size: 0.9rem; display: none;
}

.error-msg {
    background: rgba(255, 107, 107, 0.1); border: 1px solid #ff6b6b;
    border-radius: 8px; padding: 12px; margin-bottom: 16px;
    color: #ff6b6b; font-size: 0.9rem; display: none;
}

.user-info {
    background: var(--bg-tertiary); border-radius: 8px; padding: 16px; margin: 16px 0;
    font-family: var(--font-mono); font-size: 0.85rem;
}

.user-info div { margin: 6px 0; color: var(--text-secondary); }
.user-info .label { color: var(--accent-red); }

.btn-group { display: flex; gap: 12px; margin-top: 16px; }
.btn {
    flex: 1; padding: 12px 24px; border: none; border-radius: 8px;
    color: #fff; font-size: 0.9rem; cursor: pointer; transition: all 0.3s;
}

.btn-primary { background: var(--accent-red); }
.btn-primary:hover { background: var(--accent-red-dark); }

.btn-secondary {
    background: var(--bg-tertiary); border: 1px solid var(--border-color);
}

.btn-secondary:hover { background: rgba(255, 255, 255, 0.05); }

.debug-info {
    margin-top: 24px; padding: 16px; background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 8px;
    font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-secondary);
}

.debug-info h4 { color: var(--accent-red); margin-bottom: 8px; }

/* Responsive */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .mobile-mode-selector { display: flex; }
    .input-wrapper { flex-wrap: wrap; }
    #messageInput { flex: 1 0 70%; min-width: 150px; }
    .main-container { padding-bottom: 140px; }
    .sidebar { width: 280px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .main-container { padding-bottom: 100px; }
}

@media (min-width: 1025px) {
    .main-container { padding-bottom: 70px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ====== CHAT SIDEBAR ====== */
.chat-sidebar {
    position: fixed;
    left: -320px;
    top: 72px;
    width: 320px;
    height: calc(100vh - 72px);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 1002;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-sidebar.active {
    left: 0;
    z-index: 2002;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.new-chat-btn {
    flex: 1;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--accent-red), var(--accent-red-dark));
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.new-chat-btn .icon {
    font-size: 16px;
    font-weight: bold;
}

.sidebar-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-red);
}

.sidebar-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-search input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.sidebar-search input:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-glow);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    padding: 12px 14px;
    margin-bottom: 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

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

.chat-item.active {
    background: rgba(204, 26, 26, 0.15);
    border-color: var(--accent-red);
}

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

.chat-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chat-delete-btn:hover {
    background: rgba(204, 26, 26, 0.2);
    color: var(--accent-red);
}

.chat-preview {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
}

.message-count {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 12px;
}

.chat-date {
    color: var(--text-muted);
}

.empty-chats {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Sidebar toggle button in navbar */
.sidebar-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.3s ease;
    margin-right: 8px;
}

.sidebar-toggle-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-red);
}

/* Mobile sidebar */
@media (max-width: 768px) {
    .chat-sidebar {
        width: 280px;
        left: -280px;
    }
    
    .main-container {
        margin-left: 0;
    }
}
