.toggle-container {
    display: inline-block;
    margin-left: var(--spacing-md);
}

#checkbox {
    display: none;
}

.label {
    height: 32px;
    width: 64px;
    background-color: var(--color-gray-200);
    border-radius: 16px;
    box-shadow: inset 0 0 5px 2px rgba(0, 0, 0, 0.1),
        inset 0 0 10px 1px rgba(0, 0, 0, 0.05),
        0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: background-color var(--transition-base),
        transform var(--transition-base);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

.label:hover {
    transform: scale(1.05);
}

.label::before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    left: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2),
        0 0 8px rgba(255, 215, 0, 0.4);
    transition: left var(--transition-base),
        background var(--transition-base),
        box-shadow var(--transition-base);
}

/* Sun icon (light mode) */
.label::after {
    content: "";
    position: absolute;
    left: 8px;
    font-size: 14px;
    transition: opacity var(--transition-fast);
    opacity: 1;
    pointer-events: none;
}

/* Moon icon (dark mode) - positioned on the right */
#checkbox:checked~.label::after {
    content: "";
    left: auto;
    right: 8px;
    opacity: 1;
}

/* Toggle switch moves to the right when checked */
#checkbox:checked~.label::before {
    left: 36px;
    background: linear-gradient(135deg, #4A5568 0%, #2D3748 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 8px rgba(160, 174, 192, 0.3);
}

/* Dark mode background */
#checkbox:checked~.label {
    background-color: var(--color-gray-700);
}

/* Hover effect when checked */
#checkbox:checked~.label:hover {
    transform: scale(1.05);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .toggle-container {
        margin-left: var(--spacing-sm);
    }

    .label {
        height: 28px;
        width: 56px;
    }

    .label::before {
        height: 20px;
        width: 20px;
    }

    #checkbox:checked~.label::before {
        left: 32px;
    }

    .label::after {
        font-size: 12px;
        left: 6px;
    }

    #checkbox:checked~.label::after {
        right: 6px;
    }
}