/* ============================================================
   DKmusic — style repris du design system DKup
   ============================================================ */
:root {
  --primary: #4a6cf7;
  --primary-light: #6b8cff;
  --primary-lighter: #8da8ff;
  --success: #50c878;
  --warning: #f5a623;
  --danger: #e74c3c;

  --text-white: #ffffff;
  --text-light: #ccc;
  --text-normal: #999;
  --text-muted: #666;
  --text-subtle: #555;

  --bg-dark: #0a0a0c;
  --bg-darker: #111115;
  --bg-card: rgba(18, 18, 22, 0.5);
  --bg-panel: rgba(14, 14, 18, 0.95);

  --border-subtle: rgba(255, 255, 255, 0.03);
  --border-light: rgba(255, 255, 255, 0.06);
  --border-normal: rgba(255, 255, 255, 0.08);
  --border-active: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

/* Anti double-tap zoom (mobile) ; on garde la sélection de texte ailleurs */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: #e0e0e0;
  background-image:
    radial-gradient(ellipse 600px 400px at 10% 20%, rgba(74, 108, 247, 0.12), transparent),
    radial-gradient(ellipse 500px 500px at 85% 15%, rgba(168, 85, 247, 0.08), transparent),
    radial-gradient(ellipse 400px 300px at 50% 80%, rgba(59, 130, 246, 0.08), transparent);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: 110px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Barre de défilement (large, facile à attraper) ---------- */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent; }
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  border: 4px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active {
  background: rgba(255, 255, 255, 0.42);
  background-clip: padding-box;
}

/* ---------- Header ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.8rem 2rem;
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(20px);
  background: rgba(10, 10, 12, 0.55);
}
.header-left { display: flex; align-items: center; }
.header-logo-link { cursor: pointer; display: flex; align-items: center; }
.header-logo-link:hover { opacity: 0.85; }
.header-logo { height: 30px; }

.header-right { display: flex; align-items: center; gap: 0.6rem; margin-left: auto; }

/* Point d'état IA */
.ai-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: default;
}
.ai-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-subtle);
  transition: all 0.3s;
}
.ai-status.online .ai-dot {
  background: var(--success);
  box-shadow: 0 0 6px rgba(80, 200, 120, 0.5);
}
.ai-status.online .ai-label { color: var(--text-light); }
.ai-status.offline .ai-dot {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(231, 76, 60, 0.5);
}
.ai-status.checking .ai-dot { background: var(--warning); animation: pulse 1.5s infinite; }

/* ---------- Recherche + autocomplete ---------- */
.search { flex: 1; max-width: 560px; }
.search-wrap { display: flex; align-items: center; gap: 0.5rem; }
.search-field { position: relative; flex: 1; }

/* Bouton micro (recherche vocale) */
.mic-btn {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-normal);
  border-radius: 10px;
  color: var(--text-light); cursor: pointer; transition: all 0.15s;
}
.mic-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.mic-btn.recording {
  background: rgba(231, 76, 60, 0.18);
  border-color: rgba(231, 76, 60, 0.5);
  color: #f06050;
  animation: pulse 1.2s infinite;
}
.mic-btn.processing { opacity: 0.6; cursor: progress; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-normal);
  border-radius: 10px;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
#search-input::placeholder { color: var(--text-subtle); }
#search-input:focus { outline: none; border-color: rgba(74, 108, 247, 0.5); }
#search-input { padding-right: 2.6rem; }

.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light); border-radius: 8px;
  color: var(--text-normal); cursor: pointer; transition: all 0.15s;
}
.search-clear:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.search-clear.hidden { display: none; }

