/*
 * Mobile booking UX for the tour detail page.
 *
 * Everything here is inside a max-width query so the desktop layout is
 * untouched. The phone problems this addresses:
 *
 *  1. The price list is a 8-column table. The responsive pattern stacks every
 *     cell into its own full-width row, so a single room took ~450px and the
 *     totals row added 8 more rows, 4 of them a bold label with nothing beside
 *     it. Rooms are now cards with a 2-up grid, and the empty totals cells are
 *     hidden.
 *  2. The booking form lives in the right column, which stacks below the whole
 *     write-up, so the live total and the book button were off-screen for most
 *     of the page. A sticky bar keeps both reachable.
 *  3. The fixed call/WhatsApp buttons sat on top of the table's left-hand
 *     labels, hiding "Room type", "Per adult" and "Per child". They are lifted
 *     clear of the sticky bar.
 */

.mobile-booking-bar {
    display: none;
}

@media (max-width: 991px) {

    /* ---------- 1. price list: one card per room ---------- */

    table.price-list-table tr {
        background-color: #fff;
        border: 1px solid #e3e3e3;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
        margin-bottom: 14px;
        overflow: hidden;
        padding: 4px 0;
    }

    /* Two cells per line instead of one, which roughly halves the height. */
    table.price-list-table td {
        align-items: center;
        border-bottom: 1px solid #f0f0f0;
        display: flex;
        font-size: 14px;
        gap: 8px;
        justify-content: space-between;
        line-height: 1.3;
        min-height: 40px;
        padding: 8px 12px;
        text-align: right;
    }

    table.price-list-table td::before {
        color: #6b6b6b;
        float: none;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: .04em;
        flex: 0 0 auto;
        text-align: left;
    }

    table.price-list-table td:last-child {
        background: #f6fbfd;
        border-bottom: 0;
        font-weight: 700;
    }

    /* Selects inside the table were full-width blocks pushing rows taller. */
    table.price-list-table td select {
        background: transparent;
        border: 1px solid #dcdcdc !important;
        border-radius: 6px;
        font-size: 14px;
        height: 32px;
        max-width: 50%;
        padding: 0 6px;
        width: auto;
    }

    /*
     * The totals row carries four placeholder cells (&nbsp;). On desktop they
     * are invisible blanks in a table; stacked on a phone each became a bold
     * label with no value, which is what made the last block look broken.
     */
    table.price-list-table .price-total-row {
        background: #f8f8f8;
        border-color: #cfe9f3;
    }

    table.price-list-table .price-total-row .is-blank {
        display: none;
    }

    /* ---------- 2. sticky booking bar ---------- */

    .mobile-booking-bar {
        align-items: center;
        background: #fff;
        border-top: 1px solid #e0e0e0;
        bottom: 0;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, .12);
        display: flex;
        gap: 12px;
        justify-content: space-between;
        left: 0;
        padding: 10px 14px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        position: fixed;
        right: 0;
        z-index: 1030;
    }

    .mobile-booking-bar__total {
        display: flex;
        flex-direction: column;
        line-height: 1.2;
        min-width: 0;
    }

    .mobile-booking-bar__label {
        color: #6b6b6b;
        font-size: 11px;
        letter-spacing: .04em;
        text-transform: uppercase;
    }

    .mobile-booking-bar__total strong {
        color: #1d1d1d;
        font-size: 18px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-booking-bar__cta {
        flex: 0 0 auto;
        min-width: 140px;
        padding: 10px 22px;
        text-align: center;
        white-space: nowrap;
    }

    /* Stop the bar covering the end of the page. */
    .inner-package-detail-wrap {
        padding-bottom: 86px;
    }

    /* ---------- 3. keep the contact buttons clear ---------- */

    /*
     * This stylesheet is loaded site-wide, but only the tour page has the
     * sticky bar. :has() keeps the lift scoped to pages that actually have
     * one, so the buttons stay where they are everywhere else.
     */
    body:has(.mobile-booking-bar) .header-whatsapp {
        bottom: calc(86px + env(safe-area-inset-bottom, 0px));
        z-index: 1031;
    }

    body:has(.mobile-booking-bar) .header-phone {
        bottom: calc(146px + env(safe-area-inset-bottom, 0px));
        z-index: 1031;
    }

    /*
     * They still float over the left edge, where the price labels start.
     * Smaller and slightly translucent so the label underneath stays
     * readable; they are still a comfortable tap target at 36px.
     */
    body:has(.mobile-booking-bar) .header-whatsapp a i,
    body:has(.mobile-booking-bar) .header-phone i {
        height: 36px;
        width: 36px;
        font-size: 19px;
    }

    body:has(.mobile-booking-bar) .header-whatsapp,
    body:has(.mobile-booking-bar) .header-phone {
        opacity: .92;
    }

    /* ---------- 4. booking form breathing room ---------- */

    .booking-form-inner .rs-booking-hoteloption {
        margin-bottom: 14px;
    }

    .booking-form-inner .form-control,
    .booking-form-inner select {
        font-size: 16px; /* iOS zooms the page for anything under 16px */
        min-height: 44px;
    }

    .booking-form-inner .book-submitbtn {
        min-height: 48px;
    }
}

