/* ── Asesor de Ventas IA – Freeze Foods ── */

#asesor-bubble {
  position: fixed;
  bottom: 130px;
  left: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}

/* ── Botón flotante ── */
#asesor-toggle {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b1a 0%, #ff9a00 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(255, 107, 26, 0.45);
  pointer-events: all;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  flex-shrink: 0;
}

#asesor-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(255, 107, 26, 0.6);
}

#asesor-toggle svg {
  width: 28px;
  height: 28px;
  color: #fff;
  transition: opacity 0.15s;
}

#asesor-toggle .icon-chat { display: flex; align-items: center; justify-content: center; }
#asesor-toggle .icon-chat img { width: 46px; height: 46px; object-fit: contain; }
#asesor-toggle .icon-close { display: none; }
#asesor-toggle.abierto .icon-chat { display: none; }
#asesor-toggle.abierto .icon-close { display: flex; }

/* Pulso de notificación */
#asesor-toggle::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(255, 107, 26, 0.35);
  animation: asesorPulse 2s ease-out infinite;
  opacity: 0;
}

#asesor-toggle.pulsando::before {
  opacity: 1;
}

@keyframes asesorPulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ── Aparición inicial ── */
#asesor-toggle.asesor-oculto {
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
}

@keyframes asesorPopIn {
  0%   { transform: scale(0) rotate(-8deg); opacity: 0; }
  55%  { transform: scale(1.22) rotate(5deg);  opacity: 1; }
  78%  { transform: scale(0.91) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

#asesor-toggle.asesor-visible {
  animation: asesorPopIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: all;
}

/* Badge de notificación */
#asesor-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #ff3b3b;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}

#asesor-badge.visible { display: block; }

/* ── Panel de chat ── */
#asesor-panel {
  width: min(340px, calc(100vw - 60px));
  max-height: 520px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: all;
  transform: scale(0.85) translateY(20px);
  transform-origin: bottom left;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), opacity 0.2s ease, visibility 0s 0.25s;
  pointer-events: none;
}

#asesor-panel.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), opacity 0.2s ease, visibility 0s 0s;
  pointer-events: all;
}

/* Header */
#asesor-header {
  background: linear-gradient(135deg, #ff6b1a 0%, #ff9a00 100%);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.asesor-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
}

.asesor-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.asesor-info h4 {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.asesor-info span {
  color: rgba(255,255,255,0.85);
  font-size: 0.75rem;
}

.asesor-status {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

/* Mensajes */
#asesor-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#asesor-mensajes::-webkit-scrollbar { width: 4px; }
#asesor-mensajes::-webkit-scrollbar-track { background: transparent; }
#asesor-mensajes::-webkit-scrollbar-thumb { background: #e5e5e5; border-radius: 4px; }

.msg-burbuja {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.45;
  word-break: break-word;
  animation: msgEntrada 0.2s ease;
}

@keyframes msgEntrada {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-burbuja.agente {
  background: #f4f4f5;
  color: #18181b;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  white-space: pre-line;
}

.msg-burbuja.usuario {
  background: linear-gradient(135deg, #ff6b1a 0%, #ff9a00 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Typing indicator */
.msg-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: #f4f4f5;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
}

.msg-typing span {
  width: 7px;
  height: 7px;
  background: #a1a1aa;
  border-radius: 50%;
  display: block;
  animation: typingDot 1.2s infinite;
}
.msg-typing span:nth-child(2) { animation-delay: 0.2s; }
.msg-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* Chips de respuesta rápida */
#asesor-chips {
  padding: 6px 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.chip-respuesta {
  background: #fff7ed;
  border: 1.5px solid #ff9a00;
  color: #ff6b1a;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.chip-respuesta:hover {
  background: #ff6b1a;
  color: #fff;
  transform: scale(1.03);
}

/* Input */
#asesor-footer {
  padding: 10px 14px 14px;
  border-top: 1px solid #f4f4f5;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

#asesor-input {
  flex: 1;
  border: 1.5px solid #e5e5e5;
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 0.875rem;
  outline: none;
  resize: none;
  transition: border-color 0.15s;
  font-family: inherit;
  line-height: 1.4;
  max-height: 80px;
  overflow-y: auto;
}

#asesor-input:focus { border-color: #ff6b1a; }
#asesor-input::placeholder { color: #a1a1aa; }

#asesor-attach {
  width: 36px;
  height: 36px;
  background: #f4f4f5;
  border: 1.5px solid #e5e5e5;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background 0.15s;
}
#asesor-attach:hover { background: #e0edff; border-color: #184080; }

#asesor-send {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #ff6b1a, #ff9a00);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: transform 0.15s, opacity 0.15s;
}

#asesor-send:hover { transform: scale(1.08); }
#asesor-send:disabled { opacity: 0.5; cursor: default; }
#asesor-send svg { color: #fff; width: 18px; height: 18px; }

/* ── Burbuja de entrada (saludo proactivo) ── */
#asesor-callout {
  position: absolute;
  bottom: 74px;
  left: 0;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  padding: 12px 16px;
  max-width: 240px;
  font-size: 0.83rem;
  color: #18181b;
  line-height: 1.4;
  pointer-events: all;
  cursor: pointer;
  animation: calloutEntrada 0.35s cubic-bezier(.34,1.56,.64,1);
  z-index: 1;
}

