/* Bellota V2 — Widget de chat IA (burbuja flotante abajo-derecha).
   Sin conflictos con el resto del CSS: todo namespaced con `.bel-chat`. */

.bel-chat {
    position: fixed;
    right: 20px; bottom: 20px;
    z-index: 9999;
    font-family: inherit;
    color: #111;
}

/* ---------------- Burbuja (botón cerrado) ---------------- */
.bel-chat-bubble {
    position: relative;
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--c-brand, #b71c1c);
    color: #fff;
    border: none;
    box-shadow: 0 6px 20px rgba(0,0,0,.22);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.bel-chat-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(0,0,0,.28);
    background: #a11818;
}
.bel-chat-bubble svg { width: 28px; height: 28px; }
.bel-chat-bubble-dot {
    position: absolute; top: 12px; right: 12px;
    width: 10px; height: 10px;
    background: #22c55e; border-radius: 50%;
    border: 2px solid var(--c-brand, #b71c1c);
}

/* ---------------- Panel abierto ---------------- */
.bel-chat-panel {
    position: absolute;
    right: 0; bottom: 76px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: min(560px, calc(100vh - 120px));
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,.18);
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: bel-chat-in .18s ease-out;
}
.bel-chat-panel[hidden] { display: none !important; }
@keyframes bel-chat-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------------- Header ---------------- */
.bel-chat-head {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px;
    background: var(--c-brand, #b71c1c);
    color: #fff;
}
.bel-chat-head-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.bel-chat-head-info strong { font-size: 14px; font-weight: 700; }
.bel-chat-head-info small { font-size: 11px; opacity: .85; }
.bel-chat-head button {
    background: transparent; border: none; color: #fff;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; border-radius: 4px;
    transition: background .15s;
}
.bel-chat-head button:hover { background: rgba(255,255,255,.15); }

/* ---------------- Body / mensajes ---------------- */
.bel-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f9fafb;
    display: flex; flex-direction: column; gap: 10px;
}
.bel-chat-welcome {
    text-align: center;
    padding: 24px 12px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.5;
}
.bel-chat-msg { max-width: 88%; }
.bel-chat-msg--user { align-self: flex-end; }
.bel-chat-msg--bot  { align-self: flex-start; }
.bel-chat-msg-body {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px; line-height: 1.45;
    word-wrap: break-word; overflow-wrap: anywhere;
}
.bel-chat-msg--user .bel-chat-msg-body {
    background: var(--c-brand, #b71c1c);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.bel-chat-msg--bot .bel-chat-msg-body {
    background: #fff;
    color: #111;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.bel-chat-msg-body p { margin: 0 0 6px; }
.bel-chat-msg-body p:last-child { margin-bottom: 0; }
.bel-chat-msg-body a {
    color: var(--c-brand, #b71c1c);
    text-decoration: underline; text-underline-offset: 2px;
}
.bel-chat-msg--user .bel-chat-msg-body a { color: #fff; }
.bel-chat-msg-body strong { font-weight: 700; }

/* Refs cards debajo del mensaje del bot */
.bel-chat-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bel-chat-ref {
    display: inline-block;
    padding: 4px 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    font-size: 11px;
    color: var(--c-brand, #b71c1c);
    text-decoration: none;
    transition: background .15s;
}
.bel-chat-ref:hover { background: #fee2e2; text-decoration: none; }

/* Indicador "escribiendo…" */
.bel-chat-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background: #fff; border: 1px solid #e5e7eb;
    border-radius: 12px; border-bottom-left-radius: 4px;
    display: inline-flex; gap: 4px;
}
.bel-chat-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: #9ca3af;
    animation: bel-chat-dot 1.2s ease-in-out infinite;
}
.bel-chat-typing span:nth-child(2) { animation-delay: .15s; }
.bel-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bel-chat-dot {
    0%, 80%, 100% { opacity: .3; transform: translateY(0); }
    40%           { opacity: 1;  transform: translateY(-3px); }
}

/* ---------------- Form ---------------- */
.bel-chat-form {
    display: flex; gap: 6px;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}
.bel-chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 22px;
    font-size: 13px;
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
    color: #111;
    background: #f9fafb;
}
.bel-chat-input:focus {
    border-color: var(--c-brand, #b71c1c);
    background: #fff;
}
.bel-chat-send {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--c-brand, #b71c1c);
    color: #fff;
    border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}
.bel-chat-send:hover:not(:disabled) { background: #a11818; }
.bel-chat-send:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- Móvil: panel a pantalla completa ---------------- */
@media (max-width: 480px) {
    .bel-chat { right: 12px; bottom: 12px; }
    .bel-chat-panel {
        right: -12px; bottom: 76px;
        width: calc(100vw - 24px);
        height: min(70vh, calc(100vh - 100px));
    }
}
