/* =============================================================
   umbau/css/meisterschaft.css
   Vamily – Clubmeisterschaften & Turnierbaum (KO-System)
   =============================================================
   Inhalt:
     1. Turnierbaum-Container (horizontales Scroll-Layout)
     2. Runden-Spalten
     3. Match-Karten (Grundzustand)
     4. Match-Karten-Teams (Zeilen für Spieler + Score)
     5. Match-Meta-Bereich (Datum, Status)
     6. SVG-Verbindungslinien zwischen Karten
     7. Match-Highlight (eigene Spiele)
     8. Geplante-Matches-Liste
   ============================================================= */


/* ─────────────────────────────────────────────────────────────
   1. TURNIERBAUM-CONTAINER
   Horizontales Scrollen für breite KO-Brackets
   ───────────────────────────────────────────────────────────── */
.tree-container {
    display: flex;
    gap: 40px;
    padding: 20px 10px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 400px;
    position: relative; /* Wichtig: SVG-Linien werden absolut positioniert */
}


/* ─────────────────────────────────────────────────────────────
   2. RUNDEN-SPALTEN
   Jede Runde (Viertelfinale, Halbfinale etc.) ist eine Spalte
   ───────────────────────────────────────────────────────────── */
.tree-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 20px;
    width: 250px;
    min-width: 250px; /* Verhindert Schrumpfen bei vielen Runden */
    flex-shrink: 0;
}

/* Label über jeder Runden-Spalte */
.tree-round-label {
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}


/* ─────────────────────────────────────────────────────────────
   3. MATCH-KARTEN (Grundzustand)
   Eine Karte pro Begegnung im KO-Baum
   ───────────────────────────────────────────────────────────── */
.tree-match-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-bright);
    border-radius: 16px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
    width: 100%;
    position: relative; /* Für das "DEIN SPIEL"-Label */
}

.tree-match-card:hover {
    border-color: var(--primary);
    transform: translateX(4px);
    box-shadow: 0 8px 24px rgba(190, 242, 100, 0.1);
}


/* ─────────────────────────────────────────────────────────────
   4. MATCH-KARTEN-TEAMS
   Jede Karte hat zwei Zeilen (Spieler 1 und Spieler 2)
   ───────────────────────────────────────────────────────────── */
.tree-match-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: background 0.15s ease;
}

/* Gewinner-Zeile: farbig hervorgehoben */
.tree-match-team.winner {
    background: var(--primary-muted);
    color: var(--primary);
    font-weight: 700;
}

/* Verlierer-Zeile: leicht gedimmt */
.tree-match-team.loser {
    opacity: 0.55;
}

/* Spieler-Name (linke Seite) */
.tree-match-team-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
    font-weight: 600;
}

.tree-match-team.winner .tree-match-team-name {
    color: var(--primary);
}

/* Ergebnis-Score (rechte Seite, feste Breite für stabile Ausrichtung) */
.tree-match-score {
    font-variant-numeric: tabular-nums; /* Verhindert Jitter durch variable Ziffernbreite */
    font-weight: 800;
    font-size: 0.8rem;
    min-width: 36px;
    text-align: right;
    flex-shrink: 0;
}


/* ─────────────────────────────────────────────────────────────
   5. MATCH-META-BEREICH
   Zeigt Datum, Uhrzeit und Status unterhalb der Teamzeilen
   ───────────────────────────────────────────────────────────── */
.tree-match-meta {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Status-Badges innerhalb des Meta-Bereichs */
.match-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.match-status-badge.geplant    { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.match-status-badge.abgeschlossen { background: var(--primary-muted);  color: var(--primary); }
.match-status-badge.offen      { background: rgba(255,255,255,0.05);   color: var(--text-muted); }


/* ─────────────────────────────────────────────────────────────
   6. SVG-VERBINDUNGSLINIEN
   Horizontale + Kurven-Linien zwischen den Match-Karten
   ───────────────────────────────────────────────────────────── */

/* Der SVG-Layer liegt über dem gesamten tree-container */
#tree-connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Klicks gehen durch den SVG-Layer */
    overflow: visible;
}

#tree-connections-svg path {
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 1.5;
    fill: none;
    transition: stroke 0.3s ease;
}

/* Beim Hover über eine Karte: zugehörige Linien heller */
#tree-connections-svg path.highlighted {
    stroke: var(--primary);
    stroke-width: 2;
    opacity: 0.7;
}


/* ─────────────────────────────────────────────────────────────
   7. MATCH-HIGHLIGHT (eigene Spiele im Turnierbaum)
   Hebt Matches hervor, an denen der eingeloggte User beteiligt ist
   Hinweis: .is-own-match ist auch in dashboard.css definiert –
   hier ergänzen wir nur turnierbaum-spezifische Overrides
   ───────────────────────────────────────────────────────────── */
.tree-match-card.is-own-match {
    border: 2px solid var(--primary) !important;
    box-shadow: 0 0 20px var(--primary-muted) !important;
}

/* "DEIN SPIEL"-Pill */
.tree-match-card.is-own-match::after {
    content: 'DEIN SPIEL';
    position: absolute;
    top: -10px;
    right: 12px;
    background: var(--primary);
    color: var(--bg-dark);
    font-size: 0.55rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    pointer-events: none;
}


/* ─────────────────────────────────────────────────────────────
   8. GEPLANTE-MATCHES-LISTE (Zuschauer-Infos)
   Kompakte Liste der angesetzten CM-Spiele
   ───────────────────────────────────────────────────────────── */
.cm-match-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.cm-match-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.cm-match-teams {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}

.cm-match-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Wettbewerbs-Label rechts neben dem Eintrag */
.cm-match-badge {
    font-size: 0.7rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--primary-muted);
    color: var(--primary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Score Sets in Match Cards */
.tree-match-score span {
    min-width: 14px;
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
}
.tree-match-score span.set-winner {
    color: var(--text-main);
    font-weight: 800;
}
.tree-match-team.winner .tree-match-score span.set-winner {
    color: var(--primary);
}
