/* ============================================
   MASTER THEME SYSTEM - Light & Dark Modes
   Single source of truth for all colors
   Consolidated and optimized for performance
   ============================================ */

:root {
    /* === LIGHT MODE COLORS === */
    
    /* Brand Colors */
    --primary-blue: #1a3a52;
    --primary-navy: #1a3a52;
    --dark-blue: #0d1f2d;
    --light-blue: #f0f9ff;
    
    --accent-gold: #ff6b35;
    --accent-gold-dark: #ff5214;
    --dark-gold: #ff5214;
    --light-gold: #fff4e6;
    
    /* Neutral Palette */
    --gray-900: #1a1a1a;
    --gray-800: #2d2d2d;
    --gray-700: #4a4a4a;
    --gray-600: #5a5a5a;
    --gray-500: #6f6f6f;
    --gray-400: #9a9a9a;
    --gray-300: #d9d9d9;
    --gray-200: #e5e5e5;
    --gray-100: #f5f5f5;
    --white: #ffffff;
    
    /* Semantic Colors - Light Mode */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-700);
    --text-tertiary: var(--gray-500);
    --text-inverse: var(--white);
    
    --bg-primary: var(--white);
    --bg-secondary: var(--gray-100);
    --bg-elevated: var(--white);
    --background-gray: var(--gray-100);
    
    --border-default: var(--gray-300);
    --border-subtle: rgba(0, 0, 0, 0.1);
    --border-gray: var(--gray-300);
    
    --surface-white: var(--white);
    
    /* Interactive States */
    --hover-overlay: rgba(0, 0, 0, 0.05);
    --active-overlay: rgba(0, 0, 0, 0.1);
    --focus-ring: 0 0 0 3px rgba(26, 58, 82, 0.2);
    
    /* Status Colors */
    --success-green: #28a745;
    --professional-red: #dc3545;
    --urgent-blue: #2c5aa0;
    
    /* Shadows - Light Mode */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 5px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
    
    /* Typography */
    --font-primary: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-size-base: 16px;
    --line-height-base: 1.7;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-xxl: 4rem;
    
    /* Container */
    --container-max: 1200px;
    --container-padding: 20px;
    
    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Z-index */
    --z-header: 1000;
    --z-modal: 10000;
}

/* ============================================
   DARK MODE OVERRIDES
   Automatically applied when html.dark-mode
   ============================================ */

html.dark-mode {
    color-scheme: dark;
    
    /* Brand Colors - Adjusted for dark backgrounds */
    --primary-blue: #60a5fa;
    --primary-navy: #60a5fa;
    --dark-blue: #93c5fd;
    --light-blue: #1e3a4c;
    
    --accent-gold: #fbbf24;
    --accent-gold-dark: #f59e0b;
    --dark-gold: #f59e0b;
    --light-gold: #1f2937;
    
    /* Neutral Palette - Inverted for dark mode */
    --gray-900: #f3f4f6;
    --gray-800: #e5e7eb;
    --gray-700: #d1d5db;
    --gray-600: #b5b8bd;
    --gray-500: #9ca3af;
    --gray-400: #6b7280;
    --gray-300: #374151;
    --gray-200: #2d3748;
    --gray-100: #111827;
    --white: #1f2937;
    
    /* Semantic Colors - Dark Mode */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-700);
    --text-tertiary: var(--gray-500);
    --text-inverse: #1a1a1a;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-elevated: #1f2937;
    --background-gray: #111827;
    
    --border-default: var(--gray-300);
    --border-subtle: rgba(255, 255, 255, 0.1);
    --border-gray: var(--gray-300);
    
    --surface-white: #1f2937;
    
    /* Interactive States - Dark Mode */
    --hover-overlay: rgba(255, 255, 255, 0.05);
    --active-overlay: rgba(255, 255, 255, 0.1);
    --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.3);
    
    /* Shadows - Deeper for dark mode */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 5px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.7);
}

/* ============================================
   GLOBAL DARK MODE STYLES
   Base styling that applies to all elements
   ============================================ */

html.dark-mode body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(251, 191, 36, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(251, 191, 36, 0.05) 0px, transparent 50%);
    color: var(--text-primary);
}

/* Subtle texture overlay for premium feel */
html.dark-mode body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.015) 2px, rgba(255,255,255,0.015) 4px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

/* ============================================
   TYPOGRAPHY - DARK MODE
   Automatic color inheritance from variables
   ============================================ */

/* DARK MODE - ALL TEXT WHITE */
html.dark-mode h1,
html.dark-mode h2,
html.dark-mode h3,
html.dark-mode h4,
html.dark-mode h5,
html.dark-mode h6 {
    color: #ffffff !important;
}

html.dark-mode p,
html.dark-mode span:not(.btn *):not(.inline-icon),
html.dark-mode li,
html.dark-mode td,
html.dark-mode div,
html.dark-mode a:not(.btn) {
    color: #ffffff !important;
}

