/* Asistente BuildCore — widget flotante. Todo va bajo #bc-asistente para no chocar con los estilos de cada página. */
#bc-asistente {
  --bc-primario: #171427;
  --bc-primario-hover: #2a2443;
  --bc-acento: #7c3aed;
  --bc-acento-hover: #6425d6;
  --bc-naranja: #ff6a13;
  --bc-naranja-hover: #e85a05;
  --bc-verde: #27ae60;
  --bc-rojo: #e74c3c;
  --bc-amarillo: #f39c12;
  --bc-fondo: #ffffff;
  --bc-fondo-suave: #f7f6fb;
  --bc-borde: #e7e4f0;
  --bc-texto: #23212f;
  --bc-texto-suave: #6c6981;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--bc-texto);
  text-align: left;
}
#bc-asistente *, #bc-asistente *::before, #bc-asistente *::after { box-sizing: border-box; }
#bc-asistente [hidden] { display: none !important; }
#bc-asistente button { font-family: inherit; }

/* Lanzador */
#bc-asistente .bc-lanzador {
  position: relative;
  width: 58px; height: 58px;
  border: none; border-radius: 50%;
  background: var(--bc-acento); color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin-left: auto;
  transition: transform .15s ease, background .15s ease;
}
#bc-asistente .bc-lanzador:hover { background: var(--bc-acento-hover); transform: scale(1.05); }
#bc-asistente .bc-contador {
  position: absolute; top: -2px; right: -2px;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--bc-naranja); color: #fff;
  font-size: 12px; font-weight: bold; line-height: 20px; text-align: center;
}
#bc-asistente .bc-contador.bc-alerta { background: var(--bc-rojo); }

/* Burbuja proactiva */
#bc-asistente .bc-burbuja {
  position: absolute; right: 0; bottom: 70px;
  width: 260px; padding: 12px 30px 12px 14px;
  background: var(--bc-fondo); border: 1px solid var(--bc-borde); border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .15);
  cursor: pointer; animation: bc-aparecer .2s ease;
}
#bc-asistente .bc-burbuja-cerrar {
  position: absolute; top: 4px; right: 6px;
  border: none; background: none; color: var(--bc-texto-suave); font-size: 18px; cursor: pointer;
}

/* Panel */
#bc-asistente .bc-panel {
  position: absolute; right: 0; bottom: 70px;
  width: 370px; height: 560px;
  max-width: calc(100vw - 32px); max-height: calc(100vh - 110px);
  display: flex; flex-direction: column;
  background: var(--bc-fondo); border-radius: 14px; overflow: hidden;
  box-shadow: 0 10px 32px rgba(0, 0, 0, .25);
  animation: bc-aparecer .2s ease;
}
#bc-asistente .bc-cabecera {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--bc-primario); color: #fff;
}
#bc-asistente .bc-cabecera strong { display: block; font-size: 15px; }
#bc-asistente .bc-estado { font-size: 12px; opacity: .8; }
#bc-asistente .bc-acciones { display: flex; gap: 4px; }
#bc-asistente .bc-icono {
  width: 30px; height: 30px; border: none; border-radius: 6px;
  background: transparent; color: #fff; font-size: 18px; cursor: pointer;
}
#bc-asistente .bc-icono:hover { background: rgba(255, 255, 255, .15); }

#bc-asistente .bc-pestanas { display: flex; border-bottom: 1px solid var(--bc-borde); }
#bc-asistente .bc-pestana {
  flex: 1; padding: 9px; border: none; background: none; cursor: pointer;
  color: var(--bc-texto-suave); font-size: 13px; font-weight: bold;
  border-bottom: 2px solid transparent;
}
#bc-asistente .bc-pestana.activa { color: var(--bc-primario); border-bottom-color: var(--bc-acento); }

#bc-asistente .bc-vista { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#bc-asistente .bc-vista-ensamble { overflow-y: auto; padding: 12px; display: block; }

