:root {
  /* Ces valeurs sont surchargées en JS (app.js -> applyTheme()) à partir de
     config.js, lui-même basé sur la Charte Graphique HCC v1.0. Modifier
     config.js suffit pour changer tout le thème. */
  --color-primary: #004A78;
  --color-primary-dark: #003A5E;
  --color-secondary: #ffffff;
  --color-accent: #E0001F;
  --color-home-bg: #e8f5e9;
  --color-away-bg: #EEF1F4;
  --color-encre: #2B3640;
  --color-gris: #6B7884;
  --color-gris-clair: #EEF1F4;
  --color-gris-ligne: #DFE4EA;
  --color-creme: #F7F8FA;
  --font-title: 'Poppins', 'Calibri', Arial, sans-serif;
  --font-body: 'Inter', 'Calibri', Arial, sans-serif;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-creme);
  color: var(--color-encre);
}

h1, h2, .brand, .nav-btn, .btn, .week-tab, .tab-btn {
  font-family: var(--font-title);
}

.hidden { display: none !important; }
.muted { color: var(--color-gris); }
.small { font-size: 0.85em; }

/* Header */
.app-header {
  background: var(--color-primary);
  color: var(--color-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 3px solid var(--color-accent); /* filet rouge, signature de la charte */
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; }
.brand-logo { height: 36px; width: 36px; object-fit: contain; }
.main-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: var(--color-secondary);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-btn.active { background: var(--color-secondary); color: var(--color-primary); font-weight: 700; }
.nav-btn--danger { background: rgba(0,0,0,0.2); }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* Auth */
.auth-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  max-width: 480px;
  margin: 0 auto;
}
.auth-card h1 {
  color: var(--color-primary);
  font-weight: 700;
  letter-spacing: -0.01em;
  position: relative;
  padding-bottom: 14px;
}
.auth-card h1::after {
  /* Filet rouge sous le grand titre, comme spécifié dans la charte */
  content: "";
  display: block;
  width: 64px;
  height: 3px;
  background: var(--color-accent);
  margin-top: 10px;
}
.tabs { display: flex; gap: 8px; margin: 16px 0; border-bottom: 1px solid var(--color-gris-ligne); }
.tab-btn {
  background: none; border: none; padding: 10px 4px; cursor: pointer;
  font-size: 0.95rem; color: var(--color-gris); border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-accent); font-weight: 600; }
