/* =========================================================
   DobleNueveIT — chatbot (ficha 9|9)
   Usa las variables de marca definidas en styles.css
   ========================================================= */

.cb { --cb-ivory: #fbf8ef; position: fixed; right: 24px; bottom: 24px; z-index: 90; font-family: var(--font); }
@media (max-width: 760px) { .cb { right: 16px; bottom: 16px; } }

/* ---------- Botón flotante ---------- */
.cb-launcher {
  position: relative; width: 68px; height: 68px; border-radius: 50%;
  border: 3px solid var(--green); background: var(--deep); cursor: pointer; padding: 0;
  display: grid; place-items: center;
  box-shadow: 0 10px 28px rgba(10, 36, 32, .35);
  transition: transform .2s ease, box-shadow .2s ease;
  animation: cb-pop .6s cubic-bezier(.3, 1.6, .5, 1) both;
}
.cb-launcher:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 14px 32px rgba(10, 36, 32, .42); }
.cb-launcher:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 50%; }

.cb-launcher .cb-tile { width: 32px; height: 51px; transform: rotate(-10deg); transition: transform .3s ease, opacity .2s ease; animation: cb-wiggle 6s ease-in-out 2s infinite; }
.cb-launcher:hover .cb-tile { animation: cb-hop .6s ease; }
.cb-launcher .cb-x { position: absolute; width: 26px; height: 26px; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; fill: none; opacity: 0; transform: rotate(-90deg) scale(.5); transition: transform .3s ease, opacity .2s ease; }
.cb.open .cb-launcher .cb-tile { opacity: 0; transform: rotate(80deg) scale(.4); animation: none; }
.cb.open .cb-launcher .cb-x { opacity: 1; transform: none; }

.cb-badge {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--gold); color: var(--ink); font-size: 12px; font-weight: 600;
  display: grid; place-items: center; border: 2px solid #fff; animation: cb-pulse 2s ease-in-out infinite;
}
.cb.seen .cb-badge { display: none; }

/* ---------- Ficha (SVG) ---------- */
.cb-tile .tile { fill: var(--cb-ivory); stroke: var(--deep); stroke-width: 3; }
.cb-tile .div { stroke: var(--deep); stroke-width: 2.5; stroke-linecap: round; }
.cb-tile .pip { fill: var(--deep); }
.cb-tile .pip-g { fill: var(--green-btn); }
.cb-tile .eye-w { fill: #fff; stroke: var(--deep); stroke-width: 1.6; }
.cb-tile .shine { fill: #fff; }
.cb-tile .eyes { transform-box: fill-box; transform-origin: center; animation: cb-blink 4.5s infinite; }
.cb-tile .pupils { transition: transform .2s ease; }
.cb.thinking .cb-head .cb-tile .pupils { transform: translate(1.5px, -1.5px); }

/* ---------- Globito ---------- */
.cb-teaser {
  position: absolute; right: 4px; bottom: 84px; width: max-content; max-width: min(260px, calc(100vw - 40px));
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 16px 16px 4px 16px;
  padding: 12px 34px 12px 14px; font-size: 15px; line-height: 1.4; cursor: pointer;
  box-shadow: 0 10px 30px rgba(10, 36, 32, .18);
  animation: cb-teaser-in .5s cubic-bezier(.3, 1.5, .5, 1) both;
}
.cb-teaser[hidden] { display: none; }
.cb-teaser-close {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-3); font-size: 18px; line-height: 1; cursor: pointer;
}
.cb-teaser-close:hover { background: var(--bg-gray); color: var(--ink); }

/* ---------- Panel ---------- */
.cb-panel {
  position: absolute; right: 0; bottom: 84px;
  width: min(380px, calc(100vw - 32px)); height: min(580px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border-radius: 20px; border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(10, 36, 32, .28);
  transform-origin: bottom right; transform: scale(.6) translateY(20px); opacity: 0; visibility: hidden;
  transition: transform .3s cubic-bezier(.3, 1.3, .5, 1), opacity .2s ease, visibility 0s linear .3s;
}
.cb.open .cb-panel { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }

.cb-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px;
  background: var(--deep); color: #fff; border-bottom: 3px solid var(--green);
}
.cb-head .cb-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--deep-2); display: grid; place-items: center; flex: none; }
.cb-head .cb-tile { width: 20px; height: 32px; transform: rotate(-10deg); }
.cb.happy .cb-head .cb-tile { animation: cb-hop .5s ease 3; }
.cb-head-text { flex: 1; min-width: 0; line-height: 1.25; }
.cb-head-text strong { display: block; font-weight: 600; font-size: 16px; }
.cb-head-text strong .gold { color: var(--gold); }
.cb-head-text > span { font-size: 13px; color: rgba(255, 255, 255, .72); display: inline-flex; align-items: center; gap: 6px; }
.cb-head-text > span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.cb-close {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: #fff; cursor: pointer;
  display: grid; place-items: center; flex: none;
}
.cb-close:hover { background: rgba(255, 255, 255, .12); }
.cb-close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }

