/*
 * Système graphique repris de l'application de référence (structure, grille
 * de boutons, navigation mobile) mais aux couleurs du club : fond crème,
 * titres en Fraunces, texte en Inter, accents rouge "sang" (primaire) et or
 * (secondaire), cartes arrondies à ombre douce, boutons/puces en pilule.
 * Toutes les règles de composants (hauteur mini des boutons, largeur du
 * menu mobile, ombres) sont identiques à la référence : c'est cette
 * structure qui garantit des boutons alignés et un menu mobile sans
 * scrollbar, quelle que soit la page.
 */
:root {
  --cream-50: #fdfbf7;
  --cream-100: #faf5ec;
  --cream-200: #f3e9d7;

  --red-50: #fdf1f1;
  --red-100: #fbdcdd;
  --red-200: #f3b4b8;
  --red-300: #e8838a;
  --red-400: #d94f5a;
  --red-500: #c8102e;
  --red-600: #a80e29;
  --red-700: #8f0a22;

  --gold-50: #faf6e7;
  --gold-100: #f2e6bf;
  --gold-200: #e3cb85;
  --gold-500: #8a6a11;
  --gold-600: #6e5410;
  --gold-700: #54400c;
  --gold-bright: #d4a017;

  --charcoal-50: #f5f4f2;
  --charcoal-100: #e6e3de;
  --charcoal-300: #a8a099;
  --charcoal-500: #6b6259;
  --charcoal-700: #453f39;
  --charcoal-900: #2a2521;

  --shadow-soft: 0 1px 2px rgba(42, 37, 33, .04), 0 6px 16px -4px rgba(42, 37, 33, .08);
  --shadow-soft-hover: 0 2px 4px rgba(42, 37, 33, .06), 0 12px 24px -6px rgba(42, 37, 33, .14);
  --radius-xl2: 1.25rem;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background: var(--cream-50);
  color: var(--charcoal-900);
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-family: 'Fraunces', ui-serif, Georgia, serif;
  color: var(--charcoal-900);
  font-weight: 600;
  letter-spacing: .1px;
}
h1 { font-size: 1.7rem; margin: 0 0 .3rem; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 .8rem; }

/* --- En-tête / navigation (crème translucide, pilule rouge active) --- */
header.topbar {
  background: rgba(253, 251, 247, .9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--charcoal-900);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(42, 37, 33, .05);
}
header.topbar a { color: var(--charcoal-900); text-decoration: none; }
.brand {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: .1px;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.brand .pastille {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--red-500); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .95rem; font-family: 'Fraunces', serif;
  box-shadow: inset 0 0 0 2px var(--gold-bright);
}
.brand img.blason { width: 32px; height: 32px; object-fit: contain; }
header.topbar nav { display: flex; align-items: center; gap: .2rem; }
header.topbar nav a {
  padding: .5rem .95rem; border-radius: 999px; font-size: .88rem; font-weight: 500;
  color: var(--charcoal-700); transition: background .15s ease, color .15s ease;
}
header.topbar nav a:hover { background: var(--cream-100); }
header.topbar nav a.actif { background: var(--red-500); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: .7rem; font-size: .85rem; color: var(--charcoal-700); }

.menu-toggle {
  display: none; background: transparent; border: none; color: var(--charcoal-700);
  cursor: pointer; padding: .4rem; line-height: 1; border-radius: 999px;
}
.menu-toggle:hover { background: var(--cream-100); }
.menu-toggle .icone { width: 24px; height: 24px; }

main.container { max-width: 1150px; margin: 1.5rem auto; padding: 0 1.2rem 3rem; }
main.container.etroit { max-width: 720px; }

/* --- Icônes trait (feather-style) --- */
.icone { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; }

/* --- Cartes --- */
.card {
  background: #fff;
  border-radius: var(--radius-xl2);
  padding: 1.3rem 1.4rem;
  margin-bottom: 1.3rem;
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgba(42, 37, 33, .05);
}
.card-hover { transition: transform .2s ease, box-shadow .2s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft-hover); }

/* --- Tableaux --- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem .7rem; border-bottom: 1px solid var(--charcoal-100); text-align: left; font-size: .9rem; }
th { background: var(--cream-100); color: var(--charcoal-700); font-weight: 700; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:nth-child(even) td { background: var(--cream-50); }
tr:hover td { background: var(--red-50); }

table.sortable th[data-sort] { cursor: pointer; user-select: none; position: relative; padding-right: 1.4rem; }
table.sortable th[data-sort]:hover { background: var(--cream-200); }
table.sortable th[data-sort]::after { content: "\21C5"; position: absolute; right: .55rem; opacity: .4; font-size: .75rem; }
table.sortable th[data-sort].tri-asc::after { content: "\25B2"; opacity: .9; }
table.sortable th[data-sort].tri-desc::after { content: "\25BC"; opacity: .9; }

/* --- Boutons (pilules) --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border-radius: 999px; padding: .55rem 1.2rem;
  font-size: .87rem; font-weight: 500; font-family: inherit;
  border: none; cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
  min-height: 40px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* .btn seul = primaire (rouge plein) */
