/*
 * Barock: durchsuchbare Benutzer-Auswahl.
 *
 * Gilt fuer jedes <select data-user-picker> (siehe public/js/user-picker.js).
 * Alles haengt an .up-container / .up-dropdown, damit andere Select2-Felder
 * im System unberuehrt bleiben. Die Klassen stehen in den Regeln doppelt
 * (.up-container.up-container): Manche Seiten laden das Select2-Stylesheet
 * erst nach diesem hier, mit gleich starken Selektoren – so gewinnen unsere
 * Regeln unabhaengig von der Reihenfolge.
 */

.up-container,
.up-dropdown {
    --up-primary: #2563eb;
    --up-primary-soft: rgba(37, 99, 235, 0.08);
    --up-primary-ring: rgba(37, 99, 235, 0.15);
    --up-danger: #ef4444;
    --up-danger-ring: rgba(239, 68, 68, 0.15);
    --up-surface: #fff;
    --up-surface-2: #f8fafc;
    --up-hover: #f1f5f9;
    --up-border: #cbd5e1;
    --up-border-soft: #e2e8f0;
    --up-border-hover: #94a3b8;
    --up-ink: #0f172a;
    --up-muted: #64748b;
    --up-placeholder: #94a3b8;
    --up-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.18), 0 4px 8px -4px rgba(15, 23, 42, 0.08);
    font-family: 'Inter', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body.dark-mode .up-container,
