/* Schmale erste Spalte gruppierter Tabellen (MudTable mit aufklappbarer Gruppierung):
   MudTable fügt jeder Datenzeile eine Einrück-Zelle und jeder Gruppenzeile den
   Umschaltknopf als erste Zelle ein. Die Selektoren zielen nur auf die direkte
   Tabelle (nicht auf verschachtelte Tabellen in aufgeklappten Zeilen). */

.table-group-slim > .mud-table-container > table > thead > tr > th:first-child,
.table-group-slim > .mud-table-container > table > tbody > tr > td:first-child:not([colspan]) {
    padding-left: 2px !important;
    padding-right: 2px !important;
}

/* Feste Einrückung (34 px) der eingefügten Zelle entfernen — die Ebenen-Einrückung
   erfolgt in der Nummernspalte */
.table-group-slim > .mud-table-container > table > tbody > tr > td:first-child > .d-flex {
    padding-left: 0 !important;
}

/* Umschaltknopf der Gruppenzeile kompakt halten */
.table-group-slim > .mud-table-container > table > tbody > tr > td:first-child > .mud-icon-button {
    padding: 4px;
}

/* ---- Listen über die gesamte verfügbare Höhe ------------------------------------------------
   Der Inhaltsbereich ist eine Flex-Spalte über die volle Fensterhöhe. Listen auf oberster
   Seitenebene wachsen dynamisch auf die verbleibende Höhe (nach Kopfzeile, Titel, Toolbar,
   Filterbereich und Zusatzbereichen); nur der Tabellenkörper scrollt, Toolbar und Pager
   bleiben sichtbar. Ohne feste Höhen oder max-height-Begrenzungen: Der interne Scrollbalken
   erscheint erst, wenn die tatsächliche Fensterhöhe vollständig genutzt ist. Seiten ohne
   Listen scrollen unverändert im Inhaltsbereich. */

.mud-main-content {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

.mud-main-content > .mud-table {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.mud-main-content > .mud-table > .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    max-height: none !important;
    height: auto !important;
}

/* Kopfzeile der Liste bleibt beim internen Scrollen sichtbar */
.mud-main-content > .mud-table > .mud-table-container > table > thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: var(--mud-palette-surface);
}
/* Gemeinsamer Listenstandard: Filterzeilen reagieren auf Maus, Fokus und den
   zentral gesetzten Hover-/Touch-Zustand. */
.mud-table thead tr:has(.mud-input-control),
.list-standard-table thead tr.list-filter-row {
    display: none !important;
}

.mud-table thead.list-filter-hover-open tr:has(.mud-input-control),
.mud-table thead:focus-within tr:has(.mud-input-control),
.mud-table thead.list-filter-open tr:has(.mud-input-control),
.list-standard-table thead.list-filter-hover-open tr.list-filter-row,
.list-standard-table thead:focus-within tr.list-filter-row,
.list-standard-table thead.list-filter-open tr.list-filter-row {
    display: table-row !important;
}

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

.list-toolbar__actions,
.list-toolbar__templates,
.list-toolbar__hierarchy,
.list-toolbar__search,
.list-toolbar__trash,
.list-toolbar-switch {
    display: flex;
    align-items: center;
}

.list-toolbar__spacer { flex: 1 1 24px; }
.list-toolbar__search { flex: 0 1 320px; }
.list-toolbar__search .mud-input-control { width: 100%; }
.list-toolbar-switch { gap: 4px; white-space: nowrap; }

/* Auch noch nicht migrierte Toolbars folgen sofort dem Listenstandard. */
.mud-table-toolbar {
    flex-wrap: wrap;
    gap: 8px;
}

.mud-table-toolbar > * { order: 1; }
.mud-table-toolbar > [data-list-control="templates"] { order: 2; }
.mud-table-toolbar > .mud-spacer { order: 3; }
.mud-table-toolbar > .mud-button-group-root { order: 4; }
.mud-table-toolbar > .mud-input-control {
    order: 5;
    flex: 0 1 320px;
    width: 320px !important;
    min-width: 220px !important;
    max-width: 320px !important;
}
.mud-table-toolbar > [data-list-control="trash"] { order: 6; }

@media (max-width: 700px) {
    .list-toolbar__spacer { flex-basis: 100%; height: 0; }
    .list-toolbar__search { flex: 1 1 220px; }
    .mud-table-toolbar > .mud-spacer { flex-basis: 100%; height: 0; }
    .mud-table-toolbar > .mud-input-control { flex: 1 1 220px; width: auto !important; }
}

/* Dokumentgruppen und Dokumente verwenden dieselben kompakten Spaltenachsen. */
.table-group-slim > .mud-table-container > table > tbody > tr:not(:has(.mud-table-cell-custom-group)) > td:first-child:not([colspan]) {
    display: none;
}

.table-group-slim .document-type-cell {
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    padding-left: 4px !important;
    padding-right: 4px !important;
    text-align: center;
}

.document-group-grid {
    display: grid;
    grid-template-columns: 32px 80px minmax(160px, 1fr) 1fr 120px;
    align-items: center;
    width: 100%;
    min-width: 0;
    height: 100%;
}

