/* ============================================================
   Filter im Testverzeichnis (/testverzeichnis)
   Blade: resources/views/tests/testdisplay.blade.php
          resources/views/tests/testparts/directory_filter_option.blade.php
   JS:    public/js/testdisplay/_4_directory-filter.js
   Konzept: docs/testinfoseiten/themen-und-filter.md

   Präfix .tvfilter-*. Die Seitenleiste selbst ist die bestehende
   .sidebar (1_responsive-sidebar.css): am Desktop fest neben der Liste,
   auf dem Telefon hinter "Filter anzeigen". Farben nach token-colors:
   #4279BC Blau, #275996 dunkler, #163C6B dunkelblau, #dbeafe aktive
   Fläche, #b8d7ff hellstes Blau.
   ============================================================ */

.tvfilter-root [hidden] {
    display: none !important;
}

.tvfilter-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}


/* ── Seitenleiste ─────────────────────────────────────────── */

/* Ab 64rem (dort wird .sidebar--static@md fest) Leiste links, Liste rechts.
   Die frühere Hülle .ax0-flex@md ist in keinem Stylesheet definiert. */
@media (min-width: 64rem) {
    .tvfilter-layout {
        display: grid;
        grid-template-columns: 320px minmax(0, 1fr);
        gap: var(--sp-mm);
        align-items: start;
    }

    .tvfilter-layout > .test_directory_main {
        min-width: 0;
    }
}

/* Suche unter der Überschrift, über Leiste und Liste */
.tvfilter-searchbar {
    margin-bottom: var(--sp-mm);
}

.tvfilter-search-hint {
    display: block;
    margin-top: var(--sp-xxs);
}

/* Telefon: Filter in der geöffneten Leiste */
.tvfilter-filters {
    padding: var(--sp-m);
}

/* Desktop: Filter in einem Kasten wie die Liste daneben */
.sidebar--static .tvfilter-filters {
    padding: var(--sp-mm) var(--sp-m);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.tvfilter-group {
    min-width: 0;
    margin: var(--sp-mm) 0 0;
    padding: 0;
    border: 0;
}

.tvfilter-group:first-child {
    margin-top: 0;
}

.tvfilter-group__legend {
    margin-bottom: var(--sp-xs);
    padding: 0;
    font-size: var(--text-size-95);
    font-weight: 600;
}

.tvfilter-list,
.tvfilter-check-children {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Telefon: Knopf am Fuß der Leiste zeigt die Treffer und schließt sie */
.tvfilter-apply {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: var(--sp-m);
    padding: var(--sp-s) var(--sp-m);
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

.sidebar--static .tvfilter-apply {
    display: none;
}

.tvfilter-apply__btn {
    width: 100%;
}


/* ── Kontrollkästchen ─────────────────────────────────────── */

.tvfilter-check {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 6px;
    font-size: var(--text-size-95);
    border-radius: 6px;
    cursor: pointer;
}

.tvfilter-check:hover {
    background: #f8f9fa;
}

.tvfilter-check__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.tvfilter-check__box {
    position: relative;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 1.5px solid #b5b5b5;
    border-radius: 4px;
    transition: background 0.15s, border-color 0.15s;
}

.tvfilter-check__input:checked + .tvfilter-check__box,
.tvfilter-check__input:indeterminate + .tvfilter-check__box {
    background: #4279BC;
    border-color: #4279BC;
}

.tvfilter-check__input:checked + .tvfilter-check__box::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Strich: von diesem Oberthema sind nur Unterthemen gewählt */
.tvfilter-check__input:indeterminate + .tvfilter-check__box::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 6.5px;
    width: 9px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
}

.tvfilter-check__input:focus-visible + .tvfilter-check__box {
    outline: 2px solid #93aaf7;
    outline-offset: 2px;
}

.tvfilter-check__text {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.tvfilter-check__count {
    font-size: var(--text-size-80);
    font-variant-numeric: tabular-nums;
    color: #8a8a8a;
}

/* Oberthemen etwas kräftiger als Unterthemen */
.tvfilter-band__body > .tvfilter-check-option > .tvfilter-check .tvfilter-check__text {
    font-weight: 500;
}

/* Unterthema, das ein gewähltes Oberthema schon einschließt */
.tvfilter-check-option.is-included > .tvfilter-check {
    cursor: default;
}

.tvfilter-check-option.is-included > .tvfilter-check:hover {
    background: none;
}

.tvfilter-check-option.is-included > .tvfilter-check .tvfilter-check__box {
    background: #b8d7ff;
    border-color: #b8d7ff;
}

.tvfilter-check-option.is-included > .tvfilter-check .tvfilter-check__text {
    color: #6b7280;
}

/* Unterthemen mit dünner Führungslinie unter ihrem Oberthema */
.tvfilter-check-children {
    margin: 0 0 4px 14px;
    padding-left: 10px;
    border-left: 1px solid #e5e7eb;
}


/* ── Bänder zum Aufklappen ────────────────────────────────── */

.tvfilter-band {
    border-bottom: 1px solid #eef0f3;
}

.tvfilter-band__head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 10px 6px;
    font: inherit;
    text-align: left;
    color: inherit;
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.tvfilter-band__head:hover {
    background: #f8f9fa;
}

.tvfilter-band__head:focus-visible {
    outline: 2px solid #93aaf7;
    outline-offset: 1px;
}

.tvfilter-band__top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tvfilter-band__title {
    flex: 1;
    font-size: var(--text-size-95);
    font-weight: 600;
}

.tvfilter-band__selcount {
    padding: 1px 8px;
    font-size: var(--text-size-80);
    color: #275996;
    background: #dbeafe;
    border-radius: 999px;
    white-space: nowrap;
}

.tvfilter-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: #8a8a8a;
    transition: transform 0.15s ease;
}

.tvfilter-band__head[aria-expanded="true"] .tvfilter-chevron {
    transform: rotate(90deg);
    color: #4279BC;
}

.tvfilter-band__preview {
    display: -webkit-box;
    overflow: hidden;
    font-size: var(--text-size-80);
    line-height: 1.35;
    color: #8a8a8a;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tvfilter-band__head[aria-expanded="true"] .tvfilter-band__preview {
    display: none;
}

.tvfilter-band__body {
    padding-bottom: 8px;
}


/* ── Trefferzahl und Auswahl über der Liste ───────────────── */

.tvfilter-results__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-xs) var(--sp-s);
    min-height: 34px;
    margin-bottom: var(--sp-s);
}

