/**
 * Hotel Card Gallery Styles
 * 
 * Styles for hotel gallery carousels in booking flow cards
 * Optimized for performance and mobile responsiveness
 */

/* Ensure parent container constrains the gallery - More specific selectors */
.img-link .colimg,
.available-hotel .colimg,
.hotel-col .colimg {
    overflow: hidden !important;
    position: relative !important;
    /* Don't override width/height - let theme handle sizing */
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    background: transparent !important;
}

/* Override theme image styles for gallery containers */
.colimg .hotel-card-gallery {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 1 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    background: transparent !important;
}

/* Override theme img styles specifically for gallery images */
.colimg .hotel-card-gallery img,
.colimg .gallery-current-image {
    aspect-ratio: unset !important;
    max-width: none !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    display: block !important;
}

/* Let theme handle sizing - don't override aspect ratios */

/* Hotel Card Gallery Container */
.hotel-card-gallery {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    background: transparent;
    border-radius: inherit;
}

/* Gallery Main Image Container */
.gallery-main-image {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
    background: transparent;
    border-radius: inherit;
}

/* Theme handles all sizing - no fallbacks needed */

.gallery-current-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: opacity 0.3s ease;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: inherit;
}

/* Navigation Buttons - More specific targeting */
.colimg .hotel-card-gallery .gallery-nav-buttons,
.img-link .colimg .gallery-nav-buttons,
.available-hotel .colimg .gallery-nav-buttons {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 12px !important;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 20 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
}

.colimg .hotel-card-gallery:hover .gallery-nav-buttons,
.colimg .gallery-main-image:hover .gallery-nav-buttons,
.img-link .colimg:hover .gallery-nav-buttons,
.available-hotel .colimg:hover .gallery-nav-buttons {
    opacity: 1 !important;
    pointer-events: none !important;
}

/* Only the actual buttons should be clickable */
.colimg .hotel-card-gallery:hover .gallery-nav-prev,
.colimg .hotel-card-gallery:hover .gallery-nav-next,
.colimg .gallery-main-image:hover .gallery-nav-prev,
.colimg .gallery-main-image:hover .gallery-nav-next,
.img-link .colimg:hover .gallery-nav-prev,
.img-link .colimg:hover .gallery-nav-next,
.available-hotel .colimg:hover .gallery-nav-prev,
.available-hotel .colimg:hover .gallery-nav-next {
    pointer-events: auto !important;
}

.gallery-nav-prev,
.gallery-nav-next {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    border: 2px solid rgba(255, 255, 255, 0.8);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    pointer-events: auto;
}

.gallery-nav-prev:hover,
.gallery-nav-next:hover {
    background: white;
    border-color: white;
    transform: scale(1.15);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    color: #000;
}

.gallery-nav-prev:active,
.gallery-nav-next:active {
    transform: scale(0.95);
}

/* Better arrow symbols */
.gallery-nav-prev::before {
    content: "‹";
    margin-right: 2px;
    line-height: 1;
}

.gallery-nav-next::before {
    content: "›";
    margin-left: 2px;
    line-height: 1;
}

/* Hide arrows when only one image */
.hotel-card-gallery[data-image-count="1"] .gallery-nav-buttons {
    display: none;
}

/* AGGRESSIVE SPACING ELIMINATION - Target the cyan border issue */

/* Nuclear option: Eliminate ALL possible spacing sources */
.img-link .colimg,
.available-hotel .colimg,
.hotel-col .colimg,
.colimg .hotel-card-gallery,
.gallery-main-image,
.gallery-current-image {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    vertical-align: top !important;
    line-height: 0 !important;
}

/* Revert to normal sizing - negative margins made it worse */
.gallery-current-image {
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
}

/* Override any theme styles that might add spacing */
.img-link .colimg *,
.available-hotel .colimg *,
.hotel-col .colimg * {
    box-sizing: border-box !important;
}

/* FIX: Ensure hotel card images inherit border-radius from container */
.img-link .colimg,
.available-hotel .colimg,
.hotel-col .colimg {
    background: transparent !important;
    border-radius: 30px 30px 0 0 !important; /* Match container border-radius for top corners */
}

.colimg .hotel-card-gallery,
.gallery-main-image {
    background: transparent !important;
    border-radius: 30px 30px 0 0 !important; /* Match container border-radius for top corners */
}

.gallery-current-image {
    border-radius: 30px 30px 0 0 !important; /* Match container border-radius for top corners */
}

