/* =============================================
   TOURNOI LADDER v2 - Association Pongiste du Vuache
   ============================================= */

:root {
  --cat-poussin: #4ade80;
  --cat-benjamin: #60a5fa;
  --cat-cadet: #fb923c;
  --cat-junior: #a78bfa;
  --cat-senior: #3b82f6;
  --cat-veteran: #dc2626;
  
  --bg-dark: #0a0e27;
  --bg-card: #111936;
  --bg-card-hover: #1a2347;
  --accent: #ec8675;
  --accent-light: #ff9d8f;
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --success: #22c55e;
  --border-color: rgba(255,255,255,0.1);
}

* {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  background: var(--bg-dark);
  min-height: 100vh;
  overflow-x: hidden;
}

/* =============================================
   HERO SECTION
   ============================================= */

.tournoi-hero {
  background: linear-gradient(135deg, #081158 0%, #0a1a4a 50%, #0d2040 100%);
  padding: 100px 20px 40px;
  position: relative;
  overflow: hidden;
}

.tournoi-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 20% 80%, rgba(236, 134, 117, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.tournoi-hero-content {
  text-align: center;
  position: relative;
  z-index: 2;
}

.tournoi-title {
  font-family: 'Permanent Marker', cursive;
  font-size: clamp(2rem, 8vw, 3.5rem);
  color: var(--text-primary);
  margin: 0 0 10px;
  text-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.tournoi-subtitle {
  font-family: 'Red Hat Display', sans-serif;
  font-size: clamp(1rem, 4vw, 1.25rem);
  color: var(--text-secondary);
  margin: 0;
}

.hero-decoration {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ping-ball {
  position: absolute;
  width: 40px;
  height: 40px;
  background: radial-gradient(circle at 30% 30%, #fff 0%, #f97316 100%);
  border-radius: 50%;
  opacity: 0.6;
  animation: float 6s ease-in-out infinite;
}

.ping-ball.ball-2 { width: 25px; height: 25px; top: 30%; right: 10%; animation-delay: -2s; }
.ping-ball.ball-3 { width: 35px; height: 35px; bottom: 20%; left: 5%; animation-delay: -4s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(180deg); }
}

/* =============================================
   MAIN CONTENT
   ============================================= */

.tournoi-main {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: 100px;
}

/* =============================================
   CRÉNEAUX TABS
   ============================================= */

.creneaux-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.creneaux-tabs::-webkit-scrollbar {
  display: none;
}

.creneau-tab {
  flex-shrink: 0;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.creneau-tab:hover {
  background: var(--bg-card-hover);
}

.creneau-tab.active {
  border-color: var(--tab-color, var(--accent));
  background: color-mix(in srgb, var(--tab-color, var(--accent)) 15%, transparent);
}

.creneau-tab-nom {
  display: block;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.creneau-tab-horaire {
  display: block;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* =============================================
   CRÉNEAU INFO
   ============================================= */

.creneau-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.creneau-info-badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
}

.creneau-info-horaire {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* =============================================
   INSTRUCTIONS
   ============================================= */

.instructions-card {
  background: linear-gradient(135deg, rgba(236, 134, 117, 0.15) 0%, rgba(236, 134, 117, 0.05) 100%);
  border: 1px solid rgba(236, 134, 117, 0.3);
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.instructions-card.hidden { display: none; }

.instructions-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.instructions-header h3 {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
  font-weight: 600;
}

.instructions-icon { font-size: 1.2rem; }

.close-instructions {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.instructions-list {
  margin: 0;
  padding-left: 20px;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.instructions-list strong { color: var(--accent); }

/* =============================================
   MON PROFIL
   ============================================= */

.mon-profil-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 14px 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profil-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profil-icon { font-size: 1.3rem; }

#monProfilNom {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

.btn-changer-profil {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 8px;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-changer-profil:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text-primary);
}

/* =============================================
   ÉCHELLE DE CLASSEMENT
   ============================================= */

.echelle-container {
  background: var(--bg-card);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.echelle-header {
  display: grid;
  grid-template-columns: 50px 1fr 60px;
  padding: 14px 16px;
  background: rgba(0,0,0,0.3);
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.echelle-liste {
  padding: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.etiquette {
  display: grid;
  grid-template-columns: 50px 1fr 60px;
  align-items: center;
  padding: 14px 12px;
  margin: 6px 0;
  border-radius: 12px;
  background: var(--bg-card-hover);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  user-select: none;
  border: 2px solid transparent;
}

.etiquette::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  border-radius: 12px 0 0 12px;
}

.etiquette.cat-poussin::before { background: var(--cat-poussin); }
.etiquette.cat-benjamin::before { background: var(--cat-benjamin); }
.etiquette.cat-cadet::before { background: var(--cat-cadet); }
.etiquette.cat-junior::before { background: var(--cat-junior); }
.etiquette.cat-senior::before { background: var(--cat-senior); }
.etiquette.cat-veteran::before { background: var(--cat-veteran); }

.etiquette:hover {
  transform: translateX(4px);
  background: rgba(255,255,255,0.08);
}

.etiquette:active { transform: scale(0.98); }

.etiquette.selected {
  border-color: var(--accent);
  background: rgba(236, 134, 117, 0.1);
  box-shadow: 0 0 20px rgba(236, 134, 117, 0.2);
}

.etiquette.mon-etiquette {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.08);
}

.etiquette.mon-etiquette::after {
  content: '👤';
  position: absolute;
  right: -8px;
  top: -8px;
  font-size: 1rem;
  background: var(--bg-card);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.etiquette.defiable {
  border-color: rgba(251, 191, 36, 0.5);
  animation: pulse-defi 1.5s infinite;
}

@keyframes pulse-defi {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); }
}

.etiquette.non-defiable {
  opacity: 0.4;
  cursor: not-allowed;
}

.etiquette-rank {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.3rem;
  color: var(--text-secondary);
  text-align: center;
}

.etiquette:nth-child(1) .etiquette-rank { color: #ffd700; }
.etiquette:nth-child(2) .etiquette-rank { color: #c0c0c0; }
.etiquette:nth-child(3) .etiquette-rank { color: #cd7f32; }

.etiquette-nom {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 600;
  padding-left: 8px;
}

.etiquette-stats {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

.etiquette-stats .wins { color: var(--success); }
.etiquette-stats .losses { color: var(--cat-veteran); }

.echelle-vide {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-family: 'Red Hat Display', sans-serif;
}

/* =============================================
   BOUTONS D'ACTION
   ============================================= */

.actions-container {
  display: flex;
  gap: 12px;
}

.btn-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-historique {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-historique:hover { background: var(--bg-card-hover); }

.btn-admin {
  background: rgba(236, 134, 117, 0.15);
  color: var(--accent);
  border: 1px solid rgba(236, 134, 117, 0.3);
}

.btn-admin:hover { background: rgba(236, 134, 117, 0.25); }

.btn-icon { font-size: 1.1rem; }

/* =============================================
   MODALS
   ============================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 24px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  transform: translateY(20px);
  transition: transform 0.3s;
}

.modal-large { max-width: 500px; }

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 10;
}

.modal-header h3 {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 1.1rem;
  color: var(--text-primary);
  margin: 0;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body { padding: 20px; }

/* Modal Défi */
.defi-joueurs {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-bottom: 24px;
}

.defi-joueur { text-align: center; }

.defi-etiquette {
  padding: 12px 20px;
  border-radius: 10px;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  background: var(--bg-card-hover);
}

.challenger .defi-etiquette { background: var(--accent); }
.defender .defi-etiquette { background: var(--cat-senior); }

.defi-role {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.defi-vs {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.5rem;
  color: var(--text-secondary);
}

.defi-question {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 20px;
}

.defi-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.btn-gagnant {
  padding: 16px 20px;
  border: none;
  border-radius: 12px;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-challenger { background: var(--accent); color: white; }
.btn-challenger:hover { background: var(--accent-light); transform: scale(1.02); }

.btn-defender { background: var(--cat-senior); color: white; }
.btn-defender:hover { background: #2563eb; transform: scale(1.02); }

.btn-annuler {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-secondary);
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Modal Historique */
.historique-liste {
  max-height: 400px;
  overflow-y: auto;
}

.historique-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 8px;
}

.historique-date {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.7rem;
  color: var(--text-secondary);
  min-width: 80px;
}

.historique-match {
  flex: 1;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.historique-gagnant { color: var(--success); font-weight: 600; }
.historique-perdant { color: var(--text-secondary); }

.historique-vide {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-family: 'Red Hat Display', sans-serif;
}

/* Modal Admin */
.admin-section {
  margin-bottom: 24px;
}

.admin-section h4 {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin: 0 0 12px;
  font-weight: 600;
}

.admin-help {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 12px;
  line-height: 1.5;
}

.admin-help code {
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.csv-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.85rem;
  resize: vertical;
}

.csv-textarea::placeholder { color: var(--text-secondary); }

.import-options {
  margin: 12px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.btn-import {
  width: 100%;
  padding: 12px;
  background: var(--success);
  border: none;
  border-radius: 10px;
  color: white;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-import:hover { background: #16a34a; }

.admin-form {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
}

.admin-input {
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.9rem;
}

.admin-input::placeholder { color: var(--text-secondary); }

.admin-input-small {
  max-width: 60px;
  text-transform: uppercase;
  text-align: center;
}

.admin-select {
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-card-hover);
  color: var(--text-primary);
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.9rem;
  grid-column: span 3;
}

.btn-ajouter {
  grid-column: span 3;
  padding: 12px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-ajouter:hover { background: var(--accent-light); }

.admin-joueurs-liste {
  max-height: 200px;
  overflow-y: auto;
}

.admin-joueur-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  margin-bottom: 6px;
}

.admin-joueur-nom {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-joueur-rank {
  color: var(--text-secondary);
  font-size: 0.8rem;
  min-width: 30px;
}

.admin-joueur-cat {
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.admin-empty {
  text-align: center;
  color: var(--text-secondary);
  font-family: 'Red Hat Display', sans-serif;
  padding: 20px;
}

.btn-supprimer {
  background: rgba(220, 38, 38, 0.2);
  border: none;
  color: var(--cat-veteran);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-supprimer:hover { background: rgba(220, 38, 38, 0.4); }

.admin-danger {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.btn-reset {
  width: 100%;
  padding: 12px;
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 10px;
  color: var(--cat-veteran);
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 8px;
}

.btn-reset:hover { background: rgba(220, 38, 38, 0.25); }

.btn-reset-all {
  background: rgba(220, 38, 38, 0.3);
}

/* Modal profil */
.profil-liste {
  max-height: 350px;
  overflow-y: auto;
}

.profil-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.profil-option:hover { background: rgba(255,255,255,0.05); }

.profil-option.selected {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.profil-option-rank {
  font-family: 'Permanent Marker', cursive;
  font-size: 1rem;
  color: var(--text-secondary);
  min-width: 30px;
}

.profil-option-nom {
  font-family: 'Red Hat Display', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* =============================================
   NOTIFICATIONS
   ============================================= */

.notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 20px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2000;
  animation: slideUp 0.3s ease-out;
  max-width: 90%;
  font-family: 'Red Hat Display', sans-serif;
  font-size: 0.9rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.notification.success { background: var(--success); color: white; }
.notification.error { background: var(--cat-veteran); color: white; }

.notification button {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
}

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(100%); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* =============================================
   LOADING
   ============================================= */

.is-loading .echelle-liste {
  opacity: 0.5;
  pointer-events: none;
}

.loading-small {
  text-align: center;
  padding: 30px;
  color: var(--text-secondary);
  font-family: 'Red Hat Display', sans-serif;
}

#loader {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 39, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 480px) {
  .tournoi-main { padding: 16px; }
  .etiquette { padding: 12px 10px; }
  .etiquette-nom { font-size: 0.9rem; }
  .admin-form { grid-template-columns: 1fr 1fr; }
  .admin-input:first-child { grid-column: span 2; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
