/* ================================================================
   RealConnect — Theme System v2
   10 themes: 5 sáng + 5 tối
   Đồng bộ với toàn bộ biến trong style.css
   ================================================================ */

/* ----------------------------------------------------------------
   BASE: Thêm biến --nav-bg, --orb1-color, --orb2-color, --card-hover
   vào mọi theme để override giá trị hardcode trong style.css
   ---------------------------------------------------------------- */

/* ════════════════════════════════════════════════════════════════
   🌑 DARK THEMES
   ════════════════════════════════════════════════════════════════ */

/* ── 1. Indigo Night (mặc định) ──────────────────────────────── */
[data-theme="dark-indigo"] {
    --bg:          #080c16;
    --bg2:         #0d1120;
    --card:        rgba(255,255,255,0.04);
    --glass:       rgba(255,255,255,0.06);
    --border:      rgba(255,255,255,0.10);
    --border2:     rgba(255,255,255,0.06);
    --accent:      #6366f1;
    --accent2:     #10b981;
    --accent3:     #f59e0b;
    --glow:        rgba(99,102,241,0.30);
    --glow2:       rgba(16,185,129,0.20);
    --text:        #e8eaf6;
    --text2:       #9496b0;
    --text3:       #5c5e78;
    --danger:      #f43f5e;
    --success:     #10b981;
    --warn:        #f59e0b;
    --nav-bg:      rgba(8,12,22,0.90);
    --orb1:        rgba(99,102,241,0.18);
    --orb2:        rgba(16,185,129,0.12);
    --grid-color:  rgba(99,102,241,0.05);
    --scrollbar:   rgba(99,102,241,0.35);
}

/* ── 2. Midnight Blue ────────────────────────────────────────── */
[data-theme="dark-midnight"] {
    --bg:          #050912;
    --bg2:         #0a1020;
    --card:        rgba(255,255,255,0.04);
    --glass:       rgba(255,255,255,0.06);
    --border:      rgba(148,180,255,0.12);
    --border2:     rgba(148,180,255,0.07);
    --accent:      #3b82f6;
    --accent2:     #22d3ee;
    --accent3:     #a78bfa;
    --glow:        rgba(59,130,246,0.30);
    --glow2:       rgba(34,211,238,0.20);
    --text:        #dde8ff;
    --text2:       #7f9abf;
    --text3:       #445566;
    --danger:      #f87171;
    --success:     #34d399;
    --warn:        #fbbf24;
    --nav-bg:      rgba(5,9,18,0.92);
    --orb1:        rgba(59,130,246,0.15);
    --orb2:        rgba(34,211,238,0.10);
    --grid-color:  rgba(59,130,246,0.05);
    --scrollbar:   rgba(59,130,246,0.35);
}

/* ── 3. Dark Forest ──────────────────────────────────────────── */
[data-theme="dark-forest"] {
    --bg:          #060f0b;
    --bg2:         #0a1810;
    --card:        rgba(255,255,255,0.04);
    --glass:       rgba(255,255,255,0.06);
    --border:      rgba(52,211,153,0.14);
    --border2:     rgba(52,211,153,0.07);
    --accent:      #10b981;
    --accent2:     #34d399;
    --accent3:     #f59e0b;
    --glow:        rgba(16,185,129,0.28);
    --glow2:       rgba(52,211,153,0.20);
    --text:        #d4f1e6;
    --text2:       #6aad8e;
    --text3:       #3a6654;
    --danger:      #f87171;
    --success:     #34d399;
    --warn:        #fbbf24;
    --nav-bg:      rgba(6,15,11,0.92);
    --orb1:        rgba(16,185,129,0.15);
    --orb2:        rgba(52,211,153,0.10);
    --grid-color:  rgba(16,185,129,0.05);
    --scrollbar:   rgba(16,185,129,0.35);
}

/* ── 4. Dark Coffee ──────────────────────────────────────────── */
[data-theme="dark-coffee"] {
    --bg:          #100a06;
    --bg2:         #1a1008;
    --card:        rgba(255,255,255,0.05);
    --glass:       rgba(255,255,255,0.06);
    --border:      rgba(217,119,6,0.18);
    --border2:     rgba(217,119,6,0.09);
    --accent:      #f59e0b;
    --accent2:     #fb923c;
    --accent3:     #a78bfa;
    --glow:        rgba(245,158,11,0.28);
    --glow2:       rgba(251,146,60,0.20);
    --text:        #fdf0e0;
    --text2:       #c09060;
    --text3:       #7a5a38;
    --danger:      #f87171;
    --success:     #34d399;
    --warn:        #fbbf24;
    --nav-bg:      rgba(16,10,6,0.92);
    --orb1:        rgba(245,158,11,0.15);
    --orb2:        rgba(251,146,60,0.10);
    --grid-color:  rgba(245,158,11,0.05);
    --scrollbar:   rgba(245,158,11,0.35);
}

