/* ==== RESET & BASE ==== */
html, body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  background-color: #f9f9f9;
  overflow-x: hidden;
}
.visually-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ==== HEADER ==== */
.header {
  background-color: #001f3f;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  height: 70px;
  z-index: 100;
}
.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
}
.header-center {
  font-size: 24px;
  font-weight: bold;
  flex-grow: 1;
  justify-content: center;
  user-select: none;
}
.logo {
  height: 50px;
}

/* ==== BURGER MENU ==== */
.menu-burger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 30px;
  height: 24px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.menu-burger span {
  height: 3px;
  width: 100%;
  background: white;
  margin: 3px 0;
  border-radius: 2px;
  transition: all 0.3s ease;
}
#menu-content {
  position: absolute;
  top: 70px;
  left: 0;
  width: 20%;
  background: white;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 99;
}
#menu-content.show {
  opacity: 1;
  pointer-events: auto;
}
#menu-content a {
  display: block;
  padding: 10px;
  color: #333;
  text-decoration: none;
}
#menu-content a:hover {
  background-color: #f1f1f1;
}

/* ==== BUTTONS ==== */
button, .modal-button, .btn-exit {
  padding: 12px 24px;
  font-size: 18px;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  transition: background-color 0.3s;
}
button, .modal-button {
  background-color: #001f3f;
  color: white;
}
.modal-button:hover {
  background-color: #004d9b;
}
.btn-exit {
  margin-top: 2rem;
  background-color: #ccc;
  color: #333;
  font-weight: bold;
}

/* ==== TEXT ==== */
h1 {
  color: #333;
  text-align: center;
  margin-top: 40px;
}
.modal-h2 {
  font-size: 24px;
  margin-bottom: 20px;
}

/* ==== AUTH MODAL ==== */
#authModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#authModal.show {
  display: flex;
}
.modal-content {
  background: white;
  padding: 30px 40px;
  border-radius: 10px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}
.modal-idbox {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
}
.modal-smalltxt {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 20px;
}
.modal-button-container {
  display: block;
  gap: 10px;
}
.modal-cross {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 26px;
  font-weight: bold;
  color: #333;
  cursor: pointer;
  background: none;
  border: none;
}

/* ==== CUSTOM ALERT ==== */
#customAlert {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
#customAlert.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}
.alert-content {
  background: white;
  padding: 25px 40px;
  border-radius: 10px;
  font-size: 18px;
  text-align: center;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==== QUIZ UI ==== */
.selection-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 30px auto;
  max-width: 800px;
}
.selection-grid button {
  min-width: 140px;
  padding: 12px 16px;
  font-size: 16px;
}
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2rem;
}
.choice-btn {
  font-size: 1.2rem;
  padding: 1rem;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  border: none;
  transition: 0.3s;
}
.color-0 { background-color: #004700; }
.color-1 { background-color: #4e0000; }
.color-2 { background-color: #5a005a; }
.color-3 { background-color: #794200; }
.color-4 { background-color: #7a0041; }
.color-5 { background-color: #803058; }

/* ==== GAME OVERLAY ==== */
.game-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.game-overlay.show {
  display: flex;
}
.game-popup {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  text-align: center;
}
.countdown-number {
  font-size: 80px;
  font-weight: bold;
  color: #001f3f;
  animation: pop 0.4s ease;
}

@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==== CHOICE BUTTON STATE ==== */
.choice-btn.correct {
  background-color: #00ff3c !important;
  animation: flash 0.3s ease;
}
.choice-btn.incorrect {
  background-color: #ff1900 !important;
  animation: flash 0.3s ease;
}
@keyframes flash {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
#countdown, #timerboom {
  font-size: 3rem;
  text-align: center;
  font-weight: bold;
  color: #001f3f;
  margin: 1rem 0;
  animation: zoom 0.5s ease;
}
#chrono-indicator {
  display: block;
  font-size: 3rem;
  color: #001f3f;
  text-align: center;
  margin-top: 1rem;
  animation: zoom 0.5s ease;
}

.timer-bar-container {
  width: 100%;
  height: 10px;
  background-color: #ddd;
  border-radius: 5px;
  overflow: hidden;
  margin: 1rem 0;
}

.timer-bar {
  height: 100%;
  background-color: #4caf50;
  width: 100%;
  transition: width linear;
}

.timer-bar.urgent {
  background-color: #ff1900 ;
  animation: pulse-red 1s infinite;
}
@keyframes pulse-red {
  0%   { background-color: #ff1900; }
  50%  { background-color: #ff4d4d; }
  100% { background-color: #ff1900; }
}
#victoryAnimation {
  font-size: 60px;
  text-align: center;
  margin-top: 20px;
}
canvas#fireworks {
  display: block;
  margin: 0 auto;
}


/* ==== JOIN PAGE CENTRAGE ==== */
.join-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  gap: 30px;
  padding: 40px 20px;
  min-height: calc(100vh - 70px); /* header height */
}

.join-centered > div,
.join-centered > a {
  width: 100%;
  max-width: 500px;
}

#qrcodeArea canvas {
  display: block;
  margin: 0 auto;
}

#joinArea input {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
}

#waitingRoom,
#gameArea,
#results {
  display: none;
}

#gameOptions {
  margin-top: 1rem;
}

#waitingText.waiting-dots::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ''; }
  33% { content: '.'; }
  66% { content: '..'; }
  100% { content: '...'; }
}