/* Eliminate any pseudo-element spacing */
.img-link .colimg::after,
.available-hotel .colimg::after,
.hotel-col .colimg::after,
.hotel-card-gallery::before,
.hotel-card-gallery::after,
.gallery-main-image::before,
.gallery-main-image::after {
    display: none !important;
    content: none !important;
}

/* Image Counter */
.gallery-counter {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    z-index: 22;
}

/* Hidden gallery data elements */
.gallery-data {
    display: none !important;
}

/* Performance Optimizations */
.gallery-current-image[loading="lazy"] {
    background: #f0f0f0;
    min-height: 200px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    /* Fix mobile image display issues */
    .img-link .colimg,
    .available-hotel .colimg,
    .hotel-col .colimg {
        min-height: 150px !important;
        height: auto !important;
        display: block !important;
    }
    
    .colimg .hotel-card-gallery,
    .gallery-main-image {
        min-height: 150px !important;
        height: auto !important;
    }
    
    .gallery-current-image,
    .colimg img {
        width: 100% !important;
        height: auto !important;
        min-height: 150px !important;
        object-fit: cover !important;
        display: block !important;
    }
    
    .gallery-nav-buttons {
        opacity: 1;
        pointer-events: auto;
    }
    
    .gallery-nav-prev,
    .gallery-nav-next {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .gallery-thumbnails {
        opacity: 1;
    }
    
    .gallery-thumb {
        width: 20px;
        height: 15px;
    }
    
    .gallery-counter {
        font-size: 10px;
        padding: 3px 6px;
        border-radius: 10px;
    }
}

@media (max-width: 480px) {
    /* Enhanced mobile image fixes for very small screens */
    .img-link .colimg,
    .available-hotel .colimg,
    .hotel-col .colimg {
        min-height: 120px !important;
    }
    
    .colimg .hotel-card-gallery,
    .gallery-main-image {
        min-height: 120px !important;
    }
    
    .gallery-current-image,
    .colimg img {
        min-height: 120px !important;
    }
    
    .gallery-nav-buttons {
        padding: 0 4px;
    }
    
    .gallery-nav-prev,
    .gallery-nav-next {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
    
    .gallery-counter {
        bottom: 4px;
        right: 4px;
        font-size: 9px;
        padding: 2px 5px;
        border-radius: 8px;
    }
}

/* Additional fix for mobile container padding issues */
@media (max-width: 600px) {
    .row.products-grid.grid-view.grid-container .product.hotel-col {
        margin-bottom: 15px !important;
    }
    
    .row.products-grid.grid-view.grid-container .product.hotel-col .img-link .colimg {
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .gallery-nav-buttons {
        opacity: 1;
        pointer-events: auto;
    }
    
    .gallery-nav-prev,
    .gallery-nav-next {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
    }
}

/* High Performance Mode */
@media (prefers-reduced-motion: reduce) {
    .gallery-current-image,
    .gallery-nav-buttons,
    .gallery-thumbnails,
    .gallery-thumb {
        transition: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .gallery-counter {
        background: rgba(255, 255, 255, 0.2);
        color: white;
    }
    
    .gallery-thumb {
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .gallery-thumb.active {
        border-color: rgba(255, 255, 255, 0.8);
    }
}

/* Loading States */
.gallery-current-image.loading {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-current-image.loaded {
    opacity: 1;
}

/* Smooth fade transition for image changes */
.gallery-current-image {
    transition: opacity 0.3s ease;
}

.gallery-current-image.fade-in {
    opacity: 1;
}

/* Accessibility */
.gallery-nav-prev:focus,
.gallery-nav-next:focus,
.gallery-thumb:focus {
    outline: 2px solid #4F46E5;
    outline-offset: 2px;
}

/* Animation for smooth transitions */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gallery-current-image.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Prevent layout shift during image loading */
.hotel-card-gallery::before {
    content: '';
    display: block;
    width: 100%;
    height: 0;
    padding-bottom: 60%; /* 5:3 aspect ratio */
    position: absolute;
    top: 0;
    left: 0;
    background: #f0f0f0;
    z-index: -1;
}

/* Override for existing hotel card styles */
.gdlr-hotel-room-item .hotel-card-gallery {
    border-radius: inherit;
}

.gdlr-hotel-room-item .hotel-card-gallery .gallery-main-image {
    border-radius: inherit;
}

/* Ensure gallery works within existing hotel card containers */
.hotel-item .hotel-card-gallery,
.room-item .hotel-card-gallery,
.gdlr-hotel-room-item .hotel-card-gallery {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Performance: GPU acceleration for smooth animations */
.gallery-current-image,
.gallery-nav-prev,
.gallery-nav-next,
.gallery-thumb {
    will-change: transform, opacity;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Ensure proper stacking context */
.hotel-card-gallery {
    z-index: 1;
}

.gallery-nav-buttons,
.gallery-counter,
.gallery-thumbnails {
    z-index: 10;
}

/* Hover effects for better UX */
.hotel-card-gallery:hover .gallery-current-image {
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

/* Prevent text selection on gallery controls */
.gallery-nav-buttons,
.gallery-counter,
.gallery-thumbnails {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Room Gallery Integration Styles */
.gdlr-hotel-room-item .room-booking-gallery,
.room-item .room-booking-gallery {
    margin: 15px 0;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.gdlr-hotel-room-item .room-booking-gallery:hover,
.room-item .room-booking-gallery:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.gdlr-hotel-room-item .room-booking-gallery .room-gallery-main-image,
.room-item .room-booking-gallery .room-gallery-main-image {
    border-radius: 12px;
    overflow: hidden;
    background: #f8f9fa;
}

.gdlr-hotel-room-item .room-booking-gallery .main-gallery-image,
.room-item .room-booking-gallery .main-gallery-image {
    width: 100% !important;
    height: auto !important;
    max-height: 250px !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    transition: transform 0.3s ease;
}

.gdlr-hotel-room-item .room-booking-gallery:hover .main-gallery-image,
.room-item .room-booking-gallery:hover .main-gallery-image {
    transform: scale(1.02);
}

/* Room Gallery Thumbnails */
.gdlr-hotel-room-item .room-booking-gallery .room-gallery-thumbnails,
.room-item .room-booking-gallery .room-gallery-thumbnails {
    padding: 8px 0 0 0;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.gdlr-hotel-room-item .room-booking-gallery .room-gallery-thumbnails::-webkit-scrollbar,
.room-item .room-booking-gallery .room-gallery-thumbnails::-webkit-scrollbar {
    display: none;
}

.gdlr-hotel-room-item .room-booking-gallery .gallery-thumbnail,
.room-item .room-booking-gallery .gallery-thumbnail {
    width: 44px !important;
    height: 33px !important;
    border-radius: 4px !important;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.gdlr-hotel-room-item .room-booking-gallery .gallery-thumbnail:hover,
.room-item .room-booking-gallery .gallery-thumbnail:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.gdlr-hotel-room-item .room-booking-gallery .gallery-thumbnail.active,
.room-item .room-booking-gallery .gallery-thumbnail.active {
    border-color: #059669 !important;
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2) !important;
}

.gdlr-hotel-room-item .room-booking-gallery .gallery-more-indicator,
.room-item .room-booking-gallery .gallery-more-indicator {
    min-width: 44px !important;
    height: 33px !important;
    font-size: 9px !important;
    border-radius: 4px;
}

/* Room Gallery Navigation in Card Context */
.gdlr-hotel-room-item .room-booking-gallery .gallery-nav,
.room-item .room-booking-gallery .gallery-nav {
    background: rgba(0, 0, 0, 0.6) !important;
    width: 30px !important;
    height: 30px !important;
    font-size: 14px !important;
    border-radius: 50% !important;
    transition: all 0.2s ease;
    border: none !important;
}

.gdlr-hotel-room-item .room-booking-gallery .gallery-nav:hover,
.room-item .room-booking-gallery .gallery-nav:hover {
    background: rgba(0, 0, 0, 0.8) !important;
    transform: scale(1.05);
}

/* Room Gallery Counter */
.gdlr-hotel-room-item .room-booking-gallery .gallery-counter,
.room-item .room-booking-gallery .gallery-counter {
    background: rgba(0, 0, 0, 0.75) !important;
    padding: 2px 6px !important;
    font-size: 10px !important;
    border-radius: 8px !important;
    bottom: 6px !important;
    right: 6px !important;
}

/* Mobile optimizations for room galleries in cards */
@media (max-width: 768px) {
    .gdlr-hotel-room-item .room-booking-gallery .main-gallery-image,
    .room-item .room-booking-gallery .main-gallery-image {
        max-height: 200px !important;
    }
    
    .gdlr-hotel-room-item .room-booking-gallery .gallery-thumbnail,
    .room-item .room-booking-gallery .gallery-thumbnail {
        width: 38px !important;
        height: 29px !important;
    }
    
    .gdlr-hotel-room-item .room-booking-gallery .gallery-nav,
    .room-item .room-booking-gallery .gallery-nav {
        width: 26px !important;
        height: 26px !important;
        font-size: 12px !important;
    }
}
