/* Berimbolario Chat · Flyzo Studio */
.bchat {
    --bc-ink: #161616;
    --bc-ink-2: #3b3b3b;
    --bc-muted: #7b7b7b;
    --bc-line: #ececec;
    --bc-soft: #f4f4f6;
    --bc-blue: #1e5bd8;
    --bc-purple: #6b2fb3;
    --bc-grad: linear-gradient(135deg, #1e5bd8 0%, #6b2fb3 100%);
    --bc-green: #22b357;
    font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14.5px;
    line-height: 1.45;
    color: var(--bc-ink);
}
.bchat *, .bchat *::before, .bchat *::after { box-sizing: border-box; }
.bchat [hidden] { display: none !important; }
.bchat button { font: inherit; color: inherit; }

/* ---------- Botón flotante (encima del de WhatsApp) ---------- */
.bchat-launcher {
    position: fixed;
    right: 18px;
    bottom: 92px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background: var(--bc-grad);
    color: #fff !important;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 0 10px 28px rgba(30, 91, 216, 0.38), 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform .25s cubic-bezier(.2, .9, .3, 1.3), box-shadow .25s ease;
}
.bchat-launcher:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 14px 34px rgba(107, 47, 179, 0.42), 0 2px 6px rgba(0, 0, 0, 0.2); }
.bchat-launcher::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(30, 91, 216, 0.35);
    animation: bchat-pulse 2.8s ease-out infinite;
    pointer-events: none;
}
.bchat.is-open .bchat-launcher::after { display: none; }
@keyframes bchat-pulse { 0% { transform: scale(.9); opacity: .9; } 70%, 100% { transform: scale(1.25); opacity: 0; } }
.bchat-launcher__ico { position: absolute; display: grid; place-items: center; transition: transform .3s ease, opacity .2s ease; }
.bchat-launcher__ico svg { width: 28px; height: 28px; }
.bchat-launcher__ico--close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.bchat.is-open .bchat-launcher__ico--chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.bchat.is-open .bchat-launcher__ico--close { opacity: 1; transform: none; }
.bchat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #e02424;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    border: 2px solid #fff;
}

/* Bocadillo de invitación */
.bchat-hint {
    position: fixed;
    right: 90px;
    bottom: 100px;
    z-index: 9998;
    max-width: 230px;
    padding: 12px 34px 12px 14px;
    border-radius: 14px 14px 4px 14px;
    background: #fff;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    animation: bchat-in .35s cubic-bezier(.2, .9, .3, 1.2);
}
.bchat-hint strong { display: block; font-family: "Poppins", sans-serif; font-size: 14px; }
.bchat-hint span { color: var(--bc-muted); font-size: 13px; }
.bchat-hint__x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; background: none; color: var(--bc-muted); cursor: pointer; padding: 3px; }
.bchat-hint__x svg { width: 16px; height: 16px; }
@keyframes bchat-in { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }

/* ---------- Panel ---------- */
.bchat-panel {
    position: fixed;
    right: 18px;
    bottom: 166px;
    z-index: 9999;
    width: 390px;
    height: min(640px, calc(100vh - 190px));
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28), 0 4px 14px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(.97);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.bchat.is-open .bchat-panel { opacity: 1; visibility: visible; transform: none; transition: opacity .22s ease, transform .26s cubic-bezier(.2, .9, .3, 1.15), visibility 0s; }

.bchat-head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 12px 16px 16px;
    background: #161616;
    color: #fff;
}
.bchat-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--bc-grad); }
.bchat-avatar { width: 44px; height: 44px; border-radius: 50%; background: #fff; display: grid; place-items: center; flex: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12); }
.bchat-avatar img { width: 30px; height: 30px; object-fit: contain; }
.bchat-head__txt { flex: 1; min-width: 0; }
.bchat-head__txt strong { display: block; font-family: "Poppins", sans-serif; font-weight: 600; font-size: 16px; letter-spacing: .2px; }
.bchat-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: rgba(255, 255, 255, 0.72); }
.bchat-status em { font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bchat-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--bc-green); box-shadow: 0 0 0 3px rgba(34, 179, 87, 0.25); flex: none; }
.bchat-status.is-human i { background: #f5b301; box-shadow: 0 0 0 3px rgba(245, 179, 1, 0.25); }
.bchat-icon { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: #fff !important; cursor: pointer; display: grid; place-items: center; flex: none; transition: background-color .15s ease; }
.bchat-icon:hover { background: rgba(255, 255, 255, 0.12); }
.bchat-icon svg { width: 20px; height: 20px; }

.bchat-menu {
    position: absolute;
    top: 62px;
    right: 12px;
    z-index: 3;
    min-width: 220px;
    padding: 6px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
    animation: bchat-in .18s ease;
}
.bchat-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--bc-ink) !important; text-align: left; cursor: pointer; font-size: 14px; }
.bchat-menu button:hover { background: var(--bc-soft); }
.bchat-menu svg { width: 18px; height: 18px; color: var(--bc-muted); }

