/* ═══════════════════════════════════════════════════════════════
   local_chatbot — Widget flotante
   ═══════════════════════════════════════════════════════════════ */

/* ── Contenedor raíz (esquina inferior derecha) ─────────────────── */
#local-chatbot-root {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
}

/* ── Botón flotante ──────────────────────────────────────────────── */
#chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0073aa;
    /* color institucional — cámbialo a tu gusto */
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    margin-left: auto;
    /* empuja el botón a la derecha */
}

#chatbot-toggle:hover {
    background: #005f8a;
    transform: scale(1.08);
}

/* ── Ventana del chat ────────────────────────────────────────────── */
#chatbot-window {
    width: 340px;
    max-height: 480px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
    /* animación de apertura */
    transform-origin: bottom right;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#chatbot-window.chatbot-hidden {
    display: none;
}

/* ── Encabezado ──────────────────────────────────────────────────── */
#chatbot-header {
    background: #0073aa;
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

#chatbot-header span {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chatbot-header span::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4cde80;
    border-radius: 50%;
    display: inline-block;
}

#chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}

#chatbot-close:hover {
    opacity: 1;
}

/* ── Área de mensajes ────────────────────────────────────────────── */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f6f8;
    scroll-behavior: smooth;
}

/* scrollbar sutil */
#chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

/* ── Burbujas ────────────────────────────────────────────────────── */
.chatbot-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    line-height: 1.5;
    font-size: 13px;
    white-space: pre-wrap;
    /* respeta saltos de línea del PHP */
    word-break: break-word;
}

/* Mensaje del bot — izquierda */
.chatbot-msg.bot {
    background: #ffffff;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Mensaje del usuario — derecha */
.chatbot-msg.user {
    background: #0073aa;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* ── Indicador de escritura (tres puntos animados) ───────────────── */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.chatbot-typing span {
    width: 7px;
    height: 7px;
    background: #aab;
    border-radius: 50%;
    display: inline-block;
    animation: chatbot-bounce 1.2s infinite ease-in-out;
}

.chatbot-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatbot-bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Área de input ───────────────────────────────────────────────── */
#chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e8eaed;
    background: #fff;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #dde1e7;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
    background: #f9fafb;
    color: #1a1a2e;
}

#chatbot-input:focus {
    border-color: #0073aa;
    background: #fff;
}

#chatbot-input::placeholder {
    color: #aaa;
}

#chatbot-send {
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

#chatbot-send:hover {
    background: #005f8a;
}

#chatbot-send:disabled {
    background: #aac4d4;
    cursor: default;
}

/* ── Responsivo (móvil) ──────────────────────────────────────────── */
@media (max-width: 420px) {
    #local-chatbot-root {
        bottom: 16px;
        right: 16px;
    }

    #chatbot-window {
        width: calc(100vw - 32px);
    }
}