/**
 * Professional Theme Toggle System CSS
 * ====================================
 * 
 * Class-based theme system (replaces prefers-color-scheme media queries)
 * Works on desktop and mobile
 * Smooth transitions
 * No duplicate code
 * 
 * Author: KoreaSewa Development Team
 * Version: 1.0.0
 * Last Updated: 2025-01-XX
 */

/* ============================================
   Theme Transition - Smooth Color Changes
   ============================================ */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
    transition: background-color 0.2s ease,
                border-color 0.2s ease,
                color 0.2s ease,
                fill 0.2s ease,
                stroke 0.2s ease !important;
    transition-delay: 0s !important;
}

/* ============================================
   Theme Toggle Button - Professional Design
   ============================================ */
.theme-toggle,
[data-theme-toggle] {
    /* Base styles */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    
    /* Icon sizing */
    line-height: 1;
}

.theme-toggle i,
[data-theme-toggle] i {
    font-size: 1.125rem;
    width: 1.125rem;
    height: 1.125rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.theme-toggle:hover,
[data-theme-toggle]:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

.theme-toggle:active,
[data-theme-toggle]:active {
    transform: scale(0.95);
}

.theme-toggle:focus,
[data-theme-toggle]:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.theme-toggle:focus:not(:focus-visible),
[data-theme-toggle]:focus:not(:focus-visible) {
    outline: none;
}

/* Glass style used in header - Legacy support */
.theme-toggle-glass {
    position: relative;
    padding: 0.35rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.95), rgba(218, 233, 255, 0.7));
    border: 1px solid rgba(59, 130, 246, 0.25);
    box-shadow: 0 15px 35px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.45);
    color: #1d4ed8;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle-glass::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.5), rgba(99, 102, 241, 0.4), rgba(236, 72, 153, 0.35));
    opacity: 0.8;
    z-index: -1;
}

.theme-toggle-glass::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 999px;
    background: radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.9), transparent 60%);
    opacity: 0.6;
    pointer-events: none;
}

.theme-toggle-glass:hover {
    transform: translateY(-1px);
    box-shadow: 0 22px 45px rgba(15, 23, 42, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

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

.theme-toggle-glass i {
    color: currentColor;
    font-size: 1.2rem;
}

[data-theme="dark"] .theme-toggle-glass,
html[data-theme="dark"] .theme-toggle-glass,
body.theme-dark .theme-toggle-glass {
    background: radial-gradient(circle at 35% 35%, rgba(20, 83, 197, 0.35), rgba(0, 4, 15, 0.9));
    border-color: rgba(14, 165, 233, 0.35);
    color: #facc15;
    box-shadow: 0 25px 50px rgba(2, 6, 23, 0.85), 0 0 25px rgba(56, 189, 248, 0.35);
}

[data-theme="dark"] .theme-toggle-glass::before,
html[data-theme="dark"] .theme-toggle-glass::before,
body.theme-dark .theme-toggle-glass::before {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.45), rgba(99, 102, 241, 0.55), rgba(244, 114, 182, 0.45));
    opacity: 0.95;
}

[data-theme="dark"] .theme-toggle-glass::after,
html[data-theme="dark"] .theme-toggle-glass::after,
body.theme-dark .theme-toggle-glass::after {
    opacity: 0.75;
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.35), transparent 65%);
}

/* Modern Theme Toggle - Enhanced Visibility & User-Friendly Design */
.theme-toggle-modern {
    position: relative;
    padding: 0;
    min-width: 3rem;
    min-height: 3rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.3);
    background: linear-gradient(135deg, #93c5fd 0%, #a78bfa 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25), 
                0 2px 4px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.theme-toggle-modern::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 70%);
    opacity: 0.6;
    pointer-events: none;
}

.theme-toggle-modern:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35), 
                0 4px 8px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.4);
    border-color: rgba(59, 130, 246, 0.5);
}

.theme-toggle-modern:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3), 
                inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.theme-toggle-modern:focus {
    outline: 3px solid rgba(59, 130, 246, 0.4);
    outline-offset: 2px;
}

