/* ╔══════════════════════════════════════════════════════════════════════════════╗
   ║                    WHATSAPP WEB CLONE - CSS                                  ║
   ║                                                                              ║
   ║  Módulo: 25-ai-toggle.css                                                    ║
   ║  Descripción: Estilos para el toggle de activar/desactivar IA por contacto  ║
   ║  Fecha: 2025-01-11                                                           ║
   ╚══════════════════════════════════════════════════════════════════════════════╝ */

/* ========================================
   CONTENEDOR DEL TOGGLE DE IA
   ======================================== */

.ai-toggle-container {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 20px;
    background: rgba(0, 168, 132, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    margin-right: 4px;
}

.ai-toggle-container:hover {
    background: rgba(0, 168, 132, 0.2);
}

.ai-toggle-container.ai-paused {
    background: rgba(255, 87, 34, 0.15);
}

.ai-toggle-container.ai-paused:hover {
    background: rgba(255, 87, 34, 0.25);
}

/* ========================================
   LABEL DEL TOGGLE
   ======================================== */

.ai-toggle-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #00a884;
    transition: color 0.3s ease;
    user-select: none;
}

.ai-toggle-container.ai-paused .ai-toggle-label {
    color: #FF5722;
}

/* ========================================
   SWITCH TOGGLE ESTILO iOS/MODERNO
   ======================================== */

.ai-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.ai-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ai-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #3b4a54 0%, #2a3942 100%);
    border-radius: 24px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.2);
}

.ai-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Icono del robot dentro del slider */
.ai-toggle-slider .ai-icon {
    position: absolute;
    font-size: 10px;
    top: 50%;
    left: 26px;
    transform: translateY(-50%);
    color: #8696a0;
    transition: all 0.3s ease;
    opacity: 0.7;
}

/* Estado ACTIVO (checked) */
.ai-toggle input:checked + .ai-toggle-slider {
    background: linear-gradient(135deg, #00a884 0%, #008f6f 100%);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.1),
        0 0 12px rgba(0, 168, 132, 0.4);
}

.ai-toggle input:checked + .ai-toggle-slider:before {
    transform: translateX(20px);
    background: linear-gradient(135deg, #ffffff 0%, #e8f5e9 100%);
}

.ai-toggle input:checked + .ai-toggle-slider .ai-icon {
    left: 6px;
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
}

/* Estado INACTIVO - efecto especial */
.ai-toggle input:not(:checked) + .ai-toggle-slider {
    background: linear-gradient(135deg, #FF5722 0%, #E64A19 100%);
}

.ai-toggle input:not(:checked) + .ai-toggle-slider .ai-icon {
    color: rgba(255, 255, 255, 0.7);
    left: 26px;
}

/* ========================================
   EFECTOS DE HOVER Y FOCUS
   ======================================== */

.ai-toggle:hover .ai-toggle-slider {
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        0 0 8px rgba(0, 168, 132, 0.3);
}

.ai-toggle input:focus + .ai-toggle-slider {
    outline: 2px solid rgba(0, 168, 132, 0.5);
    outline-offset: 2px;
}

/* Efecto de "pulse" cuando se cambia */
@keyframes ai-toggle-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 168, 132, 0.5);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 168, 132, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 168, 132, 0);
    }
}

.ai-toggle-slider.pulse {
    animation: ai-toggle-pulse 0.6s ease-out;
}

/* ========================================
   TOOLTIP INFORMATIVO
   ======================================== */

.ai-toggle-container::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2c33;
    color: #e9edef;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.ai-toggle-container:hover::after {
    opacity: 1;
    visibility: visible;
    bottom: -40px;
}

/* ========================================
   INDICADOR DE CARGA
   ======================================== */

.ai-toggle-container.loading {
    pointer-events: none;
    opacity: 0.7;
}

.ai-toggle-container.loading .ai-toggle-slider:before {
    animation: ai-loading-spin 1s linear infinite;
}

@keyframes ai-loading-spin {
    from {
        transform: translateX(10px) rotate(0deg);
    }
    to {
        transform: translateX(10px) rotate(360deg);
    }
}

/* ========================================
   BADGE DE ESTADO EN LISTA DE CONTACTOS
   ======================================== */

.contact-ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
    margin-left: 6px;
}

.contact-ai-badge.ai-active {
    background: rgba(0, 168, 132, 0.2);
    color: #00a884;
}

.contact-ai-badge.ai-paused {
    background: rgba(255, 87, 34, 0.2);
    color: #FF5722;
}

.contact-ai-badge i {
    font-size: 8px;
}

/* ========================================
   RESPONSIVE - MÓVIL
   ======================================== */

@media (max-width: 768px) {
    .ai-toggle-container {
        padding: 3px 6px;
        gap: 4px;
    }
    
    .ai-toggle {
        width: 38px;
        height: 20px;
    }
    
    .ai-toggle-slider:before {
        height: 14px;
        width: 14px;
    }
    
    .ai-toggle input:checked + .ai-toggle-slider:before {
        transform: translateX(18px);
    }
    
    .ai-toggle-slider .ai-icon {
        font-size: 8px;
    }
    
    .ai-toggle-label {
        font-size: 10px;
    }
    
    /* Ocultar tooltip en móvil */
    .ai-toggle-container::after {
        display: none;
    }
}

@media (max-width: 480px) {
    /* En pantallas muy pequeñas, mostrar solo el toggle sin label */
    .ai-toggle-label {
        display: none;
    }
    
    .ai-toggle-container {
        padding: 3px 4px;
    }
}

/* ========================================
   ANIMACIÓN DE ENTRADA
   ======================================== */

.ai-toggle-container {
    animation: ai-toggle-fadein 0.3s ease-out;
}

@keyframes ai-toggle-fadein {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================
   TEMA OSCURO (ya aplicado por defecto)
   ======================================== */

/* El diseño ya está optimizado para tema oscuro */

