/**
 * Shared currency picker UI — custom rate-select menus and Select2 currency dropdowns.
 */

/* ------------------------------------------------------------------ custom rate-select (e.g. dashboard FX) */
.rate-select {
  position: relative;
}

.rate-select-btn {
  width: 100%;
  border: 1px solid var(--border-subtle, #e2e8f0);
  background: var(--surface, #fff);
  border-radius: var(--radius-sm, 8px);
  height: 44px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rate-select-btn:hover,
.rate-select-btn:focus,
.rate-select-open .rate-select-btn {
  border-color: var(--primary-color, #16a34a);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color, #16a34a) 18%, transparent);
}

.rate-select-value {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary, #0f172a);
  font-weight: 600;
  font-size: 13px;
}

.rate-flag,
.currency-select-flag {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--border-subtle, #e2e8f0);
  flex-shrink: 0;
}

.rate-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: min(280px, calc(100vw - 48px));
  background: var(--surface, #fff);
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  display: none;
  margin: 0;
  padding: 4px 0;
  list-style: none;
}

.rate-select-open .rate-select-menu {
  display: block;
}

.rate-option {
  width: 100%;
  border: 0;
  background: var(--surface, #fff);
  text-align: left;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  cursor: pointer;
  color: var(--text-primary, #0f172a);
  line-height: 1.3;
}

.rate-option:hover {
  background: var(--surface-muted, #f8fafc);
}

.rate-option > span {
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.rate-option small {
  display: block;
  width: 100%;
  padding-left: 26px;
  color: var(--text-muted, #64748b);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
}

/* ------------------------------------------------------------------ Select2 currency selects */
.currency-select + .select2-container {
  width: 100% !important;
}

.currency-select + .select2-container .select2-selection--single {
  height: 44px;
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface, #fff);
}

.currency-select + .select2-container .select2-selection__rendered {
  line-height: 42px;
  padding-left: 10px;
  padding-right: 28px;
  color: var(--text-primary, #0f172a);
}

.currency-select + .select2-container .select2-selection__arrow {
  height: 42px;
}

.currency-select-selection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

.currency-select-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 2px 0;
  line-height: 1.3;
  min-width: 200px;
}

.currency-select-option__primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary, #0f172a);
}

.currency-select-option__name {
  display: block;
  width: 100%;
  padding-left: 26px;
  color: var(--text-muted, #64748b);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
}

.select2-container--default .select2-results__option--highlighted .currency-select-option__name {
  color: inherit;
  opacity: 0.85;
}

.select2-container--default .select2-results__option {
  padding: 8px 12px;
}

.select2-dropdown.currency-select-dropdown {
  border-color: var(--border-subtle, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.select2-dropdown.currency-select-dropdown .select2-results__options {
  max-height: 260px;
}