body.dark-mode .up-dropdown {
    --up-primary: #60a5fa;
    --up-primary-soft: rgba(96, 165, 250, 0.12);
    --up-primary-ring: rgba(96, 165, 250, 0.22);
    --up-surface: var(--e-surface, #22272e);
    --up-surface-2: var(--e-surface-2, #2a2f37);
    --up-hover: var(--e-surface-2, #2a2f37);
    --up-border: var(--e-border-strong, #3f4650);
    --up-border-soft: var(--e-border, #363c45);
    --up-border-hover: var(--e-muted-2, #7a828f);
    --up-ink: var(--e-ink, #eaecef);
    --up-muted: var(--e-muted, #949cab);
    --up-placeholder: var(--e-muted-2, #7a828f);
    --up-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.55);
}

/* ---------------------------------------------------------------- Feld */

.select2-container.up-container.up-container { max-width: 100%; }

.up-container.up-container .select2-selection--single,
.up-container.up-container .select2-selection--multiple {
    position: relative;
    min-height: 44px;
    background: var(--up-surface);
    border: 1px solid var(--up-border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.up-container.up-container .select2-selection--single {
    height: 44px;
    display: flex;
    align-items: center;
}
.up-container.up-container .select2-selection:hover { border-color: var(--up-border-hover); }
.up-container.up-container.select2-container--open .select2-selection,
.up-container.up-container.select2-container--focus .select2-selection {
    border-color: var(--up-primary);
    box-shadow: 0 0 0 3px var(--up-primary-ring);
}
.up-container.up-container.up-invalid .select2-selection {
    border-color: var(--up-danger);
    box-shadow: 0 0 0 3px var(--up-danger-ring);
}
.up-container.up-container.select2-container--disabled .select2-selection {
    background: var(--up-surface-2);
    opacity: .7;
    cursor: not-allowed;
}

.up-container.up-container .select2-selection--single .select2-selection__rendered {
    flex: 1;
    min-width: 0;
    padding: 0 60px 0 12px;
    line-height: normal;
    color: var(--up-ink);
    font-size: 0.875rem;
}
.up-container.up-container .select2-selection__placeholder {
    color: var(--up-placeholder) !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.up-container.up-container .select2-selection--single .select2-selection__arrow {
    height: 100%;
    top: 0;
    right: 10px;
}
.up-container.up-container .select2-selection--single .select2-selection__arrow b {
    border-color: var(--up-placeholder) transparent transparent transparent;
}
.up-container.up-container.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--up-primary) transparent;
}

/* Loeschen-Kreuz: rechts neben dem Pfeil statt links vor dem Namen */
.up-container.up-container .select2-selection--single .select2-selection__clear {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    float: none;
    margin: 0;
    padding: 0;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    font-size: 1.1rem;
    font-weight: 400;
    line-height: 1;
    color: var(--up-placeholder);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.up-container.up-container .select2-selection--single .select2-selection__clear:hover {
    background: var(--up-hover);
    color: var(--up-danger);
}

/* Mehrfachauswahl: Personen als Chips */
.up-container.up-container .select2-selection--multiple {
    padding: 5px 36px 5px 6px;
    cursor: text;
}
.up-container.up-container .select2-selection--multiple .select2-selection__rendered {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.up-container.up-container .select2-selection--multiple .select2-selection__choice {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 3px 4px 3px 3px;
    background: var(--up-primary-soft);
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--up-ink);
    font-size: 0.8125rem;
    max-width: 100%;
}
.up-container.up-container .select2-selection--multiple .select2-selection__choice__display { padding: 0; }
.up-container.up-container .select2-selection--multiple .select2-selection__choice__remove {
    position: static;
    order: 2;
    margin: 0 0 0 2px;
    padding: 0;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--up-muted);
    font-size: 0.95rem;
    line-height: 1;
}
.up-container.up-container .select2-selection--multiple .select2-selection__choice__remove:hover {
    background: var(--up-surface);
    color: var(--up-danger);
}
.up-container.up-container .select2-selection--multiple .select2-selection__clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    color: var(--up-placeholder);
}
.up-container.up-container .select2-search--inline { flex: 1; min-width: 60px; }
.up-container.up-container .select2-search--inline .select2-search__field {
    margin: 0 0 0 6px;
    height: 28px;
    width: 100% !important;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--up-ink);
    background: transparent;
}
.up-container.up-container .select2-search--inline .select2-search__field::placeholder { color: var(--up-placeholder); }

/* Klein – fuer Filterleisten (form-control-sm) */
.up-container.up-container.up-sm .select2-selection--single { height: 31px; min-height: 31px; border-radius: 8px; }
.up-container.up-container.up-sm .select2-selection--multiple { min-height: 31px; border-radius: 8px; padding: 2px 30px 2px 4px; }
.up-container.up-container.up-sm .select2-selection--single .select2-selection__rendered { padding: 0 52px 0 8px; font-size: 0.8125rem; }
.up-container.up-container.up-sm .select2-selection--single .select2-selection__clear { right: 26px; width: 18px; height: 18px; font-size: 1rem; }
.up-container.up-container.up-sm .select2-selection--single .select2-selection__arrow { right: 6px; }
.up-container.up-container.up-sm .select2-search--inline .select2-search__field { height: 22px; font-size: 0.8125rem; }

/* ---------------------------------------------------------------- Liste */

/* Select2 haengt die Klasse je nach Version an das Panel selbst oder an
   dessen Huelle – beide Faelle abdecken. */
.select2-dropdown.up-dropdown.up-dropdown,
.up-dropdown.up-dropdown .select2-dropdown {
    background: var(--up-surface);
    border: 1px solid var(--up-border-soft) !important;
    border-radius: 12px !important;
    box-shadow: var(--up-shadow);
    overflow: hidden;
    color: var(--up-ink);
    min-width: 260px;
    z-index: 2060;
}
.select2-dropdown.up-dropdown.up-dropdown.select2-dropdown--below,
.up-dropdown.up-dropdown .select2-dropdown--below { margin-top: 6px; }
.select2-dropdown.up-dropdown.up-dropdown.select2-dropdown--above,
.up-dropdown.up-dropdown .select2-dropdown--above { margin-top: -6px; }

.up-dropdown.up-dropdown .select2-search--dropdown {
    padding: 10px;
    border-bottom: 1px solid var(--up-border-soft);
}
.up-dropdown.up-dropdown .select2-search--dropdown .select2-search__field {
    width: 100%;
    border: 1px solid var(--up-border-soft) !important;
    border-radius: 8px;
    background: var(--up-surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center;
    padding: 8px 12px 8px 32px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--up-ink);
    outline: none;
    transition: border-color .15s ease, background-color .15s ease;
}
.up-dropdown.up-dropdown .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--up-primary) !important;
    background-color: var(--up-surface);
}

.up-dropdown.up-dropdown .select2-results > .select2-results__options { max-height: 300px; padding: 6px; }
.up-dropdown.up-dropdown .select2-results__option {
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 2px;
    color: var(--up-ink);
    background: transparent;
}
.up-dropdown.up-dropdown .select2-results__option--highlighted,
.up-dropdown.up-dropdown .select2-results__option--highlighted[aria-selected],
.up-dropdown.up-dropdown .select2-results__option--highlighted.select2-results__option--selectable {
    background: var(--up-primary-soft) !important;
    color: var(--up-ink) !important;
}
.up-dropdown.up-dropdown .select2-results__option[aria-selected=true],
.up-dropdown.up-dropdown .select2-results__option--selected {
    background: var(--up-primary-soft);
}
.up-dropdown.up-dropdown .select2-results__option[aria-disabled=true],
.up-dropdown.up-dropdown .select2-results__option--disabled { opacity: .5; }
.up-dropdown.up-dropdown .select2-results__message {
    color: var(--up-placeholder);
    font-size: 0.8125rem;
    text-align: center;
    padding: 18px 10px;
}
/* Eintrag „alle"/„niemand" ohne Avatar */
.up-dropdown.up-dropdown .up-option--leer {
    color: var(--up-muted);
    font-style: italic;
    font-size: 0.8125rem;
}

/* ---------------------------------------------------------------- Personenzeile */

.up-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.up-option__avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: #fff;
}
.up-option--compact { gap: 8px; }
.up-option--compact .up-option__avatar { width: 26px; height: 26px; font-size: 0.6875rem; }
.up-option--chip .up-option__avatar { width: 22px; height: 22px; font-size: 0.625rem; }
.up-sm .up-option--compact .up-option__avatar { width: 20px; height: 20px; font-size: 0.5625rem; }
.up-option__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.up-option__name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--up-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.up-sm .up-option__name,
.up-option--chip .up-option__name { font-size: 0.8125rem; }
.up-option__email {
    font-size: 0.75rem;
    color: var(--up-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.up-option mark {
    background: var(--up-primary-ring);
    color: inherit;
    padding: 0 1px;
    border-radius: 3px;
}