/* ── 5. Dark Grape ───────────────────────────────────────────── */
[data-theme="dark-grape"] {
    --bg:          #0d0512;
    --bg2:         #160920;
    --card:        rgba(255,255,255,0.04);
    --glass:       rgba(255,255,255,0.06);
    --border:      rgba(192,132,252,0.14);
    --border2:     rgba(192,132,252,0.07);
    --accent:      #a855f7;
    --accent2:     #ec4899;
    --accent3:     #38bdf8;
    --glow:        rgba(168,85,247,0.28);
    --glow2:       rgba(236,72,153,0.20);
    --text:        #eedeff;
    --text2:       #9a7ab8;
    --text3:       #5a3a7a;
    --danger:      #f87171;
    --success:     #34d399;
    --warn:        #fbbf24;
    --nav-bg:      rgba(13,5,18,0.92);
    --orb1:        rgba(168,85,247,0.16);
    --orb2:        rgba(236,72,153,0.12);
    --grid-color:  rgba(168,85,247,0.05);
    --scrollbar:   rgba(168,85,247,0.35);
}

/* ════════════════════════════════════════════════════════════════
   ☀️ LIGHT THEMES
   ════════════════════════════════════════════════════════════════ */

/* ── 6. Snow White (Trắng tinh) ──────────────────────────────── */
[data-theme="light-snow"] {
    --bg:          #f8faff;
    --bg2:         #eef2ff;
    --card:        #ffffff;
    --glass:       rgba(99,102,241,0.05);
    --border:      rgba(99,102,241,0.18);
    --border2:     rgba(99,102,241,0.09);
    --accent:      #4f46e5;
    --accent2:     #059669;
    --accent3:     #d97706;
    --glow:        rgba(79,70,229,0.20);
    --glow2:       rgba(5,150,105,0.15);
    --text:        #0f0e1a;
    --text2:       #3d3b52;
    --text3:       #9090a8;
    --danger:      #dc2626;
    --success:     #059669;
    --warn:        #d97706;
    --nav-bg:      rgba(248,250,255,0.95);
    --orb1:        rgba(99,102,241,0.08);
    --orb2:        rgba(16,185,129,0.06);
    --grid-color:  rgba(99,102,241,0.06);
    --scrollbar:   rgba(79,70,229,0.30);
}

/* ── 7. Warm Linen (Kem ấm) ──────────────────────────────────── */
[data-theme="light-linen"] {
    --bg:          #fdf7ee;
    --bg2:         #f5ece0;
    --card:        #fffcf7;
    --glass:       rgba(180,100,20,0.06);
    --border:      rgba(180,100,20,0.18);
    --border2:     rgba(180,100,20,0.10);
    --accent:      #c2410c;
    --accent2:     #15803d;
    --accent3:     #b45309;
    --glow:        rgba(194,65,12,0.18);
    --glow2:       rgba(21,128,61,0.15);
    --text:        #1a0d00;
    --text2:       #5c3a1e;
    --text3:       #a07850;
    --danger:      #dc2626;
    --success:     #15803d;
    --warn:        #b45309;
    --nav-bg:      rgba(253,247,238,0.97);
    --orb1:        rgba(194,65,12,0.08);
    --orb2:        rgba(21,128,61,0.06);
    --grid-color:  rgba(180,100,20,0.06);
    --scrollbar:   rgba(194,65,12,0.28);
}

/* ── 8. Sky Blue (Xanh trời) ─────────────────────────────────── */
[data-theme="light-sky"] {
    --bg:          #f0f9ff;
    --bg2:         #e0f2fe;
    --card:        #ffffff;
    --glass:       rgba(2,132,199,0.06);
    --border:      rgba(2,132,199,0.20);
    --border2:     rgba(2,132,199,0.10);
    --accent:      #0369a1;
    --accent2:     #059669;
    --accent3:     #ea580c;
    --glow:        rgba(3,105,161,0.20);
    --glow2:       rgba(5,150,105,0.15);
    --text:        #0c1a26;
    --text2:       #1e5070;
    --text3:       #7ab0cc;
    --danger:      #dc2626;
    --success:     #059669;
    --warn:        #ea580c;
    --nav-bg:      rgba(240,249,255,0.97);
    --orb1:        rgba(3,105,161,0.10);
    --orb2:        rgba(5,150,105,0.07);
    --grid-color:  rgba(2,132,199,0.07);
    --scrollbar:   rgba(3,105,161,0.30);
}

