/* ============================================================================
 * CerebroV1 · Widget de chat GASOLITO — diseño moderno + animaciones.
 * Marca: cambiá --gaso-1 / --gaso-2 para re-brandear.
 * Avatar de GASOLITO: images/gasolito-avatar.png (lo provee el cliente; hay fallback).
 * ==========================================================================*/
#chatbot-widget {
    --gaso-1: #6d5efc;
    --gaso-2: #9b6cfb;
    --gaso-bot: #f3f4fb;
    --gaso-text: #1f2430;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 99999;
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---- Botón flotante (toggle) con avatar + pulso ---- */
#chatbot-widget .chatbot-toggle {
    width: 64px; height: 64px; border-radius: 50%;
    /* background: linear-gradient(135deg, var(--gaso-1), var(--gaso-2)); */
    box-shadow: 0 10px 26px rgba(109, 94, 252, .45);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 30px; color: #fff; position: relative; overflow: hidden;
    animation: gaso-bob 3.2s ease-in-out infinite; transition: transform .2s ease;
}
#chatbot-widget .chatbot-toggle:hover { transform: scale(1.07); }
#chatbot-widget .chatbot-toggle img { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: contain; }
#chatbot-widget .chatbot-toggle::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(109, 94, 252, .55);
    animation: gaso-pulse 2.4s ease-out infinite;
}
@keyframes gaso-pulse { 0% { box-shadow: 0 0 0 0 rgba(109,94,252,.5); } 70% { box-shadow: 0 0 0 16px rgba(109,94,252,0); } 100% { box-shadow: 0 0 0 0 rgba(109,94,252,0); } }
@keyframes gaso-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---- Panel ---- */
#chatbot-widget .chatbot-panel {
    position: absolute; right: 0; bottom: 80px;
    width: 380px; max-width: calc(100vw - 32px);
    height: 560px; max-height: calc(100vh - 120px);
    background: #fff; border-radius: 20px;
    box-shadow: 0 24px 60px rgba(20, 20, 60, .28);
    display: flex; flex-direction: column; overflow: hidden;
    transform-origin: bottom right;
    animation: gaso-open .28s cubic-bezier(.18,.89,.32,1.28);
}
@keyframes gaso-open { from { opacity: 0; transform: translateY(16px) scale(.92); } to { opacity: 1; transform: none; } }

/* ---- Header con avatar + estado ---- */
#chatbot-widget .chatbot-header {
    background: linear-gradient(135deg, var(--gaso-1), var(--gaso-2));
    color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 12px;
    font-weight: 600;
}
/* Círculo claro, igual que los mini-avatares del pie del chat. */
#chatbot-widget .gaso-ava {
    width: 46px; height: 46px; border-radius: 50%;
    background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18);
    display: flex; align-items: center; justify-content: center; font-size: 24px;
    flex: 0 0 auto; animation: gaso-bob 3.2s ease-in-out infinite;
    position: relative; overflow: hidden;
}
/* La imagen se monta ENCIMA del emoji de fallback (que solo se ve si el png falla). */
#chatbot-widget .gaso-ava img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
#chatbot-widget .gaso-info { line-height: 1.15; }
#chatbot-widget .gaso-name { font-weight: 700; font-size: 15px; }
#chatbot-widget .gaso-status { font-size: 12px; opacity: .92; display: flex; align-items: center; gap: 5px; font-weight: 400; }
#chatbot-widget .gaso-dot { width: 8px; height: 8px; border-radius: 50%; background: #46f29a; animation: gaso-pulse 2s infinite; }
#chatbot-widget .gaso-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#chatbot-widget .gaso-clear-btn {
    background: none; border: none; color: #fff; cursor: pointer;
    opacity: .75; font-size: 16px; padding: 2px 4px; line-height: 1;
    transition: opacity .2s, transform .2s;
}
#chatbot-widget .gaso-clear-btn:hover { opacity: 1; transform: scale(1.15); }
#chatbot-widget .gaso-close { cursor: pointer; opacity: .85; font-size: 22px; line-height: 1; }
#chatbot-widget .gaso-close:hover { opacity: 1; }

/* ---- Barra de confirmación borrar historial ---- */
#chatbot-widget .gaso-confirm-borrar {
    display: none; align-items: center; gap: 10px; flex-wrap: wrap;
    background: #fff3cd; border-bottom: 1px solid #ffc107;
    padding: 10px 14px; font-size: 13px; color: #664d03;
}
#chatbot-widget .gaso-confirm-borrar span { flex: 1; min-width: 140px; }
#chatbot-widget .gaso-confirm-si,
#chatbot-widget .gaso-confirm-no {
    border: none; border-radius: 6px; padding: 5px 14px;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
#chatbot-widget .gaso-confirm-si { background: #dc3545; color: #fff; }
#chatbot-widget .gaso-confirm-si:hover { opacity: .85; }
#chatbot-widget .gaso-confirm-no { background: #e2e6ea; color: #333; }
#chatbot-widget .gaso-confirm-no:hover { opacity: .75; }

