/* ============================================================
   Asistente de ayuda (chatbot) — widget flotante, company-facing.
   Solo se carga si el chatbot está habilitado. Marca Sara (navy/aqua).
   Scopeado .sara-chat* — aditivo, no pisa nada del panel.
   ============================================================ */
.sara-chat {
    --c-navy: #062B63; --c-navy2: #0a3e8c; --c-aqua: #03DEBD; --c-aqua2: #04E6C5; --c-aqua-d: #02A38C;
    --c-ink: #1f2937; --c-muted: #6b7280; --c-line: #e6e9ee; --c-soft: #f5f7fa;
    position: fixed; right: 22px; bottom: 22px; z-index: 1080;
    font-size: .92rem;
}

/* Botón flotante */
.sara-chat-fab {
    width: 58px; height: 58px; border: 0; border-radius: 50%; cursor: pointer;
    display: grid; place-items: center; color: #062B63; font-size: 1.5rem;
    background: linear-gradient(135deg, var(--c-aqua2), var(--c-aqua-d));
    box-shadow: 0 12px 26px -8px rgba(2,163,140,.6), 0 0 0 0 rgba(4,230,197,.5);
    transition: transform .18s ease, box-shadow .18s ease;
    animation: saraPulse 2.6s ease-out 1s 3;
}
.sara-chat-fab:hover { transform: translateY(-3px) scale(1.04); }
.sara-chat.is-open .sara-chat-fab { transform: rotate(8deg); }
@keyframes saraPulse {
    0% { box-shadow: 0 12px 26px -8px rgba(2,163,140,.6), 0 0 0 0 rgba(4,230,197,.5); }
    70%{ box-shadow: 0 12px 26px -8px rgba(2,163,140,.6), 0 0 0 14px rgba(4,230,197,0); }
    100%{ box-shadow: 0 12px 26px -8px rgba(2,163,140,.6), 0 0 0 0 rgba(4,230,197,0); }
}

/* Panel de chat */
.sara-chat-panel {
    position: absolute; right: 0; bottom: 72px; width: 370px; max-width: calc(100vw - 32px);
    height: 520px; max-height: calc(100vh - 120px);
    background: #fff; border: 1px solid var(--c-line); border-radius: 18px; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 60px -18px rgba(6,43,99,.45);
    animation: saraRise .22s ease both;
}
@keyframes saraRise { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.sara-chat-head {
    background: linear-gradient(135deg, var(--c-navy), var(--c-navy2));
    color: #fff; padding: .85rem 1rem; display: flex; align-items: center; gap: .6rem;
}
.sara-chat-head .sara-ava {
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
    background: var(--c-aqua2); color: var(--c-navy); font-size: 1rem; flex: 0 0 auto;
}
.sara-chat-head .sara-ttl { font-weight: 700; line-height: 1.1; }
.sara-chat-head .sara-sub { font-size: .72rem; color: rgba(255,255,255,.75); }
.sara-chat-close {
    margin-left: auto; background: rgba(255,255,255,.12); border: 0; color: #fff;
    width: 28px; height: 28px; border-radius: 8px; cursor: pointer; display: grid; place-items: center;
    transition: background .15s ease;
}
.sara-chat-close:hover { background: rgba(255,255,255,.25); }

/* Mensajes */
.sara-chat-msgs { flex: 1 1 auto; overflow-y: auto; padding: 1rem; background: var(--c-soft); display: flex; flex-direction: column; gap: .55rem; }
.sara-msg { display: flex; }
.sara-msg-user { justify-content: flex-end; }
.sara-bubble {
    max-width: 84%; padding: .55rem .8rem; border-radius: 14px; line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0,0,0,.05); word-wrap: break-word;
}
.sara-msg-bot   .sara-bubble { background: #fff; border: 1px solid var(--c-line); border-bottom-left-radius: 5px; color: var(--c-ink); }
.sara-msg-user  .sara-bubble { background: var(--c-navy); color: #fff; border-bottom-right-radius: 5px; }
.sara-msg-error .sara-bubble { background: #fdecef; border: 1px solid #f6c6cf; color: #99203a; border-bottom-left-radius: 5px; }
.sara-bubble strong { font-weight: 700; }

/* Typing dots */
.sara-typing .sara-bubble { display: inline-flex; gap: 4px; align-items: center; }
.sara-typing .sara-bubble span {
    width: 7px; height: 7px; border-radius: 50%; background: #b6bdc8; display: inline-block;
    animation: saraBlink 1.2s infinite ease-in-out;
}
.sara-typing .sara-bubble span:nth-child(2) { animation-delay: .2s; }
.sara-typing .sara-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes saraBlink { 0%,60%,100% { opacity: .25; } 30% { opacity: 1; } }

/* Input */
.sara-chat-form { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--c-line); background: #fff; }
.sara-chat-input {
    flex: 1 1 auto; resize: none; border: 1px solid var(--c-line); border-radius: 12px;
    padding: .55rem .7rem; font: inherit; max-height: 90px; min-height: 40px; color: var(--c-ink);
}
.sara-chat-input:focus { outline: none; border-color: var(--c-aqua); box-shadow: 0 0 0 3px rgba(4,230,197,.18); }
.sara-chat-send {
    flex: 0 0 auto; width: 40px; border: 0; border-radius: 12px; cursor: pointer; color: #062B63;
    background: var(--c-aqua); display: grid; place-items: center; font-size: 1.1rem;
    transition: background .15s ease;
}
.sara-chat-send:hover:not(:disabled) { background: var(--c-aqua2); }
.sara-chat-send:disabled { opacity: .5; cursor: default; }

.sara-chat-foot { font-size: .68rem; color: var(--c-muted); text-align: center; padding: 0 .7rem .55rem; background: #fff; }

@media (max-width: 480px) {
    .sara-chat { right: 14px; bottom: 14px; }
    .sara-chat-panel { width: calc(100vw - 28px); height: calc(100vh - 110px); }
}
@media (prefers-reduced-motion: reduce) {
    .sara-chat-fab { animation: none; }
    .sara-chat-panel { animation: none; }
}
