/* ====================================================================
   Grundlayout & Typografie
   ==================================================================== */

:root {
  --ml-bg: #ffffff;
  --ml-border: #444444;        /* Anthrazit */
  --ml-border-light: #dddddd;
  --ml-accent: #0066ff;
  --ml-text: #111111;
  --ml-muted: #666666;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--ml-bg);
  color: var(--ml-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;             /* Grundgröße */
  line-height: 1.4;
}

/* Headline */
.ml-heading {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 10px;
}

/* Abschnittsüberschriften (z.B. „Einzel“, „Doppel“) */
.ml-table-title {
  font-size: 15px;
  font-weight: 700;
  margin: 16px 0 6px;
}

/* Zusatzinfos (Meta-Texte) */
.ml-meta,
.ml-player-meta,
.ml-score-meta-line,
.ml-autosave-status {
  font-size: 11px;
  color: var(--ml-muted);
}

/* Links */
.ml-link {
  color: var(--ml-accent);
  text-decoration: underline;
  font-weight: 500;
}


/* ====================================================================
   Layout-Container
   ==================================================================== */

.ml-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--ml-border-light);
}

.ml-header-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ml-logo {
  max-width: 160px;
  width: 100%;
  height: auto;
  display: block;
}

.ml-header-title {
  font-size: 15px;
  font-weight: 600;
}

.ml-main {
  max-width: 960px;
  margin: 16px auto;
  padding: 0 12px;
}

.ml-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--ml-border-light);
  font-size: 11px;
  color: var(--ml-muted);
}

/* Card-Layout */
.ml-card {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--ml-border-light);
  border-radius: 6px;
  padding: 14px 12px;
  box-sizing: border-box;
}

.ml-card-wide {
  max-width: 880px;
  margin: 0 auto;
  position: relative; /* Referenz für z.B. Reload-Icon */
}


/* ====================================================================
   Formulare (Editor)
   ==================================================================== */

.ml-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ml-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ml-field label {
  font-size: 12px;
  font-weight: 600;
}

.ml-field select,
.ml-field input[type="text"],
.ml-textarea {
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--ml-border-light);
  background: #ffffff;
  box-sizing: border-box;
}

.ml-field select:focus,
.ml-field input[type="text"]:focus,
.ml-textarea:focus {
  outline: 1px solid var(--ml-accent);
  outline-offset: 1px;
}

.ml-textarea {
  resize: vertical;
}

/* Button schlicht */
.ml-btn {
  border-radius: 4px;
  border: 1px solid var(--ml-border);
  background: var(--ml-accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
}

.ml-btn:hover {
  filter: brightness(0.95);
}

/* Autosave-Status */
.ml-autosave-status {
  margin: 4px 0 10px;
}


/* ====================================================================
   Score-Übersicht (Editor & Live)
   ==================================================================== */

.ml-score-summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.ml-score-summary-table td {
  border: none;
  padding: 2px 4px;
  vertical-align: middle;
}

.ml-score-cell-main {
  width: 60%;
}

.ml-score-meta-line {
  font-weight: 600;
}

.ml-score-team {
  font-size: 14px;
  font-weight: 700;
}

.ml-score-team-home,
.ml-score-team-away {
  color: var(--ml-text);
}

.ml-score-cell-heading {
  width: 20%;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ml-muted);
}

.ml-score-cell-value {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}


/* ====================================================================
   Tabellen (allgemein + Einzel/Doppel + Live-Liste)
   ==================================================================== */

/* generische Tabellenbasis für deine neuen Tabellen */
.ml-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.9rem;
}

.ml-table th,
.ml-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--ml-border-light);
}

.ml-table th {
  text-align: left;
  font-weight: 600;
}

/* Bestehende Scoreboard-/Live-Tabellen */

.nb-table,
.ml-live-list-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}

.nb-table th,
.nb-table td,
.ml-live-list-table th,
.ml-live-list-table td {
  border: 1px solid var(--ml-border-light);
  padding: 6px 4px;
  vertical-align: top;
  box-sizing: border-box;
}

.nb-table thead th,
.ml-live-list-table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ml-muted);
  background: #f7f7f7;
}

/* Spaltenbreiten Scoreboard */
.nb-col-pos {
  width: 32px;
  text-align: center;
  font-weight: 700;
}

.nb-col-players {
  width: 45%;
  color: #333;
}

.nb-col-sets {
  width: 40px;
  text-align: center;
}

/* Live-Liste etwas reduzierter gerahmt */
.ml-live-list-table th,
.ml-live-list-table td {
  border: none;
  border-bottom: 1px solid var(--ml-border-light);
}

.ml-live-list-table tr:last-child td {
  border-bottom: none;
}


/* ====================================================================
   Spieler-Anzeige
   ==================================================================== */

.ml-player-name {
  font-size: 13px;
  font-weight: 600;
}

.ml-player-meta {
  margin-top: 1px;
}

/* Tabellen: Spieler, Partien, Teams (Suchergebnisse, Teamseite) */

.ml-player-table,
.ml-match-table,
.ml-team-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.9rem;
}