.table-group-slim .mud-table-cell-custom-group { padding: 0 !important; }
.table-group-slim > .mud-table-container > table > tbody > tr:has(.mud-table-cell-custom-group),
.table-group-slim > .mud-table-container > table > tbody > tr:has(.document-title-cell) {
    height: 48px;
}
.table-group-slim > .mud-table-container > table > tbody > tr:has(.mud-table-cell-custom-group) {
    position: relative;
    z-index: 1;
    overflow: hidden;
}
.table-group-slim > .mud-table-container > table > tbody > tr:has(.mud-table-cell-custom-group) > td,
.table-group-slim > .mud-table-container > table > tbody > tr:has(.mud-table-cell-custom-group) > th,
.table-group-slim > .mud-table-container > table > tbody > tr:has(.document-title-cell) > td {
    height: 48px;
    vertical-align: middle;
}
.table-group-slim .mud-table-cell-custom-group-action,
.table-group-slim .mud-table-cell-custom-group {
    height: 48px !important;
    min-height: 48px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    vertical-align: middle !important;
}
.table-group-slim .mud-table-cell-custom-group-action {
    padding-left: 2px !important;
    padding-right: 2px !important;
}
.table-group-slim .document-group-grid {
    height: 48px !important;
    min-height: 48px;
    align-items: center !important;
}
.document-group-text {
    font-size: inherit;
    font-weight: 500;
    line-height: inherit;
}
.document-group-title-actions {
    height: 48px;
    min-width: 0;
    display: flex;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    white-space: nowrap;
}
.document-group-title {
    min-width: 0;
    flex: 0 1 auto;
    width: fit-content;
    max-width: 100%;
    overflow: hidden;
}
.document-group-title-actions > .mud-icon-button,
.document-group-title-actions > span:not(.document-group-title) {
    flex: 0 0 auto;
}
.document-group-grid > :nth-child(2),
.document-group-grid > :nth-child(3) { padding-left: 16px; }
.document-group-grid__spacer { min-width: 0; grid-column: span 4; }
.document-actions-cell, .document-actions-header {
    white-space: nowrap;
    text-align: right !important;
    justify-content: flex-end;
}
.document-actions-cell { display: flex; align-items: center; padding-left: 8px !important; padding-right: 16px !important; }
.document-title-cell, .document-group-grid > .mud-tooltip-root { min-width: 0; }
.document-group-grid > .mud-tooltip-root,
.document-group-grid .document-actions-cell {
    display: flex;
    align-items: center;
}
.document-group-grid .document-actions-cell {
    align-self: center;
    max-height: 48px;
    overflow: hidden;
}

.document-icon-with-badge { position: relative; overflow: visible; }
.document-warning-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 12px !important;
    height: 12px !important;
}

.list-title-ellipsis {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Listen- und Datenblattaktionen erscheinen nach der zentralen 400-ms-Verzögerung. */
.delayed-row-actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .12s ease, visibility .12s ease;
}

/* Einblendung nur für die eigene Zeile: Zeilen mit eingebetteter Liste (aufgeklappte
   Detailzeilen, z. B. Projekt-Register mit Projektplan) dürfen die Aktions-Icons ihrer
   verschachtelten Zeilen nicht pauschal sichtbar machen — sonst erscheinen dort alle
   Icons dauerhaft, sobald Fokus oder Hover irgendwo in der Detailzeile liegt.

   Der Ausschluss prüft gezielt .mud-table (MudTable wie MudSimpleTable tragen die Klasse)
   und nicht jedes table-Element: seit dem Rückbau der Kapiteltabellen steht die
   Beschreibung eines Inhalts als gewöhnliche HTML-Tabelle in derselben Zeile: ein
   pauschales :has(table) hätte dort die Aktionen dauerhaft verborgen.
   Siehe Konzept-Tabellen-Rueckbau.md. */
.delayed-actions-open:not(:has(.mud-table)) .delayed-row-actions,
.delayed-row-actions:focus-within,
tr:focus-within:not(:has(.mud-table)) .delayed-row-actions,
.data-sheet-header-actions-host:focus-within .delayed-row-actions {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.mud-table-cell:has(.delayed-row-actions) {
    white-space: nowrap;
}

/* Aktions-Icons: das Icon unter dem Cursor hebt farblich hervor (app-weiter Standard).
   Destruktive Aktionen (Löschen/Endgültig löschen — erkennbar am Material-Delete-Pfad)
   warnen in Error-Rot; in der farbigen AppBar bleibt die vererbte Farbe erhalten. */
.mud-icon-button:hover {
    color: var(--mud-palette-primary);
}

.mud-icon-button:hover:has(path[d^="M6 19c0"]) {
    color: var(--mud-palette-error);
}

.mud-appbar .mud-icon-button:hover {
    color: inherit;
}

/* Kommentare: Das Symbol bleibt sichtbar, sobald am Element oder irgendwo darunter ein
   Kommentar liegt — offen oder erledigt. Alle übrigen Zeilenaktionen erscheinen weiterhin
   erst beim Berühren der Zeile (Listen-Standard); der Kommentar ist die bewusste Ausnahme,
   weil man sonst jede Zeile einzeln anfahren müsste, um zu sehen, wo etwas besprochen wurde.

   Zwei Klassen, damit die Regel die Verzögerung übersteuert, ohne !important. Der Platz
   bleibt ohnehin reserviert (visibility statt display), es verschiebt sich also nichts. */
.delayed-row-actions.comment-marked {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
