/* ═══════════════════════════════════════════════════════════════
   JF Constructor · V4
   Paso 5 más visual + fondos de producto blancos + precio/ud. fijo.
   Se carga DESPUÉS de compact-layout-v4.css.
   ═══════════════════════════════════════════════════════════════ */

/* ── PRECIO TOTAL + PRECIO POR CAMISETA, SIEMPRE VISIBLES ───── */
@media (min-width: 901px) {
  .jf-builder-total {
    min-width: 186px !important;
    padding: 5px 7px !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    text-align: right;
  }
  .jf-builder-total__metric {
    min-width: 0;
    padding: 2px 8px;
  }
  .jf-builder-total__metric + .jf-builder-total__metric {
    border-left: 1px solid rgba(255,255,255,.13);
  }
  .jf-builder-total__metric small,
  .jf-builder-total__metric strong {
    display: block;
    white-space: nowrap;
  }
  .jf-builder-total__metric small {
    color: rgba(255,255,255,.55);
    font-size: 7px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .jf-builder-total__metric strong {
    margin-top: 2px;
    color: var(--jf-olive-light);
    font-size: 14px;
    line-height: 1.1;
  }
  .jf-builder-total__metric--unit strong {
    color: #fff;
    font-size: 12px;
  }

  .jf-builder-selection__row--unit {
    margin-top: 3px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,.11);
  }
  .jf-builder-selection__row--unit strong {
    color: var(--jf-olive-light);
  }
}

/* ── PASO 5: 1/3 CONFIGURACIÓN + 2/3 MOCKUP ─────────────────── */
@media (min-width: 901px) {
  #box-zonas.active {
    grid-template-columns: minmax(270px, .56fr) minmax(0, 1.44fr) !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    gap: 8px 12px !important;
    padding: 10px 12px 12px !important;
  }

  /* El encabezado solo ocupa la zona izquierda; el mockup sube hasta arriba. */
  #box-zonas.active > .jf-box-head {
    grid-column: 1 !important;
    grid-row: 1 !important;
    align-self: start;
    padding: 0 2px 2px;
  }
  #box-zonas.active > .jf-box-head > span {
    margin-bottom: 4px;
    font-size: 9px;
  }
  #box-zonas.active > .jf-box-head h2 {
    max-width: 390px;
    margin-bottom: 5px;
    font-size: clamp(1.35rem, 1.7vw, 1.9rem) !important;
    line-height: 1.02;
  }
  #box-zonas.active > .jf-box-head p {
    max-width: 390px;
    margin: 0;
    font-size: 10px;
    line-height: 1.35;
  }

  #box-zonas.active > .jf-design-config-panel {
    grid-column: 1 !important;
    grid-row: 2 !important;
    padding-right: 2px !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 5px !important;
    align-content: start;
  }

  /* Nota redundante: en desktop quitamos una línea para ganar altura. */
  #box-zonas .jf-zone-topbar {
    display: none !important;
  }

  #box-zonas .jf-zone-group {
    display: grid;
    grid-template-columns: 72px minmax(0,1fr);
    gap: 6px;
    align-items: start;
  }
  #box-zonas .jf-zone-group h3 {
    margin: 8px 0 0 !important;
    font-size: 8px !important;
    line-height: 1.2;
    letter-spacing: .06em;
  }
  #box-zonas .jf-zone-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 4px !important;
  }
  #box-zonas .jf-zone-card {
    min-height: 38px !important;
    padding: 5px 8px !important;
    border-radius: 9px !important;
    text-align: left;
  }
  #box-zonas .jf-zone-card > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
  }
  #box-zonas .jf-zone-card strong {
    font-size: 10px !important;
  }
  #box-zonas .jf-zone-card small {
    margin: 0 !important;
    font-size: 8px !important;
    white-space: nowrap;
  }

  #box-zonas #jfZoneConfigs {
    max-height: min(215px, 28vh);
    overflow: auto;
    scrollbar-width: thin;
  }
  #box-zonas .jf-zone-configs {
    gap: 5px !important;
  }
  #box-zonas .jf-zone-config {
    padding: 7px !important;
  }
  #box-zonas .jf-zone-summary {
    padding: 7px 9px !important;
    font-size: 9px !important;
  }
  #box-zonas .jf-box-actions .jf-next-btn {
    min-height: 36px !important;
    padding-inline: 15px !important;
  }

  /* Mockup arranca desde la misma altura que el título y ocupa ambas filas. */
  #box-zonas.active > .jf-mockup-final-block {
    grid-column: 2 !important;
    grid-row: 1 / 3 !important;
    height: 100% !important;
    min-height: 0 !important;
  }
  #box-zonas .jf-mockup-box {
    padding: 8px !important;
    border-radius: 16px !important;
  }
  #box-zonas .jf-mockup-box-head {
    margin-bottom: 4px !important;
  }
  #box-zonas .jf-mockup-box-head span {
    margin-bottom: 2px !important;
    font-size: 7px !important;
  }
  #box-zonas .jf-mockup-box-head h2 {
    margin-bottom: 1px !important;
    font-size: 15px !important;
  }
  #box-zonas .jf-mockup-box-head p {
    font-size: 8px !important;
    line-height: 1.2 !important;
  }
  #box-zonas .jf-mockup-wrap {
    grid-template-columns: minmax(0, 1fr) 164px !important;
    gap: 6px !important;
  }
  #box-zonas .jf-mockup-main {
    min-height: 0;
    grid-template-rows: 28px minmax(0, 1fr) !important;
  }
  #box-zonas .jf-mockup-toolbar {
    margin: 0 0 4px !important;
    gap: 4px;
  }
  #box-zonas .jf-view-btn {
    min-height: 25px !important;
    padding-inline: 6px !important;
    font-size: 7px !important;
  }
  #box-zonas .jf-mockup-stage {
    min-height: 0 !important;
    height: 100% !important;
    padding: 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    background: #fff !important;
  }
  #box-zonas .jf-mockup-canvas {
    position: relative;
    flex: 0 1 auto;
    width: auto !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    aspect-ratio: 5 / 6 !important;
    margin: 0 auto !important;
  }
  #box-zonas .jf-mockup-canvas > img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center center !important;
  }

  /* Panel de ajuste pegado arriba y más compacto. */
  #box-zonas .jf-mockup-side-info {
    gap: 4px !important;
    align-content: start !important;
  }
  #box-zonas .jf-mockup-editor-box {
    gap: 4px !important;
    padding: 6px !important;
  }
  #box-zonas .jf-mockup-editor-box > strong {
    font-size: 10px;
  }
  #box-zonas .jf-vdb-wrap,
  #box-zonas .jf-mockup-width-box,
  #box-zonas .jf-mockup-pad-box {
    padding: 5px !important;
  }
  #box-zonas .jf-mockup-added-list {
    max-height: 58px !important;
    padding: 5px 6px !important;
  }
  #box-zonas .jf-mockup-actions {
    gap: 4px !important;
  }
  #box-zonas .jf-mockup-action-btn {
    min-height: 28px !important;
    font-size: 7px !important;
  }
}

