/* =====================================================
   GLOBAL LIGHT/DARK THEME SYSTEM
   All templates inherit these CSS variables for theme support
   ===================================================== */

:root {
    /* ==================== DARK MODE (Default - Brand Palette) ==================== */
    --bg-primary: #050505;        /* Deep Black: Main background */
    --accent-glow: #3B0000;       /* Dark Red: Shadow & glow areas */
    --accent: #8B0000;            /* Blood Red: Main accent */
    --highlight: #FF1A1A;         /* Neon Red: Buttons, borders, highlights */
    --accent-secondary: #D10000;  /* Crimson: Text glow & UI lines */
    --bg-secondary: #1A1A1A;      /* Dark Gray: Panels & cards */
    --bg-tertiary: #2B2B2B;       /* Charcoal: Sidebar backgrounds */
    --text-primary: #F2F2F2;      /* Soft White: Main text */
    --text-secondary: #BDBDBD;    /* Light Gray: Secondary text */
    --text-tertiary: #888888;
    
    --border-primary: rgba(255, 26, 26, 0.2);
    --border-secondary: rgba(255, 255, 255, 0.05);
    --shadow-primary: rgba(59, 0, 0, 0.5);
    --shadow-secondary: rgba(0, 0, 0, 0.9);
    
    /* Glass/Transparent Colors */
    --glass-dark: rgba(26, 26, 26, 0.85);
    --glass-light: rgba(255, 255, 255, 0.03);
    
    /* Gradient Colors */
    --gradient-start: rgba(139, 0, 0, 0.2);
    --gradient-end: rgba(0, 0, 0, 0.6);
}

/* ==================== LIGHT MODE OVERRIDES ==================== */
body.light-mode,
html.light-mode {
    /* Light Mode Palette - Ultra Crisp & High Contrast */
    --bg-primary: #F8F9FA;        /* Off-white page background */
    --bg-secondary: #FFFFFF;      /* Pure white panels & cards */
    --bg-tertiary: #F1F3F5;       /* Light gray input fields */
    --text-primary: #121212;      /* Dark Charcoal/Black main text */
    --text-secondary: #495057;    /* Medium dark gray secondary text */
    --text-tertiary: #6C757D;     /* Muted gray text */
    --accent: #8B0000;            /* Blood Red */
    --highlight: #E60000;         /* Vivid Red buttons/accents */
    --accent-secondary: #C00000;  /* Crimson Red */
    --accent-glow: rgba(230, 0, 0, 0.15);
    
    /* Light Mode Borders & Shadows */
    --border-primary: rgba(230, 0, 0, 0.2);
    --border-secondary: rgba(0, 0, 0, 0.08);
    --shadow-primary: rgba(0, 0, 0, 0.08);
    --shadow-secondary: rgba(0, 0, 0, 0.15);
    
    /* Light Mode Glass */
    --glass-dark: rgba(255, 255, 255, 0.94);
    --glass-light: rgba(230, 0, 0, 0.05);
    
    /* Light Mode Gradients */
    --gradient-start: rgba(230, 0, 0, 0.06);
    --gradient-end: rgba(0, 0, 0, 0.02);
}

/* ==================== LIGHT MODE GLOBAL HELPER RULES ==================== */
body.light-mode .text-white,
body.light-mode .text-slate-50,
body.light-mode .text-slate-100,
body.light-mode .text-slate-200,
body.light-mode .text-slate-300,
body.light-mode .text-gray-50,
body.light-mode .text-gray-100,
body.light-mode .text-gray-200,
body.light-mode .text-gray-300 {
    color: var(--text-primary) !important;
}

body.light-mode .text-slate-400,
body.light-mode .text-gray-400,
body.light-mode .text-gray-500 {
    color: #495057 !important;
}

body.light-mode .text-slate-500,
body.light-mode .text-gray-600 {
    color: #6C757D !important;
}

/* Ensure buttons, badges and custom colored text blocks retain crisp white text on colored backgrounds */
body.light-mode .btn,
body.light-mode .btn-primary,
body.light-mode .badge,
body.light-mode .badge-primary,
body.light-mode .bg-emerald-600,
body.light-mode .bg-green-600,
body.light-mode .bg-green-500,
body.light-mode .bg-red-600,
body.light-mode .bg-red-700,
body.light-mode [class*="bg-red-"],
body.light-mode [class*="bg-\[\#FF1A1A\]"] {
    color: #FFFFFF !important;
}

body.light-mode .text-red-50 {
    color: var(--text-primary) !important;
}


/* ==================== GLOBAL TRANSITIONS ==================== */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

body * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ==================== SEMANTIC COLOR VARIABLES ==================== */

/* Backgrounds */
.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }

/* Text Colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* Borders */
.border-primary { border-color: var(--border-primary); }
.border-secondary { border-color: var(--border-secondary); }

/* Card/Glass Styles - Ultra Smooth High Quality */
.glass-panel {
    background: var(--glass-dark);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-primary);
    box-shadow: 0 8px 32px var(--shadow-secondary);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease;
}

.glass-card {
    background: rgba(26, 26, 26, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
    box-shadow: 0 10px 30px var(--shadow-primary);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.35s ease, background 0.35s ease;
    will-change: transform, box-shadow;
}

.glass-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 26, 26, 0.4);
    box-shadow: 0 20px 45px rgba(255, 26, 26, 0.22);
}

body.light-mode .glass-card,
html.light-mode .glass-card {
    background: var(--glass-dark);
    box-shadow: 0 10px 30px var(--shadow-primary);
}

body.light-mode .glass-panel,
html.light-mode .glass-panel {
    background: var(--glass-dark);
}

/* ==================== COMPONENT STYLES ==================== */

