/* P-EMTS Phase 1T.5.63 — global searchable select UI + portal visibility repair. */
.pems-global-select {
    position: relative;
    width: 100%;
    min-width: 0;
    font: inherit;
}

.pems-global-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-width: 1px !important;
    min-height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
}

.pems-global-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .7rem;
    width: 100%;
    min-height: 2.55rem;
    padding: .62rem .78rem;
    border: 1px solid #d7dde7;
    border-radius: .62rem;
    background: #fff;
    color: #263348;
    text-align: left;
    font: inherit;
    line-height: 1.25;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .025);
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.pems-global-select-trigger:hover:not(:disabled) { border-color: #bdc6d4; }
.pems-global-select-trigger:focus-visible,
.pems-global-select.is-open .pems-global-select-trigger {
    outline: none;
    border-color: #8b1b1b;
    box-shadow: 0 0 0 3px rgba(139, 27, 27, .09);
}
.pems-global-select-trigger:disabled { cursor: not-allowed; opacity: .62; background: #f6f7f9; }
.pems-global-select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pems-global-select-value.is-placeholder { color: #7c8798; }
.pems-global-select-chevron { flex: 0 0 auto; display: grid; place-items: center; color: #64748b; transition: transform .15s ease; }
.pems-global-select-chevron svg { width: 1rem; height: 1rem; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pems-global-select.is-open .pems-global-select-chevron { transform: rotate(180deg); }

.pems-global-select-panel {
    position: absolute;
    z-index: 12000;
    top: calc(100% + .35rem);
    left: 0;
    right: 0;
    min-width: min(100%, 18rem);
    padding: .48rem;
    border: 1px solid #d9dee7;
    border-radius: .68rem;
    background: #fff;
    box-shadow: 0 18px 45px -24px rgba(15, 23, 42, .55), 0 8px 20px -18px rgba(112, 19, 19, .28);
}
.pems-global-select-panel[hidden] { display: none !important; }

.pems-global-select-search-wrap {
    display: flex;
    align-items: center;
    gap: .42rem;
    min-height: 2.35rem;
    padding: 0 .62rem;
    border: 1px solid #d9dee7;
    border-radius: .5rem;
    background: #fbfcfd;
}
.pems-global-select-search-wrap:focus-within { border-color: #8b1b1b; box-shadow: 0 0 0 2px rgba(139,27,27,.07); background: #fff; }
.pems-global-select-search-icon { display: grid; place-items: center; flex: 0 0 auto; color: #7a8798; }
.pems-global-select-search-icon svg { width: .95rem; height: .95rem; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.pems-global-select-search {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: #263348;
    padding: .45rem 0 !important;
    font: inherit;
    font-size: .82rem;
}
.pems-global-select-search::placeholder { color: #8a94a3; }
.pems-global-select-search::-webkit-search-cancel-button { cursor: pointer; }

.pems-global-select-list {
    max-height: 15.5rem;
    margin-top: .38rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #9aa4b2 transparent;
}
.pems-global-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .65rem;
    width: 100%;
    min-height: 2.25rem;
    padding: .52rem .62rem;
    border: 0;
    border-radius: .45rem;
    background: transparent;
    color: #293548;
    text-align: left;
    font: inherit;
    font-size: .81rem;
    line-height: 1.3;
    cursor: pointer;
}
.pems-global-select-option:hover:not(:disabled),
.pems-global-select-option.is-active { background: #fff2e6; color: #761616; }
.pems-global-select-option[aria-selected="true"] { background: #f8edf0; color: #761616; font-weight: 800; }
.pems-global-select-option:disabled { color: #a1a9b5; cursor: not-allowed; }
.pems-global-select-option-label { min-width: 0; overflow-wrap: anywhere; }
.pems-global-select-check { flex: 0 0 auto; color: #8b1b1b; font-weight: 900; }
.pems-global-select-empty { padding: .72rem .65rem; color: #7a8798; font-size: .78rem; text-align: center; }
.pems-global-select-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Keep the global picker above P-EMTS modal content. */
.pems-modal-panel .pems-global-select-panel { z-index: 16000; }

@media (max-width: 640px) {
    .pems-global-select-panel { min-width: 100%; }
    .pems-global-select-list { max-height: 13rem; }
}

@media (prefers-reduced-motion: reduce) {
    .pems-global-select-trigger,
    .pems-global-select-chevron { transition: none; }
}

@media print {
    .pems-global-select { display: none !important; }
    .pems-global-select-native {
        position: static !important;
        width: auto !important;
        height: auto !important;
        opacity: 1 !important;
        clip-path: none !important;
    }
}

/* =====================================================================
   Phase 1T.5.63 — modal-safe portal layer visibility repair
   ===================================================================== */
.pems-global-select-panel.is-portal {
    position: fixed !important;
    right: auto !important;
    bottom: auto !important;
    z-index: 2147483000 !important;
    min-width: 0 !important;
    max-width: calc(100vw - 16px) !important;
    overflow: hidden;
    box-sizing: border-box;
}

.pems-global-select-panel.is-portal .pems-global-select-list {
    min-height: 0;
    overflow-y: auto;
}

.pems-global-select-panel.is-portal.is-drop-up {
    transform-origin: bottom center;
}

.pems-global-select-panel.is-portal:not(.is-drop-up) {
    transform-origin: top center;
}

@media (prefers-reduced-motion: no-preference) {
    .pems-global-select-panel.is-portal {
        animation: pems-global-select-pop 100ms ease-out both;
    }
}

@keyframes pems-global-select-pop {
    from { opacity: .88; transform: translateY(2px) scale(.995); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =====================================================================
   Phase 1T.5.80 - persistent compact global select geometry
   Keep the JavaScript-enhanced trigger on the same 36px / .875rem rhythm
   as the intended compact filter control after deferred enhancement and
   Livewire rescans. Phase 1T.5.78 accidentally shipped this override with
   literal escaped newline text, so browsers ignored the compact rules and
   fell back to the older 2.55rem trigger after JavaScript enhancement.
   ===================================================================== */
.pems-global-select {
    min-height: 2.25rem;
}

.pems-global-select > .pems-global-select-trigger {
    box-sizing: border-box;
    width: 100%;
    height: 2.25rem !important;
    min-height: 2.25rem !important;
    padding: .38rem .72rem !important;
    border-radius: .55rem;
    font-size: .875rem !important;
    line-height: 1.25rem !important;
}

.pems-global-select-chevron svg {
    width: .9rem;
    height: .9rem;
}

.pems-global-select-search-wrap {
    min-height: 2.2rem;
}

.pems-global-select-option {
    min-height: 2.1rem;
    padding-top: .44rem;
    padding-bottom: .44rem;
}