/* Mensajes */
#bc-asistente .bc-mensajes {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bc-fondo-suave);
}
#bc-asistente .bc-mensaje {
  max-width: 88%; padding: 8px 12px; border-radius: 12px;
  word-wrap: break-word; overflow-wrap: anywhere;
}
#bc-asistente .bc-mensaje p { margin: 0 0 6px; }
#bc-asistente .bc-mensaje p:last-child { margin-bottom: 0; }
#bc-asistente .bc-mensaje ul { margin: 4px 0 6px; padding-left: 18px; }
#bc-asistente .bc-mensaje li { margin: 2px 0; }
#bc-asistente .bc-mensaje code { background: rgba(0, 0, 0, .06); padding: 0 4px; border-radius: 4px; }
#bc-asistente .bc-asistente { align-self: flex-start; background: var(--bc-fondo); border: 1px solid var(--bc-borde); border-bottom-left-radius: 4px; }
#bc-asistente .bc-asistente a { color: var(--bc-acento); font-weight: bold; text-decoration: none; }
#bc-asistente .bc-asistente a:hover { text-decoration: underline; }
#bc-asistente .bc-usuario { align-self: flex-end; background: var(--bc-primario); color: #fff; border-bottom-right-radius: 4px; }

#bc-asistente .bc-escribiendo { display: flex; gap: 4px; padding: 12px; }
#bc-asistente .bc-escribiendo span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--bc-texto-suave);
  animation: bc-punto 1s infinite ease-in-out;
}
#bc-asistente .bc-escribiendo span:nth-child(2) { animation-delay: .15s; }
#bc-asistente .bc-escribiendo span:nth-child(3) { animation-delay: .3s; }

/* Chips de sugerencias */
#bc-asistente .bc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; background: var(--bc-fondo); }
#bc-asistente .bc-chips:empty { display: none; }
#bc-asistente .bc-chip {
  padding: 5px 10px; border: 1px solid var(--bc-acento); border-radius: 14px;
  background: var(--bc-fondo); color: var(--bc-acento); font-size: 12px; cursor: pointer; text-align: left;
}
#bc-asistente .bc-chip:hover { background: var(--bc-acento); color: #fff; }

/* Entrada */
#bc-asistente .bc-formulario { display: flex; gap: 8px; padding: 10px 12px; background: var(--bc-fondo); border-top: 1px solid var(--bc-borde); }
#bc-asistente .bc-entrada {
  flex: 1; resize: none; min-height: 38px; max-height: 110px;
  padding: 9px 12px; border: 1px solid var(--bc-borde); border-radius: 10px;
  font: inherit; color: var(--bc-texto); background: var(--bc-fondo);
}
#bc-asistente .bc-entrada:focus { outline: none; border-color: var(--bc-acento); }
#bc-asistente .bc-enviar {
  width: 40px; border: none; border-radius: 10px;
  background: var(--bc-acento); color: #fff; font-size: 16px; cursor: pointer;
}
#bc-asistente .bc-enviar:hover { background: var(--bc-acento-hover); }

/* Ensamble */
#bc-asistente .bc-vacio { color: var(--bc-texto-suave); margin: 4px 0 12px; }
#bc-asistente .bc-resumen { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; border-left: 4px solid; }
#bc-asistente .bc-resumen.bc-ok { background: #eafaf1; border-color: var(--bc-verde); }
#bc-asistente .bc-resumen.bc-aviso { background: #fef5e7; border-color: var(--bc-amarillo); }
#bc-asistente .bc-resumen.bc-error { background: #fdedec; border-color: var(--bc-rojo); }
#bc-asistente .bc-cifras { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 12px; }
#bc-asistente .bc-nota { margin: 6px 0 0; font-size: 12px; }

#bc-asistente .bc-lista { list-style: none; margin: 0; padding: 0; }
#bc-asistente .bc-lista li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--bc-borde);
}
#bc-asistente .bc-cat { flex: 0 0 105px; font-size: 12px; font-weight: bold; color: var(--bc-texto-suave); }
#bc-asistente .bc-cat em { font-weight: normal; }
#bc-asistente .bc-pieza { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#bc-asistente .bc-pieza a, #bc-asistente .bc-sugerencia a {
  color: var(--bc-texto); text-decoration: none; font-weight: bold;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#bc-asistente .bc-pieza a:hover, #bc-asistente .bc-sugerencia a:hover { color: var(--bc-acento); }