/* Right-to-left: the labels and the bar mirror. */
@media (max-width: 991px) {

    html[dir="rtl"] table.price-list-table td,
    body.rtl table.price-list-table td {
        text-align: left;
    }

    html[dir="rtl"] table.price-list-table td::before,
    body.rtl table.price-list-table td::before {
        text-align: right;
    }

    html[dir="rtl"] .header-whatsapp,
    html[dir="rtl"] .header-phone,
    body.rtl .header-whatsapp,
    body.rtl .header-phone {
        left: auto;
        right: 0;
    }
}

/*
 * Include / Not include panels.
 *
 * Both lists are long and sat open above the itinerary, pushing the itinerary
 * and the price list far down the page. They now collapse like the itinerary
 * accordion and start closed on a phone. Desktop is unchanged: the panels are
 * forced open and the heading is not interactive.
 */

.mobile-collapse__head a {
    align-items: center;
    color: inherit;
    display: flex;
    justify-content: space-between;
    text-decoration: none;
}

/* Chevron, rotated when the panel is open. */
.mobile-collapse__head a::after {
    border-bottom: 2px solid currentColor;
    border-right: 2px solid currentColor;
    content: "";
    flex: 0 0 auto;
    height: 9px;
    margin-left: 12px;
    transform: rotate(45deg);
    transform-origin: center;
    transition: transform .2s ease;
    width: 9px;
}

.mobile-collapse__head a[aria-expanded="true"]::after {
    transform: rotate(-135deg);
}

@media (min-width: 992px) {

    /*
     * Desktop keeps both panels open. Scoped to .mobile-collapse so the
     * itinerary accordion below still opens one day at a time.
     */
    .mobile-collapse .mobile-collapse__body {
        display: block !important;
        height: auto !important;
        visibility: visible !important;
    }

    .mobile-collapse .mobile-collapse__head a {
        cursor: default;
        pointer-events: none;
    }

    .mobile-collapse .mobile-collapse__head a::after {
        display: none;
    }
}

@media (max-width: 991px) {

    .mobile-collapse__head {
        margin-bottom: 0;
    }

    .mobile-collapse__head a {
        padding: 4px 0;
    }

    .mobile-collapse .mobile-collapse__body {
        padding-top: 10px;
    }

    /*
     * Hotels used goes to the end of the column on a phone: it is a browsing
     * aid, not part of booking, and it sat between the itinerary and the
     * price list where it interrupted the flow.
     */
    .package-content-detail {
        display: flex;
        flex-direction: column;
    }

    .package-content-detail > .tour-hotels-used {
        order: 10;
    }
}

/*
 * Itinerary.
 *
 * Desktop is unchanged: the per-day accordion still opens one day at a time.
 * On a phone that meant a tap per day on top of the tap for the section, so
 * the inner panels are forced open there and the days read straight through.
 */

@media (max-width: 991px) {

    /* Inner day panels only -- not the outer .mobile-collapse__body. */
    .package-ininerary .itinerary-days .itinerary-day__body {
        display: block !important;
        height: auto !important;
        visibility: visible !important;
    }

    /*
     * One rhythm for every section.
     *
     * Only Include / Not include were cards; Overview, Itinerary, Price list
     * and Hotels used were bare. That left titles on two different left edges
     * (15px vs 35px) and gaps of 20, 40, 40, 68 and 24px down the page. Every
     * section is now the same card with the same spacing, so the column reads
     * as one stack.
     *
     * .mt-5 / .mb-5 are Bootstrap utilities carrying !important, so the
     * margin has to be forced.
     */
    .package-content-detail > article {
        background-color: #f8f8f8;
        border-radius: 10px;
        margin: 0 0 20px !important;
        padding: 20px;
    }

    /*
     * Hotels used is moved last with `order`, so :last-child here is still
     * the price list in DOM order and zeroing it would collapse the gap in
     * the wrong place. Target the section that actually ends the column.
     */
    .package-content-detail > .tour-hotels-used {
        margin-bottom: 0 !important;
    }

    /* Headings sit on the same baseline in every card. */
    .package-content-detail > article > h3,
    .package-content-detail > article > .mobile-collapse__head {
        font-size: 18px;
        margin: 0 0 12px;
    }

    /* Collapsed panels should not leave the gap a heading margin would add. */
    .package-content-detail > article > .mobile-collapse__head {
        margin-bottom: 0;
    }

    .mobile-collapse .mobile-collapse__body {
        padding-top: 12px;
    }

    /*
     * Hotels used stays last (see .tour-hotels-used order below); the extra
     * top margin it used to carry is now part of the shared rhythm.
     */
    .package-content-detail > .tour-hotels-used {
        margin-top: 0 !important;
    }

    /*
     * The day heading is no longer a control and nothing inside it toggles,
     * so the accordion bar is stripped back to plain text -- the dark day
     * block and the blue title bar both come from the site's accordion
     * styling and outrank a plain rule.
     */
    .package-ininerary .itinerary-day {
        display: block;
    }

    .package-ininerary .itinerary-day__title {
        background: none;
        border: 0;
        border-radius: 0;
        padding: 0;
    }

    .package-ininerary .itinerary-day__title a {
        background: none !important;
        border-radius: 0 !important;
        color: #223645 !important;
        cursor: default;
        display: block !important;
        font-size: 15px;
        font-weight: 700;
        line-height: 1.4;
        padding: 0 !important;
        pointer-events: none;
    }

    .package-ininerary .itinerary-day__title b {
        background: none !important;
        color: #2bc2ee !important;
        display: inline !important;
        margin: 0 6px 0 0 !important;
        padding: 0 !important;
    }

    /*
     * The chevron belongs to the site's accordion styling and outranks a
     * plain rule here. Nothing on a phone toggles, so it has to go or it
     * invites a tap that does nothing.
     */
    .package-ininerary .itinerary-day__title a::after,
    .package-ininerary .itinerary-day__title a::before {
        display: none !important;
    }

    .package-ininerary .itinerary-day {
        background: none;
        border: 0;
        box-shadow: none;
        margin: 0;
    }

    .package-ininerary .itinerary-day + .itinerary-day {
        border-top: 1px solid #e6e6e6;
        margin-top: 16px;
        padding-top: 16px;
    }

    .package-ininerary .itinerary-day__body .card-body {
        padding: 6px 0 0;
    }

    .package-ininerary .itinerary-day__body .ql-editor {
        font-size: 14px;
        line-height: 1.6;
        padding: 0;
        white-space: normal;
    }
}