/* ── PASO 7/8: las fotos ya traen fondo blanco ──────────────── */
#box-pack .jf-pack-image,
#box-regalo .jf-gift-visual {
  background: #fff !important;
}
#box-pack .jf-pack-image img,
#box-regalo .jf-gift-visual img {
  mix-blend-mode: normal !important;
}

@media (min-width: 901px) {
  #box-pack .jf-pack-image {
    border: 1px solid rgba(24,25,22,.08);
  }
  #box-pack .jf-pack-image img {
    padding: 2px !important;
  }
}

/* ── MÓVIL: total + precio por unidad en el dock ───────────── */
@media (max-width: 900px) {
  .jf-mobile-dock-total {
    min-width: 86px;
    display: flex !important;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 1px;
    line-height: 1.05;
  }
  .jf-mobile-dock-total small,
  .jf-mobile-dock-total strong {
    display: block;
    white-space: nowrap;
  }
  .jf-mobile-dock-total small {
    color: var(--jf-muted);
    font-size: 9px;
    font-weight: 800;
  }
  .jf-mobile-dock-total strong {
    color: var(--jf-olive);
    font-size: 12px;
    font-weight: 900;
  }
}

/* ═══════════════════════════════════════════════════════════════
   V5 · MÓVIL PACK + RESUMEN
   - Carrusel horizontal real y evidente en Complementos
   - Las acciones dejan de tapar la tarjeta
   - Tarjeta completa visible y controles compactos
   - Paso 9 protegido frente al dock inferior
   ═══════════════════════════════════════════════════════════════ */

.jf-pack-carousel-nav {
  display: none;
}

