/* ----------------------------
   Style de base + thèmes
----------------------------- */

/* Valeurs par défaut (fallback) */
:root {
  --primary-color: #f26722;
  --primary-color-hover: #d9581c;
  --primary-shadow: rgba(242, 103, 34, 0.35);

  --body-bg: #f5f5f7;
  --text-main: #333;
  --text-header: #3b3b3d;
  --border-soft: #e3e3e7;
  --border-input: #d0d0d5;

  --badge-ok: #2e7d32;
  --badge-ko: #c62828;
}

/* Thème ORANGE */
:root[data-theme="orange"] {
  --primary-color: #f26722;
  --primary-color-hover: #d9581c;
  --primary-shadow: rgba(242, 103, 34, 0.35);
  --body-bg: #fef6f2;
}

/* Thème BLEU */
:root[data-theme="blue"] {
  --primary-color: #2563eb;
  --primary-color-hover: #1d4ed8;
  --primary-shadow: rgba(37, 99, 235, 0.35);
  --body-bg: #eef3ff;
}

/* Thème ROSE */
:root[data-theme="pink"] {
  --primary-color: #db2777;
  --primary-color-hover: #be185d;
  --primary-shadow: rgba(219, 39, 119, 0.35);
  --body-bg: #fff0f7;
}

/* Thème VERT */
:root[data-theme="green"] {
  --primary-color: #16a34a;
  --primary-color-hover: #15803d;
  --primary-shadow: rgba(22, 163, 74, 0.35);
  --body-bg: #edfdf3;
}

/* Reset léger */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Utilitaires */
.hidden { display: none !important; }

/* Typographie */
html,body {
  font-family: Arial, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  color: var(--text-main);
  background: var(--body-bg);
  line-height: 1.5;
}
h1,h2,h3,h4 {
  font-family: Georgia, serif;
  color: var(--text-header);
  font-weight: 600;
}

/* App container */
.app {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 16px 32px;
}
.app-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-header h1 { font-size: 2.2rem; }

/* Bouton config header */
.header-config-btn {
  font-size: 0.85rem;
  padding: 8px 16px;
}

/* Layout jeu */
.layout {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: 24px;
}
.game-panel,
.sidebar,
.config-screen {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border-soft);
  box-shadow:
    0 1px 3px rgba(0,0,0,0.08),
    0 8px 24px rgba(0,0,0,0.06);
}

/* Écran configuration */
.config-screen h2 {
  font-size: 1.4rem;
  margin-bottom: 16px;
}
.config-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row label,
.form-label {
  font-size: 0.9rem;
  color: #4b4b4f;
  font-weight: 600;
}
.config-form input[type="text"],
.config-form select {
  border-radius: 999px;
  border: 1px solid var(--border-input);
  padding: 8px 12px;
  background: #fff;
}
.theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.9rem;
}
.theme-options label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.hint {
  font-size: 0.85rem;
  color: #6b6b6f;
}
.form-actions {
  margin-top: 8px;
}

/* Panneau de jeu */
.game-area.hidden { display: none; }
.current-question h2 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}
.question-info {
  font-size: 0.9rem;
  color: #6b6b6f;
  margin-bottom: 8px;
}
#audioPlayer {
  width: 100%;
  margin: 12px 0 16px;
  border-radius: 8px;
}

/* Boutons */
.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  border: none;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn {
  background: var(--primary-color);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-shadow);
}
.primary-btn:hover {
  background: var(--primary-color-hover);
  transform: translateY(-1px);
}
.secondary-btn {
  background: #fff;
  color: #444;
  border: 1px solid var(--border-input);
}
.secondary-btn:hover {
  background: #f5f5f7;
  transform: translateY(-1px);
}
.small-btn {
  padding: 6px 14px;
  font-size: 0.85rem;
}

/* Navigation */
.navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.navigation-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
#questionCounter {
  font-size: 0.9rem;
  color: #6b6b6f;
}

/* Timer circular */
.timer-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-ring {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-svg {
  width: 40px;
  height: 40px;
  transform: rotate(-90deg);
}
.timer-bg {
  fill: none;
  stroke: #e5e7eb;
  stroke-width: 3;
}
.timer-progress {
  fill: none;
  stroke: var(--primary-color);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 113 113;
  stroke-dashoffset: 113;
  transition: stroke-dashoffset 0.2s linear;
}
.timer-label {
  position: absolute;
  font-size: 0.75rem;
  color: #555;
}

/* Answer panel */
.answer-panel {
  border-top: 1px solid #ececef;
  padding-top: 16px;
  margin-top: 4px;
}
.answer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.answer-row label {
  min-width: 110px;
  font-size: 0.9rem;
  color: #4b4b4f;
}
.answer-row input,
.answer-row select {
  flex: 1;
  border-radius: 8px;
  border: 1px solid var(--border-input);
  padding: 8px 10px;
  background: #fff;
}

/* Sidebar */
.sidebar h2 {
  font-size: 1.2rem;
  margin-bottom: 10px;
}
.team-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
#teamNameInput {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--border-input);
  padding: 8px 12px;
}
.team-list {
  list-style: none;
  max-height: 190px;
  overflow-y: auto;
  padding-right: 4px;
}
.team-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #fafafa;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
}

/* Team action buttons */
.team-actions {
  display: flex;
  gap: 6px;
}
.team-actions .edit-btn {
  background: #e3f0ff;
  color: #174ea6;
  border-radius: 999px;
  padding: 4px 10px;
  border: none;
  cursor: pointer;
}
.team-actions .delete-btn {
  background: #ffe5e5;
  color: #b3261e;
  border-radius: 999px;
  padding: 4px 10px;
  border: none;
  cursor: pointer;
}

/* History */
.history-table-wrapper {
  max-height: 260px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: #fff;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.history-table th,
.history-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f0f2;
  text-align: left;
}
.history-table thead {
  background: #fafafa;
  position: sticky;
  top: 0;
  z-index: 1;
}
.history-table tbody tr:nth-child(even) td {
  background: #fcfcfd;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.badge.ok {
  background: var(--badge-ok);
  color: #fff;
}
.badge.ko {
  background: var(--badge-ko);
  color: #fff;
}

/* History actions (badge + icon) */
.history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.history-edit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 4px;
}
.history-edit-btn:hover {
  background: #ececec;
}
.history-edit-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  color: #555;
}

/* Scrollbars (webkit) */
.history-table-wrapper::-webkit-scrollbar,
.team-list::-webkit-scrollbar {
  width: 6px;
}
.history-table-wrapper::-webkit-scrollbar-thumb,
.team-list::-webkit-scrollbar-thumb {
  background: #d0d0d5;
  border-radius: 999px;
}

/* Responsive */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .game-panel,
  .sidebar,
  .config-screen {
    padding: 16px;
  }
}
