/* ============================================
   ARIA — THEMES (4 giao diện) + UI Controls
   → Tím Đêm (obsidian), Dương Đêm (ocean), Xám Sáng (light), Xanh Dương Sáng (sky)
   Chữ trong mọi theme được đẩy độ tương phản để luôn đọc rõ trên nền.
   Load sau styles.css để ghi đè design tokens
   ============================================ */

/* ── Theme 1: OBSIDIAN (tím đêm) ── */
html[data-theme="obsidian"] {
    --bg-0: #0a0d14; --bg-1: #0f1117; --bg-2: #161b27; --bg-3: #1e2535;
    --surface: rgba(255, 255, 255, 0.04); --surface-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(139, 92, 246, 0.2); --border-light: rgba(255, 255, 255, 0.07);
    --accent: #7c3aed; --accent-bright: #8b5cf6; --accent-light: #a78bfa; --accent-pale: #c4b5fd;
    --accent-glow: rgba(139, 92, 246, 0.25); --accent-subtle: rgba(139, 92, 246, 0.08);
    --text: #f1f5f9; --text-muted: #b6c2d4; --text-faint: #7d8da3;
}

/* ── Theme 2: OCEAN (dương đêm — xanh biển) ── */
html[data-theme="ocean"] {
    --bg-0: #081018; --bg-1: #0b1622; --bg-2: #0f1f30; --bg-3: #16293f;
    --surface: rgba(255, 255, 255, 0.04); --surface-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(56, 189, 248, 0.2); --border-light: rgba(255, 255, 255, 0.07);
    --accent: #0ea5e9; --accent-bright: #38bdf8; --accent-light: #7dd3fc; --accent-pale: #bae6fd;
    --accent-glow: rgba(56, 189, 248, 0.25); --accent-subtle: rgba(14, 165, 233, 0.08);
    --cyan: #22d3ee; --cyan-subtle: rgba(34, 211, 238, 0.1);
    --text: #e8f6ff; --text-muted: #aac6dc; --text-faint: #7b95aa;
}

/* ── Theme 3: LIGHT (xám sáng — light mode) ── */
html[data-theme="light"] {
    --bg-0: #f7f8fa; --bg-1: #eef1f5; --bg-2: #e2e7ee; --bg-3: #d3dae4;
    --surface: rgba(15, 23, 42, 0.04); --surface-hover: rgba(15, 23, 42, 0.08);
    --border: rgba(124, 58, 237, 0.18); --border-light: rgba(15, 23, 42, 0.09);
    --accent: #7c3aed; --accent-bright: #6d28d9; --accent-light: #8b5cf6; --accent-pale: #a78bfa;
    --accent-glow: rgba(124, 58, 237, 0.16); --accent-subtle: rgba(124, 58, 237, 0.07);
    --cyan: #0891b2; --cyan-subtle: rgba(8, 145, 178, 0.1);
    --green: #059669; --green-subtle: rgba(5, 150, 105, 0.1);
    --text: #0b1220; --text-muted: #334155; --text-faint: #5c6b7f;
}

/* ── Theme 4: SKY (xanh dương sáng — MẶC ĐỊNH, nền sáng, chữ navy đậm, accent xanh dương) ── */
html[data-theme="sky"] {
    --bg-0: #eaf3fc; --bg-1: #f5faff; --bg-2: #dcebf9; --bg-3: #cadff4;
    --surface: rgba(2, 132, 199, 0.06); --surface-hover: rgba(2, 132, 199, 0.12);
    --border: rgba(2, 132, 199, 0.24); --border-light: rgba(2, 132, 199, 0.14);
    --accent: #0284c7; --accent-bright: #0369a1; --accent-light: #0ea5e9; --accent-pale: #38bdf8;
    --accent-glow: rgba(2, 132, 199, 0.22); --accent-subtle: rgba(2, 132, 199, 0.09);
    --cyan: #0891b2; --cyan-subtle: rgba(8, 145, 178, 0.1);
    --green: #059669; --green-subtle: rgba(5, 150, 105, 0.1);
    --text: #0a2540; --text-muted: #35618a; --text-faint: #517b9c;
}

