/* ═══════════════════════════════════════════════════════════════════════════
   Select2 im Design der App.

   Grundgedanke: Der Container von Select2 übernimmt die Klassen des ursprünglichen
   Feldes (containerCssClass: ':all:'). Damit greifen .input-contrast, .form-select
   und die Höhenklassen (h-8 … h-12) unverändert weiter – der Container IST das Feld.
   Das innere Gerüst von Select2 wird dafür durchsichtig gemacht.
   Wird nach dist/output.css und app-forms.css geladen.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Das Feld ───────────────────────────────────────────────────────────── */
.select2-container {
  /* display bleibt inline-block (Select2-Standard), damit w-full und min-w-… wirken
     wie beim nativen Feld – ein erzwungenes block würde jedes Feld breit ziehen. */
  box-sizing: border-box;
  padding: 0 !important; /* der Innenabstand sitzt am gerenderten Text */
  vertical-align: middle;
  max-width: 100%;
}

/* Ohne Höhenklasse die Maße der Textfelder übernehmen */
.select2-container .select2-selection--single {
  min-height: 2.5rem;
}

.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
  height: 100%;
  display: flex;
  align-items: center;
  background: transparent;
  border: none;
  border-radius: inherit;
  font: inherit;
  color: inherit;
  outline: none;
  cursor: pointer;
}

/* Gewählter Text */
.select2-container--default .select2-selection--single .select2-selection__rendered {
  flex: 1;
  min-width: 0;
  padding: 0 2.25rem 0 0.875rem;
  line-height: 1.4;
  color: inherit;
  font-weight: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: #a8a29e;
  font-weight: 400;
}

/* Kompakte Felder brauchen weniger Rand */
.select2-container.h-7 .select2-selection--single .select2-selection__rendered,
.select2-container.h-8 .select2-selection--single .select2-selection__rendered {
  padding: 0 1.5rem 0 0.625rem;
}

/* ── Pfeil: derselbe wie bei den nativen Feldern ────────────────────────── */
.select2-container--default .select2-selection--single .select2-selection__arrow {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2.25rem;
  height: auto;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 1.25em 1.25em;
  transition: transform 0.15s ease;
}

.select2-container.h-7 .select2-selection__arrow,
.select2-container.h-8 .select2-selection__arrow {
  width: 1.5rem;
  background-position: right 0.375rem center;
  background-size: 1em 1em;
}

/* Das eigene Dreieck von Select2 verschwindet */
.select2-container--default .select2-selection--single .select2-selection__arrow b {
  display: none;
}

.select2-container--open .select2-selection__arrow {
  transform: rotate(180deg);
}

/* ── Mehrfachauswahl ────────────────────────────────────────────────────── */
.select2-container--default .select2-selection--multiple {
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 0.625rem;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: #ffffff;
  border: 1px solid #e7e5e4;
  border-radius: 6px;
  color: #1c1917;
  font-size: 12px;
  font-weight: 500;
  margin: 0;
  padding: 2px 8px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: #a8a29e;
  margin-right: 4px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
  color: #1c1917;
}

/* ── Fokus: wie bei den Textfeldern ─────────────────────────────────────── */
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border: none;
  outline: none;
}

.select2-container--focus.input-contrast,
.select2-container--open.input-contrast,
.select2-container--focus.form-select,
.select2-container--open.form-select {
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* ── Die aufgeklappte Liste ─────────────────────────────────────────────── */
.select2-dropdown {
  background: #ffffff;
  border: 1px solid #e7e5e4;
  border-radius: 12px;
  box-shadow: 0 12px 24px -6px rgba(28, 25, 23, 0.12), 0 2px 8px rgba(28, 25, 23, 0.04);
  overflow: hidden;
  z-index: 100000; /* über allen Dialogen der App */
}

.select2-container--open .select2-dropdown {
  z-index: 100000;
}

.select2-dropdown .select2-results__options {
  max-height: 260px;
  padding: 6px;
}

.select2-dropdown .select2-results__option {
  border-radius: 8px;
  color: #1c1917;
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 10px;
}

.select2-dropdown .select2-results__option--highlighted[aria-selected],
.select2-dropdown .select2-results__option--highlighted[data-selected] {
  background: #f5f5f4;
  color: #1c1917;
}

.select2-dropdown .select2-results__option[aria-selected='true'],
.select2-dropdown .select2-results__option[data-selected='true'] {
  background: #1c1917;
  color: #ffffff;
  font-weight: 500;
}

.select2-dropdown .select2-results__message {
  color: #a8a29e;
  font-size: 12px;
  padding: 10px;
}

/* Gruppen (<optgroup>) */
.select2-dropdown .select2-results__group {
  color: #a8a29e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 10px 10px 4px;
  text-transform: uppercase;
}

.select2-dropdown .select2-results__option .select2-results__options--nested {
  padding: 0;
}

/* ── Suchfeld in der Liste ──────────────────────────────────────────────── */
.select2-dropdown .select2-search--dropdown {
  border-bottom: 1px solid #f5f5f4;
  padding: 8px;
}

.select2-dropdown .select2-search--dropdown .select2-search__field {
  background: #f5f5f4;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #1c1917;
  font-size: 13px;
  padding: 8px 10px;
}

.select2-dropdown .select2-search--dropdown .select2-search__field:focus {
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

/* ── Gesperrte Felder ───────────────────────────────────────────────────── */
.select2-container--disabled,
.select2-container--default.select2-container--disabled .select2-selection--single {
  cursor: not-allowed;
  opacity: 0.6;
}
