/* ============================================================
   finwealth-theme.css — Single source of truth cho toàn hệ thống
   Phải load TRƯỚC mọi CSS khác (sau Bootstrap).
   ============================================================ */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Light Mode (default / :root) ── */
/* Triết lý: Nền xám mát + text đen neutral + tím chỉ dùng cho ACCENT */
:root {
    --fw-base:           #e2e8f0;   /* Xám slate đậm hơn để nổi rõ nền trắng của các thẻ */
    --fw-card:           #ffffff;
    --fw-card-alt:       #f1f5f9;   /* Nền phụ xám nhạt thay vì tím mờ */
    --fw-sidebar:        #f8fafc;   /* Slate-50 sạch sẽ, tương phản tốt hơn */

    --fw-text-primary:   #0f172a;   /* Slate-900 — đọc số liệu crisp */
    --fw-text-secondary: #1e293b;   /* Slate-800 — Tăng độ đậm */
    --fw-text-muted:     #475569;   /* Slate-600 — Đậm hơn thay vì 500 */

    /* Màu nhấn rực rỡ và đậm hơn */
    --fw-accent-purple:  #6d28d9;   /* purple-700 (đậm hơn 600) */
    --fw-accent-blue:    #1d4ed8;   /* blue-700 */
    --fw-accent-emerald: #047857;   /* emerald-700 */
    --fw-accent-amber:   #b45309;   /* amber-700 */
    --fw-accent-cyan:    #0e7490;   /* cyan-700 */
    --fw-accent-rose:    #be123c;   /* rose-700 */

    --fw-border:         rgba(15, 23, 42, 0.15); /* Viền rõ nét hơn */
    --fw-shadow:         0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 10px 25px rgba(109, 40, 217, 0.1);
}

/* ── Dark Mode ── */
html.dark {
    /* 4 mức nền rõ ràng: base → sidebar → card → card-alt (mỗi bước ~4-5% lightness) */
    --fw-base:           #0a0c14;   /* Level 0: nền trang, sâu nhất */
    --fw-sidebar:        #0f1422;   /* Level 1: sidebar / panel phụ */
    --fw-card:           #161e30;   /* Level 2: card nổi rõ khỏi nền */
    --fw-card-alt:       #1c2640;   /* Level 3: header/footer card, row hover */

    --fw-text-primary:   #eef2ff;   /* Hơi blue-tint, dễ đọc trên nền tối */
    --fw-text-secondary: #b8c8e0;   /* Brighter than before */
    --fw-text-muted:     #8fa3c8;   /* was #64748b — contrast ratio ~4.6:1, pass WCAG AA */

    /* Semantic roles — mỗi màu 1 vai trò duy nhất, KHÔNG dùng lẫn lộn:
       purple = AI / premium / CTA chính
       emerald = tín hiệu tích cực / tăng
       rose    = rủi ro / giảm / cảnh báo đỏ
       amber   = thận trọng / trung tính cảnh báo
       blue    = dữ liệu / biểu đồ / phân tích
       cyan    = thông tin phụ / link */
    --fw-accent-purple:  #a78bfa;   /* AI/premium: sáng hơn c084fc, tương phản tốt hơn */
    --fw-accent-blue:    #60a5fa;
    --fw-accent-emerald: #34d399;
    --fw-accent-amber:   #fbbf24;
    --fw-accent-cyan:    #22d3ee;
    --fw-accent-rose:    #fb7185;

    --fw-border:         rgba(255, 255, 255, 0.08);  /* was 0.05 — viền card nhìn thấy rõ hơn */
    --fw-shadow:         0 1px 3px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3); /* card nổi khỏi nền */
}

/* ── Global Reset ── */
body {
    font-family: 'Inter', 'Be Vietnam Pro', sans-serif;
    background-color: var(--fw-base);
    color: var(--fw-text-primary);
}

