/* ── Variables ── */
:root {
  --bg: #0b0e14;
  --panel: #111726;
  --line: #1a2236;
  --text: #e8eefc;
  --muted: #9aa3b2;
  --gold: #ffd166;
  --accent: #7c6aff;
  --accent-soft: rgba(124, 106, 255, 0.15);
  --green: #4ade80;
  --red: #f87171;
  --header-height: 58px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font: 15px/1.5 'Inter', system-ui, sans-serif;
}

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-bar {
  max-width: 1100px;
  margin: 0 auto;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Lang switcher ── */
.lang-switcher {
  display: inline-flex !important;
  align-items: center !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  gap: 0 !important;
}
.lang-btn {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  color: rgba(255, 255, 255, 0.35) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  padding: 0 5px !important;
}
.lang-btn.active { color: #fff !important; }
.lang-btn:focus, .lang-btn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
.lang-sep {
  color: rgba(255, 255, 255, 0.2);
  font-size: 11px;
  pointer-events: none;
}

.profile-link,
.stats-button,
.records-button,
.suggest-button,
.likes-button {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}
.profile-link:hover,
.stats-button:hover,
.records-button:hover,
.likes-button:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}
.stats-button   { color: #ffd166; border-color: rgba(255, 209, 102, 0.3); }
.records-button { color: #60a5fa; border-color: rgba(96, 165, 250, 0.3); }
.likes-button   { color: #f472b6; border-color: rgba(244, 114, 182, 0.3); }
.suggest-button { color: #a78bfa; border-color: rgba(167, 139, 250, 0.3); }

.logout-button {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: border-color 0.15s;
}
.logout-button:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.login-button-google {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
}
.login-button-google:hover { background: rgba(255, 255, 255, 0.1); }

.profile-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.username {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ── Main ── */
.catalogue-main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 36px 16px 80px;
}

.catalogue-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.catalogue-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  margin: 0;
}
.catalogue-title .count {
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}

/* ── Search ── */
.search-box {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

#search-input {
  flex: 1;
  height: 46px;
  font-size: 14px;
  padding: 0 16px;
  background: #ffffff;
  color: #111;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  font-family: inherit;
  transition: border-color 0.15s;
  outline: none;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: #888; }

#search-btn {
  height: 46px;
  padding: 0 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
#search-btn:hover { opacity: 0.9; }
#search-btn:active { transform: scale(0.97); }

/* ── Grid ── */
.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

/* ── Track card ── */
.track-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.track-card:hover {
  border-color: rgba(124, 106, 255, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(124, 106, 255, 0.12);
}

.track-cover {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--line);
  display: block;
}

.track-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.track-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.track-artist {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-playlist {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 2px 7px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Record ── */
.track-record {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  min-width: 0;
}

.record-badge {
  background: rgba(255, 209, 102, 0.12);
  color: var(--gold);
  border-radius: 5px;
  padding: 2px 7px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.record-user {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  min-width: 0;
}
.record-user:hover { color: var(--text); text-decoration: underline; }

.no-record {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* ── Loading / Empty ── */
.loading-state,
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 16px;
  color: var(--muted);
  font-size: 15px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.pagination button {
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.pagination button:hover:not(:disabled) {
  border-color: rgba(124, 106, 255, 0.45);
  background: var(--accent-soft);
}
.pagination button:disabled { opacity: 0.35; cursor: default; }
.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.pagination-sep {
  color: var(--muted);
  font-size: 13px;
  padding: 0 2px;
}

/* ── Playlist dropdown ── */
.playlist-dropdown {
  position: relative;
  display: inline-block;
  margin-top: 2px;
  max-width: 100%;
}

.playlist-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  border-radius: 5px;
  padding: 2px 7px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: background 0.15s;
}
.playlist-toggle:hover { background: rgba(124, 106, 255, 0.25); }

.playlist-count {
  color: rgba(124, 106, 255, 0.8);
  font-size: 10px;
  flex-shrink: 0;
}

.playlist-dropdown-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: #1e2535;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  z-index: 100;
  min-width: 160px;
  max-width: 220px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.playlist-dropdown-menu.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.playlist-dropdown-item {
  font-size: 12px;
  color: var(--text);
  padding: 5px 8px;
  border-radius: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s;
}
.playlist-dropdown-item:hover {
  background: var(--accent-soft);
  color: #c4b5fd;
}

/* ══════════════════════════════════════════════════════════
   MOBILE
══════════════════════════════════════════════════════════ */

/* Navbar 800px — cache tout, garde hamburger */
@media (max-width: 800px) {
  .lang-switcher { display: none !important; }
  .header-bar {
    height: 48px !important;
    padding: 0 8px !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
  }
  .brand { font-size: 13px !important; }
  .header-tabs { gap: 4px !important; }
  .header-tabs .tab-link {
    font-size: 10px !important;
    padding: 4px 5px !important;
    gap: 3px !important;
    white-space: nowrap !important;
  }
  .brand { font-size: 14px !important; }
  .nav-right .records-button,
  .nav-right .likes-button,
  .nav-right .logout-button,
  .nav-right .profile-link,
  .nav-right .suggest-button,
  .nav-right .stats-button,
  .nav-right .login-button-google,
  .nav-right .username,
  .nav-right .profile-img,
  .header-tabs { display: none !important; }
  .nav-right {
    margin-left: auto;
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    overflow: visible !important;
  }

  .header-tabs {
  flex-wrap: nowrap !important;
  overflow: hidden !important;
}
.tab-link {
  font-size: 10px !important;
  padding: 4px 6px !important;
  white-space: nowrap !important;
}
}

/* Contenu 600px */
@media (max-width: 600px) {
  .catalogue-main { padding: 20px 10px 60px; }
  .catalogue-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }
  .catalogue-title { font-size: 22px; }
  .search-box { max-width: 100%; }
  #search-input { height: 42px; font-size: 14px; }
  #search-btn { height: 42px; padding: 0 14px; font-size: 13px; }
  .catalogue-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .track-info { padding: 8px; gap: 3px; }
  .track-title { font-size: 13px; }
  .track-artist { font-size: 12px; }
  .record-badge { font-size: 11px; padding: 2px 5px; }
  .record-user { font-size: 11px; }
  .no-record { font-size: 11px; }
  .pagination button { padding: 5px 9px; font-size: 13px; }
}

/* Hamburger 768px */
@media (max-width: 768px) {
  .suggest-button { display: none !important; }
}

/* ── Hamburger ── */
.hamburger-btn {
  display: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 20px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  z-index: 998;
}
.hamburger-btn:hover { background: rgba(255, 255, 255, 0.12); }

.hamburger-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 999;
}
.hamburger-overlay.open { display: block; }

.hamburger-panel {
  position: fixed;
  top: 0; right: 0;
  width: 280px;
  height: 100vh;
  background: #111827;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  padding: 20px 0 32px;
  overflow-y: auto;
}
.hamburger-panel.open { transform: translateX(0); }

.hamburger-close {
  position: absolute;
  top: 10px; right: 12px;
  background: none; border: none;
  color: #9aa3b2; font-size: 22px;
  cursor: pointer; opacity: 0.5;
}
.hamburger-close:hover { color: #fff; opacity: 1; }

.hamburger-user {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px 20px;
  border-bottom: 2px solid rgba(99, 120, 255, 0.5);
}
.hamburger-avatar {
  width: 40px; height: 40px;
  border-radius: 50%; object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}
.hamburger-username {
  font-size: 15px; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.hamburger-links {
  display: flex; flex-direction: column;
  gap: 0; padding: 0 12px; flex: 1;
}
.hamburger-link {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  color: #e8eefc; text-decoration: none;
  font-size: 14px; font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid transparent;
  transition: background 0.15s, border-left 0.15s;
}
.hamburger-link:last-child { border-bottom: none; }
.hamburger-link:hover {
  background: rgba(99, 120, 255, 0.08);
  border-left: 3px solid rgba(99, 120, 255, 0.6);
  color: #fff;
}
.hamburger-logout {
  color: #9aa3b2; margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 16px;
  border-left: 3px solid transparent;
}
.hamburger-logout:hover {
  color: #fff;
  background: rgba(255, 80, 80, 0.08);
  border-left: 3px solid rgba(255, 80, 80, 0.5);
}
.hamburger-suggest { margin-top: 8px; }
.hamburger-login {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 12px 16px; border-radius: 10px;
  color: #fff; font-size: 14px; font-weight: 500;
}
.hamburger-lang {
  display: flex; align-items: center;
  justify-content: center; gap: 4px;
  padding: 20px 20px 0;
}

@media (max-width: 768px) {
  .hamburger-btn { display: flex; }
  .nav-right .profile-link,
  .nav-right .stats-button,
  .nav-right .records-button,
  .nav-right .likes-button,
  .nav-right .suggest-button,
  .nav-right .logout-button,
  .nav-right .login-button-google,
  .nav-right .lang-switcher,
  .nav-right .username,
  .nav-right .profile-img,
  .header-tabs { display: none !important; }
  .nav-right {
    margin-left: auto;
    display: flex !important;
    align-items: center;
    gap: 8px;
    overflow: visible !important;
  }
  .header-bar {
    height: 56px !important;
    padding: 0 12px !important;
    gap: 0 !important;
  }
}