/* Shared language-dropdown (select2) styling for the patient web forms.
 *
 * Brings select2 in line with the field system in task-web-form-refresh.md item 11:
 * "10px radius, 1.5px borders, tinted rest fill, primary-tinted focus ring" -- and item 3,
 * "tinted fill (--bg) at rest and turn white on focus with the primary focus ring".
 *
 * WHY A SHARED FILE. This block was previously inlined (partially, and differently) in each
 * template, which is how it drifted. Measured across the 15 templates that render a language
 * dropdown: only 2 styled the OPEN control, only 5 styled option hover, and NONE styled the
 * dropdown panel -- so on most forms clicking it revealed select2's stock #aaa border, 4px
 * corners and #5897fb blue highlight hanging off a 10px-radius control.
 *
 * TOKEN FALLBACKS ARE LOAD-BEARING, NOT DEFENSIVE. Seven of the fifteen templates
 * (smartdimensions, referral-auth-form, smart-dimension-form, smart-dimension-new-form and the
 * three ca-smartdimensions-*) define NO CSS custom properties at all -- they never received the
 * redesign layer. A bare var(--primary) there is invalid at computed-value time, the declaration
 * is dropped, and select2's defaults survive: the file would silently do nothing on nearly half
 * the forms. The fallbacks are the mockup's own token values, so those forms get the reference
 * navy until their per-client theme block is added, at which point the client colour takes over
 * with no change here.
 *
 * SCOPING. select2 appends its panel to <body>, OUTSIDE the form, so panel rules cannot be
 * scoped under .insurance-form-redesign or any other form-level class. They hang off the
 * .lang-dropdown class that the select2 init passes via dropdownCssClass -- which keeps them off
 * every other select2 on the page (diagnosis-code-select, etc.). Any template initialising the
 * language select MUST pass dropdownCssClass: 'lang-dropdown notranslate' or none of the panel
 * rules below will match.
 */

/* ---------- closed control ---------- */
/* Scoped by the select's own id rather than a blanket .select2-selection--single, which would
 * also restyle unrelated select2 controls on the same page.
 * On the templates that already carry a redesign layer this is a no-op -- background, radius and
 * the declared 1.5px border all already matched. It is restated so the seven templates with no
 * redesign layer get the same control instead of select2's stock 1px #aaa.
 * NOTE ON 1.5px: getComputedStyle reports "1px" for this at devicePixelRatio 1 -- Chrome rounds
 * sub-pixel border widths to whole device pixels in the used value. A freshly created div with
 * border:1.5px reports 1px too, as do this page's text inputs and option pills. That is expected;
 * it is not a cascade failure and does not need "fixing" with a 2px value. */