.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-normal);
  border-radius: 10px;
  overflow: hidden;
  z-index: 60;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
}
.suggest-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text-light);
  cursor: pointer;
}
.suggest-item:hover, .suggest-item.active { background: rgba(74, 108, 247, 0.1); color: #fff; }
.suggest-item svg { color: var(--text-muted); flex-shrink: 0; }

/* ---------- Contenu ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 1.8rem 2rem; }
.view.hidden { display: none; }
.hidden { display: none !important; }

.view-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap;
}
h2 { font-size: 1.3rem; font-weight: 700; margin: 0; color: #fff; }
.count { color: var(--text-muted); font-size: 0.9rem; font-weight: 400; }

.controls { display: flex; gap: 0.8rem; }
.ctl {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; color: var(--text-muted);
}
.ctl select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-normal);
  border-radius: 6px;
  color: var(--text-light);
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}
.ctl select:focus { outline: none; border-color: rgba(74, 108, 247, 0.5); }

.tab {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  color: var(--text-normal);
  font-size: 0.8rem; font-weight: 500;
  padding: 0.45rem 0.8rem; border-radius: 6px; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
}
.tab:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-light); }

.empty { color: var(--text-muted); padding: 2rem 0; font-size: 0.9rem; }

/* ---------- Groupes ---------- */
.group-title {
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--primary-light);
  margin: 1.4rem 0 0.5rem; padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-light);
}
.group-title:first-child { margin-top: 0; }

/* ---------- Liste / lignes ---------- */
.list { display: flex; flex-direction: column; gap: 2px; }
.row {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.5rem 0.7rem; border-radius: 8px;
  border: 1px solid transparent; transition: all 0.15s;
}
.row:hover { background: rgba(255, 255, 255, 0.03); }
.row.playing {
  background: rgba(74, 108, 247, 0.08);
  border-color: rgba(74, 108, 247, 0.25);
}
.row img {
  width: 46px; height: 46px; border-radius: 5px; object-fit: cover;
  background: rgba(255, 255, 255, 0.04); flex-shrink: 0;
}
.row-meta { flex: 1; min-width: 0; }
.row-title {
  font-size: 0.9rem; color: #eee;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row.playing .row-title { color: var(--primary-light); font-weight: 600; }
.row-sub {
  font-size: 0.76rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.tag-genre {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  background: rgba(74, 108, 247, 0.1); border: 1px solid rgba(74, 108, 247, 0.2);
  color: var(--primary-light); font-size: 0.65rem; margin-left: 0.4rem;
}
.row-plays {
  font-size: 0.7rem; color: var(--text-subtle);
  font-variant-numeric: tabular-nums; min-width: 60px; text-align: right;
}
.row-dur {
  color: var(--text-muted); font-size: 0.76rem;
  font-variant-numeric: tabular-nums; min-width: 38px; text-align: right;
}

.row-actions { display: flex; gap: 0.3rem; }
.row-actions button {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-light); font-size: 0.85rem; cursor: pointer;
  display: grid; place-items: center; transition: all 0.15s;
}
.row-actions button:hover { background: rgba(255, 255, 255, 0.06); }
.row-actions button.add:hover { background: rgba(74, 108, 247, 0.25); border-color: rgba(74, 108, 247, 0.35); color: var(--primary-lighter); }
.row-actions button.del:hover { background: rgba(231, 76, 60, 0.15); border-color: rgba(231, 76, 60, 0.25); color: #f06050; }
.row-actions button:disabled { opacity: 0.5; cursor: progress; }

/* ---------- Lecteur ---------- */
.player {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: 1fr 1.6fr 1fr;
  align-items: center; gap: 1.5rem;
  height: 100px; padding: 0 1.8rem;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-normal);
  backdrop-filter: blur(20px);
  z-index: 40;
}
.player.hidden { display: none; }

.player-now { display: flex; align-items: center; gap: 0.9rem; min-width: 0; }
.player-thumb { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.player-meta { min-width: 0; }
.player-title {
  font-weight: 600; font-size: 0.88rem; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-artist {
  color: var(--text-muted); font-size: 0.76rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.player-center { display: flex; flex-direction: column; gap: 0.5rem; }
.player-controls { display: flex; align-items: center; justify-content: center; gap: 1.6rem; }
.player-controls button {
  background: none; border: none; color: var(--text-light);
  cursor: pointer; transition: transform 0.15s, color 0.15s;
  display: grid; place-items: center; padding: 0;
  width: 44px; height: 44px;
}
.player-controls button:hover { color: #fff; }
.player-controls button:active { transform: scale(0.92); }
#btn-play {
  width: 52px; height: 52px; border-radius: 50%;
  background: #fff; color: #000;
}
#btn-play:hover { transform: scale(1.06); color: #000; }

/* Bouton aléatoire — déplacé à droite, près du volume */
.shuffle-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.15s; flex-shrink: 0;
}
.shuffle-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-light); border-color: var(--border-active); }
.shuffle-btn.active {
  color: var(--primary-light);
  border-color: rgba(74, 108, 247, 0.4);
  background: rgba(74, 108, 247, 0.12);
}

.player-progress { display: flex; align-items: center; gap: 0.7rem; }
.player-progress span { font-size: 0.7rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Barre de progression custom, gros curseur tactile */
#seek {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 6px; border-radius: 4px;
  background: linear-gradient(90deg, var(--primary) var(--seek, 0%), rgba(255, 255, 255, 0.14) var(--seek, 0%));
  outline: none; cursor: pointer;
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: none; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s;
}
#seek::-webkit-slider-thumb:hover { transform: scale(1.2); }
#seek::-webkit-slider-thumb:active { transform: scale(1.45); background: var(--primary-light); }
#seek::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: none; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); cursor: pointer;
}
#seek::-moz-range-progress { background: var(--primary); height: 6px; border-radius: 4px; }

