/**
 * Media Panorama Slider KM - Styles
 * ACF-based slides with 40/40/20 layout
 */

/* Slider Section - Isolated container */
.mps-section {
    position: relative;
    width: 100%;
    z-index: 1; /* Lower than navigation */
    isolation: isolate;
    contain: layout style;
}

/* Fancybox Thumbnails - Ensure multiple thumbnails are visible */
.f-thumbs__viewport {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
}

.f-thumbs__track {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px;
    width: auto !important;
    min-width: fit-content !important;
}

.f-thumbs__slide {
    flex-shrink: 0 !important;
    width: 80px !important;
    height: 80px !important;
    min-width: 80px !important;
    min-height: 80px !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.mps {
    position: relative;
    width: 100%;
}

/* Main Slider Container */
.mps-main {
    position: relative;
    width: 100%;
    margin-bottom: 0;
    background-color: #000000; /* Black background for gap between slides */
}

.mps-main-swiper {
    width: 100%;
    height: 500px; /* Fixed height to match slide height */
    overflow: hidden; /* Clip slides that extend beyond viewport */
    background-color: #000000; /* Black background shows as gap between slides */
    position: relative; /* Ensure proper stacking context */
}

.mps-main-swiper .swiper-wrapper {
    display: flex;
    align-items: stretch;
    height: 100%; /* Ensure wrapper takes full height */
}

/* Slide Layout: Uniform width (40% desktop, 100% mobile) */
/* The "20% peek" effect is achieved by viewport clipping, not by changing slide width */
.mps-slide {
    position: relative;
    height: 500px; /* Fixed height for PC */
    min-height: 500px; /* Ensure minimum height */
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.3s ease; /* Only transition visual effects, not width */
    overflow: hidden;
    flex-shrink: 0;
    will-change: transform;
    background-color: #000000; /* Black background - will be covered by image */
    box-sizing: border-box;
    /* Uniform width: 40% on desktop (viewport shows 2 full + peek of 3rd) */
    width: 40%;
    min-width: 40%; /* Ensure minimum width */
    flex: 0 0 40%;
    /* Ensure proper stacking context for images */
    z-index: 0;
    /* Ensure slide is visible */
    visibility: visible;
    opacity: 1;
}

/* Classes is-main/is-next/is-next2 are only for styling (opacity/scale), NOT for width */
.mps-slide.is-main {
    /* Optional: subtle visual emphasis */
    opacity: 1;
}

.mps-slide.is-next {
    /* Optional: subtle visual emphasis */
    opacity: 1;
}

.mps-slide.is-next2 {
    /* Optional: subtle visual emphasis */
    opacity: 1;
}

/* Image directly in slide (matching ok.html structure) */
/* Ensure all images have the same size */
.mps-slide img {
    width: 100% !important;
    height: 100% !important;
    min-width: 100%;
    min-height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    will-change: transform;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 1; /* Above background but below overlay */
    background-color: #000000; /* Fallback if image fails to load */
    /* Force image to be visible */
    pointer-events: auto;
}

/* Video Poster */
.mps-video-poster {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%; /* Fill entire slide container */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1; /* Ensure poster is above background */
}

.mps-video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    opacity: 0.9;
}

/* Fixed Overlay (in mps-main container, shows active slide title/subtitle at bottom) */
.mps-main .mps-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 40px;
    z-index: 10;
    pointer-events: none;
    /* Ensure overlay doesn't cover images */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
}

.mps-title {
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    line-height: 1.2;
}

.mps-subtitle {
    font-size: 16px;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    line-height: 1.4;
    opacity: 0.95;
}

/* Thumbnail Strip */
.mps-thumbs {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    width: 100%;
    min-height: 80px; /* Configurable height */
}

/* Left: Thumbnails + Navigation */
.mps-thumbs-left {
    display: flex;
    align-items: center;
    gap: 0; /* No gap - nav buttons sit flush with thumbnails */
    flex: 1;
    min-width: 0; /* Allow shrinking */
    margin: 0;
    padding: 0;
}

.mps-thumbs-swiper {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-width: 0; /* Allow shrinking */
}

/* Right: "Tất cả ảnh" Button */
.mps-thumbs-right {
    flex-shrink: 0;
    margin-left: auto; /* Push to right edge */
}

.mps-thumbs-swiper .swiper-wrapper {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
  
}

/* Remove any padding/margin from swiper container */
.mps-thumbs-swiper.swiper {
    padding: 0;
    margin: 0;
    background-color: #000;
}

.mps-thumb {
    position: relative;
    width: 100px; /* Portrait thumbnail width */
    height: 100px; /* Fixed height for thumbnails */
    cursor: pointer;
    margin-right: 2px;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0.7; /* Normal state: dark overlay */
    flex-shrink: 0;
}

/* Remove margin from last thumbnail to align flush with next button */
.mps-thumbs-swiper .swiper-slide:last-child .mps-thumb {
    margin-right: 0;
}

/* Dark overlay for normal state */
.mps-thumb::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
    transition: opacity 0.3s ease;
}

/* Hover effects removed */

.mps-thumb.is-active {
    opacity: 1; /* Brightest when active */
}

.mps-thumb.is-active::before {
    background: rgba(0, 0, 0, 0.1);
}

