/* Chat ServiBot dentro del drawer de la carta publica. Reusa las variables
   de tema que la carta define en :root (fondo oscuro, acento naranja). */

/* Las reglas con display (flex) le ganan al atributo hidden del UA stylesheet;
   sin esto, el panel y el indicador de escribiendo quedarian SIEMPRE en el
   layout aunque el JS los marque hidden. */
.servibot-chat[hidden],
.servibot-chat-typing[hidden],
.servibot-chat-verificando[hidden],
.servibot-chat-imagen[hidden],
.servibot-chat-pwa[hidden],
.servibot-chat-opciones[hidden] {
    display: none !important;
}

.servibot-chat {
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* El drawer (.pedido-drawer) es position:fixed con top/bottom:0, y su
       body (.pedido-drawer-body) ya es flex:1 dentro de eso -- osea que YA
       tiene un alto real y definido para llenar. 100% (no un vh/px fijo)
       hace que el chat use exactamente todo ese espacio hasta el fondo. */
    height: 100%;
}

.servibot-chat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--card, #191c24);
    border: 1px solid var(--border, #272b35);
    border-radius: 12px;
}

.servibot-chat-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent-soft, rgba(244, 121, 30, 0.16));
    font-size: 20px;
}

.servibot-chat-head-texto {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.servibot-chat-head-texto span {
    font-size: 12px;
    color: var(--muted, #98a0ac);
}

/* Tarjeta de orden fija (estilo recibo): el detalle del pedido vive aca,
   no dentro de las burbujas. Se actualiza sola con cada respuesta. */
.servibot-chat-orden {
    background: var(--card, #191c24);
    border: 1px solid var(--border, #272b35);
    border-radius: 12px;
    padding: 12px 14px;
    /* Fuera del contenedor que crece con cada mensaje: siempre visible
       arriba, nunca empujada hacia abajo por la conversacion. */
    flex-shrink: 0;
}

.servibot-chat-orden[hidden] {
    display: none !important;
}

.servibot-chat-orden-titulo {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted, #98a0ac);
    margin-bottom: 8px;
}

.servibot-chat-orden-items {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.servibot-chat-orden-fila {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
}

.servibot-chat-orden-fila.domicilio {
    color: var(--muted, #98a0ac);
    font-size: 13px;
}

.servibot-chat-orden-precio {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.servibot-chat-orden-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border, #272b35);
    font-size: 14px;
}

.servibot-chat-orden-total strong {
    color: var(--accent-strong, #ff9a44);
    font-size: 17px;
    font-variant-numeric: tabular-nums;
}

.servibot-chat-mensajes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* flex:1 dentro de un .servibot-chat con alto REAL (ver arriba): llena
       todo el espacio libre entre la orden (fija arriba) y los chips/form
       (abajo), sin empujar a nadie -- ella misma hace scroll interno cuando
       la conversacion no cabe. min-height:0 es necesario para que el
       overflow funcione dentro de un flex column (si no, el cuadro se
       estira mas alla de su padre en vez de scrollear). */
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 2px;
    scroll-behavior: smooth;
}

/* Aunque este vacio (recien se abrio el chat, sin mensajes todavia), sigue
   ocupando su espacio flexible -- si se colapsara (display:none) el resto
   (chips, input, volver) subiria pegado a la orden en vez de quedar anclado
   abajo del todo, dejando un hueco vacio despues de "Volver a la carta". */

.servibot-burbuja {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.servibot-burbuja.bot {
    align-self: flex-start;
    background: var(--card, #191c24);
    border: 1px solid var(--border, #272b35);
    border-bottom-left-radius: 4px;
}

.servibot-burbuja.cliente {
    align-self: flex-end;
    background: var(--accent-soft, rgba(244, 121, 30, 0.16));
    border: 1px solid var(--accent, #f4791e);
    border-bottom-right-radius: 4px;
}

.servibot-burbuja.staff {
    align-self: center;
    background: rgba(76, 175, 130, 0.14);
    border: 1px solid rgba(76, 175, 130, 0.5);
    font-size: 13px;
    text-align: center;
}

/* Burbuja que contiene la foto del comprobante */
.servibot-burbuja.imagen {
    padding: 4px;
    max-width: 70%;
}

.servibot-burbuja.imagen img {
    display: block;
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    border-radius: 10px;
}

/* Despedida animada del bot al completar el pago */
.servibot-chat-celebracion {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    padding: 28px 18px;
    animation: servibot-celebracion-entrada 0.45s ease-out;
}

.servibot-chat-celebracion-bot {
    font-size: 56px;
    line-height: 1;
    animation: servibot-celebracion-salto 1.1s ease-in-out 3;
}

.servibot-chat-celebracion-titulo {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-strong, #ff9a44);
}

.servibot-chat-celebracion-texto {
    font-size: 14px;
    color: var(--muted, #98a0ac);
    max-width: 300px;
    line-height: 1.45;
}

@keyframes servibot-celebracion-entrada {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes servibot-celebracion-salto {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-12px) rotate(-8deg); }
    50% { transform: translateY(0) rotate(0deg); }
    75% { transform: translateY(-7px) rotate(8deg); }
}

.servibot-chat-celebracion-aceptar {
    margin-top: 8px;
    padding: 11px 42px;
    border-radius: 999px;
    border: none;
    background: var(--accent, #f4791e);
    color: var(--accent-text-on, #2a1206);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.servibot-chat-celebracion-aceptar:active {
    opacity: 0.85;
}

.servibot-chat-celebracion-instalar {
    margin-top: 4px;
    padding: 9px 22px;
    border-radius: 999px;
    border: 1px solid var(--border, #272b35);
    background: transparent;
    color: var(--muted, #98a0ac);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.servibot-chat-celebracion-instalar[hidden] {
    display: none;
}

.servibot-chat-celebracion-instalar:hover,
.servibot-chat-celebracion-instalar:focus-visible {
    color: var(--accent-strong, #ff9a44);
    background: var(--accent-soft, rgba(244, 121, 30, 0.16));
    border-color: var(--accent, #f4791e);
    outline: none;
}

.servibot-chat-typing {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
}

.servibot-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted, #98a0ac);
    animation: servibot-typing 1.2s infinite ease-in-out;
}

.servibot-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.servibot-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes servibot-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Animacion de "escaneo" mientras el bot analiza la foto del comprobante */
.servibot-chat-verificando {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
}

.servibot-chat-verificando-icono {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 18px;
    border-radius: 8px;
    background: var(--accent-soft, rgba(244, 121, 30, 0.16));
    overflow: hidden;
    flex-shrink: 0;
}

.servibot-chat-verificando-linea {
    position: absolute;
    left: 2px;
    right: 2px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent, #f4791e);
    box-shadow: 0 0 6px var(--accent, #f4791e);
    animation: servibot-verificando-escaneo 1.5s ease-in-out infinite;
}

@keyframes servibot-verificando-escaneo {
    0% { top: 3px; opacity: 0.25; }
    50% { top: calc(100% - 5px); opacity: 1; }
    100% { top: 3px; opacity: 0.25; }
}

.servibot-chat-verificando-texto {
    font-size: 14px;
    color: var(--muted, #98a0ac);
    animation: servibot-verificando-pulso 1.5s ease-in-out infinite;
}

@keyframes servibot-verificando-pulso {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

.servibot-chat-opciones {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.servibot-chat-opciones button {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--accent, #f4791e);
    background: transparent;
    color: var(--accent-strong, #ff9a44);
    font-size: 14px;
    cursor: pointer;
}

.servibot-chat-opciones button:active {
    background: var(--accent-soft, rgba(244, 121, 30, 0.16));
}

.servibot-chat-imagen-btn {
    display: block;
    text-align: center;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px dashed var(--accent, #f4791e);
    color: var(--accent-strong, #ff9a44);
    font-size: 14px;
    cursor: pointer;
}

.servibot-chat-form {
    display: flex;
    gap: 8px;
}

.servibot-chat-form input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--border, #272b35);
    background: var(--bg-soft, #12151c);
    color: var(--text, #f5f6f8);
    font-size: 14px;
    outline: none;
}

.servibot-chat-form input:focus {
    border-color: var(--accent, #f4791e);
}

.servibot-chat-form button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--accent, #f4791e);
    color: var(--accent-text-on, #2a1206);
    font-size: 16px;
    cursor: pointer;
}

.servibot-chat-form button:disabled {
    opacity: 0.5;
    cursor: default;
}

.servibot-chat-volver {
    display: block;
    width: fit-content;
    margin: 4px auto 0;
    background: transparent;
    border: 1px solid var(--border, #272b35);
    color: var(--muted, #98a0ac);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 9px 16px;
    border-radius: 999px;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.servibot-chat-volver:hover,
.servibot-chat-volver:focus-visible {
    color: var(--accent-strong, #ff9a44);
    background: var(--accent-soft, rgba(244, 121, 30, 0.16));
    border-color: var(--accent, #f4791e);
    outline: none;
}

.servibot-chat-volver:active {
    color: var(--accent, #f4791e);
}

.servibot-chat-pwa {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--card, #191c24);
    border: 1px solid var(--border, #272b35);
    font-size: 13px;
}

.servibot-chat-pwa-botones {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.servibot-chat-pwa-botones button {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid var(--border, #272b35);
    background: transparent;
    color: var(--muted, #98a0ac);
}

.servibot-chat-pwa-botones button[data-chat-pwa-instalar] {
    background: var(--accent, #f4791e);
    border-color: var(--accent, #f4791e);
    color: var(--accent-text-on, #2a1206);
}

/* Entrada "continuar mi pedido" que la carta muestra en el banner */
.pedido-actual-abrir-chat {
    margin-top: 8px;
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--accent, #f4791e);
    background: transparent;
    color: var(--accent-strong, #ff9a44);
    font-size: 13px;
    cursor: pointer;
}
