/* ===== CSS Variables for Themes ===== */
:root {
    /* Light Theme */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-sidebar: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-hover: #f1f5f9;
    
    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-on-primary: #ffffff;
    
    /* Border & Shadows */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Message Bubbles */
    --user-bubble: var(--primary);
    --bot-bubble: var(--bg-secondary);
    --typing-bubble: #e2e8f0;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: #1e293b;
    --bg-surface: #334155;
    --bg-hover: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #475569;
    --bot-bubble: #334155;
    --user-bubble: #4f46e5;
}

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

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--transition-normal);
}

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

.container {
    display: flex;
    max-width: 1400px;
    height: 100vh;
    margin: 0 auto;
    padding: 20px;
    gap: 20px;
}

/* ===== Sidebar Styles ===== */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-xl);
    padding: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
}

.sidebar-header {
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.logo i {
    font-size: 1.8rem;
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.sidebar-section {
    margin-bottom: 32px;
}

.sidebar-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Settings Switches */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

.switch input {
    display: none;
}

.slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
}

.slider:before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

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

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

/* Stats */
.stats {
    display: flex; 
    justify-content: space-between;
    gap: 10px;
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; 
    padding: 12px 8px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm); 
    min-width: 0; 
}

.stat-item:hover {
    transform: translateY(-2px);
}

.stat-value {
   font-size: 1.25rem; 
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

.quick-btn i {
    font-size: 0.9rem;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.version {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-container {
    flex: 1;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transition: all var(--transition-normal);
}

/* ===== Chat Header ===== */
.chat-header {
    padding: 20px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-normal);
}

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

.avatar {
    position: relative;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.status-indicator {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--success);
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
    bottom: -2px;
    right: -2px;
}

.status-indicator.active {
    animation: pulse 2s infinite;
}

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

.header-info h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.subtitle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status {
    color: var(--success);
    font-weight: 500;
}

.model {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-text-fill-color: transparent;
    font-weight: 600;
}

.typing-status {
    font-style: italic;
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-surface);
    min-width: 180px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 100;
    overflow: hidden;
}

.dropdown-content a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background var(--transition-fast);
}

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

.dropdown-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* ===== Chat Window ===== */
.chat-window {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.welcome-section {
    text-align: center;
    padding: 40px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.welcome-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 16px;
}

.welcome-section h2 {
    font-size: 1.75rem;
    margin-bottom: 12px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-text-fill-color: transparent;
}

.welcome-text {
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 24px;
    line-height: 1.6;
}

.quick-prompts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.prompt-btn {
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.prompt-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* ===== Message Styles ===== */
.message {
    max-width: 85%;
    padding: 16px;
    border-radius: var(--radius-lg);
    position: relative;
    animation: slideIn 0.3s ease-out;
}

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

.message.bot {
    align-self: flex-start;
    background: var(--bot-bubble);
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: var(--user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.welcome {
    max-width: 90%;
    margin: 0 auto;
    background: var(--bg-secondary);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.75rem;
}

.sender {
    font-weight: 600;
    color: var(--text-primary);
}

.message.user .sender {
    color: rgba(255, 255, 255, 0.9);
}

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

.message.user .timestamp {
    color: rgba(255, 255, 255, 0.7);
}

.message-content {
    line-height: 1.6;
    font-size: 0.95rem;
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

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

.action-btn {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--radius-sm);
    color: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Typing Indicator */
.message.typing {
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

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

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

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.typing-text {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ===== Input Area ===== */
.chat-input-container {
    padding: 20px 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

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

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

.input-action-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.input-action-btn:hover {
    background: var(--primary);
    color: white;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#user-input {
    width: 100%;
    padding: 16px 20px;
    padding-right: 80px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    transition: all var(--transition-fast);
}

#user-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-hint {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

.send-btn {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.send-btn:active {
    transform: translateY(0) scale(0.98);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.disclaimer, .model-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Feature Showcase ===== */
.feature-showcase {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.feature {
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.feature:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.feature h4 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.feature p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ===== Confetti Canvas ===== */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
    .container {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .quick-prompts {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .feature-showcase {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .chat-header {
        padding: 16px;
    }
    
    .chat-window {
        padding: 16px;
    }
    
    .welcome-section {
        padding: 24px 16px;
    }
    
    .quick-prompts {
        grid-template-columns: 1fr;
    }
    
    .feature-showcase {
        grid-template-columns: 1fr;
    }
    
    .input-footer {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .message {
        max-width: 95%;
    }
}

@media (max-width: 480px) {
    .subtitle {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .header-actions .icon-btn:not(#menu-toggle) {
        display: none;
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pulse {
    animation: pulse 2s infinite;
}

.pulse-red {
    animation: pulse-red-bg 1.5s infinite;
    color: #ef4444 !important;
}

@keyframes pulse-red-bg {
    0% { transform: scale(1); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); }
}