/* Layout ------------------------------------------- */

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: #020817;
}

.mud-main-content {
    max-width: 100%;
    margin: 0 auto;
}

/* Drawer / Navigation -------------------------------- */

.mud-drawer {
    background-color: #020817 !important;
}

.mud-nav-link {
    color: #e5e7eb !important;
    border-radius: 8px;
    margin: 4px 8px;
    padding: 8px 14px;
    font-size: 0.9rem;
}

    .mud-nav-link:hover {
        background-color: rgba(99, 102, 241, 0.16);
    }

    .mud-nav-link.active {
        background-color: rgba(99, 102, 241, 0.28);
        color: #ffffff !important;
    }

/* Paper / Card -------------------------------------- */

.mud-paper,
.mud-card {
    background-color: #0b1120 !important;
    border-radius: 16px !important;
}

.mud-divider {
    border-color: #111827 !important;
}

/* Typo leicht aufhellen ------------------------------ */

.mud-typography-body1,
.mud-typography-body2,
.mud-table td,
.mud-input-root input {
    color: #e5e7eb !important;
}

/* Tabellen ------------------------------------------ */

.mud-table {
    background-color: transparent !important;
}

    .mud-table th {
        font-weight: 600;
        font-size: 0.8rem;
        color: #9ca3af;
    }

/* Inputs / DatePicker / TimePicker ------------------ */

.mud-input-underline:before,
.mud-input-underline:after {
    border-bottom-color: #374151 !important;
}

.mud-input-underline.mud-input-focused:after {
    border-bottom-color: #6366F1 !important;
}

.mud-input-outlined .mud-input-outline {
    border-color: #374151 !important;
}

.mud-input-outlined.mud-input-focused .mud-input-outline {
    border-color: #6366F1 !important;
}

.mud-input-label {
    color: #9ca3af !important;
}

.mud-input-adornment,
.mud-input-adornment-icon {
    color: #9ca3af !important;
}

/* Popups (Select, DatePicker) dunkel */

.mud-popover .mud-paper,
.mud-menu .mud-paper,
.mud-picker .mud-paper {
    background-color: #020817 !important;
    color: #e5e7eb !important;
}

/* Error UI unten ------------------------------------ */

#blazor-error-ui {
    background: #7f1d1d;
    color: #fff;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 12px;
    font-size: 0.75rem;
    z-index: 2000;
}

/* Multi-Select Spieler (Filter) --------------------- */
/* (Optional, falls du die Klasse player-filter-select verwendest) */

.player-filter-select .mud-input-slot {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px;
    padding-top: 4px;
    padding-bottom: 4px;
}

/* ---------- Ranking-Legende ------------------------ */

.ranking-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.ranking-legend-label {
    font-weight: 500;
    margin-right: 4px;
}

.ranking-legend-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
}

    /* Farben der Legende m�ssen 1:1 zu den Row-Styles passen */

    .ranking-legend-badge.clinched {
        background-color: #062e17;
        color: #e5e7eb;
    }

    .ranking-legend-badge.top {
        background-color: #167534;
        color: #e5e7eb;
    }

    .ranking-legend-badge.pre {
        background-color: #a96a06;
        color: #e5e7eb;
    }

    .ranking-legend-badge.contender {
        background-color: #2158e2;
        color: #e5e7eb;
    }

    .ranking-legend-badge.out {
        background-color: #c81e1e;
        color: #e5e7eb;
    }

/* ---------- Quali-Rangliste: Zeilen-Highlights ----- */
/* Semantik:
   rank-safe-po   = dunkelgr�n (fix direkte Playoffs)
   rank-top       = hellgr�n (aktuell in direkter PO-Zone, aber nicht fix)
   rank-pre       = gelb (fix in Pre-Playoffs, keine Chance mehr auf direkt / raus)
   rank-bubble    = blau (kann noch in Pre-Playoffs rutschen)
   rank-elim-pre  = rot (keine Chance mehr auf Pre-Playoffs)
*/

.mud-table tr td {
    transition: background-color 0.12s ease;
}

/* Sicher direkte Playoffs */
.mud-table tr.rank-safe-po {
    background-color: #062e17 !important;
}

/* Aktuell direkte Playoff-Zone (aber nicht fix) */
.mud-table tr.rank-top:not(.rank-safe-po) {
    background-color: #167534 !important;
}

/* Sicher in den Pre-Playoffs (fix im Pre-Bereich) */
.mud-table tr.rank-pre {
    background-color: #a96a06 !important;
}

/* Bubble-Zone: Chance auf Pre-Playoffs */
.mud-table tr.rank-bubble {
    background-color: #2158e2 !important;
}

/* Ausgeschieden: keine Chance mehr auf Pre-Playoffs */
.mud-table tr.rank-elim-pre {
    background-color: #c81e1e !important;
}

/* Zonen-Trennlinien: unter dem letzten direkten Playoff-Rang (grün)
   und unter dem letzten Pre-Playoff-Rang (gelb). Grenzen kommen aus der Saison-Konfiguration. */
