/* ---------- Variables par thème ---------- */

:root,
html[data-theme="clair"] {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-alt: #f1f3f5;
  --text: #1a1d21;
  --text-muted: #6b7280;
  --border: #e2e5e9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text: #ffffff;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
}

html[data-theme="sombre"] {
  --bg: #14161a;
  --surface: #1e2126;
  --surface-alt: #252932;
  --text: #e5e7eb;
  --text-muted: #9aa1ac;
  --border: #31353d;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-text: #0b0d10;
  --success-bg: #052e1c;
  --success-text: #4ade80;
  --error-bg: #3a0d0d;
  --error-text: #f87171;
}

html[data-theme="neon"] {
  --bg: #120826;
  --surface: #1c0f3a;
  --surface-alt: #251654;
  --text: #f0e6ff;
  --text-muted: #b79ee0;
  --border: #3d2570;
  --accent: #ff2fb0;
  --accent-hover: #ff5cc4;
  --accent-text: #120826;
  --success-bg: #062d2a;
  --success-text: #2dd4bf;
  --error-bg: #3a0d2a;
  --error-text: #ff6ec7;
}

html[data-theme="ocean"] {
  --bg: #e8f6f8;
  --surface: #ffffff;
  --surface-alt: #d7f0f3;
  --text: #0b3a44;
  --text-muted: #4d7b85;
  --border: #bfe4e9;
  --accent: #0891b2;
  --accent-hover: #0e7490;
  --accent-text: #ffffff;
  --success-bg: #d1fae5;
  --success-text: #065f46;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
}

html[data-theme="foret"] {
  --bg: #f1f5ee;
  --surface: #ffffff;
  --surface-alt: #e4ead9;
  --text: #233421;
  --text-muted: #5c7159;
  --border: #cfdcc5;
  --accent: #2e7d32;
  --accent-hover: #256628;
  --accent-text: #ffffff;
  --success-bg: #dcedc8;
  --success-text: #33691e;
  --error-bg: #ffe0e0;
  --error-text: #b71c1c;
}

html[data-theme="coucher-de-soleil"] {
  --bg: #fff3ec;
  --surface: #ffffff;
  --surface-alt: #ffe3d1;
  --text: #4a2415;
  --text-muted: #9c6c52;
  --border: #ffd2ae;
  --accent: #f4623a;
  --accent-hover: #e0502a;
  --accent-text: #ffffff;
  --success-bg: #e6f4d7;
  --success-text: #4d7c0f;
  --error-bg: #fde0dd;
  --error-text: #9d174d;
}

html[data-theme="minimaliste"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-alt: #efefef;
  --text: #111111;
  --text-muted: #6e6e6e;
  --border: #dddddd;
  --accent: #111111;
  --accent-hover: #333333;
  --accent-text: #ffffff;
  --success-bg: #e8ede8;
  --success-text: #2f4f2f;
  --error-bg: #efe6e6;
  --error-text: #5f2f2f;
}

html[data-theme="retro"] {
  --bg: #f2e8d5;
  --surface: #fbf3e3;
  --surface-alt: #e9dbc0;
  --text: #4a3728;
  --text-muted: #8a7259;
  --border: #d8c4a0;
  --accent: #b5651d;
  --accent-hover: #8f4f16;
  --accent-text: #fbf3e3;
  --success-bg: #e3ecd0;
  --success-text: #4b5320;
  --error-bg: #f0d5c8;
  --error-text: #8b3a2a;
}

html[data-theme="pastel"] {
  --bg: #fdf6fb;
  --surface: #ffffff;
  --surface-alt: #f7e9f5;
  --text: #4a3b4d;
  --text-muted: #9a86a0;
  --border: #efd9ec;
  --accent: #c77dff;
  --accent-hover: #b565f0;
  --accent-text: #ffffff;
  --success-bg: #d8f3dc;
  --success-text: #40916c;
  --error-bg: #ffd6e8;
  --error-text: #c9184a;
}

html[data-theme="contraste"] {
  --bg: #000000;
  --surface: #000000;
  --surface-alt: #1a1a1a;
  --text: #ffffff;
  --text-muted: #ffff00;
  --border: #ffff00;
  --accent: #ffff00;
  --accent-hover: #ffd400;
  --accent-text: #000000;
  --success-bg: #003300;
  --success-text: #00ff00;
  --error-bg: #330000;
  --error-text: #ff5555;
}

