/* === Chatbot de atención al cliente (Yeboyebo_Chatbot::chatbot.phtml) ===
   Botón flotante abajo a la derecha y ventana de chat. En móvil la ventana
   ocupa toda la pantalla. El botón queda por debajo del banner de cookies
   (z-50) y de drawers/popups; la ventana, por encima de la barra de la app. */
.yb-chat-launcher {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 45;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Mismo tamaño que el de la PWA (icono 35px + 5px de margen + borde); icono algo más pequeño */
    width: 47px;
    height: 47px;
    padding: 0;
    border: 1px solid #373753;
    border-radius: 50%;
    background: #fff;
    color: #373753;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
/* Como el botón del chat de la PWA: crece y sombra al pasar el ratón */
.yb-chat-launcher:hover { transform: scale(1.1); box-shadow: 1px 1px 10px rgba(0,0,0,0.9); }
.yb-chat-launcher:focus-visible { outline: 2px solid #373753; outline-offset: 3px; }
.yb-chat-launcher svg { display: block; width: 28px; height: 28px; }
/* App: encima de la barra inferior y del announcement */
html.is-app .yb-chat-launcher {
    bottom: calc(var(--elg-app-tabbar-h) + var(--elg-safe-bottom) + 1rem);
}
html.is-app body:has(#elganso-announcement) .yb-chat-launcher {
    bottom: calc(var(--elg-app-tabbar-h) + var(--elg-safe-bottom) + 3rem);
}

.yb-chat-window {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 8900;
    display: flex;
    flex-direction: column;
    width: 380px;
    height: min(600px, calc(100vh - 2.5rem));
    background: var(--color-bg, #fff);
    color: #041D40;
    border-radius: 4px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    overflow: hidden;
    font-size: 0.875rem;
    line-height: 1.45;
}
@media (max-width: 639px) {
    .yb-chat-window {
        inset: 0;
        width: auto;
        height: 100dvh;
        border-radius: 0;
        padding-bottom: var(--elg-safe-bottom);
    }
    html.yb-chat-is-open,
    html.yb-chat-is-open body { overflow: hidden; }
}

/* Cabecera blanca con el logo y "ASISTENTE", como el chat de la PWA */
.yb-chat-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem 3rem 1rem;
    background: #fff;
    color: #041D40;
    border-bottom: 1px solid rgba(4,29,64,0.1);
}
.yb-chat-head-text { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.yb-chat-logo { display: block; width: 150px; height: auto; }
.yb-chat-title {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.25em;
    text-transform: uppercase;
}
.yb-chat-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: opacity 0.2s;
}
.yb-chat-icon-btn:hover { opacity: 0.6; }
.yb-chat-icon-btn:focus-visible { outline: 2px solid #041D40; outline-offset: -2px; }
.yb-chat-head-reset { position: absolute; top: 0.5rem; left: 0.5rem; }
.yb-chat-head-close { position: absolute; top: 0.5rem; right: 0.5rem; }

.yb-chat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 1rem;
    background: #f8f8f8;
}
.yb-chat-msg {
    max-width: 88%;
    padding: 0.625rem 0.875rem;
    border-radius: 12px;
    overflow-wrap: anywhere;
}
.yb-chat-msg p { margin: 0; }
.yb-chat-msg p + p,
.yb-chat-msg p + ul,
.yb-chat-msg ul + p { margin-top: 0.5rem; }
.yb-chat-msg ul { margin: 0; padding-left: 1.1rem; list-style: disc; }
.yb-chat-msg li + li { margin-top: 0.2rem; }
.yb-chat-msg a { text-decoration: underline; text-underline-offset: 2px; }
.yb-chat-msg strong { font-weight: 600; }
/* Como el chat de la PWA: bot en oscuro y cliente en claro (con nuestros colores) */
.yb-chat-msg--bot {
    align-self: flex-start;
    background: #041D40;
    color: #fff;
    border-bottom-left-radius: 4px;
}
.yb-chat-msg--bot a { color: #fff; }
.yb-chat-msg--error {
    align-self: flex-start;
    background: #fff;
    border: 1px solid rgba(4,29,64,0.08);
    border-bottom-left-radius: 4px;
    color: #b42318;
}
.yb-chat-msg--user {
    align-self: flex-end;
    background: #fff;
    border: 1px solid rgba(4,29,64,0.08);
    color: #041D40;
    border-bottom-right-radius: 4px;
}
/* Solo en el párrafo: en el bocadillo pintaría también los saltos del HTML de la plantilla */
.yb-chat-msg--user p { white-space: pre-line; }
.yb-chat-entry { display: flex; flex-direction: column; gap: 0.5rem; }
.yb-chat-notice { margin-top: 0.5rem !important; font-size: 0.75rem; color: rgba(255,255,255,0.75); }

.yb-chat-typing { display: inline-flex; gap: 4px; padding: 0.875rem 1rem; }
.yb-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.8);
    animation: yb-chat-dot 1.2s infinite ease-in-out;
}
.yb-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.yb-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes yb-chat-dot {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
    .yb-chat-typing span { animation: none; }
    .yb-chat-launcher { transition: none; }
}

.yb-chat-quick { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; }
.yb-chat-quick-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid #041D40;
    border-radius: 999px;
    background: #fff;
    color: #041D40;
    font-size: 0.8125rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.yb-chat-quick-btn:hover { background: #041D40; color: #fff; }

.yb-chat-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid rgba(4,29,64,0.1);
    background: #fff;
}
.yb-chat-input {
    flex: 1 1 auto;
    min-height: 2.5rem;
    max-height: 120px;
    padding: 0.55rem 1rem;
    border: 1px solid rgba(4,29,64,0.2);
    border-radius: 20px;
    resize: none;
    font: inherit;
    font-size: 1rem; /* evita el zoom automático de iOS */
    color: #041D40;
    overflow-y: hidden; /* autosize() la activa cuando el texto no cabe */
    scrollbar-width: thin;
    scrollbar-color: rgba(4,29,64,0.3) transparent;
}
/* Barra fina, sin flechas, que no tapa el borde redondeado */
.yb-chat-input::-webkit-scrollbar { width: 6px; }
.yb-chat-input::-webkit-scrollbar-button { display: none; }
.yb-chat-input::-webkit-scrollbar-track { background: transparent; margin: 10px 0; }
.yb-chat-input::-webkit-scrollbar-thumb { background: rgba(4,29,64,0.3); border-radius: 3px; }
.yb-chat-input:focus { outline: none; border-color: #373753; box-shadow: none; }
/* Enviar: solo el avión de papel, sin fondo (como la PWA) */
.yb-chat-send {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    background: transparent;
    color: #373753;
    cursor: pointer;
    transition: opacity 0.2s;
}
.yb-chat-send:hover { opacity: 0.7; }
.yb-chat-send:disabled { opacity: 0.35; cursor: default; }
.yb-chat-send:focus-visible { outline: 2px solid #373753; outline-offset: -2px; border-radius: 50%; }

.yb-chat-foot {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 0.875rem 0.625rem;
    background: #fff;
    font-size: 0.75rem;
}
.yb-chat-human { color: #041D40; text-decoration: underline; text-underline-offset: 2px; }
.yb-chat-privacy { color: #737880; }
.yb-chat-privacy:hover, .yb-chat-human:hover { opacity: 0.7; }

/* --- Widgets bajo las respuestas (productos, tiendas, pedidos, formulario) --- */
.yb-chat-widget { width: 100%; }
.yb-chat-products {
    display: flex;
    gap: 0.5rem;
    margin: 0;
    padding: 0 0 0.25rem;
    list-style: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
}
.yb-chat-product { flex: 0 0 140px; scroll-snap-align: start; }
.yb-chat-product-link {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    height: 100%;
    padding-bottom: 0.5rem;
    background: #fff;
    border: 1px solid rgba(4,29,64,0.08);
    border-radius: 4px;
    overflow: hidden;
    color: #041D40;
    text-decoration: none;
}
.yb-chat-product-link:hover .yb-chat-product-name { text-decoration: underline; }
.yb-chat-product-img { width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; background: #f1f1f1; }
.yb-chat-product-name { padding: 0 0.5rem; font-size: 0.75rem; line-height: 1.3; }
.yb-chat-product-price { display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0 0.5rem; font-size: 0.75rem; font-weight: 600; }
.yb-chat-product-old { color: #737880; font-weight: 400; }
.yb-chat-product-sale { color: #b42318; }

.yb-chat-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.yb-chat-card {
    padding: 0.75rem 0.875rem;
    background: #fff;
    border: 1px solid rgba(4,29,64,0.08);
    border-radius: 4px;
    font-size: 0.8125rem;
}
.yb-chat-card .yb-chat-list { gap: 0.625rem; margin-top: 0.5rem; }
.yb-chat-card .yb-chat-list li { display: flex; flex-direction: column; }
.yb-chat-card a { text-decoration: underline; text-underline-offset: 2px; }
.yb-chat-card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0; font-weight: 600; }
.yb-chat-card-meta { margin: 0.25rem 0 0; color: #737880; }
.yb-chat-card-empty { margin: 0.5rem 0 0; color: #737880; }
.yb-chat-card-link { display: inline-block; margin-top: 0.4rem; }
.yb-chat-badge {
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: #eef1f6;
    font-size: 0.6875rem;
    font-weight: 600;
}

.yb-chat-lookup { display: flex; flex-direction: column; gap: 0.5rem; }
.yb-chat-field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.75rem; color: #737880; }
.yb-chat-field input {
    padding: 0.45rem 0.6rem;
    border: 1px solid rgba(4,29,64,0.2);
    border-radius: 4px;
    font-size: 1rem;
    color: #041D40;
}
.yb-chat-field input:focus { outline: none; border-color: #041D40; box-shadow: none; }
.yb-chat-field-error { margin: 0; color: #b42318; font-size: 0.75rem; }
.yb-chat-lookup-btn {
    align-self: flex-start;
    padding: 0.5rem 1.25rem;
    border: 0;
    border-radius: 4px;
    background: #041D40;
    color: #fff;
    font-size: 0.8125rem;
    cursor: pointer;
}
.yb-chat-lookup-btn:disabled { opacity: 0.5; cursor: default; }

.yb-chat-social { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.yb-chat-social a { display: block; transition: opacity 0.2s; }
.yb-chat-social a:hover { opacity: 0.75; }
.yb-chat-social img { display: block; width: 40px; height: 40px; border-radius: 6px; }
.yb-chat-apps { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.yb-chat-apps a { display: block; transition: opacity 0.2s; }
.yb-chat-apps a:hover { opacity: 0.8; }
.yb-chat-apps img { display: block; width: 135px; height: auto; }

.yb-chat-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
