/**
 * Palace Tours Display - Final Merged Fixes v21.1.14
 * v21.1.13: Scoped overflow + Card wrap + Itinerary + Maps.
 * v21.1.14: Restored html/body overflow-x:hidden from v21.1.11 (white space fix).
 */

/* --- 1. HEADER & MENU PROTECTION --- */
.elementor-location-header,
.elementor-nav-menu--dropdown,
.elementor-menu-toggle,
#header_pop {
    z-index: 10000 !important;
}

/* --- 2. WHITE SPACE PROTECTION --- */
/* Global kill — this was in v21.1.11 and worked. v21.1.13 scoped version missed edge cases. */
@media (max-width: 960px) {
    html, body {
        overflow-x: hidden !important;
        position: relative !important;
        width: 100% !important;
    }

    .elementor-section, .e-con, .e-con-inner {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .e-con:has(.ptd-tour-container),
    .e-con-inner:has(.ptd-tour-container),
    .elementor-section:has(.ptd-tour-container) {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .ptd-tour-container {
        width: 100% !important;
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }
}

/* --- 3. GOLD BAR ALIGNMENT & Z-INDEX --- */
@media (max-width: 768px) {
    body .ptd-mobile-sticky-header {
        z-index: 998 !important; 
        position: fixed !important;
        top: var(--ptd-sticky-offset, 60px) !important;
        background: #c9a227 !important;
        height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }

    body .ptd-sticky-wrapper.is-stuck {
        z-index: 997 !important;
    }
}

/* --- 4. ITINERARY: MOBILE GRID & TEXT WRAPPING --- */
@media (max-width: 767px) {
    body .ptd-tour-container .ptd-ge-day {
        display: block !important;
        width: 100% !important;
        grid-template-columns: none !important;
        border-bottom: 1px solid #eee !important;
    }

    body .ptd-tour-container .ptd-ge-day-image-col {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16 / 9 !important;
        max-height: 250px !important;
    }

    body .ptd-tour-container .ptd-ge-day-text-col {
        width: 100% !important;
        min-height: 1px !important;
        padding: 15px !important;
    }

    body .ptd-tour-container .ptd-ge-day-content p,
    body .ptd-tour-container .ptd-day-content p,
    body .ptd-tour-container .ptd-ge-day-content li {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
        line-height: 1.7 !important;
    }
}

/* --- 5. CATEGORY CARD: TEXT WRAPPING --- */
.ptd-tour-card {
    min-width: 0 !important;
}

.ptd-tour-card-title,
.ptd-tour-card-cities,
.ptd-tour-card-excerpt {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
}

.ptd-tour-card-cities {
    display: flex !important;
    flex-wrap: wrap !important;
}

/* --- 6. GOOGLE MAPS & GALLERY --- */
body .ptd-route-map {
    width: 100% !important;
    height: 350px !important;
    display: block !important;
}

.gm-style img {
    max-width: none !important;
}

/* ===================================
   Mobile Gallery & Carousel Fixes
   =================================== */
@media (max-width: 768px) {
    /* Universal Smart Crop for Gallery Cards */
    body .ptd-tour-container .ptd-gallery {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }
    body .ptd-tour-container .ptd-gallery-item,
    .ptd-gallery-item {
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    body .ptd-tour-container .ptd-gallery-link,
    .ptd-gallery-link {
        width: 100% !important;
        aspect-ratio: 1 / 1 !important;
        overflow: hidden !important;
        display: block !important;
        border-radius: 8px !important;
        background: #f8f8f8 !important;
        line-height: 0 !important;
        font-size: 0 !important;
    }
    body .ptd-tour-container .ptd-gallery-link img,
    .ptd-gallery-link img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }
    /* Title below the cropped image */
    body .ptd-tour-container .ptd-gallery-caption,
    .ptd-gallery-caption,
    .ptd-gallery-title {
        display: block !important;
        padding: 8px 4px !important;
        text-align: center !important;
        font-size: 12px !important;
        line-height: 1.3 !important;
        min-height: 2.6em !important;
        margin: 0 !important;
    }

    /* Hide carousel arrows on mobile for cleaner look */
    body .ptd-tour-container .ptd-banner-nav,
    .ptd-banner-nav,
    .ptd-v2-hero-nav button,
    .ptd-hero-prev,
    .ptd-hero-next {
        display: none !important;
    }
    /* Keep dots visible for orientation */
    .ptd-banner-dots,
    .ptd-v2-hero-counter {
        bottom: 15px !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}
