/* themes.css - Optimized Theme System for GetUpDeals */
:root {
    --radius-lg: 1rem;
    --warning-dark: #d97706;
    --danger-dark: #dc2626;
}

[data-theme="dark"] {
    --warning-dark: #f59e0b;
    --danger-dark: #ef4444;
}
:root {
    /* Add these missing variables */
    --radius: 0.5rem;
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;
    
    /* Shadow variables */
    --shadow-sm: 0 1px 2px var(--shadow-color-light);
    --shadow-md: 0 4px 6px var(--shadow-color);
    --shadow-lg: 0 10px 25px var(--shadow-color);
    --shadow-xl: 0 20px 40px var(--shadow-color);
    
    /* Gradient variables */
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--secondary));
    --gradient-accent: linear-gradient(135deg, var(--accent), var(--primary));
    
    /* Animation durations */
    --transition-fast: 150ms;
    --transition-normal: 300ms;
    --transition-slow: 500ms;
}



/* ==========================================================================
   Theme Configuration
   ========================================================================== */

/* Light Theme (Default) */
:root {
    /* Primary Colors */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    
    /* Secondary Colors */
    --secondary: #7c3aed;
    --secondary-dark: #6d28d9;
    
    /* Accent Colors */
    --accent: #f59e0b;
    --accent-dark: #d97706;
    
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --black: #000000;
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Background Colors */
    --bg-primary: var(--white);
    --bg-secondary: var(--gray-50);
    --bg-tertiary: var(--gray-100);
    
    /* Text Colors */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-700);
    --text-muted: var(--gray-500);
    --text-inverse: var(--white);
    
    /* Border Colors */
    --border-primary: var(--gray-200);
    --border-secondary: var(--gray-300);
    
    /* Shadow Colors */
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-color-light: rgba(0, 0, 0, 0.05);
    
    /* Theme Transition */
    --theme-transition: background-color 0.3s ease, 
                        color 0.3s ease, 
                        border-color 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    /* Primary Colors */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    
    /* Secondary Colors */
    --secondary: #8b5cf6;
    --secondary-dark: #7c3aed;
    
    /* Accent Colors */
    --accent: #fbbf24;
    --accent-dark: #f59e0b;
    
    /* Neutral Colors (Inverted) */
    --white: #111827;
    --gray-50: #1f2937;
    --gray-100: #374151;
    --gray-200: #4b5563;
    --gray-300: #6b7280;
    --gray-400: #9ca3af;
    --gray-500: #d1d5db;
    --gray-600: #e5e7eb;
    --gray-700: #f3f4f6;
    --gray-800: #f9fafb;
    --gray-900: #ffffff;
    
    /* Semantic Colors */
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #60a5fa;
    
    /* Background Colors */
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    
    /* Text Colors */
    --text-primary: #f9fafb;
    --text-secondary: #e5e7eb;
    --text-muted: #9ca3af;
    --text-inverse: #111827;
    
    /* Border Colors */
    --border-primary: #374151;
    --border-secondary: #4b5563;
    
    /* Shadow Colors */
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-color-light: rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Theme Transitions
   ========================================================================== */

/* Apply smooth transitions to theme-sensitive elements */
body {
    transition: var(--theme-transition);
}

/* Specific elements that need theme transitions */
.theme-transition {
    transition: var(--theme-transition);
}

/* ==========================================================================
   Theme-Specific Component Overrides
   ========================================================================== */

