/* =====================================================================
   CURAR-C · Asesor virtual (chat)
   ===================================================================== */

.bot {
  position: fixed;
  right: var(--s-4);
  bottom: var(--s-4);
  z-index: 80;
  font-family: var(--sans);
}

/* Lanzador ------------------------------------------------------------ */
.bot__lanzador {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 56px;
  padding: 0 var(--s-4) 0 6px;
  background: var(--tinta);
  color: var(--papel);
  border: 1px solid rgba(230, 210, 168, .35);
  border-radius: 999px;
  box-shadow: 0 10px 30px -12px rgba(10, 36, 54, .7);
  cursor: pointer;
  transition: background var(--transicion), transform var(--transicion);
}
.bot__lanzador:hover { background: var(--azul-hondo); transform: translateY(-1px); }
.bot__lanzador[hidden] { display: none; }

.bot__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--oro-claro), var(--oro));
  color: #241a08;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
}
.bot__avatar--grande { width: 40px; height: 40px; font-size: 20px; }

.bot__lanzador-texto { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.bot__lanzador-texto strong { font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.bot__lanzador-texto small { font-size: 11px; color: var(--oro-claro); }

.bot__punto {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #58C48B;
  box-shadow: 0 0 0 3px rgba(88, 196, 139, .25);
  margin-left: 2px;
  animation: bot-latido 2.4s ease-in-out infinite;
}
@keyframes bot-latido {
  0%, 100% { box-shadow: 0 0 0 3px rgba(88, 196, 139, .22); }
  50% { box-shadow: 0 0 0 6px rgba(88, 196, 139, .08); }
}

/* Panel ---------------------------------------------------------------- */
.bot__panel {
  position: fixed;
  right: var(--s-4);
  bottom: var(--s-4);
  width: min(384px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  background: var(--papel);
  border: 1px solid var(--linea-fuerte);
  border-radius: var(--radio-g);
  box-shadow: 0 24px 60px -24px rgba(10, 36, 54, .55);
  overflow: hidden;
  transform-origin: bottom right;
  animation: bot-entrar 220ms cubic-bezier(.22, .61, .36, 1);
}
.bot__panel[hidden] { display: none; }
@keyframes bot-entrar {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.bot__cabecera {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  background: var(--tinta);
  color: var(--papel);
}
.bot__identidad { display: flex; flex-direction: column; line-height: 1.25; margin-right: auto; min-width: 0; }
.bot__identidad strong { font-family: var(--serif); font-size: 18px; font-weight: 400; }
.bot__identidad span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(247, 242, 233, .72);
}
.bot__en-linea {
  width: 6px; height: 6px; border-radius: 50%;
  background: #58C48B;
  display: inline-block;
}
.bot__acciones { display: flex; gap: 2px; }
.bot__icono {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radio);
  color: var(--oro-claro);
  cursor: pointer;
  transition: background var(--transicion), border-color var(--transicion);
}
.bot__icono:hover { background: rgba(230, 210, 168, .12); border-color: rgba(230, 210, 168, .3); color: #fff; }
.bot__icono svg { width: 17px; height: 17px; }

/* Mensajes ------------------------------------------------------------- */
.bot__mensajes {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 100% 0%, rgba(193, 145, 63, .06), transparent 45%),
    var(--papel);
}

.bot__fila { display: flex; }
.bot__fila--bot { justify-content: flex-start; }
.bot__fila--usuario { justify-content: flex-end; }

.bot__burbuja {
  max-width: 86%;
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.55;
  border-radius: 12px;
  word-wrap: break-word;
}
.bot__burbuja p { margin: 0 0 6px; }
.bot__burbuja p:last-child { margin-bottom: 0; }
.bot__burbuja strong { color: var(--tinta); font-weight: 700; }

.bot__burbuja--bot {
  background: var(--papel-alto);
  color: var(--texto);
  border: 1px solid var(--linea);
  border-bottom-left-radius: 3px;
}
.bot__burbuja--usuario {
  background: var(--tinta);
  color: var(--papel);
  border-bottom-right-radius: 3px;
}
.bot__burbuja--usuario strong { color: var(--oro-claro); }

.bot__burbuja ul { margin: 4px 0 6px; padding-left: 18px; }
.bot__burbuja li { margin-bottom: 3px; }

/* Indicador de escritura */
.bot__escribiendo {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}
.bot__escribiendo span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--linea-fuerte);
  animation: bot-punto 1.1s infinite ease-in-out;
}
.bot__escribiendo span:nth-child(2) { animation-delay: .15s; }
.bot__escribiendo span:nth-child(3) { animation-delay: .3s; }
@keyframes bot-punto {
  0%, 60%, 100% { transform: translateY(0); opacity: .55; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* Tarjetas de producto dentro del chat */
.bot__productos { display: grid; gap: var(--s-2); margin-top: 4px; }
.bot__producto {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: var(--s-2);
  align-items: center;
  padding: 8px;
  background: var(--papel);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
}
.bot__producto img {
  width: 52px; height: 58px;
  object-fit: cover;
  border: 1px solid var(--linea);
  border-radius: 2px;
}
.bot__producto-info { min-width: 0; }
.bot__producto-nombre {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tinta);
  text-decoration: none;
  line-height: 1.3;
}
.bot__producto-nombre:hover { color: var(--azul); }
.bot__producto-precio {
  font-size: 12px;
  color: var(--texto-sec);
  font-variant-numeric: tabular-nums;
}
.bot__producto-precio s { opacity: .7; margin-left: 4px; }
.bot__producto-acciones { display: flex; flex-direction: column; gap: 4px; }
.bot__mini-btn {
  font-size: 11px;
  padding: 5px 8px;
  border: 1px solid var(--tinta);
  background: var(--tinta);
  color: var(--papel);
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transicion), border-color var(--transicion);
}
.bot__mini-btn:hover { background: var(--azul); border-color: var(--azul); }
.bot__mini-btn--linea { background: transparent; color: var(--tinta); border-color: var(--linea-fuerte); }
.bot__mini-btn--linea:hover { background: var(--papel-hondo); color: var(--tinta); }