.tab-panel { display: none; flex-direction: column; gap: 12px; }
.tab-panel.active { display: flex; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; font-weight: 500; font-family: var(--font-body); }
input {
  padding: 10px 12px; border: 1px solid var(--color-gris-ligne); border-radius: 8px;
  font-size: 1rem; font-family: var(--font-body);
}
.field-hint { font-size: 0.78rem; color: var(--color-gris); font-weight: 400; line-height: 1.3; }
input:invalid:not(:placeholder-shown) { border-color: var(--color-accent); }
.password-field { position: relative; display: flex; }
.password-field input { flex: 1; padding-right: 40px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1.1rem;
  padding: 4px 8px; line-height: 1; opacity: 0.6;
}
.password-toggle:hover { opacity: 1; }
.btn {
  padding: 12px; border-radius: 8px; border: none; font-size: 1rem; cursor: pointer; font-weight: 600;
}
.btn-primary { background: var(--color-accent); color: var(--color-secondary); }
.btn-primary:hover { background: #b50019; }
.btn:disabled { opacity: 0.65; cursor: not-allowed; }
.btn-spinner {
  display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,0.45); border-top-color: #fff; border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn-secondary {
  background: white; color: var(--color-primary); border: 1px solid var(--color-primary);
  margin-top: 8px;
}
.btn-secondary:hover { background: var(--color-creme); }
.form-error { color: #c62828; font-size: 0.85rem; min-height: 1em; }
.form-success { color: var(--color-vert, #3FA34D); font-size: 0.85rem; }

/* Semaines / matchs */
.week-tabs {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px;
}
.week-tab {
  flex-shrink: 0; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--color-gris-ligne);
  background: white; cursor: pointer; font-size: 0.9rem; font-weight: 500;
}
.week-tab.active { background: var(--color-primary); color: var(--color-secondary); border-color: var(--color-primary); }

.matches-list { display: flex; flex-direction: column; gap: 12px; }

/* Barre de progression de la semaine */
.week-progress { background: white; border-radius: var(--radius); padding: 14px 16px; }
.week-progress__header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 600; }
.week-progress__bar { height: 8px; background: var(--color-gris-clair); border-radius: 4px; overflow: hidden; }
.week-progress__fill { height: 100%; background: var(--color-vert, #3FA34D); border-radius: 4px; transition: width 0.3s ease; }
.week-complete-banner {
  background: #E8F5E9; color: #2E7D32; border-radius: var(--radius); padding: 14px 16px;
  font-size: 0.9rem; text-align: center;
}

.match-card {
  border-radius: var(--radius); padding: 16px; background: var(--color-away-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border-left: 4px solid var(--color-gris-ligne);
}
.match-card--home { background: var(--color-home-bg); border-left-color: var(--color-vert, #3FA34D); }
.match-card--away { border-left-color: var(--color-primary); }
.match-card__teams { font-size: 1.05rem; margin-bottom: 4px; font-family: var(--font-title); font-weight: 700; }
.match-card__meta { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--color-gris); margin-bottom: 10px; }
.match-result, .match-my-prediction, .match-closed, .match-upcoming {
  font-size: 0.9rem; margin-top: 6px; padding: 8px; background: rgba(255,255,255,0.7); border-radius: 8px;
}

/* Pronostic façon "ticket" : boutons 1 / N / 2 + score compact à droite */
.pick-row { display: flex; gap: 8px; align-items: stretch; }
.pick-btn {
  flex: 1 1 0; min-width: 0; height: 52px; border-radius: 10px; border: 2px solid var(--color-gris-ligne);
  background: white; font-size: 1.1rem; font-weight: 700; font-family: var(--font-title);
  color: var(--color-encre); cursor: pointer; transition: all 0.15s ease;
}
.pick-btn:hover { border-color: var(--color-primary); }
.pick-btn:disabled, .score-slot input:disabled { opacity: 0.5; cursor: not-allowed; }
.pick-btn--home.selected { background: var(--color-primary); border-color: var(--color-primary); color: white; }
.pick-btn--draw.selected { background: var(--color-orange, #EA6404); border-color: var(--color-orange, #EA6404); color: white; }
.pick-btn--away.selected { background: var(--color-accent); border-color: var(--color-accent); color: white; }
.score-slot {
  flex: 1.3 1 0; min-width: 0; height: 52px; border-radius: 10px; border: 2px solid var(--color-gris-ligne);
  background: white; display: flex; align-items: center; justify-content: center; gap: 4px;
}
.score-slot input {
  width: 32px; padding: 4px; border: none; text-align: center; font-size: 1.1rem; font-weight: 700;
  font-family: var(--font-title); color: var(--color-encre); -moz-appearance: textfield;
}
.score-slot input::-webkit-outer-spin-button, .score-slot input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.score-sep { color: var(--color-gris); font-weight: 700; }
.pick-status { font-size: 0.82rem; margin: 8px 0 0; min-height: 1.1em; }
.pick-status--ok { color: #2E7D32; }
.pick-status--error { color: #C62828; }

/* Indicateurs 1/N/2 côté admin : mêmes couleurs que côté joueur, mais en
   lecture seule — le résultat se déduit automatiquement du score saisi. */
.pick-indicator {
  flex: 1 1 0; min-width: 0; height: 52px; border-radius: 10px; border: 2px solid var(--color-gris-ligne);
  background: white; font-size: 1.1rem; font-weight: 700; font-family: var(--font-title);
  color: var(--color-gris); display: flex; align-items: center; justify-content: center;
}
.pick-indicator--home.selected { background: var(--color-primary); border-color: var(--color-primary); color: white; }
.pick-indicator--draw.selected { background: var(--color-orange, #EA6404); border-color: var(--color-orange, #EA6404); color: white; }
.pick-indicator--away.selected { background: var(--color-accent); border-color: var(--color-accent); color: white; }
.admin-pick-hint { margin: 8px 0; }

/* Tableau de bord admin */
.dashboard-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.dashboard-stat-card {
  flex: 1 1 140px; background: white; border-radius: var(--radius); padding: 16px;
  text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.dashboard-stat-card strong { display: block; font-size: 1.6rem; color: var(--color-primary); font-family: var(--font-title); }
.dashboard-stat-card span { font-size: 0.78rem; color: var(--color-gris); }
.dashboard-toolbar { display: flex; justify-content: flex-end; margin-top: 12px; }
.dashboard-table-container { overflow-x: auto; }
.dashboard-table-container table { min-width: 0; width: 100%; font-size: 0.78rem; }
.dashboard-table-container th, .dashboard-table-container td { padding: 7px 8px; }
.dashboard-table th.dashboard-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.dashboard-table th.dashboard-sortable:hover { opacity: 0.85; }
.dashboard-table th.active { text-decoration: underline; }
.dashboard-row-clickable { cursor: pointer; }
.dashboard-row-clickable:hover { background: var(--color-corail-clair, #FBE3DD) !important; }

/* Popup pronostics d'un joueur */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex;
  align-items: center; justify-content: center; padding: 20px; z-index: 1000;
}
.modal-card {
  background: white; border-radius: var(--radius); padding: 20px; max-width: 820px;
  width: 100%; max-height: 80vh; overflow-y: auto;
}
.modal-card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-card__header h3 { color: var(--color-primary); margin: 0; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--color-gris); }
.modal-close:hover { color: var(--color-accent); }
.modal-predictions-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.modal-predictions-table th, .modal-predictions-table td { padding: 8px; text-align: left; border-bottom: 1px solid var(--color-gris-ligne); }
.modal-predictions-table thead { background: var(--color-gris-clair); }

/* Classements */
.standings-table table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; }
.standings-table th, .standings-table td { padding: 10px 12px; text-align: left; font-size: 0.9rem; }
.standings-table thead { background: var(--color-primary); color: var(--color-secondary); font-family: var(--font-title); }
.standings-table tbody tr:nth-child(even) { background: var(--color-gris-clair); }
.standings-row--me { background: var(--color-corail-clair, #FBE3DD) !important; font-weight: 700; }
.standings-sep { text-align: center; color: var(--color-gris); }

/* Profil */
.profile-card { background: white; border-radius: var(--radius); padding: 24px; max-width: 640px; margin: 0 auto; }
.profile-card h2 { color: var(--color-primary); font-weight: 700; }
.profile-stats { display: flex; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.profile-stats > div { text-align: center; background: var(--color-creme); border-radius: 8px; padding: 12px 18px; }
.profile-stats strong { display: block; font-size: 1.4rem; color: var(--color-accent); font-family: var(--font-title); }
.profile-stats span { font-size: 0.8rem; color: var(--color-gris); }

/* Admin */
.admin-title { color: var(--color-primary); font-weight: 700; margin-bottom: 4px; }
.admin-predictions-list { margin-top: 10px; }
.admin-predictions-table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; }
.admin-predictions-table th, .admin-predictions-table td { padding: 8px 10px; text-align: left; font-size: 0.85rem; }
.admin-predictions-table thead { background: var(--color-gris-clair); }
.admin-predictions-table tbody tr:nth-child(even) { background: var(--color-creme); }

/* Règles du jeu */
.rules-box {
  margin: 16px 0; padding: 12px 16px; background: var(--color-creme);
  border-radius: 8px; border: 1px solid var(--color-gris-ligne);
}
.rules-box summary { cursor: pointer; font-weight: 600; color: var(--color-primary); }
.rules-content h2 { color: var(--color-primary); margin-top: 12px; }
.rules-list { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.rules-list ul, .rules-list ol { margin-top: 6px; padding-left: 20px; }

@media (max-width: 480px) {
  .app-header { flex-direction: column; align-items: flex-start; }
}
