/* ==========================================================================
   Find parts by manufacturer form
   Colours/spacing driven by the design tokens in style.css (:root)
   ========================================================================== */
:root {
  /* Map the form's local names onto the theme tokens so this form
     stays in sync with the global style guide. */
  --bc-fp-accent: var(--primary, #d94100);
  --bc-fp-accent-fg: var(--primary-foreground, #ffffff);
  /* Peach tint of the primary for the "filled" state
     (matches the mockup: 10% primary over transparent, mixed in oklab) */
  --bc-fp-accent-bg: color-mix(
    in oklab,
    var(--primary, #d94100) 10%,
    transparent
  );
  --bc-fp-label: var(--muted-foreground, #717171);
  --bc-fp-border: color-mix(
    in srgb,
    var(--foreground, #181818) 12%,
    transparent
  );
  --bc-fp-card: var(--card, #ffffff);
  --bc-fp-text: var(--foreground, #181818);
  --bc-fp-radius: var(--radius-lg, 10px);
}

.bc-find-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
}

.bc-find-form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 80px;
  min-width: 180px;
}

.bc-find-form-label {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bc-fp-label);
}

/* --------------------------------------------------------------------------
   Tom Select control box
   -------------------------------------------------------------------------- */
.bc-find-form-field .ts-wrapper {
  margin: 0;
  background: transparent;
  font-family: var(--font-sans);
}

.bc-find-form-field .ts-wrapper .ts-control {
  /* base tom-select forces padding-right via this var (with !important),
     so reserve chevron space here rather than in the padding shorthand */
  --ts-pr-min: 2.5rem;
  background-color: var(--bc-fp-card);
  border: 1px solid var(--bc-fp-border);
  border-radius: var(--bc-fp-radius);
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--bc-fp-text);
  box-shadow: none;
  min-height: 0;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.bc-find-form-field .ts-wrapper .ts-control:hover {
  border: 1px solid var(--primary);
}

/* Filled state — light peach fill + primary border, like the mockup.
   Tom Select adds `has-items` to the wrapper once a value is chosen. */
.bc-find-form-field .ts-wrapper.has-items .ts-control {
  background-color: var(--bc-fp-accent-bg);
  border-color: var(--bc-fp-accent);
}

/* Placeholder text (empty state) reads muted */
.bc-find-form-field .ts-wrapper:not(.has-items) .ts-control,
.bc-find-form-field .ts-wrapper .ts-control input::placeholder {
  color: var(--bc-fp-label);
  font-weight: 500;
}

.bc-find-form-field .ts-wrapper.disabled .ts-control {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Chevron — replace the default triangle with a rotating chevron */
.bc-find-form-field .ts-wrapper .ts-control::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border: 0;
  border-right: 2px solid var(--bc-fp-text);
  border-bottom: 2px solid var(--bc-fp-text);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.bc-find-form-field .ts-wrapper.dropdown-active .ts-control::after {
  margin-top: -2px;
  transform: rotate(-135deg);
}

/* --------------------------------------------------------------------------
   Dropdown menu
   -------------------------------------------------------------------------- */
.ts-dropdown.bc-find-form-dropdown .ts-dropdown-content {
  max-height: 400px; /* e.g. ~8 rows at current row height */
}

.ts-dropdown.bc-find-form-dropdown {
  margin-top: 6px;
  border: 1px solid var(--bc-fp-border);
  border-radius: var(--bc-fp-radius);
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
  overflow: hidden;
  font-family: var(--font-sans);
}

.ts-dropdown.bc-find-form-dropdown .option {
  padding: 10px 16px;
  font-size: 15px;
  color: var(--bc-fp-text);
  border-left: 3px solid transparent;
}

/* Hover / keyboard-highlighted option */
.ts-dropdown.bc-find-form-dropdown .option.active {
  background-color: var(--bc-fp-accent-bg);
  color: var(--bc-fp-text);
}

/* Currently selected option — peach fill, bold, primary check on the right */
.ts-dropdown.bc-find-form-dropdown .option.selected {
  background-color: var(--bc-fp-accent-bg);
  border-left-color: var(--bc-fp-accent);
  font-weight: 700;
  position: relative;
}

.ts-dropdown.bc-find-form-dropdown .option.selected::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  width: 6px;
  height: 11px;
  margin-top: -7px;
  border-right: 2px solid var(--bc-fp-accent);
  border-bottom: 2px solid var(--bc-fp-accent);
  transform: rotate(45deg);
}

/* --------------------------------------------------------------------------
   Submit button
   -------------------------------------------------------------------------- */
.bc-find-form-actions {
  flex-basis: 100%;
  margin-top: 4px;
}

.bc-find-form-actions .gb-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bc-fp-accent);
  color: var(--bc-fp-accent-fg);
  border-radius: var(--bc-fp-radius);
  padding: 14px 28px;
  font-family: var(--font-sans);
  font-size: inherit; /* <button> UA font is smaller — match the old span */
  line-height: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
  -webkit-appearance: none;
  appearance: none;
}

.bc-find-form-actions .gb-button:hover {
  background-color: color-mix(in srgb, var(--bc-fp-accent) 88%, black);
}

/* Disabled until a manufacturer is chosen */
.bc-find-form-actions .gb-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bc-find-form-actions .gb-button:disabled:hover {
  background-color: var(--bc-fp-accent);
}

@media (max-width: 640px) {
  .bc-find-form-field {
    flex: 1 1 100%;
  }
}