/* ── Theme Transition (300ms smooth) ── */
html.transition-colors *,
html.transition-colors *::before,
html.transition-colors *::after {
    transition-property: background-color, border-color, color, fill, stroke !important;
    transition-duration: 300ms !important;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ── Utility Classes (.fw-*) ── */
.fw-base     { background-color: var(--fw-base); }
.fw-card     { background-color: var(--fw-card); box-shadow: var(--fw-shadow); }
.fw-card-alt { background-color: var(--fw-card-alt); }
.fw-sidebar  { background-color: var(--fw-sidebar); }
.fw-ring-base    { border-color: var(--fw-base) !important; }
.fw-ring-sidebar { border-color: var(--fw-sidebar) !important; }

/* Zone 1 gradient */
.fw-zone1-grad {
    background: linear-gradient(135deg, #0e1022 0%, #0c0f1d 60%, #0d0f1a 100%);
}
html:not(.dark) .fw-zone1-grad {
    background: linear-gradient(135deg, #f8f7fc 0%, #eef2ff 60%, #e0e7ff 100%);
    border-color: rgba(124,58,237,0.15) !important;
}

/* ── Glassmorphism ── */
.glass {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
html:not(.dark) .glass {
    background: rgba(255, 255, 255, 0.85);
}

/* ── Shine hover effect ── */
.shine { position: relative; overflow: hidden; }
.shine::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
    transform: rotate(45deg);
    transition: 0.6s;
}
.shine:hover::after { left: 100%; top: 100%; }

/* ── fadeIn animation ── */
@keyframes fw-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fw-fadeIn 0.4s ease forwards; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2d3748; border-radius: 10px; }
html:not(.dark) ::-webkit-scrollbar-thumb { background: #cbd5e1; }
.hide-scroll::-webkit-scrollbar { display: none; }
.hide-scroll { -ms-overflow-style: none; scrollbar-width: none; }

/* ══════════════════════════════════════════
   WealthScore Tab Active States
   Dùng chung ở cả dark và light
   ══════════════════════════════════════════ */
.tab-has-signal   { background: rgba(244,63,94,0.15);  color: #fb7185; border-color: rgba(244,63,94,0.3); }
.tab-golden   { background: rgba(168,85,247,0.15); color: #c084fc; border-color: rgba(168,85,247,0.3); }
.tab-wave     { background: rgba(16,185,129,0.15);  color: #34d399; border-color: rgba(16,185,129,0.3); }
.tab-value    { background: rgba(59,130,246,0.15);  color: #60a5fa; border-color: rgba(59,130,246,0.3); }
.tab-inactive { background: rgba(255,255,255,0.04); color: #64748b; border-color: rgba(255,255,255,0.08); }

html:not(.dark) .tab-has-signal   { background: rgba(225,29,72,0.10);   color: #e11d48; border-color: rgba(225,29,72,0.25); }
html:not(.dark) .tab-golden   { background: rgba(124,58,237,0.10);  color: #7c3aed; border-color: rgba(124,58,237,0.25); }
html:not(.dark) .tab-wave     { background: rgba(5,150,105,0.10);   color: #059669; border-color: rgba(5,150,105,0.25); }
html:not(.dark) .tab-value    { background: rgba(37,99,235,0.10);   color: #2563eb; border-color: rgba(37,99,235,0.25); }
html:not(.dark) .tab-inactive { background: rgba(0,0,0,0.03); color: #64748b; border-color: rgba(0,0,0,0.08); }

/* ── Semantic Status Badges — dùng cho market regime, tín hiệu, tag trạng thái ── */
/* Quy tắc: 1 màu = 1 ý nghĩa. KHÔNG dùng purple cho trạng thái thị trường. */
.badge-bull {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
    font-weight: 600;
}
.badge-bear {
    background: rgba(251, 113, 133, 0.15);
    color: #fb7185;
    border: 1px solid rgba(251, 113, 133, 0.3);
    font-weight: 600;
}
.badge-caution {
    /* Dùng cho "Thận trọng", "Thị trường trung tính" */
    background: rgba(251, 191, 36, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.35);
    font-weight: 700;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.12);
}
.badge-data {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.3);
    font-weight: 600;
}
.badge-ai {
    /* Dùng cho tính năng AI / premium — purple là màu duy nhất hợp lệ */
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.3);
    font-weight: 600;
}
html:not(.dark) .badge-bull    { background: rgba(5,150,105,0.1);   color: #059669; border-color: rgba(5,150,105,0.25); }
html:not(.dark) .badge-bear    { background: rgba(225,29,72,0.1);   color: #e11d48; border-color: rgba(225,29,72,0.25); }
html:not(.dark) .badge-caution { background: rgba(217,119,6,0.1);   color: #b45309; border-color: rgba(217,119,6,0.25); box-shadow: 0 0 10px rgba(217,119,6,0.08); }
html:not(.dark) .badge-data    { background: rgba(37,99,235,0.1);   color: #1d4ed8; border-color: rgba(37,99,235,0.25); }
html:not(.dark) .badge-ai      { background: rgba(109,40,217,0.08); color: #6d28d9; border-color: rgba(109,40,217,0.2); }

/* ── WealthScore Premium Cards ── */
.ws-card-golden {
    background: linear-gradient(135deg, rgba(168,85,247,0.1) 0%, rgba(124,58,237,0.05) 100%);
    border: 1px solid rgba(168,85,247,0.2);
    color: #c084fc;
}
html:not(.dark) .ws-card-golden {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border-color: rgba(124,58,237,0.2);
    color: #7c3aed;
}

.ws-card-wave {
    background: linear-gradient(135deg, rgba(16,185,129,0.1) 0%, rgba(5,150,105,0.05) 100%);
    border: 1px solid rgba(16,185,129,0.2);
    color: #34d399;
}
html:not(.dark) .ws-card-wave {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-color: rgba(5,150,105,0.2);
    color: #059669;
}

.ws-card-value {
    background: linear-gradient(135deg, rgba(59,130,246,0.1) 0%, rgba(37,99,235,0.05) 100%);
    border: 1px solid rgba(59,130,246,0.2);
    color: #60a5fa;
}
html:not(.dark) .ws-card-value {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: rgba(37,99,235,0.2);
    color: #2563eb;
}

/* ── Section Headers ── */
.fw-section-title {
    font-size: 12.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
}
html.dark .fw-section-title { color: #94a3b8; }

/* ── Navbar Premium ── */
.fw-navbar {
    background: rgba(13,15,23,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
html:not(.dark) .fw-navbar {
    background: #ffffff;
    border-bottom: 2px solid rgba(124,58,237,0.18);
    box-shadow: 0 2px 12px rgba(15,23,42,0.08), 0 1px 3px rgba(124,58,237,0.06);
}

.fw-brand-name { color: #c084fc; font-weight: 800; }
html:not(.dark) .fw-brand-name {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fw-nav-link { color: #64748b; transition: all 0.2s; }
.fw-nav-link:hover { background: rgba(124,58,237,0.12) !important; color: #7c3aed !important; }
html:not(.dark) .fw-nav-link { color: #475569; }
html:not(.dark) .fw-nav-link:hover { background: rgba(124,58,237,0.08) !important; color: #7c3aed !important; }

.fw-nav-active {
    background: rgba(124,58,237,0.15);
    color: #c084fc !important;
}
html:not(.dark) .fw-nav-active {
    background: rgba(124,58,237,0.1);
    color: #7c3aed !important;
}

/* ── Profile Bar ── */
.profile-bar-bg {
    background: linear-gradient(to right, rgba(224,231,255,0.8), rgba(238,242,255,0.5), transparent);
}
html.dark .profile-bar-bg {
    background: linear-gradient(to right, rgba(88,28,135,0.4), rgba(30,58,138,0.2), transparent);
}

/* ── WealthScore Action Buttons (Premium Light Mode) ── */
html:not(.dark) .ws-action-btn {
    background-color: rgba(124,58,237,0.06) !important;
    border-color: rgba(124,58,237,0.15) !important;
    color: #7c3aed !important;
}
html:not(.dark) .ws-action-btn:hover {
    background-color: rgba(124,58,237,0.12) !important;
    border-color: rgba(124,58,237,0.25) !important;
}
html:not(.dark) .ws-action-emerald {
    background-color: rgba(5,150,105,0.06) !important;
    border-color: rgba(5,150,105,0.15) !important;
    color: #059669 !important;
}
html:not(.dark) .ws-action-emerald:hover {
    background-color: rgba(5,150,105,0.12) !important;
    border-color: rgba(5,150,105,0.25) !important;
}
html:not(.dark) .ws-action-blue {
    background-color: rgba(37,99,235,0.06) !important;
    border-color: rgba(37,99,235,0.15) !important;
    color: #2563eb !important;
}
html:not(.dark) .ws-action-blue:hover {
    background-color: rgba(37,99,235,0.12) !important;
    border-color: rgba(37,99,235,0.25) !important;
}

/* ── AI Top Pick PREMIUM ── */
.ai-pick-premium {
    position: relative;
    background: #0f1425;
    border-radius: 20px;
    padding: 2px;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.1);
}
html:not(.dark) .ai-pick-premium {
    background: #e0e7ff;
    box-shadow: 0 10px 25px rgba(124, 58, 237, 0.1);
}

.ai-pick-premium::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        from 0deg,
        transparent 0%,
        transparent 30%,
        #8b5cf6 40%,
        #d946ef 50%,
        #8b5cf6 60%,
        transparent 70%,
        transparent 100%
    );
    animation: fw-ai-rotate 4s linear infinite;
}

@keyframes fw-ai-rotate {
    100% { transform: rotate(360deg); }
}

.ai-pick-content {
    position: relative;
    background: #0f1425;
    border-radius: 18px;
    padding: 1rem;
    height: 100%;
    width: 100%;
    z-index: 1;
    display: flex;
    flex-direction: column;
}
html:not(.dark) .ai-pick-content {
    background: #ffffff;
}

.ai-pick-premium:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 15px 35px rgba(139, 92, 246, 0.25);
}


.ai-pick-badge-premium {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    color: white !important;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    font-size: 8px !important;
}

.ticker-ultra-glow {
    font-size: 1.5rem;
    line-height: 1;
    background: linear-gradient(to bottom, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 5px rgba(139, 92, 246, 0.4));
}
html:not(.dark) .ticker-ultra-glow {
    background: linear-gradient(to bottom, #1e1b4b, #4338ca);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: none;
}

/* ══════════════════════════════════════════
   Tailwind Utility Light-Mode Overrides
   Khi html không có class .dark, ánh xạ lại
   các màu Tailwind hard-coded sang biến --fw-*
   ══════════════════════════════════════════ */

/* — Texts — */
/* Trên nền tối (dark mode) Tailwind dùng slate sáng, nên khi sang light
   phải flip thứ tự: slate-100 (sáng nhất) → đậm nhất, slate-500 → nhạt nhất */
html:not(.dark) .text-white,
html:not(.dark) .text-slate-50,
html:not(.dark) .text-slate-100 { color: var(--fw-text-primary) !important; }  /* #0f172a */
html:not(.dark) .text-slate-200 { color: #1e293b !important; }                  /* slate-800 */
html:not(.dark) .text-slate-300 { color: var(--fw-text-secondary) !important; } /* #334155 */
html:not(.dark) .text-slate-400 { color: #475569 !important; }                  /* slate-600 */
html:not(.dark) .text-slate-500 { color: var(--fw-text-muted) !important; }     /* #64748b */
html:not(.dark) .text-slate-600 { color: #94a3b8 !important; }                  /* slate-400 — nhạt hơn */
html:not(.dark) .text-slate-700 { color: #cbd5e1 !important; }                  /* slate-300 — rất nhạt */

html:not(.dark) .text-purple-400 { color: var(--fw-accent-purple) !important; }
html:not(.dark) .text-blue-400   { color: var(--fw-accent-blue) !important; }
html:not(.dark) .text-emerald-400{ color: var(--fw-accent-emerald) !important; }
html:not(.dark) .text-amber-400  { color: var(--fw-accent-amber) !important; }
html:not(.dark) .text-cyan-400   { color: var(--fw-accent-cyan) !important; }
html:not(.dark) .text-rose-400   { color: var(--fw-accent-rose) !important; }
html:not(.dark) .text-orange-400 { color: #ea580c !important; }

html:not(.dark) .hover\:text-white:hover { color: var(--fw-text-primary); }
html:not(.dark) .group:hover .group-hover\:text-purple-400 { color: var(--fw-accent-purple); }
html:not(.dark) .group:hover .group-hover\:text-emerald-400 { color: var(--fw-accent-emerald); }
html:not(.dark) .group:hover .group-hover\:text-blue-400 { color: var(--fw-accent-blue); }

/* — Borders — */
html:not(.dark) .border-white\/5,
html:not(.dark) .border-white\/10,
html:not(.dark) .border-white\/\[0\.04\],
html:not(.dark) .border-white\/\[0\.05\],
html:not(.dark) .border-white\/\[0\.08\] { border-color: rgba(15, 23, 42, 0.15) !important; }

html:not(.dark) .border-purple-500\/15,
html:not(.dark) .border-purple-500\/20,
html:not(.dark) .border-purple-500\/30 { border-color: rgba(124,58,237,0.15); }
html:not(.dark) .border-blue-500\/15,
html:not(.dark) .border-blue-500\/20,
html:not(.dark) .border-blue-500\/30   { border-color: rgba(37,99,235,0.15); }
html:not(.dark) .border-emerald-500\/15,
html:not(.dark) .border-emerald-500\/20,
html:not(.dark) .border-emerald-500\/30{ border-color: rgba(5,150,105,0.15); }
html:not(.dark) .border-amber-500\/15,
html:not(.dark) .border-amber-500\/20,
html:not(.dark) .border-amber-500\/30  { border-color: rgba(217,119,6,0.15); }
html:not(.dark) .border-cyan-500\/15,
html:not(.dark) .border-cyan-500\/20,
html:not(.dark) .border-cyan-500\/30   { border-color: rgba(8,145,178,0.15); }

/* — Backgrounds — */
html:not(.dark) .bg-white\/5,
html:not(.dark) .bg-white\/10,
html:not(.dark) .bg-white\/\[0\.03\],
html:not(.dark) .bg-white\/\[0\.04\],
html:not(.dark) .bg-white\/\[0\.07\] { background-color: #ffffff !important; }
html:not(.dark) .bg-white\/\[0\.06\] { background-color: #fbfaff !important; }

html:not(.dark) .bg-purple-500\/10,
html:not(.dark) .bg-purple-500\/15 { background-color: rgba(124,58,237,0.08); }
html:not(.dark) .bg-blue-500\/10,
html:not(.dark) .bg-blue-500\/15   { background-color: rgba(37,99,235,0.08); }
html:not(.dark) .bg-emerald-500\/10,
html:not(.dark) .bg-emerald-500\/15{ background-color: rgba(5,150,105,0.08); }
html:not(.dark) .bg-amber-500\/10,
html:not(.dark) .bg-amber-500\/15  { background-color: rgba(217,119,6,0.08); }
html:not(.dark) .bg-cyan-500\/10,
html:not(.dark) .bg-cyan-500\/15   { background-color: rgba(8,145,178,0.08); }
html:not(.dark) .bg-rose-500\/10,
html:not(.dark) .bg-rose-500\/15   { background-color: rgba(225,29,72,0.08); }

html:not(.dark) .hover\:bg-white\/5:hover,
html:not(.dark) .hover\:bg-white\/10:hover,
html:not(.dark) .hover\:bg-white\/\[0\.08\]:hover { background-color: rgba(0,0,0,0.04); }

/* — Force Colors (Dùng cho các element có nền cố định không đổi theo theme) — */
.text-white-force { color: #ffffff !important; }
.text-slate-100-force { color: #f1f5f9 !important; }
.text-slate-200-force { color: #e2e8f0 !important; }

/* — Inputs — */
html:not(.dark) input[type="text"],
html:not(.dark) input[type="search"] {
    background-color: rgba(0,0,0,0.04) !important;
    border-color: rgba(0,0,0,0.08) !important;
    color: var(--fw-text-primary) !important;
}
html:not(.dark) input::placeholder { color: var(--fw-text-muted) !important; }
html.dark input::placeholder { color: rgba(255, 255, 255, 0.5) !important; }

/* ══════════════════════════════════════════
   Bootstrap Component Dark Mode Overrides
   Áp dụng khi html.dark — cho các trang còn
   dùng Bootstrap (không phải home standalone)
   ══════════════════════════════════════════ */
html.dark body { background-color: var(--fw-base) !important; color: var(--fw-text-secondary); }
html.dark .card {
    background-color: var(--fw-card) !important;
    border-color: var(--fw-border) !important;
    color: var(--fw-text-primary);
}
html.dark .card-header,
html.dark .card-footer {
    background-color: var(--fw-card-alt) !important;
    border-color: var(--fw-border) !important;
}
html.dark .table { color: var(--fw-text-primary); }
html.dark .table td,
html.dark .table th { border-color: var(--fw-border); }
html.dark .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: rgba(124,58,237,0.05);
}
html.dark .form-control,
html.dark .form-select {
    background-color: var(--fw-card-alt);
    border-color: var(--fw-border);
    color: var(--fw-text-primary);
}
html.dark .form-control:focus { border-color: var(--fw-accent-purple); box-shadow: 0 0 0 0.2rem rgba(192,132,252,0.15); }
html.dark .dropdown-menu {
    background-color: var(--fw-card) !important;
    border-color: var(--fw-border) !important;
    backdrop-filter: none !important;
}
html.dark .dropdown-item { color: var(--fw-text-secondary); }
html.dark .dropdown-item:hover,
html.dark .dropdown-item:focus {
    background-color: rgba(124,58,237,0.12) !important;
    color: var(--fw-accent-purple) !important;
}
html.dark .dropdown-divider { border-color: var(--fw-border) !important; }
html.dark .modal-content {
    background-color: var(--fw-card) !important;
    color: var(--fw-text-primary);
    border-color: var(--fw-border);
}
html.dark .modal-header,
html.dark .modal-footer { border-color: var(--fw-border) !important; }
html.dark .alert { border-color: var(--fw-border) !important; }
html.dark .alert-warning {
    background: rgba(217,119,6,0.12) !important;
    color: var(--fw-accent-amber) !important;
}
html.dark .badge.bg-light { background: var(--fw-card-alt) !important; color: var(--fw-text-primary) !important; }
html.dark .bg-light { background-color: var(--fw-card-alt) !important; }
html.dark .bg-white { background-color: var(--fw-card) !important; }
html.dark .text-dark { color: var(--fw-text-primary) !important; }
html.dark .text-muted { color: var(--fw-text-muted) !important; }
html.dark .border { border-color: var(--fw-border) !important; }
html.dark .border-bottom { border-bottom-color: var(--fw-border) !important; }
html.dark .nav-tabs .nav-link { color: var(--fw-text-muted); }
html.dark .nav-tabs .nav-link.active { color: var(--fw-accent-purple) !important; border-bottom-color: var(--fw-accent-purple) !important; }
html.dark hr { border-color: var(--fw-border); }

/* Dark mode: notification button */
html.dark #notificationDropdownBtn {
    background: var(--fw-card-alt) !important;
    color: var(--fw-accent-purple) !important;
    border-color: var(--fw-border) !important;
}
html.dark #notificationDropdownBtn:hover { background: var(--fw-card) !important; }
html.dark .account-dropdown .btn {
    background: var(--fw-card-alt) !important;
    color: var(--fw-text-primary) !important;
    border-color: var(--fw-border) !important;
}
html.dark .account-dropdown .btn:hover { background: var(--fw-card) !important; }
html.dark .account-info { background: var(--fw-card-alt) !important; }

/* Dark mode: ai toolbox menu */
html.dark .ai-toolbox__menu {
    background: var(--fw-card) !important;
    border-color: var(--fw-border) !important;
}
html.dark .ai-toolbox__menu::before {
    background: var(--fw-card) !important;
    border-color: var(--fw-border) !important;
}
html.dark .ai-toolbox__action {
    background: var(--fw-card-alt) !important;
    color: var(--fw-text-secondary);
}
html.dark .ai-toolbox__action:hover { background: rgba(124,58,237,0.12) !important; }
html.dark .ai-toolbox__title { color: var(--fw-text-primary) !important; }
html.dark .ai-loading-overlay { background: rgba(13,15,23,0.9) !important; }

/* content-card / main-card từ main-template.css không có dark override */
html.dark .content-card,
html.dark .main-card {
    background: var(--fw-card) !important;
    border-color: var(--fw-border) !important;
}
html.dark .content-card .card-body { color: var(--fw-text-primary); }
html.dark .main-input-container {
    background-color: var(--fw-card-alt) !important;
    border-color: var(--fw-border) !important;
}
html.dark .main-input-container input,
html.dark .main-input-container select,
html.dark .main-input-container textarea {
    color: var(--fw-text-primary) !important;
}
html.dark .main-title { color: var(--fw-text-primary) !important; }
html.dark .main-subtitle { color: var(--fw-text-muted) !important; }

/* ══════════════════════════════════════════
   Dark mode: Bootstrap Navbar override
   Tối hoá navbar khi chuyển sang dark mode
   ══════════════════════════════════════════ */
html.dark .navbar.bg-primary {
    background: linear-gradient(135deg, #1e0a3c, #3b0d75) !important;
    border-bottom-color: rgba(255,255,255,0.04) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important;
}

/* ══════════════════════════════════════════
   Light mode: Bootstrap Dropdown override
   Dropdowns on old pages get a clean white
   ══════════════════════════════════════════ */
html:not(.dark) .dropdown-menu {
    background-color: #ffffff !important;
    border-color: rgba(109, 40, 217, 0.1) !important;
    box-shadow: 0 10px 25px -5px rgba(109, 40, 217, 0.1), 0 8px 10px -6px rgba(109, 40, 217, 0.05) !important;
}
html:not(.dark) .dropdown-item {
    color: #4527a0 !important; /* Tím đậm */
}
html:not(.dark) .dropdown-item i,
html:not(.dark) .dropdown-item svg {
    color: #7e57c2 !important; /* Tím trung tính cho icon */
}
html:not(.dark) .dropdown-item:hover,
html:not(.dark) .dropdown-item:focus {
    background-color: #f5f0ff !important;
    color: #6d28d9 !important;
}
html:not(.dark) .nav-tabs .nav-link.active {
    color: var(--fw-accent-purple);
    border-bottom-color: var(--fw-accent-purple);
}

/* Fix cụ thể cho văn bản trong dropdown header và các thông tin phụ */
html:not(.dark) .dropdown-menu .text-white,
html:not(.dark) .dropdown-menu .text-slate-200,
html:not(.dark) .dropdown-menu .text-slate-700,
html:not(.dark) .dropdown-menu .text-slate-400 {
    color: #475569 !important;
}
html:not(.dark) .dropdown-menu .text-slate-900 {
    color: #1e1b4b !important;
}

/* ── Sidebar Right Container Fix ── */
aside.xl\:flex {
    background: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(20px) !important;
}
html:not(.dark) aside.xl\:flex {
    background: rgba(248, 250, 252, 0.8) !important;
    border-left-color: rgba(124, 58, 237, 0.1) !important;
}

/* ── AI Toolbox Sidebar ── */
.sidebar-toolbox .ai-toolbox__action {
    display: flex !important;
    align-items: center !important;
    gap: 14px;
    padding: 14px 18px !important;
    background: rgba(124, 58, 237, 0.04);
    border: 1px solid rgba(124, 58, 237, 0.08);
    border-radius: 20px;
    width: 100%;
    text-align: left;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 10px;
    color: inherit;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

html:not(.dark) .sidebar-toolbox .ai-toolbox__action {
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.06);
    border-color: rgba(124, 58, 237, 0.1);
}

.sidebar-toolbox .ai-toolbox__action:hover {
    background: rgba(124, 58, 237, 0.1);
    border-color: rgba(124, 58, 237, 0.3);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.15);
}

.ai-toolbox__icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(99, 102, 241, 0.15));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #a78bfa;
    shrink: 0;
    transition: all 0.4s;
    border: 1px solid rgba(124, 58, 237, 0.1);
}

html:not(.dark) .ai-toolbox__icon {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    color: #7c3aed;
}

.ai-toolbox__action:hover .ai-toolbox__icon {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: white;
    transform: rotate(10deg);
}

.ai-toolbox__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ai-toolbox__title {
    font-size: 14px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    margin-bottom: 2px;
}

html:not(.dark) .ai-toolbox__title {
    color: #1e1b4b;
}

.ai-toolbox__desc {
    font-size: 11.5px;
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html:not(.dark) .ai-toolbox__desc {
    color: #64748b;
}

/* ── Refined AI Top Pick PREMIUM (Light Mode fix) ── */
html:not(.dark) .ai-pick-premium {
    background: linear-gradient(135deg, #f5f3ff 0%, #e0e7ff 100%);
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.12);
}

html:not(.dark) .ai-pick-content {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
}

/* Fix for broken images */
img[onerror] {
    position: relative;
}
/* ── AI Loading Components (Shared) ── */
.ai-loader-inline {
    padding: 2rem 0;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    text-align: center !important;
    grid-column: 1 / -1 !important; /* Đảm bảo trải dài hết các cột nếu nằm trong CSS Grid */
}

.ai-loader-inline p {
    text-align: center !important;
    width: 100% !important;
}
