/* #785 search results redesign — two-column list + fly-in review panel. Global (not scoped) because the
   result card is its own child component and the panel lives in Search.razor; both share these classes.
   Engage design tokens only; no purple/indigo. Names are search-specific to avoid global collisions
   (the app already has a heavily-used .status-badge — ours is .sr-status-badge). */

:root { --sr-review-w: 1215px; } /* letter view width (was 900px, +35%) */

/* ---- two-column layout ---- */
/* margin-top matches the working card's, so the results + panel sit clearly BELOW the search bar
   (without it the sticky panel rides up flush against / over the search box). */
.results-layout { display: flex; gap: 24px; align-items: flex-start; width: 100%; margin-top: 28px; }
/* flex-basis 0 so the list fills exactly the space left by the fixed-width panel and can't push into it */
.results-list-col { flex: 1 1 0; min-width: 0; }
/* explicit width (not min() in the flex shorthand — that parses unreliably and lets the col size to the
   wide letter body, overlapping the results). Sticky sidebar that stays put while the list scrolls. */
.review-col {
    flex: 0 0 auto;
    width: min(var(--sr-review-w), 60vw);
    max-width: var(--sr-review-w);
    position: sticky;
    top: 24px;
    align-self: flex-start;
}

/* ---- results header + segmented toggle ---- */
.results-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.results-count { font-size: 13px; color: var(--text-tertiary); }
.results-toggle {
    display: inline-flex; align-items: center; gap: 2px; padding: 3px;
    border-radius: var(--radius-full); background: var(--bg-tertiary);
}
.results-toggle button {
    border: none; background: none; cursor: pointer; font-family: inherit;
    font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
    padding: 5px 12px; border-radius: var(--radius-full);
    transition: background .15s, color .15s;
}
.results-toggle button.active { background: #fff; color: var(--color-primary); box-shadow: 0 1px 2px rgba(16,32,64,.08); }

/* ---- client groups ---- */
.results-groups { display: flex; flex-direction: column; gap: 22px; }
.results-group-head {
    width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 6px;
    border: none; background: none; cursor: pointer; text-align: left;
    border-bottom: 1px solid var(--border-primary); margin-bottom: 14px;
}
.results-group-head > i { font-size: 12px; color: var(--text-tertiary); width: 12px; flex-shrink: 0; }
.results-group-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.results-group-count {
    font-size: 12px; font-weight: 600; color: var(--text-tertiary);
    background: var(--bg-tertiary); padding: 2px 9px; border-radius: var(--radius-full);
}

/* ---- timeline (grouped view) ---- */
.results-timeline { display: flex; flex-direction: column; }
.tl-row { display: flex; }
.tl-rail { width: 20px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--color-primary); flex-shrink: 0; margin-top: 3px; }
.tl-dot-add { width: 8px; height: 8px; background: var(--color-cyan); }
.tl-line { flex: 1; width: 2px; background: var(--border-primary); margin-top: 3px; min-height: 12px; }
.tl-content { flex: 1; min-width: 0; padding-bottom: 14px; }
.tl-addendum .tl-content { padding-left: 26px; }
.tl-date { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; font-size: 11px; color: var(--text-tertiary); }

/* ---- flat view ---- */
.results-flat { display: flex; flex-direction: column; gap: 12px; }