.mud-table tr.zone-break-direct td {
    border-bottom: 3px solid #22c55e !important;
}

.mud-table tr.zone-break-pre td {
    border-bottom: 3px solid #eab308 !important;
}

.ranking-zone-summary {
    margin-top: 6px;
    font-size: 0.8rem;
}

/* Hover f�r markierte Reihen */

.mud-table tr.rank-safe-po:hover {
    background-color: rgba(6, 46, 23, 0.96) !important;
}

.mud-table tr.rank-top:hover:not(.rank-safe-po) {
    background-color: rgba(22, 117, 52, 0.96) !important;
}

.mud-table tr.rank-pre:hover {
    background-color: #b8720a !important;
}

.mud-table tr.rank-bubble:hover {
    background-color: #2563eb !important;
}

.mud-table tr.rank-elim-pre:hover {
    background-color: #dc2626 !important;
}

/* Hover f�r unmarkierte Reihen */

.mud-table tr:not(.rank-safe-po):not(.rank-top):not(.rank-pre):not(.rank-bubble):not(.rank-elim-pre):hover td {
    background-color: rgba(255, 255, 255, 0.04);
}

/*Playoff tab*/

/* Wrapper fürs seitliche Scrollen auf schmalen Bildschirmen -- der Bracket
   selbst behält seine Mindestbreite pro Runde (siehe minmax unten) und läuft
   bei Bedarf über den Container hinaus, statt Namen/Scores unlesbar zu quetschen. */
