/* Leal Galería MercadoLibre — frontend v1.0.5 */
/*
 * El layout interno siempre ocupa el 100% de su contenedor.
 * Solo la integración automática de WooCommerce conserva el ancho nativo del 48%.
 * El shortcode no hereda la clase .images para evitar que el tema vuelva a reducirlo
 * al 48% dentro de una columna de Elementor.
 */
.leal-ml-gallery {
    display: grid !important;
    grid-template-columns: 78px minmax(0, 1fr) !important;
    gap: 16px !important;
    max-width: none !important;
    box-sizing: border-box !important;
}

div.product div.images.leal-ml-gallery:not(.leal-shortcode) {
    float: left !important;
    width: 48% !important;
    margin: 0 0 2em !important;
}

.leal-ml-gallery.leal-shortcode,
div.product .leal-ml-gallery.leal-shortcode,
.elementor-widget-shortcode .leal-ml-gallery.leal-shortcode,
.elementor-widget-container > .leal-ml-gallery.leal-shortcode {
    float: none !important;
    clear: none !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
}

.leal-ml-gallery .leal-thumbs {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    max-height: 620px !important;
    overflow-y: auto !important;
    padding: 2px !important;
}

.leal-ml-gallery .leal-thumb {
    appearance: none !important;
    width: 68px !important;
    height: 68px !important;
    min-width: 68px !important;
    padding: 3px !important;
    border: 1px solid #d8d8d8 !important;
    border-radius: 6px !important;
    background: #fff !important;
    cursor: pointer !important;
    overflow: hidden !important;
    position: relative !important;
    box-shadow: none !important;
}

.leal-ml-gallery .leal-thumb.active {
    border: 2px solid #3483fa !important;
}

.leal-ml-gallery .leal-thumb img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain !important;
    margin: 0 !important;
}

.leal-video-thumb {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

.leal-video-thumb b {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .72);
    color: #fff;
    font-size: 13px;
}

