/* ============================================================================
   CHATBOT CESQ - ESTILOS PERSONALIZADOS
   ============================================================================*/

/* --------------------------------------------------------------------------
   Variables CSS (sobreescriben variables de @n8n/chat)
   -------------------------------------------------------------------------- */
:root {
    --chat--color--primary: #242B57;
    --chat--color--secondary: #4197CB;
    --chat--color--accent: #D4A574;
    --chat--window--width: 380px;
    --chat--window--height: 660px;
    --chat--toggle--size: 60px;
    --chat--toggle--hover--background: #4197CB;
    --chat--message--user--background: #e8f4fd;
    --chat--message--user--color: #1e3a8a;
    --chat--message--bot--background: #ffffff;
    --chat--message--bot--color: #242B57;
    --chat--header--background: linear-gradient(135deg, #242B57 0%, #1a2041 100%);
    --chat--header--color: #ffffff;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --------------------------------------------------------------------------
   Toast Notification (Burbuja de bienvenida)
   -------------------------------------------------------------------------- */
.toast-notification {
    position: fixed;
    bottom: 80px;
    right: 40px;
    width: 320px;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(36, 43, 87, 0.2), 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 9998;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-left: 4px solid #D4A574;
}

.toast-notification.show {
    transform: translateX(0);
}

.toast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toast-header h4 {
    margin: 0;
    font-weight: 600;
    color: var(--chat--color--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #aaa;
    margin-bottom: 32px;
}

.toast-close:hover {
    color: var(--chat--color--primary);
}

.toast-body p {
    margin: 0 0 16px 0;
    color: #333;
    font-size: 14px;
}

.toast-actions button {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #242B57 0%, #4197CB 100%);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(36, 43, 87, 0.3);
}

.toast-actions button:hover {
    background: linear-gradient(135deg, #1a2041 0%, #2d7bb4 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(36, 43, 87, 0.4);
}

/* --------------------------------------------------------------------------
   Quick Replies (Respuestas rápidas)
   - Toggle funciona con CSS puro usando checkbox :checked
   -------------------------------------------------------------------------- */
.custom-quick-replies {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 17px;
    margin-bottom: 48px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    max-height: 200px;
    margin-left: auto;
    margin-right: auto;
}

/* Checkbox invisible que controla el estado del toggle */
.quick-replies-toggle-checkbox {
    display: none;
}

/* Label que actúa como botón toggle */
.quick-replies-toggle-label {
    display: block;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #475569;
    margin-bottom: 8px;
    width: 100%;
    text-align: center;
    user-select: none;
}

.quick-replies-toggle-label:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: #242B57;
}

/*
   NOTA SOBRE EL SÍMBOLO ~ (tilde):
   En CSS, ~ es el "combinador de hermano general" (general sibling combinator).
   Selecciona elementos hermanos que aparecen DESPUÉS del primer elemento,
   sin importar si están inmediatamente adyacentes o no.
   
   Ejemplo: .checkbox ~ .label selecciona .label cuando es hermano de .checkbox
   y aparece después en el DOM (comparten el mismo elemento padre).
*/

/* Texto del toggle: Ocultar opciones (estado por defecto) */
.quick-replies-toggle-checkbox:not(:checked) ~ .quick-replies-toggle-label::before {
    content: "📋 Ocultar opciones";
}
/*
   Significa: "Cuando el checkbox NO está marcado (:not(:checked)),
   selecciona el ::before del label que es hermano del checkbox
   y aparece después de él en el DOM".
*/

/* Texto del toggle: Mostrar opciones (checkbox checked) */
.quick-replies-toggle-checkbox:checked ~ .quick-replies-toggle-label::before {
    content: "📋 Mostrar opciones";
}

/* Grid de respuestas rápidas - visible por defecto */
.quick-replies-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Cuando el checkbox está checked, ocultar el grid */
.quick-replies-toggle-checkbox:checked ~ .quick-replies-grid {
    display: none;
}

.quick-reply-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.1s ease;
    text-align: center;
    color: #334155;
    will-change: transform, background, color;
}

.quick-reply-btn:hover {
    background: linear-gradient(135deg, #242B57 0%, #4197CB 100%);
    color: white;
    border-color: #4197CB;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(36, 43, 87, 0.2);
}

/* --------------------------------------------------------------------------
   Header del Chat
   -------------------------------------------------------------------------- */
.chat-header {
    background: linear-gradient(135deg, #242B57 0%, #4197CB 100%) !important;
}

.chat-header h1 {
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 23px !important;
    line-height: 1.2 !important;
    letter-spacing: 1.2px !important;
    text-shadow: 0 4px 8px rgba(0,0,0,0.4) !important;
    text-transform: uppercase !important;
    opacity: 0.95 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.chat-header p {
    display: none !important;
}

/* --------------------------------------------------------------------------
   Burbuja Flotante del Chat (Toggle Button)
   -------------------------------------------------------------------------- */
.chat-window-toggle {
    background: linear-gradient(135deg, #242B57 0%, #4197CB 100%) !important;
    box-shadow: 0 2px 6px rgba(65, 151, 203, 0.2) !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

.chat-window-toggle:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 3px 10px rgba(65, 151, 203, 0.25) !important;
}

/* --------------------------------------------------------------------------
   Animación de Pulso (cuando carga la página)
   -------------------------------------------------------------------------- */
@keyframes pulse-bubble {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 6px rgba(65, 151, 203, 0.2);
        filter: brightness(1);
    }
    25%, 75% {
        transform: scale(1.12);
        box-shadow: 0 3px 10px rgba(65, 151, 203, 0.25);
        filter: brightness(1.15);
    }
    50% {
        transform: scale(1.12);
        box-shadow: 0 3px 10px rgba(212, 165, 116, 0.22);
        filter: brightness(1.25) saturate(1.2);
    }
}

.chat-window-toggle.pulse {
    animation: pulse-bubble 0.8s ease-in-out 2;
}

/* --------------------------------------------------------------------------
   Ventana del Chat
   -------------------------------------------------------------------------- */
.chat-window {
    border-radius: 12px !important;
    overflow: hidden !important;
}

.chat-input,
.chat-window input,
.chat-window textarea {
    margin-bottom: 8px;
}
