/*
 * Asistente IA Fuster — burbuja flotante + panel chat.
 * Todo namespaced bajo .fus-asist para no colisionar con los estilos del sitio.
 */

:root {
    /* Paleta corporativa Fuster: dorado + negro */
    --fus-asist-brand: #e9af32;          /* dorado principal */
    --fus-asist-brand-hover: #c89421;    /* dorado más oscuro para hover */
    --fus-asist-dark: #212529;           /* negro corporativo */
    --fus-asist-dark-soft: #343a40;
    --fus-asist-on-brand: #212529;       /* texto sobre fondo dorado = negro */
    --fus-asist-on-dark:  #ffffff;       /* texto sobre fondo negro = blanco */

    --fus-asist-bg: #ffffff;
    --fus-asist-bg-user: #fdf6e3;        /* tenue dorado para globos de usuario */
    --fus-asist-bg-bot: #ffffff;
    --fus-asist-text: #212529;
    --fus-asist-text-muted: #64748b;
    --fus-asist-border: #e2e8f0;
    --fus-asist-shadow: 0 10px 40px rgba(0, 0, 0, .18);
    --fus-asist-radius: 16px;
}

/* ── Burbuja flotante ───────────────────────────────────────────────────── */
.fus-asist-bubble {
    position: fixed;
    right: 20px;
    bottom: 100px; /* por encima del badge de reCAPTCHA de Google */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--fus-asist-brand);
    color: var(--fus-asist-on-brand);
    border: 2px solid var(--fus-asist-dark);
    cursor: pointer;
    box-shadow: var(--fus-asist-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999998;
    transition: background .18s, transform .18s;
    padding: 0;
}
.fus-asist-bubble:hover    { background: var(--fus-asist-brand-hover); transform: scale(1.05); }
.fus-asist-bubble svg      { width: 36px; height: 36px; }
.fus-asist-bubble[aria-expanded="true"] { display: none; }

/* ── Panel ─────────────────────────────────────────────────────────────── */
.fus-asist-panel {
    position: fixed;
    right: 20px;
    bottom: 100px; /* alineado con la burbuja — por encima del reCAPTCHA */
    width: 380px;
    max-width: calc(100vw - 20px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: var(--fus-asist-bg);
    border-radius: var(--fus-asist-radius);
    box-shadow: var(--fus-asist-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--fus-asist-text);
    font-size: 14px;
    line-height: 1.5;
}
.fus-asist-panel[hidden] { display: none; }

@media (max-width: 480px) {
    .fus-asist-panel {
        right: 0; bottom: 0; left: 0;
        width: 100%;
        height: 100vh; max-height: 100vh;
        border-radius: 0;
    }
}

/* ── Header del panel ──────────────────────────────────────────────────── */
.fus-asist-head {
    background: var(--fus-asist-dark);
    color: var(--fus-asist-on-dark);
    padding: 12px 14px 12px 18px;
    flex-shrink: 0;
    border-bottom: 3px solid var(--fus-asist-brand);
    display: flex;
    align-items: center;
    gap: 10px;
}
.fus-asist-head-text { flex: 1 1 auto; min-width: 0; }
.fus-asist-head h3   { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .2px; color: var(--fus-asist-brand); display: inline-flex; align-items: center; gap: 6px; }
.fus-asist-head h3::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px; border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34,197,94,.25);
    animation: fus-asist-pulse 2s infinite;
}
.fus-asist-head p    { margin: 2px 0 0; font-size: 13px; color: rgba(255,255,255,.92); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fus-asist-head-actions { display: flex; gap: 4px; flex-shrink: 0; }
/* Selector hiper-específico: style.css del sitio tiene
   `button { color: var(--color-body); width: 100%; border: 1px solid ... }`
   que pisa nuestros botones. Aquí usamos la ruta completa + !important +
   hex directo (sin variable) para blindar por encima de cualquier cascada. */
.fus-asist-panel .fus-asist-head .fus-asist-head-actions .fus-asist-close,
.fus-asist-panel .fus-asist-head .fus-asist-head-actions .fus-asist-fullscreen {
    width: 32px !important;
    height: 32px !important;
    background: transparent !important;
    border: none !important;
    color: #e9af32 !important;
    cursor: pointer !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    min-width: 0 !important;
    outline: none !important;
    transition: background .18s;
}
.fus-asist-panel .fus-asist-head .fus-asist-head-actions .fus-asist-close:hover,
.fus-asist-panel .fus-asist-head .fus-asist-head-actions .fus-asist-fullscreen:hover {
    background: rgba(233,175,50,.18) !important;
    border: none !important;
}
.fus-asist-panel .fus-asist-head .fus-asist-head-actions .fus-asist-close svg,
.fus-asist-panel .fus-asist-head .fus-asist-head-actions .fus-asist-fullscreen svg {
    width: 18px !important;
    height: 18px !important;
    stroke: #e9af32 !important;
    fill: none !important;
    color: #e9af32 !important;
}
.fus-asist-panel .fus-asist-head .fus-asist-head-actions .fus-asist-close svg * ,
.fus-asist-panel .fus-asist-head .fus-asist-head-actions .fus-asist-fullscreen svg * {
    stroke: #e9af32 !important;
    fill: none !important;
}
/* Toggle icono expandir/contraer según estado. !important para blindar
   contra cualquier CSS global del sitio que pueda poner display:inline. */
.fus-asist-fullscreen .fus-icon-shrink { display: none !important; }
.fus-asist-fullscreen .fus-icon-expand { display: block !important; }
.fus-asist-panel.fus-asist-fullscreen-on .fus-asist-fullscreen .fus-icon-expand { display: none !important; }
.fus-asist-panel.fus-asist-fullscreen-on .fus-asist-fullscreen .fus-icon-shrink { display: block !important; }

@keyframes fus-asist-pulse {
    0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.25); }
    50%     { box-shadow: 0 0 0 6px rgba(34,197,94,.08); }
}

