/* =========================================================
   GLOBAL SEARCH
   ========================================================= */

.global-search {
    position: relative;
    z-index: 1040;
    flex: 1 1 540px;
    max-width: 640px;
    min-width: 240px;
    margin: 0 1.5rem;
}

.global-search-shell {
    position: relative;
}

.global-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.global-search-input {
    min-height: 42px;
    padding-left: 2.55rem;
    padding-right: 5.75rem;
    border-color: #dbe3ef;
    border-radius: 12px;
    background: #f8fafc;
    box-shadow: none;
    font-size: .9rem;
    transition:
        border-color .16s ease,
        background-color .16s ease,
        box-shadow .16s ease;
}

.global-search-input:focus {
    border-color: rgba(37, 99, 235, .55);
    background: #fff;
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .1);
}

.global-search-input-icon {
    position: absolute;
    left: .9rem;
    z-index: 2;
    color: #64748b;
    pointer-events: none;
}

.global-search-shortcut {
    position: absolute;
    right: 2.65rem;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: .18rem .4rem;
    border: 1px solid #dbe3ef;
    border-radius: 6px;
    color: #64748b;
    background: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.2;
}

.global-search-clear {
    position: absolute;
    right: .65rem;
    display: inline-flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: #64748b;
    background: transparent;
}

.global-search-clear:hover,
.global-search-clear:focus {
    color: #1f2937;
    background: #e2e8f0;
}

/* Use our own clear/close controls so Chromium does not render a second
   search-cancel icon beside them. */
.global-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.global-search-mobile-close {
    display: none;
}

.global-search-panel {
    position: absolute;
    top: calc(100% + .55rem);
    left: 0;
    right: 0;
    overflow: hidden;
    max-height: min(70vh, 580px);
    border: 1px solid #dbe3ef;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 22px 55px rgba(15, 23, 42, .18);
}

.global-search-results-scroll {
    overflow-y: auto;
    max-height: min(58vh, 470px);
    padding: .45rem;
}

.global-search-group + .global-search-group {
    margin-top: .35rem;
    padding-top: .35rem;
    border-top: 1px solid #edf1f6;
}

