/* Ultra-Modern Micro-Interaction Ecosystem Theme Switcher */

/* Dark Theme Variables */
html[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --accent: #f97316;
    --accent-dark: #ea580c;
    --success: #10b981;
    --success-dark: #059669;
    --info: #3b82f6;
    --info-dark: #2563eb;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #f97316;
    --bg-topbar: #1e293b;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-white: #ffffff;
    --text-sidebar: #f1f5f9;
    --text-sidebar-hover: #ffffff;
    --border-color: #334155;
    --border-sidebar: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --icon-color: #f1f5f9;
}

/* Dark theme specific overrides */
html[data-theme="dark"] body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .sidebar {
    background: var(--bg-sidebar) !important;
    color: var(--text-sidebar) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3), 2px 0 8px rgba(0, 0, 0, 0.2) !important;
    border-right: 1px solid var(--border-sidebar) !important;
}

html[data-theme="dark"] .topbar {
    background: var(--bg-topbar) !important;
    color: var(--text-white) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

html[data-theme="dark"] .main-content {
    background-color: var(--bg-primary) !important;
}

html[data-theme="dark"] .content-wrapper {
    background-color: var(--bg-primary) !important;
}

html[data-theme="dark"] .app-footer {
    background-color: var(--bg-secondary) !important;
    border-top: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
}

/* Dark theme form controls */
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="week"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

/* Dark theme scrollbar */
html[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

html[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.theme-switcher-container {
    position: relative;
    display: inline-block;
    margin-right: 1rem;
}

.theme-switcher {
    position: relative;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    max-width: 38px;
    max-height: 38px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    overflow: visible;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    flex-grow: 0;
    display: block;
}

.theme-switcher:hover {
    transform: scale(1.05);
}

.theme-switcher:active {
    transform: scale(0.95);
}

/* Main Icon Container */
.theme-icon-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1), 
        rgba(255, 255, 255, 0.05)
    );
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-switcher:hover .theme-icon-container {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.15), 
        rgba(255, 255, 255, 0.08)
    );
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Main Icon */
.theme-main-icon {
    font-size: 14px;
    color: #f59e0b;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
    position: relative;
}

/* Dark mode styles */
html[data-theme="dark"] .theme-main-icon {
    color: #60a5fa;
}

html[data-theme="dark"] .theme-icon-container {
    background: linear-gradient(135deg, 
        rgba(0, 0, 0, 0.3), 
        rgba(0, 0, 0, 0.1)
    );
    border: 1px solid rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .theme-switcher:hover .theme-icon-container {
    background: linear-gradient(135deg, 
        rgba(0, 0, 0, 0.4), 
        rgba(0, 0, 0, 0.2)
    );
}

/* Orbital Particles */
.orbital-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #f59e0b;
    border-radius: 50%;
    opacity: 0.6;
    transition: all 0.3s ease;
}

html[data-theme="dark"] .orbital-particle {
    background: #60a5fa;
}

.orbital-particle:nth-child(1) {
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    animation: orbit-1 4s linear infinite;
}

.orbital-particle:nth-child(2) {
    top: 50%;
    right: 5px;
    transform: translateY(-50%);
    animation: orbit-2 4s linear infinite 1s;
}

.orbital-particle:nth-child(3) {
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    animation: orbit-3 4s linear infinite 2s;
}

.orbital-particle:nth-child(4) {
    top: 50%;
    left: 5px;
    transform: translateY(-50%);
    animation: orbit-4 4s linear infinite 3s;
}

/* Breathing Background */
.breathing-bg {
    position: absolute;
    top: -7px;
    left: -7px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: radial-gradient(circle, 
        rgba(245, 158, 11, 0.1) 0%, 
        transparent 70%
    );
    animation: breathe 3s ease-in-out infinite;
    z-index: -1;
}

html[data-theme="dark"] .breathing-bg {
    background: radial-gradient(circle, 
        rgba(96, 165, 250, 0.1) 0%, 
        transparent 70%
    );
}

/* Magnetic Field Effect */
.magnetic-field {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: 1px solid rgba(245, 158, 11, 0.2);
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}

html[data-theme="dark"] .magnetic-field {
    border-color: rgba(96, 165, 250, 0.2);
}

.theme-switcher:hover .magnetic-field {
    opacity: 1;
    transform: scale(1);
    animation: magnetic-pulse 2s ease-in-out infinite;
}

/* Transition Particles */
.transition-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #f59e0b;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
}

