/* 2957: patient-document contents search results (Views/Shared/Scripts/PatientDocumentSearchPanel.ts). Shared by the
   Documents tab (PatientDocument/Form.cshtml) and Pure Nellie's Structured Note tab (PureNellie/Review.cshtml). */

/* Cap height so AI results cannot crush the explorer/viewer (Documents) or note body (Nellie).
   Sized in header + N.5 rows so the last visible hit is clipped — scroll affordance without
   eating the pane. --pd-sr-row ≈ one hit (title/meta line + ~2-line snippet). */
.pd-search-results {
    --pd-sr-header: 40px;
    --pd-sr-row: 84px;
    border: 1px solid #dce4ef;
    border-radius: 6px;
    background: #f8fafc;
    margin: 6px 0;
    /* Desktop/tablet: 2 full hits + half of the next */
    max-height: min(calc(var(--pd-sr-header) + 2.5 * var(--pd-sr-row)), 40vh);
    overflow-y: auto;
    flex-shrink: 1;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 767.98px) {
    .pd-search-results {
        /* Phone: title/meta wrap → taller rows; 1 full + half of the next */
        --pd-sr-row: 112px;
        max-height: min(calc(var(--pd-sr-header) + 1.5 * var(--pd-sr-row)), 45vh);
    }
}

/* Documents toolbar nests the host; drop outer vertical margin — toolbar gap handles spacing. */
.patientDocumentToolbar > .pd-search-results {
    margin: 0;
}

.pd-search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    position: sticky;
    top: 0;
    background: #f8fafc;
}

.pd-search-results-note:empty {
    display: none;
}

.pd-search-results-note {
    padding: 6px 10px;
    color: #92400e;
    background: #fffbeb;
    font-size: 0.9em;
}

.pd-search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pd-search-results-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 12px 10px;
    color: #64748b;
    font-size: 0.9em;
    list-style: none;
}

.pd-search-result {
    padding: 8px 10px;
    border-bottom: 1px solid #eef2f7;
    cursor: pointer;
}

.pd-search-result:hover,
.pd-search-result:focus {
    background: #eef4ff;
    outline: none;
}

.pd-search-result-title {
    font-weight: 600;
    color: #1e40af;
}

.pd-search-result-meta {
    color: #6b7280;
    font-size: 0.85em;
    margin-left: 6px;
}

.pd-search-result-snippet {
    margin-top: 3px;
    font-size: 0.9em;
    color: #374151;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pd-search-result-snippet mark {
    background: #fef08a;
    padding: 0;
}

.pd-search-results-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
}

.pd-search-sort {
    display: inline-flex;
    border: 1px solid #dce4ef;
    border-radius: 6px;
    overflow: hidden;
}

.pd-search-sort .pd-search-sort-option {
    border-radius: 0;
    font-size: 0.85em;
}

.pd-search-sort .pd-search-sort-option.is-active {
    background: #dbeafe;
    color: #1e40af;
}

.pd-search-result-pages {
    color: #6b7280;
    font-size: 0.85em;
    margin-left: 6px;
}

.pd-search-result-page {
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    color: #1e40af;
    font-size: 0.95em;
    line-height: 1.2;
    padding: 0 5px;
    margin-left: 3px;
    cursor: pointer;
}

.pd-search-result-page.is-best {
    font-weight: 600;
    border-color: #93c5fd;
}

.pd-search-result-page:hover,
.pd-search-result-page:focus-visible {
    background: #dbeafe;
}

/* Pure Nellie Structured Note tab: the search box in the note topbar, and the floating read-only viewer a result
   opens in (Views/PureNellie/Scripts/NoteDocumentSearch.ts). */
.nellie-note-doc-search {
    width: 240px;
    max-width: 40vw;
}

.nellie-note-doc-search .k-input-icon[role="button"] {
    cursor: pointer;
}

.nellie-note-doc-search-results {
    margin: 0 0 12px;
}

.nellie-note-doc-window {
    padding: 0;
    overflow: hidden;
}

.nellie-note-doc-viewer {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.nellie-note-doc-window-wrapper {
    max-width: 100vw;
}