.leal-ml-gallery .leal-stage {
    position: relative !important;
    min-width: 0 !important;
    width: 100% !important;
    height: clamp(520px, 42vw, 620px) !important;
    background: #fff !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}

.leal-ml-gallery .leal-slide {
    display: none !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.leal-ml-gallery .leal-slide.active {
    display: flex !important;
}

.leal-ml-gallery button.leal-image-wrap,
.leal-ml-gallery .leal-image-wrap {
    appearance: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: inherit !important;
    line-height: normal !important;
    cursor: zoom-in !important;
    pointer-events: auto !important;
    overflow: hidden !important;
    outline: none !important;
}


.leal-ml-gallery button.leal-image-wrap:hover,
.leal-ml-gallery button.leal-image-wrap:focus,
.leal-ml-gallery button.leal-image-wrap:active {
    background: transparent !important;
    color: inherit !important;
    border: 0 !important;
    box-shadow: none !important;
    transform: none !important;
}

.leal-ml-gallery button.leal-image-wrap:focus-visible {
    box-shadow: inset 0 0 0 2px #3483fa !important;
    border-radius: 6px !important;
}

.leal-ml-gallery .leal-product-image,
.leal-ml-gallery .leal-image-wrap > img,
div.product div.images.leal-ml-gallery .leal-image-wrap > img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain !important;
    object-position: center center !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
}

.leal-zoom-hint {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, .66);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

.leal-image-wrap:hover .leal-zoom-hint,
.leal-image-wrap:focus-visible .leal-zoom-hint {
    opacity: 1;
    transform: none;
}

.leal-ml-gallery .leal-video-wrap {
    width: min(335px, 100%) !important;
    aspect-ratio: 9 / 16 !important;
    max-height: 100% !important;
    margin: auto !important;
    background: #000 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}

.leal-video-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.leal-dots { display: none; }
.leal-placeholder { display: grid; place-items: center; height: 100%; font-size: 32px; }

/* Lightbox: el archivo se muestra en sus dimensiones naturales, sin ajuste automático. */
html.leal-lightbox-open,
body.leal-lightbox-open {
    overflow: hidden !important;
}

.leal-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: none;
    background: rgba(0, 0, 0, .94);
    color: #fff;
}

.leal-lightbox.is-open { display: block; }

.leal-lightbox-viewport {
    position: absolute;
    inset: 0;
    overflow: auto;
    box-sizing: border-box;
    padding: 70px 24px 32px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.leal-lightbox-canvas {
    display: flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    min-width: 100%;
    height: max-content;
    min-height: 100%;
    box-sizing: border-box;
}

.leal-lightbox-image {
    display: block !important;
    flex: 0 0 auto !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: none !important;
    object-position: initial !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: 0 10px 45px rgba(0, 0, 0, .38) !important;
    user-select: none;
    -webkit-user-drag: none;
}

.leal-lightbox-close,
.leal-lightbox-prev,
.leal-lightbox-next {
    appearance: none;
    position: fixed;
    z-index: 2147483002;
    border: 0;
    background: rgba(20, 20, 20, .82);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: none;
}

.leal-lightbox-close {
    right: 16px;
    top: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 34px;
    line-height: 1;
}

.leal-lightbox-close:hover,
.leal-lightbox-close:focus-visible {
    background: #fff;
    color: #111;
    outline: 2px solid #3483fa;
}

.leal-lightbox-prev,
.leal-lightbox-next {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 64px;
    border-radius: 8px;
    font-size: 36px;
}

.leal-lightbox-prev { left: 14px; }
.leal-lightbox-next { right: 14px; }

.leal-lightbox-counter {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    z-index: 2147483002;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(20, 20, 20, .78);
    color: #fff;
    font-size: 13px;
}


/* Elementor Theme Builder: el widget y sus envoltorios no deben limitar el ancho. */
.elementor-widget-shortcode:has(.leal-ml-gallery.leal-shortcode),
.elementor-widget-shortcode:has(.leal-ml-gallery.leal-shortcode) > .elementor-widget-container {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

@media (max-width: 767px) {
    div.product div.images.leal-ml-gallery,
    .leal-ml-gallery {
        display: block !important;
        float: none !important;
        width: 100% !important;
        margin: 0 0 20px !important;
    }

    .leal-ml-gallery .leal-thumbs { display: none !important; }

    .leal-ml-gallery .leal-stage {
        display: flex !important;
        width: 100% !important;
        height: clamp(410px, 118vw, 540px) !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory !important;
        scroll-behavior: smooth !important;
        overscroll-behavior-x: contain !important;
        -webkit-overflow-scrolling: touch !important;
        border: 1px solid #eee !important;
    }

    .leal-stage::-webkit-scrollbar { display: none; }

    .leal-ml-gallery .leal-slide,
    .leal-ml-gallery .leal-slide.active {
        display: flex !important;
        flex: 0 0 100% !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        scroll-snap-align: start !important;
        scroll-snap-stop: always !important;
    }

    .leal-zoom-hint {
        opacity: .82;
        transform: none;
        right: 10px;
        bottom: 10px;
        width: 34px;
        height: 34px;
        font-size: 20px;
    }

    .leal-ml-gallery .leal-video-wrap {
        width: min(76vw, 330px) !important;
        max-height: 100% !important;
    }

    .leal-dots {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        margin-top: 10px;
    }

    .leal-dots button {
        width: 8px;
        height: 8px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: #c7c7c7;
    }

    .leal-dots button.active {
        background: #3483fa;
        transform: scale(1.25);
    }

    .leal-dots span {
        margin-left: 8px;
        font-size: 12px;
        color: #666;
    }

    .leal-lightbox-viewport { padding: 66px 12px 28px; }
    .leal-lightbox-close { right: 10px; top: 10px; width: 46px; height: 46px; }
    .leal-lightbox-prev,
    .leal-lightbox-next { width: 40px; height: 54px; font-size: 30px; background: rgba(20, 20, 20, .64); }
    .leal-lightbox-prev { left: 4px; }
    .leal-lightbox-next { right: 4px; }
}
