/* ── Catalog find page: filter drawer, results header, toolbar, table ────── */

.find-page {
    position: relative;
}

/* ── Filter drawer ──────────────────────────────────────────────────────── */

.find-filter-close {
    display: none;
    width: auto;
    max-width: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-1) var(--space-2);
    margin: 0;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 1.75rem;
    line-height: 1;
}

.find-filter-backdrop {
    position: fixed;
    inset: 0;
    background-color: var(--shadow-backdrop);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1080;
}

.find-filter-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.find-filter-header h1,
.find-filter-header h2 {
    margin: 0;
}

.find-page--enhanced .find-filter-close {
    display: inline-flex;
}

.find-form-card {
    position: fixed;
    top: 0;
    right: 0;
    width: min(calc(100vw - 1rem), 500px);
    height: 100vh;
    max-width: none;
    margin: 0;
    padding: var(--space-5) var(--space-5) var(--space-6);
    border-radius: 0;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(100%);
    box-shadow: -18px 0 40px var(--shadow-side);
    z-index: 1100;
}

.find-page--ready .find-filter-backdrop {
    transition: opacity var(--transition), visibility var(--transition);
}

.find-page--ready .find-form-card {
    transition: transform var(--transition), visibility var(--transition);
}

.find-page--filters-open .find-form-card {
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
}

.find-page--filters-open .find-filter-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.find-filters-open {
    overflow: hidden;
}

/* ── Results header (title + count + search + filter button) ─────────────── */

.find-sticky-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-card);
}

.find-results-header {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.find-results-header h2 {
    margin: 0;
    white-space: nowrap;
}

.find-results-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
    min-width: 0;
}

.find-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 1 400px;
    min-width: 0;
}

.find-search-input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: var(--space-1) var(--space-7) var(--space-1) var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-accent);
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
    text-overflow: clip;
}

.find-search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.find-search-icon {
    position: absolute;
    right: var(--space-2);
    pointer-events: none;
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
}

.find-filter-toggle-inline {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    margin: 0;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.find-filter-toggle-inline:hover {
    background: var(--bg-accent);
    border-color: var(--primary);
}

.find-filter-toggle-inline svg {
    width: 1rem;
    height: 1rem;
}

/* ── Results toolbar (bulk actions + pagination) ─────────────────────────── */

.find-results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    margin-top: var(--space-2);
    margin-bottom: var(--space-4);
}

.find-results-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-3);
}

.find-results-toolbar .pagination-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}

.bulk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: center;
    justify-content: flex-start;
}

.bulk-action-form {
    margin: 0;
}

/* ── Results table (catalog find) ────────────────────────────────────────── */

.results-table {
    border-collapse: separate;
    border-spacing: 0;
    border: none;
    overflow: visible;
    width: 100%;
    min-width: auto;
}

.results-table th,
.results-table td {
    border-bottom: 1px solid var(--border-color);
}

.results-table thead th {
    border-bottom: 2px solid var(--border-color);
}

/* Sortable headers carry their own padding via .th-content (tables.css) —
   the header-cell padding must not stack with it. */
.results-table thead th:not(.sortable-header) {
    padding: var(--space-3) var(--space-1);
}

.results-table tbody td {
    padding: var(--space-2) var(--space-1);
}

/* ── Counter bar ─────────────────────────────────────────────────────────── */

.find-counters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    flex: 1 1 auto;
    min-width: 0;
    justify-content: space-evenly;
}

.counter {
    color: var(--text-muted);
    font-size: 0.82rem;
    white-space: nowrap;
    line-height: 1.5;
}

/* ── Find filter form (shared by find-style pages) ───────────────────────── */

.find-results-card {
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.find-results-card .table-wrapper {
    max-width: 100%;
    min-height: 150px;
    overflow-x: auto;
}

/* Sticky submit row: the Знайти button stays visible while the drawer
   scrolls; background matches the card so fields slide underneath it. */
.find-form-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    margin-top: var(--space-4);
    padding: var(--space-2) 0;
    background: var(--bg-card);
}

.find-form-actions button {
    flex: 1;
}

form.find-form {
    gap: var(--space-1);
    max-width: 31.25rem;
}

form.find-form input,
form.find-form select {
    padding: var(--space-1) var(--space-2);
    height: 2em;
}

form.find-form .title-group {
    min-height: 1.6rem;
}

.advanced-toggle {
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.85rem;
}

.advanced-toggle label {
    cursor: pointer;
    user-select: none;
}

.help-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.help-icon-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1em;
    height: 1.1em;
    border-radius: 50%;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    transition: color var(--transition), border-color var(--transition);
}

.help-icon:hover .help-icon-trigger,
.help-icon:focus-visible .help-icon-trigger {
    color: var(--primary);
    border-color: var(--primary);
}

.help-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: calc(100% + var(--space-1));
    left: 50%;
    transform: translateX(-50%);
    width: 13.75rem;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow-side);
    color: var(--text-main);
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    z-index: 1200;
    transition: opacity var(--transition), visibility var(--transition);
    pointer-events: none;
}

