/* ============================================
   Theme Toggle Button
   ============================================ */

#theme-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--bg-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), transform var(--transition-fast);
    margin-right: 16px;
}

#theme-toggle:hover {
    background: var(--hover-overlay);
    transform: scale(1.05);
}

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

/* Theme Icons (Moon & Sun) */
.theme-icon {
    width: 20px;
    height: 20px;
    position: relative;
    display: block;
}

/* Sun Icon (Light Mode) */
.theme-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--text-primary);
    border-radius: 50%;
    box-shadow:
        0 -16px 0 -8px var(--text-primary),
        0 16px 0 -8px var(--text-primary),
        -16px 0 0 -8px var(--text-primary),
        16px 0 0 -8px var(--text-primary),
        -12px -12px 0 -8px var(--text-primary),
        12px 12px 0 -8px var(--text-primary),
        -12px 12px 0 -8px var(--text-primary),
        12px -12px 0 -8px var(--text-primary);
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

/* Moon Icon (Dark Mode) */
[data-theme="dark"] .theme-icon::before {
    transform: translate(-50%, -50%) rotate(180deg) scale(0);
    opacity: 0;
}

[data-theme="dark"] .theme-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: var(--text-primary);
    border-radius: 50%;
    box-shadow: -6px -2px 0 -2px var(--bg-secondary);
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.theme-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-180deg) scale(0);
    opacity: 0;
    width: 16px;
    height: 16px;
    background: var(--text-primary);
    border-radius: 50%;
    box-shadow: -6px -2px 0 -2px var(--bg-secondary);
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

[data-theme="dark"] .theme-icon::after {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    opacity: 1;
}

/* Smooth icon transition on theme change */
@media (prefers-reduced-motion: reduce) {
    #theme-toggle,
    .theme-icon::before,
    .theme-icon::after {
        transition: none;
    }
}

/* Focus styles for accessibility */
#theme-toggle:focus {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* Hover effect enhancement */
#theme-toggle:hover .theme-icon::before,
#theme-toggle:hover .theme-icon::after {
    filter: brightness(1.2);
}
