/* ============================================================
   Vereinsmeisterschaft (VM) – Styles
   Eigenstaendiges Stylesheet des modulex/Vm-Moduls.
   ============================================================ */

:root {
    --vm-accent: #2e7d32;
    --vm-accent-dark: #1b5e20;
    --vm-qualified: #e6f4ea;
    --vm-border: #d9d9d9;
    --vm-muted: #888;
}

/* ---------- Tabs (oben, 3 Kategorien) ---------- */
.vm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 20px;
    border-bottom: 2px solid var(--vm-border);
}
.vm-tab {
    appearance: none;
    border: 1px solid var(--vm-border);
    border-bottom: none;
    background: #f5f5f5;
    color: #333;
    padding: 12px 18px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    line-height: 1.2;
}
.vm-tab.is-active {
    background: var(--vm-accent);
    color: #fff;
    border-color: var(--vm-accent);
}
.vm-tab-panel { display: none; }
.vm-tab-panel.is-active { display: block; }

/* ---------- Tabellen ---------- */
.vm-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 16px;
    font-size: 15px;
}
.vm-table th,
.vm-table td {
    border: 1px solid var(--vm-border);
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
}
.vm-table th {
    background: #f0f0f0;
    font-weight: 600;
}
.vm-table tbody tr:hover { background: #f6f6f6; }

/* Live-Tabelle einer Gruppe */
.vm-standings { font-size: 14px; }
.vm-standings td, .vm-standings th { text-align: center; padding: 7px 6px; }
.vm-standings th:first-child, .vm-standings td:first-child { width: 24px; padding-left: 4px; padding-right: 4px; }
.vm-standings th:nth-child(2), .vm-standings td:nth-child(2) { text-align: left; }
.vm-standings th:nth-child(3), .vm-standings td:nth-child(3) { width: 30px; }   /* Sp */
.vm-standings th:nth-child(4), .vm-standings td:nth-child(4) { width: 56px; }   /* Punkte */
.vm-standings th:nth-child(5), .vm-standings td:nth-child(5) { width: 50px; }   /* Saetze */
.vm-standings th:nth-child(6), .vm-standings td:nth-child(6) { width: 62px; }   /* Spiele */
.vm-qualified { background: var(--vm-qualified); }
.vm-qualified:hover { background: #dcefe1; }

.vm-muted { color: var(--vm-muted); }

/* ---------- Gruppen-Raster (oeffentliche Seite) ---------- */
.vm-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
    gap: 20px;
    align-items: start;
}
.vm-group-card {
    border: 1px solid var(--vm-border);
    border-radius: 10px;
    padding: 14px 16px 16px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
    min-width: 0; /* erlaubt dem Grid-Element zu schrumpfen (verhindert Ueberlauf) */
}
.vm-group-card h3 {
    margin: 0 0 10px;
    color: var(--vm-accent-dark);
    font-size: 16px;
    border-bottom: 2px solid var(--vm-qualified);
    padding-bottom: 7px;
}
.vm-group-card .vm-table { margin-bottom: 10px; }

/* ---------- Bracket (K.o.-Baum) ---------- */
.vm-bracket {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    padding-bottom: 8px;
}
.vm-round {
    display: flex;
    flex-direction: column;
    min-width: 210px;
}
/* nur die Matches werden verteilt (Titel bleibt oben) -> rechte Partien stehen
   mittig zwischen ihren beiden linken Feeder-Partien */
.vm-round-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}
.vm-round-title {
    font-weight: 700;
    color: var(--vm-accent-dark);
    text-align: center;
    /* gleiche Titelhoehe, damit alle Runden-Spalten auf gleicher Hoehe starten */
    min-height: 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
}
.vm-match {
    border: 1px solid var(--vm-border);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}