@media (max-width: 900px) {
  /* PASO 7 · Flujo móvil limpio: cabecera, carrusel, navegación y acciones. */
  #box-pack.active {
    display: flex !important;
    flex-direction: column;
    gap: 9px;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 13px 12px 104px !important;
    scroll-padding-bottom: 104px;
  }

  #box-pack.active > .jf-box-head {
    flex: 0 0 auto;
    margin: 0 0 2px !important;
  }

  #box-pack.active > .jf-box-head h2 {
    margin-bottom: 4px !important;
    font-size: clamp(1.72rem, 7.4vw, 2.15rem) !important;
    line-height: .98 !important;
  }

  #box-pack.active > .jf-box-head p {
    margin: 0 !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
  }

  #box-pack .jf-pack-grid {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 0 0 auto;
    display: flex !important;
    grid-template-columns: none !important;
    gap: 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    scrollbar-width: none;
    padding: 2px 22px 5px 1px !important;
    cursor: grab;
  }

  #box-pack .jf-pack-grid:active {
    cursor: grabbing;
  }

  #box-pack .jf-pack-grid::-webkit-scrollbar {
    display: none;
  }

  #box-pack .jf-pack-item {
    flex: 0 0 min(88%, 390px) !important;
    width: min(88%, 390px) !important;
    min-width: min(88%, 390px) !important;
    height: auto !important;
    min-height: 238px;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: grid !important;
    grid-template-columns: 112px minmax(0, 1fr) !important;
    grid-template-rows: auto auto 1fr !important;
    grid-template-areas:
      "image top"
      "image colors"
      "image controls" !important;
    column-gap: 10px !important;
    row-gap: 6px !important;
    align-items: start !important;
    padding: 10px !important;
    border-radius: 15px !important;
  }

  #box-pack .jf-pack-image {
    grid-area: image !important;
    width: 112px !important;
    height: 100% !important;
    min-height: 218px !important;
    max-height: none !important;
    align-self: stretch;
    border-radius: 12px !important;
    background: #fff !important;
  }

  #box-pack .jf-pack-image img {
    width: 100% !important;
    height: 100% !important;
    padding: 4px !important;
    object-fit: contain !important;
  }

  #box-pack .jf-pack-top {
    grid-area: top !important;
    min-width: 0;
    padding: 2px 1px 0 !important;
    gap: 7px !important;
  }

  #box-pack .jf-pack-top strong {
    min-width: 0;
    overflow: hidden;
    font-size: 14px !important;
    line-height: 1.08 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #box-pack .jf-pack-top span {
    font-size: 13px !important;
    white-space: nowrap;
  }

  #box-pack .jf-pack-colors {
    grid-area: colors !important;
    min-width: 0;
    max-height: 48px;
    overflow: hidden;
    display: flex !important;
    flex-wrap: wrap !important;
    align-content: flex-start;
    gap: 4px !important;
    padding: 0 !important;
  }

  #box-pack .jf-pack-color-btn {
    width: 20px !important;
    height: 20px !important;
    flex: 0 0 20px !important;
    border-width: 1px !important;
  }

  #box-pack .jf-pack-color-btn.active {
    outline-width: 2px !important;
    outline-offset: 1px !important;
  }

  #box-pack .jf-pack-controls {
    grid-area: controls !important;
    align-self: end;
    min-width: 0;
    display: grid !important;
    gap: 6px !important;
    padding: 0 !important;
  }

  #box-pack .jf-pack-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 5px !important;
  }

  #box-pack .jf-pack-check,
  #box-pack .jf-pack-custom {
    width: 100% !important;
    min-height: 34px !important;
    padding: 0 9px !important;
    justify-content: flex-start !important;
    font-size: 10px !important;
    line-height: 1.15 !important;
  }

  #box-pack .jf-pack-qty-wrap {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }

  #box-pack .jf-pack-qty-wrap span {
    font-size: 9px !important;
  }

  #box-pack .jf-pack-controls input[type="number"] {
    width: 74px !important;
    min-height: 33px !important;
    padding: 4px 7px !important;
    font-size: 11px !important;
  }

  /* Navegación visible: ya no hay que adivinar que el bloque desliza. */
  #box-pack .jf-pack-carousel-nav {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 2px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 8px;
    align-items: center;
  }

  .jf-pack-carousel-btn {
    width: 38px;
    height: 36px;
    border: 1px solid var(--jf-border);
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: var(--jf-ink);
    background: #fff;
    box-shadow: 0 6px 14px rgba(24,25,22,.05);
    font-size: 17px;
    font-weight: 900;
    cursor: pointer;
  }

  .jf-pack-carousel-btn:disabled {
    opacity: .32;
    cursor: default;
  }

  .jf-pack-carousel-status {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--jf-muted);
    font-size: 9px;
    font-weight: 850;
    line-height: 1.2;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .jf-pack-carousel-dots {
    display: flex;
    gap: 4px;
  }

  .jf-pack-carousel-dot {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: rgba(24,25,22,.18);
    transition: width .22s ease, background .22s ease;
  }

  .jf-pack-carousel-dot.is-active {
    width: 17px;
    background: var(--jf-fiesta);
  }

  /* Muy importante: acciones EN FLUJO. No vuelven a tapar Personalizar. */
  #box-pack .jf-pack-actions {
    position: static !important;
    inset: auto !important;
    z-index: auto !important;
    flex: 0 0 auto;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px !important;
    background: transparent !important;
  }

  #box-pack .jf-pack-actions button {
    width: 100% !important;
    min-height: 44px !important;
    padding: 0 10px !important;
    font-size: 9px !important;
    line-height: 1.15 !important;
  }

  /* PASO 9 · nada queda escondido detrás del dock fijo. */
  #box-9.active {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-bottom: 118px !important;
    scroll-padding-bottom: 118px;
  }

  #box-9 .jf-summary-layout,
  #box-9 .jf-final-block {
    min-width: 0;
    width: 100%;
  }

  #box-9 .jf-final-block {
    position: static !important;
    margin-bottom: 0 !important;
  }

  #box-9 .jf-whatsapp-box {
    margin-bottom: 4px;
  }
}

@media (max-width: 430px) {
  #box-pack .jf-pack-item {
    flex-basis: calc(100% - 20px) !important;
    width: calc(100% - 20px) !important;
    min-width: calc(100% - 20px) !important;
    grid-template-columns: 100px minmax(0, 1fr) !important;
    min-height: 226px;
  }

  #box-pack .jf-pack-image {
    width: 100px !important;
    min-height: 206px !important;
  }

  #box-pack .jf-pack-actions {
    grid-template-columns: 1fr !important;
  }
}
