/**
 * NHL Bookly searchable dropdowns.
 *
 * Styles the type-to-filter combobox that replaces the native Care-centre /
 * Speciality / Staff <select>s on the booking form. Uses site design tokens
 * (--primary, --accent, --radius, --font-sans from the active theme) and matches Bookly's
 * own field metrics (14px text, full width, silver border).
 *
 * Scoped under .bookly-form so it sits inside the booking widget only.
 * The native <select> is hidden but kept in the DOM (Bookly's Svelte code
 * still reads its value), so it must be hidden with !important to beat
 * Bookly's own `display: inline-block !important`.
 */

.bookly-form select.nhl-bsearch__native {
    display: none !important;
}

/*
 * Combobox sits inside Bookly's .bookly-form-group > div (same wrapper as the native <select>).
 * On desktop, give each chain field 7px left + 7px right so columns are separated (14px between fields).
 */
@media screen and (min-width: 651px) {
    .bookly-form .bookly-table.bookly-box > .bookly-form-group[data-type="category"] > div:has(.nhl-bsearch),
    .bookly-form .bookly-table.bookly-box > .bookly-form-group[data-type="service"] > div:has(.nhl-bsearch),
    .bookly-form .bookly-table.bookly-box > .bookly-form-group[data-type="staff"] > div:has(.nhl-bsearch) {
        margin-left: 7px !important;
        margin-right: 7px !important;
    }
}

/* Let the floating panel escape Bookly's overflow:hidden on .bookly-box */
.bookly-form .bookly-table.bookly-box:has(.nhl-bsearch.is-open),
.bookly-form .bookly-form-group.is-nhl-bsearch-open {
    overflow: visible !important;
}

.bookly-form .bookly-form-group.is-nhl-bsearch-open {
    position: relative;
    z-index: 2;
}

.bookly-form .nhl-bsearch {
    position: relative;
    width: 100%;
    font-family: var(--font-sans, "Inter", system-ui, sans-serif);
    font-size: 14px;
}

/* ── Trigger ──────────────────────────────────────────────────────────────── */

.bookly-form .nhl-bsearch__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 38px;
    margin: 0;
    padding: 7px 12px;
    background: #fff;
    color: hsl(var(--primary, 216 100% 22%));
    border: 1px solid silver;
    border-radius: var(--radius, 6px);
    font: inherit;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bookly-form .nhl-bsearch__trigger:hover {
    border-color: hsl(var(--primary, 216 100% 22%) / 0.5);
}

.bookly-form .nhl-bsearch.is-open .nhl-bsearch__trigger,
.bookly-form .nhl-bsearch__trigger:focus-visible {
    border-color: hsl(var(--primary, 216 100% 22%));
    box-shadow: 0 0 0 3px hsl(var(--primary, 216 100% 22%) / 0.15);
    outline: none;
}

.bookly-form .nhl-bsearch__value {
    flex: 1 1 auto;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.bookly-form .nhl-bsearch.is-placeholder .nhl-bsearch__value {
    color: #6b7280;
}

.bookly-form .nhl-bsearch__caret {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    opacity: 0.6;
    transition: transform 0.15s ease;
}

.bookly-form .nhl-bsearch.is-open .nhl-bsearch__caret {
    transform: rotate(-135deg) translateY(-1px);
}

/* ── Panel ────────────────────────────────────────────────────────────────── */

/* position set to fixed in JS so the list does not cover other fields */
.bookly-form .nhl-bsearch__panel {
    z-index: 100000;
    background: #fff;
    border: 1px solid #e2e6ea;
    border-radius: var(--radius, 6px);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.bookly-form .nhl-bsearch__search {
    position: relative;
    padding: 8px;
    border-bottom: 1px solid #eef1f4;
}

/* Magnifier glyph (kept off the input so Bookly's input rules can't move it). */
.bookly-form .nhl-bsearch__search::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 18px;
    width: 14px;
    height: 14px;
    transform: translateY(-50%);
    background: no-repeat center / contain
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    pointer-events: none;
}

.bookly-form .nhl-bsearch__input,
.bookly-form input[type="text"].nhl-bsearch__input {
    width: 100% !important;
    padding: 8px 10px 8px 34px !important;
    border: 1px solid silver !important;
    border-radius: var(--radius, 6px) !important;
    font-size: 14px !important;
    line-height: normal !important;
    background: #fff;
    box-shadow: none !important;
}

.bookly-form .nhl-bsearch__input:focus {
    border-color: hsl(var(--primary, 216 100% 22%)) !important;
    outline: none;
}

/* ── Options ──────────────────────────────────────────────────────────────── */

.bookly-form .nhl-bsearch__list {
    list-style: none;
    margin: 0;
    padding: 4px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.bookly-form .nhl-bsearch__option--hidden {
    display: none !important;
}

.bookly-form .nhl-bsearch__option {
    margin: 0;
    padding: 9px 12px;
    border-radius: calc(var(--radius, 6px) - 2px);
    color: #1f2937;
    line-height: 1.3;
    cursor: pointer;
}

.bookly-form .nhl-bsearch__option.is-active,
.bookly-form .nhl-bsearch__option:hover {
    background: hsl(var(--accent, 140 59% 28%) / 0.12);
}

.bookly-form .nhl-bsearch__option.is-selected {
    font-weight: 600;
    color: hsl(var(--primary, 216 100% 22%));
}

.bookly-form .nhl-bsearch__option.is-selected.is-active,
.bookly-form .nhl-bsearch__option.is-selected:hover {
    background: hsl(var(--accent, 140 59% 28%) / 0.18);
}

.bookly-form .nhl-bsearch__empty {
    margin: 0;
    padding: 12px;
    color: #6b7280;
    font-size: 13px;
    text-align: center;
}
