/* ──────────────────────────────────────────────────────────────────────────
   rs-select — the app's custom dropdown.

   It enhances a real <select>: the original element stays in the DOM as the
   source of truth (form submission, .value, change listeners all unchanged)
   and is only hidden from view. See static/js/dropdown.js.

   Plain CSS rather than Tailwind utilities so the component is available on
   every page without depending on a CSS rebuild.
   ────────────────────────────────────────────────────────────────────────── */

/* The original select, kept accessible to code but out of sight.
   Scoped to .rs-wrap — which only the JS adds — so a select on a page that
   never loads dropdown.js stays visible and usable instead of vanishing. */
.rs-wrap > select.rs-select {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.rs-wrap {
    position: relative;
    display: block;
    width: 100%;
}

/* Trigger button */
.rs-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-align: left;
    color: #111827;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.rs-trigger:hover:not(:disabled) { border-color: #9ca3af; }
.rs-trigger:focus-visible,
.rs-trigger.is-open {
    outline: none;
    border-color: #6b7280;
    box-shadow: 0 0 0 2px rgba(107, 114, 128, .25);
}
.rs-trigger:disabled {
    cursor: not-allowed;
    opacity: .6;
    background-color: #f9fafb;
}
.rs-trigger-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rs-trigger-label.is-placeholder { color: #9ca3af; }
.rs-trigger-caret {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    color: #9ca3af;
    transition: transform .15s;
}
.rs-trigger.is-open .rs-trigger-caret { transform: rotate(180deg); }
.rs-trigger.is-invalid { border-color: #dc2626; }

/* Menu — appended to <body> and fixed-positioned, so it is never clipped by
   a scrolling parent (the ticket sidebar, modals) or trapped in a stacking
   context. */
.rs-menu {
    position: fixed;
    z-index: 10050;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 18rem;
}
.rs-menu[hidden] { display: none; }

.rs-search {
    flex: 0 0 auto;
    padding: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
}
.rs-search input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    color: #111827;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    outline: none;
}
.rs-search input:focus { border-color: #9ca3af; }

.rs-options {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.25rem;
}
.rs-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    color: #374151;
    border-radius: 0.375rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rs-option[hidden] { display: none; }
.rs-option.is-active { background-color: #f3f4f6; }
.rs-option.is-selected { font-weight: 600; color: #111827; }
.rs-option.is-disabled { opacity: .5; cursor: not-allowed; }
.rs-option-check {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    opacity: 0;
}
.rs-option.is-selected .rs-option-check { opacity: 1; }

/* Multi-select rows read as checkboxes, so it's obvious several can be picked
   and that the menu stays open. */
.rs-multi .rs-option-check {
    opacity: 1;
    width: 1rem;
    height: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    background-color: #fff;
    color: transparent;
}
.rs-multi .rs-option.is-selected .rs-option-check {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.dark .rs-multi .rs-option-check {
    border-color: rgba(255, 255, 255, .25);
    background-color: transparent;
}
.dark .rs-multi .rs-option.is-selected .rs-option-check {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.rs-optgroup-label {
    padding: 0.375rem 0.625rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #9ca3af;
}

.rs-empty {
    padding: 0.75rem 0.625rem;
    font-size: 0.875rem;
    color: #9ca3af;
    text-align: center;
}
.rs-empty[hidden] { display: none; }

/* ── Dark mode (class-based, matching the rest of the app) ───────────────── */
.dark .rs-trigger {
    color: #e6e6e6;
    background-color: #242424;
    border-color: rgba(255, 255, 255, .15);
}
.dark .rs-trigger:hover:not(:disabled) { border-color: rgba(255, 255, 255, .3); }
.dark .rs-trigger:focus-visible,
.dark .rs-trigger.is-open {
    border-color: rgba(255, 255, 255, .35);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .12);
}
.dark .rs-trigger:disabled { background-color: #1f1f1f; }
.dark .rs-trigger-label.is-placeholder { color: #9aa0a6; }
.dark .rs-trigger-caret { color: #9aa0a6; }

.dark .rs-menu {
    background-color: #1c1c1c;
    border-color: rgba(255, 255, 255, .12);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .5);
}
.dark .rs-search {
    background-color: #242424;
    border-bottom-color: rgba(255, 255, 255, .12);
}
.dark .rs-search input {
    color: #e6e6e6;
    background-color: #1c1c1c;
    border-color: rgba(255, 255, 255, .15);
}
.dark .rs-option { color: #c6c6c6; }
.dark .rs-option.is-active { background-color: #2f2f2f; }
.dark .rs-option.is-selected { color: #ffffff; }
.dark .rs-optgroup-label { color: #9aa0a6; }
.dark .rs-empty { color: #9aa0a6; }
