/*
 * static/css/switches.css — Toggle switches custom para todo el proyecto.
 *
 * Aplica a cualquier <div class="form-check form-switch"> con un <input>
 * y un <label for="..."> adentro (estructura estándar de Django + Bootstrap).
 *
 * Por qué este patrón en lugar del switch nativo de Bootstrap:
 *   - El switch nativo usa un SVG semi-transparente dentro de
 *     background-image del <input>. Sobre fondo oscuro (theme arcade)
 *     el SVG y el track quedan prácticamente invisibles.
 *   - Los pseudo-elementos ::before / ::after NO funcionan en <input>
 *     en todos los browsers (es replaced element).
 *   - Solución: ocultar el <input> nativo y dibujar el switch en el <label>
 *     con ::before (track) + ::after (thumb). El click en el label dispara
 *     el checkbox via `for=`, así que el form POST funciona igual.
 *
 * Estado visual:
 *   OFF: track gris oscuro (#1a1a2e) con borde cyan 3px + thumb blanco
 *        a la IZQUIERDA. Glow suave en hover.
 *   ON:  track cyan brillante (#00ffcc) con glow exterior 20px + thumb
 *        blanco DESLIZADO a la DERECHA. Imposible no notar.
 */

.form-check.form-switch {
    display: block !important;
    padding: 0 !important;
    min-height: 0 !important;
    position: relative;
}

/* Ocultar el <input> nativo sin sacarlo del DOM (sigue posteándose). */
.form-check.form-switch .form-check-input {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
}

.form-check.form-switch .form-check-label {
    cursor: pointer;
    color: #fff !important;
    position: relative;
    padding-left: 4em;
    display: inline-block;
    line-height: 1.8em;
    font-weight: 600;
    font-size: 0.95rem;
    user-select: none;
    margin: 0 !important;
}

/* Track (la pill) */
.form-check.form-switch .form-check-label::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3.2em;
    height: 1.7em;
    background: #1a1a2e;
    border: 3px solid #00ffcc;
    border-radius: 1.7em;
    transition: background-color .2s, box-shadow .2s;
    box-sizing: border-box;
}

/* Thumb (el círculo que se desliza) */
.form-check.form-switch .form-check-label::after {
    content: "";
    position: absolute;
    left: 0.3em;
    top: 50%;
    transform: translateY(-50%);
    width: 1.05em;
    height: 1.05em;
    background: #fff;
    border-radius: 50%;
    transition: left .2s ease-out;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,0,0,0.15);
}

/* Hover sobre cualquier parte del label */
.form-check.form-switch .form-check-label:hover::before {
    background: #252540;
    box-shadow: 0 0 12px rgba(0,255,204,0.5);
}

/* Checked: track cyan brillante + thumb deslizado a la derecha + glow */
.form-check.form-switch .form-check-input:checked ~ .form-check-label::before {
    background: #00ffcc;
    box-shadow: 0 0 20px rgba(0,255,204,0.7);
}
.form-check.form-switch .form-check-input:checked ~ .form-check-label::after {
    left: 1.85em;
}

/* Focus por teclado (el input invisible recibe foco via Tab) */
.form-check.form-switch .form-check-input:focus ~ .form-check-label::before {
    box-shadow: 0 0 0 3px rgba(0,255,204,0.45);
}
.form-check.form-switch .form-check-input:checked:focus ~ .form-check-label::before {
    box-shadow: 0 0 20px rgba(0,255,204,0.7),
                0 0 0 3px rgba(0,255,204,0.45);
}

/* Disabled — para casos donde el form bloquea el toggle */
.form-check.form-switch .form-check-input:disabled ~ .form-check-label {
    opacity: 0.5;
    cursor: not-allowed;
}
.form-check.form-switch .form-check-input:disabled ~ .form-check-label::before {
    border-color: rgba(255,255,255,0.25);
}
