.customer-chat { --cc-brand: #111111; --cc-ink: #333333; --cc-muted: #6b6b6b; position: fixed; right: 24px; bottom: var(--cc-bottom, 24px); z-index: 1050; font: 14px/1.5 system-ui, -apple-system, sans-serif; color: var(--cc-ink); }
.customer-chat *, .customer-chat *::before, .customer-chat *::after { box-sizing: border-box; }
.customer-chat [hidden] { display: none !important; }
.customer-chat button, .customer-chat input, .customer-chat textarea { font: inherit; }
.customer-chat button { cursor: pointer; border: 0; }
.customer-chat button:disabled { opacity: .55; cursor: not-allowed; }
.customer-chat :focus-visible { outline: 3px solid #ffb863; outline-offset: 3px; }
.customer-chat h2, .customer-chat h3, .customer-chat p { margin: 0; }
.customer-chat .cc-launcher { display: flex; align-items: center; gap: 10px; margin-left: auto; padding: 16px 22px; border-radius: 999px; background: var(--cc-brand); color: white; box-shadow: 0 6px 24px #13395a33; font-weight: 650; }
.customer-chat .cc-launcher span { overflow: hidden; max-width: 120px; white-space: nowrap; }
/* Al bajar por la página (lo activa customer-chat.js) queda solo el icono. */
.customer-chat .cc-launcher.cc-compact { gap: 0; padding: 16px; }
.customer-chat .cc-launcher.cc-compact span { max-width: 0; opacity: 0; }
.customer-chat .cc-panel { position: absolute; bottom: 74px; right: 0; display: flex; flex-direction: column; width: 390px; height: 620px; max-height: calc(100dvh - 120px); overflow: hidden; border-radius: 20px; background: white; box-shadow: 0 16px 70px #10263d33; border: 1px solid #e6e6e6; }
.customer-chat .cc-header { display: flex; align-items: center; gap: 12px; padding: 21px; background: var(--cc-brand); color: white; }
.customer-chat .cc-header h2 { font-size: 18px; font-weight: 700; color: inherit; line-height: 1.3; }
.customer-chat .cc-title-emoji { vertical-align: text-bottom; }
.customer-chat .cc-header p { font-size: 12px; color: #cccccc; margin-top: 3px; }
.customer-chat .cc-avatar { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: white; }
.customer-chat .cc-avatar img { width: 28px; height: 28px; object-fit: contain; }
.customer-chat .cc-status { position: absolute; bottom: -2px; right: -2px; width: 13px; height: 13px; border-radius: 50%; background: #9aa5b1; border: 2px solid var(--cc-brand); }
.customer-chat .cc-status.cc-online { background: #29c46f; }
.customer-chat .cc-minimize { background: transparent; color: white; width: 36px; height: 36px; border-radius: 8px; font-size: 26px; }
.customer-chat .cc-menu { position: relative; margin-left: auto; }
.customer-chat .cc-menu-toggle { background: transparent; color: white; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.customer-chat .cc-menu-toggle:hover { background: rgba(255, 255, 255, .12); }
.customer-chat .cc-menu-list { position: absolute; top: calc(100% + 8px); right: 0; z-index: 5; display: flex; flex-direction: column; gap: 2px; min-width: 200px; padding: 6px; border-radius: 12px; background: white; box-shadow: 0 12px 32px #10263d33; border: 1px solid #e6e6e6; }
.customer-chat .cc-menu-list button { padding: 10px 12px; border-radius: 8px; background: transparent; color: var(--cc-ink); font-size: 13px; font-weight: 600; text-align: left; }
.customer-chat .cc-menu-list button:hover { background: #f8f8f8; }
.customer-chat .cc-content { padding: 10px 22px 22px; overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; background: linear-gradient(#f8f8f8, #fff 220px); }
.customer-chat h3 { font-size: 24px; line-height: 1.3; font-weight: 700; margin: 12px 0; color: var(--cc-ink); }
.customer-chat .cc-contact > p, .customer-chat .cc-start > p { color: var(--cc-muted); margin-bottom: 20px; }
.customer-chat .cc-eyebrow { font-size: 10px; letter-spacing: 1.5px; font-weight: 750; color: var(--cc-brand); }
.customer-chat label { display: block; font-size: 12px; font-weight: 650; margin-bottom: 6px; }
.customer-chat input { width: 100%; height: 46px; padding: 12px; margin-bottom: 16px; border: 1px solid #dedede; border-radius: 10px; background: white; color: var(--cc-ink); box-shadow: none; }
.customer-chat .cc-small { font-size: 11px; line-height: 1.6; }
.customer-chat .cc-primary { background: var(--cc-brand); color: white; padding: 12px 16px; border-radius: 10px; font-weight: 650; }
.customer-chat .cc-contact-submit, .customer-chat .cc-start-submit, .customer-chat .cc-new { width: 100%; }
.customer-chat .cc-secondary { background: #f1f1f1; color: var(--cc-ink); padding: 8px 10px; border-radius: 8px; font-size: 12px; }
.customer-chat .cc-error { padding: 12px; border-radius: 10px; background: #fff0ed; color: #a33122; margin-bottom: 12px; overflow-wrap: anywhere; }
.customer-chat .cc-messages { display: flex; flex-direction: column; gap: 14px; }
.customer-chat .cc-message { max-width: 90%; align-self: flex-start; display: flex; flex-direction: column; align-items: flex-start; }
.customer-chat .cc-message-user { align-self: flex-end; align-items: flex-end; }
.customer-chat .cc-message > p, .customer-chat .cc-message-body { background: #f1f1f1; padding: 12px 14px; border-radius: 14px 14px 14px 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.customer-chat .cc-message-user p { background: var(--cc-brand); color: white; border-radius: 14px 14px 4px 14px; }
.customer-chat .cc-message small { display: block; color: var(--cc-muted); font-size: 10px; margin: 4px 3px; }
.customer-chat .cc-message-user small { text-align: right; }
.customer-chat .cc-pending { opacity: 1; }
.customer-chat .cc-message-system { max-width: 100%; align-self: center; align-items: center; text-align: center; }
.customer-chat .cc-message-system p { background: transparent; font-size: 12px; color: var(--cc-muted); padding: 6px; }
.customer-chat .cc-typing p { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.customer-chat .cc-typing-text { font-size: 13px; color: var(--cc-muted); }
.customer-chat .cc-typing-text:empty { display: none; }
.customer-chat .cc-typing-dots { display: flex; align-items: center; gap: 4px; }
.customer-chat .cc-typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--cc-muted); }
.customer-chat .cc-empty { text-align: center; color: var(--cc-muted); padding: 28px 10px 16px; }
.customer-chat .cc-confirm { display: flex; flex-wrap: wrap; gap: 8px; border: 1px solid #dedede; border-radius: 10px; padding: 12px; margin: 0 0 12px; }
.customer-chat .cc-confirm p { width: 100%; margin-bottom: 2px; }
.customer-chat .cc-foot { flex-shrink: 0; padding: 14px 22px; border-top: 1px solid #eeeeee; background: white; }
.customer-chat .cc-composer { display: flex; align-items: flex-end; gap: 6px; border: 1px solid #d5d5d5; border-radius: 999px; background: white; padding: 5px 5px 5px 18px; }
.customer-chat .cc-composer:focus-within { border-color: var(--cc-brand); box-shadow: 0 0 0 3px #11111122; }
.customer-chat .cc-composer :focus-visible { outline: none; }
.customer-chat textarea { flex: 1; width: auto; border: 0; resize: none; min-height: 24px; max-height: 90px; padding: 6px 0; box-shadow: none; background: transparent; color: var(--cc-ink); }
.customer-chat textarea::placeholder { color: var(--cc-muted); }
.customer-chat .cc-send { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border-radius: 50%; }
.customer-chat .cc-counter { display: none; }
.customer-chat .cc-disclaimer { margin-top: 6px; text-align: center; font-size: 9px; color: var(--cc-muted); }
/* Conversación cerrada: el aviso cierra el hilo y, sin compositor, el botón se separa del texto. */
.customer-chat .cc-closed-notice { padding: 10px 12px; border-radius: 10px; background: #fff0ed; color: #a33122; font-size: 13px; text-align: center; margin-top: 18px; }
.customer-chat .cc-composer[hidden] + .cc-disclaimer { margin-top: 0; }
.customer-chat .cc-new { margin-top: 12px; }
.customer-chat .cc-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 480px) {
    .customer-chat { right: 12px; bottom: var(--cc-bottom, max(12px, env(safe-area-inset-bottom))); }
    /* Pantalla completa siguiendo al viewport visual (--cc-vv-* los pone customer-chat.js): así el teclado no tapa ni encoge el panel. */
    .customer-chat .cc-panel { position: fixed; top: var(--cc-vv-top, 0px); right: 0; bottom: auto; left: 0; width: 100%; height: var(--cc-vv-height, 100dvh); max-height: none; border: 0; border-radius: 0; }
    .customer-chat.cc-open .cc-launcher { display: none; }
    html.cc-chat-lock { overflow: hidden; }
    .customer-chat .cc-content { padding: 10px 18px 18px; }
    .customer-chat .cc-foot { padding: 10px 18px max(10px, env(safe-area-inset-bottom)); }
    .customer-chat input, .customer-chat textarea { font-size: 16px; }
    .customer-chat .cc-launcher { padding: 13px 18px; }
    .customer-chat .cc-launcher.cc-compact { padding: 13px; }
    /* Con el teclado abierto se compacta todo lo que no sea el campo en uso. */
    .customer-chat.cc-keyboard .cc-header { padding: 10px 16px; }
    .customer-chat.cc-keyboard .cc-header p, .customer-chat.cc-keyboard .cc-disclaimer { display: none; }
    .customer-chat.cc-keyboard .cc-avatar { width: 34px; height: 34px; border-radius: 10px; }
    .customer-chat.cc-keyboard .cc-avatar img { width: 22px; height: 22px; }
    .customer-chat.cc-keyboard .cc-contact h3, .customer-chat.cc-keyboard .cc-contact > p { display: none; }
    .customer-chat.cc-keyboard .cc-foot { padding: 8px 18px; }
}
@media (prefers-reduced-motion: no-preference) {
    .customer-chat .cc-launcher, .customer-chat .cc-launcher span { transition: gap .2s ease, padding .2s ease, max-width .2s ease, opacity .15s ease; }
    .customer-chat .cc-panel { animation: cc-appear .18s ease-out; transform-origin: bottom right; }
    .customer-chat .cc-panel.cc-closing { animation: cc-disappear .16s ease-in forwards; }
    .customer-chat .cc-typing-dots span { animation: cc-bounce 1.2s infinite ease-in-out; }
    .customer-chat .cc-typing-dots span:nth-child(2) { animation-delay: .15s; }
    .customer-chat .cc-typing-dots span:nth-child(3) { animation-delay: .3s; }
    @keyframes cc-appear { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
    @keyframes cc-disappear { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(8px) scale(.98); } }
    @keyframes cc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
}

.customer-chat .cc-message-body { white-space: normal; }
.customer-chat .cc-message-body p { margin: 0 0 10px; }
.customer-chat .cc-message-body p:last-child { margin-bottom: 0; }
.customer-chat .cc-message-body ul, .customer-chat .cc-message-body ol { margin: 8px 0; padding-left: 20px; }
.customer-chat .cc-message-body li { margin: 5px 0; }
.customer-chat .cc-message-body strong { font-weight: 700; }
.customer-chat .cc-message-body a { color: var(--cc-brand); text-decoration: underline; overflow-wrap: anywhere; }

/* Carrusel de productos del asistente: desliza en horizontal; flechas solo con ratón. */
.customer-chat .cc-message-has-products { max-width: 100%; align-self: stretch; }
.customer-chat .cc-products { position: relative; width: 100%; margin-top: 8px; }
.customer-chat .cc-products-track { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 2px; padding: 2px 2px 6px; overscroll-behavior-x: contain; scrollbar-width: none; }
.customer-chat .cc-products-track::-webkit-scrollbar { display: none; }
.customer-chat .cc-product { flex: 0 0 148px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid #e6e6e6; border-radius: 14px; background: white; color: var(--cc-ink); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.customer-chat .cc-product:hover { border-color: var(--cc-brand); box-shadow: 0 4px 14px #10263d1a; color: var(--cc-ink); text-decoration: none; }
.customer-chat .cc-product-media { display: grid; place-items: center; aspect-ratio: 1; margin-bottom: 4px; border-radius: 10px; background: #f8f8f8; overflow: hidden; }
.customer-chat .cc-product-media img { width: 100%; height: 100%; object-fit: contain; }
.customer-chat .cc-product-name { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; line-height: 1.35; min-height: calc(12px * 1.35 * 3); }
.customer-chat .cc-product-price { font-weight: 750; font-size: 14px; }
.customer-chat .cc-product-stock { font-size: 11px; font-weight: 650; color: #a33122; }
.customer-chat .cc-product-cta { margin-top: auto; padding: 7px 8px; border-radius: 999px; background: var(--cc-brand); color: white; font-size: 12px; font-weight: 650; text-align: center; }
.customer-chat .cc-products-nav { display: none; position: absolute; top: 38%; width: 30px; height: 30px; padding: 0; border-radius: 50%; background: white; color: var(--cc-ink); box-shadow: 0 2px 10px #10263d33; font-size: 20px; line-height: 1; }
.customer-chat .cc-products-prev { left: -8px; }
.customer-chat .cc-products-next { right: -8px; }
@media (hover: hover) and (pointer: fine) {
    .customer-chat .cc-products-nav { display: grid; place-items: center; }
    .customer-chat .cc-products-at-start .cc-products-prev, .customer-chat .cc-products-at-end .cc-products-next { display: none; }
}
@media (max-width: 480px) {
    .customer-chat .cc-product { flex-basis: 42%; }
}

/* Selector de emojis a la izquierda del campo de texto; el panel se abre encima del compositor. */
.customer-chat .cc-composer { position: relative; padding-left: 5px; }
.customer-chat .cc-emoji-toggle { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border-radius: 50%; background: transparent; color: var(--cc-muted); }
.customer-chat .cc-emoji-toggle:hover, .customer-chat .cc-emoji-toggle[aria-expanded="true"] { background: #f1f1f1; color: var(--cc-brand); }
.customer-chat .cc-emoji-panel { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 5; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 196px; overflow-y: auto; padding: 8px; border: 1px solid #e6e6e6; border-radius: 14px; background: white; box-shadow: 0 12px 32px #10263d33; }
.customer-chat .cc-emoji { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; padding: 0; border-radius: 8px; background: transparent; font-size: 20px; line-height: 1; }
.customer-chat .cc-emoji:hover { background: #f8f8f8; }