/* Header/Navigation */
.glass-header {
    background: linear-gradient(135deg, rgba(255, 0, 60, 0.25) 0%, rgba(255, 0, 60, 0.15) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(255, 0, 60, 0.2);
    box-shadow: 0 8px 32px rgba(255, 0, 60, 0.12);
    transition: background 0.4s ease, border-color 0.4s ease;
}

body.light-mode .glass-header,
html.light-mode .glass-header {
    background: linear-gradient(135deg, rgba(255, 0, 60, 0.15) 0%, rgba(255, 0, 60, 0.08) 100%);
    border-bottom: 1px solid rgba(255, 0, 60, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Form Elements - High Quality Input Focus & Smooth Transition */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
textarea,
select {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-primary);
    transition: border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
    border-color: var(--highlight);
    box-shadow: 0 0 16px rgba(255, 26, 26, 0.35);
    outline: none;
}

/* Buttons - Premium Micro-Interactions */
.btn-primary {
    background: linear-gradient(135deg, #FF1A1A 0%, #8B0000 100%); /* Neon Red to Blood Red */
    color: #F2F2F2;
    border: none;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    box-shadow: 0 4px 18px rgba(59, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.btn-primary:hover::after {
    opacity: 1;
}

.btn-primary:hover {
    box-shadow: 0 8px 30px rgba(255, 26, 26, 0.55);
    transform: translateY(-2px) scale(1.015);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-primary);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-secondary:hover {
    border-color: var(--highlight);
    transform: translateY(-2px);
}

body.light-mode .btn-secondary:hover {
    background-color: var(--bg-secondary);
    border-color: var(--accent);
}

/* Tables */
table {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-collapse: separate;
    border-spacing: 0;
}

table thead {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

table tbody tr {
    transition: background-color 0.25s ease, transform 0.25s ease;
}

table tbody tr:hover {
    background-color: rgba(255, 26, 26, 0.05);
}

body.light-mode table tbody tr:hover,
html.light-mode table tbody tr:hover {
    background-color: #F0F0F0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 26, 26, 0.25);
    border-radius: 10px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--highlight);
}

/* ==================== UTILITY CLASSES ==================== */

.opacity-10 { opacity: 0.1; }
.opacity-20 { opacity: 0.2; }
.opacity-30 { opacity: 0.3; }
.opacity-50 { opacity: 0.5; }
.opacity-70 { opacity: 0.7; }
.opacity-80 { opacity: 0.8; }

/* Glow Effects */
.glow-red {
    text-shadow: 0 0 10px rgba(255, 0, 60, 0.5);
}

.glow-cyan {
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.glow-purple {
    text-shadow: 0 0 10px rgba(106, 0, 255, 0.5);
}

/* Responsive Typography */
.heading-1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--text-primary);
}

.heading-2 {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--text-primary);
}

.heading-3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.body-text {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.caption-text {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

/* ==================== ANIMATIONS ==================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

.animate-slide-up {
    animation: slideUp 0.3s ease-in-out;
}

.animate-slide-down {
    animation: slideDown 0.3s ease-in-out;
}

/* ==================== PRINT STYLES ==================== */

@media print {
    body {
        background-color: #FFFFFF;
        color: #000000;
    }
}

/* ==================== ACCESSIBILITY ==================== */

@media (prefers-reduced-motion: reduce) {
    body * {
        transition: none !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (prefers-color-scheme: light) {
    body:not(.light-mode) {
        /* Force light mode if system preference is light */
    }
}

/* ==================== LIGHT MODE CHATBOT WIDGET OVERRIDES ==================== */
body.light-mode .chatbot-panel {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%) !important;
    border: 1px solid var(--border-primary) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1) !important;
}

body.light-mode .bot-message .message-text {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary) !important;
    color: var(--text-primary) !important;
}

body.light-mode .chatbot-input-area {
    background: var(--bg-primary) !important;
    border-top: 1px solid var(--border-primary) !important;
}

body.light-mode .chatbot-input {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary) !important;
    color: var(--text-primary) !important;
}

body.light-mode .chatbot-input::placeholder {
    color: #888888 !important;
}

/* ==================== SIDEBAR DRAWER & OVERLAY SYSTEM ==================== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 310px;
    max-width: 85vw;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-primary);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.85);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.35s ease;
    visibility: hidden;
}

.sidebar-drawer.active {
    transform: translateX(0);
    visibility: visible;
}

body.light-mode .sidebar-drawer {
    background: #FFFFFF !important;
    border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.15) !important;
}

/* ==================== MOBILE NAVIGATION BAR ==================== */
.mobile-nav {
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-primary);
    box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.6);
    padding: 0 12px;
}

body.light-mode .mobile-nav {
    background: rgba(255, 255, 255, 0.95) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.08) !important;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 1.25rem;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    color: var(--highlight);
    background: rgba(255, 26, 26, 0.12);
    transform: translateY(-2px);
}

body.light-mode .mobile-nav-item {
    color: #495057 !important;
}

body.light-mode .mobile-nav-item:hover,
body.light-mode .mobile-nav-item.active {
    color: #E60000 !important;
    background: rgba(230, 0, 0, 0.1) !important;
}

/* Light Mode Overrides for Category Cards and Balance Containers */
body.light-mode .category-card {
    background: #FFFFFF !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06) !important;
}

body.light-mode .category-card:hover {
    border-color: rgba(230, 0, 0, 0.5) !important;
    box-shadow: 0 12px 30px rgba(230, 0, 0, 0.18) !important;
}

body.light-mode .balance-card {
    background: #FFFFFF !important;
    border-color: rgba(230, 0, 0, 0.25) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06) !important;
}
