/* ==========================================================================
   FinDash Design System — Calm Consumer Fintech + Light/Dark & Custom Themes
   ========================================================================== */

:root {
    --fd-bg: #F8FAFC;
    --fd-card: #FFFFFF;
    --fd-surface: #F8FAFC;
    --fd-surface-alt: #F1F5F9;
    --fd-border: #E2E8F0;
    --fd-divider: #F1F5F9;
    --fd-text: #0F172A;
    --fd-muted: #475569;
    --fd-subtle: #64748B;
    --fd-emerald: #059669;
    --fd-emerald-dark: #047857;
    --fd-emerald-soft: #ECFDF5;
    --fd-accent: #059669;
    --fd-header-bg: rgba(248, 250, 252, 0.90);
}

/* Default Dark Mode (Clean Midnight Slate) */
html.dark {
    --fd-bg: #090D16;
    --fd-card: #111827;
    --fd-surface: #0F172A;
    --fd-surface-alt: #1E293B;
    --fd-border: #1F2937;
    --fd-divider: #1F2937;
    --fd-text: #F8FAFC;
    --fd-muted: #CBD5E1;
    --fd-subtle: #94A3B8;
    --fd-emerald: #10B981;
    --fd-emerald-dark: #059669;
    --fd-emerald-soft: rgba(16, 185, 129, 0.14);
    --fd-accent: #10B981;
    --fd-header-bg: rgba(9, 13, 22, 0.90);
}

/* 1. Sunset Rose Theme */
html.dark[data-theme="sunset"] {
    --fd-bg: #1C0517;
    --fd-card: #2F0924;
    --fd-surface: #25071D;
    --fd-surface-alt: #440E35;
    --fd-border: #63184C;
    --fd-divider: #4E113C;
    --fd-text: #FFF1F2;
    --fd-muted: #FECDD3;
    --fd-subtle: #FDA4AF;
    --fd-accent: #F43F5E;
    --fd-header-bg: rgba(28, 5, 23, 0.90);
}
html:not(.dark)[data-theme="sunset"] {
    --fd-bg: #FFF5F7;
    --fd-surface: #FFF1F2;
    --fd-border: #FECDD3;
    --fd-accent: #E11D48;
    --fd-header-bg: rgba(255, 245, 247, 0.90);
}

/* 2. Cyberpunk Neon Theme */
html.dark[data-theme="cyberpunk"] {
    --fd-bg: #090919;
    --fd-card: #10162B;
    --fd-surface: #0B1022;
    --fd-surface-alt: #19223E;
    --fd-border: #233056;
    --fd-divider: #1A2442;
    --fd-text: #F0F9FF;
    --fd-muted: #BAE6FD;
    --fd-subtle: #7DD3FC;
    --fd-accent: #06B6D4;
    --fd-header-bg: rgba(9, 9, 25, 0.90);
}
html:not(.dark)[data-theme="cyberpunk"] {
    --fd-bg: #F0F9FF;
    --fd-surface: #ECFEFF;
    --fd-border: #BAE6FD;
    --fd-accent: #0891B2;
    --fd-header-bg: rgba(240, 249, 255, 0.90);
}

/* 3. Onyx Gold (Executive Luxury) Theme */
html.dark[data-theme="onyx"] {
    --fd-bg: #090A0F;
    --fd-card: #13151F;
    --fd-surface: #0E1018;
    --fd-surface-alt: #1D2030;
    --fd-border: #2A2D3D;
    --fd-divider: #202332;
    --fd-text: #FFFBEB;
    --fd-muted: #FDE68A;
    --fd-subtle: #D4B978;
    --fd-accent: #F59E0B;
    --fd-header-bg: rgba(9, 10, 15, 0.90);
}
html:not(.dark)[data-theme="onyx"] {
    --fd-bg: #FAFAF9;
    --fd-surface: #FEFCE8;
    --fd-border: #E7E5E4;
    --fd-accent: #D97706;
    --fd-header-bg: rgba(250, 250, 249, 0.90);
}

/* 4. Nordic Sapphire (Deep Abyss) Theme */
html.dark[data-theme="sapphire"] {
    --fd-bg: #060D1A;
    --fd-card: #0C192E;
    --fd-surface: #081325;
    --fd-surface-alt: #132746;
    --fd-border: #1B355C;
    --fd-divider: #152B4B;
    --fd-text: #F0F9FF;
    --fd-muted: #BAE6FD;
    --fd-subtle: #7DD3FC;
    --fd-accent: #38BDF8;
    --fd-header-bg: rgba(6, 13, 26, 0.90);
}
html:not(.dark)[data-theme="sapphire"] {
    --fd-bg: #F0F7FF;
    --fd-surface: #EFF6FF;
    --fd-border: #BFDBFE;
    --fd-accent: #0284C7;
    --fd-header-bg: rgba(240, 247, 255, 0.90);
}