/*
 * Native selects.
 *
 * Every picker the customer meets is now drawn by nice-select (see
 * assets/nice-select.css), so these rules are the fallback for a select
 * that has not opted in, and for the moment before the script runs. They
 * keep an unstyled browser default from sitting next to styled inputs.
 */

select.form-control,
table.price-list-table td select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 16px 16px;
    padding-right: 32px;
}

select.form-control {
    background-color: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 5px;
    color: #626672;
    height: 48px;
    width: 100%;
}

select.form-control:focus {
    border-color: #2bc2ee;
    box-shadow: none;
    outline: none;
}

@media (max-width: 991px) {

    /* 16px keeps iOS from zooming the page when the select is tapped. */
    select.form-control {
        font-size: 16px;
    }

    table.price-list-table td select {
        background-position: right 6px center;
        background-repeat: no-repeat;
        background-size: 14px 14px;
        padding-right: 24px;
    }
}

/*
 * Price list as tabs on a phone.
 *
 * Desktop keeps the 8-column table. On a phone each room stacked into a tall
 * card, so three rooms meant three screens of scrolling. One room at a time
 * behind a tab strip keeps the whole thing on one screen; the totals row
 * stays put underneath.
 */

[x-cloak] {
    display: none !important;
}

.room-tabs {
    display: none;
}

@media (max-width: 991px) {

    .room-tabs {
        display: flex;
        gap: 8px;
        margin-bottom: 14px;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .room-tabs::-webkit-scrollbar {
        display: none;
    }

    .room-tabs__tab {
        background: #fff;
        border: 1px solid #dcdcdc;
        border-radius: 20px;
        color: #626672;
        flex: 0 0 auto;
        font-size: 13px;
        font-weight: 600;
        min-height: 36px;
        padding: 6px 16px;
        white-space: nowrap;
    }

    .room-tabs__tab.is-active {
        background: #2bc2ee;
        border-color: #2bc2ee;
        color: #fff;
    }

    /* Only the selected room is on screen; the totals row is not a room. */
    .price-list-table .price-room-row:not(.is-active-room) {
        display: none;
    }
}

/*
 * Booking card, relocated under the itinerary on a phone by
 * placeBookingCard() in singleTour.blade.php. It becomes a flex item of
 * .package-content-detail, so it needs the same bottom gap as the sections
 * around it and must not keep the sticky behaviour it has in the sidebar.
 */

@media (max-width: 991px) {

    .package-content-detail > .booking-form-wrap {
        margin-bottom: 20px;
    }

    .sidebar.position-sticky {
        position: static !important;
        top: auto !important;
    }
}

/*
 * The in-card Book Now is redundant on a phone: the sticky bar carries the
 * same action and is always on screen. Hidden here, and the sticky button
 * submits the form once the card is in view (see scrollToBookingForm).
 *
 * Kept in the DOM rather than removed from the Blade so the form still has a
 * submit control for the keyboard Enter key and for the older-browser
 * fallback path.
 */

@media (max-width: 991px) {

    .booking-form-inner .book-submitbtn {
        display: none;
    }

    /* The button carried the card's bottom spacing. */
    .booking-form-inner form > p.mb-0:last-child {
        margin-bottom: 0;
    }
}