/* ── 9. Sage Green (Xanh lá nhạt) ───────────────────────────── */
[data-theme="light-sage"] {
    --bg:          #f0fdf6;
    --bg2:         #dcfce7;
    --card:        #ffffff;
    --glass:       rgba(5,150,105,0.06);
    --border:      rgba(5,150,105,0.20);
    --border2:     rgba(5,150,105,0.10);
    --accent:      #047857;
    --accent2:     #7c3aed;
    --accent3:     #d97706;
    --glow:        rgba(4,120,87,0.20);
    --glow2:       rgba(124,58,237,0.15);
    --text:        #052e16;
    --text2:       #1a5c3a;
    --text3:       #6aaa80;
    --danger:      #dc2626;
    --success:     #047857;
    --warn:        #d97706;
    --nav-bg:      rgba(240,253,246,0.97);
    --orb1:        rgba(4,120,87,0.10);
    --orb2:        rgba(124,58,237,0.07);
    --grid-color:  rgba(5,150,105,0.07);
    --scrollbar:   rgba(4,120,87,0.30);
}

/* ── 10. Rose Petal (Hồng thanh lịch) ───────────────────────── */
[data-theme="light-rose"] {
    --bg:          #fff5f7;
    --bg2:         #fce7eb;
    --card:        #ffffff;
    --glass:       rgba(190,18,60,0.05);
    --border:      rgba(190,18,60,0.18);
    --border2:     rgba(190,18,60,0.09);
    --accent:      #be123c;
    --accent2:     #7c3aed;
    --accent3:     #c2410c;
    --glow:        rgba(190,18,60,0.18);
    --glow2:       rgba(124,58,237,0.15);
    --text:        #1a0008;
    --text2:       #6b1530;
    --text3:       #c08090;
    --danger:      #dc2626;
    --success:     #059669;
    --warn:        #c2410c;
    --nav-bg:      rgba(255,245,247,0.97);
    --orb1:        rgba(190,18,60,0.08);
    --orb2:        rgba(124,58,237,0.06);
    --grid-color:  rgba(190,18,60,0.06);
    --scrollbar:   rgba(190,18,60,0.28);
}

/* ================================================================
   OVERRIDES: apply --nav-bg, grid/orb colors, light-mode fixes
   ================================================================ */

/* Topnav background */
[data-theme] .topnav {
    background: var(--nav-bg);
}

/* bg-grid màu theo theme */
[data-theme] .bg-grid {
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 64px 64px;
}

/* Orb colors theo theme */
[data-theme] .orb1 { background: radial-gradient(circle, var(--orb1), transparent 70%); }
[data-theme] .orb2 { background: radial-gradient(circle, var(--orb2), transparent 70%); }
[data-theme] .orb3 { background: radial-gradient(circle, var(--orb1), transparent 70%); opacity: 0.6; }

/* Scrollbar theo theme */
[data-theme] ::-webkit-scrollbar-thumb { background: var(--scrollbar); }

/* ── Light themes: body + card + hover overrides ──────────────── */
[data-theme^="light"] {
    color-scheme: light;
}
[data-theme^="light"] body {
    background: var(--bg);
    color: var(--text);
}
[data-theme^="light"] .bg-noise  { opacity: 0.2; }
[data-theme^="light"] .bg-orb    { opacity: 0.5; }

