/*
 * alignvu UI v2.1: search results (#search-results-modal in application/views/search/search_results.php).
 * One grid serves the header keyword search (searchV2) and the Monitor drill-downs (metricSearchV2); its markup comes
 * from js/modules/search/results/results_table.js (a FeedTable: av-table in av-table__frame). The ids below beat the
 * old #entitySearchResultsTable and .search-results rules in css/application.css and css/search.css.
 */

/* ---------- The dialog: white, the design system's type ---------- */

#search-results-modal > .modal-content {
    background: var(--surface);
    color: var(--body-ink);
    font-family: var(--font-display);
}

/* the search term and result count, the pages, then the chosen filters; it stays put while the grid scrolls */
#search-results-modal .in-page-actions.search-results-header-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 24px;
    padding: 0 0 12px;
    margin: 0 0 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--row-rule);
}

#search-results-modal .search-results-header-bar .search-result-search-term {
    margin: 0;
    font: 600 17px/24px var(--font-display);
    color: var(--heading-ink);
    overflow-wrap: anywhere;
}

#search-results-modal .search-results-header-bar .search-results-selected-facets {
    grid-column: 1 / -1;
}

#search-results-modal .search-results-header-bar .search-results-selected-facets:not(:has(.search-result-tags > *)) {
    display: none;
}

/* ---------- Pages (built by generatePaginationPages() in js/application/utils.js) ---------- */

#search-results-modal .search-pagination.pagination {
    width: auto;
    gap: 4px;
    font: 400 13px/18px var(--font-display);
}

#search-results-modal > .modal-content > .modal-body > .search-pagination.pagination {
    justify-content: flex-end;
    margin-top: 12px;
}

#search-results-modal .search-pagination span {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--heading-ink);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

#search-results-modal .search-pagination span:hover {
    background: var(--fill);
}

#search-results-modal .search-pagination span.current {
    background: var(--heading-ink);
    color: var(--surface);
    font-weight: 600;
    text-decoration: none;
}

/* ---------- The filter and summary buttons left of the grid (IconButton look) ---------- */

#search-results-modal .search-results-grid {
    gap: 12px;
}

#search-results-modal #facetToggleArrow,
#search-results-modal #search-results-show-metric-summary-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 1px solid var(--muted);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

#search-results-modal #facetToggleArrow:hover,
#search-results-modal #search-results-show-metric-summary-btn:hover {
    background: var(--fill);
}

#search-results-modal #facetToggleArrow img,
#search-results-modal #search-results-show-metric-summary-btn img {
    width: 16px;
    height: 16px;
    top: 0;
}

/* the filter arrow pointing left while the panel is open: turned in place (application.css also shifts it up) */
#search-results-modal #facetToggleArrow .facet-arrow-icon.rotate-left {
    position: static;
    transform: rotate(180deg);
}

/* chosen filter values: Chips */
#search-results-modal .facet-chip,
#search-results-modal .search-result-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 6px 6px 0;
    padding: 3px 10px;
    border: 1px solid var(--muted);
    border-radius: var(--radius-pill);
    background: var(--surface);
    font: 500 12.5px/16px var(--font-display);
    color: var(--heading-ink);
}

/* ---------- The grid (FeedTable) ---------- */

#search-results-modal .search-results-summary {
    flex: 1 1 auto;
    min-width: 0;
}

#search-results-modal #entitySearchResultsTable {
    table-layout: fixed;
    min-width: 900px;
    font: 400 13px/20px var(--font-display);
    color: var(--table-ink);
}

#search-results-modal #entitySearchResultsTable thead th {
    position: static;
    padding: 10px;
    background: var(--day-band);
    border-bottom: 1px solid var(--border);
    font: 600 12.5px/16px var(--font-display);
    color: var(--heading-ink);
    white-space: nowrap !important;
}

#search-results-modal #entitySearchResultsTable td {
    height: auto;
    padding: 10px;
    border-top: 0;
    border-bottom: 1px solid var(--row-rule);
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: normal;
}

