/* =========================================================
   QueBuscasRD — Seguimiento dentro de la página del negocio
   (22-oct-2026)
   ---------------------------------------------------------
   · Burbuja «en vivo» que aparece sola si este celular tiene un
     pedido o una cita activa con el negocio.
   · Panel: hoja inferior en el celular, panel lateral en la PC.
   · Vista de detalle con el seguimiento completo dentro del panel
     (sin salir de la página del negocio).
   JS: assets/js/seguimiento-burbuja.js
   ========================================================= */

.sb {
    --sb-acento: var(--primario-negocio, var(--primario, #1D7B7F));
    --sb-tinta: #172331;
    --sb-suave: #5B6878;
    --sb-borde: #E3E8EF;
    --sb-fondo: #FFFFFF;
    --sb-fondo-2: #F5F7FA;
    --sb-ok: #12805C;
    --sb-aviso-fondo: #FFF7E0;
    --sb-aviso-borde: #F6D77A;
    --sb-aviso-tinta: #7A4E00;
    --sb-error: #B42318;
    font-family: inherit;
    color: var(--sb-tinta);
}

/* ---------- Burbuja ---------- */

.sb-burbuja {
    position: fixed;
    left: 0;
    right: 0;
    width: -moz-fit-content;
    width: fit-content;
    margin-inline: auto;
    bottom: calc(14px + var(--sb-abajo, 0px) + env(safe-area-inset-bottom));
    z-index: 85;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 24px);
    padding: 8px 14px 8px 8px;
    border: 0;
    border-radius: 999px;
    background: #101820;
    color: #fff;
    font: inherit;
    text-align: left;
    box-shadow: 0 14px 34px -12px rgba(16, 24, 32, .55), 0 2px 6px rgba(16, 24, 32, .18);
    cursor: pointer;
    transform: none;
    transition: transform .3s cubic-bezier(.2, .9, .3, 1.2), opacity .25s ease, bottom .25s ease;
    -webkit-tap-highlight-color: transparent;
}

.sb-burbuja[hidden] { display: flex; opacity: 0; pointer-events: none; transform: translateY(140%); }
.sb-burbuja:active { transform: scale(.97); }

.sb-burbuja-ico {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--sb-acento);
}

.sb-burbuja-ico svg { width: 18px; height: 18px; }

.sb-burbuja-ico::after {
    content: "";
    position: absolute;
    right: -1px;
    top: -1px;
    width: 10px;
    height: 10px;
    border: 2px solid #101820;
    border-radius: 50%;
    background: #3DDC97;
    animation: sb-latido 1.8s ease-in-out infinite;
}

