/*
 * Pickup and drop-off search (issue #86): the "Where do you need the car?" field that assets/js/och-pickup-search.js
 * builds over the location selects of booking-search-form.php. Its own file so the shared stylesheets (och.css,
 * och-pages.css) stay untouched. Logical properties only (RTL); rows and buttons at least 44 px; the input at 16 px
 * (no zoom on iPhone); a full-screen sheet on phones.
 */

/* The select stays in the form (it is what is submitted) but is hidden once the field is built. */
.och-ps-on > select,
.och-ps-on > span:not(.och-ps) {
    display: none !important;
}

.och-ps {
    position: relative;
    width: 100%;
    text-align: start;
}

.och-ps-box {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}

.och-ps-ic {
    display: inline-flex;
    flex: none;
    line-height: 1;
}

.och-ps-pin {
    position: absolute;
    top: 50%;
    inset-inline-start: 0;
    transform: translateY(-50%);
    color: var(--och-accent-text, #9A5200);
    pointer-events: none;
}

.och-ps-pin svg {
    width: 16px;
    height: 16px;
}

.och-ps .och-ps-input,
body.och .search-box-banner .group-img .och-ps-input {
    width: 100% !important;
    min-width: 0;
    font-size: 16px !important;
    padding-inline: 26px 34px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
}

/* On the och search bar the whole tile shows the focus ring (och.css :focus-within). */
body.och .search-box-banner .och-ps-input:focus {
    outline: none !important;
}

/* Pages without the och design: the field looks like the other inputs of the old search bar. */
body:not(.och) .och-ps .och-ps-input {
    height: 45px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    color: #201f1d;
    font-weight: 500;
}

body:not(.och) .och-ps-pin {
    inset-inline-start: 12px;
}

body:not(.och) .och-ps .och-ps-input {
    padding-inline-start: 36px !important;
}

.och-ps-clear,
.och-ps-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--och-text-2, #5E6470);
    cursor: pointer;
}

.och-ps-clear {
    position: absolute;
    top: 50%;
    inset-inline-end: -10px;
    transform: translateY(-50%);
}

.och-ps-clear svg {
    width: 16px;
    height: 16px;
}

