/* Eyeston select - brands every dropdown. The native <select> remains in
   the DOM as the source of truth (name, value, change events, required
   validation) but is rendered invisible over a styled trigger; the open
   list is Eyeston's own panel. Flat and sharp: hard borders, no shadows,
   square corners, brand navy #1f3f68; dark mode via app tokens. */

/* Anti-flash: while html.eyt-enhancing is set (inline head script, removed
   the instant the enhancers finish - 1.5s failsafe), native selects and
   date/time inputs hold their layout box but stay invisible, so a reload
   never flashes browser-default chrome before the branded UI mounts. */
html.eyt-enhancing select,
html.eyt-enhancing input[type="date"],
html.eyt-enhancing input[type="time"],
html.eyt-enhancing input[type="datetime-local"] {
    visibility: hidden;
}

.eyeston-select {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
}

/* The real select: invisible but rendered and focusable, covering the
   trigger - so clicks, focus, keyboard, and required-validation bubbles
   all land on the genuine control. */
.eyeston-select > select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    z-index: 2;
    cursor: pointer;
}

.eyeston-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--line, #d8dfe8);
    border-radius: 0;
    background: var(--panel-solid, #fff);
    color: var(--ink, #16283c);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}

.eyeston-select-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.eyeston-select-label.is-placeholder {
    color: var(--muted, #64748b);
    font-weight: 500;
}

.eyeston-select-chevron {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    color: var(--muted, #64748b);
    transition: transform 0.12s ease;
}

.eyeston-select > select:focus ~ .eyeston-select-trigger {
    border-color: var(--brand-navy, #1f3f68);
    outline: 2px solid rgba(31, 63, 104, 0.25);
    outline-offset: 0;
}

.eyeston-select.is-open .eyeston-select-chevron {
    transform: rotate(180deg);
}

.eyeston-select.is-disabled .eyeston-select-trigger {
    opacity: 0.55;
}
.eyeston-select.is-disabled > select {
    cursor: not-allowed;
}

/* The open list - appended to <body>, positioned to the trigger. */
.eyeston-select-panel {
    position: fixed;
    z-index: 99998;
    min-width: 160px;
    max-height: 280px;
    overflow-y: auto;
    background: var(--panel-solid, #fff);
    color: var(--ink, #16283c);
    border: 1px solid var(--brand-navy, #1f3f68);
    border-radius: 0;
    box-shadow: none;
    font-size: 13px;
}

.eyeston-select-option {
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.eyeston-select-option.is-active {
    background: var(--line, #e4e9f0);
}

.eyeston-select-option.is-selected {
    background: var(--brand-navy, #1f3f68);
    color: #fff;
}

.eyeston-select-option.is-disabled {
    color: var(--muted, #93a1b3);
    cursor: default;
    opacity: 0.6;
}

.eyeston-select-group {
    padding: 8px 12px 4px;
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted, #64748b);
    cursor: default;
}

/* ---------- Eyeston combobox ----------
   Free-text autocomplete fields (<input list>) keep the native input, so a
   clinician can still type a value that is not in the list. eyeston-combobox.js
   wraps the input and adds a dropdown arrow as its own region, so the cursor is
   a hand over the arrow and the text caret inside the field. It also strips the
   `list` attribute (killing the browser's own datalist popup) and shows the
   branded panel instead. */
.eyeston-combobox {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
}
.eyeston-combobox > input {
    width: 100%;
}
input.eyeston-combobox-input {
    padding-right: 30px !important; /* keep typed text clear of the arrow */
}
.eyeston-combobox-arrow {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;       /* hand over the arrow */
    color: #64748b;
    z-index: 2;
}
:root[data-theme="dark"] .eyeston-combobox-arrow {
    color: #a7a29a;
}
.eyeston-combobox-chevron {
    width: 14px;
    height: 14px;
    pointer-events: none;  /* clicks land on the arrow span, not the svg */
}

/* Contexts that size their selects via CSS rules (which target <select>,
   not the wrapper) - mirror the layout intent on the wrapper. */
.frontdesk-searchbar .eyeston-select {
    flex: 0 0 auto;
    width: auto;
    min-width: 150px;
}
.eyeston-task-add .eyeston-select {
    flex: 0 0 auto;
    width: auto;
    min-width: 140px;
}
.rx-fulfil-strip .eyeston-select {
    min-width: 240px;
    width: auto;
}

/* ---------- Dark mode ---------- */
/* DASHBOARD / main app: the widget follows the app's dark panel tokens
   (charcoal family), same as its native-select siblings. */
:root[data-theme="dark"] .eyeston-select-trigger {
    background: var(--panel-solid, #161616);
    color: var(--ink, #e6edf5);
    border-color: var(--line, #2c2c2c);
}
:root[data-theme="dark"] .eyeston-select-panel {
    background: var(--panel-solid, #161616);
    color: var(--ink, #e6edf5);
    border-color: var(--brand-navy, #1f3f68);
}
:root[data-theme="dark"] .eyeston-select-option.is-active {
    background: var(--line, #2c2c2c);
}
/* Public surfaces (landing, sign-in, online booking): the widget wears brand
   blue, never the charcoal family, because the charcoal boundary makes grey
   dashboard-only. The trigger lives in-page (.lp / .auth-body /
   .booking-body); the panel teleports to body and carries .is-public. */
:root[data-theme="dark"] .lp .eyeston-select-trigger,
:root[data-theme="dark"] .auth-body .eyeston-select-trigger,
:root[data-theme="dark"] .booking-body .eyeston-select-trigger,
:root[data-theme="dark"] .booking-page .eyeston-select-trigger,
:root[data-theme="dark"] .eyeston-select-panel.is-public {
    background: #152b49;
    color: #ffffff;
    border-color: #2b4a77;
}
:root[data-theme="dark"] .eyeston-select-panel.is-public {
    border-color: #2b4a77;
}
:root[data-theme="dark"] .eyeston-select-panel.is-public .eyeston-select-option.is-active {
    background: #1f3f68;
}
:root[data-theme="dark"] .eyeston-select-option.is-selected {
    background: var(--brand-navy, #1f3f68);
    color: #fff;
}

/* Type-to-filter feedback bar at the top of an open panel */
.eyeston-select-panel .eyeston-select-filterbar {
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
    color: #1f3f68;
    background: rgba(31, 63, 104, 0.06);
    border-bottom: 1px solid rgba(31, 63, 104, 0.15);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.eyeston-select-panel .eyeston-select-filterbar::before {
    content: "Filter: ";
    font-weight: 500;
    color: rgba(31, 63, 104, 0.6);
}
:root[data-theme="dark"] .eyeston-select-panel .eyeston-select-filterbar {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    border-bottom-color: #2b4a77;
}
:root[data-theme="dark"] .eyeston-select-panel .eyeston-select-filterbar::before {
    color: #a7a29a;
}
