/* ============================================================
   ASESOR IA — el chat (ui/asesor-ia.js)
   ============================================================
   Panel acoplado abajo a la derecha en escritorio y hoja completa en móvil.
   Usa los tokens de styles.css: mismo tema claro, mismos grises, mismo azul.
   ============================================================ */

.aia-dock {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: min(620px, calc(100vh - 120px));
  display: none;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 50px -12px rgba(15, 23, 42, .28);
  z-index: var(--z-drawer);
  overflow: hidden;
}

.aia-dock.on { display: flex; }

/* ── Cabecera ── */
.aia-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.aia-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--gray-900);
}

.aia-hdr-acts { display: flex; align-items: center; gap: 6px; }

.aia-hbtn {
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.aia-hbtn:hover { color: var(--gray-900); border-color: var(--gray-300); }

.aia-x {
  border: none;
  background: none;
  color: var(--gray-500);
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

.aia-x:hover { color: var(--gray-900); }

/* ── Conversación ── */
.aia-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: #fff;
}

.aia-hint {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--gray-500);
  background: var(--gray-50);
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.aia-msg {
  max-width: 88%;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 9px 12px;
  border-radius: var(--radius);
  word-break: break-word;
}

.aia-yo {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: var(--radius-xs);
}

.aia-ia {
  align-self: flex-start;
  background: var(--gray-50);
  color: var(--gray-900);
  border: 1px solid var(--gray-200);
  border-bottom-left-radius: var(--radius-xs);
}

/* Lo que el modelo está haciendo: presente pero sin robar atención. */
.aia-paso {
  align-self: flex-start;
  font-size: 11px;
  color: var(--gray-500);
  padding-left: 2px;
}

.aia-aviso {
  align-self: center;
  font-size: 11px;
  color: var(--gray-600);
  background: var(--accent-lt);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  text-align: center;
}

/* ── Tarjetas de producto (las pinta la app, no el modelo) ── */
.aia-cards { display: flex; flex-direction: column; gap: 6px; }

.aia-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
}

.aia-card-txt { min-width: 0; }

.aia-card-nom {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.35;
}

.aia-card-meta { font-size: 10.5px; color: var(--gray-500); margin-top: 2px; }

.aia-card-der { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }

.aia-card-precio {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gray-900);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.aia-card-add {
  border: none;
  background: var(--gray-900);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.aia-card-add:hover { opacity: .85; }

.aia-cards-mas { font-size: 10.5px; color: var(--gray-500); padding-left: 2px; }

/* ── Espera ── */
.aia-pensando { align-self: flex-start; display: flex; gap: 4px; padding: 6px 2px; }

.aia-pensando span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gray-300);
  animation: aiaLatir 1.2s infinite ease-in-out;
}

.aia-pensando span:nth-child(2) { animation-delay: .15s; }
.aia-pensando span:nth-child(3) { animation-delay: .3s; }

@keyframes aiaLatir {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .aia-pensando span { animation: none; }
}

/* ── Pie ── */
.aia-foot {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.aia-foot textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.45;
  max-height: 120px;
  background: #fff;
  color: var(--gray-900);
}

.aia-foot textarea:focus { outline: none; border-color: var(--accent); }

.aia-foot textarea:disabled { background: var(--gray-50); color: var(--gray-500); }

.aia-send {
  border: none;
  background: var(--gray-900);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}

.aia-send:hover { opacity: .88; }

/* ── Móvil: hoja completa ── */
@media (max-width: 768px) {
  .aia-dock {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 88vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
}
