﻿/* ===== Gallery Container ===== */
.galleryFloorplan,
.galleryLayout {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(1, 1fr); /* mobile mặc định 1 cột */
    gap: 5px;
}

/* Breakpoints: tăng cột khi màn hình rộng hơn */
@media (min-width: 640px) {
    .galleryFloorplan, .galleryLayout {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .galleryFloorplan, .galleryLayout {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .galleryFloorplan, .galleryLayout {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Dọn margin CKEditor <p> bao ảnh */
.galleryFloorplan p, .galleryLayout p {
    margin: 0;
}

/* Tile & Image */
.galleryFloorplan .tile,
.galleryLayout .tile {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 5px;
    box-shadow: 0 3px 12px rgba(0,0,0,.08);
    background: #f6f6f6;
}

    .galleryFloorplan .tile img,
    .galleryLayout .tile img {
        display: block;
        width: 100%;
        height: auto;
        max-height: 250px;
        object-fit: cover;
        float: none !important;
        transition: transform .35s ease, filter .35s ease;
    }

    .galleryFloorplan .tile:hover img,
    .galleryLayout .tile:hover img {
        transform: scale(1.04);
        filter: brightness(1.03);
    }

/* ===== Lightbox Overlay ===== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.86);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

    .lightbox.open {
        display: flex;
    }

    /* Stage & Image */
    .lightbox .lb-stage {
        position: fixed;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        z-index: 1;
    }

        .lightbox .lb-stage img {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0.85);
            max-width: calc(100vw - 40px);
            max-height: calc(100vh - 120px);
            object-fit: contain;
            border-radius: 12px;
            box-shadow: 0 5px 24px rgba(0,0,0,.35);
            opacity: 0;
            transition: opacity .4s ease, transform .4s ease;
        }

            /* Zoom-in khi mở ảnh */
            .lightbox .lb-stage img.loaded {
                animation: zoomInCenter 0.4s ease forwards;
            }

@keyframes zoomInCenter {
    0% {
        transform: translate(-50%, -50%) scale(0.85);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Slide animation khi next/prev */
.lightbox .lb-stage img.slide-out-left {
    animation: slideOutLeft .4s forwards;
}

.lightbox .lb-stage img.slide-out-right {
    animation: slideOutRight .4s forwards;
}

.lightbox .lb-stage img.slide-in-left {
    animation: slideInLeft .4s forwards;
}

.lightbox .lb-stage img.slide-in-right {
    animation: slideInRight .4s forwards;
}

@keyframes slideOutLeft {
    to {
        transform: translate(-150%,-50%);
        opacity: 0;
    }
}

@keyframes slideOutRight {
    to {
        transform: translate(150%,-50%);
        opacity: 0;
    }
}

@keyframes slideInLeft {
    from {
        transform: translate(-150%,-50%);
        opacity: 0;
    }

    to {
        transform: translate(-50%,-50%);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translate(150%,-50%);
        opacity: 0;
    }

    to {
        transform: translate(-50%,-50%);
        opacity: 1;
    }
}

/* Spinner khi load ảnh */
.lightbox .spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Caption & Reset Zoom */
.lightbox .lb-caption {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    color: #fff;
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 6px 10px;
    background: rgba(0,0,0,.45);
    border-radius: 10px;
    max-width: 90vw;
    backdrop-filter: blur(4px);
    z-index: 3;
}

.lb-reset {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

    .lb-reset:hover {
        background: rgba(255,255,255,.3);
    }

/* Nút Close / Next / Prev */
.lightbox .lb-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    z-index: 3;
}

    .lightbox .lb-btn:hover {
        background: rgba(255,255,255,.2);
    }

.lightbox .lb-close {
    top: 16px;
    right: 16px;
    transform: none;
    font-size: 30px;
}

.lightbox .lb-prev {
    left: 16px;
}

.lightbox .lb-next {
    right: 16px;
}

/* Zoom/Pan cursors */
.lightbox .lb-stage img.can-pan {
    cursor: grab;
}

.lightbox .lb-stage img.dragging {
    cursor: grabbing;
}

/* Mobile chỉnh nhỏ hơn */
@media (max-width: 640px) {
    .lightbox .lb-btn {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .lightbox .lb-caption {
        font-size: 13px;
        padding: 5px 8px;
        bottom: 10px;
    }

    .lightbox .lb-stage img {
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 96px);
        border-radius: 10px;
    }
}