.theme-toggle-modern:focus:not(:focus-visible) {
    outline: none;
}

.theme-toggle-modern i {
    font-size: 1.25rem !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    z-index: 1;
    position: relative;
    visibility: visible !important;
    opacity: 1 !important;
    font-family: "bootstrap-icons", "bootstrap-icons-fallback", sans-serif !important;
    font-style: normal !important;
    font-weight: normal !important;
    font-variant: normal !important;
    text-transform: none !important;
    speak: none !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Light mode icon color - dark blue for visibility */
.theme-toggle-modern .theme-icon-light {
    color: #1e40af !important;
}

/* Dark mode icon color - yellow for visibility */
.theme-toggle-modern .theme-icon-dark {
    color: #fbbf24 !important;
}

/* Light mode - show sun icon, hide moon icon */
.theme-toggle-modern .theme-icon-light {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 1.25rem !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    color: #1e40af !important;
    font-family: "bootstrap-icons", "bootstrap-icons-fallback", sans-serif !important;
    font-style: normal !important;
    font-weight: normal !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

.theme-toggle-modern .theme-icon-dark {
    display: none !important;
    visibility: hidden !important;
}

/* Dark Mode State - Modern Toggle */
[data-theme="dark"] .theme-toggle-modern,
html[data-theme="dark"] .theme-toggle-modern,
body.theme-dark .theme-toggle-modern {
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
    border-color: rgba(147, 197, 253, 0.4);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4), 
                0 2px 4px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.2),
                0 0 20px rgba(147, 197, 253, 0.3);
    color: #fbbf24;
}

[data-theme="dark"] .theme-toggle-modern:hover,
html[data-theme="dark"] .theme-toggle-modern:hover,
body.theme-dark .theme-toggle-modern:hover {
    box-shadow: 0 6px 20px rgba(30, 64, 175, 0.5), 
                0 4px 8px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.3),
                0 0 25px rgba(147, 197, 253, 0.4);
    border-color: rgba(147, 197, 253, 0.6);
}

/* Dark mode - hide sun icon, show moon icon */
[data-theme="dark"] .theme-toggle-modern .theme-icon-light,
html[data-theme="dark"] .theme-toggle-modern .theme-icon-light,
body.theme-dark .theme-toggle-modern .theme-icon-light {
    display: none !important;
    visibility: hidden !important;
}

