/**
 * ============================================================================
 * HANNAH CHAT WIDGET v3 - SISSA GRASS (Edición Humana & Diseño Premium)
 * ============================================================================
 * Diseño de vanguardia: Glassmorphism suave, micro-animaciones fluidas,
 * tipografía cuidada, burbujas modernas y adaptación móvil perfecta.
 */

:root {
    --hannah-green-dark: #0a3319;
    --hannah-green-main: #15803d;
    --hannah-green-light: #16a34a;
    --hannah-green-accent: #22c55e;
    --hannah-emerald: #10b981;
    --hannah-wa-green: #25d366;
    --hannah-wa-dark: #128c7e;
    --hannah-bg-chat: #f8fafc;
    --hannah-text-dark: #0f172a;
    --hannah-text-body: #334155;
    --hannah-text-muted: #64748b;
    --hannah-border: #e2e8f0;
    --hannah-shadow-card: 0 4px 14px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    --hannah-shadow-window: 0 24px 50px -12px rgba(10, 51, 25, 0.25), 0 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* ============================================================================
   1. BOTÓN LANZADOR FLOTANTE (BOTTOM RIGHT)
   ============================================================================ */
.hannah-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

/* Cuando el chat está abierto, el botón lanzador se oculta limpiamente */
.hannah-launcher.launcher-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.6) translateY(20px);
}

/* Burbuja de Saludo Proactivo */
.hannah-bubble {
    background: #ffffff;
    color: var(--hannah-text-dark);
    padding: 12px 18px;
    border-radius: 20px 20px 6px 20px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.45;
    margin-bottom: 12px;
    max-width: 290px;
    border-left: 4.5px solid var(--hannah-green-accent);
    position: relative;
    animation: hannahFloatIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    border-top: 1px solid var(--hannah-border);
    border-right: 1px solid var(--hannah-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hannah-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.15);
}

.hannah-bubble strong {
    color: var(--hannah-green-main);
    font-weight: 700;
}

.hannah-bubble-close {
    position: absolute;
    top: 5px;
    right: 9px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--hannah-text-muted);
    cursor: pointer;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.15s ease, color 0.15s ease;
}

.hannah-bubble-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Botón Circular con Avatar */
.hannah-btn-launch {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #15803d, #0a3319);
    box-shadow: 0 10px 28px rgba(21, 128, 61, 0.45), 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    border: 3px solid #ffffff;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    overflow: visible;
}

.hannah-btn-launch:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 14px 36px rgba(21, 128, 61, 0.6);
}

.hannah-btn-launch:active {
    transform: scale(0.96);
}

.hannah-launcher-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Badge con pulso de En Línea */
.hannah-online-badge {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 16px;
    height: 16px;
    background: #22c55e;
    border: 2.5px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.hannah-online-badge::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid #22c55e;
    animation: hannahPulseDot 2s infinite;
}

@keyframes hannahPulseDot {
    0% { transform: scale(1); opacity: 0.8; }
    70% { transform: scale(1.9); opacity: 0; }
    100% { transform: scale(1.9); opacity: 0; }
}

@keyframes hannahFloatIn {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================================
   2. VENTANA PRINCIPAL DE CHAT (COMPACTA, FLUIDA Y ANCLADA)
   ============================================================================ */
.hannah-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 395px;
    max-width: calc(100vw - 32px);
    height: 610px;
    max-height: calc(100vh - 48px);
    background: #ffffff;
    border-radius: 24px;
    box-shadow: var(--hannah-shadow-window);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100000;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transform: scale(0.92) translateY(24px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.24s ease;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.hannah-window.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================================
   3. CABECERA PREMIUM (VERDE ESMERALDA BOSQUE CON GLASSMORPHISM)
   ============================================================================ */
.hannah-header {
    background: linear-gradient(135deg, #0a3319 0%, #15803d 60%, #16a34a 100%);
    color: #ffffff;
    padding: 15px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 16px rgba(10, 51, 25, 0.18);
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.hannah-header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hannah-header-avatar-box {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    position: relative;
    border: 2.5px solid #ffffff;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
    background: #0a3319;
    flex-shrink: 0;
}

.hannah-header-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.hannah-header-info {
    display: flex;
    flex-direction: column;
}

.hannah-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ffffff;
    line-height: 1.2;
}

.hannah-verified-icon {
    width: 16px;
    height: 16px;
    color: #4ade80;
    display: inline-block;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.hannah-header-info p {
    margin: 3px 0 0 0;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.88);
    display: flex;
    align-items: center;
    gap: 5px;
}

.hannah-header-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #22c55e;
}

/* Botones de acción en cabecera */
.hannah-header-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.hannah-btn-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    padding: 0;
}

.hannah-btn-icon:hover {
    background: rgba(255, 255, 255, 0.26);
    transform: translateY(-1px);
}

.hannah-btn-icon:active {
    transform: scale(0.94);
}

.hannah-btn-wa:hover {
    background: #25d366 !important;
    border-color: #25d366 !important;
    color: #ffffff !important;
}

/* ============================================================================
   4. CUERPO DE MENSAJES (FLEXIBLE Y SCROLL SUAVE)
   ============================================================================ */
.hannah-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    background: var(--hannah-bg-chat);
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.hannah-body::-webkit-scrollbar {
    width: 5px;
}

.hannah-body::-webkit-scrollbar-track {
    background: transparent;
}

.hannah-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Fila de Mensaje */
.hannah-msg-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: hannahMsgPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.hannah-msg-row-user {
    justify-content: flex-end;
}

@keyframes hannahMsgPop {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.hannah-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    border: 1.5px solid #ffffff;
    flex-shrink: 0;
}

/* Burbujas de Texto */
.hannah-msg {
    max-width: 82%;
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}

.hannah-msg-bot {
    background: #ffffff;
    color: var(--hannah-text-dark);
    border-radius: 18px 18px 18px 4px;
    box-shadow: var(--hannah-shadow-card);
    border: 1px solid #f1f5f9;
}

.hannah-msg-user {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #ffffff;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.28);
    font-weight: 500;
}

.hannah-msg a.hannah-link {
    color: var(--hannah-green-main);
    font-weight: 700;
    text-decoration: underline;
    transition: color 0.15s ease;
}

.hannah-msg a.hannah-link:hover {
    color: #047857;
}

.hannah-msg strong {
    font-weight: 700;
    color: #0f172a;
}

.hannah-msg-user strong {
    color: #ffffff;
}

/* ============================================================================
   5. TARJETA ELEGANTE DE WHATSAPP (CTA OFICIAL)
   ============================================================================ */
.hannah-wa-card {
    margin-top: 12px;
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    border-radius: 14px;
    padding: 12px 14px;
    text-align: center;
}

.hannah-wa-card p {
    margin: 0 0 10px 0;
    font-size: 12.5px;
    font-weight: 700;
    color: #14532d;
    line-height: 1.4;
}

.hannah-wa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #25d366;
    color: #ffffff !important;
    text-decoration: none !important;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.hannah-wa-btn:hover {
    background: #1eb855;
    transform: translateY(-1.5px);
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.55);
}

