/* ==========================================================================
   Chat / Cotizador
   ========================================================================== */
.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* Overlay de arrastrar y soltar */
.chat.is-dragging::after {
  content: "Suelta tu archivo aquí";
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px dashed var(--c-accent);
  border-radius: inherit;
  background: rgba(248, 249, 250, .92);
  font-weight: 700;
  color: var(--c-accent);
}

.chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
}
.chat__avatar { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.chat__title { font-size: 15px; font-weight: 700; line-height: 1.2; color: var(--c-accent); }
.chat__subtitle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--c-muted); }

/* ---------- Barra de progreso (5 etapas) ---------- */
.progress {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 18px 9px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg-alt);
}
.progress__step {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--c-muted);
}
.progress__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress__bar {
  position: relative;
  height: 3px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--c-border);
}
.progress__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--c-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .4s var(--ease);
}
.progress__step.is-current { color: var(--c-accent); font-weight: 700; }
.progress__step.is-current .progress__bar::after { transform: scaleX(.45); }
.progress__step.is-done { color: var(--c-text); }
.progress__step.is-done .progress__bar::after { transform: scaleX(1); }

/* ---------- Log de mensajes ---------- */
.chat__log {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 360px;
  max-height: min(620px, 68vh);
  max-height: min(620px, 68svh);
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  overscroll-behavior: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 768px) {
  .chat {
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
  }
  .chat__header {
    padding: 10px 14px;
    gap: 10px;
  }
  .chat__avatar {
    width: 34px;
    height: 34px;
  }
  .chat__title {
    font-size: 14.5px;
  }
  .chat__subtitle {
    font-size: 11.5px;
  }
  .progress {
    padding: 7px 12px 6px;
    gap: 4px;
  }
  .progress__label {
    font-size: 10px;
  }
  .chat__log {
    min-height: 190px;
    max-height: 44svh;
    padding: 12px 14px;
    gap: 10px;
    overscroll-behavior-y: auto;
    overscroll-behavior: auto;
  }
  .msg__bubble {
    font-size: 14px;
    padding: 8px 12px;
    line-height: 1.4;
  }
  .chips {
    gap: 8px;
    padding: 2px 0;
  }
  .chip {
    min-height: 38px;
    padding: 7px 14px;
    font-size: 13px;
  }
  .dropzone {
    padding: 14px 12px;
    gap: 2px;
  }
  .dropzone__icon {
    width: 36px;
    height: 36px;
    margin-bottom: 2px;
  }
  .dropzone__icon .icon {
    width: 18px;
    height: 18px;
  }
  .dropzone__title {
    font-size: 14px;
  }
  .dropzone__hint {
    font-size: 11.5px;
  }
}

.chat__noscript { padding: 18px; font-size: 14px; }

.msg {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 90%;
  animation: msg-in .3s var(--ease) both;
}
.chat__log.no-anim .msg,
.chat__log.no-anim .controls { animation: none; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.msg--bot { align-self: flex-start; }
.msg--user { align-self: flex-end; flex-direction: row-reverse; }

.msg__bubble {
  min-width: 0;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.msg--bot .msg__bubble {
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-top-left-radius: 6px;
}
.msg--user .msg__bubble {
  background: var(--c-accent);
  color: #fff;
  font-weight: 500;
  border: 1px solid var(--c-accent);
  border-top-right-radius: 4px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, .18);
  letter-spacing: .01em;
}
.msg--user .msg__bubble strong {
  color: #fff;
  font-weight: 700;
}

.msg__edit {
  flex: none;
  padding: 4px 6px;
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--c-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg__edit:hover { color: var(--c-accent); }
.chat__log.is-locked .msg__edit { display: none; }

/* Archivos dentro de una burbuja */
.msg__files { display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 5px 10px 5px 5px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
}
.file-chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.thumb {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #fff;
  object-fit: cover;
}
.thumb--pdf {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  color: var(--c-accent);
  background: #fff;
  border: 1px solid var(--c-border);
}
.thumb--pdf .icon { width: 18px; height: 18px; }
.thumb--pdf small { font-size: 9px; font-weight: 800; letter-spacing: .04em; line-height: 1; }

.zone-list { margin: 0; padding-left: 18px; }
.zone-list li + li { margin-top: 2px; }

/* Indicador "escribiendo" */
.typing { display: inline-flex; align-items: center; gap: 10px; color: var(--c-muted); font-size: 14px; }
.typing__dots { display: inline-flex; gap: 4px; }
.typing__dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-muted);
  animation: blink 1.2s infinite;
}
.typing__dots i:nth-child(2) { animation-delay: .15s; }
.typing__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- Controles interactivos ---------- */
.controls { padding-top: 2px; animation: msg-in .3s var(--ease) both; }
.controls.is-static { animation: none; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 2px;
}