.btn { background: var(--red-500); color: #fff; box-shadow: var(--shadow-soft); }
.btn:hover:not(:disabled) { background: var(--red-600); }
.btn.or {
  background: var(--gold-bright); color: var(--charcoal-900);
}
.btn.or:hover:not(:disabled) { background: var(--gold-500); color: #fff; }
.btn.secondaire {
  background: #fff; color: var(--charcoal-700);
  box-shadow: inset 0 0 0 1px var(--charcoal-100);
}
.btn.secondaire:hover:not(:disabled) { background: var(--cream-100); }
.btn.danger {
  background: #fff; color: var(--red-600);
  box-shadow: inset 0 0 0 1px var(--red-200);
}
.btn.danger:hover:not(:disabled) { background: var(--red-50); }
.btn.petit { padding: .35rem .85rem; font-size: .78rem; min-height: 32px; }
.actions-ligne { display: flex; gap: .4rem; flex-wrap: wrap; }

/* --- Puces de filtre (chips) --- */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px;
  padding: .3rem .8rem; font-size: .85rem; font-weight: 500; cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.chip-off { background: #fff; color: var(--charcoal-700); box-shadow: inset 0 0 0 1px var(--charcoal-100); }
.chip-off:hover { background: var(--cream-100); }
.chip-on { background: var(--gold-500); color: #fff; }

/* --- Formulaires --- */
label { display: block; margin: .8rem 0 .35rem; font-weight: 500; font-size: .85rem; color: var(--charcoal-700); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; padding: .6rem .8rem; border: none; border-radius: .8rem;
  font-size: .95rem; background: #fff; color: var(--charcoal-900); font-family: inherit;
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--charcoal-100);
}
input::placeholder, textarea::placeholder { color: var(--charcoal-300); }
input:focus, select:focus, textarea:focus {
  outline: none; box-shadow: var(--shadow-soft), inset 0 0 0 2px var(--red-400);
}
fieldset { border: none; padding: 0; margin: 0; }
.champ-inline { display: flex; gap: .6rem; flex-wrap: wrap; }
.champ-inline > div { flex: 1; min-width: 140px; }

.flash { padding: .8rem 1.1rem; border-radius: 1rem; margin-bottom: 1rem; font-size: .9rem; font-weight: 500; }
.flash.success { background: var(--gold-50); color: var(--gold-700); box-shadow: inset 0 0 0 1px var(--gold-200); }
.flash.error { background: var(--red-50); color: var(--red-700); box-shadow: inset 0 0 0 1px var(--red-200); }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .65rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--gold-50); color: var(--gold-700); box-shadow: inset 0 0 0 1px var(--gold-200); }
.badge.repos { background: var(--red-50); color: var(--red-700); box-shadow: inset 0 0 0 1px var(--red-200); }
.badge.neutre { background: var(--charcoal-50); color: var(--charcoal-700); box-shadow: inset 0 0 0 1px var(--charcoal-100); }

.toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: 1.1rem; flex-wrap: wrap; }
form.inline { display: inline; }
small.muted { color: var(--charcoal-500); }
.recherche { margin-bottom: .8rem; max-width: 320px; }
.recherche input[type=text] { margin: 0; }

/* --- Icônes circulaires (cartes KPI, écrans publics) --- */
.icone-cercle {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--gold-50); color: var(--gold-700);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icone-cercle .icone { width: 22px; height: 22px; }
.icone-cercle.rouge { background: var(--red-50); color: var(--red-600); }

