/* ============================================================
   CROSS-BROWSER COMPATIBILITY PATCH
   Safari, Firefox, Chrome, Edge – all fixes in one file.
   Loaded after custom.css via functions.php enqueue.
   ============================================================ */

/* ── 1. SAFARI: -webkit-sticky for ALL sticky elements ────── */
.hook-details .sidebar,
.hook-checkout .checkout-right,
.hook-cart .summary,
.order-details-right {
    position: -webkit-sticky;
    position: sticky;
}

/* ── 2. SAFARI: height: fit-content not supported in old iOS ─ */
.hook-details .sidebar,
.hook-checkout .checkout-right {
    height: auto;  /* fallback */
    height: -webkit-fit-content;
    height: -moz-fit-content;
    height: fit-content;
}

/* ── 3. SAFARI/iOS: inputs – remove default appearance ──────── */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 8px; /* prevent iOS pill rounding */
}

/* Restore normal appearance for checkboxes & radios */
input[type="checkbox"],
input[type="radio"] {
    -webkit-appearance: checkbox;
    -moz-appearance: checkbox;
    appearance: auto;
}

/* ── 4. SAFARI: accent-color not supported on iOS <15.4 ─────── */
/* Fallback custom checkbox styling for lock-site & SMS toggles */
.lock-site-label input[type="checkbox"],
.sms-checkbox-label input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #3182ce;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

.lock-site-label input[type="checkbox"]:checked,
.sms-checkbox-label input[type="checkbox"]:checked {
    background: #3182ce;
    border-color: #3182ce;
}

.lock-site-label input[type="checkbox"]:checked::after,
.sms-checkbox-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

.terms-check input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid #2e7d32;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    position: relative;
    margin-top: 2px;
    transition: background 0.2s;
}

.terms-check input[type="checkbox"]:checked {
    background: #2e7d32;
}

.terms-check input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

/* ── 5. SAFARI: SMS toggle switch fix ───────────────────────── */
.sms-switch input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

/* ── 6. SAFARI: gap in flex not supported in iOS <14.5 ──────── */
/* Replace gap with margin-based fallbacks for critical flex rows */
.listing-search-bar .input-group + .input-group { margin-left: 10px; }

@supports (gap: 1px) {
    .listing-search-bar .input-group + .input-group { margin-left: 0; }
}

/* ── 7. SAFARI: justify-content: end → flex-end ─────────────── */
/* "end" is not a valid flexbox value; use "flex-end" */
.hook-listing-section .price-wrap {
    -webkit-justify-content: flex-end;
    justify-content: flex-end;
}

.listing-search-bar .button-wrap.input-group {
    -webkit-justify-content: flex-end;
    justify-content: flex-end;
    -webkit-align-items: flex-end;
    align-items: flex-end;
}

.upper_filter.equipment_lenght_filter {
    -webkit-justify-content: flex-start;
    justify-content: flex-start;
    -webkit-align-items: flex-end;
    align-items: flex-end;
}

/* ── 8. SAFARI: @keyframes slideUp needs -webkit- prefix ────── */
@-webkit-keyframes slideUp {
    from { -webkit-transform: translateY(100%); transform: translateY(100%); }
    to   { -webkit-transform: translateY(0);    transform: translateY(0); }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

#campsite-info.popup-bottom-sheet {
    -webkit-animation: slideUp 0.25s ease;
    animation: slideUp 0.25s ease;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); /* specific iPhone safe area fix */
}

/* ── 9. SAFARI: width: fit-content on qty-control ───────────── */
.qty-control {
    width: -webkit-fit-content;
    width: -moz-fit-content;
    width: fit-content;
}

/* ── 10. SAFARI: object-fit on img needs explicit dimensions ─── */
.hook-listing-section .site-image img,
.map-listing-popup-img,
#sync1 .item img,
#sync2 .item img,
.hook-cart .item-info img,
.hook-addon .addon-card img {
    -o-object-fit: cover;
    object-fit: cover;
}

/* ── 11. SAFARI: backdrop-filter needs -webkit- prefix ─────── */
.testimonial-slider .et_pb_container {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* ── 12. SAFARI: transition on border shorthand buggy ───────── */
/* Replace "border 0.3s ease" with border-color transition only */
.hook-details .gallery img {
    border: 2px solid transparent;
    -webkit-transition: border-color 0.3s ease;
    transition: border-color 0.3s ease;
}

/* ── 13. SAFARI: price-wrap justify-content (listing) ───────── */
/* "justify-content: end" is invalid in Safari — fix in style.css too */
.hook-listing-section .subheading {
    margin-bottom: 20px;
}

/* ── 14. FIREFOX: range input thumb ─────────────────────────── */
.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
    -moz-appearance: none;
    appearance: none;
}

.slider::-moz-range-track {
    background: transparent;
    height: 6px;
}

/* ── 15. EDGE/IE: flex shorthand fixes ───────────────────────── */
.hook-checkout .checkout-left  { -ms-flex: 2 1 0%; flex: 2; }
.hook-checkout .checkout-right { -ms-flex: 1 1 0%; flex: 1; }
.order-details-left            { -ms-flex: 2 1 0%; flex: 2; }
.order-details-right           { -ms-flex: 1 1 0%; flex: 1; }
.hook-cart .cart-item-listing  { -ms-flex: 1 1 0%; flex: 1; }