/* ── Panel en pantalla completa ────────────────────────────────────────── */
/* En fullscreen cada contenedor ocupa 100% de ancho (así el fondo gris de la
   zona de mensajes y el blanco del form cubren toda la pantalla). El contenido
   se centra con padding lateral calculado para que las burbujas queden en una
   columna cómoda de ~820px, como en ChatGPT/Claude.ai. */
.fus-asist-panel.fus-asist-fullscreen-on {
    right: 0 !important; bottom: 0 !important; top: 0 !important; left: 0 !important;
    width: 100vw !important; max-width: 100vw !important;
    height: 100vh !important; max-height: 100vh !important;
    border-radius: 0 !important;
}
.fus-asist-panel.fus-asist-fullscreen-on .fus-asist-head {
    padding-left:  calc((100vw - 820px) / 2 + 20px);
    padding-right: calc((100vw - 820px) / 2 + 20px);
}
.fus-asist-panel.fus-asist-fullscreen-on .fus-asist-msgs {
    padding: 24px calc((100vw - 820px) / 2 + 20px);
}
.fus-asist-panel.fus-asist-fullscreen-on .fus-asist-form {
    padding: 12px calc((100vw - 820px) / 2 + 20px);
}
.fus-asist-panel.fus-asist-fullscreen-on .fus-asist-footer {
    padding: 6px calc((100vw - 820px) / 2 + 20px) 10px;
}
/* Debajo de 900px no hay espacio para centrar — padding normal. */
@media (max-width: 900px) {
    .fus-asist-panel.fus-asist-fullscreen-on .fus-asist-head    { padding-left: 18px; padding-right: 14px; }
    .fus-asist-panel.fus-asist-fullscreen-on .fus-asist-msgs    { padding: 24px 20px; }
    .fus-asist-panel.fus-asist-fullscreen-on .fus-asist-form    { padding: 12px 20px; }
    .fus-asist-panel.fus-asist-fullscreen-on .fus-asist-footer  { padding: 6px 20px 10px; }
}