.mps-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    position: relative;
    z-index: 0;
}

/* Video Thumbnail */
.mps-thumb-video {
    position: relative;
    width: 80px;
    height: 80px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mps-thumb-video::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
    transition: opacity 0.3s ease;
}

.mps-thumb.is-active .mps-thumb-video::before {
    background: rgba(0, 0, 0, 0.1);
}

.mps-thumb-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    opacity: 0.9;
    width: 28px;
    height: 28px;
}

.mps-thumb-play-icon svg {
    width: 100%;
    height: 100%;
}

/* "Tất cả ảnh" Button */
.mps-all {
    position: relative;
    width: 140px; /* Wider than thumbnails */
    height: 100px; /* Same height as thumbnails */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.952); /* Dark background */
    border-radius: 0; /* No border radius */
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    flex-shrink: 0;
    margin-left: auto; /* Ensure it stays at right edge */
}

/* Hover effects removed */

.mps-all i {
    color: #ffffff;
    font-size: 20px;
}

.mps-all span {
    color: #ffffff;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

/* Navigation Arrows - Inside thumbs-left container */
.mps-nav {
    position: relative;
    width: 32px;
    height: 100px; /* Same height as thumbnails */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(0, 0, 0); /* Dark background */
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0; /* No border radius */
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
}

/* Hover effects removed */

.mps-nav svg {
    width: 18px;
    height: 18px;
    color: #ffffff; /* White icon */
    display: block;
    margin: 0 auto; /* Center icon */
}

.mps-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Hover effects removed */

/* Responsive: Tablet */
@media (max-width: 1024px) {
    .mps-slide {
        height: 450px;
    }
    
    .mps-slide img,
    .mps-video-poster {
        height: 450px;
    }
    
    .mps-main .mps-overlay {
        padding: 24px 30px;
    }
    
    .mps-title {
        font-size: 24px;
    }
    
    .mps-subtitle {
        font-size: 14px;
    }
    
    .mps-thumb {
        width: 70px;
        height: 70px;
    }
    
    .mps-thumb-video {
        width: 70px;
        height: 70px;
    }
    
    .mps-all {
        width: 120px;
        height: 70px;
    }
    
    .mps-all i {
        font-size: 18px;
    }
    
    .mps-all span {
        font-size: 11px;
    }
}

/* Mobile Action Bar */
.mps-mobile-actions {
    display: none; /* Hidden on desktop */
    width: 100%;
    padding: 12px 16px;
    background-color: rgba(0, 0, 0, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mps-mobile-actions-inner {
    display: flex;
    gap: 12px;
    width: 100%;
}

.mps-mobile-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    user-select: none;
}

.mps-mobile-btn:hover,
.mps-mobile-btn:focus {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
    text-decoration: none;
}

.mps-mobile-btn:active {
    background-color: rgba(255, 255, 255, 0.15);
}

.mps-mobile-btn i {
    font-size: 16px;
}

.mps-mobile-btn.hidden {
    display: none;
}

/* Responsive: Mobile */
@media (max-width: 768px) {
    .mps-main {
        margin-bottom: 0;
    }
    
    /* Mobile: Show 1 slide at a time (uniform width, no peek) */
    .mps-slide {
        width: 100% !important;
        flex: 0 0 100% !important;
        height: 400px;
        margin-left: 0;
    }
    
    .mps-slide img,
    .mps-video-poster {
        height: 400px;
    }
    
    .mps-main .mps-overlay {
        padding: 20px 24px;
    }
    
    .mps-title {
        font-size: 20px;
        margin-bottom: 6px;
    }
    
    .mps-subtitle {
        font-size: 13px;
    }
    
    /* Hide thumbnail strip on mobile */
    .mps-thumbs {
        display: none !important;
    }
    
    /* Show mobile action bar */
    .mps-mobile-actions {
        display: block;
    }
}

/* Lightbox Gallery Styles */
.mps-lightbox-gallery {
    display: none;
}

.mps-lightbox-item {
    display: none;
}

/* Video Modal Fallback */
.mps-video-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mps-video-modal-content {
    position: relative;
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.mps-video-modal-content iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.mps-video-modal-content {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.mps-video-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

/* Fallback Gallery Modal */
.mps-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mps-gallery-modal-content {
    position: relative;
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.mps-gallery-item {
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    position: relative;
    background: #000;
}

.mps-gallery-item img,
.mps-gallery-item iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: none;
}

.mps-gallery-item img {
    object-fit: contain;
}

.mps-gallery-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    transition: all 0.3s ease;
}

.mps-gallery-close:hover {
    background: rgba(255, 255, 255, 1);
}

.mps-gallery-prev,
.mps-gallery-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    transition: all 0.3s ease;
}

.mps-gallery-prev {
    left: 20px;
}

.mps-gallery-next {
    right: 20px;
}

.mps-gallery-prev:hover,
.mps-gallery-next:hover {
    background: rgba(255, 255, 255, 1);
}

.mps-gallery-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10;
}

/* Hover effects removed */

/* Ensure Swiper doesn't interfere with layout */
.mps-main-swiper.swiper {
    margin: 0;
    padding: 0;
}

.mps-thumbs-swiper.swiper {
    margin: 0;
    padding: 0;
}
