/* Variables CSS pour les thèmes */
:root {
  /* Mode clair */
  --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --bg-secondary: white;
  --text-primary: #333;
  --text-secondary: #7f8c8d;
  --text-white: white;
  --border-color: #ddd;
  --input-bg: #f8f9fa;
  --shadow: 0 8px 25px rgba(0,0,0,0.15);
  --button-bg: rgba(255, 255, 255, 0.9);
  --score-color: #2c3e50;
  --header-bg: #4a90e2;
  --add-btn-bg: #27ae60;
  --undo-btn-bg: #e74c3c;
  --highlight-bg: #d4edda;
}

[data-theme="dark"] {
  /* Mode sombre */
  --bg-primary: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --bg-secondary: #2d3748;
  --text-primary: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-white: #e2e8f0;
  --border-color: #4a5568;
  --input-bg: #4a5568;
  --shadow: 0 8px 25px rgba(0,0,0,0.4);
  --button-bg: rgba(45, 55, 72, 0.9);
  --score-color: #f7fafc;
  --header-bg: #2c5282;
  --add-btn-bg: #38a169;
  --undo-btn-bg: #e53e3e;
  --highlight-bg: #2f855a;
}

/* Reset et base */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-size: 16px;
  transition: background 0.3s ease;
}

.container {
  max-width: 100%;
  padding: 10px;
  margin: 0 auto;
}

/* Header */
h1 {
  color: var(--text-white);
  text-align: center;
  margin: 10px 0 20px 0;
  font-size: 1.8rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Sélecteur de mode de victoire */
.victory-mode-selector {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.victory-mode-selector label {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9rem;
}

.victory-mode-selector select {
  background: var(--input-bg);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.victory-mode-selector select:focus {
  outline: none;
  border-color: var(--header-bg);
  background: var(--bg-secondary);
}

/* Bouton thème */
.theme-toggle {
  position: fixed;
  top: 15px;
  right: 15px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: var(--button-bg);
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  z-index: 1000;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* Boutons d'action principaux */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.action-buttons button {
  background: var(--button-bg);
  border: none;
  border-radius: 12px;
  padding: 15px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.action-buttons button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.action-buttons button i {
  font-size: 1.1rem;
}

/* Table responsive */
.table-container {
  background: var(--bg-secondary);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  background: var(--header-bg);
  color: var(--text-white);
  padding: 15px 8px;
  font-weight: 600;
  font-size: 0.85rem;
}

td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-primary);
}

/* Colonnes spécifiques */
.player-name {
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  padding-left: 15px;
}

.score {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--score-color);
}

.last-score {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Actions par joueur */
.player-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.points-input {
  width: 60px;
  height: 40px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.points-input:focus {
  outline: none;
  border-color: var(--header-bg);
  background: var(--bg-secondary);
}

.action-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.add-btn {
  background: var(--add-btn-bg);
  color: white;
}

.add-btn:active {
  background: #229954;
  transform: scale(0.95);
}

.undo-btn {
  background: var(--undo-btn-bg);
  color: white;
}

.undo-btn:active {
  background: #c0392b;
  transform: scale(0.95);
}

/* Formulaire d'ajout de joueur */
.player-form {
  background: var(--bg-secondary);
  border-radius: 15px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-top: 20px;
  transition: all 0.3s ease;
}

.player-form input {
  width: 100%;
  padding: 15px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
  margin-bottom: 15px;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.player-form input:focus {
  outline: none;
  border-color: var(--header-bg);
  background: var(--bg-secondary);
}

.player-form button {
  width: 100%;
  padding: 15px;
  background: var(--header-bg);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

.player-form button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Historique des scores */
.history-button {
  background: var(--button-bg);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 5px;
}

.history-button:hover {
  background: var(--header-bg);
  color: var(--text-white);
}

.history-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.history-modal.show {
  display: flex;
}

.history-modal-content {
  background: var(--bg-secondary);
  border-radius: 15px;
  padding: 20px;
  max-width: 90%;
  max-height: 80%;
  overflow-y: auto;
  box-shadow: var(--shadow);
  position: relative;
}

.history-modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.history-modal-title {
  color: var(--text-primary);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 15px;
  padding-right: 30px;
}

.history-modal-list {
  max-height: 300px;
  overflow-y: auto;
}

.history-modal-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.history-modal-item:last-child {
  border-bottom: none;
}

.history-modal-item .points {
  font-weight: 600;
  color: var(--score-color);
}

.history-modal-item .time {
  font-size: 0.9rem;
}

/* Responsive design */
@media (max-width: 480px) {
  .container {
    padding: 5px;
  }
  
  h1 {
    font-size: 1.5rem;
    margin: 5px 0 15px 0;
  }
  
  .action-buttons {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .action-buttons button {
    padding: 12px 8px;
    font-size: 0.85rem;
    min-height: 45px;
  }
  
  th, td {
    padding: 10px 5px;
    font-size: 0.8rem;
  }
  
  .player-name {
    padding-left: 10px;
  }
  
  .points-input {
    width: 50px;
    height: 35px;
    font-size: 0.9rem;
  }
  
  .action-btn {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }
  
  .player-actions {
    gap: 5px;
  }
  
  .theme-toggle {
    width: 45px;
    height: 45px;
    font-size: 1rem;
  }
  
  .victory-mode-selector {
    padding: 10px;
    gap: 8px;
  }
  
  .victory-mode-selector label {
    font-size: 0.8rem;
  }
  
  .victory-mode-selector select {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.player-form, .table-container, .history-container {
  animation: fadeIn 0.3s ease-out;
}

.history-item {
  animation: slideIn 0.3s ease-out;
}

/* États spéciaux */
.score.highlight {
  background: var(--highlight-bg);
  border-radius: 5px;
  padding: 2px 5px;
  animation: pulse 0.5s ease-in-out;
}

.score.celebration {
  animation: bounce 0.6s ease-in-out;
}

/* Scroll horizontal pour tableaux larges */
@media (max-width: 600px) {
  .table-container {
    overflow-x: auto;
  }
  
  table {
    min-width: 500px;
  }
}

/* Scrollbar personnalisée */
.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-track {
  background: var(--input-bg);
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