/* ---------- Mise en page générale ---------- */

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}

#page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 5.5rem;
}

h1 {
  font-size: 1.6rem;
  margin: 0.5rem 0 1rem;
}

h2 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.75rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- Navigation ---------- */

nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.5rem;
}

nav a {
  color: var(--text);
  font-weight: 500;
}

nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.theme-form {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Barre de lecteur ---------- */

#player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

#now-playing {
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-basis: 100%;
}

#player-bar audio {
  flex: 1 1 auto;
  min-width: 200px;
  max-width: 700px;
}

/* ---------- Formulaires ---------- */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="file"],
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
}

label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Boutons ---------- */

/* Neutre par défaut : la plupart des actions n'ont pas besoin de crier plus fort
   que le titre de leur section. Seules les actions vraiment principales (.btn-primary)
   gardent la couleur d'accent. */
button {
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

button:hover {
  background: var(--border);
}

button:active {
  transform: translateY(1px);
}

.btn-primary {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.play-btn {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.play-btn:hover {
  background: var(--accent);
  color: var(--accent-text);
}

/* ---------- Tableaux ---------- */

table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

thead tr:first-child th:first-child {
  border-top-left-radius: 8px;
}

thead tr:first-child th:last-child {
  border-top-right-radius: 8px;
}

th a {
  color: inherit;
}

tbody tr:hover {
  background: var(--surface-alt);
}

/* ---------- Messages flash ---------- */

.flash-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
}

.flash {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  background: var(--success-bg);
  color: var(--success-text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.flash.error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* ---------- Barre de progression d'upload ---------- */

progress {
  width: 260px;
  height: 0.9rem;
  vertical-align: middle;
  accent-color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt);
}

#upload-progress-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

/* ---------- Contrôles de lecture d'une playlist ---------- */

.playback-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.stop-btn {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.stop-btn:hover {
  background: var(--error-bg);
  color: var(--error-text);
}

/* ---------- Chat ---------- */

#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.chat-message {
  align-self: flex-start;
  max-width: 70%;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  background: var(--surface-alt);
}

.chat-message-mine {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-text);
}

.chat-message-meta {
  display: flex;
  gap: 0.6rem;
  font-size: 0.75rem;
  opacity: 0.8;
  margin-bottom: 0.15rem;
}

.chat-message p {
  margin: 0;
  white-space: pre-wrap;
}

/* ---------- Sections d'actions groupées ---------- */

.page-header {
  margin-bottom: 1rem;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface-alt);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  vertical-align: middle;
}

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.action-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.action-section h2 {
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* Action discrète (retirer/supprimer) : moins de poids visuel que les actions principales */
.btn-subtle {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.reorder-cell {
  white-space: nowrap;
}

/* ---------- Égaliseur 16 bandes ---------- */

.eq-bands {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.5rem 0;
}

.eq-band {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 42px;
  flex-shrink: 0;
}

.eq-slider-wrap {
  height: 140px;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eq-slider {
  width: 130px;
  transform: rotate(-90deg);
}

.eq-freq,
.eq-value {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
}

.eq-value {
  margin-top: 0.15rem;
}

/* ---------- Filtres de restauration (dé-click / dé-pop / dé-esser) ---------- */

.restoration-tool {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.restoration-tool:last-child {
  border-bottom: none;
}

.restoration-tool h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.reorder-cell button {
  padding: 0.2rem 0.5rem;
  font-size: 1rem;
  line-height: 1;
}

.btn-subtle:hover {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-text);
}

/* ---------- Menu d'actions par ligne (natif, sans JS) ---------- */

.row-actions {
  position: relative;
  text-align: right;
  white-space: nowrap;
}

.row-actions summary {
  cursor: pointer;
  list-style: none;
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
}

.row-actions summary::-webkit-details-marker {
  display: none;
}

.row-actions summary:hover,
.row-actions[open] summary {
  background: var(--surface-alt);
}

.row-actions-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0.5rem;
  white-space: nowrap;
}

.row-actions-menu form {
  display: block;
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}