.playoff-bracket-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.playoff-bracket {
    display: grid;
    /* Spaltenzahl kommt aus dem Markup (--bracket-columns), damit der Baum bei
       jeder Rundenzahl passt: 16 Teilnehmer = 4 Spalten, 4 Teilnehmer = 2.
       minmax(180px, ...) statt minmax(0, ...): Runden-Spalten dürfen nicht auf
       Null schrumpfen, sonst werden Namen/Scores auf dem Handy unlesbar --
       stattdessen läuft der Grid über und der Wrapper oben macht ihn scrollbar. */
    grid-template-columns: repeat(var(--bracket-columns, 4), minmax(180px, 1fr));
    gap: 16px;
    align-items: stretch;
}

    .playoff-bracket .round-column {
        display: flex;
        flex-direction: column;
    }

    /* Der Rumpf füllt die Spaltenhöhe; alle Slots teilen sie sich zu gleichen Teilen.
       Runde 1 hat 8 Slots, Runde 2 nur 4 -- deren Slots sind doppelt so hoch, die Karte
       darin zentriert und damit auf der Mitte ihrer beiden Vorgänger.
       Kein min-height: 0 auf den Slots: die automatische Mindesthöhe ist genau das,
       was die höchste Spalte die Zeilenhöhe bestimmen lässt. */
    .playoff-bracket .round-body {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
    }

    .playoff-bracket .match-slot {
        flex: 1 0 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 4px 0;
    }

        .playoff-bracket .match-slot > .match-card {
            width: 100%;
            margin: 0;
        }

    .playoff-bracket .round-title {
        flex: 0 0 auto;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: #9ca3af;
        margin-bottom: 8px;
        text-align: center;
    }

    /*.playoff-bracket .match-card {
        padding: 8px 10px;
        border-radius: 10px;
        background-color: #020817;
        border: 1px solid #111827;
        font-size: 0.78rem;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }*/

    /* Playoff Bracket: Gewinner/Verlierer hervorheben */

    .playoff-bracket .match-card {
        /* Kein margin-bottom mehr: der Abstand kommt jetzt aus der Slot-Höhe,
           sonst würde die Zentrierung im Slot verschoben. */
        padding: 8px 10px;
        border-radius: 10px;
        border: 1px solid rgba(148, 163, 253, 0.18);
        background-color: #020817;
        font-size: 0.8rem;
    }

    .playoff-bracket .team {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .playoff-bracket .team-winner {
        color: #22c55e; /* sattes Gr�n */
        font-weight: 600;
    }

    .playoff-bracket .team-loser {
        color: #f97373; /* weiches Rot */
        opacity: 0.9;
    }


        .playoff-bracket .match-card .vs {
            font-size: 0.65rem;
            color: #6b7280;
        }

        .playoff-bracket .match-card .score {
            font-size: 0.75rem;
            color: #e5e7eb;
        }

    .playoff-bracket .final-match {
        border-color: #facc15;
    }

    .playoff-bracket .winner-label {
        margin-top: 4px;
        font-size: 0.75rem;
        color: #facc15;
    }

    .playoff-bracket .player-group-tag {
        font-size: 0.7rem;
        margin-left: 4px;
        color: #9ca3af;
    }

/*bracket tree view*/

/* Die Spalten richten sich ueber justify-content: space-around aus. Die frueheren
   pixelgenauen nth-child-Offsets funktionierten nur fuer exakt 8/4/2/1 Spiele und
   verrutschten, sobald Freilose oder eine andere Baumtiefe im Spiel waren. */

.playoff-bracket .match-bye {
    border-style: dashed;
    opacity: 0.75;
}

    .playoff-bracket .match-bye .vs {
        color: #facc15;
    }



/* ---------- Players Admin Tabelle ------------------ */
.players-admin-table table {
    table-layout: fixed;
    width: 100%;
}

.players-admin-table .col-name {
    width: 24%;
}

.players-admin-table .col-group {
    width: 18%;
}

.players-admin-table .col-active {
    width: 12%;
}

.players-admin-table .col-note {
    width: 31%;
}

.players-admin-table .col-action {
    width: 15%;
}

/* Hinweis-Text nicht ganze Spalte aufziehen lassen */

.players-admin-table .col-note .mud-typography {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* ==================================================== */
/* Responsive (Handy-Breiten)                            */
/* Einheitlicher Breakpoint 600px -- entspricht MudBlazors
   eigenem "sm" und dem, worauf DrawerVariant.Responsive
   bereits intern reagiert. */
/* ==================================================== */

/* ---------- Tabellen: horizontales Scrollen statt Spalten-Crush --- */
/* Wrapper um bestehende MudTable-Markups, ohne RowTemplate/MudTd
   anzufassen. min-width sorgt dafür, dass Spalten ihre natürliche
   Breite behalten und die Tabelle stattdessen seitlich scrollt. */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

    .table-scroll table {
        min-width: 640px;
    }

/* ---------- Sponsoren-Logo (Bären Rapperswil) ---------- */
/* Logo hat einen weissen, undurchsichtigen Hintergrund (kein Alpha-Kanal) --
   auf dem dunklen Theme braucht es ein eigenes weisses Badge, sonst wirkt es
   wie ein loser weisser Klotz in der AppBar. */

.appbar-logo {
    height: 36px;
    width: 36px;
    background-color: #ffffff;
    border-radius: 8px;
    padding: 2px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ---------- Responsive: AppBar ------------------------- */

@media (max-width: 600px) {
    .appbar-title {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .appbar-subtitle,
    .appbar-nav-button {
        /* !important noetig: MudBlazor.min.css laedt nach app.css und setzt
           .mud-button-root{display:inline-flex} mit gleicher Spezifitaet --
           ohne !important gewinnt MudBlazors Regel per Ladereihenfolge. */
        display: none !important;
    }

    .appbar-logo {
        height: 30px;
        width: 30px;
    }

    /* Spieler-Tabelle: die feste %-Breite (siehe oben, Desktop) presst
       eingebettete MudSelect/MudSwitch sonst auf unbrauchbare Breite --
       auf Handy stattdessen wie die anderen Tabellen scrollen lassen. */
    .players-admin-table table {
        table-layout: auto;
        min-width: 560px;
    }
}

/* ---------- Dialog: internes Scrollen auf Handy-Höhen ---- */
/* Lange Formulare (z.B. CreateSeasonDialog) sollen nicht höher als der
   Viewport werden -- DialogActions (Abbrechen/Erstellen) bleibt sichtbar,
   der Inhalt scrollt für sich. */

.dialog-content-scroll {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

/* ---------- Spielplanung (/admin/schedule): Spaltenbreiten ---------- */

/* Kurze Textspalten (Gruppe, Phase, Runde, Spieler): nur so breit wie der Inhalt */
.schedule-edit-table td.col-narrow {
    width: 1%;
    white-space: nowrap;
}

/* Eingabefelder brauchen feste Breiten, sonst quetscht die Tabelle sie zusammen */
.schedule-edit-table .col-date {
    width: 165px;
}

.schedule-edit-table .col-time {
    width: 120px;
}

.schedule-edit-table .col-board {
    width: 125px;
}

/* Hinweise umbrechen statt die restlichen Spalten wegzudrücken */
.schedule-edit-table td.col-hint {
    min-width: 180px;
    max-width: 300px;
}

.schedule-edit-table td.col-hint .mud-chip {
    height: auto;
    min-height: 24px;
    max-width: 100%;
    white-space: normal;
    padding-top: 2px;
    padding-bottom: 2px;
}

.schedule-edit-table td.col-hint .mud-chip .mud-chip-content {
    white-space: normal;
}

/* Spielpool (/admin/schedule): eigene Liste in bis zu zwei Spalten.
   Spalten: Checkbox | Runde/Phase | Heim | Auswärts | Termin */
.pool-list {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden;
}

.pool-row {
    display: grid;
    grid-template-columns: 40px minmax(70px, 0.8fr) minmax(0, 1.2fr) minmax(0, 1.2fr) 100px;
    align-items: center;
    column-gap: 8px;
    padding: 0 10px 0 2px;
    min-height: 38px;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
}

.pool-row:last-child {
    border-bottom: none;
}

.pool-row:not(.pool-header):hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.pool-row.selected {
    background-color: rgba(89, 74, 226, 0.18);
}

.pool-row.pool-header {
    font-weight: 500;
    min-height: 34px;
    cursor: default;
    background-color: rgba(255, 255, 255, 0.03);
}

.pool-cell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
