/* ===== THEME TOGGLE COMPONENT ===== */

.theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 50px;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-primary);
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
}

.theme-toggle:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-secondary);
}

.theme-toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: var(--color-surface);
    border-radius: 12px;
    border: 1px solid var(--color-border-primary);
    transition: all 0.3s ease;
    overflow: hidden;
}

.theme-toggle-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.theme-toggle.dark .theme-toggle-switch::before {
    transform: translateX(24px);
    background: var(--color-secondary);
}

.theme-toggle-icon {
    font-size: 1rem;
    color: var(--color-text-secondary);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.theme-toggle-icon.active {
    color: var(--color-primary);
    transform: scale(1.1);
}

.theme-toggle.dark .theme-toggle-icon.moon {
    color: var(--color-secondary);
    transform: scale(1.1);
}

.theme-toggle.dark .theme-toggle-icon.sun {
    color: var(--color-text-secondary);
    transform: scale(1);
}

/* Theme Toggle Label */
.theme-toggle-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-left: 0.5rem;
}

/* Compact version for navbar */
.theme-toggle-compact {
    padding: 0.25rem;
    gap: 0.25rem;
    background: transparent;
    border: none;
}

.theme-toggle-compact .theme-toggle-switch {
    width: 36px;
    height: 18px;
}

.theme-toggle-compact .theme-toggle-switch::before {
    width: 14px;
    height: 14px;
    top: 1px;
    left: 1px;
}

.theme-toggle-compact.dark .theme-toggle-switch::before {
    transform: translateX(18px);
}

.theme-toggle-compact .theme-toggle-icon {
    font-size: 0.875rem;
    width: 16px;
    height: 16px;
}

/* Animation for theme transition */
.theme-transition {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Theme preference indicator */
.theme-preference-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: var(--color-success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    color: white;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s ease;
}

.theme-toggle:hover .theme-preference-indicator {
    opacity: 1;
    transform: scale(1);
}

/* Accessibility improvements */
.theme-toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-switch {
    background: var(--color-primary-light);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .theme-toggle {
        border-width: 2px;
    }
    
    .theme-toggle-switch {
        border-width: 2px;
    }
    
    .theme-toggle-switch::before {
        border: 2px solid var(--color-bg-primary);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .theme-toggle,
    .theme-toggle-switch,
    .theme-toggle-switch::before,
    .theme-toggle-icon {
        transition: none;
    }
}

/* Full-size theme toggle for profile page */
.theme-toggle-full {
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.theme-toggle-full:hover {
    background-color: var(--color-surface-hover) !important;
    border-color: var(--color-border-secondary) !important;
}

.theme-toggle-full .theme-toggle-switch {
    width: 60px;
    height: 30px;
    border-radius: 15px;
}

.theme-toggle-full .theme-toggle-switch::before {
    width: 24px;
    height: 24px;
    top: 2px;
    left: 2px;
}

.theme-toggle-full.dark .theme-toggle-switch::before {
    transform: translateX(30px);
}

.theme-toggle-full .theme-toggle-icon {
    font-size: 1.25rem;
    width: 24px;
    height: 24px;
}

/* Dark mode specific styles */
@media (prefers-color-scheme: dark) {
    .theme-toggle {
        background: var(--color-surface-elevated);
        border-color: var(--color-border-primary);
    }
    
    .theme-toggle:hover {
        background: var(--color-surface-hover);
    }
    
    .theme-toggle-switch {
        background: var(--color-surface);
        border-color: var(--color-border-primary);
    }

    .theme-toggle-full {
        background-color: var(--color-surface-elevated) !important;
        border-color: var(--color-border-primary) !important;
    }
}
