/* ============================================================
   cotizador.css — Löwex
   El formulario de cotización (ítems 7 y 8). Lo comparten la Home
   (dentro de un <dialog> centrado) y la campaña /importar/ (incrustado
   en la página). Se carga después de tokens.css.

   Referencias de orden y agrupación: FedEx (ruta a ancho completo,
   aviso debajo del campo) y DHL (una fila por tipo de paquete con
   totales en vivo). Colores, botones y tipografía son los de Löwex.
   ============================================================ */

/* --- El modal: centrado sobre fondo oscurecido; en móvil, pantalla completa --- */
html.bloqueado { overflow: hidden; scrollbar-gutter: stable; }

.cz {
  margin: auto;
  padding: 0;
  width: min(54rem, calc(100vw - 2rem));
  max-width: 100vw;
  max-height: min(92dvh, 60rem);
  background: var(--hueso);
  color: var(--texto);
  border: 1px solid var(--linea);
  border-radius: var(--radio-card);
  overflow: hidden;
}
.cz[open] { display: flex; }
.cz::backdrop { background: rgb(0 30 34 / 0.62); }
@media (prefers-reduced-motion: no-preference) {
  .cz[open] { animation: cz-entra 320ms var(--ease-suave); }
  .cz[open]::backdrop { animation: cz-fondo 320ms var(--ease-suave); }
}
@keyframes cz-entra { from { opacity: 0; transform: translateY(1rem) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes cz-fondo { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 640px) {
  .cz {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
}

.cz__panel { display: flex; flex-direction: column; width: 100%; min-width: 0; min-height: 0; }
.cz__cab {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem clamp(1.25rem, 4vw, 2.25rem) 1.1rem;
  border-bottom: 1px solid var(--linea);
}
.cz__cab h2 { font-size: var(--t-h2); margin: 0.45rem 0 0; }
.cz__cerrar {
  flex-shrink: 0;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  padding: 0;
  background: transparent;
  color: var(--petroleo);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  cursor: pointer;
  transition: background-color var(--dur-rapida) var(--ease-suave), border-color var(--dur-rapida) var(--ease-suave);
}
.cz__cerrar:hover { background: var(--lima); border-color: var(--lima); }
.cz__cerrar svg { width: 18px; height: 18px; }
.cz__cuerpo {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.6rem clamp(1.25rem, 4vw, 2.25rem) 2.5rem;
}

/* Incrustado (campaña): la misma caja, sin el modal */
.cz__slot {
  background: #FFFFFF;
  border: 1px solid var(--linea);
  border-radius: var(--radio-card);
  padding: clamp(1.25rem, 3.5vw, 2.5rem);
  min-width: 0;
}
.cz [hidden], .cz__slot [hidden] { display: none !important; }

/* --- Estructura del formulario --- */
.cz__form { display: grid; gap: 1.9rem; min-width: 0; }
.cz__bloque { border: 0; padding: 0; margin: 0; min-width: 0; display: block; }

.cz__leyenda {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0;
  margin-bottom: 1rem;
  font-size: var(--t-h3);
  font-weight: 700;
  letter-spacing: var(--tr-titulo);
  color: var(--petroleo);
}
.cz__n {
  flex-shrink: 0;
  width: 1.75rem; height: 1.75rem;
  display: grid; place-items: center;
  background: var(--petroleo);
  color: var(--lima);
  border-radius: var(--radio-pastilla);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0;
}
.cz__sub {
  margin: 1.1rem 0 0.55rem;
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--texto-suave);
}
.cz__sub { margin-top: 1.5rem; }
.cz__carga > .cz__sub:first-child { margin-top: 0; }

/* --- Botones de opción: verdes con letra amarilla; al elegir se invierten --- */
.cz__opciones { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.cz-op { position: relative; display: block; cursor: pointer; }
.cz-op input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; opacity: 0;
  cursor: pointer;
}
.cz-op__cuerpo {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 6.5rem;
  padding: 0.75rem 1.2rem;
  background: var(--petroleo);
  color: var(--lima);
  border: 1px solid var(--petroleo);
  border-radius: var(--radio);
  text-align: left;
  transition:
    background-color var(--dur-rapida) var(--ease-suave),
    color            var(--dur-rapida) var(--ease-suave),
    border-color     var(--dur-rapida) var(--ease-suave);
}
.cz-op__cuerpo b { font-size: 0.98rem; font-weight: 600; letter-spacing: 0.01em; }
.cz-op__cuerpo small { font-size: 0.74rem; font-weight: 400; opacity: 0.85; }
.cz-op:hover .cz-op__cuerpo { background: var(--petroleo-on); }
.cz-op input:checked + .cz-op__cuerpo {
  background: var(--lima);
  color: var(--petroleo);
  border-color: var(--petroleo);
}
.cz-op input:focus-visible + .cz-op__cuerpo { outline: 2px solid var(--petroleo); outline-offset: 3px; }
.cz__opciones--error .cz-op__cuerpo { border-color: oklch(52% 0.19 27); box-shadow: 0 0 0 1px oklch(52% 0.19 27); }
.cz-op--chica .cz-op__cuerpo { min-width: 0; padding: 0.55rem 1rem; }
.cz-op--chica .cz-op__cuerpo b { font-size: 0.9rem; }

/* --- Rejilla y campos --- */
.cz__rejilla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.cz__rejilla + .cz__sub, .cz__opciones + .cz__sub, .cz__rejilla + .cz__rejilla { margin-top: 1.1rem; }

.campo { display: flex; flex-direction: column; gap: 0.4rem; grid-column: 1 / -1; min-width: 0; position: relative; }
.campo--mitad { grid-column: span 1; }
.campo > label, .campo__rotulo {
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--texto-suave);
}
.campo--req > label::after { content: " *"; }
.campo__opc { text-transform: none; letter-spacing: 0; font-weight: 400; }

.campo input[type="text"],
.campo input[type="email"],
.campo input[type="tel"],
.campo input[type="date"],
.campo input[type="number"],
.campo select,
.campo textarea,
.cz__celda input {
  font-family: var(--f-texto);
  font-size: 1rem;
  color: var(--texto);
  background: #FFFFFF;
  border: 1px solid #CFCCC4;
  border-radius: var(--radio);
  padding: 0.7rem 0.85rem;
  /* Sin esto el input no baja de su ancho intrínseco (20 caracteres) y
     estira la grilla entera: en pantallas angostas desborda la página. */
  width: 100%;
  min-width: 0;
  transition: border-color var(--dur-rapida) var(--ease-suave), box-shadow var(--dur-rapida) var(--ease-suave);
}
.campo textarea { resize: vertical; min-height: 4.5rem; }
.cz__celda select {
  font-family: var(--f-texto);
  font-size: 1rem;
  color: var(--texto);
  appearance: none;
  cursor: pointer;
  width: 100%;
  min-width: 0;
  border: 1px solid #CFCCC4;
  border-radius: var(--radio);
  padding: 0.7rem 2.2rem 0.7rem 0.85rem;
  background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300424A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.7rem center / 1rem;
}
.cz__celda select:focus { outline: 0; border-color: var(--petroleo); box-shadow: 0 0 0 1px var(--petroleo); }
.cz__celda--revisar select { background-color: #FBFDE3; border-color: oklch(70% 0.14 105); }
.campo select {
  appearance: none;
  cursor: pointer;
  padding-right: 2.2rem;
  background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300424A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.7rem center / 1rem;
}
.campo input:hover, .campo select:hover, .campo textarea:hover, .cz__celda input:hover { border-color: var(--petroleo); }
.campo input:focus, .campo select:focus, .campo textarea:focus, .cz__celda input:focus {
  outline: 0;
  border-color: var(--petroleo);
  box-shadow: 0 0 0 1px var(--petroleo);
}
.campo input::placeholder, .campo textarea::placeholder, .cz__celda input::placeholder { color: rgb(15 27 29 / 0.45); }
.campo--error input, .campo--error select, .campo--error textarea { border-color: oklch(52% 0.19 27); box-shadow: 0 0 0 1px oklch(52% 0.19 27); }

/* Aviso informativo debajo del campo (como el de "Entrega final" de FedEx) */
.campo__aviso { margin: 0.1rem 0 0; font-size: 0.8rem; line-height: 1.45; color: var(--texto-suave); max-width: none; }
.campo__aviso--ok { color: var(--petroleo); font-weight: 600; }
.campo__aviso--ok::before { content: ""; display: inline-block; width: 0.55rem; height: 0.55rem; margin-right: 0.45rem; border-radius: 50%; background: var(--menta); border: 1px solid var(--petroleo); }
.campo__error { margin: 0.1rem 0 0; font-size: 0.8rem; color: oklch(48% 0.19 27); max-width: none; }

/* --- Sugerencias de Google Places --- */
.cz__sug {
  position: absolute;
  top: calc(100% - 0.2rem); left: 0; right: 0;
  z-index: 30;
  margin: 0; padding: 0.3rem;
  list-style: none;
  background: #FFFFFF;
  border: 1px solid var(--linea);
  border-radius: var(--radio);
}
.cz__sug-item { padding: 0.6rem 0.7rem; font-size: var(--t-small); cursor: pointer; border-radius: 8px; }
.cz__sug-item:hover, .cz__sug-item.sel { background: var(--lima); }
.cz__sug-pie { padding: 0.35rem 0.7rem; font-size: 0.65rem; text-align: right; color: var(--texto-suave); }

/* --- Contenedor (FCL) --- */
.cz__contenedor { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem 1.1rem; }

/* --- Paquetes: una fila por tipo de paquete --- */
.cz__filas { display: grid; gap: 0.75rem; }
.cz__fila {
  display: grid;
  grid-template-columns: minmax(7.5rem, 1.2fr) repeat(5, minmax(0, 1fr)) 2.75rem;
  gap: 0.6rem;
  align-items: end;
  padding: 0.85rem;
  background: #FFFFFF;
  border: 1px solid var(--linea);
  border-radius: var(--radio);
}
.cz__fila--courier { grid-template-columns: repeat(5, minmax(0, 1fr)) 2.75rem; }
.cz__celda { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; position: relative; }
.cz__celda > span {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--texto-suave);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* La unidad va dentro del campo */
.cz__unidad { position: relative; }
.cz__unidad input { padding-right: 2.4rem; }
.cz__unidad::after {
  content: attr(data-u);
  position: absolute;
  right: 0.8rem; top: 50%;
  transform: translateY(-50%);
  font-size: 0.78rem;
  color: var(--texto-suave);
  pointer-events: none;
}
.cz__quitar {
  width: 2.75rem; height: 2.75rem;
  display: grid; place-items: center;
  padding: 0;
  background: transparent;
  color: var(--texto-suave);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  cursor: pointer;
  transition: background-color var(--dur-rapida) var(--ease-suave), color var(--dur-rapida) var(--ease-suave);
}
.cz__quitar:hover { background: oklch(94% 0.04 27); color: oklch(45% 0.19 27); }
.cz__quitar:disabled { opacity: 0.3; cursor: default; pointer-events: none; }
.cz__quitar svg { width: 16px; height: 16px; }

/* Dato leído de un Packing List: marcado hasta que el cliente lo revisa */
.cz__celda--revisar input { background: #FBFDE3; border-color: oklch(70% 0.14 105); box-shadow: 0 0 0 1px oklch(70% 0.14 105); }
.cz__celda--revisar > span::after { content: " · revisar"; color: oklch(45% 0.1 105); text-transform: none; letter-spacing: 0; }

.cz__agregar { margin-top: 0.75rem; }

.cz__totales {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.9rem;
  padding: 0.8rem 1rem;
  background: var(--petroleo);
  color: var(--texto-inv);
  border-radius: var(--radio);
  font-size: var(--t-small);
}
.cz__totales b { color: var(--lima); font-weight: 600; margin-left: 0.25rem; }
.cz__totales span { white-space: nowrap; }

/* --- Opciones por carga --- */
.cz__checks { display: flex; flex-wrap: wrap; gap: 0.6rem 1.6rem; margin-top: 1.1rem; }
.cz__check { display: inline-flex; align-items: center; gap: 0.6rem; font-size: var(--t-small); font-weight: 600; cursor: pointer; }
.cz__check input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--petroleo); cursor: pointer; }

/* --- Packing List --- */
.cz__pl { margin-top: 1.4rem; padding: 1rem 1.1rem; border: 1px dashed #CFCCC4; border-radius: var(--radio); background: #FFFFFF; }
.cz__pl-t { margin: 0; font-weight: 600; font-size: var(--t-small); max-width: none; }
.cz__pl-a { margin: 0.2rem 0 0.8rem; font-size: 0.8rem; line-height: 1.5; color: var(--texto-suave); max-width: none; }
.cz__pl-btn { position: relative; overflow: hidden; }
.cz__pl-in { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.cz__pl-btn:focus-within { outline: 2px solid var(--petroleo); outline-offset: 2px; }
.cz__pl-arch { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.8rem; font-size: var(--t-small); }
.cz__pl-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cz__pl-arch small { color: var(--texto-suave); flex-shrink: 0; }
.cz__pl-msg { margin: 0.7rem 0 0; font-size: 0.8rem; line-height: 1.5; color: var(--petroleo); max-width: none; }
.cz__pl-error { margin: 0.7rem 0 0; font-size: 0.8rem; color: oklch(48% 0.19 27); max-width: none; }

/* --- Botones del formulario (los generales viven en lowex.css y no se cargan en la campaña) --- */
.cz-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--btn-alto);
  padding: 0 var(--btn-px);
  border: 1px solid transparent;
  border-radius: var(--radio);
  font-family: var(--f-texto);
  font-size: var(--btn-fs);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur-rapida) var(--ease-suave), border-color var(--dur-rapida) var(--ease-suave), transform var(--dur-rapida) var(--ease-suave);
}
.cz-btn:active { transform: translateY(1px); }
.cz-btn:disabled { opacity: 0.6; cursor: default; }
.cz-btn--acento { background: var(--lima); color: var(--petroleo); border-color: var(--lima); }
.cz-btn--acento:hover:not(:disabled) { background: var(--lima-on); border-color: var(--lima-on); }
.cz-btn--linea { background: transparent; color: var(--petroleo); border-color: var(--linea-fuerte); }
.cz-btn--linea:hover { border-color: var(--petroleo); background: rgb(0 66 74 / 0.05); }
.cz-btn--chico { /* mismo tamaño que el resto */ }

