/**
 * ===============================================================================
 * BALAM AI - Toggle Switch Component
 * ===============================================================================
 *
 * Unified toggle switch with enhanced visual design:
 * gradient knob, glow effects, hover states, active "squish" animation.
 *
 * HTML Pattern:
 *   <label class="toggle-switch">
 *     <input type="checkbox" role="switch" aria-checked="false">
 *     <span class="toggle-slider"></span>
 *   </label>
 *
 * With label text (recommended):
 *   <label class="toggle-label">
 *     <span class="toggle-text">Enable feature</span>
 *     <span class="toggle-switch">
 *       <input type="checkbox" role="switch" aria-checked="false">
 *       <span class="toggle-slider"></span>
 *     </span>
 *   </label>
 *
 * Form toggle layout (with description):
 *   <div class="balam-form-toggle">
 *     <div class="balam-form-toggle-info">
 *       <span class="toggle-label-text">Setting Name</span>
 *       <span class="toggle-desc">Description of what this does</span>
 *     </div>
 *     <label class="toggle-switch">
 *       <input type="checkbox" role="switch">
 *       <span class="toggle-slider"></span>
 *     </label>
 *   </div>
 *
 * @requires shared-variables.css
 * @version 2.0.0
 * ===============================================================================
 */

/* ===============================================================================
   Toggle Switch Container
   =============================================================================== */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

/* ===============================================================================
   Slider Track - OFF State
   =============================================================================== */

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(71, 85, 105, 0.3), rgba(51, 65, 85, 0.25));
    border: 2px solid rgba(148, 163, 184, 0.3);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 28px;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toggle-slider:hover {
    background: linear-gradient(135deg, rgba(71, 85, 105, 0.4), rgba(51, 65, 85, 0.35));
    border-color: rgba(148, 163, 184, 0.4);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Thumb/Knob - OFF State */
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 2px;
    background: linear-gradient(135deg, #f1f5f9, #cbd5e1);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

/* ===============================================================================
   Slider Track - ON State
   =============================================================================== */

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: rgba(34, 197, 94, 0.6);
    box-shadow: inset 0 2px 6px rgba(16, 185, 129, 0.4), 0 0 16px rgba(34, 197, 94, 0.3), 0 2px 8px rgba(34, 197, 94, 0.2);
}

.toggle-switch input:checked + .toggle-slider:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    border-color: rgba(34, 197, 94, 0.8);
    box-shadow: inset 0 2px 6px rgba(16, 185, 129, 0.5), 0 0 20px rgba(34, 197, 94, 0.4), 0 2px 10px rgba(34, 197, 94, 0.3);
}

/* Thumb - ON State (slides right) */
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background: linear-gradient(135deg, #ffffff, #f0fdf4);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), 0 0 12px rgba(34, 197, 94, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* ===============================================================================
   Interactive States
   =============================================================================== */

/* Active/pressed - "squish" effect for tactile feedback */
.toggle-switch input:active + .toggle-slider:before {
    width: 24px;
    transition: width 0.15s ease;
}

.toggle-switch input:checked:active + .toggle-slider:before {
    transform: translateX(20px);
}

/* Focus state - Keyboard navigation (a11y) */
.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--balam-primary);
    outline-offset: 2px;
}

/* Disabled state */
.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===============================================================================
   Label Hover Effects
   =============================================================================== */

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: var(--balam-spacing-3);
    cursor: pointer;
}

.toggle-label:hover .toggle-slider {
    border-color: rgba(148, 163, 184, 0.5);
}

.toggle-label:hover .toggle-switch input:checked + .toggle-slider {
    border-color: rgba(34, 197, 94, 0.7);
}

/* ===============================================================================
   Form Toggle Layout (toggle with label + description)
   =============================================================================== */

.balam-form-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--balam-spacing-4);
    padding: var(--balam-spacing-4);
    background: var(--balam-modal-card, #1a1a24);
    border: 1px solid var(--balam-modal-border, #2d2d3a);
    border-radius: var(--balam-radius-lg);
    transition: border-color 0.2s ease;
}

.balam-form-toggle:hover {
    border-color: var(--balam-modal-border-light, #3d3d4a);
}

.balam-form-toggle-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.toggle-label-text {
    font-size: var(--balam-text-sm);
    font-weight: var(--balam-font-semibold);
    color: var(--balam-modal-text, #ffffff);
}

.toggle-desc {
    font-size: var(--balam-text-xs);
    color: var(--balam-modal-text-muted, #9ca3af);
    line-height: 1.4;
}

/* ===============================================================================
   Reduced Motion
   =============================================================================== */

@media (prefers-reduced-motion: reduce) {
    .toggle-slider,
    .toggle-slider:before {
        transition: none;
    }

    .toggle-slider:hover {
        box-shadow: none;
    }
}