.och-ps-clear:hover,
.och-ps-back:hover {
    background: var(--och-gray-100, #F2F3F5);
}

.och-ps-clear:focus-visible,
.och-ps-back:focus-visible,
.och-ps-chip:focus-visible,
.och-ps-use:focus-visible,
.och-ps-wa:focus-visible {
    outline: 2px solid var(--och-teal-500, #0E6E8C);
    outline-offset: 2px;
}

.och-ps-head {
    display: none;
}

/* ---- the dropdown (desktop) */
.och-ps-pop {
    position: absolute;
    z-index: 1050;
    top: calc(100% + 14px);
    inset-inline-start: -16px;
    width: max(calc(100% + 32px), 400px);
    max-width: calc(100vw - 32px);
    max-height: min(460px, 70vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px;
    border: 1px solid var(--och-line, #E8EAED);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 44px rgba(20, 23, 28, 0.18);
    color: var(--och-text, #353A43);
    cursor: default;
    white-space: normal;
}

.och-ps-pop[hidden] {
    display: none;
}

.och-ps-actions:empty {
    display: none;
}

.och-ps-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 6px 10px;
}

.och-ps-chips[hidden] {
    display: none;
}

.och-ps-chip {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--och-gray-300, #D9DCE1);
    border-radius: 999px;
    background: #fff;
    color: var(--och-heading, #14171C);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.och-ps-chip:hover {
    border-color: var(--och-teal-500, #0E6E8C);
    background: var(--och-teal-50, #E8F3F6);
}

.och-ps-group + .och-ps-group {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--och-gray-100, #F2F3F5);
}

.och-ps-gh {
    padding: 8px 10px 4px;
    color: var(--och-text-2, #5E6470);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.och-ps-opt {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 44px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
}

.och-ps-opt:hover,
.och-ps-opt.is-active {
    background: var(--och-teal-50, #E8F3F6);
}

.och-ps-opt.is-active {
    box-shadow: inset 0 0 0 1.5px var(--och-teal-500, #0E6E8C);
}

.och-ps-opt .och-ps-ic {
    margin-top: 1px;
    color: var(--och-teal-500, #0E6E8C);
}

.och-ps-opt.is-none .och-ps-ic {
    color: var(--och-gray-500, #8B919C);
}

.och-ps-txt {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.och-ps-t {
    color: var(--och-heading, #14171C);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.och-ps-opt.is-current .och-ps-t::after {
    content: " \2713";
    color: var(--och-teal-500, #0E6E8C);
}

.och-ps-s {
    color: var(--och-text-2, #5E6470);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
}

.och-ps-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.3;
}

.och-ps-d {
    color: var(--och-text-2, #5E6470);
    font-weight: 600;
}

.och-ps-b {
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 700;
}

.och-ps-b.is-free { background: var(--och-green-50, #E9F6EF); color: var(--och-green-600, #16784A); }
.och-ps-b.is-fee { background: var(--och-orange-50, #FFF4E5); color: var(--och-orange-700, #9A5200); }
.och-ps-b.is-notice { background: var(--och-amber-50, #FEF3E2); color: var(--och-amber-600, #B54708); }
.och-ps-b.is-wa { background: #E7F5EC; color: var(--och-wa, #1A7F44); }

.och-ps-empty {
    padding: 10px 10px 4px;
    font-size: 14px;
    line-height: 1.45;
}

.och-ps-empty[hidden] {
    display: none;
}

.och-ps-empty p {
    margin: 0 0 6px;
}

.och-ps-empty-t {
    color: var(--och-heading, #14171C);
    font-weight: 700;
}

.och-ps-wa {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--och-wa, #1A7F44) !important;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.och-ps-trip .och-ps-wa {
    min-height: 0;
}

.och-ps-loading {
    padding: 14px 10px;
    color: var(--och-text-2, #5E6470);
    font-size: 14px;
}

.och-ps-sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---- under the form: the chosen place, notice, fee lines; under the return field: the one-way cost */
.och-ps-trip {
    order: 3;   /* the och search form is a flex column (och-pages.css): after the fields and the top row */
    margin: 10px 4px 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--och-gray-50, #F7F8FA);
    color: var(--och-text, #353A43);
    font-size: 14px;
    line-height: 1.45;
    text-align: start;
}

.och-ps-trip[hidden] {
    display: none;
}

.och-ps-trip p {
    margin: 0 0 6px;
}

.och-ps-trip p:last-child {
    margin-bottom: 0;
}

.och-ps-trip-place.is-none strong {
    color: var(--och-amber-600, #B54708);
}

.och-ps-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    color: var(--och-amber-600, #B54708);
    font-weight: 600;
}

.och-ps-use {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1.5px solid var(--och-teal-500, #0E6E8C);
    border-radius: 999px;
    background: #fff;
    color: var(--och-teal-600, #0B5A73);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.och-ps-use:hover {
    background: var(--och-teal-50, #E8F3F6);
}

.och-ps-dir {
    color: var(--och-text-2, #5E6470);
}

.och-ps-oneway {
    margin: 4px 0 0;
    color: var(--och-text-2, #5E6470);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    white-space: normal;
}

.och-ps-oneway[hidden] {
    display: none;
}

/* ---- phones: a full-screen sheet with its own header */
html.och-ps-locked,
html.och-ps-locked body {
    overflow: hidden !important;
}

@media (max-width: 767.98px) {
    .och-ps-pop {
        inset-inline-start: 0;
        width: 100%;
    }

    .och-ps-in.is-sheet {
        position: fixed;
        inset: 0;
        z-index: 2000;
        display: flex;
        flex-direction: column;
        padding: 6px 12px env(safe-area-inset-bottom, 0);
        background: #fff;
        cursor: default;
    }

    .och-ps-in.is-sheet .och-ps-head {
        display: flex;
        align-items: center;
        gap: 4px;
        min-height: 52px;
        margin-inline-start: -6px;
    }

    .och-ps-title {
        color: var(--och-heading, #14171C);
        font-size: 17px;
        font-weight: 700;
    }

    [dir="rtl"] .och-ps-back svg {
        transform: scaleX(-1);
    }

    .och-ps-in.is-sheet .och-ps-box {
        min-height: 52px;
        padding-inline: 12px 4px;
        border: 1.5px solid var(--och-teal-500, #0E6E8C);
        border-radius: 12px;
        background: #fff;
    }

    .och-ps-in.is-sheet .och-ps-pin {
        inset-inline-start: 12px;
    }

    body .och-ps-in.is-sheet .och-ps-input,
    body.och .search-box-banner .group-img .och-ps-in.is-sheet .och-ps-input {
        height: 48px !important;
        border: 0 !important;
        background: transparent !important;
        padding-inline: 26px 36px !important;
    }

    .och-ps-in.is-sheet .och-ps-clear {
        inset-inline-end: 4px;
    }

    .och-ps-in.is-sheet .och-ps-pop {
        position: static;
        flex: 1;
        width: auto;
        max-width: none;
        max-height: none;
        margin: 8px -12px 0;
        padding: 4px 4px 24px;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .och-ps-trip {
        margin: 10px 0 0;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .och-ps-opt,
    .och-ps-chip {
        transition: background-color 0.12s ease;
    }
}
