/* Coti - widget de chat (cr_chatventas) */
.cr-chat, .cr-chat * { box-sizing: border-box; }
.cr-chat [hidden] { display: none !important; }
.cr-chat {
  --cr-yellow: #FFC20E; --cr-orange: #FF7F11; --cr-green: #2DBE60;
  --cr-ink: #1d2433; --cr-muted: #7a8497; --cr-line: #e3e8f1; --cr-bg: #f4f6fb;
  position: fixed; bottom: 20px; right: 20px; z-index: 99990;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--cr-ink); -webkit-font-smoothing: antialiased;
}
.cr-chat.cr-pos-left { right: auto; left: 20px; }
.cr-chat button, .cr-chat textarea { font: inherit; color: inherit; margin: 0; }
.cr-chat button { cursor: pointer; }
.cr-chat h4 { margin: 0; font-size: 14px; }

/* ---------- botón flotante ---------- */
.cr-launcher {
  position: relative; display: block; width: 68px; height: 68px; padding: 0; border: 0; border-radius: 50%;
  background: var(--cr-yellow); box-shadow: 0 6px 20px rgba(20, 40, 90, .28);
  transition: transform .18s ease, box-shadow .18s ease; margin-left: auto;
}
.cr-pos-left .cr-launcher { margin-left: 0; margin-right: auto; }
.cr-launcher:hover { transform: scale(1.06); box-shadow: 0 8px 24px rgba(20, 40, 90, .34); }
.cr-launcher:focus-visible, .cr-chat button:focus-visible, .cr-chat textarea:focus-visible, .cr-chat a:focus-visible { outline: 3px solid var(--cr-primary); outline-offset: 2px; }
.cr-launcher img { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; transform: translate(-50%, -48%); object-fit: contain; }
.cr-launcher-dot { position: absolute; right: 3px; top: 3px; width: 15px; height: 15px; border-radius: 50%; background: var(--cr-green); border: 3px solid #fff; }
.cr-chat:not(.cr-open) .cr-launcher { animation: cr-bounce 4s ease-in-out 3s 2; }

/* ---------- globo de saludo ---------- */
.cr-greeting {
  position: absolute; bottom: 80px; right: 0; max-width: 240px; padding: 12px 30px 12px 14px;
  background: #fff; border-radius: 16px 16px 4px 16px; box-shadow: 0 6px 22px rgba(20, 40, 90, .2);
  animation: cr-pop .25s ease-out;
}
.cr-pos-left .cr-greeting { right: auto; left: 0; border-radius: 16px 16px 16px 4px; }
.cr-greeting-text { cursor: pointer; font-weight: 600; }
.cr-greeting-close { position: absolute; top: 2px; right: 6px; border: 0; background: none; font-size: 20px; line-height: 1; color: var(--cr-muted); padding: 4px; }

/* ---------- panel ---------- */
.cr-panel {
  position: absolute; bottom: 82px; right: 0; width: 384px; max-width: calc(100vw - 24px);
  height: min(660px, calc(100vh - 120px)); height: min(660px, calc(100dvh - 120px));
  display: flex; flex-direction: column; background: #fff; border-radius: 20px; overflow: hidden;
  box-shadow: 0 18px 60px rgba(15, 30, 70, .32);
  opacity: 0; transform: translateY(14px) scale(.96); transform-origin: bottom right;
  transition: opacity .2s ease, transform .2s ease;
}
.cr-pos-left .cr-panel { right: auto; left: 0; transform-origin: bottom left; }
.cr-chat.cr-open .cr-panel { opacity: 1; transform: none; }

.cr-header { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; background: var(--cr-primary); color: #fff; }
.cr-header-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--cr-yellow); object-fit: contain; padding: 2px; flex: none; }
.cr-header-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.cr-header-info strong { font-size: 16px; }
.cr-status { font-size: 12px; opacity: .92; display: flex; align-items: center; gap: 6px; }
.cr-status i { width: 8px; height: 8px; border-radius: 50%; background: #5CF28C; display: inline-block; }
.cr-icon-btn { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 22px; line-height: 1; display: grid; place-items: center; padding: 0; }
.cr-icon-btn:hover { background: rgba(255, 255, 255, .18); }

/* ---------- mensajes ---------- */
.cr-messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 12px 6px; background: var(--cr-bg); display: flex; flex-direction: column; gap: 4px; scroll-behavior: auto; }
.cr-row { display: flex; align-items: flex-end; gap: 8px; animation: cr-pop .2s ease-out; }
.cr-row.cr-user { justify-content: flex-end; }
.cr-row.cr-agent.cr-first { margin-top: 8px; }
.cr-row.cr-agent.cr-cont { padding-left: 36px; }
.cr-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--cr-yellow); object-fit: contain; flex: none; align-self: flex-start; }
.cr-col { display: flex; flex-direction: column; min-width: 0; max-width: 80%; }
.cr-user .cr-col { align-items: flex-end; }
.cr-col-wide { max-width: 100%; flex: 1; }
.cr-bubble { padding: 9px 13px; border-radius: 16px; background: #fff; box-shadow: 0 1px 2px rgba(20, 40, 90, .08); white-space: pre-wrap; overflow-wrap: anywhere; }
.cr-agent .cr-bubble { border-bottom-left-radius: 5px; }
.cr-user .cr-bubble { background: var(--cr-primary); color: #fff; border-bottom-right-radius: 5px; }
.cr-bubble a { color: var(--cr-primary); text-decoration: underline; }
.cr-time { font-size: 11px; color: var(--cr-muted); margin: 3px 4px 0; }

.cr-typing { display: inline-flex; gap: 4px; align-items: center; padding: 13px 14px; }
.cr-typing i { width: 7px; height: 7px; border-radius: 50%; background: #aab3c5; animation: cr-dot 1.1s infinite ease-in-out; }
.cr-typing i:nth-child(2) { animation-delay: .15s; }
.cr-typing i:nth-child(3) { animation-delay: .3s; }

.cr-notice { align-self: center; max-width: 92%; margin: 6px 0; padding: 8px 12px; border-radius: 12px; background: #fff4d6; color: #6b4e00; font-size: 13px; text-align: center; }
.cr-link-btn { border: 0; background: none; color: var(--cr-primary); font-weight: 700; text-decoration: underline; padding: 0 0 0 6px; }

/* ---------- tarjetas de producto ---------- */
.cr-cards { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.cr-card { flex: 0 0 188px; scroll-snap-align: start; background: #fff; border: 1px solid var(--cr-line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 1px 3px rgba(20, 40, 90, .07); }
.cr-card-img { position: relative; height: 128px; background: #fff; display: grid; place-items: center; }
.cr-card-img img { width: 100%; height: 100%; object-fit: contain; }
.cr-badge { position: absolute; left: 8px; top: 8px; background: var(--cr-orange); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.cr-card-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.cr-card-name { font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
.cr-card-price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.cr-card-price strong { font-size: 17px; }
.cr-card-price s { color: var(--cr-muted); font-size: 12px; }
.cr-stock { align-self: flex-start; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.cr-stock.cr-low { background: #fff1de; color: #a85a00; }
.cr-stock.cr-out { background: #eceff5; color: #596277; }
.cr-card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }

.cr-btn { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; border: 1px solid var(--cr-primary); background: var(--cr-primary); color: #fff; padding: 7px 10px; border-radius: 10px; font-weight: 600; font-size: 13px; line-height: 1.2; }
.cr-btn:hover { filter: brightness(1.08); color: #fff; text-decoration: none; }
.cr-btn-ghost { flex: 0 0 auto; padding-left: 14px; padding-right: 14px; background: #fff; color: var(--cr-primary); }
.cr-btn-ghost:hover { background: #f0f6ff; color: var(--cr-primary); }
.cr-btn-big { flex: none; display: inline-flex; padding: 10px 16px; font-size: 14px; border-radius: 999px; }
.cr-btn-cart { background: var(--cr-yellow); border-color: var(--cr-yellow); color: #3a2a00; }
.cr-btn-cart:hover { color: #3a2a00; }
.cr-btn-wa { background: #25D366; border-color: #25D366; color: #fff; }

/* ---------- respuestas rápidas y formulario ---------- */
.cr-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 4px; background: var(--cr-bg); }
.cr-quick:empty { display: none; }
.cr-chip { border: 1px solid var(--cr-primary); background: #fff; color: var(--cr-primary); border-radius: 999px; padding: 6px 13px; font-size: 14px; font-weight: 600; transition: background .15s, color .15s; }
.cr-chip:hover { background: var(--cr-primary); color: #fff; }

.cr-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; background: #fff; border-top: 1px solid var(--cr-line); }
.cr-form textarea { flex: 1; resize: none; max-height: 110px; min-height: 42px; border: 1px solid #d3dae8; border-radius: 21px; padding: 10px 15px; font-size: 16px; line-height: 1.3; background: #fff; box-shadow: none; }
.cr-form textarea:focus { border-color: var(--cr-primary); outline: none; }
.cr-send { flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--cr-primary); color: #fff; display: grid; place-items: center; padding: 0; }
.cr-send:disabled { opacity: .5; cursor: default; }
.cr-footnote { margin: 0; padding: 2px 14px 10px; font-size: 11px; color: var(--cr-muted); text-align: center; background: #fff; }

/* ---------- celulares ---------- */
@media (max-width: 520px) {
  .cr-chat { bottom: 14px; right: 14px; }
  .cr-pos-left { left: 14px; }
  .cr-chat.cr-open { bottom: 0; right: 0; left: 0; }
  .cr-chat.cr-open .cr-launcher { display: none; }
  .cr-panel { position: fixed; inset: 0; width: 100%; max-width: none; height: 100vh; height: 100dvh; border-radius: 0; transform-origin: bottom center; padding-top: env(safe-area-inset-top); }
  .cr-footnote { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .cr-card { flex-basis: 170px; }
}

/* ---------- animaciones ---------- */
@keyframes cr-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes cr-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes cr-bounce { 0%, 88%, 100% { transform: translateY(0); } 92% { transform: translateY(-9px); } 96% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) {
  .cr-chat *, .cr-chat *::before, .cr-chat *::after { animation: none !important; transition: none !important; }
}