.sb-burbuja.sb-aviso .sb-burbuja-ico::after { background: #FFC53D; }

.sb-burbuja-txt { min-width: 0; display: grid; line-height: 1.2; }
.sb-burbuja-txt small { font-size: 11.5px; color: rgba(255, 255, 255, .7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-burbuja-txt strong { font-size: 14px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sb-burbuja-mas {
    flex: 0 0 auto;
    margin-left: 2px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    font-size: 11.5px;
    font-weight: 700;
}

.sb-burbuja.sb-cambio { animation: sb-brinco .7s cubic-bezier(.2, .9, .3, 1.4); }

@keyframes sb-latido { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: .55; } }
@keyframes sb-brinco { 0% { transform: scale(1); } 35% { transform: translateY(-8px) scale(1.06); } 100% { transform: scale(1); } }

@media (min-width: 900px) {
    .sb-burbuja { left: auto; right: 24px; bottom: 24px; margin: 0; }
}

/* ---------- Fondo y panel ---------- */

.sb-fondo {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(12, 18, 26, .45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity .25s ease;
}

/* Cerrado: no atrapa clics (antes el fondo transparente se quedaba encima
   de la página y los botones dejaban de responder) */
.sb-fondo { pointer-events: none; visibility: hidden; transition: opacity .25s ease, visibility 0s linear .25s; }
.sb-fondo.sb-on { opacity: 1; pointer-events: auto; visibility: visible; transition: opacity .25s ease; }

.sb-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1101;
    display: flex;
    flex-direction: column;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: 22px 22px 0 0;
    background: var(--sb-fondo);
    box-shadow: 0 -20px 50px -20px rgba(12, 18, 26, .45);
    transform: translateY(105%);
    transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .32s;
    padding-bottom: env(safe-area-inset-bottom);
}

.sb-panel { visibility: hidden; }
.sb-panel.sb-on { transform: none; visibility: visible; transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
.sb-panel.sb-con-detalle { height: 92vh; height: 92dvh; max-height: none; }

.sb-panel::before {
    content: "";
    align-self: center;
    flex: 0 0 auto;
    width: 40px;
    height: 4px;
    margin-top: 8px;
    border-radius: 99px;
    background: #D5DBE3;
}

@media (min-width: 900px) {
    .sb-panel {
        left: auto;
        top: 0;
        width: 420px;
        max-height: none;
        border-radius: 0;
        transform: translateX(105%);
        box-shadow: -20px 0 50px -20px rgba(12, 18, 26, .45);
    }
    .sb-panel.sb-con-detalle { width: 480px; height: auto; }
    .sb-panel::before { display: none; }
}

.sb-cab {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 10px 18px;
}

.sb-cab-txt { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.sb-cab-txt strong { display: block; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.sb-cab-txt small { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--sb-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-vivo { width: 7px; height: 7px; border-radius: 50%; background: #2BB673; flex: 0 0 auto; animation: sb-latido 1.8s ease-in-out infinite; }

.sb-btn-ico {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--sb-fondo-2);
    color: var(--sb-tinta);
    cursor: pointer;
}

.sb-btn-ico svg { width: 18px; height: 18px; }

.sb-cuerpo {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 16px 18px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior: contain;
}

.sb-cuerpo::-webkit-scrollbar { display: none; }

/* ---------- Tarjeta de pedido / cita ---------- */

.sb-item {
    margin-top: 10px;
    padding: 14px;
    border: 1px solid var(--sb-borde);
    border-radius: 16px;
    background: var(--sb-fondo);
}

.sb-item.sb-fin { background: var(--sb-fondo-2); }

.sb-item-cab { display: flex; align-items: flex-start; gap: 10px; }

.sb-item-ico {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--sb-acento) 12%, #fff);
    color: var(--sb-acento);
}

.sb-item-ico svg { width: 19px; height: 19px; }
.sb-item-txt { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.sb-item-txt strong { display: block; font-size: 15px; font-weight: 750; overflow-wrap: anywhere; }
.sb-item-txt small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--sb-suave); }

.sb-chip {
    flex: 0 0 auto;
    padding: 4px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--sb-acento) 13%, #fff);
    color: var(--sb-acento);
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.sb-chip.sb-ok { background: #E6F6EF; color: var(--sb-ok); }
.sb-chip.sb-mal { background: #FDECEA; color: var(--sb-error); }

/* Pasos */
.sb-pasos {
    display: grid;
    grid-template-columns: repeat(var(--sb-n, 4), minmax(0, 1fr));
    gap: 4px;
    margin: 14px 0 4px;
    padding: 0;
    list-style: none;
}

.sb-paso { position: relative; display: grid; justify-items: center; gap: 6px; text-align: center; }

.sb-paso::before {
    content: "";
    position: absolute;
    top: 6px;
    right: 50%;
    width: 100%;
    height: 3px;
    border-radius: 3px;
    background: var(--sb-borde);
}

.sb-paso:first-child::before { display: none; }
.sb-paso.sb-hecho::before, .sb-paso.sb-ahora::before { background: var(--sb-acento); }

.sb-punto {
    position: relative;
    z-index: 1;
    width: 15px;
    height: 15px;
    border: 3px solid var(--sb-borde);
    border-radius: 50%;
    background: #fff;
}

.sb-hecho .sb-punto { border-color: var(--sb-acento); background: var(--sb-acento); }
.sb-ahora .sb-punto { border-color: var(--sb-acento); box-shadow: 0 0 0 5px color-mix(in srgb, var(--sb-acento) 20%, transparent); }
.sb-paso span { font-size: 11px; line-height: 1.2; color: var(--sb-suave); }
.sb-ahora span { color: var(--sb-tinta); font-weight: 750; }

.sb-nota { margin: 10px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--sb-tinta); }

.sb-accion {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--sb-aviso-borde);
    border-radius: 12px;
    background: var(--sb-aviso-fondo);
    color: var(--sb-aviso-tinta);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
}

.sb-ver {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 42px;
    margin-top: 12px;
    border: 0;
    border-radius: 12px;
    background: var(--sb-fondo-2);
    color: var(--sb-tinta);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.sb-ver.sb-fuerte { background: var(--sb-acento); color: #fff; }
.sb-ver svg { width: 16px; height: 16px; }

/* ---------- Buscar con el celular ---------- */

.sb-buscar { margin-top: 6px; padding: 16px; border-radius: 16px; background: var(--sb-fondo-2); }
.sb-buscar p { margin: 0 0 12px; font-size: 14px; line-height: 1.45; color: var(--sb-suave); }
.sb-buscar label { display: block; margin: 0 0 6px; font-size: 12.5px; font-weight: 700; color: var(--sb-tinta); }

.sb-buscar input {
    display: block;
    width: 100%;
    height: 46px;
    margin-bottom: 10px;
    padding: 0 14px;
    border: 1px solid var(--sb-borde);
    border-radius: 12px;
    background: #fff;
    color: var(--sb-tinta);
    font: inherit;
    font-size: 16px;
}

.sb-buscar input:focus { outline: 2px solid color-mix(in srgb, var(--sb-acento) 45%, transparent); outline-offset: 1px; }
.sb-error { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--sb-error); }
.sb-vacio { padding: 24px 6px 6px; text-align: center; font-size: 14px; color: var(--sb-suave); }

.sb-mas-link {
    display: block;
    margin: 14px auto 0;
    border: 0;
    background: none;
    color: var(--sb-suave);
    font: inherit;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- Detalle completo dentro del panel ---------- */

.sb-detalle { flex: 1 1 auto; min-height: 0; display: flex; }
.sb-detalle iframe { flex: 1 1 auto; width: 100%; border: 0; background: var(--sb-fondo-2); }

.sb-cargando { padding: 30px 0; text-align: center; color: var(--sb-suave); font-size: 14px; }

body.sb-abierto { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .sb-burbuja, .sb-panel, .sb-fondo { transition: none; }
    .sb-burbuja-ico::after, .sb-vivo, .sb-burbuja.sb-cambio { animation: none; }
}

/* ---------- Acceso arriba: barra del celular y menú de secciones ---------- */

.perfil-tab-seg svg { width: 16px; height: 16px; flex: 0 0 auto; }
.app-barra .sb-acceso, .sb-acceso { position: relative; overflow: visible; }

/* Punto verde (o ámbar si necesita respuesta) cuando hay algo en curso.
   Es un <i> propio: las pestañas ya usan ::after para el subrayado. */
.sb-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 9px;
    height: 9px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #22C55E;
    pointer-events: none;
    animation: sb-latido 1.8s ease-in-out infinite;
}

.perfil-tab-seg .sb-dot { position: static; flex: 0 0 auto; margin-left: -2px; border: 0; width: 8px; height: 8px; }
.sb-acceso.sb-aviso .sb-dot { background: #F59E0B; }

/* «¿Te avisamos cuando respondan?» junto a la burbuja (avisos al cliente) */
.sb-pregunta { position: fixed; z-index: 2147482000; display: flex; align-items: center; gap: 10px; box-sizing: border-box; width: min(380px, calc(100vw - 24px)); padding: 12px 10px 12px 14px; border-radius: 16px; background: #fff; color: #172331; box-shadow: 0 18px 40px -14px rgba(15, 36, 56, .45); border: 1px solid #E2E8F0; font-size: 14px; animation: sbPreg .35s ease; }
.sb-pregunta[hidden] { display: none; }
.sb-pregunta > span { flex: none; font-size: 20px; }
.sb-pregunta p { margin: 0; flex: 1; line-height: 1.35; }
.sb-pregunta .sb-preg-si { flex: none; min-height: 38px; padding: 0 12px; border: 0; border-radius: 10px; background: #18334E; color: #fff; font: inherit; font-weight: 800; font-size: 13.5px; cursor: pointer; }
.sb-pregunta .sb-preg-no { flex: none; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: #64748B; font-size: 20px; cursor: pointer; }
.sb-cuerpo > .qac-card { margin: 0 0 12px; }
@keyframes sbPreg { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Campanita pequeña siempre visible (sin pedidos en curso) ---------- */
.sb-burbuja.sb-mini { left: auto; right: 16px; margin: 0; width: 52px; height: 52px; padding: 0; justify-content: center; gap: 0; }
.sb-burbuja.sb-mini .sb-burbuja-txt, .sb-burbuja.sb-mini .sb-burbuja-mas { display: none; }
.sb-burbuja.sb-mini .sb-burbuja-ico { width: 52px; height: 52px; background: transparent; }
.sb-burbuja.sb-mini .sb-burbuja-ico::after { display: none; }
.sb-burbuja.sb-mini .sb-burbuja-ico svg { width: 22px; height: 22px; }
.sb-burbuja-num { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: #DC2626; color: #fff; font-size: 11.5px; font-weight: 800; line-height: 20px; text-align: center; box-shadow: 0 0 0 2px #fff; }
.sb-burbuja-num[hidden] { display: none; }
.sb-burbuja:not(.sb-mini) .sb-burbuja-num { top: -6px; right: -2px; }
@media (min-width: 761px) { .sb-burbuja.sb-mini { right: 24px; } }

/* Avisos dentro del panel */
.sb-avisos { margin: 0 0 14px; }
.sb-avisos h3 { margin: 0 0 8px; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #64748B; }
.sb-aviso-item { display: grid; gap: 2px; padding: 11px 13px; margin-bottom: 6px; border-radius: 12px; background: #F4F6F8; color: inherit; text-decoration: none; }
.sb-aviso-item.sb-nuevo { background: #FFF7E0; box-shadow: inset 3px 0 0 #F2BE4B; }
.sb-aviso-item strong { font-size: 14.5px; }
.sb-aviso-item span { font-size: 13.5px; color: #475569; }
.sb-aviso-item small { font-size: 12px; color: #94A3B8; }
.sb-explica { margin: 0 0 14px; padding: 14px; border-radius: 14px; background: #EEF6FF; color: #12324F; font-size: 14.5px; line-height: 1.5; }
/* Campanita blanca: se distingue del botón verde de WhatsApp y va con cualquier color de negocio */
.sb-burbuja.sb-mini { background: #FFFFFF; color: #18334E; border: 1px solid #E2E8F0; box-shadow: 0 10px 26px -10px rgba(16, 24, 32, .35), 0 2px 6px rgba(16, 24, 32, .10); }
.sb-burbuja.sb-mini:hover { background: #F8FAFC; }
.sb-burbuja.sb-mini .sb-burbuja-ico { color: #18334E; }