/* ---- Mensajes ---- */
#chatbot-widget .chatbot-messages { flex: 1; overflow-y: auto; padding: 16px 14px; background: #fafbff; display: flex; flex-direction: column; gap: 10px; }
#chatbot-widget .chatbot-messages::-webkit-scrollbar { width: 7px; }
#chatbot-widget .chatbot-messages::-webkit-scrollbar-thumb { background: #dcdfee; border-radius: 10px; }

#chatbot-widget .chatbot-msg { max-width: 82%; padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.42; color: var(--gaso-text); white-space: pre-wrap; word-wrap: break-word; animation: gaso-in .25s ease; }
@keyframes gaso-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#chatbot-widget .chatbot-msg.assistant { background: var(--gaso-bot); border-bottom-left-radius: 5px; align-self: flex-start; }
#chatbot-widget .chatbot-msg.user { background: linear-gradient(135deg, var(--gaso-1), var(--gaso-2)); color: #fff; border-bottom-right-radius: 5px; align-self: flex-end; }
#chatbot-widget .chatbot-msg.error { background: #fde8e8; color: #b3261e; }
/* Enlaces dentro del texto del bot. break-word es necesario: las URLs de producto son
   largas y sin cortar desbordan la burbuja en el ancho de un celular. 2026-08-03. */
#chatbot-widget .chatbot-link { color: var(--gaso-1, #2563eb); text-decoration: underline; overflow-wrap: anywhere; word-break: break-word; }
#chatbot-widget .chatbot-link:hover { text-decoration: none; }
#chatbot-widget .chatbot-link:focus-visible { outline: 2px solid var(--gaso-1, #2563eb); outline-offset: 2px; border-radius: 3px; }

/* fila bot con avatar chiquito */
#chatbot-widget .chatbot-row { display: flex; align-items: flex-end; gap: 8px; max-width: 90%; align-self: flex-start; }
#chatbot-widget .chatbot-row .mini-ava { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--gaso-1), var(--gaso-2)); flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 15px; color: #fff; overflow: hidden; }
#chatbot-widget .chatbot-row .mini-ava { position: relative; }
#chatbot-widget .chatbot-row .mini-ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#chatbot-widget .chatbot-row .chatbot-msg { max-width: 100%; }

/* ---- Typing (3 puntitos) ---- */
#chatbot-widget .chatbot-typing { display: inline-flex; gap: 4px; padding: 13px 14px; background: var(--gaso-bot); border-radius: 16px; border-bottom-left-radius: 5px; }
#chatbot-widget .chatbot-typing span { width: 8px; height: 8px; border-radius: 50%; background: #b9bed6; animation: gaso-typing 1.2s infinite ease-in-out; }
#chatbot-widget .chatbot-typing span:nth-child(2) { animation-delay: .18s; }
#chatbot-widget .chatbot-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes gaso-typing { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-6px); opacity: 1; } }

/* ---- Tarjetas de producto ---- */
#chatbot-widget .chatbot-product-response { background: transparent; padding: 0; max-width: 100%; align-self: stretch; }
#chatbot-widget .chatbot-intro { font-size: 14px; color: var(--gaso-text); margin: 0 0 8px; }
#chatbot-widget .chatbot-product-list { display: flex; flex-direction: column; gap: 10px; }
#chatbot-widget .chatbot-product-card { background: #fff; border: 1px solid #eceef6; border-radius: 14px; padding: 10px; display: flex; gap: 11px; align-items: center; box-shadow: 0 4px 14px rgba(30,30,70,.05); transition: transform .15s ease, box-shadow .15s ease; }
#chatbot-widget .chatbot-product-card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(109,94,252,.14); }
#chatbot-widget .chatbot-product-img-wrap { width: 64px; height: 64px; border-radius: 11px; overflow: hidden; flex: 0 0 auto; background: #f5f6fb; display: flex; align-items: center; justify-content: center; }
#chatbot-widget .chatbot-product-img { width: 100%; height: 100%; object-fit: cover; }
#chatbot-widget .chatbot-product-info { flex: 1; min-width: 0; }
#chatbot-widget .chatbot-product-name { font-weight: 600; font-size: 13.5px; color: var(--gaso-text); line-height: 1.25; margin-bottom: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#chatbot-widget .chatbot-product-price { font-weight: 800; color: var(--gaso-1); font-size: 15px; }
#chatbot-widget .chatbot-product-stock { font-size: 11px; color: #5a6072; margin-left: 6px; font-weight: 500; }
#chatbot-widget .chatbot-product-stock.out { color: #c0392b; }
#chatbot-widget .chatbot-product-actions { margin-top: 6px; display: flex; gap: 8px; align-items: center; }
#chatbot-widget .chatbot-product-card .btn-add-to-cart { display: inline-flex; align-items: center; gap: 5px; background: linear-gradient(135deg, var(--gaso-1), var(--gaso-2)); color: #fff !important; border: none; border-radius: 9px; padding: 7px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; text-decoration: none; transition: filter .15s ease; }
#chatbot-widget .chatbot-product-card .btn-add-to-cart:hover { filter: brightness(1.08); }
#chatbot-widget .chatbot-product-card .gaso-ver { font-size: 12px; color: var(--gaso-1); text-decoration: none; }
#chatbot-widget .chatbot-cierre { font-size: 13px; color: #5a6072; margin: 8px 0 0; }