/* --- Grille de cartes KPI --- */
.kpi-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.3rem; }
.kpi-carte {
  background: #fff; border-radius: var(--radius-xl2);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: .8rem;
}
.kpi-carte .valeur { font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.5rem; color: var(--charcoal-900); line-height: 1.1; }
.kpi-carte .label { font-size: .78rem; color: var(--charcoal-500); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

/* ================= SPÉCIFIQUE TOURNOIS ================= */

/* --- Classement de poule --- */
.classement td.numero, .classement th.numero { text-align: center; width: 2.4rem; }
.classement .rang-qualifie { box-shadow: inset 3px 0 0 var(--gold-bright); }

/* --- Podium (page publique) --- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: .8rem; margin: 1.5rem 0 2rem; }
.podium-marche { flex: 1; max-width: 180px; border-radius: 1rem 1rem 0 0; text-align: center; padding: 1rem .6rem .8rem; box-shadow: var(--shadow-soft); }
.podium-marche .rang { font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.6rem; }
.podium-marche .nom { font-weight: 600; margin-top: .3rem; font-size: .95rem; word-break: break-word; }
.podium-1 { background: linear-gradient(180deg, var(--gold-bright), var(--gold-500)); color: #fff; height: 148px; order: 2; }
.podium-2 { background: linear-gradient(180deg, var(--charcoal-300), var(--charcoal-500)); color: #fff; height: 118px; order: 1; }
.podium-3 { background: linear-gradient(180deg, #d99a6c, #a8663a); color: #fff; height: 96px; order: 3; }
.classement-liste { display: flex; flex-direction: column; gap: .5rem; }
.classement-ligne { display: flex; align-items: center; gap: .8rem; background: #fff; border-radius: 1rem; padding: .6rem .9rem; box-shadow: var(--shadow-soft); }
.classement-ligne .rang-badge { width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--cream-100); color: var(--charcoal-700); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.classement-ligne .equipes { flex: 1; font-weight: 500; }

/* --- Tableau à élimination directe (bracket) --- */
.bracket-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: .5rem; }
.bracket { display: flex; gap: 2.2rem; align-items: stretch; min-width: max-content; padding: .5rem; }
.bracket-tour { display: flex; flex-direction: column; justify-content: space-around; gap: 1.2rem; min-width: 220px; }
.bracket-tour-titre { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--charcoal-500); text-align: center; margin-bottom: .3rem; }
.bracket-match { background: #fff; border-radius: .9rem; box-shadow: var(--shadow-soft); overflow: hidden; }
.bracket-equipe { display: flex; justify-content: space-between; align-items: center; padding: .5rem .7rem; font-size: .85rem; gap: .5rem; }
.bracket-equipe:first-child { border-bottom: 1px solid var(--charcoal-100); }
.bracket-equipe.vainqueur { font-weight: 700; background: var(--gold-50); }
.bracket-equipe .nom-equipe { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bracket-equipe .score { font-weight: 700; font-family: 'Fraunces', serif; min-width: 1.3rem; text-align: right; }

/* --- Buvette --- */
.buvette-categorie { margin-bottom: 1.6rem; }
.buvette-categorie h2 { display: flex; align-items: center; gap: .5rem; }
.buvette-liste { display: flex; flex-direction: column; gap: .5rem; }
.buvette-article { display: flex; justify-content: space-between; align-items: center; background: #fff; border-radius: 1rem; padding: .8rem 1rem; box-shadow: var(--shadow-soft); gap: 1rem; }
.buvette-article .nom { font-weight: 600; }
.buvette-article .description { font-size: .82rem; color: var(--charcoal-500); margin-top: .1rem; }
.buvette-article .prix { font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.15rem; color: var(--red-600); white-space: nowrap; }

/* --- Affiche / poster QR --- */
.affiche { background: #fff; border-radius: var(--radius-xl2); box-shadow: var(--shadow-soft); padding: 2.5rem; text-align: center; max-width: 520px; margin: 0 auto; }
.affiche h1 { font-size: 2rem; }
.affiche .qr-cadre { display: inline-block; padding: 1rem; background: #fff; border-radius: 1rem; box-shadow: inset 0 0 0 1px var(--charcoal-100); margin: 1.2rem 0; }
.affiche .qr-cadre svg { display: block; width: 220px; height: 220px; }
.affiche .lien { font-size: .85rem; color: var(--charcoal-500); word-break: break-all; }

/* --- Page d'accueil publique / setup --- */
.hero-public { text-align: center; padding: 2rem 0 1rem; }
.hero-public .pastille { width: 72px; height: 72px; font-size: 1.9rem; margin: 0 auto 1rem; }

/* ================= RESPONSIVE ================= */
@media (max-width: 880px) {
  header.topbar { flex-wrap: wrap; height: auto; padding: .7rem 1rem; row-gap: .5rem; }
  .menu-toggle { display: inline-flex; }
  header.topbar nav {
    display: none; width: 100%; flex-direction: column; align-items: stretch;
    order: 3; padding-top: .4rem; border-top: 1px solid var(--charcoal-100);
  }
  header.topbar nav.ouvert { display: flex; }
  header.topbar nav a { padding: .7rem .9rem; border-radius: .8rem; }
  .topbar-user { order: 2; margin-left: auto; }
  main.container { margin: 1.1rem auto; padding: 0 .8rem 3rem; }
  h1 { font-size: 1.4rem; }
  .card { padding: 1rem; border-radius: 1rem; }
  th, td { padding: .5rem .5rem; font-size: .84rem; }
  .btn { padding: .6rem 1rem; }
  .kpi-grille { grid-template-columns: repeat(2, 1fr); }
  .podium { gap: .5rem; }
  .podium-marche { padding: .7rem .4rem .6rem; }
}

@media (max-width: 520px) {
  .kpi-grille { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .kpi-carte { padding: .8rem .9rem; }
  .toolbar { gap: .4rem; }
  .btn.petit { flex: 1; }
  .actions-ligne { width: 100%; }
  .affiche { padding: 1.5rem 1.1rem; }
  .affiche .qr-cadre svg { width: 170px; height: 170px; }
}

/* Tables larges : défilement horizontal tactile sur petit écran */
@media (max-width: 700px) {
  .table-scroll table { min-width: 560px; }
}

/* Impression de l'affiche : masque la navigation et les marges, n'imprime que la carte */
@media print {
  header.topbar, .no-print { display: none !important; }
  main.container { margin: 0; padding: 0; max-width: none; }
  .affiche { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}
