/* ── Searchable combo component (Career Analysis redesign, Task 01) ──
   Generalized single-select searchable combobox. Reused by configuration for Country,
   State/Province, Currency, Highest Education, and Stream/Major — do not duplicate these
   rules per-field; add field-specific tweaks (if truly needed) as additional classes, not forks. */

.searchable-combo {
  position: relative;
}

.searchable-combo__input {
  width: 100%;
  min-height: 44px; /* touch target minimum */
  padding: 0.625rem 2rem 0.625rem 0.75rem;
  border: 1px solid var(--color-border, #D1D5DB);
  border-radius: var(--radius-md, 0.375rem);
  font-size: var(--font-size-base, 1rem); /* >=16px avoids iOS auto-zoom */
  color: var(--color-text-primary, #111827);
  background: var(--color-surface, #fff);
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

/*
 * Host pages (e.g. market-estimate.html) apply their own `.estimate-form__input` class to the
 * SAME <input> this component enhances, and that page stylesheet typically loads AFTER this one —
 * at equal specificity, source order would let it silently win the cascade on `padding`, collapsing
 * the space reserved for the chevron below. This compound selector has higher specificity than
 * either class alone, so it wins regardless of stylesheet load order on either page. Extend this
 * list (don't remove the base rule above) if another host page uses a different input class.
 */
.estimate-form__input.searchable-combo__input,
.form-row input.searchable-combo__input {
  padding-right: 2rem;
}

.searchable-combo__chevron {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  display: inline-flex;
  color: var(--color-text-tertiary, #6B7280);
  pointer-events: none;
}

.searchable-combo__input:focus {
  outline: 2px solid var(--color-primary, #2563EB);
  outline-offset: 1px;
  border-color: var(--color-primary, #2563EB);
}

.searchable-combo__input:disabled,
.searchable-combo__input[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--color-surface-disabled, #F3F4F6);
}

.searchable-combo__input:disabled ~ .searchable-combo__chevron {
  opacity: 0.5;
}

.searchable-combo__listbox {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #D1D5DB);
  border-radius: var(--radius-md, 0.375rem);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  max-height: 280px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  /* Keep the panel usable on small screens without ever exceeding the viewport */
  max-width: 100vw;
}

.searchable-combo__listbox[hidden] {
  display: none;
}

.searchable-combo__option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 44px; /* touch target minimum */
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  font-size: var(--font-size-base, 1rem);
  color: var(--color-text-primary, #111827);
  box-sizing: border-box;
}

.searchable-combo__option:hover,
.searchable-combo__option:focus {
  background-color: var(--color-primary-light, #EFF6FF);
  color: var(--color-primary, #2563EB);
  outline: none;
}

.searchable-combo__option-secondary {
  flex-shrink: 0;
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--color-text-muted, #6B7280);
}

.searchable-combo__option--static {
  cursor: default;
  color: var(--color-text-muted, #6B7280);
  font-style: italic;
}

.searchable-combo__option--static[aria-disabled="true"]:hover {
  background: none;
  color: var(--color-text-muted, #6B7280);
}

.searchable-combo__option--error {
  cursor: pointer;
  color: var(--color-danger, #DC2626);
  font-style: normal;
}

.searchable-combo__option--error:hover {
  background-color: var(--color-danger-light, rgba(220, 38, 38, 0.05));
}

@media (prefers-reduced-motion: reduce) {
  .searchable-combo__input { transition: none; }
}