/* Trefferzahl rechts und zurückhaltend; die Chips der Auswahl stehen links */
.tvfilter-results__count {
    margin: 0 0 0 auto;
    font-size: var(--text-size-90);
    color: #8a8a8a;
    white-space: nowrap;
}

.tvfilter-results__count strong {
    font-weight: 600;
    color: #6b7280;
}

.tvfilter-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.tvfilter-summary:empty {
    display: none;
}

.tvfilter-summary__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 12px;
    font: inherit;
    font-size: var(--text-size-90);
    color: #275996;
    background: #dbeafe;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.tvfilter-summary__item:hover {
    background: #bfdbfe;
}

.tvfilter-summary__item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.tvfilter-linkbtn {
    padding: 4px 6px;
    font: inherit;
    font-size: var(--text-size-90);
    color: #4279BC;
    text-decoration: underline;
    background: none;
    border: 0;
    cursor: pointer;
}

.tvfilter-linkbtn:hover {
    color: #275996;
}

.tvfilter-summary__item:focus-visible,
.tvfilter-linkbtn:focus-visible {
    outline: 2px solid #93aaf7;
    outline-offset: 2px;
}


/* ── Tabelle ──────────────────────────────────────────────── */

/* Spalte mit dem Link zur Infoseite, vor dem Test. Kopfzellen tragen keine
   Flex-Klassen: Ein <th> mit display: flex ist keine Tabellenzelle mehr. */
.tvfilter-col-link {
    width: 1%;
    padding-right: 0;
    vertical-align: middle;
}

.tvfilter-col-type {
    text-align: right;
}

/* Kürzel über dem Langnamen */
.tvfilter-test-short {
    margin: 0 0 2px;
    font-size: var(--text-size-100);
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #163C6B;
}

.tvfilter-test-author {
    margin-top: 2px;
}

/* Telefon: Tabelle in Bildschirmbreite statt 600px, lange Wörter brechen um,
   Pillen untereinander */
@media (max-width: 40rem) {
    .tvfilter-root .table_main_db {
        min-width: 0;
    }

    .tvfilter-root .table_cell_db {
        padding: 12px 8px;
    }

    .tvfilter-root .main_td p {
        overflow-wrap: anywhere;
    }

    .tvfilter-root .options_td .flex_icons_db {
        flex-direction: column;
        align-items: flex-end;
        gap: 6px;
    }
}