#language_radio + .select2-container .select2-selection--single,
#language_radio_csv + .select2-container .select2-selection--single,
.lang_dropdown_div .select2-container .select2-selection--single {
	/* background-COLOR, not the `background` shorthand: the shorthand resets background-image to
	   none, which would wipe the chevron applied in the "native select look" section below. */
	background-color: var(--bg, #F4F5F9) !important;
	border: 1.5px solid var(--line, #E4E6EE) !important;
	border-radius: 10px !important;
}

/* ---------- open control: white fill + primary ring, same affordance as every other field ---------- */
#language_radio + .select2-container.select2-container--open .select2-selection--single,
#language_radio_csv + .select2-container.select2-container--open .select2-selection--single,
.lang_dropdown_div .select2-container.select2-container--open .select2-selection--single {
	/* background-COLOR again -- a native select keeps its arrow while open, so the shorthand must
	   not blank the chevron out from under it. */
	background-color: #fff !important;
	border-color: var(--primary, #1B3A6B) !important;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #1B3A6B) 12%, transparent) !important;
	outline: none !important;
}

/* ---------- panel ---------- */
/* select2 ships border:1px solid #aaa and border-radius:0 0 4px 4px, which is what made the open
 * state read as a different design system from the control it drops out of. */
.lang-dropdown.select2-dropdown,
.select2-container--open .lang-dropdown {
	border: 1.5px solid var(--line, #E4E6EE) !important;
	border-radius: 10px !important;
	overflow: hidden !important;
	box-shadow: 0 4px 14px rgba(20, 30, 60, .10), 0 14px 40px rgba(20, 30, 60, .12) !important;
}
.lang-dropdown .select2-results__options {
	border-radius: 10px !important;
}

/* ---------- options ---------- */
.lang-dropdown .select2-results__option {
	font-size: 13.5px !important;
	padding: 9px 12px !important;
	color: var(--ink, #23262E) !important;
}

/* Hover / keyboard-highlight. The mockup has no select2 panel to copy -- it uses native selects,
 * where the OS draws the list -- so this is a derivation. Solid primary + white matches the
 * mockup's ".yn button.sel" treatment and is what the two already-updated templates shipped. */
.lang-dropdown .select2-results__option--highlighted,
.lang-dropdown .select2-results__option--highlighted.select2-results__option--selectable {
	background-color: var(--primary, #1B3A6B) !important;
	color: #fff !important;
}

/* Current value, when not hovered: the mockup's soft-tint selected state (".opt.sel"), so the
 * active language stays legible rather than reading as a second hover. */
.lang-dropdown .select2-results__option[aria-selected="true"]:not(.select2-results__option--highlighted) {
	background-color: var(--primary-soft, #E8EEF8) !important;
	color: var(--ink, #23262E) !important;
}

/* ---------- Treatment / Insurance Plan Type fields (.hv-s2) ----------
 * Wrapper class set by assets/app/js/hive-select2-fields.js, which turns #choose-treatment and
 * #interested-in-a-specific-insurance into select2 on the redesigned forms (a native <select> popup is
 * OS-styled and as wide as its longest option, so on the widget it ran past the card). The panel is
 * appended INSIDE this wrapper (dropdownParent), so every rule here is scoped by it and nothing else
 * on the page is touched. Closed control mirrors the mockup .fld input: 42px, --bg fill, 1.5px
 * --line border, 10px radius, 13.5px --ink, chevron arrow. Token fallbacks are the mockup defaults. */
.hv-s2 { position: relative !important; }
.hv-s2 > .select2-container { width: 100% !important; }
.hv-s2 > .select2-container .select2-selection--single {
	height: 42px !important; display: flex !important; align-items: center !important; outline: none !important;
	background-color: var(--bg, #F4F5F9) !important; border: 1.5px solid var(--line, #E4E6EE) !important;
	border-radius: 10px !important;
}
/* Rendered text + arrow carry .select2-container--default so they out-rank the sticker templates' own
 * ".sticky_form(_template) .select2-container--default .select2-selection--single .select2-selection__*"
 * rules (0,4,0) -- those set line-height:45px and arrow top:10px/5px, which pushed the text and chevron
 * to the bottom of the 38px box. */
.hv-s2 > .select2-container .select2-selection__rendered,
.hv-s2 > .select2-container.select2-container--default .select2-selection--single .select2-selection__rendered {
	padding: 0 32px 0 12px !important; height: 39px !important; line-height: 39px !important;
	font-size: 13.5px !important; color: var(--ink, #23262E) !important; text-align: left !important;
	white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; flex: 1 1 auto !important;
}
.hv-s2 > .select2-container .select2-selection__arrow,
.hv-s2 > .select2-container.select2-container--default .select2-selection--single .select2-selection__arrow { top: 0 !important; height: 39px !important; right: 8px !important; }
/* select2 draws a solid grey triangle; the mockup (and every native redesign select) uses the 10x6
 * chevron. The triangle is hidden and the same chevron SVG as hive-webform.css section 2 is painted. */
.hv-s2 > .select2-container.select2-container--default .select2-selection--single .select2-selection__arrow b { display: none !important; }
.hv-s2 > .select2-container.select2-container--default .select2-selection--single .select2-selection__arrow {
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23767B87' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center center !important;
}
.hv-s2 > .select2-container.select2-container--open .select2-selection--single,
.hv-s2 > .select2-container.select2-container--focus .select2-selection--single {
	background-color: #fff !important; border-color: var(--primary, #1B3A6B) !important;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #1B3A6B) 12%, transparent) !important;
}
/* Validation still shows the field's error label and borders the (now hidden) native select, so the
 * red outline is mirrored onto the visible box -- "the label is the border". */
.hv-s2:has(label.error[style*="display: block"]) > .select2-container .select2-selection--single {
	border-color: var(--error, #DC5A5A) !important;
}
/* Panel: placed under the box at its width by the JS (the bundled select2 mis-measures here). */
/* 1000: field error labels on these templates sit at z-index 999 and otherwise paint over the open list. */
.hv-s2 > .select2-container:has(> .select2-dropdown) { z-index: 1000 !important; }
.hv-s2 .select2-dropdown {
	width: 100% !important; border: 1.5px solid var(--line, #E4E6EE) !important; border-radius: 10px !important;
	overflow: hidden !important; box-shadow: 0 4px 14px rgba(20, 30, 60, .10), 0 14px 40px rgba(20, 30, 60, .12) !important;
}
.hv-s2 .select2-results__option {
	font-size: 13.5px !important; padding: 9px 12px !important; color: var(--ink, #23262E) !important;
	white-space: normal !important; line-height: 1.35 !important; text-align: left !important;
}
/* Hover / keyboard highlight and the current value. Two traps:
 * - the widget templates ship inline ".select2-container--default .select2-results__option--highlighted
 *   .select2-results__option--selectable{background:#fff !important}" (+ a :hover #ccc variant), which
 *   out-ranked a plain class rule -- grey fill under white text. The chain below is more specific.
 * - select2 4.1 marks the CURRENT VALUE with .select2-results__option--selected (default grey #ddd);
 *   aria-selected="true" there means HIGHLIGHTED, not chosen. */
.hv-s2 .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable,
.hv-s2 .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable:hover {
	background-color: var(--primary, #1B3A6B) !important; color: #fff !important;
}
.hv-s2 .select2-container--default .select2-results__option--selected:not(.select2-results__option--highlighted) {
	background-color: var(--primary-soft, #E8EEF8) !important; color: var(--ink, #23262E) !important;
}
/* Grouped Insurance Plan Type (insurance-plan-groups.js optgroups). The group <li> took the full 9px
 * option padding on top of its label's own 6px, so the gaps between groups read as too loose
 * (John, 2026-11-09: reduce by 50%). Both halved; the options inside keep their 9px. */
.hv-s2 .select2-results__option[role="group"] { padding-top: 4.5px !important; padding-bottom: 4.5px !important; }
.hv-s2 .select2-results__group { padding-top: 3px !important; padding-bottom: 3px !important; }

/* Language options show their country flag left of the name (hive-select2-fields.js). */
/* Spacing is a margin on the flag, not flex gap: in the closed field the span did not stay inline-flex,
 * so gap was ignored and the flag touched the name (Nenshi, 2026-11-16). */
.hv-s2-flag { display: inline-flex; align-items: center; min-width: 0; }
.hv-s2-flag .fi { flex: 0 0 auto; width: 1.333em; line-height: 1em; border-radius: 2px; margin-right: 8px !important; }

/* Open flag list (Nenshi, 2026-11-17). This picker reuses the OLD language picker's class names, and the
 * templates' inline legacy CSS still hits it:
 * - ".lang-dropdown ul li { width:158px/140px !important }" sized the rows for the old compact picker, so
 *   the hover bar stopped mid-panel. Rows fill the panel again.
 * - ".lang_dropdown_div .notranslate { color:<form font colour> !important; background:... }" also matches
 *   the flag+name span (it carries .notranslate), forcing dark text onto the navy hover row -- only the flag
 *   showed. The span now follows its row, and the hovered row is set to white directly, because some
 *   combined templates colour the rows themselves with ID-level !important rules. */
.hv-s2 .lang-dropdown .select2-results__option,
.hv-s2 .lang-dropdown ul li { width: auto !important; }
.hv-s2 .lang-dropdown .hv-s2-flag,
.hv-s2 .lang-dropdown .hv-s2-flag span:not(.fi) { color: inherit !important; background: transparent !important; border: 0 !important; }
.hv-s2 .lang-dropdown .select2-results__option--highlighted .hv-s2-flag,
.hv-s2 .lang-dropdown .select2-results__option--highlighted .hv-s2-flag span:not(.fi) { color: #fff !important; }

/* ONE colour scheme for the open language list on every form (Nenshi, 2026-11-17): resting rows white /
 * ink, hover solid --primary / white, current value --primary-soft / ink. The sticker and two-column
 * templates (and the combined forms) carry their own ID-level row colours -- e.g.
 * "#conversion_sticker.sticker-form-redesign .lang-dropdown ul li.select2-results__option--highlighted
 * { background: var(--primary-soft); color: var(--ink) }" at (1,3,2) -- which made the sticker hover a
 * pale row under the white hover text above. Each rule is therefore stated twice: plainly, and prefixed
 * with #conversion_sticker plus the extra .select2-results level, one step above every template rule so
 * it wins whatever order the stylesheets load in. */
.hv-s2 .lang-dropdown .select2-results ul li,
#conversion_sticker .hv-s2 .lang-dropdown .select2-results ul li {
	background: #fff !important; color: var(--ink, #23262E) !important; font-weight: 400 !important;
}
.hv-s2 .lang-dropdown .select2-results ul li.select2-results__option--selected:not(.select2-results__option--highlighted),
#conversion_sticker .hv-s2 .lang-dropdown .select2-results ul li.select2-results__option--selected:not(.select2-results__option--highlighted) {
	background: var(--primary-soft, #E8EEF8) !important; color: var(--ink, #23262E) !important; font-weight: 400 !important;
}
.hv-s2 .lang-dropdown .select2-results ul li.select2-results__option--highlighted,
#conversion_sticker .hv-s2 .lang-dropdown .select2-results ul li.select2-results__option--highlighted {
	background: var(--primary, #1B3A6B) !important; color: #fff !important;
}

/* PUF repeater count select ("How many Facility/Date") is the one select2 inside a .has_float_label
 * wrapper. ivs-main.css's caption rule ".has_float_label span" (absolute, top/left, 9-12px, white fill,
 * pointer-events:none) also hits every select2 <span>: the box collapsed to 2px x 0, the chevron sat at
 * the left edge and clicks fell through (Nenshi, 2026-11-16). Undo it for select2's spans only; the
 * .hv-s2 box rules above (with !important) still set the look. */
.has_float_label.hv-s2 .select2-container,
.has_float_label.hv-s2 .select2-container span {
	pointer-events: auto !important; font-size: inherit; font-family: inherit; transition: none !important;
}
.has_float_label.hv-s2 > .select2.select2-container { position: relative !important; display: block !important; top: auto !important; left: auto !important; }
.has_float_label.hv-s2 .select2-container .selection,
.has_float_label.hv-s2 .select2-selection,
.has_float_label.hv-s2 .select2-selection__rendered,
.has_float_label.hv-s2 .select2-selection__placeholder,
.has_float_label.hv-s2 .select2-results,
.has_float_label.hv-s2 .select2-search { position: static !important; top: auto !important; left: auto !important; }
.has_float_label.hv-s2 .select2-container .selection,
.has_float_label.hv-s2 .select2-results,
.has_float_label.hv-s2 .select2-search--dropdown:not(.select2-search--hide) { display: block !important; }
.has_float_label.hv-s2 .select2-selection__rendered { background: transparent !important; }
.has_float_label.hv-s2 .select2-selection__arrow { left: auto !important; }
.has_float_label.hv-s2 .select2-dropdown { top: auto !important; left: 0 !important; background-color: #fff !important; }
/* The wrapper is a flex row, so the empty caption span took a slot beside the box (box 22px narrow)
 * and the 5px-tall row threw off the panel placement. The select's first option already shows the question. */
div.has_float_label.hv-s2 { display: block !important; height: auto !important; }
.has_float_label.hv-s2 > .dynamic_questions_field:empty { display: none !important; }
