/* public/css/components/global-search.css
 * Header search — input plus a results dropdown grouped by record type.
 *
 * Lives in the masthead's right-hand column alongside the user section, so
 * the "Phoenix" wordmark stays in the middle cell of the 1fr/auto/1fr grid.
 */

.navbar-masthead-right {
    justify-self: end;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.global-search {
    position: relative;
}

.global-search-input {
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    width: 220px;
    max-width: 32vw;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--rule);
    border-radius: var(--border-radius-lg);
    background: var(--white);
    color: var(--ink);
    transition: var(--transition-fast);
}

.global-search-input::placeholder {
    color: var(--ink-dim);
}

.global-search-input:focus {
    outline: none;
    border-color: var(--ink);
    width: 280px;
}

/* Clears the input; the results panel closes on its own via the input event. */
.global-search-input::-webkit-search-cancel-button {
    cursor: pointer;
}

.global-search-results {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    z-index: 200;
    width: 340px;
    max-width: 90vw;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.12));
    padding: var(--space-2) 0;
}

.global-search-results[hidden] {
    display: none;
}

.global-search-group {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-widest);
    text-transform: uppercase;
    color: var(--ink-dim);
    padding: var(--space-3) var(--space-4) var(--space-1);
}

.global-search-result {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: var(--space-2) var(--space-4);
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-body);
    color: var(--ink);
}

.global-search-result:hover,
.global-search-result.active {
    background: var(--paper-2, rgba(0, 0, 0, 0.04));
}

.global-search-result-label {
    font-size: var(--text-sm);
}

.global-search-result-sublabel {
    font-size: var(--text-xs);
    color: var(--ink-dim);
}

.global-search-empty {
    padding: var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--ink-dim);
}

.global-search-hint {
    border-top: 1px solid var(--rule);
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-4) 0;
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    color: var(--ink-dim);
}

/* On narrow screens the masthead is already tight — the search collapses to
   an icon-width field that expands on focus rather than being hidden, since
   it is the fastest route to a record on a phone. */
@media (max-width: 768px) {
    .global-search-input {
        width: 40px;
        padding-left: var(--space-2);
        padding-right: var(--space-2);
    }

    .global-search-input:focus {
        width: 60vw;
    }

    .global-search-results {
        width: 80vw;
    }
}
