/* ============================================================================
   BWA-Stylesheet - bewusst minimal.
   FluentUI-Komponenten + Design-Tokens machen den Grossteil der Arbeit.
   Hier nur Page-Layout, Card-Sizing-Pitfall und Row-Faerbung im DataGrid.
   ============================================================================ */

/* ----- Page Layout ----------------------------------------------------- */
/* Keine Flex-Hoehe, kein eigenes overflow - die Seite waechst natuerlich,
   das umschliessende .body-content (MainLayout) uebernimmt das Scrollen. */
.bwa-page {
    padding: 18px 20px;
    display: block;
}

.bwa-page > * {
    margin-bottom: 14px;
}

.bwa-page > *:last-child {
    margin-bottom: 0;
}

.bwa-toolbar { gap: 10px; }

.bwa-section-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 4px 2px;
}

/* Hinweistext (Zusatztext) unterhalb der Detailansicht: fett hervorgehoben (Weight via FluentLabel). */
.bwa-zusatztext {
    display: block;
    margin: 12px 0 4px;
}

/* ----- Kontext-Header (Mandant / Wirtschaftszeitraum / Kanzlei) ------- */
/* Schmale Info-Zeile zwischen AppPageHeader und Breadcrumb. Items werden
   per CSS-Separator getrennt (kein leading-/trailing-Punkt bei fehlenden
   Items). Wrap-bar auf schmalen Viewports. */
