/* ─── Variables & Reset ──────────────────────────────────────────────────── */
:root {
  --gold:    #F4C430;
  --silver:  #A8A9AD;
  --bronze:  #CD7F32;
  --primary: #7253a0;
  --primary-light: #9a77c2;
  --accent:  #e06899;
  --p1: #cdb4db;
  --p2: #ffc8dd;
  --p3: #ffafcc;
  --p4: #bde0fe;
  --p5: #a2d2ff;
  --bg:         #faf5ff;
  --bg2:        #f0e8ff;
  --card:       #ffffff;
  --text:       #2d1a4a;
  --text-muted: #8a6a9a;
  --border:     #e8d5f5;
  --radius:     12px;
  --shadow:     0 4px 20px rgba(114,83,160,0.10);
  --transition: 0.2s ease;
  --input-bg:   #ffffff;
}

/* ─── Thème sombre ───────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --primary:       #a882d4;
  --primary-light: #c4a0e8;
  --bg:            #0e0a1a;
  --bg2:           #160f28;
  --card:          #1c1430;
  --text:          #ede0ff;
  --text-muted:    #9478b8;
  --border:        #2e2045;
  --shadow:        0 4px 20px rgba(0,0,0,0.4);
  --input-bg:      #251840;
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .card { background: var(--card); border-color: var(--border); }
[data-theme="dark"] .form-control,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--input-bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
[data-theme="dark"] .modal { background: var(--card); color: var(--text); }
[data-theme="dark"] .modal-header { border-color: var(--border); }
[data-theme="dark"] .modal-footer { border-color: var(--border); }
[data-theme="dark"] .list-item { background: var(--card); border-color: var(--border); }
[data-theme="dark"] .table-wrap { background: var(--card); border-color: var(--border); }
[data-theme="dark"] table th { background: var(--bg2); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] table td { border-color: var(--border); }
[data-theme="dark"] table tr:hover td { background: var(--bg2); }
[data-theme="dark"] .badge { background: var(--bg2); color: var(--text-muted); }
[data-theme="dark"] .tab-btn { color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .btn { background: var(--bg2); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .btn:hover { background: var(--border); }
[data-theme="dark"] .btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .section-title { color: var(--text); }
[data-theme="dark"] footer { background: var(--bg2); border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .stats-bar { background: var(--card); border-color: var(--border); }
[data-theme="dark"] .stat-card { border-color: var(--border); }
[data-theme="dark"] .hero-bg-plain { background: var(--bg2); }
[data-theme="dark"] .empty-state { color: var(--text-muted); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ─── Nav ────────────────────────────────────────────────────────────────── */
nav {
  background: var(--primary);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.nav-logo {
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.nav-logo span { color: var(--p2); }

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}
.nav-links a {
  color: rgba(255,255,255,0.85);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.nav-admin-btn {
  background: var(--p2);
  color: var(--primary) !important;
  font-weight: 600 !important;
  padding: 0.5rem 1.1rem !important;
}
.nav-admin-btn:hover { background: var(--p3) !important; color: var(--primary) !important; }

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #5c3478 0%, var(--primary) 40%, #5a8fd6 100%);
  color: #fff;
  padding: 4rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='30' cy='30' r='28' fill='none' stroke='rgba(255,255,255,0.05)' stroke-width='2'/%3E%3C/svg%3E") repeat;
  background-size: 80px 80px;
}
.hero-content { position: relative; max-width: 700px; margin: 0 auto; }
.hero h1 { font-size: 2.8rem; font-weight: 800; margin-bottom: 0.5rem; }
.hero h1 span { color: var(--p2); }
.hero-meta { margin: 1rem 0; opacity: 0.85; font-size: 1.05rem; display: flex; justify-content: center; gap: 2rem; flex-wrap: wrap; }
.hero-meta span { display: flex; align-items: center; gap: 0.4rem; }
.hero p { font-size: 1.1rem; opacity: 0.9; max-width: 500px; margin: 0 auto 1.5rem; }

/* ─── Rings décoratifs ───────────────────────────────────────────────────── */
.rings {
  display: flex;
  justify-content: center;
  gap: -10px;
  margin: 0.4rem 0;
}
.ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 5px solid;
  margin: 0 -4px;
}
.ring:nth-child(1) { border-color: #4FC3F7; }
.ring:nth-child(2) { border-color: #F4C430; margin-top: 20px; }
.ring:nth-child(3) { border-color: #ffafcc; }
.ring:nth-child(4) { border-color: #4CAF50; margin-top: 20px; }
.ring:nth-child(5) { border-color: #FF7043; }

/* ─── Main / Container ───────────────────────────────────────────────────── */
main { flex: 1; max-width: 1100px; margin: 0 auto; width: 100%; padding: 2rem 1.5rem; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.card-title { font-size: 1.1rem; font-weight: 700; }
.card-subtitle { font-size: 0.85rem; color: var(--text-muted); }

/* ─── Section title ──────────────────────────────────────────────────────── */
.section-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.25rem;
}
.section-desc {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ─── Badges & Tags ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-or     { background: #FFF8DC; color: #B8860B; }
.badge-argent { background: #F0F0F0; color: #666; }
.badge-bronze { background: #FFF0E6; color: #8B4513; }
.badge-primary{ background: #edd5f5; color: var(--primary); }
.badge-success{ background: #E8F5E9; color: #2E7D32; }
.badge-warning{ background: #FFF3E0; color: #E65100; }

/* ─── Tableau ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--card); }
thead { background: var(--primary); color: #fff; }
thead th { padding: 0.85rem 1rem; text-align: left; font-size: 0.9rem; font-weight: 600; }
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #faf0ff; }
tbody td { padding: 0.85rem 1rem; font-size: 0.95rem; }

.rank-1 td:first-child { color: var(--gold); font-weight: 800; font-size: 1.1rem; }
.rank-2 td:first-child { color: var(--silver); font-weight: 800; }
.rank-3 td:first-child { color: var(--bronze); font-weight: 800; }

.medal-cell { display: flex; gap: 0.5rem; align-items: center; }
.medal { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; }
.medal-or     { background: var(--gold); color: #5a3e00; }
.medal-argent { background: var(--silver); color: #333; }
.medal-bronze { background: var(--bronze); color: #fff; }

/* ─── Boutons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); color: #fff; text-decoration: none; }
.btn-gold    { background: var(--p2); color: var(--primary); }
.btn-gold:hover { background: var(--p3); color: var(--primary); }
.btn-danger  { background: #ffebee; color: #c62828; }
.btn-danger:hover { background: #ffcdd2; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.82rem; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }

/* ─── Formulaires ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.4rem; font-size: 0.9rem; color: var(--text); }
.form-control {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color var(--transition);
  background: #fff;
  color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(114,83,160,0.15); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(-10px); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-title { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: #333;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
}
.toast.success { background: #2E7D32; }
.toast.error   { background: #c62828; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }

/* ─── Stats bar (accueil) ────────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-number { font-size: 2.5rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label  { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.3rem; }

/* ─── Couleur équipe ─────────────────────────────────────────────────────── */
.team-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
  border: 1px solid rgba(0,0,0,0.1);
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state p { font-size: 1rem; }

/* ─── Footer ─────────────────────────────────────────────────────────────── */
footer {
  background: var(--primary);
  color: rgba(255,255,255,0.7);
  text-align: center;
  padding: 1.25rem;
  font-size: 0.85rem;
  margin-top: auto;
}
footer strong { color: var(--p2); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
/* ─── Theme toggle ───────────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,0.12); }

/* ─── Hamburger button ───────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.nav-hamburger:hover { background: rgba(255,255,255,0.12); }
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
  transform-origin: center;
}
/* Croix quand ouvert */
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 700px) {
  .form-row { grid-template-columns: 1fr; }
  nav { padding: 0 1rem; }
  main { padding: 1.25rem 1rem; }

  /* Masquer les liens, afficher le hamburger */
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0; right: 0;
    background: var(--primary);
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 0 0.75rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a {
    display: block;
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
  }
  .nav-links a:last-child { border-bottom: none; }
  .nav-hamburger { display: flex; }
}