/* ---- Input ---- */
#chatbot-widget .chatbot-input-area { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #eef0f7; background: #fff; }
#chatbot-widget #chatbot-input { flex: 1; border: 1.5px solid #e4e7f2; border-radius: 22px; padding: 11px 16px; font-size: 14px; outline: none; transition: border-color .15s ease; }
#chatbot-widget #chatbot-input:focus { border-color: var(--gaso-1); }
#chatbot-widget #chatbot-send { border: none; background: linear-gradient(135deg, var(--gaso-1), var(--gaso-2)); color: #fff; border-radius: 50%; width: 44px; height: 44px; cursor: pointer; font-size: 17px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; transition: transform .15s ease; }
#chatbot-widget #chatbot-send:hover { transform: scale(1.06); }
#chatbot-widget #chatbot-send:disabled { opacity: .55; cursor: default; transform: none; }

@media (max-width: 480px) {
    #chatbot-widget { right: 12px; bottom: 12px; }
    #chatbot-widget .chatbot-panel { width: calc(100vw - 24px); height: calc(100vh - 100px); bottom: 78px; }
}


/* ── Burbuja proactiva (peek) ───────────────────────────────────────────── */
#chatbot-widget .gaso-peek {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: #fff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 4px 20px rgba(109,94,252,.22), 0 1px 6px rgba(0,0,0,.10);
    padding: 12px 36px 12px 14px;
    max-width: 240px;
    min-width: 160px;
    font-size: 13.5px;
    line-height: 1.45;
    color: #1f2430;
    cursor: default;
    opacity: 0;
    transform: translateY(8px) scale(.96);
    transition: opacity .28s ease, transform .28s ease;
    z-index: 10001;
}
#chatbot-widget .gaso-peek::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 18px;
    border: 8px solid transparent;
    border-top-color: #fff;
    border-bottom: 0;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,.08));
}
#chatbot-widget .gaso-peek.gaso-peek-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
#chatbot-widget .gaso-peek-msg {
    cursor: pointer;
    color: #1f2430;
}
#chatbot-widget .gaso-peek-msg:hover { color: #6d5efc; }
#chatbot-widget .gaso-peek-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    line-height: 1;
    color: #aaa;
    cursor: pointer;
    padding: 0 2px;
}
#chatbot-widget .gaso-peek-close:hover { color: #666; }

/* ── Chips de respuesta rápida ──────────────────────────────────────────── */
#chatbot-widget .gaso-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 2px 0 4px 0;
    animation: gaso-in .25s ease;
}
#chatbot-widget .gaso-chip {
    background: #fff;
    border: 1.5px solid var(--gaso-1);
    color: var(--gaso-1);
    border-radius: 20px;
    padding: 6px 13px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .18s, color .18s, transform .12s;
    white-space: nowrap;
    line-height: 1.3;
}
#chatbot-widget .gaso-chip:hover {
    background: var(--gaso-1);
    color: #fff;
    transform: translateY(-1px);
}
#chatbot-widget .gaso-chip:active { transform: scale(.96); }

/* ── Separador de historial ─────────────────────────────────────────────── */
#chatbot-widget .gaso-separador {
    text-align: center;
    font-size: 11px;
    color: #aab;
    letter-spacing: .03em;
    padding: 4px 0;
    position: relative;
}
#chatbot-widget .gaso-separador::before,
#chatbot-widget .gaso-separador::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 22%;
    height: 1px;
    background: #e0e2ef;
}
#chatbot-widget .gaso-separador::before { left: 0; }
#chatbot-widget .gaso-separador::after  { right: 0; }

/* ── Lista de pedido ────────────────────────────────────────────────────── */
#chatbot-widget .chatbot-lista-response { display: block; }
#chatbot-widget .chatbot-lista-sec-title {
    font-size: 12px;
    font-weight: 700;
    color: #555;
    margin: 10px 0 4px;
    letter-spacing: .02em;
}
#chatbot-widget .chatbot-lista-no-enc-title { color: #b36a00; }
#chatbot-widget .chatbot-lista-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}
#chatbot-widget .chatbot-lista-card { position: relative; }
#chatbot-widget .chatbot-lista-qty-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--gaso-1, #2563eb);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 7px;
    z-index: 2;
}
#chatbot-widget .chatbot-lista-agregar-todos {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 9px 14px;
    background: var(--gaso-1, #2563eb);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}
#chatbot-widget .chatbot-lista-agregar-todos:hover { filter: brightness(1.1); }
#chatbot-widget .chatbot-lista-agregar-todos:disabled { opacity: .65; cursor: default; }
#chatbot-widget .chatbot-lista-no-enc {
    margin: 4px 0 0 16px;
    padding: 0;
    font-size: 12.5px;
    color: #b36a00;
}
#chatbot-widget .chatbot-lista-no-enc li { margin-bottom: 2px; }
