.switch {
    position: relative;
    display: inline-block;
    width: 80px;  /* Width of the switch */
    height: 34px; /* Height of the switch */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
    margin: 0;
}

/* Hide the default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* 3. The Slider (The Background) */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc; /* Default OFF color */
    transition: .4s;
    border-radius: 34px; /* Makes it round */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    overflow: hidden;
}

/* 4. The Knob (The White Circle) */
.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    z-index: 2; /* Ensure knob is on top of text */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 5. The Text Labels (ON / OFF) */
.on-text, .off-text {
    color: white;
    font-size: 12px;
    font-weight: bold;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.on-text {
    left: 12px;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.4s;
}

.off-text {
    right: 12px;
    opacity: 1; /* Visible by default */
    transition: opacity 0.4s;
}

/* 6. Checked State (When clicked) */
input:checked + .slider {
    background-color: #2196F3; /* Modern Blue */
}

/* Move the knob to the right */
input:checked + .slider:before {
    transform: translateX(46px); /* Width - Height - Margin correction */
}

/* Show/Hide Text based on state */
input:checked + .slider .on-text {
    opacity: 1;
}

input:checked + .slider .off-text {
    opacity: 0;
}