.global-search-group-label {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .55rem .7rem .35rem;
    color: #64748b;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.global-search-result {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: .7rem;
    align-items: center;
    width: 100%;
    padding: .65rem .7rem;
    border: 0;
    border-radius: 11px;
    color: inherit;
    background: transparent;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.global-search-result:hover,
.global-search-result:focus,
.global-search-result.is-active {
    color: inherit;
    background: #eff6ff;
    outline: none;
}

.global-search-result-icon {
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: #2563eb;
    background: #dbeafe;
    font-size: 1rem;
}

.global-search-result-title {
    overflow: hidden;
    color: #172033;
    font-size: .88rem;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.global-search-result-subtitle {
    overflow: hidden;
    margin-top: .08rem;
    color: #64748b;
    font-size: .75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.global-search-result-status {
    max-width: 120px;
    overflow: hidden;
    padding: .25rem .48rem;
    border-radius: 999px;
    color: #475569;
    background: #f1f5f9;
    font-size: .66rem;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.global-search-state {
    padding: 1.2rem 1rem;
    color: #64748b;
    font-size: .84rem;
    text-align: center;
}

.global-search-loading {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
}

.global-search-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid #cbd5e1;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: global-search-spin .75s linear infinite;
}

@keyframes global-search-spin {
    to { transform: rotate(360deg); }
}

.global-search-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    padding: .55rem .8rem;
    border-top: 1px solid #edf1f6;
    color: #64748b;
    background: #f8fafc;
    font-size: .68rem;
    text-align: right;
}

.global-search-view-all {
    color: #2563eb;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
}

.global-search-view-all:hover,
.global-search-view-all:focus {
    color: #1d4ed8;
    text-decoration: underline;
}

.global-search-footer kbd {
    margin: 0 .08rem;
    padding: .08rem .28rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #475569;
    background: #fff;
    box-shadow: none;
    font-family: inherit;
    font-size: .64rem;
}

.global-search-footer-separator {
    margin: 0 .3rem;
}

.global-search-mobile-trigger {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #dbe3ef;
    border-radius: 10px;
    color: #475569;
    background: #fff;
}

@media (max-width: 1199.98px) {
    .global-search {
        flex: 0 0 auto;
        min-width: 0;
        margin: 0 .4rem 0 auto;
    }

    .global-search-shell {
        position: fixed;
        top: calc(var(--bm-topbar-height) + .5rem);
        left: 1rem;
        right: 1rem;
        display: none;
        max-width: 720px;
        margin: 0 auto;
    }

    .global-search.is-open .global-search-shell,
    .global-search[data-mobile-open="true"] .global-search-shell {
        display: block;
        z-index: 1100;
    }

    .global-search.is-open .global-search-panel:not(.d-none),
    .global-search[data-mobile-open="true"] .global-search-panel:not(.d-none) {
        display: flex !important;
        z-index: 1101;
        flex-direction: column;
        max-height: calc(100dvh - var(--bm-topbar-height) - 5rem);
    }

    .global-search.is-open [data-global-search-results],
    .global-search[data-mobile-open="true"] [data-global-search-results] {
        min-height: 0;
        overflow: hidden;
    }

    .global-search.is-open .global-search-results-scroll,
    .global-search[data-mobile-open="true"] .global-search-results-scroll {
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    body.global-search-mobile-open {
        overflow: hidden;
    }

    .global-search.is-open .global-search-input-wrap {
        filter: drop-shadow(0 12px 30px rgba(15, 23, 42, .14));
    }
}

@media (max-width: 575.98px) {
    .global-search-shell {
        left: .6rem;
        right: .6rem;
    }

    .global-search-result {
        grid-template-columns: 36px minmax(0, 1fr);
    }

    .global-search-result-status {
        grid-column: 2;
        justify-self: start;
    }

    .global-search-footer {
        display: flex;
        justify-content: flex-end;
    }

    .global-search-footer > span {
        display: none;
    }
}

/* =========================================================
   MOBILE SEARCH PORTAL
   The application topbar uses backdrop-filter, which creates a
   containing block for fixed descendants in Chromium. On compact
   viewports the search shell is temporarily moved to <body> so the
   results panel can use the real viewport instead of collapsing to
   the topbar's height.
   ========================================================= */
@media (max-width: 1199.98px) {
    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal {
        position: fixed;
        z-index: 1200;
        inset: 0;
        display: block;
        width: 100vw;
        max-width: none;
        height: 100dvh;
        margin: 0;
        padding: 1rem;
        background: rgba(248, 250, 252, .985);
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-input-wrap {
        position: relative;
        z-index: 2;
        filter: drop-shadow(0 12px 30px rgba(15, 23, 42, .14));
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-input {
        min-height: 48px;
        padding-right: 8.2rem;
        background: #fff;
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-clear {
        right: 5.35rem;
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-mobile-close {
        position: absolute;
        right: .55rem;
        z-index: 4;
        display: inline-flex;
        min-width: 70px;
        height: 36px;
        align-items: center;
        justify-content: center;
        gap: .35rem;
        padding: 0 .7rem;
        border: 1px solid #dbe3ef;
        border-radius: 9px;
        color: #475569;
        background: #fff;
        font-size: .78rem;
        font-weight: 700;
        line-height: 1;
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-mobile-close:hover,
    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-mobile-close:focus {
        border-color: #cbd5e1;
        color: #1f2937;
        background: #f1f5f9;
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-panel {
        position: absolute;
        z-index: 3;
        top: 4.9rem;
        right: 1rem;
        bottom: 1rem;
        left: 1rem;
        max-height: none;
        border-radius: 16px;
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-panel:not(.d-none) {
        display: flex !important;
        flex-direction: column;
        overflow: hidden;
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal [data-global-search-results] {
        min-height: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-results-scroll {
        height: 100%;
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 575.98px) {
    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal {
        padding: .6rem;
    }

    body.global-search-mobile-open > .global-search-shell.global-search-mobile-portal .global-search-panel {
        top: 4.35rem;
        right: .6rem;
        bottom: .6rem;
        left: .6rem;
    }
}