html[data-theme="dark"] .transition-particle {
    background: #60a5fa;
}

/* Login Page Specific Styles */
.login-page .theme-switcher-container,
.register-page .theme-switcher-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.login-theme-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.login-page .theme-switcher,
.register-page .theme-switcher {
    width: 35px;
    height: 35px;
    min-width: 35px;
    min-height: 35px;
    max-width: 35px;
    max-height: 35px;
}

.login-page .theme-icon-container,
.register-page .theme-icon-container {
    width: 35px;
    height: 35px;
}

.login-page .theme-main-icon,
.register-page .theme-main-icon {
    font-size: 12px;
}

.login-page .orbital-particle,
.register-page .orbital-particle {
    width: 2px;
    height: 2px;
}

.login-page .breathing-bg,
.register-page .breathing-bg {
    width: 49px;
    height: 49px;
}

.login-page .magnetic-field,
.register-page .magnetic-field {
    width: 59px;
    height: 59px;
}

/* Animations */
@keyframes orbit-1 {
    0% { transform: translateX(-50%) rotate(0deg) translateY(-15px) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg) translateY(-15px) rotate(-360deg); }
}

@keyframes orbit-2 {
    0% { transform: translateY(-50%) rotate(0deg) translateX(15px) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg) translateX(15px) rotate(-360deg); }
}

@keyframes orbit-3 {
    0% { transform: translateX(-50%) rotate(0deg) translateY(15px) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg) translateY(15px) rotate(-360deg); }
}

@keyframes orbit-4 {
    0% { transform: translateY(-50%) rotate(0deg) translateX(-15px) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg) translateX(-15px) rotate(-360deg); }
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.1); opacity: 0.6; }
}

@keyframes magnetic-pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.05); opacity: 0.6; }
}

@keyframes particle-explosion {
    0% {
        opacity: 1;
        transform: scale(1) translate(0, 0);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) translate(var(--dx), var(--dy));
    }
}

@keyframes icon-morph {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(0.8); }
    100% { transform: rotate(360deg) scale(1); }
}

@keyframes glow-pulse {
    0%, 100% { 
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.2),
            0 0 20px rgba(245, 158, 11, 0.3);
    }
    50% { 
        box-shadow: 
            0 12px 40px rgba(0, 0, 0, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.3),
            0 0 30px rgba(245, 158, 11, 0.5);
    }
}

@keyframes glow-pulse-dark {
    0%, 100% { 
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.1),
            0 0 20px rgba(96, 165, 250, 0.3);
    }
    50% { 
        box-shadow: 
            0 12px 40px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.2),
            0 0 30px rgba(96, 165, 250, 0.5);
    }
}

/* Transition States */
.theme-switcher.transitioning .theme-main-icon {
    animation: icon-morph 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-switcher.transitioning .theme-icon-container {
    animation: glow-pulse 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="dark"] .theme-switcher.transitioning .theme-icon-container {
    animation: glow-pulse-dark 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-switcher.transitioning .orbital-particle {
    animation-duration: 0.5s;
    transform: scale(1.5);
}

/* Responsive Design */
@media (max-width: 768px) {
    .theme-switcher-container {
        margin-right: 0.5rem;
    }
    
    .theme-switcher {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        max-width: 32px;
        max-height: 32px;
    }
    
    .theme-icon-container {
        width: 32px;
        height: 32px;
    }
    
    .theme-main-icon {
        font-size: 12px;
    }
    
    .orbital-particle {
        width: 2px;
        height: 2px;
    }
    
    .breathing-bg {
        width: 46px;
        height: 46px;
    }
    
    .magnetic-field {
        width: 56px;
        height: 56px;
    }
    
    .login-page .theme-switcher {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        max-width: 30px;
        max-height: 30px;
    }
    
    .login-page .theme-icon-container {
        width: 30px;
        height: 30px;
    }
    
    .login-page .theme-main-icon {
        font-size: 10px;
    }
    
    .login-page .breathing-bg {
        width: 44px;
        height: 44px;
    }
    
    .login-page .magnetic-field {
        width: 54px;
        height: 54px;
    }
}

/* Accessibility */
.theme-switcher:focus {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
}

html[data-theme="dark"] .theme-switcher:focus {
    outline-color: #60a5fa;
}

.theme-switcher:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .orbital-particle,
    .breathing-bg,
    .magnetic-field {
        animation: none;
    }
    
    .theme-switcher,
    .theme-icon-container,
    .theme-main-icon {
        transition: none;
    }
}