/* CREACH - Fondo global de todos los elementos visuales de PRODUCTOS.
   Solo se aplica si el administrador configuró product_global_background.
   Dejar fondos de vehículos, marcas, anuncios y otros recursos intactos.
   Las fotografías PNG/WebP transparentes quedan delante del fondo.
*/
.creach-product-media-stage[data-creach-product-bg="1"]{
  background-repeat:no-repeat !important;
  background-position:center center !important;
  background-size:contain !important;
  position:relative;
  overflow:hidden;
}
.creach-product-media-stage[data-creach-product-bg="1"] > img,
.creach-product-media-stage[data-creach-product-bg="1"] > .creach-product-media-object{
  background-color:transparent !important;
  background-image:none !important;
  object-fit:contain;
  position:relative;
  z-index:1;
}
/* El antiguo marcador de engranaje tenía fondo opaco y ocultaba el fondo global. */
.creach-gallery-hero[data-creach-product-bg="1"] .huge-part,
.creach-product-media-stage[data-creach-product-bg="1"] > .huge-part,
.creach-product-media-stage[data-creach-product-bg="1"] > .part-icon{
  background:transparent !important;
  background-image:none !important;
}
.creach-product-page .creach-gallery-hero[data-creach-product-bg="1"]{
  background-color:#f4f7f9 !important;
  background-size:contain !important;
}
.creach-product-page .creach-gallery-hero[data-creach-product-bg="1"] .creach-gallery-stage{
  background:transparent !important;
  background-image:none !important;
}
.creach-product-page .creach-gallery-hero[data-creach-product-bg="1"] .huge-part{
  background:transparent !important;
  background-image:none !important;
}
/* Miniaturas relacionadas, galería principal y formularios de edición. */
.creach-product-page .creach-related-stage[data-creach-product-bg="1"] img,
.admin-pro .creach-product-media-stage[data-creach-product-bg="1"] img{
  background:transparent !important;
}
.creach-product-page .creach-related-stage[data-creach-product-bg="1"]{
  display:grid;place-items:center;min-height:94px;
}
.creach-product-fallback{display:grid;place-items:center;width:100%;height:100%;font-size:clamp(25px,4vw,55px);color:#829ba9;position:relative;z-index:1}
.creach-related-stage .creach-product-fallback{height:94px;font-size:39px}
.admin-pro .product-admin-thumb .creach-product-fallback{font-size:30px}
.admin-pro .product-edit-preview .creach-product-fallback{font-size:65px}
.admin-pro .admin-offers-product .creach-admin-offer-visual{
  display:grid;place-items:center;flex:0 0 76px;width:76px;height:76px;
  overflow:hidden;border-radius:9px;
}
.admin-pro .admin-offers-product .creach-admin-offer-visual img{
  width:100%;height:100%;object-fit:contain;
}
.admin-pro .creach-admin-offer-visual .creach-product-fallback{font-size:36px}
.admin-pro .product-edit-preview img[hidden]{display:none!important}
.admin-pro .product-gallery-inline .gallery-admin-photo[data-creach-product-bg="1"] img{background:transparent!important}

.creach-product-fallback[hidden]{display:none!important}
.creach-product-media-stage[data-creach-product-bg="1"] .product-viewer-stage img,
.creach-image-viewer .product-viewer-stage[data-creach-product-bg="1"] img{background:transparent!important}
.admin-pro .admin-gallery-upload-preview .creach-product-media-stage[data-creach-product-bg="1"]{background-repeat:no-repeat!important;background-size:contain!important;background-position:center!important}

.admin-pro .admin-ticker-product-preview{display:grid;place-items:center;min-height:90px;max-width:430px;overflow:hidden;border-radius:10px}
.admin-pro .admin-ticker-product-preview img{width:100%;max-height:220px;object-fit:contain;background:transparent!important}
.admin-pro .admin-data-image[data-creach-product-bg="1"] img{background:transparent!important}


/* ================================================================
   CREACH 2026-10-14 · UNA SOLA PROPORCION VISUAL PARA REPUESTOS
   Medida de autoria: 1200 x 960 px. Representacion: 5 / 4.
   Mantiene la imagen y el fondo global completos (contain) sin
   cambiar los archivos originales, logos de marcas o vehiculos.
   ================================================================ */
:root { --creach-product-frame-ratio: 5 / 4; }

/* Tarjetas del catalogo, Inicio, ofertas, resultados y carrito.
   Se sobreescriben alturas fijas anteriores; la imagen manda. */
body .product-card .product-visual,
body .catalog-products .product-visual,
body .catalog-pro-page .catalog-card-pro .catalog-card-visual,
body .related-products-grid .product-visual,
body .cart-row-card .catalog-card-pro .product-visual,
body .favorites-unified-grid .product-visual {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: var(--creach-product-frame-ratio) !important;
    box-sizing: border-box;
    flex: none;
}
/* Respeta el arte original: no se agranda ni recorta la pieza. */
body .product-card .product-visual > img,
body .product-card .product-visual > .creach-product-media-object,
body .catalog-card-visual > img,
body .favorite-image img {
    object-fit: contain !important;
    object-position: center !important;
}
/* Ficha completa en escritorio, tablet y movil: siempre 5:4. */
body .creach-product-page .creach-gallery-hero,
body .creach-product-page .product-media .creach-gallery-hero,
body .creach-product-page .creach-gallery-hero.creach-product-media-stage {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: var(--creach-product-frame-ratio) !important;
}
/* El stage interior llena el marco exterior; no anida otro ratio. */
body .creach-product-page .creach-gallery-hero > .creach-gallery-stage {
    width: 100%;
    height: 100% !important;
    aspect-ratio: auto !important;
    position: relative;
}
body .creach-product-page .creach-gallery-hero > .creach-gallery-stage > img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain !important;
    object-position: center !important;
}
/* Las miniaturas de la galeria y los articulos relacionados tambien 5:4. */
body .creach-product-page .creach-gallery-thumbs .creach-thumb,
body .creach-product-page .thumb-gallery .product-photo-thumb,
body .creach-product-page .creach-related-card .creach-related-stage {
    display: grid;
    place-items: center;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: var(--creach-product-frame-ratio) !important;
    overflow: hidden;
}
body .creach-product-page .creach-gallery-thumbs .creach-thumb > img,
body .creach-product-page .creach-related-card .creach-related-stage > img {
    display: block;
    width: 100%;
    height: 100% !important;
    max-height: 100%;
    object-fit: contain !important;
    object-position: center !important;
}
body .creach-product-page .creach-related-card .creach-related-stage .creach-product-fallback {
    width: 100%;
    height: 100% !important;
}
/* Mantener igual el fondo guardado en Administracion: nunca recortarlo. */
body .creach-product-media-stage[data-creach-product-bg="1"] {
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
}
/* Miniatura general de favoritos. */
body .favorite-image {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: var(--creach-product-frame-ratio) !important;
}
/* Administracion: miniatura, imagen principal, galeria y ofertas. */
body.admin-pro .product-admin-thumb,
body.admin-pro .product-edit-preview,
body.admin-pro .admin-offers-product .creach-admin-offer-visual,
body.admin-pro .product-gallery-inline .gallery-admin-photo,
body.admin-pro .admin-gallery-upload-preview > div.creach-product-media-stage,
body.admin-pro .admin-ticker-product-preview.creach-product-media-stage {
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: var(--creach-product-frame-ratio) !important;
    overflow: hidden;
}
body.admin-pro .product-edit-preview,
body.admin-pro .product-admin-thumb,
body.admin-pro .admin-offers-product .creach-admin-offer-visual {
    display: grid;
    place-items: center;
}
body.admin-pro .product-admin-thumb img,
body.admin-pro .product-edit-preview > img,
body.admin-pro .admin-offers-product .creach-admin-offer-visual > img {
    display: block;
    width: 100%;
    height: 100% !important;
    object-fit: contain !important;
}
/* Las vistas previas de nueva galeria incluyen una descripcion debajo:
   solo su superficie visual (imagen) mantiene 5:4. */
