/*
 * Rihla — phone layout fixes and installed-app (PWA) chrome for the client site.
 * Loaded after rihla-brand.css on the frontend, customer-account and auth layouts.
 */

/* ───────────────────────── Installed app: bottom tab bar ───────────────────────── */

.rd-app-tabbar {
  display: none;
}

@media (display-mode: standalone) {
  html:not(.rd-no-tabbar) .rd-app-tabbar { display: flex; }
}

html.is-standalone:not(.rd-no-tabbar) .rd-app-tabbar {
  display: flex;
}

.rd-app-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1040;
  justify-content: space-around;
  align-items: stretch;
  background: #fff;
  border-top: 1px solid var(--rihla-border, #f0cbcd);
  box-shadow: 0 -6px 20px rgba(22, 42, 68, .06);
  padding: 4px 4px env(safe-area-inset-bottom, 0);
}

.rd-app-tabbar__item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  padding: 6px 2px;
  color: var(--rihla-muted, #5e6c7e) !important;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none !important;
  -webkit-tap-highlight-color: transparent;
}

.rd-app-tabbar__item.is-active {
  color: var(--rihla-red, #c1272d) !important;
}

.rd-app-tabbar__item.is-active svg {
  stroke-width: 2.2;
}

@media (display-mode: standalone) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  /* Sticky bottom widgets sit above the tab bar. */
  .rd-cookie-banner { bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important; }
}

html.is-standalone body {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

/* ───────────────────────── Install prompt ───────────────────────── */

.rd-install {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 1050;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--rihla-border, #f0cbcd);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(22, 42, 68, .22);
  transform: translateY(calc(100% + 24px));
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
}

.rd-install[hidden] { display: none; }

.rd-install.is-visible {
  transform: none;
  opacity: 1;
}

.rd-install__icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 11px;
}

.rd-install__body { flex: 1 1 auto; min-width: 0; }

.rd-install__title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--rihla-ink, #162a44);
}

.rd-install__text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--rihla-muted, #5e6c7e);
}