.player-right { display: flex; align-items: center; justify-content: flex-end; gap: 0.8rem; }
.badge {
  font-size: 0.65rem; padding: 0.2rem 0.55rem; border-radius: 10px;
  color: var(--text-muted); border: 1px solid var(--border-light);
  white-space: nowrap;
}

/* ---- Volume : tactile, facile à attraper ---- */
.volume-box { display: flex; align-items: center; gap: 0.6rem; }
.vol-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  color: var(--text-light); cursor: pointer;
  transition: all 0.15s;
}
.vol-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; border-color: var(--border-active); }
.vol-btn .vol-off { display: none; color: var(--danger); }
.vol-btn.muted .vol-on { display: none; }
.vol-btn.muted .vol-off { display: block; }

/* Slider de volume custom, gros curseur tactile */
#volume {
  -webkit-appearance: none; appearance: none;
  width: 110px; height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary) var(--vol, 100%), rgba(255,255,255,0.12) var(--vol, 100%));
  outline: none; cursor: pointer;
}
#volume::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s;
}
#volume::-webkit-slider-thumb:hover { transform: scale(1.15); }
#volume::-webkit-slider-thumb:active { transform: scale(1.3); background: var(--primary-light); }
#volume::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); cursor: pointer;
}
#volume::-moz-range-progress { background: var(--primary); height: 6px; border-radius: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%);
  background: var(--bg-darker); border: 1px solid var(--border-normal);
  padding: 0.7rem 1.2rem; border-radius: 8px; z-index: 100;
  font-size: 0.85rem; color: var(--text-light);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  animation: fadeSlideIn 0.2s ease;
}
.toast.hidden { display: none; }

/* ---------- Animations ---------- */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes fadeSlideIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; display: inline-block; }

/* ---------- Bouton paroles ---------- */
.lyrics-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.lyrics-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-light); border-color: var(--border-active); }
.lyrics-btn.active { color: var(--primary-light); border-color: rgba(74, 108, 247, 0.4); background: rgba(74, 108, 247, 0.12); }

/* ---------- Modal paroles ---------- */
.lyrics-modal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(8px);
  padding: 1rem;
}
.lyrics-modal.hidden { display: none; }
.lyrics-box {
  width: 100%; max-width: 560px; max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--bg-darker);
  border: 1px solid var(--border-normal);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}
