* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-sidebar: #0f3460;
    --accent: #e94560;
    --text-primary: #eee;
    --text-secondary: #aaa;
    --msg-user: #0f3460;
    --msg-bot: #16213e;
    --input-bg: #16213e;
    --border: #2a2a4a;
    --radius: 12px;
}

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

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.chat-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

#btn-new-chat {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: opacity 0.2s;
}

#btn-new-chat:hover { opacity: 0.85; }

/* Body */
.chat-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 { font-size: 0.9rem; color: var(--text-secondary); }

#conversation-list {
    list-style: none;
    padding: 8px;
}

#conversation-list li {
    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 0.2s;
}

#conversation-list li:hover,
#conversation-list li.active {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

/* Main */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-msg {
    text-align: center;
    margin: auto;
    opacity: 0.7;
}

.welcome-msg h2 { margin-bottom: 8px; }

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.bot { align-self: flex-start; }

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

.message.user .avatar { background: var(--accent); }
.message.bot .avatar { background: var(--bg-sidebar); }

.message .content {
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.5;
    font-size: 0.92rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.message.user .content {
    background: var(--msg-user);
    border-bottom-right-radius: 4px;
}

.message.bot .content {
    background: var(--msg-bot);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Code blocks */
.message .content pre {
    background: #0d1117;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 0.85rem;
}

.message .content code {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
}

/* Typing indicator */
.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite;
}

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

/* Input */
.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within { border-color: var(--accent); }

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    resize: none;
    max-height: 150px;
    line-height: 1.5;
    outline: none;
    font-family: inherit;
}

#user-input::placeholder { color: var(--text-secondary); }

#btn-send {
    background: var(--accent);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

#btn-send:hover { opacity: 0.85; }
#btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .message { max-width: 95%; }
}
