/* The admin top bar's search box and the dialog it opens.
 *
 * Shared admin chrome, so it sits at the top of css/ beside app-theme.css.
 * See templates/_admin_search.html for what it is and static/js/admin-search.js
 * for how it ranks.
 *
 * The trigger is a translucent box on the app-coloured bar -- the way it reads
 * on a documentation site -- and the dialog is a white panel over a dimmed
 * page, hanging from the top so the list grows downward as you type.
 * Result tiles take the per-app colours from app-theme.css, so a result says
 * which app it will take you to before you read the breadcrumb.
 */

/* --- the trigger in the bar ------------------------------------------- */

.admin-search__trigger {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
    margin-right: .5rem;
    padding: .375rem .5rem .375rem .75rem;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: .5rem;
    background: rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .85);
    font-size: .875rem;
    line-height: 1.25;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
}

.admin-search__trigger:hover,
.admin-search__trigger:focus-visible {
    background: rgba(255, 255, 255, .18);
    border-color: rgba(255, 255, 255, .4);
    color: #fff;
}

.admin-search__trigger-kbd {
    padding: .05rem .4rem;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: .3rem;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: .75rem;
    box-shadow: none;
}

/* On the expanded bar it sits after the brand, before the app's links; on a
   narrow bar it is pushed right, beside the hamburger, and shrinks to its icon. */
@media (min-width: 1200px) {
    .admin-search__trigger {
        margin-left: .25rem;
        margin-right: 1rem;
        min-width: 12rem;
    }
    .admin-search__trigger-kbd { margin-left: auto; }
}

@media (max-width: 575.98px) {
    .admin-search__trigger { padding: .45rem .6rem; }
    .admin-search__trigger-label,
    .admin-search__trigger-kbd { display: none; }
}

/* --- the dialog -------------------------------------------------------- */

.admin-search {
    width: min(640px, calc(100vw - 2rem));
    max-width: none;
    max-height: none;
    margin: 8vh auto auto;
    padding: 0;
    border: 0;
    border-radius: .75rem;
    background: transparent;
    color: #1e293b;
    overflow: visible;
}

.admin-search::backdrop {
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
}

.admin-search__panel {
    display: flex;
    flex-direction: column;
    max-height: min(560px, 80vh);
    border-radius: .75rem;
    background: #fff;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .3);
    overflow: hidden;
}

.admin-search__bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.admin-search__bar-icon { color: #64748b; }

.admin-search__input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: inherit;
    font-size: 1.0625rem;
}

/* The browser's own clear button duplicates Esc. */
.admin-search__input::-webkit-search-cancel-button { display: none; }

.admin-search__close {
    padding: .1rem .45rem;
    border: 1px solid #cbd5e1;
    border-radius: .3rem;
    background: #f8fafc;
    color: #64748b;
    font-size: .75rem;
}

.admin-search__results {
    flex: 1;
    overflow-y: auto;
    padding: .5rem;
    overscroll-behavior: contain;
}

.admin-search__group {
    padding: .5rem .5rem .25rem;
    color: #64748b;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.admin-search__hit {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .625rem;
    border-radius: .5rem;
    color: inherit;
    text-decoration: none;
}

.admin-search__hit.is-active {
    background: #eef2ff;
    box-shadow: inset 0 0 0 1px #c7d2fe;
    color: inherit;
}

.admin-search__icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: .45rem;
    background: var(--app-admin);
    color: #fff;
    font-size: .875rem;
}

.admin-search__icon--portal    { background: var(--app-portal); }
.admin-search__icon--scheduler { background: var(--app-scheduler); }
.admin-search__icon--tickets   { background: var(--app-tickets); }
.admin-search__icon--tasks     { background: var(--app-tasks); }
.admin-search__icon--admin     { background: var(--app-admin); }

.admin-search__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.admin-search__label {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-search__label mark {
    padding: 0;
    background: transparent;
    color: #4338ca;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

.admin-search__crumb {
    color: #64748b;
    font-size: .8125rem;
}

.admin-search__enter {
    color: #94a3b8;
    visibility: hidden;
}

.admin-search__hit.is-active .admin-search__enter { visibility: visible; }

.admin-search__empty {
    margin: 0;
    padding: 2rem 1rem;
    color: #64748b;
    text-align: center;
}

.admin-search__foot {
    display: flex;
    gap: 1.25rem;
    padding: .5rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    font-size: .75rem;
}

.admin-search__foot kbd {
    margin-right: .2rem;
    padding: .05rem .35rem;
    border: 1px solid #cbd5e1;
    border-radius: .25rem;
    background: #fff;
    color: #475569;
    font-family: inherit;
    font-size: .7rem;
    box-shadow: 0 1px 0 #cbd5e1;
}

@media (max-width: 575.98px) {
    .admin-search { margin-top: 1rem; }
    .admin-search__foot { display: none; }
}
