/**
 * Property Gallery Slider Styles
 * @package IntelliRealty
 * @version 2.0.0
 */

/* ============================================
   GALLERY CONTAINER
   ============================================ */
.ir-property-gallery-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 0;
}

/* Desktop: side-by-side layout */
@media (min-width: 769px) {
    .ir-property-gallery-container {
        display: flex;
        gap: 12px;
    }
}

/* ============================================
   GALLERY SLIDER
   ============================================ */
.ir-gallery-slider {
    position: relative;
    width: 100%;
    min-height: 650px;
    overflow: hidden;
}

@media (min-width: 769px) {
    .ir-gallery-slider {
        flex: 1;
        min-width: 0;
    }
}

.ir-gallery-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 650px;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
}

.ir-gallery-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.ir-gallery-slide img {
    width: 100%;
    height: 100%;
    min-height: 650px;
    object-fit: cover;
    cursor: pointer;
    display: block;
    border-radius: 30px;
}

/* ============================================
   NAVIGATION ARROWS
   ============================================ */
.ir-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.ir-gallery-arrow:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: translateY(-50%) scale(1.1);
}

.ir-gallery-prev {
    left: 20px;
}

.ir-gallery-next {
    right: 20px;
}

.ir-gallery-arrow svg {
    display: block;
}

/* ============================================
   IMAGE COUNTER
   ============================================ */
.ir-gallery-counter {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    z-index: 10;
    letter-spacing: 0.5px;
}

/* ============================================
   THUMBNAIL STRIP
   ============================================ */
.ir-gallery-thumbnails {
    position: relative;
    width: 100%;
    margin-top: 12px;
    overflow: hidden;
    padding: 0 44px;
    box-sizing: border-box;
}

.ir-gallery-thumbnails-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 4px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x mandatory;
}

.ir-gallery-thumbnails-track::-webkit-scrollbar {
    display: none;
}

.ir-gallery-thumb {
    /* Exactly 5 per row: (100% - 4 gaps of 10px) / 5 */
    flex: 0 0 calc((100% - 40px) / 5);
    aspect-ratio: 3 / 2;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    padding: 0;
    background: none;
    opacity: 0.5;
    transition: all 0.3s ease;
    position: relative;
    scroll-snap-align: start;
}

.ir-gallery-thumb:hover {
    opacity: 0.85;
}

.ir-gallery-thumb.active {
    opacity: 1;
    border-color: #2563eb;
    box-shadow: 0 0 0 1px #2563eb;
}

.ir-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 11px;
}

/* Thumbnail slider arrows */
.ir-thumb-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    padding: 0;
}

.ir-thumb-arrow:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.ir-thumb-arrow.hidden {
    opacity: 0;
    pointer-events: none;
}

.ir-thumb-arrow-prev {
    left: 2px;
}

.ir-thumb-arrow-next {
    right: 2px;
}

/* ============================================
   DESKTOP: VERTICAL THUMBNAILS ON RIGHT
   ============================================ */
@media (min-width: 769px) {
    .ir-gallery-thumbnails {
        width: 160px;
        flex-shrink: 0;
        margin-top: 0;
        padding: 40px 0;
        height: 650px;
        max-height: 650px;
    }

    .ir-gallery-thumbnails-track {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        height: calc(650px - 80px);
        gap: 8px;
        padding: 0 4px;
        scroll-snap-type: y mandatory;
    }

    .ir-gallery-thumb {
        /* Exactly 5 visible: (track height - 4 gaps of 8px) / 5 */
        flex: 0 0 calc((100% - 32px) / 5);
        width: 100%;
        border-radius: 10px;
        scroll-snap-align: start;
    }

    .ir-gallery-thumb img {
        border-radius: 7px;
    }

    /* Arrows become top/bottom for vertical scroll */
    .ir-thumb-arrow {
        top: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    .ir-thumb-arrow:hover {
        transform: translateX(-50%) scale(1.1);
    }

    .ir-thumb-arrow-prev {
        top: 0;
        left: 50%;
    }

    .ir-thumb-arrow-next {
        bottom: 0;
        top: auto;
        left: 50%;
        right: auto;
    }

    /* Rotate arrow SVGs for vertical direction */
    .ir-thumb-arrow-prev svg {
        transform: rotate(90deg);
    }

    .ir-thumb-arrow-next svg {
        transform: rotate(90deg);
    }
}

/* ============================================
   LIGHTBOX MODAL
   ============================================ */
.ir-gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.ir-gallery-modal.active {
    display: block;
}

.ir-gallery-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
}

.ir-gallery-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 90vh;
    z-index: 10000;
}

.ir-gallery-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: block;
}

.ir-gallery-modal-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10001;
}

.ir-gallery-modal-close:hover {
    transform: scale(1.2);
}

.ir-gallery-modal-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10001;
}

.ir-gallery-modal-arrow:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.ir-gallery-modal-prev {
    left: 20px;
}

.ir-gallery-modal-next {
    right: 20px;
}

/* ============================================
   VIDEO PLAY BUTTON ON FIRST SLIDE
   ============================================ */
