/* ============================================
   STATS STYLE - NTBA
   Fichier CSS unifié pour :
   - stats_courtA.html / stats_courtB.html / stats_courtC.html (live)
   - stats_history.html (historique)
   ============================================ */

:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --primary-light: #1976d2;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #212121;
  --text-light: #616161;
  --text-muted: #9e9e9e;
  --border: #e0e0e0;
  --highlight: #2e7d32;
  --player-a: #1565c0;
  --player-b: #00897b;
}

/* ====== Reset ====== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

/* ====== Shell principal ====== */
.stats-shell {
  width: 100%;
  max-width: 500px;
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ====== HEADER / SCOREBOARD ====== */
.scoreboard {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
  color: white;
  padding: 1.25rem 1rem;
  text-align: center;
}

/* Badges (EN DIRECT / TERMINÉ / HISTORIQUE) */
.live-badge,
.history-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  color: white;
  margin-bottom: 0.5rem;
}

.live-badge {
  background: #4caf50;
}

.live-badge.ended {
  background: #ffc107;
  color: #333;
}

.history-badge {
  background: #78909c;
}

/* Info match (Court A, etc.) */
.match-info {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.9;
  margin-bottom: 1rem;
}

/* Ligne des joueurs */
.players-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.player-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.player-name {
  font-size: 0.95rem;
  font-weight: 600;
}

/* Score central */
.score-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.score-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

.main-score {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ====== SECTION PROBABILITÉ DE VICTOIRE (Live uniquement) ====== */
.win-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.win-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.win-title {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: center;
  flex: 1;
}

.win-pct {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 50px;
}

.win-pct.left {
  text-align: left;
  color: var(--player-a);
}

.win-pct.right {
  text-align: right;
  color: var(--player-b);
}

.win-names {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ====== GRAPHIQUE (Live uniquement) ====== */
.chart-container {
  position: relative;
  height: 120px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.chart-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0;
}

.chart-line {
  border-bottom: 1px dashed var(--border);
  position: relative;
}

.chart-line:last-child {
  border-bottom: none;
}

.chart-line-label {
  position: absolute;
  left: 4px;
  top: -8px;
  font-size: 0.55rem;
  color: var(--text-muted);
}

.chart-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ====== ONGLETS SETS ====== */
.set-tabs {
  display: flex;
  justify-content: center;
  padding: 0 1rem;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
}

.set-tabs:empty {
  display: none;
}

.set-tab {
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.set-tab:hover {
  color: var(--primary);
}

.set-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ====== SECTION STATS ====== */
.stats-section {
  padding: 0;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.stats-header-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
}

/* Ligne de stat */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-val {
  font-size: 0.85rem;
  min-width: 85px;
  color: var(--text);
}

.stat-val.left {
  text-align: left;
}

.stat-val.right {
  text-align: right;
}

.stat-val.highlight {
  color: var(--highlight);
  font-weight: 600;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  text-align: center;
  flex: 1;
}

/* ====== RÉSUMÉ / VAINQUEUR ====== */
.match-summary {
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  background: var(--bg);
}

.match-summary:empty {
  display: none;
}

.match-summary.winner {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--highlight);
}

/* ====== RESPONSIVE ====== */
@media (max-width: 500px) {
  body {
    padding: 0;
    align-items: flex-start;
  }

  .stats-shell {
    border-radius: 0;
    min-height: 100vh;
  }
}

@media (max-width: 400px) {
  .player-name {
    font-size: 0.85rem;
  }

  .stat-val {
    font-size: 0.75rem;
    min-width: 70px;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .win-pct {
    font-size: 0.95rem;
    min-width: 40px;
  }

  .chart-container {
    height: 100px;
  }
}