/* Dark Theme Overrides */
[data-theme="dark"] {
    /* Hero Section */
    .hero-section {
        background: linear-gradient(135deg, var(--gray-900) 0%, transparent 100%);
    }
    
    .hero-image img {
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    }
    
    /* Cards */
    .category-card,
    .deal-card,
    .blog-card,
    .testimonial-card,
    .feature-card {
        background: var(--bg-secondary);
        border-color: var(--border-primary);
    }
    
    .category-card:hover,
    .deal-card:hover,
    .blog-card:hover,
    .testimonial-card:hover,
    .feature-card:hover {
        border-color: var(--primary);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    }
    
    /* Store Tabs */
    .store-tab {
        background: var(--bg-tertiary);
    }
    
    .store-tab.active {
        background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    }
    
    /* Seasonal Deals */
    .seasonal-deals-section {
        background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    }
    
    /* Newsletter */
    .newsletter-section {
        background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-dark) 100%);
    }
    
    .newsletter-card {
        background: rgba(255, 255, 255, 0.05);
    }
    
    /* Footer */
    .main-footer {
        background: var(--gray-800);
    }
    
    .social-link {
        background: var(--gray-700);
    }
    
    .app-btn {
        background: var(--gray-700);
    }
    
    /* Forms */
    input,
    select,
    textarea {
        background: var(--bg-secondary);
        border-color: var(--border-primary);
        color: var(--text-primary);
    }
    
    input:focus,
    select:focus,
    textarea:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
    }
    
    /* Loading Overlay */
    .loading-overlay {
        background: rgba(17, 24, 39, 0.95);
    }
    
    /* Cookie Consent */
    .cookie-consent {
        background: var(--bg-secondary);
        border-color: var(--border-primary);
    }
    
    /* Top Bar */
    .top-bar {
        background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    }
    
    /* Skeleton Loaders */
    .skeleton {
        background: linear-gradient(90deg, var(--gray-800) 25%, var(--gray-700) 50%, var(--gray-800) 75%);
    }
    
    /* Alert Components */
    .alert {
        background: var(--bg-tertiary);
        border-left-color: currentColor;
    }
    
    /* Badges */
    .badge {
        color: white;
    }
    
    .badge-primary {
        background: var(--gradient-primary);
    }
    
    .badge-secondary {
        background: var(--gray-600);
    }
}

/* ==========================================================================
   Theme Toggle Components
   ========================================================================== */

/* Desktop Theme Toggle */
.theme-toggle {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: var(--gray-100);
    color: var(--gray-700);
    transition: all 0.3s ease;
    overflow: hidden;
}