/* ── UI CONTROLS: ngôn ngữ + theme ── */
.ui-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-toggle {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
}
.lang-toggle button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    cursor: pointer;
    transition: all var(--t);
    font-family: inherit;
}
.lang-toggle button.active {
    background: var(--accent);
    color: #fff;
}
.lang-toggle button:not(.active):hover { color: var(--text); }

.theme-menu {
    position: relative;
}
.theme-btn {
    background: var(--surface);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--t);
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }

.theme-dropdown {
    position: absolute;
    top: 40px;
    right: 0;
    background: var(--bg-1);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 6px;
    min-width: 170px;
    display: none;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    z-index: 1000;
}
.theme-dropdown.open { display: flex; }
.theme-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--t);
}
.theme-dropdown button:hover { background: var(--surface-hover); color: var(--text); }
.theme-dropdown button.active {
    background: var(--accent-subtle);
    color: var(--accent-bright);
    font-weight: 600;
}
.theme-dropdown .swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Settings modal: chọn theme & ngôn ngữ ── */
.pref-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.pref-group {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 14px;
}
.pref-group h4 {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}
.pref-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pref-option {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    padding: 7px 10px;
    cursor: pointer;
    transition: all var(--t);
}
.pref-option:hover { color: var(--text); border-color: var(--accent); }
.pref-option.active {
    color: var(--accent-bright);
    border-color: var(--accent);
    background: var(--accent-subtle);
    font-weight: 600;
}

/* ── Settings modal: chọn avatar trợ lý (8 avatar có sẵn) ── */
.pref-group.avatar-group { grid-column: 1 / -1; }
.pref-options.avatar-options {
    flex-direction: row;
    flex-wrap: wrap;
}
.pref-option.avatar-pick {
    flex: 0 0 auto;
    padding: 6px 10px 6px 6px;
}
.avatar-thumb {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}

/* ============================================
   ĐỘ TƯƠNG PHẢN CHO THEME NỀN SÁNG (light, sky)
   Nền sáng khiến #0ea5e9 / #38bdf8 (accent-light) quá nhạt khi làm CHỮ hoặc chữ trắng
   trên nền accent → đổi sang --accent-bright (đậm hơn, ≥ 4.5:1).
   ============================================ */
html[data-theme="light"] .lang-toggle button.active,
html[data-theme="sky"]   .lang-toggle button.active,
html[data-theme="light"] .tab-badge,
html[data-theme="sky"]   .tab-badge,
html[data-theme="light"] .lt-btn.lt-primary,
html[data-theme="sky"]   .lt-btn.lt-primary {
    background: var(--accent-bright);
    color: #fff;
}
html[data-theme="light"] .tab.active,
html[data-theme="sky"]   .tab.active { color: var(--accent-bright); }

html[data-theme="light"] a,
html[data-theme="sky"]   a { color: var(--accent-bright); }

/* Thanh cuộn nhìn thấy được trên nền sáng (styles.css dùng màu trắng cho nền tối) */
html[data-theme="light"] ::-webkit-scrollbar-thumb,
html[data-theme="sky"]   ::-webkit-scrollbar-thumb { background: rgba(2, 132, 199, 0.35); }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover,
html[data-theme="sky"]   ::-webkit-scrollbar-thumb:hover { background: rgba(2, 132, 199, 0.5); }
html[data-theme="light"] *,
html[data-theme="sky"]   * { scrollbar-color: rgba(2, 132, 199, 0.4) transparent; }

/* Dropdown giao diện: bóng đổ nhẹ cho nền sáng */
html[data-theme="light"] .theme-dropdown,
html[data-theme="sky"]   .theme-dropdown { box-shadow: 0 12px 32px rgba(2, 132, 199, 0.22); }
