/* ==========================================================================
   UNIT DETAIL PAGE — Page-specific styles only.
   Load order: design.css → shared.css → photoswipe.css → components/unit-sections.css → unit-detail.css
   The top section and the tabs are styled in components/unit-sections.css, which the booking
   detail in My account loads too.
   Classes that already exist in shared.css (.sheet, .p-card, .btn-ico, .btn-cta,
   .price-val, .price-old, .card-wish, etc.) are NOT redefined here.
   ========================================================================== */

/* ── Main wrapper ────────────────────────────────────────────────────────── */
/* Room under the page for the fixed bottom bar, so the last content is never hidden behind it. The
   bar shows below 992px; --ud-mob-bar-h is its height (taller once it wraps, below 575px). */
@media (max-width: 575.98px) {
  .page-content main { padding-top: 0px; }
  .ud-main { padding-bottom: calc(var(--ud-mob-bar-h, 76px) + env(safe-area-inset-bottom, 0px)); }
}

/* ── Breadcrumb — Bootstrap's own markup; the look (.landing-breadcrumb) is in shared.css ───── */
.ud-breadcrumb-nav { padding-bottom: 14px; }

/* ── Gallery: full-width CSS Grid mosaic ─────────────────────────────────── */
.ud-gallery {
  margin-bottom: 28px;
  border-radius: 20px; overflow: hidden;
}

/* Mobile (< 768px): single hero image */
.ud-gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 260px;
  gap: 4px;
  background: var(--color-surface-2);
  border-radius: 20px; overflow: hidden;
  position: relative;
}

/* Tablet (≥ 768px): hero left + 2-column stack right */
@media (min-width: 768px) {
  .ud-gallery-grid {
    grid-template-columns: 3fr 2fr;
    grid-template-rows: 220px 220px;
    height: 444px; /* 2 × 220 + 4px gap */
  }
}

/* Desktop (≥ 992px): hero left + 2×2 grid right (5-image mosaic) */
@media (min-width: 992px) {
  .ud-gallery-grid {
    grid-template-columns: 3fr 1fr 1fr;
    grid-template-rows: 230px 230px;
    height: 464px;
  }
}

/* Hero image — spans both rows on tablet+ */
.ud-gallery-hero {
  grid-column: 1;
  grid-row: 1;
}
@media (min-width: 768px) {
  .ud-gallery-hero { grid-row: 1 / 3; }
}

/* Thumb slots */
.ud-gallery-thumb { display: none; }
@media (min-width: 768px) {
  .ud-gallery-thumb { display: block; }
  /* On tablet: show only first 2 thumbs in right column */
  .ud-gallery-thumb:nth-child(n+4) { display: none; }
}
@media (min-width: 992px) {
  /* Desktop: show all 4 thumbs in 2-col 2-row right grid */
  .ud-gallery-thumb { display: block; }
  .ud-gallery-thumb:nth-child(n+4) { display: block; }
}

/* All gallery images fill their cell */
.ud-gallery-hero img,
.ud-gallery-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.ud-gallery-hero,
.ud-gallery-thumb {
  position: relative; overflow: hidden;
  background: var(--color-surface-2);
}
/* Hover zoom on desktop */
@media (min-width: 992px) {
  .ud-gallery-hero img,
  .ud-gallery-thumb img {
    transition: transform .5s ease;
  }
  .ud-gallery-hero:hover img,
  .ud-gallery-thumb:hover img { transform: scale(1.04); }
}

/* "عرض جميع الصور" button — absolute over last thumb */
.ud-gallery-view-all {
  position: absolute;
  bottom: 14px; inset-inline-end: 14px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 10px; padding: 8px 16px;
  font-size: .88rem; font-weight: 700;
  color: var(--color-primary); cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, box-shadow .15s;
  z-index: 3;
}
.ud-gallery-view-all:hover { background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.12); }

/* Gallery cells are divs with role="button" — need explicit cursor */
.ud-gallery-hero,
.ud-gallery-thumb { cursor: pointer; }

