/* Searchable select ("combobox").
   Progressive enhancement over a plain <select>: the select keeps holding the
   value and submitting it, while the input below drives search. With JS off,
   the original select is left visible and everything still works. */

.combobox {
    position: relative;
    width: 100%;
}

/* The real <select> is kept in the DOM (it carries the value on submit) but
   hidden once the combobox is live. */
.combobox > select.combobox-source {
    display: none;
}

.combobox-input {
    width: 100%;
}

.combobox-input::placeholder {
    color: var(--muted);
}

.combobox[data-open="true"] .combobox-input {
    border-color: var(--lime);
}

.combobox-panel {
    background: var(--navy-850, #102219);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
    display: none;
    left: 0;
    /* Ten rows, then scroll — keeps the window short on long member lists. */
    max-height: calc(var(--combobox-row-height, 38px) * 10);
    overflow-y: auto;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 60;
}

.combobox[data-open="true"] .combobox-panel {
    display: block;
}

.combobox-option {
    color: var(--white);
    cursor: pointer;
    font-size: 14px;
    line-height: 1.35;
    min-height: var(--combobox-row-height, 38px);
    padding: 9px 14px;
}

.combobox-option:hover,
.combobox-option.is-active {
    background: rgba(255, 255, 255, .08);
}

.combobox-option[aria-selected="true"] {
    color: var(--lime);
    font-weight: 800;
}

.combobox-empty {
    color: var(--muted);
    font-size: 13px;
    padding: 12px 14px;
}

.combobox-count {
    background: var(--navy-850, #102219);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    padding: 8px 14px;
}

/* "+ Add ..." row. Pinned to the top of the panel so it stays reachable
   without scrolling past a long list of existing records. */
.combobox-add {
    background: var(--navy-850, #102219);
    border-bottom: 1px solid var(--line);
    color: var(--lime);
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    padding: 11px 14px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.combobox-add:hover,
.combobox-add.is-active {
    background: rgba(255, 255, 255, .08);
}

/* Inline quick-add group revealed from the "+ Add ..." row. */
.quick-add-group {
    border: 1px dashed var(--line);
    border-radius: 10px;
    margin-bottom: 14px;
    padding: 4px 14px 14px;
}

.quick-add-group[hidden] {
    display: none;
}

.quick-add-banner {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 13px;
    font-weight: 800;
    gap: 10px;
    justify-content: space-between;
    padding-top: 12px;
}

.quick-add-cancel {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    padding: 0;
    text-decoration: underline;
}

.quick-add-cancel:hover {
    color: var(--white);
}

/* ── Quick-add modal ─────────────────────────────────────────
   Hosts the real create form (same one the full page uses) so a
   member, sponsor, or event can be added without losing the form
   already being filled in underneath. */

.quick-add-modal[hidden] {
    display: none;
}

.quick-add-modal {
    align-items: center;
    display: flex;
    inset: 0;
    justify-content: center;
    /* The dialog owns its own scrolling, so the overlay itself never
       scrolls — that is what let the action bar float over the fields. */
    overflow: hidden;
    padding: 32px 16px;
    position: fixed;
    z-index: 200;
}

.quick-add-backdrop {
    background: rgba(3, 10, 7, .72);
    inset: 0;
    position: fixed;
}

/* Header / scrolling fields / footer, as a flex column. */
.quick-add-dialog {
    background: var(--navy-900, #0b1a13);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
    display: flex;
    flex-direction: column;
    max-height: 100%;
    max-width: 720px;
    min-height: 0;
    position: relative;
    width: 100%;
}

.quick-add-header {
    align-items: center;
    background: var(--navy-900, #0b1a13);
    border-bottom: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    display: flex;
    flex: 0 0 auto;
    gap: 16px;
    justify-content: space-between;
    padding: 18px 24px;
}

.quick-add-header h2 {
    font-size: 20px;
    margin: 0;
}

.quick-add-x {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
    padding: 0 4px;
}

.quick-add-x:hover {
    color: var(--white);
}

.quick-add-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.quick-add-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

/* The only scrolling region. */
.quick-add-fields {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 24px 4px;
}

/* Values the server assigns: shown so you know what you are getting, with no
   input to type into. */
.quick-add-fields .readonly-field {
    background: rgba(213, 162, 76, .10);
    border: 1px solid rgba(213, 162, 76, .34);
    border-radius: 12px;
    margin-bottom: 14px;
    padding: 12px 14px;
}

.quick-add-fields .readonly-field > span {
    color: var(--white, #fff);
    font-size: 13px;
    letter-spacing: .01em;
    text-transform: uppercase;
}

.quick-add-fields .readonly-field strong {
    color: var(--gold, #d5a24c);
    display: block;
    font-size: 20px;
    letter-spacing: .04em;
    margin-top: 4px;
}

.quick-add-fields .readonly-field small {
    color: var(--muted);
    display: block;
    margin-top: 2px;
}

.quick-add-loading {
    color: var(--muted);
    padding: 40px 24px;
    text-align: center;
}

.quick-add-fields .quick-add-errors,
.quick-add-errors {
    background: rgba(224, 96, 96, .12);
    border: 1px solid rgba(224, 96, 96, .4);
    border-radius: 10px;
    color: #ffb4b4;
    font-size: 13px;
    margin-bottom: 16px;
    padding: 10px 14px;
}

.quick-add-actions {
    background: var(--navy-900, #0b1a13);
    border-radius: 0 0 16px 16px;
    border-top: 1px solid var(--line);
    display: flex;
    flex: 0 0 auto;
    gap: 12px;
    margin: 0;
    padding: 16px 24px;
}

/* .primary-button and .ghost-button inherit different sizing defaults, which
   left Save and Cancel visibly mismatched. Pin both to the same box here. */
.quick-add-actions .primary-button,
.quick-add-actions .ghost-button {
    font-size: 14px;
    min-height: 42px;
    min-width: 110px;
    padding: 10px 22px;
}

@media (max-width: 640px) {
    .quick-add-modal {
        padding: 0;
    }

    .quick-add-dialog {
        border-radius: 0;
        height: 100%;
        max-height: 100%;
    }

    .quick-add-header,
    .quick-add-actions {
        border-radius: 0;
    }

    .quick-add-fields {
        padding: 16px 18px 4px;
    }

    .quick-add-actions {
        padding: 14px 18px;
    }
}
