/* Tavernyx — thème sombre, responsive. Vanilla CSS. */

:root {
  --bg:        #12131a;
  --bg-2:      #1a1c26;
  --bg-3:      #23263340;
  --panel:     #1c1e29;
  --border:    #2c2f3d;
  --text:      #e9eaf0;
  --text-dim:  #9aa0b4;
  --accent:    #e0a13a;          /* ambre "taverne" */
  --accent-2:  #f0b551;
  --danger:    #e06a5a;
  --active:    #2a2d3d;
  --radius:    10px;
  --shadow:    0 8px 30px rgba(0,0,0,.45);
  --player-h:  88px;
  --top-h:     60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button { font-family: inherit; cursor: pointer; }
input, select, button { font-size: 14px; }

/* --------------------------------------------------------------------- */
/* Authentification                                                      */
/* --------------------------------------------------------------------- */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 50% -10%, #2a2233 0%, transparent 60%),
    var(--bg);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.auth-logo {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .5px;
}

.auth-tagline {
  text-align: center;
  color: var(--text-dim);
  margin: 6px 0 24px;
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px;
  border-radius: 7px;
  font-weight: 600;
  transition: .15s;
}

.auth-tab.active {
  background: var(--accent);
  color: #1b1405;
}

.auth-form { display: none; flex-direction: column; gap: 16px; }
.auth-form.active { display: flex; }

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.auth-form .hint { color: var(--text-dim); opacity: .7; font-weight: 400; }

.auth-form input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: var(--radius);
  outline: none;
}
.auth-form input:focus { border-color: var(--accent); }

.auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
}

.btn-primary {
  background: var(--accent);
  color: #1b1405;
  border: none;
  padding: 12px;
  border-radius: var(--radius);
  font-weight: 700;
  transition: .15s;
}
.btn-primary:hover { background: var(--accent-2); }

/* --------------------------------------------------------------------- */
/* App : barre du haut                                                   */
/* --------------------------------------------------------------------- */

.app-body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }

.search-wrap { flex: 1; max-width: 520px; }

#search {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 999px;
  outline: none;
}
#search:focus { border-color: var(--accent); }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.icon-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  font-size: 17px;
  transition: .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.spinning { animation: spin .8s linear infinite; }

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

/* --------------------------------------------------------------------- */
/* App : layout                                                          */
/* --------------------------------------------------------------------- */

.layout { flex: 1; display: flex; overflow: hidden; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }

.filter-group select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: var(--radius);
  outline: none;
}
.filter-group select:focus { border-color: var(--accent); }

.btn-secondary {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px;
  border-radius: var(--radius);
  transition: .15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.admin-panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-title {
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 700;
}
.admin-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.admin-toggle input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

.auth-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 18px;
}

.counter {
  margin-top: auto;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------- */
/* App : liste des titres                                                */
/* --------------------------------------------------------------------- */

.tracklist-wrap { flex: 1; overflow-y: auto; padding: 12px 12px 20px; }

.tracklist { list-style: none; margin: 0; padding: 0; }

.track {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s;
}
.track:hover { background: var(--bg-3); }
.track.active { background: var(--active); }
.track.active .track-title { color: var(--accent); }

.track-cover {
  width: 46px;
  height: 46px;
  border-radius: 7px;
  flex-shrink: 0;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 20px;
  object-fit: cover;
  overflow: hidden;
}
.track-cover img { width: 100%; height: 100%; object-fit: cover; }

.track-main { flex: 1; min-width: 0; }
.track-title {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-sub {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-dur { font-size: 13px; color: var(--text-dim); flex-shrink: 0; font-variant-numeric: tabular-nums; }

.track-edit {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  width: 32px; height: 32px;
  border-radius: 7px;
  opacity: 0;
  transition: opacity .12s, color .12s, background .12s;
}
.track:hover .track-edit { opacity: 1; }
.track-edit:hover { color: var(--accent); background: var(--bg-2); }
@media (hover: none) { .track-edit { opacity: 1; } } /* tactile : toujours visible */

.empty-state { text-align: center; color: var(--text-dim); padding: 60px 20px; }
.empty-state code { background: var(--bg-2); padding: 2px 6px; border-radius: 5px; }

/* --------------------------------------------------------------------- */
/* App : lecteur                                                         */
/* --------------------------------------------------------------------- */

.player {
  height: var(--player-h);
  flex-shrink: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
}

.player-now { display: flex; align-items: center; gap: 12px; min-width: 0; }

.player-cover {
  width: 56px; height: 56px;
  border-radius: 8px;
  background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 22px;
  flex-shrink: 0; overflow: hidden;
}
.player-cover img { width: 100%; height: 100%; object-fit: cover; }

.player-meta { min-width: 0; }
.player-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player-controls { display: flex; flex-direction: column; gap: 8px; }
.player-buttons { display: flex; align-items: center; justify-content: center; gap: 18px; }

.ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  width: 36px; height: 36px;
  border-radius: 50%;
  transition: .12s;
}
.ctrl-btn:hover { color: var(--accent); }

.ctrl-play {
  background: var(--accent);
  color: #1b1405;
  font-size: 16px;
}
.ctrl-play:hover { background: var(--accent-2); color: #1b1405; }

.player-progress { display: flex; align-items: center; gap: 10px; }
.time { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; }

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  pointer-events: none;
}

.player-volume { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.vol-icon { color: var(--text-dim); }
#volume { width: 110px; accent-color: var(--accent); cursor: pointer; }

/* --------------------------------------------------------------------- */
/* Modale d'édition                                                      */
/* --------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 18px; }

#edit-form { display: flex; flex-direction: column; gap: 14px; }

#edit-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}
#edit-form input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  outline: none;
}
#edit-form input:focus { border-color: var(--accent); }

.modal-hint { font-size: 12px; color: var(--text-dim); margin: 2px 0 0; line-height: 1.5; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal-actions .btn-primary,
.modal-actions .btn-secondary { padding: 10px 18px; }

/* --------------------------------------------------------------------- */
/* Responsive                                                            */
/* --------------------------------------------------------------------- */

@media (max-width: 760px) {
  .sidebar { display: none; }
  .player { grid-template-columns: 1fr auto; grid-template-areas: "now vol" "controls controls"; height: auto; padding: 10px 14px; gap: 10px; }
  .player-now { grid-area: now; }
  .player-volume { grid-area: vol; }
  .player-controls { grid-area: controls; }
  .brand { font-size: 16px; }
  :root { --player-h: auto; }
}

/* --------------------------------------------------------------------- */
/* Toast (notifications transitoires : upload…)                          */
/* --------------------------------------------------------------------- */

.icon-btn:disabled { opacity: .5; cursor: default; }
.icon-btn:disabled:hover { border-color: var(--border); color: var(--text); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--player-h, 88px) + 18px);
  transform: translate(-50%, 12px);
  z-index: 50;
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.toast-error { border-left-color: #e0573a; }