body.admin-pro .admin-gallery-upload-preview img {
    width: 100%;
    height: auto !important;
    aspect-ratio: var(--creach-product-frame-ratio) !important;
    object-fit: contain !important;
}
body.admin-pro .gallery-admin-photo img {
    width: 100%;
    height: 100% !important;
    object-fit: contain !important;
}
/* Otros listados de imagen de producto del administrador. */
body.admin-pro .admin-data-image[data-creach-product-bg="1"] {
    aspect-ratio: var(--creach-product-frame-ratio);
}
body.admin-pro .admin-data-image[data-creach-product-bg="1"] img {
    object-fit: contain !important;
}
/* El visor ampliado conserva su alto flexible en pantalla: no se fija a
   960 px ni se interfiere con sus controles de zoom y desplazamiento. */
body .creach-image-viewer .product-viewer-stage img { object-fit: contain !important; }

/* ================================================================
   CREACH · Visor ampliado uniforme V6 · 1200 x 960 (5:4)
   El 100% muestra el producto y el fondo global completos.
   El modal reduce su ancho cuando la altura de pantalla es pequena;
   el zoom manual conserva su comportamiento de arrastre y navegacion.
   ================================================================ */
body .creach-image-viewer {
  width: min(1040px, calc(100vw - 24px), calc((100dvh - 172px) * 1.25)) !important;
  height: auto !important;
  max-height: calc(100dvh - 24px) !important;
  overflow: hidden;
}
body .creach-image-viewer .product-viewer-window {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
}
body .creach-image-viewer .product-viewer-header,
body .creach-image-viewer .product-viewer-footer {
  flex-shrink: 0;
}
body .creach-image-viewer .product-viewer-title {
  min-width: 0;
}
body .creach-image-viewer .product-viewer-stage,
body .creach-image-viewer .product-viewer-stage.creach-product-media-stage {
  display: grid;
  place-items: center;
  flex: 0 0 auto !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: 5 / 4 !important;
  padding: 0 !important;
  overflow: hidden;
  position: relative;
  background-position: center !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
}
body .creach-image-viewer .product-viewer-stage > img,
body .creach-image-viewer .product-viewer-stage > img.creach-product-media-object {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  object-fit: contain !important;
  object-position: center !important;
  transform-origin: center center;
}
@media (max-width: 610px) {
  body .creach-image-viewer {
    width: min(calc(100vw - 12px), calc((100dvh - 155px) * 1.25)) !important;
    max-height: calc(100dvh - 12px) !important;
  }
}
/* Centrado por contenido: evita el espacio vacio que producia inset:0
   con la altura automatica del <dialog>, especialmente en movil. */
body .creach-image-viewer[open] {
  inset: auto !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%);
  margin: 0 !important;
}

/* En la tira de repuestos relacionados la referencia solo es una pista visual.
   Se mantiene visible, pero sin competir con la miniatura ni el botón del carrito. */
body .creach-product-page .creach-related-card .creach-related-stage .creach-reference-label {
  bottom: 5px !important;
  left: 5px !important;
  max-width: 62px !important;
  padding: 3px 4px !important;
  border-radius: 4px !important;
  font: 700 8px/1.05 Montserrat, Arial, sans-serif !important;
  box-shadow: 0 1px 3px rgba(13, 50, 70, .10) !important;
}
