/* Site-wide custom dropdowns — see static/js/custom_select.js.
   The button borrows its height, font size and corner from the <select> it
   replaces, so each page keeps its own scale; everything below is the part the
   browser would not let us style: the panel, the search box and the options,
   in both themes. */

.csel-native {
    /* kept in the DOM so the page's own code still owns it */
    display: none !important;
}

.csel {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    max-width: 100%;
}

.csel-button {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #0f172a;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.csel-button:hover { border-color: #cbd5e1; }
.csel.is-open .csel-button { border-color: #1A2B4B; }

.csel-value {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.csel.is-empty .csel-value { color: #94a3b8; }

.csel-caret { flex: 0 0 auto; color: #94a3b8; font-size: 0.8em; transition: transform 150ms; }
.csel.is-open .csel-caret { transform: rotate(180deg); }

.csel-panel {
    display: none;
    position: absolute;
    z-index: 1300;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    max-width: 420px;
    padding: 8px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}
.csel.is-open .csel-panel { display: block; }
/* while open the panel is moved to <body> so no ancestor's overflow can clip it,
   which puts it out of reach of the selector above */
.csel-panel.is-floating { display: block; overflow: auto; }

.csel-search { padding: 2px 2px 8px 2px; }
.csel-search-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    font-size: 0.95em;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    color: #0f172a;
    outline: none;
}
.csel-search-input:focus { border-color: #1A2B4B; background: #fff; }

.csel-list { max-height: 300px; overflow-y: auto; }
.csel-option {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #0f172a;
    font-size: 0.95em;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.csel-option:hover { background: #eef2f7; }
.csel-option.is-selected { background: #1A2B4B; color: #fff; font-weight: 600; }
.csel-option.is-disabled { color: #cbd5e1; cursor: default; }
.csel-option.is-disabled:hover { background: transparent; }
.csel-empty { padding: 12px; color: #94a3b8; text-align: center; font-size: 0.95em; }

/* Dark mode. The selected row is green here and navy in light mode, which is
   what the tables on the site already do (.active-row). */
html[data-mode="dark"] .csel-button, body.dark .csel-button {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.24);
    color: #e2e8f0;
}
html[data-mode="dark"] .csel-button:hover, body.dark .csel-button:hover {
    border-color: rgba(255, 255, 255, 0.42);
}
html[data-mode="dark"] .csel.is-open .csel-button,
body.dark .csel.is-open .csel-button { border-color: #4caf50; }
html[data-mode="dark"] .csel.is-empty .csel-value,
body.dark .csel.is-empty .csel-value { color: #64748b; }

html[data-mode="dark"] .csel-panel, body.dark .csel-panel {
    background: #1f1f1f;
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}
html[data-mode="dark"] .csel-search-input, body.dark .csel-search-input {
    background: #141414; border-color: rgba(255, 255, 255, 0.18); color: #e2e8f0;
}
html[data-mode="dark"] .csel-search-input:focus,
body.dark .csel-search-input:focus { border-color: #4caf50; background: #1a1a1a; }

html[data-mode="dark"] .csel-option, body.dark .csel-option { color: #e2e8f0; }
html[data-mode="dark"] .csel-option:hover, body.dark .csel-option:hover { background: #2a2a2a; }
html[data-mode="dark"] .csel-option.is-selected, body.dark .csel-option.is-selected {
    background: #4caf50; color: #0b1a0d;
}
html[data-mode="dark"] .csel-option.is-disabled,
body.dark .csel-option.is-disabled { color: #4b5563; }
html[data-mode="dark"] .csel-option.is-disabled:hover,
body.dark .csel-option.is-disabled:hover { background: transparent; }
html[data-mode="dark"] .csel-empty, body.dark .csel-empty { color: #64748b; }
