/*
 * Global search: header trigger and the Ctrl K palette.
 * Markup: common/global_search.php. Behaviour: js/global-search.js.
 * Colours follow the "Top navigation bar" section of css/style.css.
 * No position: sticky anywhere (the back office avoids it).
 */

/* ---- Trigger (a button in the navbar) ------------------------------------ */
.sm-gs-trigger {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    flex: 0 1 auto;
    width: 320px;
    max-width: 100%;
    height: 36px;
    margin-left: .75rem;
    padding: 0 .6rem 0 .85rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    font-size: .875rem;
    line-height: 1;
    text-align: left;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.sm-gs-trigger:hover {
    background: #e8eef5;
    color: #475569;
}
.sm-gs-trigger:focus-visible {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 .2rem rgba(99, 102, 241, .25);
}
.sm-gs-trigger-icon {
    flex: 0 0 auto;
    font-size: .85rem;
    color: #94a3b8;
}
.sm-gs-trigger-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sm-gs-kbd {
    display: inline-block;
    flex: 0 0 auto;
    padding: .15rem .4rem;
    border: 1px solid #d5dde8;
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #fff;
    color: #64748b;
    font-family: inherit;
    font-size: .7rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

@media (max-width: 1399.98px) {
    .sm-gs-trigger { width: 240px; }
}

/* Below the sidebar breakpoint the trigger is an icon-only button. */
@media (max-width: 991.98px) {
    .sm-gs-trigger {
        width: 36px;
        justify-content: center;
        padding: 0;
        margin-left: .5rem;
    }
    .sm-gs-trigger-text,
    .sm-gs-trigger .sm-gs-kbd { display: none; }
    .sm-gs-trigger-icon { font-size: .95rem; color: #475569; }
}

/* ---- Palette ----------------------------------------------------------------- */
.sm-gs-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1049;
    background: rgba(15, 23, 42, .35);
    animation: sm-gs-fade .12s ease-out;
}
.sm-gs-backdrop[hidden],
.sm-gs[hidden] { display: none; }

.sm-gs {
    position: fixed;
    z-index: 1049;
    top: 12vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    width: min(640px, calc(100vw - 16px));
    max-height: 70vh;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
    color: #0f172a;
    overflow: hidden;
    animation: sm-gs-fade .12s ease-out;
}

.sm-gs-inputrow {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: .65rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}
.sm-gs-inputicon { color: #94a3b8; }
.sm-gs-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: .3rem 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #0f172a;
    font-size: 1.05rem;
    box-shadow: none;
}
.sm-gs-input::placeholder { color: #94a3b8; }

.sm-gs-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: .35rem .4rem .5rem;
}

.sm-gs-group { margin-top: .25rem; }
.sm-gs-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: .55rem .6rem .25rem;
    color: #64748b;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.sm-gs-more {
    color: #4f46e5;
    font-size: .75rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    text-decoration: none;
}
.sm-gs-more:hover { text-decoration: underline; }

.sm-gs-row {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem .6rem;
    border-radius: 8px;
    cursor: pointer;
}
.sm-gs-row.sm-gs-sel { background: #eef2ff; }
.sm-gs-ico {
    flex: 0 0 1.4rem;
    width: 1.4rem;
    text-align: center;
    color: #64748b;
    font-size: .95rem;
}
.sm-gs-sel .sm-gs-ico { color: #4f46e5; }
.sm-gs-body { flex: 1 1 auto; min-width: 0; }
.sm-gs-line {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    min-width: 0;
}
.sm-gs-title {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: .92rem;
    font-weight: 500;
}
.sm-gs-crumb {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: right;
    color: #94a3b8;
    font-size: .78rem;
}
.sm-gs-desc {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #64748b;
    font-size: .78rem;
}
.sm-gs-badge {
    flex: 0 0 auto;
    padding: .15rem .5rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: .7rem;
    font-weight: 600;
}
.sm-gs-mark {
    padding: 0;
    border-radius: 2px;
    background: #fde68a;
    color: inherit;
}
.sm-gs-row-ask { margin-top: .4rem; border-top: 1px solid #f1f5f9; border-radius: 0 0 8px 8px; }
.sm-gs-row-ask .sm-gs-ico { color: #7c3aed; }

.sm-gs-wait,
.sm-gs-empty,
.sm-gs-hint {
    padding: .7rem .8rem;
    color: #94a3b8;
    font-size: .85rem;
}

.sm-gs-footer {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: .4rem 1.1rem;
    padding: .5rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    font-size: .75rem;
}
.sm-gs-footer .sm-gs-kbd { margin-right: .15rem; }

/* Phones: full width with 8px margins, no keyboard hints. */
@media (max-width: 575.98px) {
    .sm-gs {
        top: 8px;
        left: 8px;
        right: 8px;
        width: auto;
        transform: none;
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
    }
    .sm-gs-footer,
    .sm-gs-esc { display: none; }
    .sm-gs-input { font-size: 1rem; }
}

@keyframes sm-gs-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .sm-gs,
    .sm-gs-backdrop { animation: none; }
    .sm-gs-trigger { transition: none; }
}
