/* Cấu hình màu sắc biến động theo Theme */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-sidebar: #f3f4f6;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --chat-user-bg: #3b82f6;
    --chat-user-text: #ffffff;
    --chat-ai-bg: #f3f4f6;
    --chat-ai-text: #1f2937;
}

.dark {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-sidebar: #0f172a;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --chat-user-bg: #2563eb;
    --chat-user-text: #ffffff;
    --chat-ai-bg: #1f2937;
    --chat-ai-text: #e5e7eb;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Sidebar Styling */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
}

.sidebar-item {
    transition: all 0.2s;
    border: 1px solid transparent;
}

.sidebar-item:hover {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

.sidebar-item.active {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    font-weight: 600;
}

/* Chat Bubbles - Khắc phục lỗi tràn văn bản */
.message-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    margin-bottom: 12px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word; /* Chống tràn text */
    overflow-wrap: anywhere; /* Chống tràn text mạnh mẽ */
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message-user {
    background-color: var(--chat-user-bg);
    color: var(--chat-user-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

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

/* Progress Blinker */
.typing-cursor {
    display: inline-block;
    width: 10px;
    height: 18px;
    background-color: var(--text-main);
    margin-left: 4px;
    animation: blink 1s infinite;
    vertical-align: middle;
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #888; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* Code blocks trong Markdown */
pre {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

code {
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
}

/* Error UI */
.error-status {
    color: #ef4444;
    font-weight: bold;
    font-size: 13px;
    text-align: center;
    padding: 10px;
    background: #fef2f2;
    border: 1px solid #fee2e2;
    border-radius: 8px;
    margin: 10px 0;
}
.dark .error-status {
    background: #450a0a;
    border-color: #7f1d1d;
}
