/* Theme Switcher - Professional Light/Dark Mode System */

/* CSS Variables for Light Theme (Default) */
:root {
    /* Primary Colors */
    --primary-bg: #ffffff;
    --secondary-bg: #f8fafc;
    --accent-bg: #e2e8f0;
    --card-bg: #ffffff;
    --header-bg: rgba(30, 41, 59, 0.95);
    --footer-bg: #1e293b;
    
    /* Text Colors */
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-inverse: #ffffff;
    
    /* Brand Colors */
    --brand-primary: #0066cc;
    --brand-secondary: #004499;
    --brand-accent: #fbbf24;
    
    /* Status Colors */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    
    /* Border Colors */
    --border-light: #e2e8f0;
    --border-medium: #cbd5e0;
    --border-dark: #a0aec0;
    
    /* Shadow Colors */
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
    --shadow-heavy: rgba(0, 0, 0, 0.25);
    
    /* Theme Transition */
    --theme-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    /* Primary Colors */
    --primary-bg: #0f172a;
    --secondary-bg: #1e293b;
    --accent-bg: #334155;
    --card-bg: #1e293b;
    --header-bg: rgba(15, 23, 42, 0.95);
    --footer-bg: #0f172a;
    
    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e0;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;
    
    /* Brand Colors (Slightly adjusted for dark mode) */
    --brand-primary: #3b82f6;
    --brand-secondary: #1d4ed8;
    --brand-accent: #fbbf24;
    
    /* Status Colors (Enhanced for dark mode) */
    --success-color: #22c55e;
    --warning-color: #fbbf24;
    --error-color: #f87171;
    --info-color: #60a5fa;
    
    /* Border Colors */
    --border-light: #334155;
    --border-medium: #475569;
    --border-dark: #64748b;
    
    /* Shadow Colors */
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.4);
    --shadow-heavy: rgba(0, 0, 0, 0.6);
}

/* Universal Theme Transitions */
* {
    transition: var(--theme-transition);
}

/* Body and Background */
body {
    background-color: var(--primary-bg);
    color: var(--text-primary);
}

/* Headers and Navigation */
.navbar, .mobile-navbar {
    background: var(--header-bg) !important;
    border-bottom: 1px solid var(--border-medium);
}

.navbar-brand, .mobile-brand {
    color: var(--text-inverse) !important;
}

.nav-link {
    color: var(--text-inverse) !important;
}

/* Cards and Content Containers */
.card, .stat-card, .problem-card, .success-card, .feature-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 6px var(--shadow-light);
}

/* Buttons - Enhanced for Theme Support */
.btn-primary {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background-color: var(--brand-secondary);
    border-color: var(--brand-secondary);
}

.btn-secondary {
    background-color: var(--accent-bg);
    border-color: var(--border-medium);
    color: var(--text-primary);
}

.btn-outline-primary {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.btn-outline-primary:hover {
    background-color: var(--brand-primary);
    color: var(--text-inverse);
}

/* Forms and Inputs */
.form-control, .form-select {
    background-color: var(--card-bg);
    border-color: var(--border-medium);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    background-color: var(--card-bg);
    border-color: var(--brand-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

/* Alerts and Status Messages */
.alert-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: var(--text-inverse);
}

.alert-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: var(--text-inverse);
}

.alert-danger {
    background-color: var(--error-color);
    border-color: var(--error-color);
    color: var(--text-inverse);
}

.alert-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
    color: var(--text-inverse);
}

/* Tables */
.table {
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.table-striped > tbody > tr:nth-of-type(odd) > td,
.table-striped > tbody > tr:nth-of-type(odd) > th {
    background-color: var(--accent-bg);
}

/* Modals */
.modal-content {
    background-color: var(--card-bg);
    border: 1px solid var(--border-medium);
}

.modal-header {
    border-bottom: 1px solid var(--border-light);
}

.modal-footer {
    border-top: 1px solid var(--border-light);
}

/* 4D Shiny Animated Theme Switcher */
.theme-switcher {
    position: fixed;
    top: 140px;
    right: 25px;
    z-index: 920;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid transparent;
    border-radius: 50px;
    padding: 14px 20px;
    backdrop-filter: blur(15px);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.8),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: pulse-glow 3s ease-in-out infinite;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    user-select: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.theme-switcher::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    transform: rotate(45deg);
    animation: shine 2s linear infinite;
}

