/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #171717;
    --bg-tertiary: #212121;
    --bg-hover: #2a2a2a;
    --bg-active: #343434;
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --text-tertiary: #8e8e8e;
    --border: #2e2e2e;
    --accent: #10a37f;
    --accent-hover: #1a7f64;
    --user-bubble: #2f2f2f;
    --scrollbar: #3a3a3a;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
    --radius: 12px;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

body {
    display: flex;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 260px;
    height: 100%;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    transition: transform var(--transition), opacity var(--transition);
    flex-shrink: 0;
    z-index: 50;
}

.sidebar.hidden {
    transform: translateX(-100%);
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    padding: 12px;
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    transition: background var(--transition);
}
.new-chat-btn:hover { background: var(--bg-hover); }

.sidebar-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.conv-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background var(--transition), color var(--transition);
    margin-bottom: 2px;
}
.conv-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.conv-item.active { background: var(--bg-active); color: var(--text-primary); }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-footer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

/* ===== MAIN ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}

/* ===== TOP BAR ===== */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    flex-shrink: 0;
    height: 52px;
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: background var(--transition);
}
.menu-toggle:hover { background: var(--bg-hover); }

.model-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: default;
    color: var(--text-primary);
}

.model-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s infinite;
}

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

/* ===== CHAT AREA ===== */
.chat-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ===== WELCOME ===== */
.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 40px 20px;
}

.welcome.hidden { display: none; }

.logo-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #0ea5e9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 30px rgba(16, 163, 127, 0.3);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.welcome-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 600px;
    width: 100%;
}

.suggestion-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    text-align: left;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.suggestion-card:hover {
    background: var(--bg-hover);
    border-color: #444;
    color: var(--text-primary);
}

.suggestion-icon { font-size: 1.2rem; }

/* ===== MESSAGES ===== */
.messages {
    flex: 1;
    padding: 24px 0;
}

.message {
    padding: 12px 0;
    animation: fadeIn 0.3s ease;
}

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

.message-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 16px;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.message.user .message-avatar {
    background: #565869;
    color: white;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--accent), #0ea5e9);
    color: white;
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-sender {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-text p { margin-bottom: 12px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text code {
    background: var(--bg-active);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}
.message-text pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}
.message-text pre code {
    background: none;
    padding: 0;
}
.message-text ul, .message-text ol {
    padding-left: 24px;
    margin: 8px 0;
}
.message-text li { margin-bottom: 4px; }
.message-text strong { font-weight: 600; }
.message-text em { color: var(--text-secondary); }

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== INPUT AREA ===== */
.input-area {
    padding: 0 24px 20px;
    background: linear-gradient(180deg, transparent 0%, var(--bg-primary) 40%);
    flex-shrink: 0;
}

.input-wrapper {
    max-width: 720px;
    margin: 0 auto;
}

.input-container {
    position: relative;
    display: flex;
    align-items: flex-end;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
    padding: 4px;
}

.input-container:focus-within {
    border-color: #555;
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.15);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    outline: none;
    max-height: 200px;
    min-height: 24px;
    line-height: 1.5;
}

textarea::placeholder { color: var(--text-tertiary); }

.send-button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--text-primary);
    color: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition), transform var(--transition);
    flex-shrink: 0;
    margin: 2px;
}

.send-button:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.send-button:not(:disabled):hover {
    transform: scale(1.05);
}

.send-button:not(:disabled):active {
    transform: scale(0.95);
}

.disclaimer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-top: 10px;
    line-height: 1.4;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        opacity: 0;
        box-shadow: var(--shadow);
    }

    .sidebar.visible {
        transform: translateX(0);
        opacity: 1;
        pointer-events: all;
    }

    .suggestions {
        grid-template-columns: 1fr;
    }

    .message-inner {
        padding: 0 16px;
    }

    .input-area { padding: 0 12px 12px; }

    .welcome-title { font-size: 1.4rem; }
}