.bwa-context-header {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 13px;
    color: var(--neutral-foreground-hint, #605e5c);
    margin: 6px 0 2px;
    line-height: 1.4;
}

.bwa-context-item { display: inline-flex; align-items: baseline; gap: 4px; }
.bwa-context-item strong {
    font-weight: 600;
    color: var(--neutral-foreground-rest, #323130);
}

.bwa-context-item:not(:last-child)::after {
    content: "·";
    margin-left: 8px;
    opacity: 0.6;
}

/* ----- FrontPage / BWA-Liste ------------------------------------------ */
/* Desktop-Tabelle: Klick auf eine Zelle (OnCellClick im Code-Behind), keine
   speziellen Zell-Klassen mehr noetig. */
.bwa-result-pos { color: #08a169; font-weight: 600; }
.bwa-result-neg { color: #db1a37; font-weight: 600; }

/* ----- Vergleichs-Widgets oberhalb der Liste -------------------------- */
.bwa-compare-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
@media (max-width: 959px) {
    .bwa-compare-row { grid-template-columns: 1fr; }
}

.bwa-compare-card {
    --card-height: auto;
    --card-width: auto;
    height: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bwa-compare-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    line-height: 1.2;
}
.bwa-compare-title { font-weight: 600; font-size: 20px; }
.bwa-compare-title-sub {
    font-size: 13px;
    color: var(--neutral-foreground-hint, #605e5c);
}
@media (max-width: 959px) {
    .bwa-compare-title { font-size: 18px; }
}

.bwa-compare-hero {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    font-variant-numeric: tabular-nums;
}
.bwa-compare-hero-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.0;
}
.bwa-compare-hero-good { color: #08a169; }
.bwa-compare-hero-bad  { color: #db1a37; }
.bwa-compare-hero-pct {
    font-size: 11px;
    color: var(--neutral-foreground-hint, #605e5c);
}

.bwa-compare-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 11px;
    color: var(--neutral-foreground-rest, #323130);
    font-variant-numeric: tabular-nums;
}
.bwa-compare-stat strong { font-weight: 600; }

@media (max-width: 959px) {
    /* Mobile: Sub-Stats untereinander, kompakter Hero */
    .bwa-compare-stats { flex-direction: column; gap: 2px; }
    .bwa-compare-hero-value { font-size: 20px; }
}

/* Chart-Container: feste Hoehe + das LiveCharts-`> *`-Pattern wie in
   `.bwa-chart-canvas`, sonst rendert die Canvas in eigener Hoehe und laeuft
   unten ueber den Container-Rand hinaus. */
.bwa-compare-chart {
    position: relative;
    width: 100%;
    height: 130px;
    flex: 0 0 130px;
    min-height: 130px;
    overflow: hidden;
}
.bwa-compare-chart > * {
    width: 100%;
    height: 100%;
    display: block;
}

/* ----- Mobile: BWA-Liste als Card-Stack ------------------------------- */
.bwa-mobile-list { width: 100%; }

.bwa-mobile-card {
    --card-height: auto;
    --card-width: auto;
    height: auto;
    padding: 12px 14px;
    cursor: pointer;
}

.bwa-mobile-card-kpis {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

/* ----- FluentCard-Sizing-Pitfall (siehe fluentui-Skill) --------------- */
/* MinimalStyle bzw. host-set --card-height/-width zwingen 100% Hoehe.
   Mit den Custom-Properties auf "auto" folgt die Karte ihrem Inhalt. */
.bwa-card {
    --card-height: auto;
    --card-width: auto;
    height: auto;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.bwa-card-empty {
    padding: 14px 18px;
    color: var(--neutral-foreground-hint, #999);
    font-size: 12px;
}

/* ----- Charts-Layout ---------------------------------------------------- */
.bwa-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 959px) {
    .bwa-charts,
    .bwa-charts.stacked {
        grid-template-columns: 1fr;
    }
}

.bwa-chart-card {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    min-height: 320px;
}

.bwa-chart-canvas {
    position: relative;
    width: 100%;
    height: 240px;
    flex: 1 1 auto;
    min-height: 220px;
}

    .bwa-chart-canvas > * {
        width: 100%;
        height: 100%;
        display: block;
    }

.bwa-chart-legend {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

.bwa-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--neutral-foreground-hint, #605e5c);
}

.bwa-chart-dot {
    width: 14px;
    height: 4px;
    border-radius: 1px;
}

.bwa-chart-dot-dashed {
    background-image: linear-gradient(to right, currentColor 60%, transparent 0%);
    background-size: 6px 4px;
}

/* ----- Donut: Diagramm gross, Legende kompakt -------------------------- */
.bwa-donut-row {
    flex: 1 1 auto;
    width: 100%;
    gap: 12px !important;
}

.bwa-donut-canvas {
    position: relative;
    width: 240px;
    height: 240px;
    flex-shrink: 0;
}

@media (max-width: 959px) {
    .bwa-donut-canvas {
        width: 220px;
        height: 220px;
        margin: 0 auto;
    }
}

.bwa-donut-canvas > div,
.bwa-donut-canvas > section {
    width: 100%;
    height: 100%;
}

/* Center-Beschriftung BEHIND dem Chart-Canvas. Das Donut-Loch ist transparent,
   sodass der Text durchscheint - der Tooltip wird vom Chart ueber alles
   andere gerendert und ist damit nicht mehr verdeckt. */
.bwa-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: -1;
}

.bwa-donut-center-value {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.1;
}

.bwa-donut-center-label {
    font-size: 10px;
    color: var(--neutral-foreground-hint, #605e5c);
}

.bwa-donut-legend {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
}

.bwa-donut-li {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 2px;
}

    .bwa-donut-li.clickable { cursor: pointer; }
    .bwa-donut-li.clickable:hover,
    .bwa-donut-li.expanded {
        background: var(--accent-fill-stealth-hover, #e8f4fc);
    }

.bwa-donut-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex-shrink: 0;
}

.bwa-donut-lbl {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bwa-donut-val {
    font-weight: 600;
    white-space: nowrap;
}

.bwa-donut-detail {
    padding: 2px 0 6px 18px;
    font-size: 10px;
    color: var(--neutral-foreground-hint, #605e5c);
}

.bwa-donut-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 1px 6px;
    border-bottom: 1px solid var(--neutral-stroke-divider-rest, #f0f0f0);
}

    .bwa-donut-detail-row:last-child { border: none; }

/* ----- Grid-Scroll-Container ------------------------------------------ */
/* Grid nutzt die volle verfuegbare Breite; sobald die Inhalte breiter
   werden als der Viewport, scrollt der Wrapper horizontal. Werte werden
   nie abgeschnitten - das ist Pflicht fuer Geldbetraege ("23.252,89 EUR"). */
.bwa-grid-scroll {
    overflow-x: auto;
}

    .bwa-grid-scroll .fluent-data-grid {
        width: 100%;
        min-width: max-content;
    }

    /* Override gegen globale Ellipsis-Regel in app.css (Z. 457-475)
       UND scoped Regel td[b-w6qdxfylwy] aus dem FluentUI-NuGet-Paket
       (FluentDataGridCell.razor.css). Beide setzen overflow:hidden +
       text-overflow:ellipsis - fuer BWA-Geldbetraege ("23.252,89 EUR")
       darf das nie greifen. Klassen-Selektor + 2x Klasse hat Specificity
       0,3,1 und schlaegt damit beide Quellen. */
    .bwa-grid-scroll .fluent-data-grid th,
    .bwa-grid-scroll .fluent-data-grid td:not(.mobile-grid-item) {
        min-width: max-content;
        overflow: visible;
        text-overflow: clip;
        /* white-space: nowrap aus app.css bleibt erhalten */
    }

    .bwa-grid-scroll .fluent-data-grid .col-title-text {
        overflow: visible;
        text-overflow: clip;
    }

/* ----- Row-Faerbung im DataGrid (RowClass-Hooks) -----------------------
   Permissive Selektoren, da FluentDataGrid v4 je nach DisplayMode mit
   unterschiedlichen Element-Typen rendert (<tr>, <div>, fluent-data-grid-row).
   Wir treffen die Klasse + alle Zellen innerhalb. */
.bwa-row-group {
    background: #f5f5f5 !important;
    font-weight: 700 !important;
}

    .bwa-row-group > * {
        background: #f5f5f5 !important;
        font-weight: 700 !important;
    }

.bwa-row-sum {
    color: var(--accent-fill-rest, #2C87C7) !important;
    font-weight: 600 !important;
    border-top: 1px solid var(--accent-fill-rest, #2C87C7) !important;
}

    .bwa-row-sum > * {
        color: var(--accent-fill-rest, #2C87C7) !important;
        font-weight: 600 !important;
    }

.bwa-row-result {
    background: #f8f8f8 !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    border-top: 2px solid #323130 !important;
}

    .bwa-row-result > * {
        background: #f8f8f8 !important;
        font-weight: 700 !important;
    }

.bwa-row-detail {
    color: var(--neutral-foreground-hint, #605e5c) !important;
    font-size: 11px !important;
}

    .bwa-row-detail > *:first-child {
        padding-left: 24px !important;
    }

.bwa-row-pct {
    font-style: italic !important;
    color: #bbb !important;
    font-size: 10px !important;
}

.bwa-col-total {
    background: #f0f6ff !important;
    font-weight: 600 !important;
}

/* ----- Aufklapp-Chevron in der Detailansicht --------------------------- */
.bwa-group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    width: 100%;
}

.bwa-chevron {
    display: inline-block;
    width: 12px;
    font-size: 10px;
    color: var(--neutral-foreground-hint, #605e5c);
    transition: transform .15s ease;
}

    .bwa-chevron.open {
        transform: rotate(90deg);
    }

/* ----- Allerletzte Zeile unter der Detailansicht ----------------------- */
/* Optik orientiert an .bwa-row-result, aber freistehend - kein Klick,
   kein Chevron, ausserhalb des Grids damit keine Spaltenbreiten-Wirkung. */
.bwa-last-row {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8f8f8;
    border-top: 2px solid #323130;
    font-weight: 700;
    font-size: 13px;
}

/* ============================================================================
   Mobile Card-List (BwaQuickTable + BwaTreeTable Mobile-Branch)
   FluentDataGrid mit 14 Spalten ist auf <600px unbrauchbar - stattdessen
   Karten-Liste mit aktivem Monat, Δ Vormonat und Gesamt.
   ============================================================================ */

.bwa-mobile-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bwa-mobile-switcher-label {
    font-size: 12px;
    color: var(--neutral-foreground-hint, #605e5c);
    flex-shrink: 0;
}

.bwa-mobile-switcher-select {
    flex: 1 1 auto;
    min-width: 0;
}

.bwa-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bwa-mobile-card {
    background: var(--neutral-layer-1, #fff);
    border: 1px solid var(--neutral-stroke-divider-rest, #e5e5e5);
    border-radius: 4px;
    padding: 10px 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.bwa-mobile-card-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--neutral-foreground-rest, #323130);
}

.bwa-mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
    padding: 2px 0;
}

.bwa-mobile-card-label {
    color: var(--neutral-foreground-hint, #605e5c);
}

.bwa-mobile-card-value {
    font-weight: 600;
    color: var(--neutral-foreground-rest, #323130);
}

.bwa-mobile-card-total {
    font-weight: 700;
    color: var(--accent-fill-rest, #2C87C7);
}

/* Sum-Card: Akzent-Farbe analog .bwa-row-sum */
.bwa-mobile-card-sum {
    border-left: 3px solid var(--accent-fill-rest, #2C87C7);
}

    .bwa-mobile-card-sum .bwa-mobile-card-title,
    .bwa-mobile-card-sum .bwa-mobile-card-value {
        color: var(--accent-fill-rest, #2C87C7);
    }

/* Result-Card: kraeftige Hervorhebung analog .bwa-row-result */
.bwa-mobile-card-result {
    background: #f8f8f8;
    border-top: 2px solid #323130;
}

    .bwa-mobile-card-result .bwa-mobile-card-title {
        font-size: 14px;
        font-weight: 700;
    }

/* Detail-Card: dezenter, eingerueckt */
.bwa-mobile-card-detail {
    margin-left: 16px;
    background: var(--neutral-layer-2, #fafafa);
}

    .bwa-mobile-card-detail .bwa-mobile-card-title {
        font-size: 12px;
        font-weight: 500;
        color: var(--neutral-foreground-hint, #605e5c);
    }

/* Pct-Card: italic + grau analog .bwa-row-pct */
.bwa-mobile-card-pct .bwa-mobile-card-title {
    font-style: italic;
    color: #999;
}

/* Δ Vormonat - farblich klassifiziert */
.bwa-mobile-delta {
    font-weight: 600;
    font-size: 12px;
}

.bwa-mobile-delta-up {
    color: #08a169;
}

.bwa-mobile-delta-down {
    color: #db1a37;
}

.bwa-mobile-delta-flat {
    color: var(--neutral-foreground-hint, #605e5c);
}

/* Gruppen-Header in der Detailansicht (Mobile) */
.bwa-mobile-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 4px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.bwa-mobile-chevron {
    display: inline-block;
    width: 12px;
    font-size: 10px;
    color: var(--neutral-foreground-hint, #605e5c);
    transition: transform .15s ease;
    flex-shrink: 0;
}

    .bwa-mobile-chevron.open {
        transform: rotate(90deg);
    }

.bwa-mobile-group-label {
    flex: 1 1 auto;
    min-width: 0;
}