[data-theme="dark"] .theme-switcher {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    color: #f1f5f9;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .theme-switcher::before {
    background: linear-gradient(
        45deg,
        transparent,
        rgba(96, 165, 250, 0.4),
        transparent
    );
}

.theme-switcher:hover {
    transform: translateY(-3px) scale(1.05);
    filter: brightness(1.15);
    box-shadow: 
        0 12px 35px rgba(0, 0, 0, 0.25),
        inset 0 2px 0 rgba(255, 255, 255, 0.9),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .theme-switcher:hover {
    box-shadow: 
        0 12px 35px rgba(0, 0, 0, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.15),
        inset 0 -2px 0 rgba(0, 0, 0, 0.4);
}

.theme-switcher:active {
    transform: translateY(-1px) scale(0.98);
}

.theme-switcher i {
    font-size: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

/* Pulsing glow animation */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 
            0 8px 25px rgba(0, 0, 0, 0.2),
            inset 0 2px 0 rgba(255, 255, 255, 0.8),
            inset 0 -2px 0 rgba(0, 0, 0, 0.1),
            0 0 0 0 rgba(59, 130, 246, 0);
    }
    50% {
        box-shadow: 
            0 8px 25px rgba(0, 0, 0, 0.2),
            inset 0 2px 0 rgba(255, 255, 255, 0.8),
            inset 0 -2px 0 rgba(0, 0, 0, 0.1),
            0 0 0 10px rgba(59, 130, 246, 0.3);
    }
}

/* Light mode gets the pulse-glow animation by default */

[data-theme="dark"] .theme-switcher {
    animation: pulse-glow-dark 3s ease-in-out infinite;
}

@keyframes pulse-glow-dark {
    0%, 100% {
        box-shadow: 
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 2px 0 rgba(255, 255, 255, 0.1),
            inset 0 -2px 0 rgba(0, 0, 0, 0.3),
            0 0 0 0 rgba(96, 165, 250, 0);
    }
    50% {
        box-shadow: 
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 2px 0 rgba(255, 255, 255, 0.1),
            inset 0 -2px 0 rgba(0, 0, 0, 0.3),
            0 0 0 10px rgba(96, 165, 250, 0.4);
    }
}

/* Shine animation */
@keyframes shine {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}