.hannah-wa-btn:active {
    transform: scale(0.98);
}

/* ============================================================================
   6. BOTONES DE RESPUESTA RÁPIDA (QUICK REPLIES)
   ============================================================================ */
.hannah-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}

.hannah-quick-chip {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    padding: 7px 13px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.hannah-quick-chip:hover {
    background: #f0fdf4;
    border-color: #86efac;
    color: #15803d;
    transform: translateY(-1.5px);
    box-shadow: 0 3px 8px rgba(21, 128, 61, 0.15);
}

.hannah-quick-chip:active {
    transform: scale(0.96);
}

/* ============================================================================
   7. INDICADOR DE ESCRITURA (TYPING ANIMATION)
   ============================================================================ */
.hannah-typing {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.hannah-typing.active {
    display: flex;
}

.hannah-typing-bubble {
    background: #ffffff;
    border: 1px solid #f1f5f9;
    padding: 10px 14px;
    border-radius: 18px 18px 18px 4px;
    box-shadow: var(--hannah-shadow-card);
    display: flex;
    align-items: center;
    gap: 4px;
}

.hannah-dot {
    width: 6.5px;
    height: 6.5px;
    background: #94a3b8;
    border-radius: 50%;
    animation: hannahWave 1.3s infinite ease-in-out;
}

.hannah-dot:nth-child(1) { animation-delay: 0s; }
.hannah-dot:nth-child(2) { animation-delay: 0.2s; }
.hannah-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes hannahWave {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; background: var(--hannah-green-main); }
}

/* ============================================================================
   8. PIE DE PÁGINA (INPUT Y ACCIÓN DE ENVÍO)
   ============================================================================ */
.hannah-footer {
    background: #ffffff;
    padding: 12px 16px 10px 16px;
    border-top: 1px solid var(--hannah-border);
    flex-shrink: 0;
}

.hannah-form {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.hannah-input {
    flex: 1;
    background: #f8fafc !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 14px !important;
    padding: 11px 16px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--hannah-text-dark) !important;
    outline: none !important;
    transition: all 0.2s ease !important;
    box-sizing: border-box !important;
}

.hannah-input:focus {
    background: #ffffff !important;
    border-color: var(--hannah-green-main) !important;
    box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.15) !important;
}

.hannah-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.hannah-submit {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
    flex-shrink: 0;
    padding: 0;
}

.hannah-submit:hover {
    background: linear-gradient(135deg, #15803d, #14532d);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(22, 163, 74, 0.5);
}

.hannah-submit:active {
    transform: scale(0.94);
}

.hannah-tagline {
    margin-top: 8px;
    text-align: center;
    font-size: 10.5px;
    color: var(--hannah-text-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ============================================================================
   9. RESPONSIVE MOBILE (< 520px)
   ============================================================================ */
@media (max-width: 520px) {
    .hannah-launcher {
        bottom: 68px !important;
        right: 14px !important;
    }
    .hannah-bubble {
        max-width: 240px !important;
        font-size: 11.5px !important;
        padding: 8px 12px !important;
        margin-bottom: 6px !important;
    }
    .hannah-btn-launch {
        width: 50px !important;
        height: 50px !important;
    }

    .hannah-btn-launch {
        width: 58px;
        height: 58px;
    }

    .hannah-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .hannah-header {
        padding: 14px 16px;
        border-radius: 0;
    }

    .hannah-msg {
        max-width: 88%;
    }
}