/* ---------- Mensajes ---------- */
.bchat-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 14px 8px; background: #fafafa; scroll-behavior: smooth; }
.bchat-list { display: flex; flex-direction: column; gap: 10px; }
.bchat-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; animation: bchat-msg .25s ease; }
@keyframes bchat-msg { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bchat-bubble {
    max-width: 86%;
    padding: 10px 14px;
    border-radius: 18px 18px 18px 6px;
    background: #fff;
    border: 1px solid var(--bc-line);
    color: var(--bc-ink);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.bchat-bubble a { color: var(--bc-blue); text-decoration: underline; }
.bchat-bubble strong { font-weight: 700; }
.bchat-msg--cliente { align-items: flex-end; }
.bchat-msg--cliente .bchat-bubble { background: #161616; border-color: #161616; color: #fff; border-radius: 18px 18px 6px 18px; }
.bchat-msg--cliente .bchat-bubble a { color: #fff; }
.bchat-msg--admin .bchat-bubble { background: #eef3ff; border-color: #d6e2ff; }
.bchat-who { font-size: 11.5px; font-weight: 600; color: var(--bc-blue); margin: 0 0 4px 6px; }
.bchat-msg time { font-size: 10.5px; color: #a6a6a6; margin: 3px 6px 0; }
.bchat-sys { align-self: center; max-width: 92%; margin: 4px auto; padding: 10px 14px; border-radius: 12px; background: #fff7e0; border: 1px solid #f5e1a4; color: #5c4a12; font-size: 13px; text-align: center; }
.bchat-msg--sistema { align-items: center; }

.bchat-typing .bchat-bubble { display: flex; gap: 5px; padding: 14px 16px; }
.bchat-typing i { width: 7px; height: 7px; border-radius: 50%; background: #b5b5b5; animation: bchat-dot 1.1s infinite ease-in-out; }
.bchat-typing i:nth-child(2) { animation-delay: .15s; }
.bchat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bchat-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }

/* Botones rápidos */
.bchat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-width: 100%; }
.bchat-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid #d9d9e3;
    background: #fff;
    color: var(--bc-ink) !important;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none !important;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.bchat-chip:hover { border-color: var(--bc-blue); background: #f2f6ff; transform: translateY(-1px); }
.bchat-chips.is-old { display: none; }

/* Tarjetas de producto */
.bchat-prods { display: flex; gap: 10px; overflow-x: auto; max-width: 100%; padding: 8px 2px 6px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.bchat-prod {
    flex: 0 0 150px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--bc-line);
    color: var(--bc-ink) !important;
    text-decoration: none !important;
    transition: box-shadow .2s ease, transform .2s ease;
}
.bchat-prod:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(0, 0, 0, 0.1); }
.bchat-prod__img { display: grid; place-items: center; height: 130px; border-radius: 10px; background: var(--bc-soft); overflow: hidden; font-size: 34px; margin-bottom: 4px; }
.bchat-prod__img img { width: 100%; height: 100%; object-fit: cover; }
.bchat-prod small { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--bc-muted); }
.bchat-prod b { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bchat-prod__precio { font-weight: 700; font-size: 14px; }
.bchat-prod__precio s { font-weight: 400; color: var(--bc-muted); font-size: 12px; margin-left: 4px; }
.bchat-prod__ver { margin-top: 4px; text-align: center; padding: 6px; border-radius: 8px; background: #161616; color: #fff; font-size: 12px; font-weight: 600; }

/* ---------- Escribir ---------- */
.bchat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--bc-line); background: #fff; }
.bchat-form textarea {
    flex: 1;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    padding: 11px 14px;
    border: 1px solid #e1e1e6;
    border-radius: 22px;
    background: var(--bc-soft);
    font: inherit;
    font-size: 15px;
    color: var(--bc-ink);
    outline: none;
    transition: border-color .15s ease, background-color .15s ease;
}
.bchat-form textarea:focus { border-color: var(--bc-blue); background: #fff; }
.bchat-send { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--bc-grad); color: #fff !important; display: grid; place-items: center; cursor: pointer; flex: none; transition: transform .15s ease; }
.bchat-send:hover { transform: scale(1.06); }
.bchat-send svg { width: 20px; height: 20px; }
.bchat-foot { padding: 0 12px 9px; background: #fff; text-align: center; font-size: 11px; color: #a3a3a3; }

/* ---------- Formulario "hablar con el equipo" ---------- */
.bchat-sheet { position: absolute; inset: 0; z-index: 4; display: flex; align-items: flex-end; background: rgba(10, 10, 10, 0); transition: background-color .2s ease; }
.bchat-sheet.is-in { background: rgba(10, 10, 10, 0.45); }
.bchat-human {
    position: relative;
    width: 100%;
    max-height: 92%;
    overflow-y: auto;
    padding: 20px 18px 18px;
    border-radius: 22px 22px 0 0;
    background: #fff;
    display: grid;
    gap: 10px;
    transform: translateY(100%);
    transition: transform .25s cubic-bezier(.2, .9, .3, 1.05);
}
.bchat-sheet.is-in .bchat-human { transform: none; }
.bchat-sheet__x { position: absolute; top: 10px; right: 10px; color: var(--bc-ink) !important; }
.bchat-sheet__x:hover { background: var(--bc-soft); }
.bchat-human__top { display: flex; gap: 12px; align-items: flex-start; padding-right: 30px; margin-bottom: 4px; }
.bchat-human__top > span { font-size: 26px; line-height: 1; }
.bchat-human__top strong { display: block; font-family: "Poppins", sans-serif; font-size: 17px; }
.bchat-human__top small { color: var(--bc-muted); font-size: 12.5px; line-height: 1.4; display: block; margin-top: 2px; }
.bchat-human label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--bc-ink-2); margin: 0; }
.bchat-human label em { font-weight: 400; color: var(--bc-muted); font-style: normal; }
.bchat-human input:not([type=checkbox]), .bchat-human textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dcdce2;
    border-radius: 12px;
    font: inherit;
    font-size: 15px;
    font-weight: 400;
    color: var(--bc-ink);
    background: #fff;
    outline: none;
}
.bchat-human input:focus, .bchat-human textarea:focus { border-color: var(--bc-blue); box-shadow: 0 0 0 3px rgba(30, 91, 216, 0.12); }
.bchat-human textarea { resize: vertical; min-height: 70px; }
.bchat-check { display: flex !important; grid-template-columns: none; align-items: flex-start; gap: 10px !important; font-weight: 400 !important; padding: 10px 12px; border-radius: 12px; background: #fff3f2; border: 1px solid #ffd8d4; cursor: pointer; }
.bchat-check input { margin-top: 3px; width: 16px; height: 16px; accent-color: #d93025; }
.bchat-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.bchat-err { margin: 0; padding: 8px 12px; border-radius: 10px; background: #fdecea; color: #b3261e; font-size: 13px; }
.bchat-cta { margin-top: 4px; padding: 13px; border: 0; border-radius: 14px; background: var(--bc-grad); color: #fff !important; font-family: "Poppins", sans-serif !important; font-weight: 600; font-size: 15px; cursor: pointer; transition: filter .15s ease, transform .15s ease; }
.bchat-cta:hover { filter: brightness(1.08); transform: translateY(-1px); }
.bchat-cta:disabled { opacity: .6; cursor: wait; }

/* ---------- Móvil: pantalla completa ---------- */
@media (max-width: 639px) {
    .bchat-launcher { right: 14px; bottom: 84px; width: 56px; height: 56px; }
    .bchat-hint { right: 80px; bottom: 90px; max-width: 200px; }
    .bchat-panel {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        transform: translateY(24px);
    }
    .bchat.is-open .bchat-launcher { opacity: 0; pointer-events: none; }
    .bchat-head { padding-top: max(14px, env(safe-area-inset-top)); }
    .bchat-form { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .bchat-foot { display: none; }
    .bchat-form textarea { font-size: 16px; }
    .bchat-human input:not([type=checkbox]), .bchat-human textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .bchat-launcher::after { animation: none; }
    .bchat-panel, .bchat-msg, .bchat-human, .bchat-hint { transition: none; animation: none; }
}