.help-icon:hover .help-tooltip,
.help-icon:focus-visible .help-tooltip {
    visibility: visible;
    opacity: 1;
}

.mr-dot {
    position: relative;
}

.cell-marker {
    position: relative;
}

.dot-hover-area {
    position: absolute;
    left: 0;
    top: var(--space-1);
    width: 0.75rem;
    height: 0.75rem;
    z-index: 10;
    cursor: help;
}

.dot-hover-area .help-tooltip {
    top: calc(100% + var(--space-1));
    left: 0;
    transform: none;
    width: auto;
    white-space: nowrap;
}

/* Dots in rightmost columns (e.g. the issues item-count cell): a tooltip
   anchored to the dot's left edge protrudes past the table (clipped by the
   .table-wrapper overflow), so anchor it to the dot's right edge instead. */
.dot-hover-area--right .help-tooltip {
    left: auto;
    right: 0;
}

/* Dots near the bottom of a scrolling .table-wrapper: the tooltip opens below
   the dot and is clipped by the wrapper's bottom edge. Open upward instead —
   the sticky thead heads the wrapper, so an upward tooltip either clears it or
   paints over it (its z-index beats the sticky header) and never clips. */
.dot-hover-area--up .help-tooltip {
    top: auto;
    bottom: calc(100% + var(--space-1));
}

.text-mode-advanced {
    display: none !important;
}

form.find-form:has(.advanced-trigger:checked) .text-mode-advanced {
    display: inline-flex !important;
    align-items: center;
}

.text-mode-selector {
    margin: 0;
    font-size: 0.7rem;
    padding: 0 var(--space-1);
    width: auto;
    min-width: 5rem;
    border-radius: var(--radius-sm);
}

/* "not" checkbox next to the text-mode selector (advanced params only) */

.text-mode-not {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.text-mode-not input {
    accent-color: var(--danger);
}

.text-mode-not:has(input:checked) {
    color: var(--danger-light);
}

.title-group > :nth-child(2),
.title-group > :nth-child(3) {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

/* ── Status pill lives in components/pill.css (shared with item view) ────── */

/* ── Owner cell (MR marker + "Але у ..." mismatch line) ─────────────────── */

.owner-cell {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.owner-cell-line {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.owner-mismatch {
    color: var(--text-meta);
    font-size: 0.8rem;
    padding-left: var(--space-3);
}

/* ── Filter preview strip (bottom, shows active filters as chips) ───────── */

.filter-preview {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1060;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-4);
    background-color: var(--primary);
    box-shadow: 0 -6px 20px var(--shadow-side);
}

.filter-preview[hidden] {
    display: none;
}

.filter-preview-chips {
    display: flex;
    flex: 1;
    min-width: 0;
    align-items: center;
    gap: var(--space-2);
    overflow-x: auto;
}

.filter-preview-chip {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: stretch;
    min-height: var(--space-6);
    padding: 0;
    margin: 0;
    width: auto;
    max-width: none;
    border: 1px solid #fff;
    border-radius: var(--radius-sm);
    background-color: rgba(0, 0, 0, 0.28);
    color: #fff;
    font-size: 0.875rem;
    white-space: nowrap;
    cursor: pointer;
    overflow: hidden;
}

.filter-preview-chip:hover {
    background-color: rgba(0, 0, 0, 0.38);
}

/* "!" exclusion toggle — left segment, mirrors the shelf select2 chip's
   separated control segments (border-right separator, like __choice__remove) */

.filter-preview-chip-not {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: var(--space-5);
    border-right: 1px solid rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.55);
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}

.filter-preview-chip-not:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.12);
}

.filter-preview-chip-text {
    display: inline-flex;
    align-items: center;
    padding: 0 var(--space-2);
    line-height: 1.5;
}

/* Persistent × remove on the right — same separated segment as the shelf
   chip's __choice__remove, instead of the old hover overlay */

.filter-preview-chip-cross {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: var(--space-5);
    border-left: 1px solid rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.filter-preview-chip-cross:hover {
    color: var(--danger-light);
    background-color: rgba(0, 0, 0, 0.2);
}

/* Negated chip: the "!" is active and the whole chip signals exclusion */

.filter-preview-chip--negated {
    border-color: var(--danger-border);
}

.filter-preview-chip--negated .filter-preview-chip-not {
    color: #fff;
    background-color: var(--danger-hover);
}

.filter-preview-chip--negated .filter-preview-chip-text {
    color: rgba(255, 255, 255, 0.85);
}

.filter-preview-clear {
    flex-shrink: 0;
    width: var(--space-6);
    height: var(--space-6);
    margin-left: auto;
    padding: 0;
    border: 1px solid #fff;
    border-radius: var(--radius);
    background-color: rgba(0, 0, 0, 0.28);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.filter-preview-clear:hover {
    background-color: rgba(0, 0, 0, 0.38);
}