/* Estado A: Propuestas recién mostradas (Invitación dinámica a decidir) */
.chip {
  position: relative;
  min-height: 42px;
  padding: 9px 18px;
  border: 1.5px solid rgba(15, 23, 42, .22);
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--c-accent);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .05);
  transition: 
    transform .18s var(--ease),
    box-shadow .18s var(--ease),
    background-color .18s var(--ease),
    border-color .18s var(--ease),
    color .18s var(--ease);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Animación sutil de entrada para atraer la atención */
.controls:not(.is-static) .chip {
  animation: chip-pop .32s var(--ease) backwards;
}
.chips .chip:nth-child(1) { animation-delay: .03s; }
.chips .chip:nth-child(2) { animation-delay: .07s; }
.chips .chip:nth-child(3) { animation-delay: .11s; }
.chips .chip:nth-child(4) { animation-delay: .15s; }
.chips .chip:nth-child(5) { animation-delay: .19s; }
.chips .chip:nth-child(6) { animation-delay: .23s; }

@keyframes chip-pop {
  0% { opacity: 0; transform: translateY(8px) scale(.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Estado B: Al interactuar (Hover / Focus / Active) - Sobresale notoriamente */
.chip:hover {
  border-color: var(--c-accent);
  background: #F8FAFC;
  color: var(--c-accent);
  transform: translateY(-2.5px) scale(1.03);
  box-shadow: 0 8px 20px -4px rgba(15, 23, 42, .22), 0 3px 6px -1px rgba(15, 23, 42, .12);
  z-index: 2;
}
.chip:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* Pulsación táctil / Click activo (feedback háptico visual) */
.chip:active {
  transform: translateY(0) scale(.97);
  box-shadow: 0 2px 6px rgba(15, 23, 42, .18);
  background: #F1F5F9;
}

/* Cuando está seleccionado (ej. en matriz interactiva) */
.chip[aria-pressed="true"] {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, .28);
  transform: none;
}
.chip[aria-pressed="true"]:hover {
  background: var(--c-accent-hover);
  border-color: var(--c-accent-hover);
  transform: translateY(-1px);
}

.chip--sm {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
}

.alert {
  margin-bottom: 10px;
  padding: 9px 12px;
  border: 1px solid var(--c-error-border);
  border-radius: 10px;
  background: var(--c-error-bg);
  font-size: 13.5px;
  color: var(--c-error);
}
.alert p + p { margin-top: 4px; }

.field-error { margin-top: 6px; font-size: 13px; color: var(--c-error); }

/* Dropzone */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 22px 16px;
  border: 1.5px dashed var(--c-border-strong);
  border-radius: var(--radius);
  background: var(--c-bg-alt);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--c-accent); background: var(--c-bg-soft); }
.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.dropzone__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--c-accent);
  color: #fff;
}
.dropzone__icon .icon { width: 22px; height: 22px; }
.dropzone__title { font-weight: 700; color: var(--c-accent); }
.dropzone__hint { font-size: 12.5px; color: var(--c-muted); }
.dropzone--compact { flex-direction: row; justify-content: center; gap: 10px; padding: 12px 14px; }
.dropzone--compact .dropzone__icon { width: 32px; height: 32px; margin: 0; }
.dropzone--compact .dropzone__icon .icon { width: 18px; height: 18px; }
.dropzone--compact .dropzone__hint { display: none; }

