/* Theme Toggle Styles */

/* CSS Variables for theming */
:root {
    /* Dark theme (default) */
    --bg-primary: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    --bg-secondary: rgba(255, 255, 255, 0.05);
    --bg-tertiary: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(255, 255, 255, 0.08);
    --bg-input-focus: rgba(255, 255, 255, 0.12);
    --bg-button: linear-gradient(135deg, #06b6d4, #3b82f6);
    --bg-button-hover: linear-gradient(135deg, #0891b2, #2563eb);
    --bg-success: rgba(16, 185, 129, 0.1);
    --bg-warning: rgba(6, 182, 212, 0.1);
    --bg-tooltip: rgba(15, 15, 35, 0.95);
    
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-accent: #06b6d4;
    --text-success: #10b981;
    --text-warning: #f59e0b;
    --text-error: #f87171;
    
    --border-primary: rgba(255, 255, 255, 0.1);
    --border-secondary: rgba(255, 255, 255, 0.15);
    --border-focus: #06b6d4;
    --border-success: rgba(16, 185, 129, 0.3);
    --border-warning: rgba(6, 182, 212, 0.3);
    
    --shadow-primary: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-button: 0 20px 40px -12px rgba(6, 182, 212, 0.4);
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #cbd5e1 100%);
    --bg-secondary: rgba(255, 255, 255, 0.8);
    --bg-tertiary: rgba(255, 255, 255, 0.6);
    --bg-input: rgba(255, 255, 255, 0.9);
    --bg-input-focus: rgba(255, 255, 255, 1);
    --bg-button: linear-gradient(135deg, #0891b2, #2563eb);
    --bg-button-hover: linear-gradient(135deg, #0e7490, #1d4ed8);
    --bg-success: rgba(16, 185, 129, 0.1);
    --bg-warning: rgba(6, 182, 212, 0.1);
    --bg-tooltip: rgba(30, 41, 59, 0.95);
    
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-accent: #0891b2;
    --text-success: #059669;
    --text-warning: #d97706;
    --text-error: #dc2626;
    
    --border-primary: rgba(0, 0, 0, 0.1);
    --border-secondary: rgba(0, 0, 0, 0.15);
    --border-focus: #0891b2;
    --border-success: rgba(16, 185, 129, 0.4);
    --border-warning: rgba(6, 182, 212, 0.4);
    
    --shadow-primary: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    --shadow-button: 0 20px 40px -12px rgba(8, 145, 178, 0.3);
}

/* Theme Toggle Container */
.theme-toggle-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
}

/* Theme Toggle Switch */
.theme-toggle {
    position: relative;
}

.theme-switch {
    display: none;
}

.theme-switch-label {
    display: block;
    width: 64px;
    height: 32px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 32px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.theme-switch-label:hover {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
    transform: scale(1.05);
}

.theme-switch-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: var(--text-accent);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.theme-icon {
    position: absolute;
    font-size: 12px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.5);
}

/* Dark mode (default) - show moon */
.theme-icon.moon {
    opacity: 1;
    transform: scale(1);
}

.theme-icon.sun {
    opacity: 0;
    transform: scale(0.5);
}

/* Light mode - show sun and move slider */
.theme-switch:checked + .theme-switch-label .theme-switch-slider {
    transform: translateX(32px);
    background: #f59e0b;
}

.theme-switch:checked + .theme-switch-label .theme-icon.moon {
    opacity: 0;
    transform: scale(0.5);
}

.theme-switch:checked + .theme-switch-label .theme-icon.sun {
    opacity: 1;
    transform: scale(1);
}

/* Update body to use CSS variables */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

/* Mobile responsive adjustments for theme toggle */
@media (max-width: 768px) {
    .theme-toggle-container {
        top: 1rem;
        right: 1rem;
        z-index: 9999;
    }
    
    .theme-switch-label {
        width: 56px;
        height: 28px;
        background: var(--bg-secondary);
        border: 2px solid var(--border-primary);
        border-radius: 32px;
        cursor: pointer;
        transition: all 0.3s ease;
        backdrop-filter: blur(10px);
        position: relative;
        overflow: hidden;
        display: block;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .theme-switch-slider {
        width: 20px;
        height: 20px;
        top: 2px;
        left: 2px;
        background: var(--text-accent);
        border-radius: 50%;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        position: absolute;
    }
    
    .theme-switch:checked + .theme-switch-label .theme-switch-slider {
        transform: translateX(24px);
    }
    
    .theme-icon {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .theme-toggle-container {
        top: 0.75rem;
        right: 0.75rem;
        z-index: 9999;
    }
    
    .theme-switch-label {
        width: 48px;
        height: 24px;
        background: var(--bg-secondary);
        border: 2px solid var(--border-primary);
        border-radius: 32px;
        cursor: pointer;
        transition: all 0.3s ease;
        backdrop-filter: blur(10px);
        position: relative;
        overflow: hidden;
        display: block;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .theme-switch-slider {
        width: 16px;
        height: 16px;
        top: 2px;
        left: 2px;
        background: var(--text-accent);
        border-radius: 50%;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        position: absolute;
    }
    
    .theme-switch:checked + .theme-switch-label .theme-switch-slider {
        transform: translateX(24px);
    }
    
    .theme-icon {
        font-size: 8px;
    }
}

/* Accessibility improvements */
.theme-switch:focus + .theme-switch-label {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .theme-switch-label,
    .theme-switch-slider,
    .theme-icon,
    body {
        transition: none !important;
    }
    
    .theme-switch-label:hover {
        transform: none !important;
    }
}

/* Additional mobile theme toggle fixes */
.theme-switch-label {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* Ensure proper positioning on all mobile devices */
@media (max-width: 768px) {
    .theme-toggle-container {
        position: fixed;
        top: 1rem;
        right: 1rem;
        z-index: 9999;
    }
}

/* Fix for very small screens */
@media (max-width: 320px) {
    .theme-toggle-container {
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .theme-switch-label {
        width: 44px;
        height: 22px;
    }
    
    .theme-switch-slider {
        width: 14px;
        height: 14px;
        top: 2px;
        left: 2px;
    }
    
    .theme-switch:checked + .theme-switch-label .theme-switch-slider {
        transform: translateX(22px);
    }
    
    .theme-icon {
        font-size: 7px;
    }
}

/* Improve touch responsiveness */
@media (hover: none) and (pointer: coarse) {
    .theme-switch-label {
        cursor: pointer;
        touch-action: manipulation;
    }
    
    .theme-switch-label:active {
        transform: scale(0.98);
    }
}