/* Base Canvas & Typography */
html, body {
    background-color: var(--fd-bg) !important;
    color: var(--fd-text) !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, .font-display, .num-display {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Cards */
.fd-card {
    background: var(--fd-card) !important;
    border: 1px solid var(--fd-border) !important;
    border-radius: 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -18px rgba(15, 23, 42, 0.14);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.fd-card-subtle {
    background: var(--fd-card) !important;
    border: 1px solid var(--fd-border) !important;
    border-radius: 16px;
}

/* Universal Dark Mode & Theme Adaptations (keeps every screen crisp without cluttering HTML) */
html.dark header,
html.dark footer {
    background-color: var(--fd-header-bg) !important;
    border-color: var(--fd-border) !important;
}

html.dark aside,
html.dark nav.fixed {
    background-color: var(--fd-card) !important;
    border-color: var(--fd-border) !important;
}

html.dark section.bg-white,
html.dark .bg-white,
html.dark .bg-white\/95,
html.dark .bg-white\/90 {
    background-color: var(--fd-card) !important;
}

html.dark .bg-\[\#F8FAFC\],
html.dark .bg-slate-50,
html.dark .bg-slate-100,
html.dark .bg-slate-200\/60,
html.dark .bg-slate-200\/70,
html.dark .bg-slate-200\/80 {
    background-color: var(--fd-surface) !important;
}

html.dark .border-slate-100,
html.dark .border-slate-200,
html.dark .border-slate-200\/70,
html.dark .border-slate-200\/80,
html.dark .border-slate-300,
html.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--fd-border) !important;
}

html.dark .text-slate-900,
html.dark .text-slate-800 {
    color: var(--fd-text) !important;
}

html.dark .text-slate-700,
html.dark .text-slate-600 {
    color: var(--fd-muted) !important;
}

html.dark .text-slate-500,
html.dark .text-slate-400 {
    color: var(--fd-subtle) !important;
}

/* Keep solid dark buttons readable in dark mode */
html.dark .bg-slate-900 {
    background-color: var(--fd-surface-alt) !important;
    color: var(--fd-text) !important;
    border: 1px solid var(--fd-border);
}
html.dark .bg-slate-900:hover {
    filter: brightness(1.12);
}

/* Soft tinted surfaces in dark mode */
html.dark .bg-emerald-50,
html.dark .bg-emerald-50\/80,
html.dark .bg-emerald-50\/70,
html.dark .bg-emerald-50\/30 {
    background-color: rgba(16, 185, 129, 0.14) !important;
    border-color: rgba(16, 185, 129, 0.30) !important;
}
html.dark .text-emerald-700,
html.dark .text-emerald-800,
html.dark .text-emerald-900 {
    color: #34D399 !important;
}

html.dark .bg-sky-50 {
    background-color: rgba(14, 165, 233, 0.14) !important;
    border-color: rgba(14, 165, 233, 0.28) !important;
}
html.dark .text-sky-700 { color: #38BDF8 !important; }

html.dark .bg-amber-50,
html.dark .bg-amber-50\/90 {
    background-color: rgba(245, 158, 11, 0.14) !important;
    border-color: rgba(245, 158, 11, 0.30) !important;
}
html.dark .text-amber-700,
html.dark .text-amber-800 { color: #FBBF24 !important; }

html.dark .bg-rose-50,
html.dark .bg-rose-50\/90 {
    background-color: rgba(244, 63, 94, 0.15) !important;
    border-color: rgba(244, 63, 94, 0.30) !important;
}
html.dark .text-rose-600,
html.dark .text-rose-700 { color: #FB7185 !important; }

/* Inputs, Selects & Textareas in Dark Mode */
html.dark input:not([type="range"]):not([type="checkbox"]),
html.dark select,
html.dark textarea {
    background-color: var(--fd-surface) !important;
    border-color: var(--fd-border) !important;
    color: var(--fd-text) !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder {
    color: var(--fd-subtle) !important;
}
html.dark option {
    background-color: var(--fd-card);
    color: var(--fd-text);
}

/* Active nav tab pill in Dark Mode */
html.dark .nav-tab-btn.bg-white {
    background-color: var(--fd-surface-alt) !important;
    color: var(--fd-text) !important;
}

/* Custom Accent Tinting when a Custom Preset is selected */
html[data-theme] input[type="range"].fd-slider::-webkit-slider-thumb {
    background: var(--fd-accent);
}
html[data-theme] input[type="range"].fd-slider::-moz-range-thumb {
    background: var(--fd-accent);
}

/* Custom Range Slider */
input[type="range"].fd-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--fd-border);
    outline: none;
}
input[type="range"].fd-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--fd-accent);
    border: 3px solid #FFFFFF;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.35);
    cursor: pointer;
    transition: transform 0.15s ease;
}
input[type="range"].fd-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}
input[type="range"].fd-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--fd-accent);
    border: 3px solid #FFFFFF;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.35);
    cursor: pointer;
}

/* Magic Quick-Add Drag-Over State */
.quick-drop-active {
    border-color: var(--fd-accent) !important;
    background-color: var(--fd-emerald-soft) !important;
    box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.15) !important;
}

/* Smooth fade-up entrance */
@keyframes fdFadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.fd-animate-in {
    animation: fdFadeUp 0.22s ease-out both;
}

.mobile-safe-bottom {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Prevent iOS Safari auto-zoom on form fields while preserving sleek desktop sizing */
@media (max-width: 640px) {
    input:not([readonly]):not([type="range"]):not([type="checkbox"]),
    select,
    textarea:not([readonly]) {
        font-size: 16px !important;
    }
}
