/* Fixes Choices.js (the searchable product dropdown) for dark mode and
   sizing. Choices.js themes itself entirely through CSS custom properties
   (--choices-*), with light-mode-only defaults - overriding those
   variables under dark mode is the correct fix, not fighting individual
   property overrides. */

:root.dark {
  --choices-bg-color: #141B2E;          /* gray-800 - the input/search box background */
  --choices-bg-color-dropdown: #141B2E; /* gray-800 - the dropdown panel background */
  --choices-text-color: #E7EAF2;        /* gray-100 - input/option text color */
  --choices-keyline-color: #2B3342;     /* gray-700 - borders/dividers inside the dropdown */
  --choices-highlight-color: rgba(122, 155, 255, 0.18);
  --choices-highlighted-color: #E7EAF2; /* text color of the highlighted/hovered option */
}

/* Belt-and-braces: Choices.js's minified CSS defines .choices__input TWICE
   with two different background variables, and the second definition wins
   by source order regardless of which variable we set - so force it
   directly rather than trust variable resolution. */
:root.dark .choices__input {
  background-color: #141B2E !important;
  color: #E7EAF2 !important;
}
:root.dark .choices__input::placeholder {
  color: #9AA4B8 !important; /* gray-400 */
}

/* Give the dropdown and its trigger more breathing room - default sizing
   feels cramped, especially with longer product names. */
.choices__inner {
  min-height: 44px;
}
.choices__list--dropdown,
.choices__list[aria-expanded] {
  min-width: 280px;
  max-height: 280px;
}

/* Scoped fix for the item-entry tables on the Sale/Purchase "new" forms:
   their horizontal-scroll wrapper (needed for the table on narrow screens)
   was clipping the dropdown vertically, since setting overflow-x without
   overflow-y makes the browser compute overflow-y as "auto" too - which
   clips anything, like this dropdown, that extends below the wrapper.
   Scoped to .item-entry-scroll specifically so it doesn't affect the
   product/sales/purchases LIST pages, which intentionally keep horizontal
   scroll on their (wider, read-only) tables. */
.item-entry-scroll {
  overflow: visible !important;
}

/* ---------------------------------------------------------------------
   Filter-bar select width fix (Suppliers, Purchases, Sales, Payments
   list pages). Their <select> filter dropdowns share the .input class
   with text inputs (which need width:100% to fill an add/edit form's
   grid cell) - but on a filter bar, that same width:100% becomes each
   select's flex-basis when it's a flex sibling of the search box's
   flex-1 wrapper. Two elements each independently claiming 100% of the
   row dominates the layout and squeezes the search box down to almost
   nothing. .filter-select overrides that specifically for this context,
   without touching the base .input class other forms rely on.
   --------------------------------------------------------------------- */
.filter-select {
  flex: none !important;
  width: auto !important;
  min-width: 160px;
}
@media (max-width: 767px) {
  .filter-select {
    width: 100% !important;
  }
}
