/* ==========================================================================
   YZ Chatbot - Styling & Design System
   Modern Glassmorphism & High-Aesthetic Dark/Light Design
   ========================================================================== */

:root {
    /* Color Tokens (Dark Theme Default) */
    --bg-main: #0b0f17;
    --bg-secondary: #131b2e;
    --bg-card: rgba(22, 31, 52, 0.7);
    --bg-glass: rgba(30, 41, 67, 0.4);
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);
    
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --user-msg-bg: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --bot-msg-bg: rgba(30, 41, 67, 0.75);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-code: 'Fira Code', monospace;
    
    --sidebar-width: 310px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
body.light-theme {
    --bg-main: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(241, 245, 249, 0.6);
    
    --border-color: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(99, 102, 241, 0.2);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --user-msg-bg: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
    --bot-msg-bg: #ffffff;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
}

/* Global Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
}

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

/* App Container Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    z-index: 100;
    transition: transform var(--transition-normal), left var(--transition-normal);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.brand-text h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand-text span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.close-sidebar-btn {
    display: none;
}

/* Buttons & Inputs */
.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-select {
    width: 100%;
    padding: 10px 14px;
    background-color: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.custom-select:focus {
    border-color: var(--accent-primary);
}

.model-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 10px;
    background-color: var(--bg-glass);
    border-radius: var(--radius-sm);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #e2e8f0;
}

.status-dot.online {
    background-color: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.status-dot.loading {
    background-color: #f59e0b;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

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

.settings-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.settings-group textarea,
.settings-group input {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    resize: vertical;
    outline: none;
}

.settings-group small {
    font-size: 10px;
    color: var(--text-muted);
}

/* History List */
.history-section {
    flex: 1;
    overflow-y: auto;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.history-item:hover,
.history-item.active {
    background-color: var(--bg-glass);
    color: var(--text-primary);
}

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

.footer-btn {
    flex: 1;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.footer-btn:hover {
    background-color: var(--bg-glass);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    background-color: var(--bg-main);
}

.chat-header {
    height: 65px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-card);
    backdrop-filter: blur(12px);
    z-index: 10;
}

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

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background-color var(--transition-fast);
}

.icon-btn:hover {
    background-color: var(--bg-glass);
}

.toggle-sidebar-btn {
    display: none;
}

.active-model-info h1 {
    font-size: 16px;
    font-weight: 700;
}

.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background-color: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
    font-weight: 600;
}

/* Progress Container */
.progress-container {
    padding: 12px 24px;
    background-color: rgba(99, 102, 241, 0.08);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--bg-main);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    transition: width 0.2s ease-out;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Welcome Card */
.welcome-card {
    margin: auto;
    max-width: 600px;
    text-align: center;
    padding: 36px 24px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.welcome-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.welcome-card h2 {
    font-size: 22px;
    font-weight: 700;
}

.welcome-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.suggestion-chip {
    padding: 14px;
    background-color: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: all var(--transition-fast);
}

.suggestion-chip i {
    color: var(--accent-primary);
    font-size: 16px;
    margin-top: 2px;
}

.suggestion-chip:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Chat Message Bubbles */
.message-row {
    display: flex;
    gap: 14px;
    max-width: 850px;
    width: 100%;
}

.message-row.user-row {
    margin-left: auto;
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.user-row .avatar {
    background: var(--accent-gradient);
    color: #fff;
}

.bot-row .avatar {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
}

.message-bubble {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.user-row .message-bubble {
    background: var(--user-msg-bg);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.bot-row .message-bubble {
    background-color: var(--bot-msg-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

/* Formatted Code & Markdown inside bubbles */
.message-bubble p {
    margin-bottom: 10px;
}

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

.message-bubble pre {
    position: relative;
    margin: 12px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background-color: #1e1e1e !important;
}

.message-bubble code {
    font-family: var(--font-code);
    font-size: 13px;
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.copy-code-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 0;
}

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

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

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

/* Input Area Container */
.input-container {
    padding: 16px 24px 20px;
    background-color: var(--bg-main);
}

.chat-form {
    max-width: 850px;
    margin: 0 auto;
}

.textarea-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px 12px 8px 18px;
    box-shadow: var(--shadow-lg);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.textarea-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--border-glow);
}

.textarea-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    max-height: 150px;
    line-height: 1.5;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    margin-left: 8px;
    flex-shrink: 0;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.send-btn:hover {
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    text-align: center;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -100%;
        top: 0;
        bottom: 0;
        height: 100vh;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .toggle-sidebar-btn,
    .close-sidebar-btn {
        display: flex;
    }
    
    .suggestion-grid {
        grid-template-columns: 1fr;
    }
}
