/**
 * Theme Toggle Button Styles
 * Responsive and accessible theme switcher styling
 * Optimized for performance with CSS classes instead of inline styles
 * Positioned in top right corner with white color scheme
 */

/* Theme toggle container with label - positioned in top right of navbar */
.theme-toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    height: auto;
}

/* Theme toggle label text - white color */
.theme-toggle-label {
    font-size: 0.875rem;
    color: #ffffff;
    font-weight: 500;
    white-space: nowrap;
}

.theme-toggle-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
    position: relative;
    overflow: hidden;
    min-width: 2.5rem;
    min-height: 1.875rem;
    will-change: background-color;
}

.theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.theme-toggle-btn:active {
    background-color: rgba(255, 255, 255, 0.3);
}

.theme-toggle-btn:focus {
    outline: 2px solid rgba(76, 201, 240, 0.8);
    outline-offset: 2px;
}

.theme-toggle-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity 0.2s ease, transform 0.2s ease;
    will-change: opacity, transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Light mode icon - visible by default */
.theme-icon-light {
    opacity: 1;
    visibility: visible;
    transform: scale(1) rotate(0deg);
}

/* Dark mode icon - hidden by default */
.theme-icon-dark {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) rotate(-180deg);
    position: absolute;
}

/* Dark mode adjustments - transparent container */

html.dark-mode .theme-toggle-label {
    color: #ffffff;
}

html.dark-mode .theme-toggle-btn {
    color: #ffffff;
}

html.dark-mode .theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

html.dark-mode .theme-toggle-btn:active {
    background-color: rgba(255, 255, 255, 0.3);
}

html.dark-mode .theme-toggle-btn svg {
    stroke: currentColor;
    fill: none;
}

/* Icon visibility in dark mode - swap states */
html.dark-mode .theme-icon-light {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) rotate(180deg);
}

html.dark-mode .theme-icon-dark {
    opacity: 1;
    visibility: visible;
    transform: scale(1) rotate(0deg);
}

/* Compact mode toggle button - maintains positioning */
.main-nav.compact .theme-toggle-container {
    /* Inherits absolute positioning, automatically adjusts with navbar height */
}

.main-nav.compact .theme-toggle-btn {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.5rem;
}

/* Icon click animation - optimized with GPU acceleration */
@keyframes iconClickPulse {
    0% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.1) rotate(90deg);
    }
    100% {
        transform: scale(1) rotate(180deg);
    }
}

.theme-toggle-btn.dark-mode-active .theme-icon-light {
    animation: iconClickPulse 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    will-change: transform;
}

.theme-toggle-btn.light-mode-active .theme-icon-dark {
    animation: iconClickPulse 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    will-change: transform;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .theme-toggle-label {
        display: none;
    }

    .theme-toggle-btn {
        padding: 0.5rem;
        min-width: 2.5rem;
        min-height: 2.5rem;
    }

    .theme-toggle-btn svg {
        width: 1.2rem;
        height: 1.2rem;
    }
}

@media (max-width: 480px) {
    .theme-toggle-container {
        position: relative;
        top: auto;
        right: auto;
        transform: none;
        gap: 0.1rem;
    }

    .theme-toggle-btn {
        padding: 0.35rem;
        min-width: 2rem;
        min-height: 2rem;
    }

    .theme-toggle-btn svg {
        width: 1rem;
        height: 1rem;
    }
}

/* Accessibility: Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .theme-toggle-btn,
    .theme-toggle-btn svg,
    .theme-icon-light,
    .theme-icon-dark {
        transition: none !important;
        animation: none !important;
    }
}

/* Focus visible for keyboard navigation */
.theme-toggle-btn:focus-visible {
    outline: 2px solid #4cc9f0;
    outline-offset: 2px;
}

html.dark-mode .theme-toggle-btn:focus-visible {
    outline: 2px solid #4cc9f0;
}