.cb-log {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-gray); overscroll-behavior: contain; scroll-behavior: smooth;
}
.cb-msg {
  max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.45;
  white-space: pre-line; overflow-wrap: anywhere; animation: cb-msg-in .25s ease both;
}
.cb-msg.bot { align-self: flex-start; background: #fff; color: var(--ink); border: 1px solid var(--line-soft); border-bottom-left-radius: 4px; }
.cb-msg.user { align-self: flex-end; background: var(--green-btn); color: #fff; border-bottom-right-radius: 4px; }
.cb-msg.summary { background: #fff; border: 1.5px dashed var(--green-btn); }

/* Escribiendo… (tres puntitos de dominó) */
.cb-typing { align-self: flex-start; display: inline-flex; gap: 5px; padding: 13px 16px; background: #fff; border: 1px solid var(--line-soft); border-radius: 16px 16px 16px 4px; }
.cb-typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); animation: cb-dot 1s ease-in-out infinite; }
.cb-typing i:nth-child(2) { animation-delay: .15s; }
.cb-typing i:nth-child(3) { animation-delay: .3s; }

/* Botones de respuesta rápida */
.cb-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 6px; animation: cb-msg-in .25s ease both; }
.cb-chip {
  font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--green-btn); color: var(--green-btn); background: #fff;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.cb-chip:hover { background: var(--green-btn); color: #fff; transform: translateY(-1px); }
.cb-chips.used .cb-chip { display: none; }

/* Caja de texto */
.cb-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: #fff; }
.cb-input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 999px; color: var(--ink); background: #fff;
}
.cb-input:focus { outline: none; border-color: var(--green-btn); }
.cb-send {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--green-btn); color: #fff; display: grid; place-items: center; transition: background .15s ease;
}
.cb-send:hover { background: var(--green-btn-hover); }
.cb-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Confeti */
.cb-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cb-confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: cb-fall 1.8s ease-in forwards; }

/* ---------- Animaciones ---------- */
@keyframes cb-pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes cb-wiggle {
  0%, 88%, 100% { transform: rotate(-10deg); }
  91% { transform: rotate(8deg) translateY(-3px); }
  94% { transform: rotate(-16deg); }
  97% { transform: rotate(2deg); }
}
@keyframes cb-hop {
  0%, 100% { transform: rotate(-10deg) translateY(0); }
  40% { transform: rotate(6deg) translateY(-7px); }
  70% { transform: rotate(-14deg) translateY(0); }
}
@keyframes cb-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes cb-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes cb-teaser-in { from { opacity: 0; transform: translateY(10px) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes cb-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cb-dot { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-5px); opacity: 1; } }
@keyframes cb-fall { to { transform: translateY(620px) rotate(720deg); opacity: .2; } }

@media (prefers-reduced-motion: reduce) {
  .cb *, .cb *::before, .cb *::after, .cb-launcher { animation: none !important; transition: none !important; }
  .cb-log { scroll-behavior: auto; }
}