/* --- Contacto, señuelo, errores, pie --- */
.cz__senuelo { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cz__error { margin: 0; font-size: var(--t-small); font-weight: 600; color: oklch(48% 0.19 27); max-width: none; }
.cz__fallo { justify-self: start; }
.cz__pie { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.cz__nota { margin: 0; font-size: var(--t-label); line-height: 1.6; color: var(--texto-suave); max-width: none; }
.cz__pista { margin: 0; padding: 1rem 1.1rem; border: 1px dashed #CFCCC4; border-radius: var(--radio); font-size: var(--t-small); color: var(--texto-suave); max-width: none; }

/* --- Pantalla de revisión (sólo lectura) --- */
.cz__rev { display: grid; gap: 1.4rem; }
.cz__rev h3 { font-size: var(--t-h2); }
.cz__rev-aviso { margin: 0; font-size: var(--t-small); color: var(--texto-suave); max-width: none; }
.cz__rev-grupo { background: #FFFFFF; border: 1px solid var(--linea); border-radius: var(--radio); padding: 0.4rem 1.1rem; }
.cz__rev-fila { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr; gap: 0.3rem 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--linea); font-size: var(--t-small); }
.cz__rev-fila:last-child { border-bottom: 0; }
.cz__rev-fila dt { font-size: var(--t-label); font-weight: 600; letter-spacing: var(--tr-label); text-transform: uppercase; color: var(--texto-suave); padding-top: 0.15rem; }
.cz__rev-fila dd { margin: 0; overflow-wrap: anywhere; }
.cz__rev-fila dd div + div { margin-top: 0.15rem; }
@media (max-width: 560px) { .cz__rev-fila { grid-template-columns: 1fr; } }

/* --- Confirmación --- */
.cz__listo { display: grid; gap: 1.1rem; padding-block: 1rem; }
.cz__listo-t { margin: 0; font-size: var(--t-h1); font-weight: 700; letter-spacing: var(--tr-titulo); line-height: 1.1; color: var(--petroleo); max-width: none; }
.cz__listo-p { margin: 0; color: var(--texto-suave); max-width: 52ch; }
.cz__listo-ref {
  margin: 0;
  padding: 0.7rem 1rem;
  background: var(--petroleo);
  color: var(--lima);
  border-radius: var(--radio);
  font-weight: 600;
  letter-spacing: 0.04em;
  justify-self: start;
}

/* --- Responsive --- */
@media (max-width: 760px) {
  .cz__fila { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cz__fila .cz__celda--emb { grid-column: 1 / 4; }
  .cz__fila .cz__celda--cant { grid-column: 4 / 7; }
  .cz__fila .cz__celda--peso { grid-column: 1 / 7; }
  .cz__fila .cz__celda--l { grid-column: 1 / 3; }
  .cz__fila .cz__celda--a { grid-column: 3 / 5; }
  .cz__fila .cz__celda--h { grid-column: 5 / 7; }
  .cz__fila .cz__quitar { grid-column: 1 / -1; width: 100%; height: 2.5rem; }
  .cz__fila--courier .cz__celda--cant { grid-column: 1 / 4; }
  .cz__fila--courier .cz__celda--peso { grid-column: 4 / 7; }
  .cz__unidad input { padding-right: 2.2rem; padding-left: 0.7rem; }
}
@media (max-width: 560px) {
  .cz__rejilla { grid-template-columns: 1fr; }
  .campo--mitad { grid-column: 1 / -1; }
  .cz__contenedor { grid-template-columns: 1fr; }
  .cz__pie .cz-btn { width: 100%; white-space: normal; }
  .cz-op__cuerpo { min-width: 0; }
  .cz__opciones { gap: 0.5rem; }
  .cz__opciones .cz-op { flex: 1 1 calc(50% - 0.5rem); }
  .cz__opciones .cz-op--chica { flex: 0 1 auto; }
}

/* Diálogo de postulación (CV): más angosto que el de cotización */
.cz--cv { width: min(38rem, calc(100vw - 2rem)); }
@media (max-width: 640px) { .cz--cv { width: 100vw; } }
.cz--cv .cz__form { gap: 1.4rem; }
