/* ============================================================
   ReqCompass – Listenseiten

   Ein Baukasten für datengetriebene Übersichtsseiten: Seitenkopf, Toolbar,
   Datenkarte mit klebendem Tabellenkopf, Status-Chips, Leerzustand.

   Bewusst generische Klassennamen (.page, .toolbar, .data-table) statt
   projektspezifischer (.ws-table): Projektübersicht, Workspace, Wissensdatenbank
   und die Einstellungslisten zeigen dasselbe Muster. Zuerst eingeführt für
   Projects.razor; die übrigen Listen können nachziehen, ohne dass die Datei
   angefasst werden muss.

   Baut auf den Tokens aus app.css und den Bootstrap-Angleichungen aus theme.css
   auf. Setzt --green/--focus-ring aus theme.css voraus (mit Rückfallwerten).

   Höhenkette: MainLayout gibt <main class="content"> mit overflow:hidden vor.
   .page füllt diese Fläche, und gescrollt wird ausschließlich in .data-scroll –
   dadurch bleiben Seitenkopf und Toolbar beim Blättern stehen, und der
   Tabellenkopf klebt oben statt aus dem Bild zu laufen.
   ============================================================ */

.page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    min-height: 0;
}


/* ------------------------------------------------------------
   Seitenkopf
   ------------------------------------------------------------ */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--ink);
}

.page-sub {
    margin: 3px 0 0;
    font-size: .875rem;
    color: var(--ink-soft);
}

.page-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Zurück-Pfeil vor dem Seitentitel (Detailseiten wie der Ordner-Browser). */
.page-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: -6px;
    font-size: 1rem;
    color: var(--ink-soft);
    background: transparent;
    border: 0;
    border-radius: 9px;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.page-back:hover {
    color: var(--clr-primary);
    background: var(--tint);
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

/* Kleine Sachinformationen neben dem Titel (Kunde, Abteilung, Projektstatus).
   Bewusst dezenter als .status – die tragen einen Zustand, diese nur einen Wert. */
.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 220px;
    padding: 3px 10px;
    font-size: .78rem;
    font-weight: 500;
    color: var(--ink-soft);
    background: var(--tint);
    border: 1px solid var(--line);
    border-radius: 999px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-chip i {
    flex: none;
    font-size: .8rem;
    opacity: .8;
}

/* Trennpunkt-Liste unter dem Titel (angelegt von, angelegt am ...). */
.page-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 6px 0 0;
    font-size: .82rem;
    color: var(--ink-soft);
}

.page-meta > * + *::before {
    content: "·";
    margin-right: 8px;
    color: var(--line);
}


/* ------------------------------------------------------------
   Breadcrumb
   Ersetzt das Bootstrap-Breadcrumb, dessen Trennzeichen ein CSS-Inhalt ohne
   Bezug zur Marke ist. Die Einträge sind im Ordner-Browser zugleich
   Ablageziele beim Ziehen (data-drop-target), brauchen also eine sichtbare
   Fläche statt nur Text.
   ------------------------------------------------------------ */

.crumbs {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.crumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 260px;
    padding: 5px 10px;
    font-size: .875rem;
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color .12s ease, color .12s ease;
    /* Einträge sind Klick- und im Ordner-Browser auch Ablageziele; beim Ziehen
       darüber soll der Browser keine Textauswahl aufziehen. */
    user-select: none;
    -webkit-user-select: none;
}

.crumb:hover {
    color: var(--clr-primary);
    background: var(--accent-soft);
}

.crumb.is-current {
    color: var(--ink);
    font-weight: 600;
    cursor: default;
}

.crumb.is-current:hover {
    background: transparent;
}

.crumbs li + li::before {
    content: "\F285"; /* bi-chevron-right */
    font-family: "bootstrap-icons";
    font-size: .65rem;
    color: var(--line);
    margin: 0 1px;
}

.crumbs li {
    display: flex;
    align-items: center;
}


/* ------------------------------------------------------------
   Toolbar
   ------------------------------------------------------------ */

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-spacer {
    margin-left: auto;
}