/* ── Mobile gallery slider (< 768px) ────────────────────────────────────── */
.ud-gallery-mobile {
  position: relative; border-radius: 16px; overflow: hidden;
  margin-bottom: 28px; background: var(--color-surface-2);
}
.ud-gallery-mobile .swiper { height: 290px; }
.ud-gallery-mobile .swiper-wrapper { height: 100%; }
.ud-gallery-mobile .swiper-slide {
  overflow: hidden; height: 100%;
}
.ud-gallery-mobile .swiper-slide img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .3s ease;
}
.ud-gallery-mobile .swiper-slide:active img { transform: scale(.97); }
.ud-gallery-mobile .swiper .swiper-pagination-bullet { background: #fff; opacity: .6; }
.ud-gallery-mobile .swiper .swiper-pagination-bullet-active { background: #fff; opacity: 1; }

/* View all button for mobile slider */
.ud-gallery-view-all--mob {
  position: absolute; bottom: 10px; inset-inline-end: 12px;
  z-index: 5;
}
/* Hide/show gallery sections by breakpoint */
@media (max-width: 767.98px) { .ud-gallery-grid { display: none !important; } }
@media (min-width: 768px)    { .ud-gallery-mobile { display: none; } }

/* ── Similar properties — full-width section outside the content row ──────── */
/* Section lives in its own .container-xl directly in <main>, so no max-width needed */
.ud-similar { padding-block: 32px; border-top: 1px solid var(--color-border); }
.ud-similar[hidden] { display: none !important; }

/* While new cards are on their way (the guest changed the dates), the old ones fade and ignore taps. */
.ud-similar.is-refreshing .carousel { opacity: .45; pointer-events: none; transition: opacity .15s; }

/* Similar carousel nav arrows — disabled & hidden states */
/* Disabled: at first/last slide — Swiper adds 'is-disabled' (disabledClass in JS) */
.car-arrow.is-disabled {
  opacity: .28;
  cursor: not-allowed;
  pointer-events: none;
}
/* Hidden: when all slides fit (watchOverflow locked) */
.car-arrow.is-hidden { visibility: hidden; pointer-events: none; }

/* Similar cards: Swiper on all sizes */
.ud-similar-swiper { overflow: visible; }
/* Slides per view and gaps by screen width, as the .car-auto rule in shared.css sizes them:
   1.15 on a phone, then 2, 2.5, 3 and 3.5. */
.ud-similar-swiper { --car-per-view: 1.15; --car-gap: 16px; }
@media (min-width: 480px) { .ud-similar-swiper { --car-per-view: 2; } }
@media (min-width: 575px) { .ud-similar-swiper { --car-per-view: 2.5; } }
@media (min-width: 768px) { .ud-similar-swiper { --car-per-view: 3; --car-gap: 18px; } }
@media (min-width: 992px) { .ud-similar-swiper { --car-per-view: 3.5; } }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.ud-sidebar-wrap { position: relative; }

@media (min-width: 992px) {
  .ud-sidebar-wrap {
    position: sticky;
    /* navbar is sticky (not fixed) so top is just the navbar height + gap */
    top: calc(var(--tnav-h, 64px) + 20px);
    max-height: calc(100vh - var(--tnav-h, 64px) - 40px);
    overflow-y: auto;
    scrollbar-width: none;
  }
  .ud-sidebar-wrap::-webkit-scrollbar { display: none; }

}

.ud-sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: 20px;
  padding: 18px 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}

/* Price header: price stack on inline-start, discount badge on inline-end (opposite side) */
.uds-price-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.uds-price-stack { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
/* Row 1: slashed original price */
.uds-price-meta { display: flex; align-items: center; gap: 8px; }
.uds-price-old  { font-size: .94rem; color: var(--color-text-secondary); text-decoration: line-through; }
/* Discount badge — prominent pill on the opposite side from the price stack */
/* Colours and shape come from the unit card's own .card-offer-tag, so a discount reads the same
   everywhere on the site. */
.uds-discount-badge { font-size: 1.2rem; flex-shrink: 0; }
/* Row 2: large current price */
.uds-price-main { display: flex; align-items: baseline; gap: 6px; }
.uds-price-val  { font-size: 1.85rem; font-weight: 900; color: var(--color-primary); line-height: 1; }
.uds-price-unit { font-size: .9rem; color: var(--color-text-secondary); }

/* Dates clickable area in sidebar */
.uds-dates {
  display: flex; align-items: stretch; gap: 0;
  border: 1.5px solid var(--color-border); border-radius: 14px;
  margin-top: 14px;
  cursor: pointer; transition: border-color .15s; position: relative;
}
.uds-dates:hover { border-color: var(--color-accent); }
.uds-dates-cell {
  flex: 1; padding: 10px 12px; display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer; font-family: inherit; text-align: start;
}
.uds-dates-cell + .uds-dates-cell { border-inline-start: 1px solid var(--color-border); }
.uds-dates-ic   { color: var(--color-accent); font-size: .9rem; flex-shrink: 0; }
.uds-dates-inner { display: flex; flex-direction: column; gap: 1px; }
.uds-dates-label { font-size: .76rem; font-weight: 600; color: var(--color-text-secondary); }
.uds-dates-val   { font-size: .95rem; font-weight: 700; color: var(--color-text-primary); }

/* Nights count — displayed above the dates widget */
.uds-nights-above {
  font-size: .82rem; font-weight: 700; color: #fff;
  text-align: center; margin-bottom: 6px;
  background: var(--color-accent); border-radius: 50px;
  padding: 3px 12px; display: inline-block; position: absolute; top: -15px; 
  left: 50%; transform: translateX(-50%);
}

/* Check-in / check-out times (read-only) */
.uds-times-row {
  display: flex; align-items: center; gap: 0;
  border: 1px solid var(--color-border); border-radius: 10px;
  overflow: hidden; margin-bottom: 14px;
}
.uds-time-cell {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; background: var(--color-surface-2);
  font-size: .82rem;
}
.uds-time-cell i { color: var(--color-text-secondary); font-size: .82rem; flex-shrink: 0; }
.uds-time-sep   { width: 1px; background: var(--color-border); flex-shrink: 0; }
.uds-time-label { font-size: .76rem; color: var(--color-text-secondary); font-weight: 500; display: block; }
.uds-time-val   { font-size: .94rem; font-weight: 700; }

/* Price breakdown table — always visible; the server draws it and the page script only swaps the figures. */
.uds-breakdown { display: block; margin-bottom: 16px; }
.uds-breakdown-title { font-size: .97rem; font-weight: 800; margin-bottom: 10px; }
.uds-row {
  display: flex; justify-content: space-between; align-items: center;
  padding-block: 2px; font-size: .97rem; gap: 12px;
}
.uds-row:last-child { border-bottom: none; }
.uds-row-lbl { font-weight: 500; }
.uds-row-val--discount { color: var(--color-good); font-size: 1.3rem; font-weight: 800; }
.uds-row--discount .uds-row-lbl { color: var(--color-good);}
.uds-row--total { padding: 13px 0px; margin-top: 13px; border-top: 2px solid var(--color-border); border-bottom: none; }
.uds-row--total .uds-row-lbl { font-weight: 800; font-size: 1rem; color: var(--color-text-primary); }
.uds-row--total .uds-row-val { font-size: 1.1rem; font-weight: 800; color: var(--color-accent); }

/* Book now CTA */
.uds-cta {
  width: 100%; padding: 14px; font-size: 1.05rem; font-weight: 800;
  border-radius: 14px; margin-bottom: 12px;
  /* uses .btn-cta from shared.css — just sizing here */
}

/* ── Mobile sticky bottom bar — single compact row ──────────────────────── */
.ud-mob-bar {
  position: fixed; bottom: 0; inset-inline: 0;
  z-index: 1049; /* below sheets (1060) */
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 20px rgba(0,0,0,.1);
}

/* Inner flex row: [dates btn] | [price info] | [book] */
.ud-mob-inner { display: flex; align-items: center; gap: 8px; }

/* Dates selector */
.ud-mob-dates-btn {
  flex: 1.5; min-width: 0;
  display: flex; align-items: center; gap: 7px;
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  border-radius: 10px; padding: 7px 10px;
  cursor: pointer; font-family: inherit; text-align: start;
  transition: border-color .15s;
}
.ud-mob-dates-btn:hover,
.ud-mob-dates-btn:focus-visible { border-color: var(--color-accent); outline: none; }
.ud-mob-dates-text     { flex: 1; min-width: 0; }
.ud-mob-dates-lbl      { font-size: .68rem; color: var(--color-text-secondary); display: block; line-height: 1; margin-bottom: 3px; font-weight: 500; }
.ud-mob-dates-date     { font-size: .82rem; font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.ud-mob-dates-date + .ud-mob-dates-date { margin-top: 3px; }
.ud-mob-dates-edit-ic  { font-size: .72rem; color: var(--color-text-secondary); flex-shrink: 0; }

/* Vertical divider between dates and price */
.ud-mob-bar-div { width: 1px; height: 34px; background: var(--color-border); flex-shrink: 0; }

/* Price info: meta row (old price + badge) + main + total */
.ud-mob-price-info  { flex: 1; min-width: 0; text-align: center; }
.ud-mob-price-meta  { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 16px; }
.ud-mob-price-old   { font-size: .76rem; color: var(--color-text-secondary); text-decoration: line-through; }
.ud-mob-price-badge { font-size: .72rem; padding: 2px 8px; }
.ud-mob-price-main  { display: flex; align-items: baseline; justify-content: center; gap: 2px; }
.ud-mob-price-val   { font-size: 1.05rem; font-weight: 800; color: var(--color-primary); }
.ud-mob-price-per   { font-size: .72rem; color: var(--color-text-secondary); }
.ud-mob-total-line  { font-size: .78rem; color: var(--color-text-secondary); margin-top: 1px; }
.ud-mob-total-line strong { color: var(--color-accent); font-weight: 800; }

/* Book button */
.ud-mob-book {
  flex-shrink: 0; padding: 10px 16px;
  font-size: .94rem; font-weight: 800; border-radius: 10px; white-space: nowrap;
}

/* Very small screens (≤ 360px) — keep everything inline, just compress */
@media (max-width: 360px) {
  .ud-mob-bar        { padding-inline: 8px; }
  .ud-mob-inner      { gap: 4px; }
  .ud-mob-dates-btn  { padding: 5px 7px; gap: 4px; }
  .ud-mob-dates-date { font-size: .75rem; }
  .ud-mob-price-val  { font-size: .92rem; }
  .ud-mob-book       { padding: 10px 10px; }
  .ud-gallery-view-all--mob { padding: 6px 8px; font-size: .75rem !important; }
}

/* ── Dates sheet (udDatesSheet) ──────────────────────────────────────────── */
#udDatesSheet .cal-wrap { margin-bottom: 0; }

/* On desktop show 2 calendars */
@media (min-width: 768px) {
  #udDatesSheet { max-width: 660px; }
  #udDatesSheet .flatpickr-months { padding-inline: 4px; }
}

/* Selected range summary row */
/* Selected range summary — .ud-dates-summary-range wraps the three date
   elements so they always stay on one line; the nights pill sits to the
   end at normal widths and wraps to the next line at very small sizes.  */
.ud-dates-summary {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 6px; padding: 10px 14px; border: 1px solid var(--color-border); border-radius: 12px;
  background: var(--color-surface-2); margin-bottom: 14px; font-size: .9rem;
}
.ud-dates-summary-range {
  display: flex; align-items: center; gap: 8px;
}
.ud-dates-summary-item { font-weight: 700; color: var(--color-primary); }
.ud-dates-summary-arrow { color: var(--color-text-secondary); font-size: .8rem; }
.ud-dates-summary-nights {
  font-size: .82rem; font-weight: 600; color: #fff;
  background: var(--color-accent); border-radius: 50px; padding: 2px 10px;
}

@media (max-width: 480px) {
  .ud-dates-summary { text-align: center; flex-direction: column;}
}

/* ── Mobile gallery overlay action buttons (back / share / fav) ───────────── */
/* Only shown in <576px full-screen app mode */
.ud-mob-gal-actions { display: none; }
@media (max-width: 575.98px) {
.ud-mob-gal-actions {
  display: flex;
  position: absolute; top: 12px; inset-inline: 0; padding-inline: 12px;
  z-index: 5; align-items: center; justify-content: space-between;
  pointer-events: none;
}
}
.ud-mob-gal-actions > * { pointer-events: auto; }
.ud-mob-gal-end { display: flex; align-items: center; gap: 8px; }
.ud-mob-gal-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  color: #fff; border-radius: 50%; border: none; cursor: pointer;
  font-size: .92rem; text-decoration: none; line-height: 1; transition: background .15s;
}
.ud-mob-gal-btn:hover,
.ud-mob-gal-btn:focus-visible { background: rgba(0,0,0,.68); color: #fff; outline: none; }

/* ── Mobile bar ≤ 480px — inline top row + book button full-width below ──── */
@media (max-width: 480px) {
  .ud-mob-inner      { flex-wrap: wrap; }
  .ud-mob-dates-btn  { flex: 1 1 auto; }
  .ud-mob-price-info { flex: 1 1 auto; }
  .ud-mob-book       { flex: 0 0 100%; order: 10; border-radius: 10px; margin-top: 4px; }
  .ud-gallery-view-all--mob { padding: 8px 10px; font-size: .80rem; }
}

/* ── Mobile < 576px — full-screen app-like layout ────────────────────────── */
@media (max-width: 575.98px) {

  body { padding-top: 0 !important; }

  /* Hide persistent chrome */
  .tnav, .nav-overlay, .nav-drawer { display: none !important; }
  .ud-breadcrumb-nav { display: none !important; }
  .dfoot { display: none !important; }

  /* The top section is drawn again inside the Specification tab (by the server), so the wide
     copy and the four guarantee cards are hidden. */
  .ud-summary-wide,
  .ud-guarantee-grid { display: none !important; }

  /* ── Gallery: true edge-to-edge ────────────────────────────────── */
  /* Negate the container's horizontal padding (Bootstrap xs = 12px each side) */
  .ud-gallery {
    margin-inline: -20px;
    margin-bottom: 0;
    border-radius: 0px;
  }
  .ud-gallery-mobile { border-radius: 0; margin-bottom: 0; }
  .ud-gallery-mobile .swiper { border-radius: 0; height: 310px; }

  /* ── Content column: the summary, then the tabs running edge to edge ── */
  #udContentCol { display: flex; flex-direction: column; padding-inline: 0; }
  #udTabs       { order: 1; margin-top: 0 !important; margin-inline: -20px; }

  /* ── Tabs: sticky at very top (no navbar on mobile) ─────────────── */
  .ud-tabs--sticky .ud-nav-tabs { top: 0; }
  .ud-nav-tabs { border-radius: 0; }

  /* ── Top section inside the Specification tab (title + meta + specs + banners + host) ── */
  .ud-spec-mob-hd {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 16px;
  }
  .ud-spec-mob-hd .ud-title {
    font-size: 1.15rem; font-weight: 800; line-height: 1.3;
    margin-bottom: 8px; color: var(--color-text-primary);
  }
  .ud-spec-mob-hd .ud-meta-list { margin-bottom: 12px; }
  .ud-spec-mob-hd .ud-specs { margin-bottom: 14px; }
  .ud-spec-mob-hd .ud-specs .ud-spec-item { padding: 8px 10px; }
  .ud-spec-mob-hd .ud-desc {
    border-top: 1px solid var(--color-border);
    padding-top: 14px; margin-top: 4px; margin-bottom: 15px;
    font-size: .9rem;
  }
  .ud-spec-mob-hd .ud-desc h2 { font-size: 1rem; }
  .ud-spec-mob-hd .ud-host { background: none; margin-bottom: 15px; }
  .ud-spec-mob-hd .ud-guarantee-banner { margin-top: 4px; margin-bottom: 10px; }

  .ud-nav-tabs .nav-link i { display: none; }

  /* ── Pane: flush edges ────────────────────────────────────────── */
  .ud-tabs .tab-pane {
    border-inline: none; border-radius: 0;
    padding: 16px 20px;
  }
}

/* ── Similar units: clear the bottom sticky bar on small phones ────────── */
@media (max-width: 480px) {
  .ud-similar {
    padding-bottom: 16px;
  }
}

/* ── Photos / videos buttons: two buttons share one corner, photos first ──────────────────── */
.ud-gallery-actions {
  position: absolute; bottom: 14px; inset-inline-end: 14px; z-index: 5;
  display: flex; gap: 8px;
}
.ud-gallery-actions--mob { bottom: 10px; inset-inline: 12px; justify-content: space-between; }
/* With no videos there is only the photos button, and it stays at the end. */
.ud-gallery-actions--mob .ud-gallery-view-all:only-child { margin-inline-start: auto; }
.ud-gallery-actions .ud-gallery-view-all { position: static; }

/* ── Below 480px ─────────────────────────────────────────────────────────────────────────────
   The bottom bar wraps (dates + price on one row, Book across the full width on the next), so it
   is taller than the one-row default; the page keeps that much room under its last content. */
@media (max-width: 480px) {
  .ud-main { --ud-mob-bar-h: 150px; }
}

/* ── Photos in the PhotoSwipe viewer keep their own proportions ──────────────────────────────
   The viewer draws a photo into a box of the size it was declared with. Until the photo's real size is
   known that is a guess, and without this rule a photo of a different shape is stretched to fill it. */
.pswp__img { object-fit: contain; }

/* While a photo loads, the viewer shows a placeholder the size of the screen. Its default colour is a solid grey
   that stays for a second after the photo appears, so the whole screen looked grey and then cleared by itself.
   Transparent, it leaves only the viewer's own dark overlay. */
.pswp div.pswp__img--placeholder { background: transparent; }

/* ── Video slides in the PhotoSwipe viewer: centred, never larger than the screen ────────── */
.ud-video-slide {
  width: 100%; height: 100%; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  padding: 56px 16px 24px;
}
.ud-video-slide video {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  background: #000; border-radius: 8px; outline: none;
}