.ml-player-table th,
.ml-player-table td,
.ml-match-table th,
.ml-match-table td,
.ml-team-table th,
.ml-team-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #ddd;
}

.ml-player-table th,
.ml-match-table th,
.ml-team-table th {
  text-align: left;
  font-weight: 600;
}

/* Links in Tabellen */
.ml-match-score-link {
  text-decoration: underline;
}

.ml-team-league-link {
  text-decoration: underline;
}


/* ====================================================================
   Satz-Eingaben (Editor)
   ==================================================================== */

.nb-set-input,
.ml-set-input {
  width: 26px;
  padding: 3px 2px;
  text-align: center;
  border-radius: 4px;
  border: 1px solid var(--ml-border-light);
  font-size: 13px;
  box-sizing: border-box;
}

.nb-set-sep,
.ml-set-sep {
  font-size: 13px;
  color: var(--ml-muted);
}

/* Fehlerzustand */
.ml-set-input-error,
.nb-set-input.ml-set-input-error {
  border-color: #e53935;
  background-color: #ffecec;
}


/* ====================================================================
   Layout-Abstände & Aktionen
   ==================================================================== */

.ml-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}

/* Share-Bar */
.ml-share-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--ml-border-light);
  background: #f7f7f7;
}

.ml-share-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ml-muted);
}

.ml-share-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ml-share-input {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--ml-border-light);
  padding: 5px 6px;
  font-size: 12px;
  background: #ffffff;
  font-family: monospace;
  box-sizing: border-box;
}

@media (min-width: 640px) {
  .ml-share-links {
    flex-direction: row;
  }
  .ml-share-input {
    flex: 1;
  }
}


/* ====================================================================
   Live-Toolbar & Buttons
   ==================================================================== */

.ml-live-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 8px;
}

.ml-icon-btn {
  border: 1px solid var(--ml-border-light);
  background: #ffffff;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
}

.ml-icon-btn:hover {
  background: #f0f0f0;
}

/* Reload-Icon auf Cards */
.ml-live-reload {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 20px;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.ml-live-reload:hover {
  opacity: 1;
  transform: scale(1.05);
}


/* ====================================================================
   Match-Status & Status-Dots
   ==================================================================== */

.ml-match-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ml-muted);
}

.ml-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Live-Indikator für Live-Ansicht (blinkend, rot) */
.ml-status-live-animated {
  background: #d50000;
  animation: ml-blink 1s infinite;
}

/* Live-/Finished für Suchergebnisse (einfache Farbe) */
.ml-status-live {
  background-color: #28a745; /* grün gefüllt */
}

.ml-status-finished {
  background-color: #ccc;
}

.ml-status-label {
  font-weight: 600;
}

@keyframes ml-blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0.3;
  }
}


/* ====================================================================
   Tabs auf Home
   ==================================================================== */

.ml-tabs {
  display: inline-flex;
  border-bottom: 1px solid var(--ml-border-light);
  margin-bottom: 10px;
}

.ml-tab-btn {
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ml-muted);
  border-bottom: 2px solid transparent;
}

.ml-tab-btn-active {
  color: var(--ml-text);
  font-weight: 600;
  border-bottom-color: var(--ml-accent);
}

.ml-tab-panel {
  display: none;
}

.ml-tab-panel-active {
  display: block;
}


/* ====================================================================
   Editor-Header
   ==================================================================== */

.ml-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}

.ml-editor-header-left {
  max-width: 60%;
}

.ml-editor-header-left .ml-meta {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.4;
}

.ml-editor-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ml-editor-header-right .ml-meta-link {
  font-size: 0.85rem;
  color: #0066cc;
  text-decoration: none;
  margin-bottom: 4px;
}

.ml-editor-header-right .ml-meta-link:hover {
  text-decoration: underline;
}


/* ====================================================================
   Gewinnerzeilen im Scoreboard
   ==================================================================== */

.nb-row-winner-home {
  background: rgba(0, 200, 0, 0.06);
  border-left: 4px solid #2e7d32;
}

.nb-row-winner-away {
  background: rgba(0, 0, 200, 0.06);
  border-left: 4px solid #1565c0;
}

.nb-row-winner-home .ml-score-team-home,
.nb-row-winner-away .ml-score-team-away {
  font-weight: 600;
}

.ml-winner {
  color: #e67e22;
  margin-right: 4px;
}

.ml-winner-text {
  font-weight: 700;
  color: #222;
}

.ml-winner-icon {
  margin-right: 4px;
}

.ml-winner-name {
  font-weight: 700;
}


/* ====================================================================
   Spieler-Overlay
   ==================================================================== */

.ml-player-overlay[hidden] {
  display: none;
}

.ml-player-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ml-player-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.ml-player-overlay-content {
  position: relative;
  z-index: 1;
  max-width: 360px;
  width: 90%;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  padding: 20px 24px 18px;
  font-size: 14px;
}

.ml-player-overlay-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.ml-player-overlay-body p {
  margin: 4px 0;
}

.ml-player-overlay-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}

/* Spieler als "Link" in Tabellen/Listen */
.ml-player-link {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.ml-player-link:hover {
  color: #0070c9;
  text-decoration: underline;
}