.lyrics-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border-light);
}
.lyrics-title { font-weight: 700; font-size: 1rem; color: #fff; }
.lyrics-artist { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.lyrics-close {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border-light);
  border-radius: 8px; color: var(--text-light); cursor: pointer; transition: all 0.15s;
}
.lyrics-close:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.lyrics-content {
  overflow-y: auto; padding: 1.4rem 1.4rem 2rem;
  line-height: 2; scroll-behavior: smooth;
}
.lyrics-content.plain { white-space: pre-wrap; color: var(--text-light); font-size: 0.92rem; }
.lyric-line {
  font-size: 1.05rem; color: var(--text-subtle);
  transition: color 0.2s, transform 0.2s; transform-origin: left;
  padding: 0.15rem 0;
}
.lyric-line.active { color: #fff; font-weight: 600; transform: scale(1.04); }
.lyric-line.past { color: var(--text-muted); }
.lyrics-empty { color: var(--text-muted); text-align: center; padding: 2rem 0; }

/* ---------- Verrou mot de passe ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-dark);
  background-image:
    radial-gradient(ellipse 600px 400px at 30% 30%, rgba(74, 108, 247, 0.15), transparent),
    radial-gradient(ellipse 500px 500px at 70% 70%, rgba(168, 85, 247, 0.1), transparent);
  padding: 1.5rem;
}
.login-overlay.hidden { display: none; }
.login-box {
  display: flex; flex-direction: column; align-items: center; gap: 0.9rem;
  width: 100%; max-width: 340px;
  padding: 2.2rem 1.8rem;
  background: var(--bg-card); backdrop-filter: blur(10px);
  border: 1px solid var(--border-normal); border-radius: 16px;
}
.login-logo { height: 36px; margin-bottom: 0.3rem; }
.login-sub { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
#login-password {
  width: 100%; padding: 0.7rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-normal); border-radius: 10px;
  color: #fff; font-size: 0.95rem; font-family: inherit; text-align: center;
}
#login-password:focus { outline: none; border-color: rgba(74, 108, 247, 0.5); }
.login-box button {
  width: 100%; padding: 0.7rem; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 0.95rem;
  font-family: inherit; cursor: pointer; transition: background 0.15s;
}
.login-box button:hover { background: var(--primary-light); }
.login-error { color: var(--danger); font-size: 0.82rem; margin: 0; }
.login-error.hidden { display: none; }

/* ---------- Responsive (mobile portrait) ---------- */
@media (max-width: 760px) {
  body { padding-bottom: 210px; }

  header { flex-wrap: wrap; gap: 0.6rem; padding: 0.6rem 0.9rem; }
  .header-left { order: 1; }
  .header-right { order: 2; margin-left: auto; }
  .search { order: 3; flex-basis: 100%; max-width: none; }

  main { padding: 1rem 0.9rem; }
  .view-head { gap: 0.7rem; }
  .controls { width: 100%; }
  .ctl { flex: 1; }
  .ctl select { width: 100%; }

  /* Dock empilé verticalement */
  .player {
    grid-template-columns: 1fr;
    height: auto;
    gap: 0.8rem;
    padding: 0.9rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
    align-items: stretch;
  }
  .player-now { order: 1; }
  .player-center { order: 2; gap: 0.7rem; }
  .player-right { order: 3; display: flex; justify-content: center; gap: 1rem; }

  /* Contrôles XL faciles à attraper au doigt */
  .player-controls { gap: 2.2rem; }
  .player-controls button { width: 52px; height: 52px; }
  #btn-play { width: 62px; height: 62px; }
  .badge { display: none; }
  #volume { width: 60%; max-width: 260px; }
  .vol-btn { width: 46px; height: 46px; }

  /* Lignes plus aérées au doigt */
  .row { padding: 0.6rem 0.5rem; }
  .row-actions button { width: 40px; height: 40px; }
  .row-plays { display: none; }
}