#qrcodeArea {
  margin-top: 1rem;
  text-align: center;
}

/* À ajouter au début de style.css */

/* ============================================
   VARIABLES DE THÈME
   ============================================ */

:root {
  /* Thème Clair (défaut) */
  --bg-primary: #f9f9f9;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f5f5f5;
  
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  
  --accent-primary: #001f3f;
  --accent-hover: #004d9b;
  --accent-danger: #c40000;
  --accent-success: #4CAF50;
  
  --border-color: #cccccc;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-strong: rgba(0, 0, 0, 0.3);
  
  /* Quiz colors - restent identiques */
  --quiz-color-0: #004700;
  --quiz-color-1: #4e0000;
  --quiz-color-2: #5a005a;
  --quiz-color-3: #794200;
  --quiz-color-4: #7a0041;
  --quiz-color-5: #803058;
}

[data-theme="dark"] {
  /* Thème Sombre */
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #2a2a2a;
  
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  
  --accent-primary: #3a5f8f;
  --accent-hover: #4a7fb8;
  --accent-danger: #ff4444;
  --accent-success: #66bb6a;
  
  --border-color: #404040;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-strong: rgba(0, 0, 0, 0.6);
  
  /* Quiz colors - versions sombres légèrement éclaircies */
  --quiz-color-0: #2d5f2d;
  --quiz-color-1: #7a3030;
  --quiz-color-2: #7a3a7a;
  --quiz-color-3: #9a6630;
  --quiz-color-4: #9a3060;
  --quiz-color-5: #a04070;
}

/* ============================================
   BOUTON DE TOGGLE THÈME
   ============================================ */

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  padding: 0.5rem;
  margin-right: 1rem;
  transition: transform 0.3s ease;
  color: white;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* ============================================
   APPLICATION DES VARIABLES
   ============================================ */

html, body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
.header {
  background-color: var(--accent-primary);
}

/* Conteneurs */
.container,
.game-popup,
.modal-content,
main {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Textes */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
}

p, span, div {
  color: var(--text-primary);
}

/* Inputs */
input, select, textarea {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Boutons */
button, .modal-button {
  background-color: var(--accent-primary);
  color: white;
}

button:hover, .modal-button:hover {
  background-color: var(--accent-hover);
}

.btn-exit {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-exit:hover {
  background-color: var(--border-color);
}

/* Boutons dangereux */
button.delete,
button.danger,
.controlmodal-cancel {
  background-color: var(--accent-danger);
}

button.delete:hover,
button.danger:hover {
  background-color: #990000;
}

/* Couleurs quiz */
.color-0 { background-color: var(--quiz-color-0); }
.color-1 { background-color: var(--quiz-color-1); }
.color-2 { background-color: var(--quiz-color-2); }
.color-3 { background-color: var(--quiz-color-3); }
.color-4 { background-color: var(--quiz-color-4); }
.color-5 { background-color: var(--quiz-color-5); }

/* Menu */
#menu-content {
  background: var(--bg-secondary);
  box-shadow: 0 4px 6px var(--shadow);
}

#menu-content a {
  color: var(--text-primary);
}

#menu-content a:hover {
  background-color: var(--bg-tertiary);
}

/* Tables */
#usersTable {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

#usersTable th {
  background: var(--accent-primary);
  color: white;
}

#usersTable td {
  border-color: var(--border-color);
}

/* Cards */
.stat-card,
.questionBlock {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

/* Overlays et modals */
.game-overlay,
#authModal {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .game-overlay,
[data-theme="dark"] #authModal {
  background: rgba(0, 0, 0, 0.85);
}

/* Alerts */
#customAlert {
  background: var(--accent-success);
  color: white;
}

/* Timer bar */
.timer-bar {
  background-color: var(--accent-success);
}

/* Countdown */
.countdown-number,
#countdown,
#timerboom,
#chrono-indicator {
  color: var(--accent-primary);
}

/* Shadows */
.container,
.game-popup,
.modal-content,
main,
.stat-card {
  box-shadow: 0 4px 12px var(--shadow);
}

/* Transitions douces pour tous les éléments */
* {
  transition: background-color 0.3s ease, 
              color 0.3s ease, 
              border-color 0.3s ease;
}