/* ---- result card ---- */
.result-card {
    background: rgba(255,255,255,.85); border: 1px solid rgba(15,23,42,.07); border-radius: 12px;
    padding: 14px 16px; cursor: pointer; box-shadow: 0 2px 10px rgba(16,32,64,.05);
    transition: border-color .15s, box-shadow .15s, background .15s, transform .12s;
}
.result-card.dense { padding: 10px 14px; }
.result-card:hover { border-color: rgba(37,99,235,.4); box-shadow: 0 6px 18px rgba(37,99,235,.12); }
.result-card.selected { background: var(--color-primary-bg-subtle); border-color: var(--color-primary); box-shadow: 0 6px 18px rgba(37,99,235,.14); }
.result-card:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.result-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.result-card.dense .result-card-head { margin-bottom: 4px; }
.result-card-subject { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.result-card.dense .result-card-subject { font-size: 13.5px; }
.result-card-chips { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.result-card-snippet { font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.result-card.dense .result-card-snippet { font-size: 12.5px; line-height: 1.4; }
.result-card-snippet.clamp-1 { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.sr-hl { font-weight: 600; color: var(--text-primary); background: var(--color-primary-bg-subtle); border-radius: 2px; }
.result-card-meta { display: flex; align-items: center; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--text-tertiary); flex-wrap: wrap; }
.result-card.dense .result-card-meta { gap: 12px; margin-top: 6px; font-size: 11.5px; }
.result-card-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.result-card-reason { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--color-primary); }
.result-card.dense .result-card-reason { margin-top: 6px; font-size: 11.5px; }

/* ---- type chips (color-coded by letter type; no purple) ---- */
.type-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-full); white-space: nowrap; }
.type-chip-engagement { background: var(--bg-tertiary); color: var(--text-secondary); }
.type-chip-addendum { background: var(--color-cyan-bg); color: var(--color-cyan-text); }
.type-chip-audit { background: var(--color-warning-bg); color: var(--color-warning-text); }
.type-chip-waiver { background: var(--color-success-bg); color: var(--color-success-text); }

/* ---- % match chip ---- */
.score-chip { font-size: 11px; font-weight: 600; color: var(--color-primary); background: var(--color-primary-bg); border-radius: 12px; padding: 2px 8px; white-space: nowrap; }

/* ---- status badge (sr- to avoid the global .status-badge) ---- */
.sr-status-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-full); white-space: nowrap; }
.sr-status-badge-success { background: var(--color-success-bg); color: var(--color-success-text); }
.sr-status-badge-danger  { background: var(--color-danger-bg); color: var(--color-danger-dark); }
.sr-status-badge-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.sr-status-badge-info    { background: var(--color-info-bg); color: var(--color-info-text); }
.sr-status-badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ---- review panel (fly-in) ---- */
.review-panel {
    background: #fff; border: 1px solid var(--border-primary); border-radius: var(--radius-2xl);
    overflow: hidden; max-height: calc(100vh - 64px); display: flex; flex-direction: column;
    box-shadow: 0 12px 40px rgba(16,32,64,.14);
    animation: sr-panel-fly-in .3s cubic-bezier(.2,0,.1,1);
}
@keyframes sr-panel-fly-in { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.review-head { padding: 20px 22px; border-bottom: 1px solid var(--border-primary); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.review-head-main { min-width: 0; }
.review-title { margin: 0 0 8px; font-size: 18px; font-weight: 600; color: var(--text-primary); }
.review-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.review-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.review-open {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500;
    color: var(--color-primary); text-decoration: none; white-space: nowrap;
    padding: 6px 11px; border: 1px solid var(--color-primary); border-radius: 8px; transition: background .15s;
}
.review-open:hover { background: var(--color-primary-bg-subtle); }
.review-close { flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-primary); background: #fff; color: var(--text-tertiary); display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s; }
.review-close:hover { background: var(--bg-secondary); color: var(--text-secondary); }

/* matched-passage highlight inside the letter body (JS-wrapped <mark>). Reads as one tinted passage
   across lines (box-decoration-break) rather than scattered bold words. */
.sr-body-hl {
    background: var(--color-primary-bg);
    color: var(--text-primary);
    border-radius: 3px;
    padding: 1px 2px;
    box-shadow: 0 0 0 1px var(--color-primary-bg);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
.review-meta { padding: 14px 22px; border-bottom: 1px solid var(--border-primary); display: flex; align-items: center; gap: 16px; font-size: 12.5px; color: var(--text-tertiary); flex-wrap: wrap; }
.review-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.review-body { flex: 1 1 auto; overflow-y: auto; padding: 22px; font-size: 14px; line-height: 1.65; color: var(--text-secondary); }
.review-body p { margin: 0 0 12px; }
.review-body img { max-width: 100%; }
.review-loading, .review-empty { display: flex; align-items: center; gap: 8px; color: var(--text-tertiary); font-size: 13px; padding: 12px 0; }

/* ---- responsive: stack the panel under the list on narrow screens ---- */
@media (max-width: 1100px) {
    .results-layout { flex-direction: column; }
    .review-col { flex-basis: auto; max-width: none; width: 100%; position: static; }
    .review-panel { max-height: 70vh; }
}
