.theme-toggle {
    position: relative;
    width: 60px;
    height: 32px;
    border-radius: 16px;
    background: var(--color-bg-alt);
    border: 2px solid var(--color-border);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    margin-left: 16px;
}
.theme-toggle:hover { border-color: var(--color-green); }
.theme-toggle:focus { outline: none; box-shadow: 0 0 0 3px rgba(45,122,79,.2); }

.theme-toggle-circle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-green);
    transition: transform 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.theme-toggle-icon {
    position: static;
    font-size: 12px;
    line-height: 1;
    transition: opacity 0.3s ease;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

.theme-toggle-icon.sun {
    opacity: 1;
}

.theme-toggle-icon.moon {
    opacity: 0;
    position: absolute;
}

/* Light mode: cerchio a sinistra (default) */
[data-theme="light"] .theme-toggle-circle {
    transform: translateX(0);
}

[data-theme="light"] .theme-toggle-icon.sun {
    opacity: 1;
}

[data-theme="light"] .theme-toggle-icon.moon {
    opacity: 0;
}

/* Dark mode: cerchio a destra */
[data-theme="dark"] .theme-toggle-circle {
    transform: translateX(28px);
}

[data-theme="dark"] .theme-toggle-icon.sun {
    opacity: 0;
}

[data-theme="dark"] .theme-toggle-icon.moon {
    opacity: 1;
}

@media (max-width: 768px) {
    .theme-toggle {
        width: 52px;
        height: 28px;
        margin-left: 8px;
    }
    .theme-toggle-circle {
        width: 22px;
        height: 22px;
        top: 1px;
        left: 1px;
    }
    [data-theme="dark"] .theme-toggle-circle {
        transform: translateX(22px);
    }
    .theme-toggle-icon {
        font-size: 11px;
    }
}
