/* Cotizador rápido v4 — barra horizontal bajo el hero (escritorio), barra compacta al
   bajar y panel inferior en celular. Usa las variables de css/estilo.css */
.seccion-cotizador { padding: 14px 0; scroll-margin-top: 90px; }
.cotizador-rapido {
  background: var(--blanco, #fff);
  border: 1px solid var(--borde, #e3e5ee);
  border-radius: var(--radio, 14px);
  box-shadow: var(--sombra, 0 4px 16px rgba(20, 20, 60, .10));
  padding: 16px 20px 12px;
  margin: 0 auto;
}
.cr-titulo-oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cr-panel-cab, .cr-lanzador, .cr-fondo { display: none; }

.cr-fila {
  display: grid; gap: 14px; align-items: end;
  grid-template-columns: 170px minmax(0, 1.2fr) minmax(0, 1.1fr) 150px minmax(170px, 1fr) 200px;
}
.cr-f-prod { grid-column: 1 / -1; display: none; }
.cotizador-rapido:not(.cr-con-preset) .cr-f-prod, .cr-f-prod.cr-abierto { display: block; }
.cr-campo { margin: 0; min-width: 0; }
.cr-campo label, .cr-label { display: block; font-weight: 600; color: var(--texto-suave, #5a5a66); margin-bottom: 4px; font-size: .8rem; }
.cr-campo select, .cr-campo input[type="text"] {
  width: 100%; min-height: 46px; padding: 0 12px; font: inherit; font-weight: 600; border: 1.5px solid #c9cde0;
  border-radius: 8px; background: #fff; color: var(--texto, #2b2b33); box-sizing: border-box;
}
.cr-campo select:disabled { background: var(--gris-fondo, #f6f7fa); color: var(--texto-suave, #5a5a66); }
.cr-campo select:focus, .cr-campo input:focus, .cr-link:focus-visible { outline: 2px solid var(--azul, #2e2ea8); outline-offset: 1px; }
.cr-chips { display: none; }
.cr-nota { color: var(--texto-suave, #5a5a66); font-size: .8rem; margin: 4px 0 0; }
.cr-nota:empty { display: none; }

.cr-stepper { display: flex; align-items: center; justify-content: space-between; border: 1.5px solid #c9cde0; border-radius: 8px; overflow: hidden; background: #fff; min-height: 46px; box-sizing: border-box; }
.cr-stepper button { width: 46px; height: 44px; font-size: 1.4rem; border: 0; background: none; color: var(--azul, #2e2ea8); cursor: pointer; }
.cr-stepper button:hover { background: var(--azul-claro, #eef0fb); }
.cr-stepper span { text-align: center; font-weight: 700; font-size: 1.1rem; }

.cr-f-total { min-width: 0; }
.cr-total-rotulo { display: block; font-size: .8rem; font-weight: 600; color: var(--texto-suave, #5a5a66); }
.cr-total-num { display: block; font-size: 1.75rem; font-weight: 800; color: var(--azul-oscuro, #23237e); line-height: 1.1; letter-spacing: -.02em; }
.cr-mas-iva { font-size: .9rem; font-weight: 600; color: var(--texto-suave, #5a5a66); letter-spacing: 0; }
.cr-total-sub { display: block; font-size: .8rem; color: var(--texto-suave, #5a5a66); }
.cr-total-vacio { display: flex; flex-direction: column; gap: 2px; color: var(--texto-suave, #5a5a66); font-size: .85rem; }
.cr-total-vacio strong { color: var(--azul-oscuro, #23237e); font-size: 1rem; }

.cr-btn { width: 100%; justify-content: center; text-align: center; cursor: pointer; border: 0; font: inherit; font-weight: 700; padding: 13px 16px; border-radius: 10px; min-height: 52px; box-sizing: border-box; }
.cr-btn.btn-wsp { background: var(--verde-wsp, #25d366); color: #06341b; }
.cr-btn--azul { background: var(--azul-oscuro, #23237e); color: #fff; }

.cr-pie { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--borde, #e3e5ee); font-size: .85rem; color: var(--texto-suave, #5a5a66); }
.cr-pie-izq, .cr-pie-der { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; }
.cr-pie a, .cr-link { color: var(--azul, #2e2ea8); font-weight: 600; text-decoration: underline; }
.cr-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; cursor: pointer; }
.cr-iva { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--texto, #2b2b33); }
.cr-iva input { width: 18px; height: 18px; accent-color: var(--azul, #2e2ea8); }
.cr-dir-det summary { cursor: pointer; color: var(--azul, #2e2ea8); font-weight: 600; }
.cr-dir-det summary small { font-weight: 400; color: var(--texto-suave, #5a5a66); }
.cr-dir-det input { margin-top: 6px; min-width: 260px; }
.cr-aviso { margin: 8px 0 0; font-size: .85rem; color: var(--texto-suave, #5a5a66); }
.cr-aviso:empty { display: none; }
.cr-toast { display: none; margin: 8px 0 0; padding: 8px 10px; background: #e8f7ee; color: #0e5a2a; border-radius: 8px; font-size: .88rem; }
.cr-toast.visible { display: block; }

/* Barra compacta: aparece bajo el encabezado cuando el cotizador queda arriba */
.cr-compacta { display: none; position: fixed; left: 0; right: 0; top: var(--cr-top, 66px); z-index: 80; background: #fff; border-bottom: 1px solid var(--borde, #e3e5ee); box-shadow: 0 6px 18px rgba(20, 20, 60, .12); padding: 8px 0; }
body.cr-fuera .cr-compacta { display: block; }
.cr-comp-int { display: flex; align-items: center; gap: 18px; }
.cr-comp-det { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; color: var(--texto, #2b2b33); }
.cr-comp-total { font-size: 1.35rem; font-weight: 800; color: var(--azul-oscuro, #23237e); white-space: nowrap; }
.cr-comp-total small { font-size: .75rem; font-weight: 600; color: var(--texto-suave, #5a5a66); }
.cr-btn--comp { width: auto; min-height: 44px; padding: 10px 20px; }



/* Selector de formato (Camionada / Al detalle) */
.cr-seg { display: flex; background: var(--azul-claro, #eef0fb); border-radius: 10px; padding: 3px; min-height: 46px; box-sizing: border-box; }
.cr-seg button { flex: 1; border: 0; background: none; border-radius: 8px; font: inherit; font-size: .85rem; font-weight: 600; color: var(--texto, #2b2b33); cursor: pointer; padding: 0 6px; }
.cr-seg button.cr-seg--sel { background: var(--azul-oscuro, #23237e); color: #fff; }
.cr-seg button:disabled { opacity: .45; cursor: not-allowed; }
.cr-seg button:focus-visible { outline: 2px solid var(--azul, #2e2ea8); outline-offset: 2px; }
.cr-modo-detalle .cr-f-camion, .cr-modo-mas22 .cr-f-camion, .cr-modo-mas22 .cr-f-cant { display: none; }
.cr-modo-detalle .cr-fila, .cr-modo-mas22 .cr-fila { grid-template-columns: 170px minmax(0, 1.2fr) 150px minmax(0, 1.5fr) 200px; }
.cr-stepper span { min-width: 72px; }

/* Despacho en venta al detalle */
.cr-pill { display: inline-block; margin-top: 6px; padding: 4px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; line-height: 1.3; }
.cr-pill--pend { background: #fff4e0; color: #8a5a00; }
.cr-pill--ok { background: #eafaf0; color: #146c33; }
.cr-sugerencia { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 14px; background: #eafaf0; border: 1px solid #bfe8cd; border-radius: 10px; color: #0e5a2a; font-size: .9rem; }
.cr-sugerencia[hidden], .cr-dir-fila[hidden] { display: none; }
.cr-btn-sug { background: #fff; border: 1.5px solid #15803d; color: #15803d; font: inherit; font-weight: 700; border-radius: 8px; padding: 8px 12px; cursor: pointer; white-space: nowrap; }
.cr-dir-fila { margin-top: 12px; }
.cr-dir-fila label { display: block; font-weight: 600; color: var(--texto-suave, #5a5a66); margin-bottom: 4px; font-size: .8rem; }
.cr-dir-fila label small { font-weight: 400; }
.cr-dir-fila input { width: 100%; min-height: 46px; padding: 0 12px; font: inherit; border: 1.5px solid var(--azul, #2e2ea8); border-radius: 8px; box-sizing: border-box; }

/* Tablet */
@media (max-width: 1060px) and (min-width: 761px) {
  .cr-fila { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 150px; }
  .cr-f-total { grid-column: span 2; }
  .cr-modo-detalle .cr-fila, .cr-modo-mas22 .cr-fila { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 150px; }
  .cr-f-modo { grid-column: 1 / -1; }
  .cr-f-modo .cr-seg { grid-template-columns: repeat(4, 1fr); }
  .cr-f-total { grid-column: 1 / -1; }
  .cr-f-accion { grid-column: 1 / -1; display: flex; gap: 8px; }
  .cr-f-accion .cr-btn { flex: 1; width: auto; }
  .cr-f-prod { grid-column: 1 / -1; }
  .cr-f-comuna { grid-column: 1 / -1; }
  .cr-modo-detalle .cr-f-comuna { grid-column: 1 / 3; }
  .cr-f-camion { grid-column: 1 / 3; }
}

/* Celular: un solo botón fijo abajo; el cotizador es un panel que se abre desde ahí */
@media (max-width: 760px) {
  body.cr-presente { padding-bottom: 76px; }
  body.cr-presente .barra-movil, body.cr-presente .wsp-flotante, body.cr-presente .carrito-flotante { display: none !important; }
  .seccion-cotizador { padding: 0; min-height: 0; }
  .cr-compacta { display: none !important; }
  .cr-lanzador { display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; background: #fff; border-top: 1px solid var(--borde, #e3e5ee); box-shadow: 0 -8px 24px rgba(20, 20, 60, .14); padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .cr-lanzador-btn { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--azul-oscuro, #23237e); color: #fff; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; text-align: left; }
  .cr-lanzador-carro { min-width: 56px; min-height: 52px; border: 1.5px solid var(--azul, #2e2ea8); border-radius: 12px; background: #fff; color: var(--azul-oscuro, #23237e); font: inherit; font-weight: 700; cursor: pointer; }
  .cr-fondo { position: fixed; inset: 0; background: rgba(15, 15, 45, .55); z-index: 1001; }
  body.cr-abierto .cr-fondo { display: block; }
  body.cr-abierto { overflow: hidden; }
  .cotizador-rapido { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1002; max-height: 92vh; max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px)); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; border-radius: 18px 18px 0 0; border: 0; margin: 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
  body.cr-abierto .cotizador-rapido { transform: none; visibility: visible; transition: transform .25s ease, visibility 0s; }
  .cr-panel-cab { display: flex; justify-content: space-between; align-items: center; color: var(--azul-oscuro, #23237e); font-size: 1.1rem; position: -webkit-sticky; position: sticky; top: -8px; z-index: 5; background: #fff; margin: -8px -16px 4px; padding: 8px 8px 4px 16px; border-radius: 18px 18px 0 0; }
  .cr-cerrar { flex: 0 0 auto; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--azul-claro, #eef0fb); font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--texto, #2b2b33); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .cr-fila, .cr-modo-detalle .cr-fila, .cr-modo-mas22 .cr-fila { grid-template-columns: 1fr; gap: 12px; }
  .cr-sugerencia { flex-direction: column; align-items: stretch; }
  .cr-btn-sug { min-height: 44px; }
  .cr-f-camion select { display: none; }
  .cr-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .cr-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 48px; padding: 4px; cursor: pointer; font: inherit; background: #fff; color: var(--texto, #2b2b33); border: 1.5px solid #d5d8e6; border-radius: 8px; }
  .cr-chip strong { font-size: 1rem; }
  .cr-chip small { color: var(--texto-suave, #5a5a66); font-size: .72rem; }
  .cr-chip--sel { background: var(--azul-oscuro, #23237e); border-color: var(--azul-oscuro, #23237e); color: #fff; }
  .cr-chip--sel small { color: rgba(255, 255, 255, .85); }
  .cr-chip:disabled { opacity: .4; cursor: not-allowed; }
  .cr-f-total { background: var(--azul-claro, #eef0fb); border-radius: 10px; padding: 12px 14px; order: 5; }
  .cr-f-accion { order: 6; }
  .cr-pie { flex-direction: column; align-items: flex-start; }
  .cr-dir-det input { min-width: 0; }
}
@media (min-width: 761px) {
  .cr-chip, .cr-chips { display: none; }
}

/* Resultado: en celular y tablet sus hijos se comportan como antes (display: contents). */
.cr-resultado { display: contents; }

/* Escritorio: campos a la izquierda, panel de resultado (total + botón) a la derecha. */
@media (min-width: 1061px) {
  .cotizador-rapido .cr-fila {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 160px 390px;
    grid-template-rows: auto auto auto 1fr;
    gap: 12px 16px; align-items: start;
  }
  .cotizador-rapido .cr-f-modo { grid-column: 1 / 4; grid-row: 1; }
  .cotizador-rapido .cr-f-prod { grid-column: 1 / 4; grid-row: 2; }
  .cotizador-rapido .cr-f-comuna { grid-column: 1 / 4; grid-row: 3; }
  .cotizador-rapido .cr-f-camion { grid-column: 1 / 3; grid-row: 4; }
  .cotizador-rapido .cr-f-cant { grid-column: 3; grid-row: 4; }
  .cotizador-rapido.cr-modo-detalle .cr-f-comuna { grid-column: 1 / 3; }
  .cotizador-rapido.cr-modo-detalle .cr-f-cant { grid-column: 3; grid-row: 3; }
  .cotizador-rapido .cr-f-modo .cr-seg { grid-template-columns: repeat(4, 1fr); }
  .cr-resultado {
    display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
    grid-column: 4; grid-row: 1 / 5; align-self: stretch;
    background: var(--azul-claro, #eef0fb); border-radius: 12px; padding: 14px 16px;
  }
  .cr-resultado .cr-f-total { flex: 1; }
  .cr-total-num { white-space: nowrap; font-size: 1.9rem; }
  .cr-total-m3 { font-size: .78rem; margin-top: 6px; padding-top: 6px; border-top: 1px dashed #c9cde0; }
  .cr-f-modo .cr-seg { max-width: none; }
  .cr-resultado .cr-pill { display: table; margin-top: 8px; }
  /* El material siempre visible y editable: no hace falta el enlace "cambiar". */
  .cotizador-rapido .cr-f-prod { display: block; }
  .cr-material-linea { display: none; }
}

/* Packs: desglose visible de cuánto lleva cada material */
.cr-pack-lineas { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 4px; padding: 8px 10px; background: #fff; border: 1px solid #c9cde0; border-radius: 8px; }
.cr-pack-linea { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: .84rem; color: var(--texto, #2b2b33); }
.cr-pack-linea span:last-child { white-space: nowrap; text-align: right; }
.cr-pack-nota { display: block; font-size: .78rem; color: var(--texto-suave, #5a5a66); margin-top: 6px; }
@media (max-width: 760px) { .cr-pack-linea { flex-direction: column; gap: 0; } .cr-pack-linea span:last-child { text-align: left; } .cr-chip strong { font-size: .88rem; } .cr-chip small { font-size: .78rem; } }

/* Packs (escritorio): el panel de resultado es más alto que los campos; que estos queden pegados arriba, sin hueco en medio */
@media (min-width: 1061px) {
  .cotizador-rapido.cr-modo-pack .cr-f-comuna,
  .cotizador-rapido.cr-modo-pack .cr-f-camion,
  .cotizador-rapido.cr-modo-pack .cr-f-cant { align-self: start; }
}

/* Formato: cuatro opciones; se reparten en una o dos filas según el ancho */
.cr-seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 3px; }
.cr-seg button { min-height: 40px; white-space: nowrap; }
.cr-total-num--txt { font-size: 1.45rem; white-space: normal; }
.cr-dir-par { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .cr-dir-par { grid-template-columns: 1fr; } }
.cr-error { display: block; margin-top: 4px; color: #c62828; font-size: .8rem; line-height: 1.3; }
.cr-btn:disabled { opacity: .5; cursor: not-allowed; }
.cr-extras { margin-top: 8px; display: grid; gap: 8px; }
.cr-extra { display: grid; grid-template-columns: minmax(0, 1fr) 130px 40px; gap: 8px; align-items: center; }
.cr-extra select, .cr-extra input { width: 100%; min-height: 46px; padding: 0 12px; font: inherit; border: 1.5px solid var(--azul, #2e2ea8); border-radius: 8px; box-sizing: border-box; background: #fff; }
.cr-error[hidden] { display: none; }
.cr-extra-x { min-height: 46px; border: 1px solid #cfd6df; background: #fff; border-radius: 8px; cursor: pointer; }
.cr-f-accion .cr-agregar-mat { display: block; width: 100%; margin: 0 0 8px; background: #fff; color: var(--azul, #2e2ea8); border: 1.5px solid var(--azul, #2e2ea8); font-weight: 700; }
@media (max-width: 560px) { .cr-extra { grid-template-columns: minmax(0, 1fr) 100px 40px; } }

/* Camión / armado: botones en escritorio y tablet (igual que en celular) */
@media (min-width: 761px) {
  .cr-f-camion select { display: none; }
  .cr-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .cr-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 48px; padding: 4px; cursor: pointer; font: inherit; background: #fff; color: var(--texto, #2b2b33); border: 1.5px solid #d5d8e6; border-radius: 8px; }
  .cr-chip:hover { border-color: var(--azul, #2e2ea8); }
  .cr-chip strong { font-size: 1rem; }
  .cr-chip small { color: var(--texto-suave, #5a5a66); font-size: .78rem; }
  .cr-chip--sel, .cr-chip--sel:hover { background: var(--azul-oscuro, #23237e); border-color: var(--azul-oscuro, #23237e); color: #fff; }
  .cr-chip--sel small { color: rgba(255, 255, 255, .85); }
  .cr-chip:disabled { opacity: .4; cursor: not-allowed; }
  .cr-chip:focus-visible { outline: 2px solid var(--azul, #2e2ea8); outline-offset: 2px; }
}

/* Foto del material elegido */
.cr-foto { margin: 0; }
.cr-foto[hidden] { display: none; }
.cr-foto figure { position: relative; margin: 0; border-radius: 10px; overflow: hidden; background: #dfe3f3; aspect-ratio: 16 / 7; }
.cr-foto img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cr-foto figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 10px 6px; color: #fff; font-size: .78rem; font-weight: 600; line-height: 1.2; background: linear-gradient(to top, rgba(10, 10, 40, .78), rgba(10, 10, 40, 0)); }
.cr-foto--dos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cr-foto--dos figure { aspect-ratio: 4 / 3; }
@media (min-width: 761px) and (max-width: 1060px) { .cr-foto { grid-column: 1 / -1; } .cr-foto figure { aspect-ratio: 16 / 5; } .cr-foto--dos figure { aspect-ratio: 16 / 7; } }
@media (max-width: 760px) { .cr-foto { order: 4; } .cr-foto figure { aspect-ratio: 16 / 8; } }
