:root {
  --bg-main: #131314;
  --bg-sidebar: #1e1f20;
  --bg-card: #282a2c;
  --text-primary: #e3e3e3;
  --text-secondary: #c4c7c5;
  --accent: #a8c7fa;
  --input-bg: #1e1f20;
  --border-color: #333538;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: "Segoe UI", Roboto, Helvetica, sans-serif; }
body { background-color: var(--bg-main); color: var(--text-primary); display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* Sidebar */
.sidebar { width: 260px; background-color: var(--bg-sidebar); display: flex; flex-direction: column; padding: 16px 12px; transition: margin-left 0.3s ease; flex-shrink: 0; }
.sidebar.closed { margin-left: -260px; }
.new-chat-btn { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 24px; background: var(--bg-card); color: var(--text-primary); border: none; cursor: pointer; font-weight: 500; font-size: 14px; transition: background 0.2s, opacity 0.2s; }
.new-chat-btn:hover:not(:disabled) { background: #37393b; }
.new-chat-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Main Container & Header */
.main-container { flex: 1; display: flex; flex-direction: column; height: 100vh; height: 100dvh; position: relative; }
header { padding: 14px 20px; display: flex; align-items: center; gap: 16px; }
.toggle-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 20px; padding: 6px; border-radius: 50%; }
.toggle-btn:hover { background: var(--bg-card); }
.app-title { font-size: 18px; font-weight: 600; background: linear-gradient(90deg, #4b90ff, #ff5546); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.model-select { margin-left: auto; padding: 8px 12px; border-radius: 8px; background: var(--input-bg); color: var(--text-primary); border: 1px solid var(--border-color); outline: none; font-size: 14px; cursor: pointer; }

/* Chat Area */
.chat-area { flex: 1; overflow-y: auto; padding: 0 20px 150px 20px; display: flex; flex-direction: column; align-items: center; }
.chat-wrapper { width: 100%; max-width: 800px; display: flex; flex-direction: column; gap: 28px; margin-top: 20px; }
.welcome-screen { text-align: center; margin-top: 15vh; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.welcome-screen h1 { font-size: 40px; font-weight: 500; background: linear-gradient(90deg, #4b90ff, #d96570); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.welcome-screen p { color: var(--text-secondary); font-size: 16px; }

/* Message Bubbles */
.message-row { display: flex; gap: 16px; width: 100%; }
.message-row.user { justify-content: flex-end; }
.user-bubble { background: var(--bg-card); padding: 12px 20px; border-radius: 20px; border-top-right-radius: 4px; max-width: 75%; font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.ai-icon { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #4b90ff, #d96570); color: #fff; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; margin-top: 2px; }
.assistant-content { flex: 1; font-size: 15px; line-height: 1.7; color: var(--text-primary); overflow-x: hidden; }
.assistant-content pre { background: #1a1b1c; padding: 16px; border-radius: 12px; overflow-x: auto; margin: 12px 0; border: 1px solid var(--border-color); }
.assistant-content code { font-family: "Consolas", monospace; font-size: 14px; }
.assistant-content p { margin-bottom: 12px; }

/* Input Section */
.input-section { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(180deg, transparent 0%, var(--bg-main) 35%); padding: 20px; display: flex; flex-direction: column; align-items: center; }
.input-box { width: 100%; max-width: 800px; background-color: var(--input-bg); border-radius: 28px; padding: 12px 20px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--border-color); transition: border-color 0.2s; }
.input-box:focus-within { border-color: #55585c; }
textarea { flex: 1; background: transparent; border: none; color: var(--text-primary); font-size: 15px; resize: none; outline: none; max-height: 150px; height: 24px; line-height: 24px; }
.send-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; transition: color 0.2s, background 0.2s; }
.send-btn:hover:not(:disabled) { color: var(--accent); background: rgba(168, 199, 250, 0.1); }
.send-btn:disabled { color: #444746; cursor: not-allowed; }
.footer-note { font-size: 12px; color: var(--text-secondary); margin-top: 10px; text-align: center; }
/* Lịch sử chat */
.history-title { font-size: 12px; color: var(--text-secondary); padding: 20px 12px 6px; }
.history-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 20px; cursor: pointer; font-size: 14px; }
.history-item:hover { background: var(--bg-card); }
.history-item.active { background: rgba(168, 199, 250, 0.15); }
.history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-del { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 14px; opacity: 0; flex-shrink: 0; }
.history-item:hover .history-del { opacity: 1; }
.history-del:hover { color: #ff6b6b; }
@media (hover: none) { .history-del { opacity: 0.6; } }

/* Tệp đính kèm */
.attach-btn { background: none; border: none; cursor: pointer; font-size: 18px; width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.attach-btn:hover:not(:disabled) { background: rgba(168, 199, 250, 0.1); }
.attach-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.file-chips { width: 100%; max-width: 800px; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.file-chips:empty { display: none; }
.file-chip { display: flex; align-items: center; gap: 8px; background: var(--bg-card); padding: 6px 12px; border-radius: 16px; font-size: 13px; max-width: 240px; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { background: none; border: none; color: var(--text-secondary); cursor: pointer; }
.bubble-files { font-size: 13px; color: var(--accent); margin-bottom: 6px; }