:root {
    --bg-color: #0f172a;
    --sidebar-color: #1e293b;
    --accent-color: #3b82f6;
    --text-color: #f8fafc;
    --chat-bubble-user: #3b82f6;
    --chat-bubble-ai: #334155;
    --border-color: #475569;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: 280px;
    background: var(--sidebar-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    z-index: 100;
    transition: transform 0.3s ease;
}

#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.new-chat-btn {
    background: var(--accent-color);
    border: none;
    color: white;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 2rem;
}

#chat-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-item {
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item:hover,
.chat-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: white;
}

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

header {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.8);
}

h1 {
    margin: 0;
    font-family: 'Outfit';
    font-size: 1.25rem;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#chat-container {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

/* Responsive Mobile Styles */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #sidebar-overlay.show {
        display: block;
    }

    header {
        padding: 1rem;
    }

    #chat-container {
        padding: 1rem;
    }

    #input-area {
        padding: 0.75rem 1rem 1.5rem;
    }

    .message {
        max-width: 95%;
    }

    #menu-toggle {
        display: block !important;
    }
}

#menu-toggle {
    display: none;
    padding: 0.5rem;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.message {
    max-width: 90%;
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    line-height: 1.6;
    font-size: 0.95rem;
    position: relative;
    word-wrap: break-word;
}

.user-message {
    align-self: flex-end;
    background: var(--chat-bubble-user);
    color: white;
    white-space: pre-wrap;
}

.ai-message {
    align-self: flex-start;
    background: var(--chat-bubble-ai);
    color: #cbd5e1;
}

.ai-message p {
    margin: 0 0 1rem 0;
}

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

.chat-img {
    max-width: 100%;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    display: block;
}

.dots {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: dot-bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes dot-bounce {
    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.3;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area Improvements */
#input-area {
    padding: 1rem 2rem 2rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.5rem;
}

#preview-container {
    display: none;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

#img-preview {
    height: 80px;
    border-radius: 0.4rem;
}

.remove-img {
    position: absolute;
    top: 0;
    right: 0;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
}

textarea#user-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    color: white;
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 200px;
    font-family: inherit;
    font-size: 1rem;
}

.input-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.5rem;
}

.tool-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.4rem;
    transition: background 0.2s;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

#send-btn {
    background: var(--accent-color);
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    color: white;
    font-weight: 600;
    cursor: pointer;
}

#stop-btn {
    background: #ef4444;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    color: white;
    font-weight: 600;
    cursor: pointer;
    display: none;
}

/* Auth/Profile Overlays same as before... */
#auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.auth-card {
    background: var(--sidebar-color);
    padding: 2.5rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 450px;
}

.auth-card h2 {
    margin: 0 0 1.5rem;
    font-family: 'Outfit';
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-full {
    grid-column: span 2;
}

.auth-card label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 0.4rem;
}

.auth-card input,
.auth-card select {
    width: 100%;
    padding: 0.75rem;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: white;
    box-sizing: border-box;
}

.auth-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--accent-color);
    border: none;
    border-radius: 0.5rem;
    color: white;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: #94a3b8;
}

.auth-switch a {
    color: var(--accent-color);
    text-decoration: none;
}

.error-msg {
    color: #ef4444;
    font-size: 0.8rem;
    margin-bottom: 1rem;
    display: none;
}

#voice-btn.recording {
    color: #ef4444;
    animation: pulse-red 1.5s infinite;
    background: rgba(239, 68, 68, 0.1);
}

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