/* ─────────────────────────────────────────────────────────────────────────────
   StyledSelect (Components/StyledSelect.razor) — line-for-line port of React
   components/shared/StyledSelect.css, form variant + option panel.
   React stamps an env class on the portaled panel (detectFormEnvClass: home-page /
   env-page / form-slideout-env…). `.home-page` is a page-layout class in this app,
   so the Home colorway is opted into with PanelClass="styled-select-panel-home"
   instead (Project Setup uses it — React's wizard resolves to home-page).
   ───────────────────────────────────────────────────────────────────────────── */

.styled-select-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}

/* Trigger button — base shared by all variants */
.styled-select-trigger {
  display: flex;
  align-items: center;
  gap: 6.4px;
  width: 100%;
  height: 24px;
  padding: 0 6.4px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 500;
  line-height: normal;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  border-radius: 2.4px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.styled-select-trigger:focus {
  outline: none;
}

.styled-select-trigger.is-disabled {
  cursor: not-allowed;
}

.styled-select-label {
  flex: 1;
  /* Grid-stack: current label + invisible sizers share one cell (trigger sizes to the widest option). */
  display: inline-grid;
  grid-template-areas: "stack";
}

.styled-select-label-current,
.styled-select-label-sizer {
  grid-area: stack;
  white-space: nowrap;
}

.styled-select-label-sizer {
  visibility: hidden;
  pointer-events: none;
}

/* Form variant: constrained by its column — the label may shrink and clip with an ellipsis. */
.styled-select-trigger-form .styled-select-label,
.styled-select-trigger-form .styled-select-label-current,
.styled-select-trigger-form .styled-select-label-sizer {
  min-width: 0;
}

.styled-select-trigger-form .styled-select-label-current,
.styled-select-trigger-form .styled-select-label-sizer {
  overflow: hidden;
  text-overflow: ellipsis;
}

.styled-select-chevron {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 8px;
  height: 4.8px;
  color: #888;
}

/* -- Form variant: mirrors .crf-divcost-button -- */
.styled-select-trigger-form {
  background: #ffffff;
  border: 1px solid #d9d9d9;
  color: #333;
}

.styled-select-trigger-form .styled-select-chevron {
  width: 10px;
  height: 6px;
}
.styled-select-trigger-form .styled-select-chevron svg {
  width: 10px;
  height: 6px;
}

.styled-select-trigger-form:hover:not(.is-disabled) {
  border-color: #b5b5b5;
}

.styled-select-trigger-form:focus {
  border-color: var(--brand-bg, #5b9bd5);
  box-shadow: 0 0 0 1.6px color-mix(in srgb, var(--brand-bg, #5b9bd5) 18%, transparent);
}

/* Empty (placeholder) state */
.styled-select-trigger-form.styled-select-empty .styled-select-label {
  color: #b0b0b0;
}

/* Disabled — neutral LOCKED look */
.styled-select-trigger-form.is-disabled {
  background: #f5f5f5;
  color: #555;
  border-color: #d9d9d9;
  cursor: not-allowed;
}

.styled-select-trigger-form.is-disabled .styled-select-chevron {
  color: #999;
}

.styled-select-trigger-form.is-disabled .styled-select-label {
  color: #555;
}

/* -- Option panel (position / width set by styled-select.js) -- */
.styled-select-panel {
  position: fixed;
  top: 0;
  left: 0;
  max-width: none;
  width: auto;
  height: auto;
  min-height: 0;
  max-height: 256px;
  overflow-y: auto;
  background: #ffffff;
  /* Hangs flush below the trigger — flat top, rounded bottom. */
  border: 1px solid #d9d9d9;
  border-top: none;
  border-radius: 0 0 2.4px 2.4px;
  box-shadow: 0 3.2px 9.6px rgba(0, 0, 0, 0.12);
  padding: 0;
  box-sizing: border-box;
  /* React: 1000 outside modals (the panel is portaled; here it sits in the trigger's
     stacking context, so it only has to clear its own page — the setup shell is 1000). */
  z-index: 1000;
}

.styled-select-item {
  display: block;
  width: 100%;
  background: #ffffff;
  border: none;
  border-bottom: 1px solid #ececec;
  padding: 4.8px 9.6px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 500;
  line-height: normal;
  color: #333;
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Item padding aligned to the form trigger's left padding. */
.styled-select-panel-form .styled-select-item {
  padding-left: 6.4px;
  padding-right: 6.4px;
}

.styled-select-item:last-child {
  border-bottom: none;
}

.styled-select-item:hover,
.styled-select-item.is-active {
  background: #f5f5f0;
}

.styled-select-item.is-selected {
  background: color-mix(in srgb, var(--brand-hover, #5b9bd5) 20%, white);
  color: #222;
  font-weight: 600;
}

/* Home colorway (React .home-page on the panel). */
.styled-select-panel-home .styled-select-item.is-selected {
  background: color-mix(in srgb, #5b9bd5 20%, white);
}

/* Form dropdowns: the committed row is the anchor — env secondary tint + left accent bar,
   not bold. Higher specificity than every env .is-selected colorway. */
.styled-select-panel.styled-select-panel-form .styled-select-item.is-selected {
  background: color-mix(in srgb, var(--brand-hover, #5b9bd5) 24%, white);
  box-shadow: inset 3px 0 0 var(--brand-hover, #5b9bd5);
  color: #222;
  font-weight: 500;
}

.styled-select-item.is-disabled {
  color: #b8b8b8;
  cursor: not-allowed;
}

.styled-select-item.is-disabled:hover,
.styled-select-item.is-disabled.is-active {
  background: #ffffff;
}

/* "+ Add New"-style option: bold, env-secondary text. */
.styled-select-item-add-new {
  font-weight: 600;
}
.styled-select-panel-home .styled-select-item-add-new {
  color: #5b9bd5;
}
