/* =====================================================
   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 */
    --bg-primary: #FFFFFF;        /* Pure White: Main background */
    --bg-secondary: #F5F5F5;      /* Soft White: Panels & sections */
    --bg-tertiary: #E5E5E5;       /* Light Gray: Cards & borders */
    --text-tertiary: #CFCFCF;     /* Silver Gray: Secondary UI */
    --text-primary: #111111;      /* Dark Black: Main text */
    --text-secondary: #222222;    /* Charcoal Black: Headings */
    --accent: #B30000;            /* Blood Red: Main accent */
    --highlight: #FF2A2A;         /* Neon Red: Buttons & glow */
    --accent-secondary: #D10000;  /* Crimson Red: Highlights */
    --accent-glow: #FFB3B3;       /* Soft Pink Red: Background glow */
    
    /* Light Mode Borders & Shadows */
    --border-primary: #E5E5E5;
    --border-secondary: #CFCFCF;
    --shadow-primary: rgba(255, 179, 179, 0.4);
    --shadow-secondary: rgba(0, 0, 0, 0.02);
    
    /* Light Mode Glass */
    --glass-dark: rgba(245, 245, 245, 0.95);
    --glass-light: rgba(255, 179, 179, 0.15);
    
    /* Light Mode Gradients */
    --gradient-start: rgba(255, 179, 179, 0.25);
    --gradient-end: rgba(255, 255, 255, 0.05);
}

/* ==================== 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: #555555 !important;
}

body.light-mode .text-slate-500,
body.light-mode .text-gray-600 {
    color: #777777 !important;
}

/* Ensure buttons, badges and custom colored text blocks retain their light/white contrast in light mode */
body.light-mode .btn,
body.light-mode .btn-primary,
body.light-mode .badge,
body.light-mode .bg-emerald-600,
body.light-mode .bg-green-600,
body.light-mode .bg-\[\#FF1A1A\],
body.light-mode .bg-red-600,
body.light-mode [class*="bg-red-"],
body.light-mode [class*="bg-\[\#FF1A1A\]"] {
    color: #FFFFFF !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 */
.glass-panel {
    background: var(--glass-dark);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
    box-shadow: 0 8px 32px var(--shadow-secondary);
}

.glass-card {
    background: rgba(26, 26, 26, 0.75);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-primary);
    box-shadow: 0 10px 30px var(--shadow-primary);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    box-shadow: 0 15px 40px rgba(255, 26, 26, 0.25);
}

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(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 0, 60, 0.2);
    box-shadow: 0 8px 32px rgba(255, 0, 60, 0.1);
}

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 */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-primary);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(255, 0, 60, 0.3);
}

/* Buttons */
.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.05em;
    box-shadow: 0 4px 15px rgba(59, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.btn-primary:hover {
    box-shadow: 0 8px 25px rgba(255, 26, 26, 0.5);
    transform: translateY(-2px) scale(1.02);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-primary);
}

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);
}

table thead {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

table tbody tr:hover {
    background-color: var(--glass-light);
}

body.light-mode table tbody tr:hover,
html.light-mode table tbody tr:hover {
    background-color: #F0F0F0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ==================== 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;
}