.rd-install__text svg { vertical-align: -3px; color: #007aff; }

.rd-install__cta {
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  padding: 0 16px;
  min-height: 40px;
  background: var(--rihla-red, #c1272d);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.rd-install__cta[hidden] { display: none; }

.rd-install__close {
  position: absolute;
  top: -12px;
  right: -6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--rihla-border, #f0cbcd);
  border-radius: 50%;
  background: #fff;
  color: var(--rihla-muted, #5e6c7e);
  box-shadow: 0 4px 12px rgba(22, 42, 68, .12);
}

/* The close badge hangs off the corner; a larger invisible hit area keeps it easy to tap. */
.rd-install__close::after {
  content: "";
  position: absolute;
  inset: -6px;
}

/* ───────────────────────── Phone layout fixes ───────────────────────── */

/* iOS zooms the page when a field under 16px gets focus; keep fields at 16px there. */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 991px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea {
      font-size: 16px !important;
    }
  }
}

@media (max-width: 991px) {
  /* Header icons: 44px touch targets instead of 20px glyphs. */
  .bravo_header [data-x-click*="mobile-menu"],
  .bravo_header .icon-user,
  .bravo_header [data-x="header-mobile-icons"] a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* The bigger targets replace the old 30px padding and 20px gaps, so the row still fits at 320px. */
  .bravo_header [data-x="header-mobile-icons"] {
    padding-left: 8px !important;
  }

  .bravo_header [data-x="header-mobile-icons"] > * {
    padding-left: 2px !important;
    padding-right: 2px !important;
  }

  .bravo_header [data-x="header-mobile-icons"] .login-mobile-item {
    margin-left: 0 !important;
  }
}

@media (max-width: 767px) {
  /*
   * Home and page-builder card lists: a swipeable row instead of one card per
   * screen stacked down the page (the home page was ~38,000px tall on a phone).
   * Browsers without :has() keep the stacked list.
   */
  .page-template-content .row:has(> [class*="col"] > .item-loop, > [class*="col"] > .hotelsCard, > [class*="col"] > .tourCard, > [class*="col"] > .rd-pack-card-v2, > [class*="col"] > .rd-pack-card) {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 15px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 14px;
  }

  .page-template-content .row:has(> [class*="col"] > .item-loop, > [class*="col"] > .hotelsCard, > [class*="col"] > .tourCard, > [class*="col"] > .rd-pack-card-v2, > [class*="col"] > .rd-pack-card)::-webkit-scrollbar {
    display: none;
  }

  .page-template-content .row:has(> [class*="col"] > .item-loop, > [class*="col"] > .hotelsCard, > [class*="col"] > .tourCard, > [class*="col"] > .rd-pack-card-v2, > [class*="col"] > .rd-pack-card) > [class*="col"] {
    flex: 0 0 82%;
    max-width: 82%;
    scroll-snap-align: start;
  }

  /* Pill tabs (e.g. hotels by city on the home page): one scrollable line. */
  .page-template-content .tabs__controls.js-tabs-controls,
  .bravo_user_profile .tabs__controls.js-tabs-controls {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    /* Fade the right edge so it reads as "more tabs this way". */
    -webkit-mask-image: linear-gradient(to right, #000 82%, transparent);
    mask-image: linear-gradient(to right, #000 82%, transparent);
  }

  .page-template-content .tabs__controls.js-tabs-controls::-webkit-scrollbar,
  .bravo_user_profile .tabs__controls.js-tabs-controls::-webkit-scrollbar {
    display: none;
  }

  .page-template-content .tabs__controls.js-tabs-controls > *,
  .bravo_user_profile .tabs__controls.js-tabs-controls > * {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* Detail-page photo grid: one large photo and two thumbnails, not five full-width photos. */
  .galleryGrid.-type-1 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    gap: 6px;
  }

  .galleryGrid.-type-1 > .galleryGrid__item:nth-of-type(1) {
    grid-column: 1 / -1;
    grid-row: auto;
    height: 240px;
  }

  .galleryGrid.-type-1 > .galleryGrid__item:nth-of-type(2),
  .galleryGrid.-type-1 > .galleryGrid__item:nth-of-type(3) {
    height: 110px;
  }

  .galleryGrid.-type-1 > .galleryGrid__item:nth-of-type(n+4) {
    display: none !important;
  }

  .galleryGrid.-type-1 .button {
    padding: 10px 16px !important;
    font-size: 14px;
  }

  /* Hotel detail: dates / guests / button stacked full width. */
  .hotel_rooms_form .form-search-row {
    flex-direction: column;
  }

  .hotel_rooms_form .form-search-row > [class*="col-"] {
    width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
    padding-left: 0;
    padding-right: 0;
  }

  .hotel_rooms_form .form-search-row > [class*="col-"] + [class*="col-"] {
    border-top: 1px solid var(--rihla-border, #f0cbcd);
  }

  .hotel_rooms_form .searchMenu-guests__field {
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    min-width: 0 !important;
  }

  .hotel_rooms_form .searchMenu-guests__field > .bg-white {
    padding: 20px !important;
  }

  /* Contact block: its 80px gutter pushed the columns 25px past both edges. */
  .row.x-gap-80 {
    margin-left: -15px;
    margin-right: -15px;
  }

  .row.x-gap-80 > * {
    padding-left: 15px;
    padding-right: 15px;
  }

  /* Footer link lists two per row instead of one long column. */
  .footer .footer_one > .row > [class*="col-"] {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .footer .footer_one > .row > [class*="col-"]:first-child,
  .footer .footer_one > .row > [class*="col-"]:last-child {
    flex-basis: 100%;
    max-width: 100%;
  }

  .footer .footer_one h5.mb-30 {
    margin-bottom: 14px !important;
  }

  .footer .footer_one {
    padding-top: 40px !important;
    padding-bottom: 32px !important;
  }

  /* Transfer search: the swap button no longer takes a full 70px row. */
  .rd-transfer-grid--route .rd-swap-btn {
    min-height: 40px;
    height: 40px;
    padding: 0;
  }
}
