/* ============================================================
   Bandhu – Property Gallery Widget
   ============================================================ */

.bppm-gallery {
    display: flex;
    flex-direction: column;
    gap: 8px; /* sobreescrito por el control Elementor */
    width: 100%;
}

/* ── Cada celda de imagen ─────────────────────────────────── */
.bppm-gallery__item {
    position: relative;
    overflow: hidden;
    border-radius: 16px; /* sobreescrito por el control Elementor */
    display: block;
    background: #e8e8e8;
}

.bppm-gallery__item a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.bppm-gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.bppm-gallery__item:hover img {
    transform: scale(1.04);
}

/* ── Grande (full width) ──────────────────────────────────── */
.bppm-gallery__item--large {
    height: 420px; /* sobreescrito por control */
}

/* ── Fila de dos ──────────────────────────────────────────── */
.bppm-gallery__row--duo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: inherit;
}

.bppm-gallery__row--duo .bppm-gallery__item {
    height: 260px; /* sobreescrito por control */
}

/* ── Overlay de hover ─────────────────────────────────────── */
.bppm-gallery__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.bppm-gallery__item:hover .bppm-gallery__overlay {
    background: rgba(0, 0, 0, 0.25);
}

.bppm-gallery__zoom {
    color: #fff;
    font-size: 28px;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.3s ease, transform 0.3s ease;
    line-height: 1;
}

.bppm-gallery__item:hover .bppm-gallery__zoom {
    opacity: 1;
    transform: scale(1);
}

/* ── Anchors ocultos (lightbox) ──────────────────────────── */
.bppm-gallery__hidden {
    display: none;
}

/* ── Botón "Ver más" ──────────────────────────────────────── */
.bppm-gallery__footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

/* Botón "Ver todas las fotos" — blanco, sin borde, estilo Airbnb */
.bppm-gallery__btn {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #fff;
    color: #222;
    cursor: pointer;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bppm-gallery__btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.bppm-gallery__btn-icon {
    flex-shrink: 0;
}

/* Cuando el botón está DENTRO de la última foto grande: flotante abajo-derecha */
.bppm-gallery__item--large .bppm-gallery__btn {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 5;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .bppm-gallery__row--duo {
        grid-template-columns: 1fr;
    }

    .bppm-gallery__item--large {
        height: 260px;
    }

    .bppm-gallery__row--duo .bppm-gallery__item {
        height: 200px;
    }
}

/* ── El botón que envuelve la foto ocupa toda la celda ────── */
.bppm-gallery__photo {
    all: unset;
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
    position: relative;
}

/* ── Placeholder en editor ────────────────────────────────── */
.bppm-gallery-placeholder {
    background: #f5f5f5;
    padding: 40px;
    text-align: center;
    border-radius: 12px;
    border: 2px dashed #ddd;
}

/* ============================================================
   Offcanvas – galería completa estilo Airbnb
   ============================================================ */

/* Bloquear scroll del body cuando está abierto */
body.bppm-canvas-open {
    overflow: hidden;
}

/* Contenedor raíz: ocupa toda la ventana */
.bppm-canvas {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

/* CRÍTICO: respetar el atributo [hidden]. Sin esto, display:flex
   deja el overlay siempre encima de la página rompiendo el scroll. */
.bppm-canvas[hidden] {
    display: none !important;
}

/* Backdrop */
.bppm-canvas__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.bppm-canvas.is-open .bppm-canvas__backdrop {
    opacity: 1;
}

/* Panel deslizante desde abajo (como Airbnb en mobile) o desde arriba */
.bppm-canvas__panel {
    position: relative;
    z-index: 1;
    background: #fff;
    width: 100%;
    max-width: none; /* ancho completo de la pantalla */
    max-height: 100dvh;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateY(40px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s ease;
    outline: none;
    display: flex;
    flex-direction: column;
}

.bppm-canvas.is-open .bppm-canvas__panel {
    transform: translateY(0);
    opacity: 1;
}

/* Header pegado arriba */
.bppm-canvas__header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    flex-shrink: 0;
}

/* El grid se centra a 1200px; el fondo del panel y el header
   (con su borde) siguen ocupando todo el ancho de la pantalla. */
.bppm-canvas__grid {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.bppm-canvas__title {
    font-size: 16px;
    font-weight: 600;
    color: #111;
}

.bppm-canvas__close {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #111;
    transition: background 0.2s ease;
}

.bppm-canvas__close:hover {
    background: #f0f0f0;
}

/* Grid de fotos – 3 columnas en desktop */
.bppm-canvas__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 24px;
}

.bppm-canvas__cell {
    all: unset;
    box-sizing: border-box;
    display: block;
    cursor: pointer;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 12px;
    background: #e8e8e8;
}

.bppm-canvas__cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.bppm-canvas__cell:hover img {
    transform: scale(1.04);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .bppm-canvas__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .bppm-canvas__grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Lightbox (visor de imagen individual con navegación)
   ============================================================ */

.bppm-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000001; /* por encima del offcanvas (999999) */
    display: flex;
    align-items: center;
    justify-content: center;
}

.bppm-lightbox[hidden] {
    display: none !important;
}

.bppm-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.bppm-lightbox.is-open .bppm-lightbox__backdrop {
    opacity: 1;
}

.bppm-lightbox__stage {
    position: relative;
    z-index: 1;
    margin: 0;
    max-width: 90vw;
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.96);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s ease;
}

.bppm-lightbox.is-open .bppm-lightbox__stage {
    transform: scale(1);
    opacity: 1;
}

.bppm-lightbox__img {
    max-width: 90vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: block;
}

/* Botones (cerrar + navegación) */
.bppm-lightbox__close,
.bppm-lightbox__nav {
    all: unset;
    position: absolute;
    z-index: 2;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    transition: background 0.2s ease, transform 0.2s ease;
}

.bppm-lightbox__close:hover,
.bppm-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.bppm-lightbox__close {
    top: 20px;
    right: 24px;
    width: 44px;
    height: 44px;
}

.bppm-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
}

.bppm-lightbox__nav:hover {
    transform: translateY(-50%) scale(1.05);
}

.bppm-lightbox__nav--prev { left: 24px; }
.bppm-lightbox__nav--next { right: 24px; }

.bppm-lightbox__counter {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.03em;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 14px;
    border-radius: 100px;
}

@media (max-width: 600px) {
    .bppm-lightbox__nav { width: 40px; height: 40px; }
    .bppm-lightbox__nav--prev { left: 10px; }
    .bppm-lightbox__nav--next { right: 10px; }
    .bppm-lightbox__close { top: 12px; right: 12px; }
}