#bc-asistente small { color: var(--bc-verde); font-weight: bold; font-size: 12px; }
#bc-asistente .bc-agotado { color: var(--bc-rojo); }
#bc-asistente .bc-pocas { color: var(--bc-amarillo); }
#bc-asistente .bc-elegir { margin-left: auto; color: var(--bc-acento); font-size: 12px; text-decoration: none; font-weight: bold; }
#bc-asistente .bc-quitar, #bc-asistente .bc-mas {
  flex: 0 0 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--bc-borde); background: var(--bc-fondo); cursor: pointer; font-size: 15px; line-height: 1;
}
#bc-asistente .bc-quitar:hover { border-color: var(--bc-rojo); color: var(--bc-rojo); }
#bc-asistente .bc-mas { color: var(--bc-verde); }
#bc-asistente .bc-mas:hover { background: var(--bc-verde); color: #fff; }

#bc-asistente .bc-subtitulo { margin: 16px 0 6px; font-size: 13px; }
#bc-asistente .bc-grupo { margin-bottom: 10px; }
#bc-asistente .bc-sugerencia { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
#bc-asistente .bc-sugerencia a { flex: 1; min-width: 0; font-weight: normal; }

#bc-asistente .bc-botonera { display: flex; gap: 8px; margin-top: 14px; }
#bc-asistente .bc-boton {
  flex: 1; padding: 9px; border: none; border-radius: 8px;
  background: var(--bc-primario); color: #fff; font-weight: bold; cursor: pointer;
}
#bc-asistente .bc-boton:hover { background: var(--bc-primario-hover); }
#bc-asistente .bc-comprar { display: block; width: 100%; margin-top: 8px; background: var(--bc-naranja); }
#bc-asistente .bc-ver3d { display: block; margin-top: 8px; text-align: center; text-decoration: none; background: var(--bc-acento); }
#bc-asistente .bc-ver3d:hover { background: var(--bc-acento-hover); }
#bc-asistente .bc-comprar:hover { background: var(--bc-naranja-hover); }
#bc-asistente .bc-comprar:disabled { background: #d9d5e5; cursor: not-allowed; }
#bc-asistente .bc-boton.bc-secundario { flex: 0 0 auto; background: var(--bc-fondo); color: var(--bc-rojo); border: 1px solid var(--bc-borde); }

@keyframes bc-aparecer { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes bc-punto { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 480px) {
  #bc-asistente { right: 12px; bottom: 12px; }
  #bc-asistente .bc-panel { width: calc(100vw - 24px); height: calc(100vh - 100px); }
}

/* Confirmación y resultado de la compra */
#bc-asistente .bc-confirmar { margin-top: 12px; padding: 12px; border: 2px solid var(--bc-verde); border-radius: 10px; background: #f4fbf7; }
#bc-asistente .bc-confirmar p { margin: 6px 0 10px; font-size: 13px; }
#bc-asistente .bc-confirmar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--bc-texto-suave); }
#bc-asistente .bc-cliente { padding: 8px 10px; border: 1px solid var(--bc-borde); border-radius: 8px; font: inherit; color: var(--bc-texto); }
#bc-asistente .bc-cliente:focus { outline: none; border-color: var(--bc-verde); }
#bc-asistente .bc-confirmar-compra { background: var(--bc-naranja); }
#bc-asistente .bc-confirmar-compra:hover { background: var(--bc-naranja-hover); }
#bc-asistente .bc-confirmar-compra:disabled { background: #d9d5e5; }
#bc-asistente .bc-error-compra { color: var(--bc-rojo); font-weight: bold; }
#bc-asistente .bc-exito { padding: 12px; margin-bottom: 12px; border-radius: 10px; background: #eafaf1; border-left: 4px solid var(--bc-verde); }
#bc-asistente .bc-exito p { margin: 0 0 6px; }
#bc-asistente .bc-exito ul { margin: 4px 0 8px; padding-left: 18px; }
#bc-asistente .bc-exito .bc-boton { width: 100%; margin-top: 6px; }

/* Advertencia al comprar piezas incompatibles (se permite, pero se avisa) */
#bc-asistente .bc-aviso-compra { background: #fff7e6; border: 1px solid #f6dcae; color: #b45309; border-radius: 8px;
                                 padding: 8px 10px; margin: 6px 0 8px; font-size: 13px; }
#bc-asistente .bc-aviso-compra p { margin: 4px 0 0; }
#bc-asistente .bc-burbuja-texto p { margin: 6px 0 0; }
#bc-asistente .bc-burbuja-texto a { color: var(--bc-acento); font-weight: 600; }