html.dark-mode .text-muted,
html.dark-mode .text-tertiary,
html.dark-mode small {
    color: rgba(255, 255, 255, 0.7) !important;
}

html.dark-mode label {
    color: #ffffff !important;
}

/* ============================================
   HEADER - DARK MODE
   ============================================ */

html.dark-mode header {
    background: rgba(15, 23, 42, 0.98) !important; /* DARK background */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* LIGHT MODE - White header */
html:not(.dark-mode) header {
    background: rgba(255, 255, 255, 0.98) !important; /* WHITE background */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

html.dark-mode .logo {
    color: var(--primary-blue);
    text-shadow: 0 2px 4px rgba(96, 165, 250, 0.2);
}

html.dark-mode .desktop-menu a {
    color: var(--text-primary);
}

html.dark-mode .desktop-menu a:hover {
    color: var(--primary-blue);
}

/* ============================================
   MOBILE MENU - DARK MODE
   ============================================ */

html.dark-mode .mobile-menu-overlay {
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(10px);
}

html.dark-mode .mobile-menu-content {
    background: rgba(30, 41, 59, 0.98);
    border-right: 1px solid var(--border-default);
}

html.dark-mode .mobile-menu-list a {
    color: var(--text-primary);
}

html.dark-mode .mobile-menu-list a:hover {
    background: var(--hover-overlay);
    color: var(--primary-blue);
}

/* ============================================
   CARDS - DARK MODE
   ============================================ */

html.dark-mode .usluga-card,
html.dark-mode .testimonial-card,
html.dark-mode .card,
html.dark-mode .blog-article {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
}

html.dark-mode .usluga-card:hover,
html.dark-mode .testimonial-card:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6),
                0 0 0 1px var(--primary-blue);
}

html.dark-mode .usluga-card h3,
html.dark-mode .testimonial-card h3 {
    color: var(--text-primary);
}

html.dark-mode .usluga-card p,
html.dark-mode .testimonial-card p {
    color: var(--text-secondary);
}

/* Icon system dark mode handled in icons.css */
html.dark-mode .usluga-icon {
    /* Legacy compatibility */
    color: var(--primary-blue);
}

html.dark-mode .price-tag {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: white;
    border: 2px solid rgba(96, 165, 250, 0.4);
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.2);
}

/* ============================================
   FORMS - DARK MODE
   ============================================ */

html.dark-mode input,
html.dark-mode textarea,
html.dark-mode select {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.8) 100%);
    color: var(--text-primary);
    border: 2px solid var(--border-default);
}

html.dark-mode input::placeholder,
html.dark-mode textarea::placeholder {
    color: var(--text-tertiary);
    opacity: 0.7;
}

html.dark-mode input:focus,
html.dark-mode textarea:focus,
html.dark-mode select:focus {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    border-color: var(--primary-blue);
    box-shadow: var(--focus-ring);
    outline: none;
}

/* ============================================
   BUTTONS - DARK MODE
   Subtle enhancements to base button styles
   ============================================ */

html.dark-mode .btn-primary {
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
}

html.dark-mode .btn-primary:hover {
    box-shadow: 0 8px 25px rgba(251, 191, 36, 0.4);
}

html.dark-mode .btn-secondary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.3);
}

html.dark-mode .btn-secondary:hover {
    box-shadow: 0 8px 25px rgba(96, 165, 250, 0.4);
}

html.dark-mode .btn-small {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #3b82f6 100%);
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.2);
}

html.dark-mode .btn-small:hover {
    background: linear-gradient(135deg, var(--dark-blue) 0%, var(--primary-blue) 100%);
    box-shadow: 0 8px 25px rgba(96, 165, 250, 0.3);
}

/* ============================================
   MODALS - DARK MODE
   ============================================ */

html.dark-mode .modal-overlay {
    background: rgba(15, 23, 42, 0.90);
    backdrop-filter: blur(8px);
}

html.dark-mode .modal-content,
html.dark-mode .modal-text {
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-subtle);
}

html.dark-mode .modal-close {
    background: var(--gray-300);
    color: var(--text-primary);
}

html.dark-mode .modal-close:hover {
    background: var(--primary-blue);
    color: white;
}

/* ============================================
   TABLES - DARK MODE
   ============================================ */

html.dark-mode table {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
}

html.dark-mode table th {
    background: rgba(96, 165, 250, 0.1);
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-default);
}

