/* style.css — CDM 2026. Mobile-first, look sombre inspiré des sites e-sport/paris. */

:root {
  --bg: #0a0e1a;
  --bg-card: #131a2b;
  --bg-elev: #1c2740;
  --bg-row: #161f33;
  --text: #e8edf4;
  --muted: #8493ad;
  --accent: #2f9e57;       /* vert validation */
  --accent-hover: #38b566;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --danger: #ef4444;
  --border: #243049;
  --radius: 10px;
  --pad: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

/* --- Header / nav --- */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 10px var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
/* --- Branding / logo Mondial Bet --- */
.brand-link { text-decoration: none; flex-shrink: 0; }
.logo { display: inline-flex; align-items: center; gap: 9px; }
.logo-ball { color: var(--accent); flex-shrink: 0; }
.logo-name {
  font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em;
  color: var(--text); white-space: nowrap; line-height: 1;
}
.logo-name b { color: var(--accent); font-weight: 800; }

/* --- Icones inline (heritent de la couleur du texte) --- */
.ico { vertical-align: -2px; flex-shrink: 0; }
nav button, #user-box button { display: inline-flex; align-items: center; gap: 6px; }
.badge .ico, .pts-pill .ico, .role-admin .ico { vertical-align: -1px; }
.role-admin { display: inline-flex; align-items: center; gap: 5px; color: var(--amber); }
.role-admin .ico { color: var(--amber); }

nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}
nav button.active { background: var(--bg-elev); color: var(--text); }

#user-box { font-size: 0.85rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
#user-name { font-weight: 600; color: var(--text); }
#admin-btn { display: none; }
body.is-admin #admin-btn { display: inline-block; }

button.danger-btn { color: var(--danger); border-color: var(--danger); padding: 6px 10px; font-size: 0.8rem; }
button.danger-btn:hover { background: var(--danger); color: #fff; }

main { padding: var(--pad); max-width: 880px; margin: 0 auto; }
/* Le Tournoi exploite toute la largeur de la page (grille de poules + bracket). */
body.wide main { max-width: 1500px; }

/* --- Views --- */
.view { display: none; }
.view.active { display: block; }
h2 { font-size: 1.2rem; margin: 4px 0 16px; }
h3 { font-size: 1rem; margin: 24px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* --- Filtres (chips) --- */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.chip {
  background: var(--bg-elev);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
}
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* --- Groupage par jour --- */
.day-header {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: capitalize;
  margin: 18px 0 8px;
  padding-left: 4px;
  font-weight: 600;
}

/* --- Ligne de match (pronostic) --- */
.match-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.match-row .time {
  font-size: 0.8rem;
  color: var(--muted);
  width: 52px;
  flex-shrink: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.grp-tag {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--blue);
  background: rgba(59,130,246,.12);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}
.match-row .teams-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.team-line { display: flex; align-items: center; gap: 8px; }
.team-line .name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 600; font-size: 0.95rem;
}
.team-line.winner .name { color: var(--accent); }

.flag {
  width: 26px; height: 18px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08);
  background: var(--bg-elev);
}
.flag-tbd {
  display: inline-block;
  width: 26px; height: 18px;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #243049, #243049 4px, #2c3a55 4px, #2c3a55 8px);
}

/* --- Stepper de score (− [n] +) --- */
.stepper { display: flex; align-items: center; gap: 0; flex-shrink: 0; }
.stepper button {
  width: 30px; height: 34px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper button:active { background: var(--blue); }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper .val {
  width: 34px; height: 34px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.05rem;
}
.match-row .badge { flex-shrink: 0; }
.meta-col { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }

/* Match commencé = verrouillé : grisé, plus de saisie possible. */
.match-row.locked {
  opacity: 0.62;
  filter: grayscale(0.35);
}
/* Sauf le match en direct : on le met en avant (bordure rouge, score lisible). */
.match-row.is-live {
  opacity: 1;
  filter: none;
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(239,68,68,.35);
}
.match-row.is-live .badge.live { color: #fff; background: var(--danger); font-weight: 700; }
.badge.live { animation: livepulse 1.6s ease-in-out infinite; }
@keyframes livepulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* --- Badges statut --- */
.badge {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge.finished { color: var(--accent); }
.badge.live { color: var(--danger); }
.pts-pill {
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgba(245,158,11,.15); color: var(--amber); white-space: nowrap;
}
.saved-tick { color: var(--accent); font-size: .9rem; opacity: 0; transition: opacity .2s; }
.saved-tick.show { opacity: 1; }

/* --- Tables (classement, groupes) --- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; }
td.num, th.num { text-align: right; }
tr.me td { background: var(--bg-elev); }
.rank { color: var(--muted); width: 26px; }

/* --- Groupes (tournoi) --- */
.groups-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.group-card .gtitle {
  padding: 8px 12px; font-weight: 700; font-size: 0.85rem;
  background: var(--bg-elev); border-bottom: 1px solid var(--border);
}
.group-card table td, .group-card table th { padding: 7px 8px; }
.group-card .qual td { border-left: 3px solid var(--accent); }
.gteam { display: flex; align-items: center; gap: 8px; }

/* Pastilles de forme V/N/D */
.form-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px; margin-right: 3px;
  font-size: 0.68rem; font-weight: 700; color: #fff;
}
.form-dot.f-w { background: var(--accent); }
.form-dot.f-d { background: var(--muted); }
.form-dot.f-l { background: var(--danger); }
.muted-dash { color: var(--muted); }

/* Modale fiche équipe */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--pad); width: 100%; max-width: 380px;
}
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.modal-head .flag { width: 32px; height: 22px; }
.muted { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }

/* --- Bracket phases finales --- */
.bracket { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; }
.bracket .round { display: flex; flex-direction: column; gap: 12px; min-width: 180px; }
.bracket .round-title { font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.bracket .tie {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; font-size: .85rem;
}
.bracket .tie .t { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.bracket .tie .t .name { flex: 1; }

/* --- Login --- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--pad); margin-bottom: 12px;
}
#login-view .card { max-width: 360px; margin: 40px auto; }
.login-brand { display: flex; justify-content: center; margin-bottom: 10px; }
.login-brand .logo-ball { width: 40px; height: 40px; }
.login-brand .logo-name { font-size: 1.5rem; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; }
input[type="text"], input[type="password"] {
  width: 100%; padding: 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font-size: 1rem;
}
.row-actions { margin-top: 12px; display: flex; gap: 8px; }
button.primary {
  background: var(--accent); color: #fff; border: none;
  padding: 12px 16px; border-radius: 10px; font-weight: 700; font-size: 1rem; cursor: pointer; flex: 1;
}
button.primary:hover { background: var(--accent-hover); }
button.primary:disabled { opacity: 0.5; cursor: default; }
button.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
}
.error { color: var(--danger); font-size: 0.85rem; margin-top: 12px; min-height: 1em; }
.locked { color: var(--muted); font-size: 0.8rem; margin-top: 8px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* --- Saisie score admin (réutilise le stepper) --- */
.admin-match { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; }

/* --- Responsive --- */
@media (min-width: 768px) {
  header h1 { font-size: 1.3rem; }
  .groups-grid { grid-template-columns: 1fr 1fr; }
  .team-line .name { font-size: 1rem; }
}
@media (min-width: 1024px) {
  main { padding: 24px; }
  .groups-grid { grid-template-columns: 1fr 1fr 1fr; }
}
/* En mode pleine largeur (Tournoi), plus de colonnes pour remplir l'écran. */
@media (min-width: 1280px) {
  body.wide .groups-grid { grid-template-columns: repeat(4, 1fr); }
}