.theme-toggle:hover {
    background: var(--gray-200);
    color: var(--primary);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle i {
    position: absolute;
    font-size: 1.25rem;
    transition: all 0.4s ease;
}

.theme-toggle .fa-moon {
    opacity: 1;
    transform: translateY(0);
}

.theme-toggle .fa-sun {
    opacity: 0;
    transform: translateY(20px);
}

[data-theme="dark"] .theme-toggle {
    background: var(--gray-700);
    color: var(--gray-300);
}

[data-theme="dark"] .theme-toggle:hover {
    background: var(--gray-600);
    color: var(--primary-light);
}

[data-theme="dark"] .theme-toggle .fa-moon {
    opacity: 0;
    transform: translateY(-20px);
}

[data-theme="dark"] .theme-toggle .fa-sun {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile Theme Switch */
.theme-switch-btn {
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
}

.theme-switch-btn:hover {
    background: var(--gray-200);
    color: var(--primary);
}

[data-theme="dark"] .theme-switch-btn {
    background: var(--gray-700);
    color: var(--gray-300);
}

[data-theme="dark"] .theme-switch-btn:hover {
    background: var(--gray-600);
    color: var(--primary-light);
}

/* Theme Toggle Animation */
@keyframes theme-switch {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.theme-toggle.animating {
    animation: theme-switch 0.4s ease;
}

/* ==========================================================================
   Theme Persistence Feedback
   ========================================================================== */

.theme-save-indicator {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    font-size: 0.875rem;
    opacity: 0;
    transition: all 0.4s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.theme-save-indicator.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.theme-save-indicator.success {
    background: var(--success);
}

.theme-save-indicator.error {
    background: var(--danger);
}

/* ==========================================================================
   Accessibility Features
   ========================================================================== */

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    :root {
        --theme-transition: none;
    }
    
    .theme-toggle,
    .theme-switch-btn,
    .theme-save-indicator {
        transition: none;
    }
    
    .theme-toggle.animating {
        animation: none;
    }
}

/* System theme preference */
@media (prefers-color-scheme: dark) {
    /* Auto-apply dark theme if system prefers it and user hasn't chosen */
    :root:not([data-theme]) {
        /* Variables would be applied via JavaScript */
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-primary: var(--gray-900);
        --border-secondary: var(--gray-900);
    }
    
    [data-theme="dark"] {
        --border-primary: var(--gray-300);
        --border-secondary: var(--gray-300);
    }
    
    .btn,
    .card,
    .deal-card {
        border-width: 2px;
    }
}

/* ==========================================================================
   Theme Loading State
   ========================================================================== */

/* Prevent Flash of Unstyled Content */
html.theme-loading * {
    visibility: hidden;
}

html.theme-loaded * {
    visibility: visible;
}

/* ==========================================================================
   Theme-Aware Images
   ========================================================================== */

/* Hide/show images based on theme */
.img-light {
    display: block;
}

.img-dark {
    display: none;
}

[data-theme="dark"] .img-light {
    display: none;
}

[data-theme="dark"] .img-dark {
    display: block;
}

/* Image adjustments for dark mode */
[data-theme="dark"] img {
    opacity: 0.9;
}

[data-theme="dark"] img:hover {
    opacity: 1;
}

/* ==========================================================================
   Theme Gradients
   ========================================================================== */

/* Light Theme Gradients */
[data-theme="light"] {
    .gradient-primary {
        background: linear-gradient(135deg, var(--primary), var(--secondary));
    }
    
    .gradient-accent {
        background: linear-gradient(135deg, var(--accent), var(--primary));
    }
    
    .gradient-subtle {
        background: linear-gradient(135deg, var(--gray-50), var(--white));
    }
}

/* Dark Theme Gradients */
[data-theme="dark"] {
    .gradient-primary {
        background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    }
    
    .gradient-accent {
        background: linear-gradient(135deg, var(--accent), var(--primary));
    }
    
    .gradient-subtle {
        background: linear-gradient(135deg, var(--gray-800), var(--gray-900));
    }
}

/* ==========================================================================
   Print Styles (Ignore Themes)
   ========================================================================== */

@media print {
    [data-theme] {
        --white: #ffffff !important;
        --black: #000000 !important;
        --text-primary: #000000 !important;
        --bg-primary: #ffffff !important;
        --border-primary: #cccccc !important;
    }
    
    .theme-toggle,
    .theme-switch-btn,
    .theme-save-indicator {
        display: none !important;
    }
}

/* ==========================================================================
   Responsive Theme Adjustments
   ========================================================================== */

/* Mobile theme adjustments */
@media (max-width: 767px) {
    .theme-toggle {
        width: 40px;
        height: 40px;
    }
    
    .theme-toggle i {
        font-size: 1.125rem;
    }
    
    .theme-save-indicator {
        bottom: 1rem;
        padding: 0.625rem 1.25rem;
        font-size: 0.8125rem;
    }
}

/* Tablet theme adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
    .theme-toggle:hover {
        transform: translateY(-2px);
    }
}

/* ==========================================================================
   Theme Debug (Development Only - Comment out for production)
   ========================================================================== */

/*
.theme-debug {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    border: 1px solid var(--border-primary);
    z-index: 9999;
    opacity: 0.8;
}

.theme-debug::before {
    content: "Theme: " attr(data-theme);
}
*/

/* ==========================================================================
   Custom Scrollbar (Theme Aware)
   ========================================================================== */

/* Light Theme Scrollbar */
[data-theme="light"] ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

[data-theme="light"] ::-webkit-scrollbar-track {
    background: var(--gray-100);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 5px;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Dark Theme Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--gray-800);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--gray-600);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* ==========================================================================
   Selection Colors (Theme Aware)
   ========================================================================== */

[data-theme="light"] ::selection {
    background-color: var(--primary-100);
    color: var(--primary);
}

[data-theme="dark"] ::selection {
    background-color: var(--primary-50);
    color: var(--primary-light);
}

/* ==========================================================================
   Focus Styles (Theme Aware)
   ========================================================================== */

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

[data-theme="dark"] :focus-visible {
    outline-color: var(--primary-light);
}

/* ==========================================================================
   End of Themes CSS
   ========================================================================== */