/* Lista de archivos (diseños adicionales) */
.file-list { display: grid; gap: 8px; margin-bottom: 10px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: #fff;
}
.file-row .thumb { width: 44px; height: 44px; background: var(--c-bg-alt); border: 1px solid var(--c-border); }
.file-row__info { flex: 1; min-width: 0; }
.file-row__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.file-row__meta { font-size: 12px; color: var(--c-muted); }

.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--c-border);
  border-radius: 50%;
  background: #fff;
  color: var(--c-muted);
}
.icon-btn:hover { color: var(--c-error); border-color: var(--c-error-border); background: var(--c-error-bg); }
.icon-btn .icon { width: 16px; height: 16px; }

.controls__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}
.controls__counter { margin-right: auto; font-size: 12.5px; color: var(--c-muted); }

/* Inputs */
.input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--c-border-strong);
  border-radius: 10px;
  background: #fff;
  font-size: 16px; /* evita zoom en iOS */
}
.input:focus { outline: 2px solid var(--c-accent); outline-offset: 0; border-color: transparent; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form .input { flex: 1; min-width: 0; }
.inline-form .btn { flex: none; }

/* Tarjeta interactiva de cantidad exacta */
.qty-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  padding: 16px;
  border: 1.5px solid rgba(15, 23, 42, .18);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, .08);
  animation: chip-pop .32s var(--ease) backwards;
}

.qty-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--c-accent);
  letter-spacing: .01em;
}

.qty-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.qty-input {
  width: 100%;
  min-height: 52px;
  padding: 10px 75px 10px 16px;
  border: 2px solid var(--c-border-strong);
  border-radius: 12px;
  background: var(--c-bg-alt);
  font-size: 22px;
  font-weight: 700;
  color: var(--c-accent);
  letter-spacing: .03em;
  transition: border-color .18s var(--ease), background-color .18s var(--ease), box-shadow .18s var(--ease);
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-input:focus {
  outline: none;
  border-color: var(--c-accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(15, 23, 42, .1);
}

.qty-unit {
  position: absolute;
  right: 18px;
  font-size: 15px;
  font-weight: 700;
  color: var(--c-muted);
  pointer-events: none;
  user-select: none;
}

/* ---------- Matriz de asignación ---------- */
.matrix { display: grid; gap: 10px; }

.zone-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.zone-card.is-complete { border-color: var(--c-accent); box-shadow: var(--shadow-sm); }
.zone-card .thumb {
  width: 64px;
  height: 64px;
  border: 1px solid var(--c-border);
  background: var(--c-bg-alt);
  object-fit: contain;
}
.zone-card__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  margin-bottom: 2px;
}
.zone-card__title { flex: none; font-size: 13px; font-weight: 800; color: var(--c-accent); }
.zone-card__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--c-muted); }
.zone-card__check { margin-left: auto; color: var(--c-accent); }
.zone-card__check .icon { width: 18px; height: 18px; }

.field-label {
  margin: 10px 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.dims { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.dims__field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--c-muted); }
.dims .input { width: 84px; min-height: 38px; }
.dims__x { font-weight: 700; color: var(--c-muted); }

@media (max-width: 480px) {
  .zone-card { grid-template-columns: 1fr; gap: 8px; }
  .zone-card__media { display: flex; align-items: center; gap: 10px; }
  .zone-card .thumb { width: 48px; height: 48px; }
}

/* ---------- Resumen y cierre ---------- */
.summary {
  overflow: hidden;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.summary__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--c-accent);
  color: #fff;
}
.summary__label { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; opacity: .75; }
.summary__folio { font-size: 22px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.summary__list {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0;
  padding: 14px 16px;
  font-size: 14px;
}
.summary__list dt { color: var(--c-muted); }
.summary__list dd { margin: 0; font-weight: 600; }
.summary__actions { display: grid; gap: 8px; padding: 0 16px 16px; }

.btn-wa .icon { color: var(--c-whatsapp); width: 22px; height: 22px; }

.note { font-size: 12.5px; color: var(--c-muted); text-align: center; }

.link-subtle {
  justify-self: center;
  padding: 8px 10px;
  border: 0;
  background: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--c-muted);
}
.link-subtle:hover { color: var(--c-accent); text-decoration: underline; text-underline-offset: 3px; }

/* Honeypot */
.hp {
  position: absolute !important;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