.ir-gallery-video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: none;
    border: none;
    cursor: pointer;
    z-index: 5;
    padding: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.ir-gallery-video-play svg {
    width: 68px;
    height: 68px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.ir-gallery-video-play:hover {
    transform: translate(-50%, -50%) scale(1.12);
}

/* ============================================
   VIDEO MODAL
   ============================================ */
.ir-gallery-video-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.ir-gallery-video-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ir-gallery-video-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
}

.ir-gallery-video-modal-content {
    position: relative;
    width: 90vw;
    max-width: 960px;
    z-index: 10001;
}

.ir-gallery-video-modal-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.ir-gallery-video-modal-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.ir-gallery-video-modal-close {
    position: absolute;
    top: -48px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 36px;
    font-weight: 300;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    z-index: 10002;
}

.ir-gallery-video-modal-close:hover {
    transform: scale(1.2);
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 768px) {
    .ir-gallery-video-play svg {
        width: 54px;
        height: 54px;
    }

    .ir-gallery-video-modal-content {
        width: 95vw;
    }

    .ir-gallery-video-modal-close {
        top: -40px;
        font-size: 30px;
    }

    .ir-property-gallery-container {
        display: block;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    .ir-gallery-slider,
    .ir-gallery-slide {
        min-height: 300px;
        width: 100%;
    }

    .ir-gallery-slide img {
        min-height: 300px;
        width: 100%;
        border-radius: 30px;
        object-fit: cover;
    }

    .ir-gallery-arrow {
        width: 40px;
        height: 40px;
    }

    .ir-gallery-prev {
        left: 15px;
    }

    .ir-gallery-next {
        right: 15px;
    }

    .ir-gallery-arrow svg {
        width: 20px;
        height: auto;
    }

    .ir-gallery-counter {
        bottom: 15px;
        right: 15px;
        font-size: 12px;
        padding: 4px 10px;
    }

    /* Thumbnails: back to horizontal on tablet/mobile */
    .ir-gallery-thumbnails {
        width: 100%;
        margin-top: 8px;
        padding: 0 38px;
        max-height: none;
    }

    .ir-gallery-thumbnails-track {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none;
        gap: 6px;
        scroll-snap-type: x mandatory;
    }

    .ir-gallery-thumb {
        /* 3 per row on tablet: (100% - 2 gaps of 6px) / 3 */
        flex: 0 0 calc((100% - 12px) / 3);
        border-radius: 10px;
        border-width: 2px;
    }

    .ir-gallery-thumb img {
        border-radius: 8px;
    }

    /* Thumb arrows back to horizontal */
    .ir-thumb-arrow {
        top: 50%;
        left: auto;
        bottom: auto;
        transform: translateY(-50%);
        width: 30px;
        height: 30px;
    }

    .ir-thumb-arrow:hover {
        transform: translateY(-50%) scale(1.1);
    }

    .ir-thumb-arrow-prev {
        left: 2px;
    }

    .ir-thumb-arrow-next {
        right: 2px;
        left: auto;
    }

    .ir-thumb-arrow-prev svg,
    .ir-thumb-arrow-next svg {
        transform: none;
    }

    /* Modal fixes for mobile */
    .ir-gallery-modal-content {
        max-width: 100vw;
        width: 100%;
        padding: 0 10px;
        box-sizing: border-box;
    }

    .ir-gallery-modal-content img {
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: 80vh;
    }

    .ir-gallery-modal-arrow {
        width: 45px;
        height: 45px;
    }

    .ir-gallery-modal-arrow svg {
        width: 20px;
        height: auto;
    }

    .ir-gallery-modal-prev {
        left: 10px;
    }

    .ir-gallery-modal-next {
        right: 10px;
    }

    .ir-gallery-modal-close {
        top: -40px;
        font-size: 30px;
        width: 40px;
        height: 40px;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 480px) {
    .ir-property-gallery-container {
        width: 100% !important;
        max-width: 100vw;
    }

    .ir-gallery-slider,
    .ir-gallery-slide {
        min-height: 250px;
    }

    .ir-gallery-slide img {
        min-height: 250px;
        border-radius: 20px;
    }

    .ir-gallery-arrow {
        width: 36px;
        height: 36px;
    }

    .ir-gallery-prev {
        left: 10px;
    }

    .ir-gallery-next {
        right: 10px;
    }

    .ir-gallery-counter {
        bottom: 12px;
        right: 12px;
        font-size: 11px;
        padding: 3px 8px;
    }

    /* Thumbnails */
    .ir-gallery-thumbnails {
        margin-top: 6px;
        padding: 0 34px;
    }

    .ir-gallery-thumb {
        /* 3 per row on mobile: (100% - 2 gaps of 5px) / 3 */
        flex: 0 0 calc((100% - 10px) / 3);
        border-radius: 8px;
        border-width: 2px;
    }

    .ir-gallery-thumb img {
        border-radius: 6px;
    }

    .ir-gallery-thumbnails-track {
        gap: 5px;
    }

    .ir-thumb-arrow {
        width: 26px;
        height: 26px;
    }

    /* Modal on small phones */
    .ir-gallery-modal-content {
        padding: 0 5px;
    }

    .ir-gallery-modal-content img {
        width: 100%;
        border-radius: 10px;
    }
}