.search {
    position: relative;
    width: 260px;
    max-width: 100%;
}

.search > .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .95rem;
    line-height: 1;
    color: var(--ink-soft);
    opacity: .7;
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 38px;
    padding: 0 34px 0 34px;
    font-family: inherit;
    font-size: .9rem;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color .15s ease, box-shadow .15s ease;
    appearance: none;
}

.search input::placeholder {
    color: color-mix(in srgb, var(--ink-soft) 55%, transparent);
}

/* type="search" ist bewusst gewählt (Escape leert das Feld), WebKit zeichnet
   dafür aber ein eigenes Löschkreuz - das läge über .search-clear. */
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.search input:hover:not(:focus) {
    border-color: color-mix(in srgb, var(--clr-primary) 35%, var(--line));
}

.search input:focus,
.search input:focus-visible {
    outline: none;
    border-color: var(--clr-primary);
    border-radius: var(--radius);
    box-shadow: var(--focus-ring, 0 0 0 3px color-mix(in srgb, var(--clr-primary) 25%, transparent));
}

.search-clear {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: .85rem;
    color: var(--ink-soft);
    background: transparent;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.search-clear:hover {
    color: var(--ink);
    background: var(--tint);
}

/* Filter als Chips statt als Kontrollkästchen: der Zustand ist auf einen Blick
   erkennbar und die Trefferfläche deutlich größer. */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 500;
    color: var(--ink-soft);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.chip:hover {
    color: var(--ink);
    border-color: color-mix(in srgb, var(--clr-primary) 35%, var(--line));
}

.chip.is-active {
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--clr-primary) 45%, transparent);
    font-weight: 600;
}

.chip i {
    font-size: .9rem;
    line-height: 1;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 1rem;
    color: var(--ink-soft);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.icon-btn:hover {
    color: var(--ink);
    background: var(--tint);
    border-color: color-mix(in srgb, var(--ink-soft) 30%, var(--line));
}

.icon-btn.is-active {
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--clr-primary) 45%, transparent);
}

/* Kompakte Variante für Zeilenaktionen in Tabellen. */
.icon-btn-sm {
    width: 32px;
    height: 32px;
    font-size: .9rem;
}


/* ------------------------------------------------------------
   Datenkarte
   ------------------------------------------------------------ */

.data-card {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(20, 33, 47, .04),
                0 4px 16px rgba(20, 33, 47, .04);
    overflow: hidden;
}

.data-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.data-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
}

/* border-collapse:separate ist Voraussetzung dafür, dass der klebende
   Tabellenkopf seine Trennlinie behält – bei collapse wandert der Rahmen an
   die Tabelle und scrollt mit weg. */
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 16px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-soft);
    text-align: left;
    white-space: nowrap;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.data-table th.is-sortable {
    cursor: pointer;
    user-select: none;
    transition: color .15s ease;
}

.data-table th.is-sortable:hover {
    color: var(--clr-primary);
}

/* Das Sortiersymbol ist immer im Markup und wird nur ein-/ausgeblendet.
   Würde es erst beim Sortieren eingefügt, sprängen die Spaltenbreiten. */
.sort-ind {
    display: inline-block;
    margin-left: 6px;
    font-size: .7rem;
    opacity: 0;
    transition: opacity .15s ease;
}

.data-table th.is-sortable:hover .sort-ind {
    opacity: .45;
}

.data-table th.is-sorted {
    color: var(--clr-primary);
}

.data-table th.is-sorted .sort-ind {
    opacity: 1;
}