/* Theme Icon Animation */
.theme-switcher .theme-icon {
    display: inline-block;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

[data-theme="light"] .theme-switcher .theme-icon {
    transform: rotate(0deg) scale(1.1);
}

[data-theme="dark"] .theme-switcher .theme-icon {
    transform: rotate(180deg) scale(1.1);
}

/* RESPONSIVE THEME SWITCHER POSITIONING - COMPREHENSIVE BREAKPOINT SYSTEM */

/* Large screens and up (1200px+) - Desktop navbar expanded, original positioning */
@media (min-width: 1200px) {
    .theme-switcher {
        top: 140px;
        right: 25px;
        padding: 14px 20px;
        font-size: 15px;
        z-index: 920;
    }
    
    .theme-switcher i {
        font-size: 20px;
    }
}

/* Medium-Large tablet/laptop screens (992px-1199px) - Navbar collapsed, hamburger shown */
@media (min-width: 992px) and (max-width: 1199px) {
    .theme-switcher {
        top: 100px; /* Move down to avoid hamburger menu area */
        right: 20px;
        padding: 12px 18px;
        font-size: 14px;
        z-index: 910; /* Below navbar dropdowns but above content */
    }
    
    .theme-switcher i {
        font-size: 18px;
    }
}

/* Small-Medium tablet screens (769px-991px) - Navbar collapsed, potential overlap */
@media (min-width: 769px) and (max-width: 991px) {
    .theme-switcher {
        top: 90px; /* Clear the navbar and hamburger area completely */
        right: 18px;
        padding: 11px 16px;
        font-size: 13px;
        z-index: 910;
    }
    
    .theme-switcher i {
        font-size: 17px;
    }
}

/* Mobile screens (≤768px) - Mobile navbar active, safe positioning */
@media (max-width: 768px) {
    .theme-switcher {
        top: 80px; /* Just below the 80px mobile navbar */
        right: 15px;
        padding: 12px 16px;
        font-size: 14px;
        z-index: 910; /* Below mobile menu overlay (z-index: 1001) */
    }
    
    .theme-switcher i {
        font-size: 18px;
    }
}

/* Small mobile screens (≤576px) - Compact mobile positioning */
@media (max-width: 576px) {
    .theme-switcher {
        top: 75px;
        right: 12px;
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .theme-switcher i {
        font-size: 16px;
    }
}

/* Extra small screens (≤480px) - Most compact positioning */
@media (max-width: 480px) {
    .theme-switcher {
        top: 70px;
        right: 10px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .theme-switcher i {
        font-size: 15px;
    }
}

/* COLLISION AVOIDANCE STYLING */

/* When theme switcher is in collision avoidance mode */
.theme-switcher-collision-mode {
    /* Enhanced visibility in collision mode */
    z-index: 905 !important; /* Lower than dropdowns but higher than normal content */
    animation: collision-pulse 2s ease-in-out infinite;
    border: 2px solid var(--brand-accent) !important;
}

[data-theme="dark"] .theme-switcher-collision-mode {
    border: 2px solid var(--brand-accent) !important;
    animation: collision-pulse-dark 2s ease-in-out infinite;
}

/* Collision mode pulse animation for light theme */
@keyframes collision-pulse {
    0%, 100% {
        box-shadow: 
            0 8px 25px rgba(0, 0, 0, 0.2),
            inset 0 2px 0 rgba(255, 255, 255, 0.8),
            inset 0 -2px 0 rgba(0, 0, 0, 0.1),
            0 0 0 0 rgba(251, 191, 36, 0);
    }
    50% {
        box-shadow: 
            0 8px 25px rgba(0, 0, 0, 0.2),
            inset 0 2px 0 rgba(255, 255, 255, 0.8),
            inset 0 -2px 0 rgba(0, 0, 0, 0.1),
            0 0 0 8px rgba(251, 191, 36, 0.4);
    }
}

/* Collision mode pulse animation for dark theme */
@keyframes collision-pulse-dark {
    0%, 100% {
        box-shadow: 
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 2px 0 rgba(255, 255, 255, 0.1),
            inset 0 -2px 0 rgba(0, 0, 0, 0.3),
            0 0 0 0 rgba(251, 191, 36, 0);
    }
    50% {
        box-shadow: 
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 2px 0 rgba(255, 255, 255, 0.1),
            inset 0 -2px 0 rgba(0, 0, 0, 0.3),
            0 0 0 8px rgba(251, 191, 36, 0.5);
    }
}

/* Collision mode transitions */
.theme-switcher-collision-mode {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* When theme switcher is temporarily hidden due to severe space constraints */
.theme-switcher.theme-switcher-hidden {
    opacity: 0.2 !important;
    pointer-events: none !important;
    transform: scale(0.8) !important;
}

/* Hero Sections Theme Support */
.hero-section, .legal-hero, .mobile-hero {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    color: var(--text-inverse);
}

/* Footer Theme Support */
.footer, .mobile-footer {
    background-color: var(--footer-bg);
    color: var(--text-inverse);
    border-top: 1px solid var(--border-medium);
}

/* Loading Animations Theme Support */
.storm-loading-overlay {
    background-color: rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .storm-loading-overlay {
    background-color: rgba(0, 0, 0, 0.9);
}

/* Dashboard Specific Elements */
.dashboard-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-light);
}

.sidebar {
    background-color: var(--secondary-bg);
    border-right: 1px solid var(--border-medium);
}

/* Smooth Fade Animation for Theme Switch */
@keyframes themeTransition {
    0% { opacity: 0.8; }
    50% { opacity: 0.9; }
    100% { opacity: 1; }
}

[data-theme] {
    animation: themeTransition 0.3s ease-in-out;
}

/* Professional Dark Mode Enhancements */
[data-theme="dark"] {
    /* Enhanced contrast for better readability */
    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
}

[data-theme="dark"] .navbar-toggler-icon {
    filter: invert(1);
}

[data-theme="dark"] .mobile-menu {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-medium);
}

/* Image Theme Adjustments */
[data-theme="dark"] img:not(.theme-preserve) {
    opacity: 0.9;
    transition: var(--theme-transition);
}

/* Logo sizing - ensure consistent size across themes */
#brand-logo {
    height: 120px !important;
    width: 320px !important;
    object-fit: contain !important;
}

[data-theme="dark"] .logo img {
    filter: brightness(1.1);
}

/* Ensure brand logo is properly sized in both light and dark modes */
[data-theme="light"] #brand-logo,
[data-theme="dark"] #brand-logo {
    height: 120px !important;
    width: auto !important;
}