.vm-side {
    /* feste Hoehe -> alle Kaesten gleich gross -> Turnierbaum bleibt ausgerichtet,
       auch bei langen/zweizeiligen Namen */
    height: 42px;
    box-sizing: border-box;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
}
.vm-side + .vm-side { border-top: 1px solid var(--vm-border); }
.vm-side.is-winner { font-weight: 700; background: var(--vm-qualified); }
.vm-side.is-bye { color: var(--vm-muted); font-style: italic; }
.vm-side-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.15;
    max-height: 2.4em;
    word-break: break-word;
}
.vm-side-score { color: var(--vm-accent-dark); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }
.vm-match-time {
    border-top: 1px solid var(--vm-border);
    background: var(--vm-qualified);
    color: var(--vm-accent-dark);
    font-size: 11.5px;
    text-align: center;
    padding: 3px 6px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.vm-match-result {
    border-top: 1px solid var(--vm-border);
    background: #fff;
    color: var(--vm-accent-dark);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .02em;
    text-align: center;
    padding: 3px 6px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ---------- Formulare / Buttons ---------- */
.vm-inline { display: inline-block; margin: 0; }
.vm-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.vm-add-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 8px 0; }
.vm-add-form label { display: flex; flex-direction: column; font-size: 13px; gap: 3px; }
.vm-add-form select, .vm-add-form input { padding: 6px 8px; }
.vm-small-button { padding: 6px 12px !important; font-size: 14px !important; }
.vm-seed-input { width: 60px; }
.vm-sets { display: inline-flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; vertical-align: bottom; }
.vm-setcol { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.vm-setlabel { font-size: 10px; color: #888; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.vm-set { display: inline-flex; align-items: center; gap: 3px; }
.vm-set-colon { color: #aaa; font-weight: 700; }
.vm-set-input {
    width: 42px;
    text-align: center;
    padding: 6px 4px;
    border: 1px solid var(--vm-border);
    border-radius: 5px;
    font-size: 15px;
}
.vm-set-input:focus { border-color: var(--vm-accent); outline: none; box-shadow: 0 0 0 2px rgba(46, 125, 50, .15); }
.vm-score { color: var(--vm-accent-dark); margin: 0 8px; font-variant-numeric: tabular-nums; }
.vm-pair { display: inline-block; min-width: 220px; }
.vm-link-button {
    appearance: none;
    background: none;
    border: none;
    color: #b00020;
    cursor: pointer;
    text-decoration: underline;
    font-size: 13px;
    padding: 0;
}

/* ---------- Startseiten-Link ---------- */
.vm-home-link {
    display: inline-block;
    background: var(--vm-accent);
    color: #fff !important;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
}
.vm-home-link:hover { background: var(--vm-accent-dark); }

/* ---------- Badge "qualifiziert" ---------- */
.vm-badge-qualified {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: var(--vm-accent);
    color: #fff;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: middle;
}
.vm-standings-name { text-align: left !important; }

/* ---------- Gruppen-Partienliste ---------- */
.vm-group-matches {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    font-size: 14px;
}
.vm-group-matches li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    border-top: 1px dotted var(--vm-border);
}
.vm-gm-score { font-weight: 600; color: var(--vm-accent-dark); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vm-gm-open { color: var(--vm-muted); font-style: italic; }
.vm-gm-time { color: var(--vm-accent-dark); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Meine Partien ---------- */
.vm-my-match {
    border: 1px solid var(--vm-border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: #fff;
}
.vm-my-head { display: flex; flex-direction: column; margin-bottom: 8px; }
.vm-my-cat { font-size: 12px; color: var(--vm-muted); text-transform: uppercase; letter-spacing: .04em; }
.vm-my-pair { font-size: 17px; }
.vm-my-body { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.vm-my-scheduled, .vm-my-result { display: flex; align-items: center; gap: 10px; }
.vm-report-label { display: block; color: var(--vm-accent-dark); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.vm-report-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.vm-small-link { font-size: 13px; }

/* ---------- Planungsformular ---------- */
.vm-plan-form {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    margin-top: 12px;
}
.vm-plan-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.vm-plan-form select, .vm-plan-form input { padding: 7px 9px; }
.vm-plan-match { font-size: 17px; }

/* ---------- Kalender-Planungsmodus + Slot-Bestätigung ---------- */
.vm-plan-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--vm-accent);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0 16px;
    font-size: 15px;
}
.vm-plan-banner a { color: #fff; text-decoration: underline; font-weight: 600; }
.vm-plan-cal { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.vm-slot-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f6faf7;
    border: 1px solid var(--vm-border);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0 16px;
    max-width: 360px;
}
.vm-slot-box > div { display: flex; justify-content: space-between; gap: 12px; }
.vm-slot-label { color: var(--vm-muted); }
.vm-slot-form { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.vm-slot-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.vm-slot-form select { padding: 8px 10px; }
/* Freie Slots im Planungsmodus hervorheben */
.cc-vm-pick { outline: 2px solid var(--vm-accent); outline-offset: -2px; }
.cc-vm-pick:hover { background: var(--vm-qualified) !important; }

/* ---------- Fristen ---------- */
.vm-deadline-h, .vm-round-deadline {
    font-size: 12px;
    font-weight: 600;
    color: #b45309;
    background: #fff4e5;
    border: 1px solid #f3d19e;
    padding: 1px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.vm-deadline-h { margin-left: 8px; }
.vm-round-deadline { display: inline-block; margin-top: 3px; font-weight: 500; }
.vm-round-title { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.vm-deadline {
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #b45309;
    background: #fff4e5;
    border: 1px solid #f3d19e;
    padding: 0 7px;
    border-radius: 10px;
}
.vm-deadline-input { width: 120px; }

/* ---------- Meine Partie: Hervorhebung / Hinweise / Inline-Planung ---------- */
.vm-me { color: var(--vm-accent-dark); }
.vm-info { color: var(--vm-muted); font-style: italic; }
.vm-plan-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: flex-end;
    margin: 6px 0;
    padding: 10px 12px;
    background: #f6faf7;
    border: 1px solid var(--vm-border);
    border-radius: 8px;
}
.vm-plan-inline label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #555; }
.vm-plan-inline select, .vm-plan-inline input { padding: 6px 8px; }
.vm-plan-caption { flex-basis: 100%; font-weight: 600; color: var(--vm-accent-dark); font-size: 13px; }
.vm-my-body { display: block; }
.vm-my-body > * { margin-bottom: 8px; }

/* ---------- Regeln ---------- */
.vm-rules { margin-top: 8px; }
.vm-rules h2 { color: var(--vm-accent-dark); }
.vm-rules-list { padding-left: 20px; }
.vm-rules-list li { margin-bottom: 8px; line-height: 1.45; }
.vm-rules-notes {
    margin-top: 12px;
    padding: 12px 14px;
    background: #f6f6f6;
    border-left: 3px solid var(--vm-accent);
    border-radius: 4px;
}
.vm-rules-notes p { margin: 0 0 6px; }
.vm-rules-notes p:last-child { margin-bottom: 0; }

/* ---------- Reiter-Links (Meine Partien / Verwaltung) ---------- */
.vm-tabs-spacer { flex: 1 1 8px; }
.vm-tab-link { text-decoration: none; color: var(--vm-accent-dark); }
.vm-tab-link:hover { background: #eef6f0; }

/* ---------- Meine Partie: Summary + Edit-Panel ---------- */
.vm-my-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.vm-my-status { font-size: 15px; }
.vm-edit-panel {
    display: none;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--vm-border);
}
.vm-my-match.is-open .vm-edit-panel { display: block; }
.vm-edit-panel > * { margin-bottom: 10px; }
.vm-edit-panel > *:last-child { margin-bottom: 0; }

/* ---------- W.O. / Aufgabe ---------- */
.vm-special-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: flex-end;
    padding: 10px 12px;
    background: #fdf6ec;
    border: 1px solid #f3d19e;
    border-radius: 8px;
}
.vm-special-caption { flex-basis: 100%; font-weight: 600; color: #b45309; font-size: 13px; }
.vm-special-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #555; }
.vm-special-form select, .vm-special-form input { padding: 6px 8px; }
.vm-special-sets { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; color: #555; }

/* ---------- Admin-Match-Zeile ---------- */
.vm-admin-match { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }

/* ---------- Turnierbaum-Editor (Admin) ---------- */
.vm-bracket-editor { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.vm-be-match { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; border-bottom: 1px dotted var(--vm-border); }
.vm-be-num { min-width: 72px; font-weight: 600; color: #555; font-size: 13px; }
.vm-be-select { padding: 5px 8px; min-width: 170px; max-width: 260px; }
.vm-be-ro { display: inline-block; min-width: 170px; max-width: 260px; padding: 5px 8px; color: #555; background: #f6f6f6; border-radius: 5px; }
.vm-be-vs { color: var(--vm-muted); font-size: 12px; }
.vm-bracket-editor > button { align-self: flex-start; margin-top: 10px; }
.vm-be-round { margin-bottom: 14px; }
.vm-be-round h3 { color: var(--vm-accent-dark); margin: 0 0 6px; }

/* ---------- Teilnehmer-Karten (Admin) ---------- */
.vm-participants { display: flex; flex-direction: column; gap: 8px; }
.vm-participant { border: 1px solid var(--vm-border); border-radius: 8px; padding: 10px 12px; background: #fff; }
.vm-participant-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.vm-edit-participant { margin: 0; }

/* ---------- Kalender-Highlight ---------- */
.calendar-cell.cc-vm,
td .cc-vm {
    background: var(--vm-accent) !important;
    color: #fff !important;
}
.cc-vm a, .cc-vm { color: #fff !important; }

/* ---------- Responsiv / Mobil ---------- */
@media (max-width: 700px) {
    .vm-bracket { flex-direction: column; }
    .vm-round { min-width: 0; }
    .vm-tab { flex: 1 1 auto; text-align: center; padding: 10px 8px; font-size: 15px; }
    .vm-pair { min-width: 0; display: block; margin-bottom: 4px; }
    .vm-table { font-size: 14px; }
    .vm-table th, .vm-table td { padding: 6px 6px; }
    .vm-add-form { flex-direction: column; align-items: stretch; }
    .vm-set-input { width: 32px; }
}