html.dark-mode table td {
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

html.dark-mode table tr:hover {
    background: var(--hover-overlay);
}

/* ============================================
   FOOTER - DARK MODE
   ============================================ */

html.dark-mode footer {
    background: rgba(15, 23, 42, 0.98);
    border-top: 1px solid var(--border-default);
    color: var(--text-primary);
}

html.dark-mode .footer-section h4,
html.dark-mode .footer-section p {
    color: var(--text-primary);
}

html.dark-mode .footer-section a,
html.dark-mode footer a {
    color: var(--primary-blue);
}

html.dark-mode .footer-section a:hover,
html.dark-mode footer a:hover {
    color: var(--dark-blue);
}

html.dark-mode .copyright {
    color: var(--text-tertiary);
}

/* ============================================
   FOOTER - LIGHT MODE (FIX TEXT VISIBILITY)
   ============================================ */

/* Footer is blue background, so text must be white in light mode too */
html:not(.dark-mode) footer {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #1e40af 100%);
    color: white !important;
}

html:not(.dark-mode) .footer-section h4,
html:not(.dark-mode) .footer-section p,
html:not(.dark-mode) .footer-column h3,
html:not(.dark-mode) .footer-column p {
    color: white !important;
}

html:not(.dark-mode) .footer-section a,
html:not(.dark-mode) .footer-column a,
html:not(.dark-mode) footer a {
    color: white !important;
}

html:not(.dark-mode) .footer-section a:hover,
html:not(.dark-mode) .footer-column a:hover,
html:not(.dark-mode) footer a:hover {
    color: white !important;
}

html:not(.dark-mode) .copyright {
    color: white !important;
}

/* ============================================
   WIDGETS - DARK MODE
   ============================================ */

html.dark-mode .faq-widget,
html.dark-mode .weather-widget {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
}

html.dark-mode .faq-item {
    border-bottom: 1px solid var(--border-subtle);
}

html.dark-mode .faq-question {
    color: var(--text-primary);
}

html.dark-mode .faq-answer {
    color: var(--text-secondary);
}

/* ============================================
   GALLERY - DARK MODE
   ============================================ */

html.dark-mode .gallery-item {
    border: 1px solid var(--border-subtle);
}

html.dark-mode .gallery-item:hover {
    border-color: var(--primary-blue);
    box-shadow: var(--shadow-lg);
}

/* ============================================
   SCROLLBAR - DARK MODE (Webkit)
   ============================================ */

html.dark-mode ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

html.dark-mode ::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

html.dark-mode ::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.3);
    border-radius: 6px;
}

html.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: rgba(96, 165, 250, 0.5);
}

/* ============================================
   ACCESSIBILITY - FOCUS STATES
   Works in both light and dark modes
   ============================================ */

*:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU acceleration for animated elements */
.btn, 
.usluga-card, 
.modal-content,
.testimonial-card {
    transform: translateZ(0);
    will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    html.dark-mode {
        --text-primary: #ffffff;
        --text-secondary: #e5e7eb;
        --border-default: var(--primary-blue);
    }
    
    html.dark-mode *:focus-visible {
        outline-width: 4px;
    }
}

/* ============================================
   MOBILE OPTIMIZATIONS
   Simplified gradients for better performance
   ============================================ */

@media (max-width: 768px) {
    /* Simplify gradients on mobile for performance */
    html.dark-mode .btn-primary,
    html.dark-mode .btn-secondary,
    html.dark-mode .btn-small {
        background: var(--primary-blue);
    }
    
    html.dark-mode .usluga-card,
    html.dark-mode .testimonial-card {
        background: var(--bg-elevated);
    }
    
    html.dark-mode body {
        background-image: none;
        background-color: var(--bg-primary);
    }
}

/* ============================================
   SMOOTH TRANSITIONS
   Applies to mode switching
   ============================================ */

html.dark-mode * {
    transition-property: background-color, border-color, color, box-shadow;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}

/* Exclude fast-animating elements from mode transition */
html.dark-mode .btn *,
html.dark-mode .hero-slide,
html.dark-mode .slider-dots {
    transition-duration: 0.15s;
}

/* ============================================
   LIGHT MODE - ALL TEXT DARK GREY
   Default mode - applies when NO dark-mode class
   ============================================ */

html:not(.dark-mode) h1,
html:not(.dark-mode) h2,
html:not(.dark-mode) h3,
html:not(.dark-mode) h4,
html:not(.dark-mode) h5,
html:not(.dark-mode) h6 {
    color: #2d3748 !important; /* Dark grey for headings */
}

html:not(.dark-mode) p,
html:not(.dark-mode) span:not(.btn *):not(.inline-icon),
html:not(.dark-mode) li,
html:not(.dark-mode) td,
html:not(.dark-mode) div,
html:not(.dark-mode) a:not(.btn) {
    color: #4a5568 !important; /* Medium dark grey for body text */
}

html:not(.dark-mode) .text-muted,
html:not(.dark-mode) .text-tertiary,
html:not(.dark-mode) small {
    color: #718096 !important; /* Lighter grey for secondary text */
}

html:not(.dark-mode) label {
    color: #2d3748 !important;
}

/* Icon handling moved to components.css */

/* Ensure button text is readable in both modes */
html:not(.dark-mode) .btn,
html:not(.dark-mode) .btn-primary,
html:not(.dark-mode) .btn-secondary {
    color: #ffffff !important;
}

html.dark-mode .btn,
html.dark-mode .btn-primary,
html.dark-mode .btn-secondary {
    color: #ffffff !important;
}
