:root {
    --bg-dark: #0a0a0c;
    --card-bg: rgba(20, 20, 25, 0.7);
    --accent-blue: #3b82f6;
    --accent-indigo: #6366f1;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(20px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.2) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.1) 0, transparent 50%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ── Sidebar ── */
.sidebar {
    width: 280px;
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 32px;
}

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

.icon-brand {
    color: var(--accent-blue);
    width: 32px;
    height: 32px;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

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

.sidebar-section label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.select-wrapper select, textarea#system-prompt {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.select-wrapper select:focus, textarea#system-prompt:focus {
    outline: none;
    border-color: var(--accent-blue);
}

textarea#system-prompt {
    height: 120px;
    resize: none;
}

.sidebar-footer {
    margin-top: auto;
}

/* ── Main Chat Room ── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-header {
    height: 72px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 10, 12, 0.5);
    backdrop-filter: blur(10px);
}

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

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.green { background: #10b981; box-shadow: 0 0 10px rgba(16, 185, 129, 0.5); }

/* ── Status Waves ── */
.model-status-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.status-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.wave-container {
    position: relative;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wave-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    z-index: 2;
}

.wave {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0;
    animation: wavePulse 2s infinite;
}

.wave:nth-child(2) { animation-delay: 0.5s; }
.wave:nth-child(3) { animation-delay: 1s; }

/* States */
.status-healthy .wave-dot { background: #10b981; }
.status-healthy .wave { border: 2px solid rgba(16, 185, 129, 0.4); }

.status-checking .wave-dot { background: #f59e0b; }
.status-checking .wave { border: 2px solid rgba(245, 158, 11, 0.4); }

.status-unavailable .wave-dot { background: #ef4444; }
.status-unavailable .wave { border: 2px solid rgba(239, 68, 68, 0.4); }

@keyframes wavePulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

.chat-history {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.welcome-card {
    max-width: 600px;
    margin: 40px auto;
    padding: 40px;
    background: var(--card-bg);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

.welcome-card h2 { margin-bottom: 12px; font-weight: 600; }
.welcome-card p { color: var(--text-secondary); line-height: 1.6; }

/* ── Messages ── */
.message {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 0.95rem;
    word-wrap: break-word;
    animation: slideUp 0.3s ease-out;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* Markdown Support */
.message h1, .message h2, .message h3 { margin: 1rem 0 0.5rem; }
.message p { margin-bottom: 0.75rem; }
.message ul, .message ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
.message code { background: rgba(0,0,0,0.3); padding: 0.2rem 0.4rem; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 0.85rem; }
.message pre { background: #1e1e2e !important; padding: 1rem; border-radius: 12px; overflow-x: auto; margin: 1rem 0; border: 1px solid var(--border-color); }
.message pre code { background: transparent; padding: 0; font-size: 0.9rem; }
.message blockquote { border-left: 4px solid var(--accent-blue); padding-left: 1rem; color: var(--text-secondary); font-style: italic; margin: 1rem 0; }
.message table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.message th, .message td { border: 1px solid var(--border-color); padding: 8px; text-align: left; }
.message th { background: rgba(255,255,255,0.05); }

/* ── Input Area ── */
.chat-input-area {
    padding: 24px 32px 32px;
    background: linear-gradient(to top, var(--bg-dark), transparent);
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(30, 30, 35, 0.8);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 12px;
    font-size: 1rem;
    max-height: 150px;
    overflow-y: auto;
    resize: none;
}

#user-input:focus { outline: none; }

.send-btn {
    background: var(--accent-blue);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.send-btn:hover { background: var(--accent-indigo); transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }

.input-hint {
    text-align: center;
    font-size: 0.75rem;
    color: #4b5563;
    margin-top: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Buttons ── */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Scrollbar Customization */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