#search-results-modal #entitySearchResultsTable tbody tr:last-child td {
    border-bottom: 0;
}

/* column widths: the table is fixed so long values wrap instead of widening it */
#search-results-modal .app-search-results__col--status { width: 9%; }
#search-results-modal .app-search-results__col--audit { width: 13%; }
#search-results-modal .app-search-results__col--feed { width: 12%; }
#search-results-modal .app-search-results__col--feed-id { width: 9%; }
#search-results-modal .app-search-results__col--name { width: 16%; }
#search-results-modal .app-search-results__col--place { width: 9%; }
#search-results-modal .app-search-results__col--ids { width: 12%; }
#search-results-modal .app-search-results__col--details { width: 11%; }
#search-results-modal .app-search-results__col--lists { width: 8%; }
#search-results-modal .app-search-results__col--score { width: 8%; }
#search-results-modal .app-search-results__col--changes { width: 9%; }

/* one value per line (audit dates, identifiers, details) */
.app-search-results__line {
    display: block;
}

.app-search-results__line + .app-search-results__line {
    margin-top: 2px;
}

/* the name opens the entity profile; the entity type sits under it */
.app-search-results__name,
.app-search-results__link {
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    color: var(--heading-ink);
    cursor: pointer;
}

.app-search-results__name {
    display: block;
    font: 600 13px/20px var(--font-display);
}

button.app-search-results__link {
    font: inherit;
}

.app-search-results__name:hover,
.app-search-results__link:hover,
.open-list:hover .app-search-results__link {
    text-decoration: underline;
}

.app-search-results__name:focus-visible,
.app-search-results__link:focus-visible,
#search-results-modal .change-count:focus-visible {
    outline: 2px solid var(--heading-ink);
    outline-offset: 2px;
}

.app-search-results__type {
    display: block;
}

/* the feed name: two lines, the whole name in the tooltip */
.app-search-results__clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* the status Badge, a little tighter so it fits the narrow column */
#search-results-modal .app-search-results__cell--status .av-badge {
    padding: 2px 7px;
}

#search-results-modal #entitySearchResultsTable .open-status,
#search-results-modal #entitySearchResultsTable .open-list {
    cursor: pointer;
}

/* changes per cluster: one Badge each, opening the changes */
#search-results-modal .change-count {
    margin: 0 4px 4px 0;
    cursor: pointer;
}

#search-results-modal .change-count:hover {
    background: var(--fill);
}

/* score: a bar for the share of the best score, then the figure */
.app-search-results__cell--score .app-sharecell__line {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.app-search-results__cell--score .av-bar {
    flex: 0 1 40px;
    min-width: 20px;
    height: 6px;
}

/* a feed ID breaks only when it cannot fit on its own line */
#search-results-modal #entitySearchResultsTable td.app-search-results__cell--feed-id {
    overflow-wrap: break-word;
}

/* ---------- The matched text under a row (keyword search) ---------- */

#search-results-modal #entitySearchResultsTable tr.has-segment td {
    border-bottom-color: transparent;
}

#search-results-modal #entitySearchResultsTable tr.search-segment td {
    padding: 0 10px 10px !important;
    border-bottom: 1px solid var(--row-rule) !important;
    font: 400 12px/18px var(--font-display);
    color: var(--muted);
}

#search-results-modal #entitySearchResultsTable tr.search-segment em {
    font-style: normal;
    font-weight: 600;
    color: var(--heading-ink);
    box-shadow: inset 0 -2px 0 var(--gold-light);
}

#search-results-modal #entitySearchResultsTable tr.search-segment em.fieldname {
    color: var(--muted);
    box-shadow: none;
}

/* a row and its matched text highlight together */
#search-results-modal #entitySearchResultsTable tr.has-segment:hover + tr.search-segment td,
#search-results-modal #entitySearchResultsTable tr.search-segment:hover td,
#search-results-modal #entitySearchResultsTable tr.has-segment:has(+ tr.search-segment:hover) td {
    background: var(--fill) !important;
}

/* no results */
.app-search-results__empty {
    text-align: center;
}