/* ── Lista de mensajes ─────────────────────────────────────────────────── */
.fus-asist-msgs {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.fus-asist-msg {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 12px;
    word-wrap: break-word;
}
.fus-asist-msg.user {
    align-self: flex-end;
    background: var(--fus-asist-bg-user);
    border-bottom-right-radius: 4px;
}
.fus-asist-msg.bot {
    align-self: flex-start;
    background: var(--fus-asist-bg-bot);
    border: 1px solid var(--fus-asist-border);
    border-bottom-left-radius: 4px;
}
.fus-asist-msg p         { margin: 0 0 6px; }
.fus-asist-msg p:last-child { margin-bottom: 0; }
/* Enlaces: dorado puro no se lee bien sobre blanco → usamos negro + subrayado dorado */
.fus-asist-msg a         { color: var(--fus-asist-dark); text-decoration: underline; text-decoration-color: var(--fus-asist-brand); text-decoration-thickness: 2px; text-underline-offset: 3px; font-weight: 600; }
.fus-asist-msg a:hover   { color: var(--fus-asist-brand-hover); text-decoration-color: var(--fus-asist-brand-hover); }
.fus-asist-msg strong    { font-weight: 700; }
.fus-asist-msg em        { font-style: italic; }
.fus-asist-msg code      { background: #f1f5f9; padding: 1px 5px; border-radius: 3px; font-family: 'Courier New', monospace; font-size: 12.5px; }
/* Listas: usamos ::before porque el sitio puede tener reset global que mata
   list-style y ::marker. Así garantizamos viñeta siempre visible. */
.fus-asist-msg ul,
.fus-asist-msg ol        { list-style: none !important; margin: 6px 0 !important; padding: 0 !important; }
.fus-asist-msg li        {
    position: relative;
    margin: 4px 0 !important;
    padding: 0 0 0 14px !important;
    line-height: 1.45;
    display: block !important;
}
.fus-asist-msg ul > li::before {
    content: '•';
    position: absolute;
    left: 2px; top: 0;
    color: var(--fus-asist-brand);
    font-weight: 700;
    line-height: 1.45;
}
.fus-asist-msg ol        { counter-reset: fus-asist-ol; }
.fus-asist-msg ol > li   { counter-increment: fus-asist-ol; padding-left: 22px !important; }
.fus-asist-msg ol > li::before {
    content: counter(fus-asist-ol) '.';
    position: absolute;
    left: 2px; top: 0;
    color: var(--fus-asist-brand);
    font-weight: 700;
}

/* Imagen de producto dentro del chat — pequeña, redondeada, con cursor zoom.
   Las imágenes van PRECEDIENDO al <p><strong>Nombre</strong></p> → formamos
   visualmente una "ficha" dejando aire alrededor y agrupando con <ul>. */
.fus-asist-img {
    display: block;
    max-width: 120px;
    max-height: 96px;
    width: auto;
    height: auto;
    object-fit: contain;
    background: #f8fafc;
    border: 1px solid var(--fus-asist-border);
    border-radius: 8px;
    padding: 4px;
    margin: 4px 0 8px;
    cursor: zoom-in;
    transition: transform .15s, box-shadow .15s;
}
.fus-asist-img:hover { transform: scale(1.04); box-shadow: 0 2px 8px rgba(0,0,0,.12); }

/* ── Fichas de producto (foto a la izq, info completa a la der con botón abajo) ─ */
.fus-asist-card {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--fus-asist-border);
    border-radius: 10px;
    margin: 6px 0;
}
/* Contenedor cuadrado fijo, imagen se adapta sin deformarse */
.fus-asist-card .fus-asist-img {
    width: 60px !important;
    height: 60px !important;
    max-width: none;
    max-height: none;
    margin: 0 !important;
    padding: 3px;
    cursor: zoom-in;
    object-fit: contain;
    background: #f8fafc;
}
.fus-asist-card-body { min-width: 0; }
.fus-asist-prod-name {
    font-weight: 600;
    font-size: 12.5px;
    color: var(--fus-asist-dark);
    line-height: 1.2;
    margin-bottom: 3px;
    /* Hasta 2 líneas; si el nombre es largo, hace wrap. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.fus-asist-prod-ref,
.fus-asist-prod-ref code {
    color: #676767 !important;
}
.fus-asist-prod-ref {
    font-size: 11.5px;
    line-height: 1.3;
}
.fus-asist-prod-ref code {
    background: transparent !important;
    padding: 0 !important;
    font-weight: 600;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 11.5px;
}

/* Especificaciones (bullet "Specs:" renderizado como pares separados por | amarilla) */
.fus-asist-prod-specs {
    font-size: 11px;
    color: #676767;
    line-height: 1.5;
    margin: 5px 0 7px;
    word-break: break-word;
}
.fus-asist-prod-specs span { display: inline; }
.fus-asist-prod-specs .spec-sep {
    color: var(--fus-asist-brand);
    font-weight: 700;
    margin: 0 5px;
}

/* Botón "Ver ficha" — único bloque, unificado. */
.fus-asist-ver-ficha,
.fus-asist-msg a[href*="/pid"] {
    display: inline-block;
    margin-top: 2px;
    padding: 4px 9px;
    background: var(--fus-asist-brand);
    color: var(--fus-asist-dark) !important;
    text-decoration: none !important;
    font-weight: 700;
    font-size: 11px;
    height: 22px;
    line-height: 13px;
    border-radius: 6px;
    transition: background .15s;
    font-family: inherit;
}
.fus-asist-ver-ficha:hover,
.fus-asist-msg a[href*="/pid"]:hover { background: var(--fus-asist-brand-hover); }

/* Cards consecutivas → se fusionan como lista unificada */
.fus-asist-card.fus-asist-card-has-next {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
    margin-bottom: 0;
}
.fus-asist-card.fus-asist-card-has-prev {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
}


/* ── Lightbox (ampliar imágenes al clicar) ─────────────────────────────── */
.fus-asist-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(33, 37, 41, .92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000;
    cursor: zoom-out;
    animation: fus-asist-fade .15s ease;
    padding: 24px;
}
.fus-asist-lightbox[hidden] { display: none; }
.fus-asist-lightbox-inner {
    position: relative;
    display: inline-block;
    cursor: default;
}
.fus-asist-lightbox img {
    display: block;
    max-width: 92vw;
    max-height: 88vh;
    width: auto; height: auto;
    object-fit: contain;
    background: #fff;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    opacity: 1;
    transition: opacity .18s ease;
}
/* Mientras la imagen nueva carga, ocultamos la vieja y mostramos un spinner */
.fus-asist-lightbox.is-loading img { opacity: 0; }
.fus-asist-lightbox-spinner {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    gap: 6px;
    pointer-events: none;
}
.fus-asist-lightbox.is-loading .fus-asist-lightbox-spinner { display: inline-flex; }
.fus-asist-lightbox-spinner span {
    width: 10px; height: 10px;
    background: rgba(255,255,255,.75);
    border-radius: 50%;
    animation: fus-asist-blink 1.4s infinite ease-in-out both;
}
.fus-asist-lightbox-spinner span:nth-child(2) { animation-delay: .2s; }
.fus-asist-lightbox-spinner span:nth-child(3) { animation-delay: .4s; }
.fus-asist-lightbox-close {
    position: absolute;
    top: -14px; right: -14px;        /* arriba a la DERECHA del modal */
    width: 36px; height: 36px;
    border-radius: 50%;
    background: #ffffff;
    color: #212529;
    border: 1px solid rgba(0,0,0,.1);
    font-size: 20px;
    font-weight: 400;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 10px rgba(0,0,0,.35);
    z-index: 2;
}
.fus-asist-lightbox-close:hover { background: #f5f5f5; color: #000; }
@keyframes fus-asist-fade { from { opacity: 0 } to { opacity: 1 } }

/* Mensaje "escribiendo…" con 3 puntos animados */
.fus-asist-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--fus-asist-border);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}
.fus-asist-typing span {
    width: 7px; height: 7px;
    background: var(--fus-asist-text-muted);
    border-radius: 50%;
    animation: fus-asist-blink 1.4s infinite ease-in-out both;
}
.fus-asist-typing span:nth-child(2) { animation-delay: .2s; }
.fus-asist-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes fus-asist-blink {
    0%, 80%, 100% { opacity: .25; transform: scale(.8); }
    40%            { opacity: 1;   transform: scale(1); }
}

/* ── Input + enviar ────────────────────────────────────────────────────── */
.fus-asist-form {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--fus-asist-border);
    background: #fff;
    flex-shrink: 0;
}
.fus-asist-input {
    flex: 1;
    border: 1px solid var(--fus-asist-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color .15s;
    max-height: 100px;
    line-height: 1.4;
}
.fus-asist-input:focus { border-color: var(--fus-asist-brand); }
.fus-asist-send {
    background: var(--fus-asist-dark);
    color: var(--fus-asist-brand);
    border: none;
    border-radius: 10px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.fus-asist-send:hover:not(:disabled)   { background: var(--fus-asist-dark-soft); }
.fus-asist-send:disabled               { opacity: .5; cursor: not-allowed; }
.fus-asist-send svg                    { width: 16px; height: 16px; }

/* ── Pie con aviso de privacidad ───────────────────────────────────────── */
.fus-asist-footer {
    font-size: 10.5px;
    color: var(--fus-asist-text-muted);
    text-align: center;
    padding: 6px 10px 10px;
    background: #fff;
    flex-shrink: 0;
}

/* ── Quick actions de bienvenida (3 botones) ────────────────────────────── */
.fus-asist-quick {
    align-self: flex-start;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 4px 0 2px;
    animation: fus-asist-fade .25s ease;
}
.fus-asist-quick-title {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--fus-asist-text-muted);
    font-weight: 600;
    padding: 2px 2px;
}
.fus-asist-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--fus-asist-border);
    background: #fff;
    color: var(--fus-asist-dark);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background .15s, border-color .15s, transform .1s;
}
.fus-asist-quick-btn:hover  { background: #fafbfc; border-color: var(--fus-asist-brand); }
.fus-asist-quick-btn:active { transform: scale(.98); }
.fus-asist-quick-icon       { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; flex-shrink: 0; }
.fus-asist-quick-icon svg   { width: 18px; height: 18px; }
.fus-asist-quick-primary    { background: var(--fus-asist-dark); color: var(--fus-asist-brand); border-color: var(--fus-asist-dark); }
.fus-asist-quick-primary:hover  { background: var(--fus-asist-dark-soft); border-color: var(--fus-asist-dark-soft); }
.fus-asist-quick-whatsapp .fus-asist-quick-icon { color: #25d366; }
.fus-asist-quick-email    .fus-asist-quick-icon { color: var(--fus-asist-brand); }
