/* ============================================
   UNIFIED DROPDOWN COMPONENT
   Searchable dropdowns with fuzzy matching
   ============================================ */

.unified-dropdown-wrapper {
  position: relative;
  width: 100%;
  display: inline-block;
  overflow: visible;
}

/* Trigger Button */
.unified-dropdown-trigger {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dde3ee;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  transition: all 0.2s;
  position: relative;
}

.unified-dropdown-trigger:hover {
  border-color: #063970;
  background: #f9fafb;
}

.unified-dropdown-trigger:focus {
  outline: none;
  border-color: #063970;
  box-shadow: 0 0 0 3px rgba(6, 57, 112, 0.1);
}

.unified-dropdown-trigger::after {
  content: '';
  position: absolute;
  right: 12px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid #9ca3af;
  border-bottom: 1.5px solid #9ca3af;
  transform: rotate(-45deg);
  pointer-events: none;
  transition: transform 0.2s;
}

.unified-dropdown-wrapper.open .unified-dropdown-trigger::after {
  transform: rotate(135deg);
  top: -1px;
}

/* Dropdown Menu */
.unified-dropdown-menu {
  position: fixed;
  top: 0;
  left: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid #dde3ee;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 300px;
  overflow: hidden;
  flex-direction: column;
  display: none;
}

/* Search Input */
.unified-dropdown-search {
  padding: 8px;
  border-bottom: 1px solid #e8edf5;
  background: #f9fafb;
}

.unified-dropdown-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dde3ee;
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #374151;
  transition: all 0.2s;
  box-sizing: border-box;
}

.unified-dropdown-search-input:focus {
  outline: none;
  border-color: #063970;
  box-shadow: 0 0 0 3px rgba(6, 57, 112, 0.1);
}

.unified-dropdown-search-input::placeholder {
  color: #9ca3af;
}

/* Options List */
.unified-dropdown-options {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding: 4px 0;
  min-width: max-content;
  max-width: 600px;
}

.unified-dropdown-options::-webkit-scrollbar {
  width: 6px;
}

.unified-dropdown-options::-webkit-scrollbar-track {
  background: transparent;
}

.unified-dropdown-options::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.unified-dropdown-options::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Option Item */
.unified-dropdown-option {
  padding: 10px 14px;
  cursor: pointer;
  color: #374151;
  transition: all 0.1s;
  border-left: 3px solid transparent;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.4;
  min-height: auto;
}

.unified-dropdown-option:hover {
  background: #f3f4f6;
  color: #063970;
}

.unified-dropdown-option.selected {
  background: #eff6ff;
  color: #063970;
  border-left-color: #063970;
  font-weight: 600;
}

.unified-dropdown-option.selected:hover {
  background: #e0f2fe;
}

/* Highlighted matching characters */
.unified-dropdown-option mark {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
  padding: 0 2px;
  border-radius: 2px;
}

/* No results message */
.unified-dropdown-no-results {
  padding: 12px 14px;
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
  font-style: italic;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
  .unified-dropdown-trigger {
    padding: 10px 12px;
    font-size: 14px;
  }

  .unified-dropdown-menu {
    max-height: 250px;
  }

  .unified-dropdown-option {
    padding: 12px 14px;
    font-size: 14px;
  }
}

/* ============================================
   FORM INTEGRATION
   ============================================ */

/* When unified dropdown is in a form-group */
.form-group .unified-dropdown-wrapper {
  width: 100%;
}

.form-group .unified-dropdown-trigger {
  font-size: 13px;
}


/* ── Group headings ────────────────────────────────────────────────────────
   A payment picker lists two different kinds of thing — the company's own bank
   and cash accounts, and staff/director floats. They were previously one flat
   list in which "KBank - 760-101806-8" and "Mui - KBank 029-8-77036-9" sat
   adjacent as near-identical strings, and a ฿140 transfer went to the wrong one.
   The heading and its rule are the separation that prevents that. */
.unified-dropdown-group {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #6b7280;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    cursor: default;
    user-select: none;
}
.unified-dropdown-group:first-child {
    border-top: none;
}

/* Bank logo beside the account name. Fixed box so names stay aligned whether or
   not a logo exists, and whether the file loads. */
.unified-dropdown-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: -4px;
    margin-right: 8px;
    flex-shrink: 0;
}
