/**
 * Dark Mode Toggle Button Styles
 * Professional toggle switch with smooth animations
 */

/* Hide Dark Mode Toggle */
.sidebar-theme-toggle,
.theme-toggle-wrapper {
    display: none !important;
}

/* Theme Toggle Button Container */
.theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 32px;
    border-radius: 16px;
    background: var(--surface-light);
    border: 2px solid var(--surface-border);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    padding: 0;
    overflow: hidden;
}

.theme-toggle:hover {
    background: var(--surface-border);
    border-color: var(--primary-green);
    transform: scale(1.05);
}

.theme-toggle:focus-visible {
    box-shadow: 0 0 0 4px rgba(0, 106, 78, 0.2);
    border-color: var(--primary-green);
}

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

/* Toggle Switch Indicator */
.theme-toggle::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

/* Dark Mode Active State */
.theme-toggle.dark-active {
    background: var(--primary-green);
    border-color: var(--primary-green);
}

.theme-toggle.dark-active::before {
    left: calc(100% - 25px);
    background: var(--surface-white);
}

/* Toggle Icons */
.theme-toggle-icons {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 6px;
    z-index: 1;
}

.theme-toggle i {
    font-size: 0.875rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle .fa-sun {
    color: #f59e0b;
    margin-left: auto;
}

.theme-toggle .fa-moon {
    color: #6366f1;
}

/* Hide icons based on theme */
.theme-toggle .fa-sun {
    display: none;
}

.theme-toggle.dark-active .fa-sun {
    display: inline-block;
}

.theme-toggle.dark-active .fa-moon {
    display: none;
}

/* Compact Version (for mobile/navigation) */
.theme-toggle.compact {
    width: 48px;
    height: 28px;
}

.theme-toggle.compact::before {
    width: 20px;
    height: 20px;
}

.theme-toggle.compact.dark-active::before {
    left: calc(100% - 22px);
}

.theme-toggle.compact i {
    font-size: 0.75rem;
}

/* Navigation Bar Integration */
.nav-theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-theme-toggle-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: none;
}

/* Settings Page Integration */
.settings-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    background: var(--surface-white);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.settings-theme-toggle:hover {
    background: var(--surface-light);
}

.settings-theme-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.settings-theme-info h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-theme-info p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Global Theme Transition */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Prevent transitions on initial load */
html:not(.theme-transitioning) * {
    transition: none !important;
}

/* Desktop Navigation Enhancement */
@media (min-width: 768px) {
    .nav-theme-toggle-label {
        display: inline-block;
    }

    .theme-toggle {
        width: 60px;
        height: 34px;
    }

    .theme-toggle::before {
        width: 24px;
        height: 24px;
    }

    .theme-toggle.dark-active::before {
        left: calc(100% - 28px);
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .theme-toggle {
        width: 50px;
        height: 30px;
    }

    .theme-toggle::before {
        width: 22px;
        height: 22px;
    }

    .theme-toggle.dark-active::before {
        left: calc(100% - 24px);
    }

    .settings-theme-toggle {
        padding: 1rem;
    }
}

/* Accessibility - High Contrast Mode */
@media (prefers-contrast: high) {
    .theme-toggle {
        border-width: 3px;
    }

    .theme-toggle::before {
        border: 2px solid var(--text-primary);
    }
}

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

/* Loading State */
.theme-toggle.loading {
    opacity: 0.6;
    cursor: wait;
    pointer-events: none;
}

.theme-toggle.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Tooltip for Toggle Button */
.theme-toggle-wrapper {
    position: relative;
    display: inline-block;
}

.theme-toggle-wrapper[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: var(--text-primary);
    color: var(--surface-white);
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.theme-toggle-wrapper[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text-primary);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.theme-toggle-wrapper:hover[data-tooltip]::after,
.theme-toggle-wrapper:hover[data-tooltip]::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