/* Sugerencias ---------------------------------------------------------- */
.bot__sugerencias {
  display: flex;
  gap: 6px;
  padding: 0 var(--s-4) var(--s-2);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--papel);
}
.bot__sugerencias::-webkit-scrollbar { display: none; }
.bot__chip {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid var(--linea-fuerte);
  background: var(--papel-alto);
  color: var(--tinta);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--transicion), background var(--transicion);
}
.bot__chip:hover { border-color: var(--tinta); background: var(--papel-hondo); }

/* Formulario ----------------------------------------------------------- */
.bot__form {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4) var(--s-2);
  border-top: 1px solid var(--linea);
  background: var(--papel-alto);
}
.bot__campo {
  flex: 1;
  min-height: 42px;
  max-height: 110px;
  padding: 10px 12px;
  border: 1px solid var(--linea-fuerte);
  border-radius: var(--radio);
  background: var(--papel);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--texto);
  resize: none;
}
.bot__campo:focus { outline: none; border-color: var(--azul); background: var(--papel-alto); }
.bot__enviar {
  width: 42px; height: 42px;
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--oro);
  border: 1px solid var(--oro);
  border-radius: var(--radio);
  color: #241a08;
  cursor: pointer;
  transition: background var(--transicion);
}
.bot__enviar:hover { background: var(--oro-claro); border-color: var(--oro-claro); }
.bot__enviar:disabled { opacity: .5; cursor: not-allowed; }
.bot__enviar svg { width: 18px; height: 18px; }

.bot__nota {
  margin: 0;
  padding: 6px var(--s-4) 10px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--texto-sec);
  background: var(--papel-alto);
  text-align: center;
}
.bot__nota a { color: var(--texto-sec); text-decoration: underline; }

/* Aviso de carrito dentro del chat */
.bot__carrito-aviso {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px dashed var(--oro);
  background: rgba(193, 145, 63, .07);
  border-radius: var(--radio);
  font-size: 12px;
}
.bot__carrito-aviso a {
  color: var(--tinta);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.bot__carrito-aviso a:hover { text-decoration: underline; }

/* Pedido creado dentro del chat --------------------------------------- */
.bot__pedido {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--oro);
  border-radius: 6px;
  background: linear-gradient(180deg, #FFFDF9, #FBF3E2);
}
.bot__pedido-etiqueta {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #7a5a14;
}
.bot__pedido-codigo {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: .06em;
  color: var(--tinta);
}
.bot__pedido-meta { font-size: 12px; color: var(--texto-sec); font-variant-numeric: tabular-nums; }
.bot__pedido-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  margin-top: 6px;
  background: #1D6B4B;
  border-radius: 3px;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transicion);
}
.bot__pedido-btn:hover { background: #17583e; color: #fff; }
.bot__pedido-secundario {
  text-align: center;
  font-size: 11.5px;
  color: var(--texto-sec);
  text-decoration: underline;
}
.bot__pedido-secundario:hover { color: var(--tinta); }

/* Progreso del formulario --------------------------------------------- */
.bot__progreso {
  height: 3px;
  margin: 2px 0 6px;
  border-radius: 2px;
  background: var(--linea);
  overflow: hidden;
}
.bot__progreso span {
  display: block;
  height: 100%;
  background: var(--oro);
  transition: width var(--transicion);
}
.bot__progreso-texto {
  display: block;
  margin-bottom: 8px;
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--texto-sec);
}

/* Nota secundaria dentro del chat ------------------------------------- */
.bot__burbuja--nota {
  background: transparent;
  border: 1px dashed var(--linea-fuerte);
  color: var(--texto-sec);
  font-size: 12px;
}

/* Móvil --------------------------------------------------------------- */
@media (max-width: 560px) {
  .bot__panel {
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
  }
  .bot__lanzador { height: 52px; }
  .bot__lanzador-texto small { display: none; }
}

/* La ficha de producto tiene barra de compra fija: subimos el lanzador */
@media (max-width: 899px) {
  .pagina-producto .bot__lanzador { bottom: calc(var(--s-4) + 74px); }
}

/* Si el bot está abierto, el body no debe hacer scroll detrás (móvil) */
@media (max-width: 560px) {
  body.bot-abierto { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .bot__panel { animation: none; }
  .bot__punto { animation: none; }
  .bot__escribiendo span { animation: none; }
}
