/* Auto Light/Dark Theme following browser/device prefers-color-scheme (no manual toggle) */
:root {
    color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
    html,
    body {
        background-color: #f8fafc !important;
        color: #0f172a !important;
    }

    .glass-nav {
        background: rgba(248, 250, 252, 0.88) !important;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
    }

    .glass-card {
        background: linear-gradient(145deg, rgba(255, 255, 255, 0.95) 0%, rgba(241, 245, 249, 0.95) 100%) !important;
        border-color: rgba(15, 23, 42, 0.1) !important;
        box-shadow: 0 8px 24px -6px rgba(15, 23, 42, 0.08) !important;
    }

    /* Tone down heavy dark shadows in light mode */
    [class*="shadow-[0_25px_60px"],
    .shadow-2xl {
        box-shadow: 0 10px 28px -8px rgba(15, 23, 42, 0.1) !important;
    }

    .glass-card-apex {
        background: linear-gradient(145deg, rgba(255, 241, 242, 0.95) 0%, rgba(255, 255, 255, 0.96) 100%) !important;
        border-color: rgba(225, 29, 72, 0.25) !important;
    }

    /* All Dark Backgrounds -> Light Surfaces */
    footer,
    [class*="bg-[#020617]"],
    [class*="bg-[#030712]"],
    [class*="bg-[#060401]"],
    [class*="bg-gray-950"],
    [class*="bg-slate-950"] {
        background-color: #f1f5f9 !important;
    }

    [class*="bg-[#0b1120]"],
    [class*="bg-[#0f172a]"],
    [class*="bg-[#131722]"],
    [class*="bg-[#141821]"],
    [class*="bg-[#0b0f19]"],
    [class*="bg-[#0e121a]"],
    [class*="bg-gray-900"],
    [class*="bg-gray-800"],
    [class*="bg-slate-900"],
    [class*="bg-slate-800"] {
        background-color: #ffffff !important;
    }

    [class*="bg-brand-900"],
    [class*="bg-brand-950"] {
        background-color: rgba(20, 184, 166, 0.1) !important;
    }
    [class*="bg-amber-900"],
    [class*="bg-amber-950"] {
        background-color: rgba(245, 158, 11, 0.1) !important;
    }
    [class*="bg-blue-900"] {
        background-color: rgba(59, 130, 246, 0.1) !important;
    }
    [class*="bg-emerald-900"],
    [class*="bg-emerald-950"],
    [class*="bg-green-900"] {
        background-color: rgba(16, 185, 129, 0.1) !important;
    }
    [class*="bg-purple-900"],
    [class*="bg-purple-950"] {
        background-color: rgba(168, 85, 247, 0.1) !important;
    }
    [class*="bg-rose-950"] {
        background-color: rgba(244, 63, 94, 0.1) !important;
    }

    [class*="bg-white/5"],
    [class*="bg-white/[0.01]"],
    [class*="bg-white/[0.02]"],
    [class*="bg-white/[0.04]"],
    [class*="bg-white/10"] {
        background-color: rgba(15, 23, 42, 0.04) !important;
    }

    /* Floating dark badges (e.g. Sectofy Star HTF Bias & Confluence) -> crisp frosted white */
    [class*="bg-black/"]:not(.fixed) {
        background-color: rgba(255, 255, 255, 0.92) !important;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    }

    /* Dark gradient stops */
    [class*="from-gray-950"],
    [class*="from-gray-900"] {
        --tw-gradient-from: #f8fafc var(--tw-gradient-from-position) !important;
    }
    [class*="to-gray-950"],
    [class*="to-gray-900"] {
        --tw-gradient-to: #f1f5f9 var(--tw-gradient-to-position) !important;
    }

    /* Typography Contrast */
    .text-white,
    .hover\:text-white:hover,
    .text-gray-100, .text-slate-100,
    .text-gray-200, .text-slate-200 {
        color: #0f172a !important;
    }
    .text-gray-300, .text-slate-300 { color: #334155 !important; }
    .text-gray-400, .text-slate-400 { color: #475569 !important; }
    .text-gray-500, .text-slate-500 { color: #64748b !important; }

    .text-brand-400, .text-brand-300 { color: #0f766e !important; }
    .text-emerald-400, .text-emerald-300 { color: #047857 !important; }
    .text-teal-300 { color: #0f766e !important; }
    .text-amber-300, .text-amber-400 { color: #b45309 !important; }
    .text-purple-300, .text-purple-400 { color: #7e22ce !important; }
    .text-rose-300, .text-rose-400 { color: #be123c !important; }
    .text-blue-300, .text-blue-400 { color: #1d4ed8 !important; }

    /* Light-mode TradingView-style Chart Telemetry Canvas */
    .chart-grid {
        background-color: #ffffff !important;
        background-image:
            linear-gradient(rgba(15, 23, 42, 0.05) 1px, transparent 1px),
            linear-gradient(90deg, rgba(15, 23, 42, 0.05) 1px, transparent 1px) !important;
        border-color: rgba(15, 23, 42, 0.12) !important;
    }
    .chart-grid [class*="bg-[#0b1120]"],
    .chart-grid [class*="bg-gray-900"] {
        background-color: #f1f5f9 !important;
        border-color: rgba(15, 23, 42, 0.1) !important;
    }
    .chart-grid .text-white { color: #0f172a !important; }
    .chart-grid .text-gray-400 { color: #475569 !important; }
    .chart-grid .text-brand-400 { color: #0d9488 !important; }
    .chart-grid .text-emerald-400 { color: #047857 !important; }

    .chart-grid svg rect[fill="rgba(15,23,42,0.92)"] {
        fill: rgba(248, 250, 252, 0.96) !important;
        stroke: rgba(15, 23, 42, 0.15) !important;
    }
    .chart-grid svg line[stroke="rgba(255,255,255,0.08)"] {
        stroke: rgba(15, 23, 42, 0.1) !important;
    }
    .chart-grid svg text[fill="#ffffff"] { fill: #0f172a !important; }
    .chart-grid svg text[fill="#94a3b8"] { fill: #475569 !important; }
    .chart-grid svg text[fill="#cbd5e1"] { fill: #334155 !important; }
    .chart-grid svg text[fill="#5eead4"],
    .chart-grid svg text[fill="#2dd4bf"] { fill: #0d9488 !important; }
    .chart-grid svg text[fill="#fbbf24"] { fill: #b45309 !important; }
    .chart-grid svg text[fill="#fda4af"] { fill: #be123c !important; }
    .chart-grid svg text[fill="#22c55e"] { fill: #047857 !important; }
    .chart-grid svg text[fill="#020617"] { fill: #ffffff !important; }

    /* Docs Concept SVG Box -> clean light surface with darkened readable SVG fills */
    .concept-svg-box {
        background-color: #f1f5f9 !important;
        border-color: rgba(15, 23, 42, 0.1) !important;
    }
    .concept-svg-box svg [fill="#141821"],
    .concept-svg-box svg [fill="#0f172a"] { fill: #ffffff !important; }
    .concept-svg-box svg [fill="#ffffff"],
    .concept-svg-box svg [fill="#e2e8f0"],
    .concept-svg-box svg [fill="#cbd5e1"] { fill: #0f172a !important; }
    .concept-svg-box svg [fill="#94a3b8"],
    .concept-svg-box svg [fill="#64748b"] { fill: #475569 !important; }
    .concept-svg-box svg [fill="#5eead4"],
    .concept-svg-box svg [fill="#2dd4bf"] { fill: #0d9488 !important; }
    .concept-svg-box svg [fill="#fde68a"],
    .concept-svg-box svg [fill="#fbbf24"],
    .concept-svg-box svg [fill="#fcd34d"] { fill: #b45309 !important; }
    .concept-svg-box svg [fill="#fca5a5"],
    .concept-svg-box svg [fill="#fb7185"] { fill: #be123c !important; }
    .concept-svg-box svg [fill="#e9d5ff"],
    .concept-svg-box svg [fill="#d8b4fe"] { fill: #7e22ce !important; }
    .concept-svg-box svg [fill="#93c5fd"] { fill: #1d4ed8 !important; }
    .concept-svg-box svg [fill="#4ade80"],
    .concept-svg-box svg [fill="#86efac"],
    .concept-svg-box svg [fill="#6ee7b7"] { fill: #047857 !important; }

    /* Keep white text ONLY on exact solid colored buttons/badges (not /10, /15, /20 tints) */
    .bg-brand-500, .bg-brand-600,
    .bg-apex-500, .bg-apex-600,
    .bg-rose-500, .bg-rose-600,
    .bg-emerald-500, .bg-purple-600,
    .bg-amber-500,
    .bg-brand-500 .text-white, .bg-brand-600 .text-white,
    .bg-apex-500 .text-white, .bg-apex-600 .text-white,
    .bg-rose-500 .text-white, .bg-rose-600 .text-white,
    .bg-emerald-500 .text-white, .bg-purple-600 .text-white,
    .bg-amber-500 .text-white,
    [class*="from-brand-500"].text-white,
    [class*="from-apex-500"].text-white,
    [class*="from-purple-600"].text-white {
        color: #ffffff !important;
    }

    /* Borders & Inputs */
    [class*="border-white/"],
    [class*="border-gray-800"],
    [class*="border-gray-700"] {
        border-color: rgba(15, 23, 42, 0.12) !important;
    }

    input[data-doc-search],
    input,
    textarea,
    select {
        background-color: #ffffff !important;
        color: #0f172a !important;
        border-color: rgba(15, 23, 42, 0.15) !important;
    }
}