.data-table tbody td {
    padding: 12px 16px;
    font-size: .9rem;
    color: var(--ink);
    vertical-align: middle;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr.is-clickable {
    cursor: pointer;
}

.data-table tbody tr.is-clickable:hover td {
    background: color-mix(in srgb, var(--clr-primary) 5%, transparent);
}

.cell-strong {
    font-weight: 600;
    color: var(--ink);
}

.cell-muted {
    color: var(--ink-soft);
    font-size: .85rem;
}

/* Lange Beschreibungen und Namen dürfen die Spaltenbreite nicht sprengen. */
.cell-clamp {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-actions {
    width: 56px;
    text-align: right;
}


/* ------------------------------------------------------------
   Zeilenaktionen

   Erst beim Überfahren sichtbar, damit die Liste ruhig wirkt. Drei Fälle
   müssen sie trotzdem zeigen:
     :focus-within  – Tastaturbedienung
     :has(.show)    – geöffnetes Bootstrap-Menü, auch wenn die Maus die Zeile
                      verlassen hat
     (hover: none)  – Touch-Geräte kennen kein Hover
   ------------------------------------------------------------ */

.row-actions {
    opacity: 0;
    transition: opacity .12s ease;
}

.data-table tbody tr:hover .row-actions,
.data-table tbody tr:focus-within .row-actions,
.row-actions:has(.show) {
    opacity: 1;
}

@media (hover: none) {
    .row-actions {
        opacity: 1;
    }
}


/* ------------------------------------------------------------
   Status-Chips
   Farbfläche plus Punkt statt vollflächiger Badge: ruhiger im Listenbild und
   nicht allein auf Farbe angewiesen, weil der Text immer daneben steht.
   ------------------------------------------------------------ */

.status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 999px;
}

.status::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: none;
    border-radius: 50%;
    background: currentColor;
}

.status-neutral {
    color: var(--ink-soft);
    background: var(--tint);
    border-color: var(--line);
}

.status-done {
    color: var(--green-ink, #10603e);
    background: var(--green-soft, #e6f5ed);
    border-color: color-mix(in srgb, var(--green, #14724a) 25%, transparent);
}

.status-cancelled {
    color: var(--red);
    background: var(--red-soft);
    border-color: color-mix(in srgb, var(--red) 25%, transparent);
}

.status-active {
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--clr-primary) 25%, transparent);
}


/* ------------------------------------------------------------
   Leerzustand
   Bisher zeigte die Seite bei leerem Ergebnis nur den Tabellenkopf – ohne
   Hinweis, ob nichts existiert oder der Filter zu eng ist.
   ------------------------------------------------------------ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 56px 24px;
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    font-size: 1.4rem;
    color: var(--clr-primary);
    background: var(--accent-soft);
    border-radius: 14px;
}

.empty-title {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
}

.empty-text {
    max-width: 42ch;
    margin: 0 0 18px;
    font-size: .9rem;
    line-height: 1.5;
    color: var(--ink-soft);
}


/* ------------------------------------------------------------
   Spalten-Panel
   ------------------------------------------------------------ */

.panel-anchor {
    position: relative;
}

.panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 200;
    min-width: 320px;
    padding: 8px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(20, 33, 47, .08),
                0 16px 40px rgba(20, 33, 47, .12);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 8px 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
}

.panel-title {
    margin: 0;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
}

.panel-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 9px;
    transition: background-color .12s ease;
}

.panel-row:hover {
    background: var(--tint);
}

.panel-row-label {
    flex: 1;
    min-width: 0;
    font-size: .875rem;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-row input[type="checkbox"] {
    flex: none;
    width: 16px;
    height: 16px;
    accent-color: var(--clr-primary);
    cursor: pointer;
}

.panel-row input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: .5;
}

/* Reihenfolge-Schaltflächen: bislang die Textzeichen ↑/↓ in einer
   btn-group-sm – als Symbolschaltflächen ruhiger und gleich groß. */
.panel-move {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: .8rem;
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}

.panel-move:hover {
    color: var(--clr-primary);
    background: var(--paper);
    border-color: var(--line);
}


/* ------------------------------------------------------------
   Responsiv
   ------------------------------------------------------------ */

@media (max-width: 767.98px) {
    .search {
        width: 100%;
    }

    .toolbar-spacer {
        margin-left: 0;
    }

    .page-head-actions {
        width: 100%;
    }

    .page-head-actions .btn {
        width: 100%;
    }

    .cell-clamp {
        max-width: 180px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chip,
    .icon-btn,
    .search input,
    .row-actions,
    .panel-row,
    .panel-move,
    .data-table th.is-sortable,
    .sort-ind {
        transition: none;
    }
}