#asesor-callout::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 22px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #fff;
}

/* El panel se abre hacia arriba desde el botón */
#asesor-panel {
  order: -1;
}

@keyframes calloutEntrada {
  from { opacity: 0; transform: scale(0.8) translateY(10px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

#asesor-callout-close {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 14px;
  color: #a1a1aa;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}

/* ── Tarjeta de plan ── */
.plan-card-chat {
  background: #fff;
  border: 1.5px solid #ffe4cc;
  border-radius: 14px;
  overflow: hidden;
  margin: 4px 0;
  font-size: 0.82rem;
  animation: msgEntrada 0.2s ease;
  align-self: flex-start;
  width: 100%;
}

.pcc-header {
  background: linear-gradient(135deg, #ff6b1a, #ff9a00);
  color: #fff;
  font-weight: 700;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.pcc-info {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  background: #fff7ed;
  flex-wrap: wrap;
}

.pcc-info span {
  font-size: 0.75rem;
  color: #7c3500;
  font-weight: 600;
}

.pcc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.pcc-table thead tr {
  background: #f4f4f5;
}

.pcc-table th {
  padding: 5px 8px;
  text-align: left;
  font-weight: 600;
  color: #52525b;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.pcc-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #f4f4f5;
  color: #27272a;
}

.pcc-table .tc { text-align: center; }
.pcc-table .tr { text-align: right; font-weight: 600; color: #ff6b1a; }

.pcc-subtotal,
.pcc-descuento,
.pcc-total {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 0.82rem;
}

.pcc-subtotal { color: #52525b; border-top: 1px solid #f4f4f5; }
.pcc-descuento { color: #16a34a; font-size: 0.78rem; }
.pcc-total {
  background: #fff7ed;
  font-weight: 700;
  font-size: 0.88rem;
  color: #ff6b1a;
}

.pcc-acciones {
  display: flex;
  gap: 6px;
  padding: 8px 12px 10px;
}

.pcc-btn-si,
.pcc-btn-no,
.pcc-btn-carrito {
  flex: 1;
  padding: 7px 4px;
  border: none;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
}

.pcc-btn-si      { background: #ff6b1a; color: #fff; }
.pcc-btn-no      { background: #f4f4f5; color: #52525b; }
.pcc-btn-carrito { background: #16a34a; color: #fff; flex: unset; width: 100%; }

.pcc-btn-si:hover,
.pcc-btn-no:hover,
.pcc-btn-carrito:hover { opacity: 0.88; transform: scale(1.02); }

.pcc-aprobado {
  font-size: 0.8rem;
  color: #16a34a;
  font-weight: 600;
  padding: 4px 0;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  #asesor-bubble { left: 14px; bottom: 170px; }
}