[data-theme="dark"] .theme-toggle-modern .theme-icon-dark,
html[data-theme="dark"] .theme-toggle-modern .theme-icon-dark,
body.theme-dark .theme-toggle-modern .theme-icon-dark {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 1.25rem !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    color: #fbbf24 !important;
    font-family: "bootstrap-icons", "bootstrap-icons-fallback", sans-serif !important;
    font-style: normal !important;
    font-weight: normal !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Dark mode button styles */
[data-theme="dark"] .theme-toggle,
[data-theme="dark"] [data-theme-toggle] {
    color: #fbbf24;
}

[data-theme="dark"] .theme-toggle:hover,
[data-theme="dark"] [data-theme-toggle]:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Light mode button styles */
[data-theme="light"] .theme-toggle,
[data-theme="light"] [data-theme-toggle] {
    color: #1e40af;
}

[data-theme="light"] .theme-toggle:hover,
[data-theme="light"] [data-theme-toggle]:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

/* Compact button variant */
.theme-toggle-compact,
[data-theme-toggle].compact {
    padding: 0.375rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
    border-radius: 50%;
}

.theme-toggle-compact .theme-toggle-text,
[data-theme-toggle].compact .theme-toggle-text {
    display: none;
}

/* Icon-only variant */
.theme-toggle-icon-only,
[data-theme-toggle].icon-only {
    padding: 0.5rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
    border-radius: 50%;
}

.theme-toggle-icon-only .theme-toggle-text,
[data-theme-toggle].icon-only .theme-toggle-text {
    display: none;
}

/* ============================================
   Dark Mode Styles - Class-Based (Replaces Media Query)
   ============================================ */
/* CRITICAL: Use [data-theme="dark"] instead of @media (prefers-color-scheme: dark) */
/* This gives user control over theme */

[data-theme="dark"],
[data-theme="dark"] body.theme-dark {
    /* Footer Dark Mode Variables */
    --footer-bg: #1a1a1a;
    --footer-border: #333;
    --footer-text: #a0a0a0;
    --footer-text-dark: #d0d0d0;
    --footer-title: #ffffff;
    --footer-link: #4a9eff;
    --footer-link-hover: #5bb0ff;
    --footer-brand-korea: #4a9eff;
    --footer-brand-sewa: #ff4a4a;
    
    /* Core Variables Dark Mode */
    --ks-bg-primary: #0f172a;
    --ks-bg-secondary: #1e293b;
    --ks-bg-tertiary: #334155;
    --ks-text-primary: #f1f5f9;
    --ks-text-secondary: #cbd5e1;
    --ks-text-muted: #94a3b8;
    --ks-text-light: #64748b;
    --ks-text-dark: #e2e8f0;
    --ks-border-light: #334155;
    --ks-border: #475569;
    --ks-border-dark: #64748b;
}

/* Footer Dark Mode - Class-Based */
[data-theme="dark"] .unified-footer {
    background: var(--footer-bg);
    border-top-color: var(--footer-border);
    color: var(--footer-text);
}

[data-theme="dark"] .unified-footer-title {
    color: var(--footer-title);
}

[data-theme="dark"] .unified-footer-brand-link {
    color: var(--footer-brand-korea);
}

[data-theme="dark"] .unified-footer-brand-link:hover {
    color: var(--footer-link-hover);
}

[data-theme="dark"] .unified-footer a {
    color: var(--footer-link);
}

[data-theme="dark"] .unified-footer a:hover {
    color: var(--footer-link-hover);
}

/* Compact Footer Dark Mode */
[data-theme="dark"] .footer-ultra {
    background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 50%, #0a0a0a 100%);
    border-top-color: #333;
    color: #a0a0a0;
}

[data-theme="dark"] .footer-ultra * {
    color: inherit;
}

/* Hero Slider Dark Mode - Class-Based */
[data-theme="dark"] .hero-slider-section {
    background: transparent;
}

/* Team Page Dark Mode - Class-Based */
[data-theme="dark"] .team-page-modern {
    --team-bg: #0f172a;
    --team-bg-alt: #1e293b;
    --team-text: #f1f5f9;
    --team-text-muted: #94a3b8;
    --team-border: #334155;
    --team-glass-bg: rgba(30, 41, 59, 0.7);
    --team-glass-border: rgba(255, 255, 255, 0.1);
    background: var(--team-bg);
    color: var(--team-text);
}

/* ============================================
   Mobile Optimizations
   ============================================ */
@media (max-width: 768px) {
    .theme-toggle,
    [data-theme-toggle] {
        padding: 0.5rem;
        min-width: 2.75rem;
        min-height: 2.75rem;
        font-size: 0.8125rem;
    }
    
    .theme-toggle i,
    [data-theme-toggle] i {
        font-size: 1.25rem;
    }
    
    .theme-toggle-modern {
        min-width: 2.75rem;
        min-height: 2.75rem;
        width: 2.75rem;
        height: 2.75rem;
    }
    
    .theme-toggle-modern i {
        font-size: 1.15rem;
    }
    
    .theme-toggle-text {
        display: none; /* Hide text on mobile, show icon only */
    }
}

/* ============================================
   Accessibility - Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    html.theme-transitioning,
    html.theme-transitioning *,
    html.theme-transitioning *::before,
    html.theme-transitioning *::after {
        transition: none !important;
    }
    
    .theme-toggle i,
    [data-theme-toggle] i {
        transition: none !important;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .theme-toggle,
    [data-theme-toggle] {
        display: none !important;
    }
    
    /* Force light mode for printing */
    [data-theme="dark"] {
        --footer-bg: #ffffff;
        --footer-text: #000000;
        --footer-title: #000000;
    }
}