/* ── 16. SAFARI iOS: prevent zoom on input focus (font < 16px) ─ */
/* iOS Safari zooms when input font-size < 16px */
@media only screen and (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ── 17. SAFARI: position sticky inside overflow:hidden breaks ─ */
/* Ensure no ancestor of sticky sidebars has overflow hidden/auto */
.hook-checkout .checkout-container,
.hook-details .details-wrap,
.order-details-grid {
    overflow: visible;
}

/* ── 18. SAFARI: smooth scrolling needs -webkit- ────────────── */
html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ── 19. ALL BROWSERS: fix "align-items: end" → "flex-end" ──── */
/* "end" is not valid for align-items in flex context */
.hook-addon .cart-summary {
    -webkit-align-items: center;
    align-items: center;
}

/* ── 20. SAFARI: SVG fill/stroke transitions ─────────────────── */
#sync1 .owl-nav svg path {
    stroke: #000;
    -webkit-transition: stroke 0.3s ease;
    transition: stroke 0.3s ease;
}

#sync1 .owl-nav button:hover svg path {
    stroke: #fff;
}

/* ── 21. ALL BROWSERS: grid auto-fit minmax fallback ────────── */
/* auto-fit with minmax can behave oddly in Safari <14 */
.hook-details .capacity-list {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 1fr 1fr;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.od-info-grid {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 1fr 1fr;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* ── 22. SAFARI: button -webkit-appearance reset ─────────────── */
button,
input[type="submit"],
input[type="button"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    touch-action: manipulation; /* Faster clicks on iOS */
}

/* ── 23. SAFARI: select arrow – add custom ───────────────────── */
.checkout-grid-box-group select,
.hook-checkout .guest-info label select,
.listing-search-bar .input-wrapper select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ── 24. SAFARI: overflow:hiddens typo fix (style.css line 550) ─ */
.hook-listing-section .filter-group {
    overflow: hidden; /* was "hiddens" – typo causing layout issues */
}

/* ── 25. SAFARI: reCAPTCHA iframe scaling fix ────────────────── */
.g-recaptcha > div {
    max-width: 100%;
    overflow: hidden;
}

@media only screen and (max-width: 360px) {
    .g-recaptcha {
        -webkit-transform: scale(0.85);
        transform: scale(0.85);
        -webkit-transform-origin: 0 0;
        transform-origin: 0 0;
    }
}

/* ── 26. ACCORDION (details section expand/collapse) ─────────── */
/* Cross-browser accordion details cards */
.details-accordion-item {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 12px;
    background: #fff;
    overflow: hidden;
}

.details-accordion-header {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    background: #fff;
    border: none;
    width: 100%;
    text-align: left;
    -webkit-transition: background 0.2s;
    transition: background 0.2s;
}

.details-accordion-header:hover {
    background: #f9fafb;
}

.details-accordion-icon {
    width: 20px;
    height: 20px;
    -webkit-transition: -webkit-transform 0.3s ease;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.details-accordion-item.open .details-accordion-icon {
    -webkit-transform: rotate(180deg);
    -ms-transform: rotate(180deg);
    transform: rotate(180deg);
}

.details-accordion-body {
    display: none;
    padding: 0 20px 20px;
    font-size: 14px;
    color: #555;
    line-height: 1.7;
    border-top: 1px solid #f0f0f0;
}

.details-accordion-item.open .details-accordion-body {
    display: block;
}

/* Safari/iPad/iPhone: prevent sticky sidebar bugs on tablet/mobile */
@media only screen and (max-width: 1024px) {
    .hook-details .sidebar,
    .hook-checkout .checkout-right,
    .hook-cart .summary,
    .order-details-right {
        position: static !important;
        top: auto !important;
        height: auto !important;
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* Safari fallback for width: fit-content */
.pkg-badge,
.qty-control {
    width: auto;
    width: -webkit-fit-content;
    width: -moz-fit-content;
    width: fit-content;
}

/* iPhone/Safari: make map popup safer */
@media only screen and (max-width: 1024px) {
    #campsite-info.popup-bottom-sheet {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        z-index: 99999 !important;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -5px 25px rgba(0,0,0,0.15);
        background: #fff;
        padding-bottom: calc(25px + env(safe-area-inset-bottom, 0px)); /* Account for iPhone home indicator */
    }
}

/* ── 27. SVG Map Touch Fixes ─────────────────────────────────── */
.campsite {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    pointer-events: visiblePainted; /* Safari SVG click fix */
    touch-action: manipulation;
}

.campsite.available {
    pointer-events: all;
}

/* ── 28. Slider Edge Cases (Map) ────────────────────────────── */
.slider-container input[type="range"] {
    -webkit-tap-highlight-color: transparent;
}

/* ── 30. Owl Carousel Touch Fix ─────────────────────────────── */
/* Ensure vertical scrolling works when swiping over a carousel */
.owl-carousel,
.owl-stage-outer {
    touch-action: pan-y;
    -webkit-user-drag: none;
}

.owl-item img {
    -webkit-user-drag: none;
}

/* ── 31. iOS Form Focus Zoom Fix (Additional) ───────────────── */
/* Ensure no zoom on focus for all possible mobile browsers */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  select:focus,
  textarea:focus,
  input:focus {
    font-size: 16px !important;
  }
}

/* ── 32. Prevent horizontal overflow from fixed/absolute elements ─ */
.hook-listing-banner,
.listing-search-wrap,
.listing-grid,
.details-wrap,
.checkout-container,
.addons-grid {
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

/* Ensure no 100vw elements cause horizontal scroll */
.full-width-section {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* ── 33. Tooltip Mobile Active State ────────────────────────── */
@media (max-width: 1024px) {
    .tooltip-wrap.active .tooltip-content {
        visibility: visible !important;
        opacity: 1 !important;
        bottom: 125% !important;
        pointer-events: auto !important;
    }
}