/* Card: nền trắng, đổ bóng nhẹ */
[data-theme^="light"] .card {
    background: var(--card);
    box-shadow: 0 1px 12px rgba(0,0,0,0.07), 0 0 0 1px var(--border2);
}
[data-theme^="light"] .card:hover {
    border-color: var(--border) !important;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

/* Post card */
[data-theme^="light"] .post-card {
    background: var(--card);
    box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}
[data-theme^="light"] .post-card:hover {
    background: var(--glass);
    border-color: var(--border) !important;
}

/* btn-ghost */
[data-theme^="light"] .btn-ghost {
    background: var(--glass);
    color: var(--text2);
    border-color: var(--border);
}
[data-theme^="light"] .btn-ghost:hover {
    background: var(--border);
    color: var(--text);
}

/* user-chip */
[data-theme^="light"] .user-chip { background: var(--glass); border-color: var(--border); }
[data-theme^="light"] .user-chip:hover { background: var(--border); }

/* nav links */
[data-theme^="light"] .nav-link { color: var(--text2); }
[data-theme^="light"] .nav-link:hover,
[data-theme^="light"] .nav-link.active { color: var(--text); background: var(--glass); }
[data-theme^="light"] .nav-link.active { color: var(--accent); }

/* Field wrap */
[data-theme^="light"] .field-wrap { background: var(--glass); }
[data-theme^="light"] .field-wrap:focus-within { background: rgba(255,255,255,0.9); }

/* Tags */
[data-theme^="light"] .tag {
    background: var(--glass);
    border-color: var(--border2);
    color: var(--text2);
}
[data-theme^="light"] .tag:hover { color: var(--accent); border-color: var(--border); }

/* Sort btn / filter btn */
[data-theme^="light"] .sort-btn,
[data-theme^="light"] .type-btn,
[data-theme^="light"] .cat-pill {
    background: var(--glass);
    border-color: var(--border2);
    color: var(--text2);
}
[data-theme^="light"] .sort-btn:hover,
[data-theme^="light"] .type-btn:hover,
[data-theme^="light"] .cat-pill:hover,
[data-theme^="light"] .sort-btn.active,
[data-theme^="light"] .type-btn.active,
[data-theme^="light"] .cat-pill.active {
    background: rgba(255,255,255,0.8);
    color: var(--accent);
    border-color: var(--border);
}

/* Page btn */
[data-theme^="light"] .page-btn { background: var(--card); border-color: var(--border); color: var(--text2); }
[data-theme^="light"] .page-btn:hover,
[data-theme^="light"] .page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Scrollbar track */
[data-theme^="light"] ::-webkit-scrollbar-track { background: var(--bg2); }

/* Topnav shadow cho light */
[data-theme^="light"] .topnav {
    box-shadow: 0 1px 16px rgba(0,0,0,0.08);
    border-bottom-color: var(--border2);
}

/* Logo text */
[data-theme^="light"] .nav-logo-text { color: var(--text); }

/* Search input */
[data-theme^="light"] .search-input {
    background: var(--card);
    border-color: var(--border);
    color: var(--text);
}
[data-theme^="light"] .search-input:focus { border-color: var(--accent); }

/* ================================================================
   THEME SWITCHER WIDGET — Thiết kế lại đẹp hơn
   ================================================================ */
.theme-switcher {
    position: fixed;
    bottom: 28px; right: 28px;
    z-index: 9999;
}

/* FAB button */
.theme-fab {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none; cursor: pointer;
    font-size: 20px;
    box-shadow: 0 6px 24px var(--glow), 0 2px 8px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
    position: relative; z-index: 2;
}
.theme-fab:hover { transform: scale(1.12) rotate(15deg); }

/* Panel */
.theme-panel {
    position: absolute;
    bottom: 60px; right: 0;
    width: 280px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25), 0 0 0 1px var(--border2);
    display: none;
    transform-origin: bottom right;
}
.theme-panel.open {
    display: block;
    animation: panelIn 0.22s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes panelIn {
    from { opacity:0; transform: scale(0.8) translateY(12px); }
    to   { opacity:1; transform: scale(1) translateY(0); }
}

.theme-panel-title {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    font-size: 13px; font-weight: 700;
    color: var(--text2);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border2);
    display: flex; align-items: center; gap: 7px;
}

/* Section labels */
.theme-section-label {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: var(--text3);
    margin: 12px 0 8px;
}
.theme-section-label:first-of-type { margin-top: 0; }

/* Theme grid */
.theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.theme-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1.5px solid var(--border2);
    background: var(--glass);
    cursor: pointer;
    transition: all 0.18s;
    text-align: left;
}
.theme-btn:hover {
    border-color: var(--border);
    background: var(--card);
    transform: translateY(-1px);
}
.theme-btn.active {
    border-color: var(--accent) !important;
    background: var(--glass) !important;
    box-shadow: 0 0 0 2px var(--glow);
}
.theme-btn.active .theme-btn-name { color: var(--accent); }

/* Color swatch */
.theme-swatch {
    width: 28px; height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
    border: 1.5px solid rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
}
.theme-swatch::after {
    content: '';
    position: absolute; top: 0; left: 50%; right: 0; bottom: 0;
}

.theme-btn-info { flex: 1; min-width: 0; }
.theme-btn-name {
    font-size: 12px; font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.theme-btn-type {
    font-size: 10px; color: var(--text3);
    margin-top: 1px;
}

/* Check mark cho active */
.theme-btn-check {
    font-size: 13px; flex-shrink: 0;
    opacity: 0; transition: opacity 0.15s;
}
.theme-btn.active .theme-btn-check { opacity: 1; }
