:root {
  --bg-main: #121212;
  --bg-side: #000000;
  --bg-card: #181818;
  --bg-card-hover: #282828;
  --text-main: #ffffff;
  --text-secondary: #b3b3b3;
  --accent: #1db954;
  --accent-hover: #1ed760;
  --border-color: #282828;
  --player-height: 80px;
  --bottom-nav-height: 60px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.hidden-audio-container {
  display: none;
}

/* LAYOUT GLOBAL */
.app-container {
  display: flex;
  height: calc(100vh - var(--player-height));
  width: 100vw;
  position: relative;
}

/* SIDEBAR (DESKTOP) */
.sidebar {
  width: 240px;
  background-color: var(--bg-side);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 20px;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: bold;
  font-size: 1.2rem;
  padding-left: 8px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  fill: var(--accent);
}

.sidebar-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
  padding-left: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  background-color: var(--bg-card);
}

.sidebar-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-icon-sm {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
}
.btn-icon-sm:hover { color: var(--text-main); }

/* MAIN CONTENT */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(to bottom, #222222, var(--bg-main) 300px);
}

.top-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.search-bar-container {
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  padding: 8px 16px;
  border-radius: 20px;
  width: 100%;
  max-width: 400px;
  gap: 10px;
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  width: 100%;
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.user-profile {
  display: none;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  margin-left: 5px;
}

/* CONTENT AREA */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.view { display: none; }
.view.active { display: block; }

.page-title {
  font-size: 1.8rem;
  margin-bottom: 20px;
}

.empty-state-box {
  background-color: var(--bg-card);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

/* TRACK LIST & ROWS */
.track-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.track-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.track-row:hover { background-color: var(--bg-card-hover); }

.track-row-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
}

.track-row-main { flex: 1; overflow: hidden; }
.track-row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.95rem; }
.track-row-artist { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-row-project { width: 150px; font-size: 0.85rem; color: var(--text-secondary); display: none; }
@media (min-width: 768px) { .track-row-project { display: block; } }

.track-row-duration { font-size: 0.85rem; color: var(--text-secondary); margin-right: 8px; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { color: var(--text-main); }
.btn-icon.liked { color: var(--accent); }

/* BOTTOM PLAYER */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: var(--player-height);
  background-color: #000000;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
}

.player-track-info {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 30%;
  min-width: 150px;
}

.player-thumb {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
}

.player-details { overflow: hidden; }
.player-title { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 40%;
  max-width: 500px;
}

.player-buttons {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-play-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--text-main);
  color: #000;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-play-toggle:hover { transform: scale(1.05); }

.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.progress-bar {
  flex: 1;
  height: 4px;
  background-color: #404040;
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background-color: var(--accent);
  border-radius: 2px;
}

.player-right-options {
  width: 30%;
  display: flex;
  justify-content: flex-end;
}

/* CARDS GRID */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.media-card {
  background-color: var(--bg-card);
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.media-card:hover { background-color: var(--bg-card-hover); }

.card-cover-box {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.card-cover { width: 100%; height: 100%; object-fit: cover; }

.card-title { font-size: 0.85rem; font-weight: bold; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-subtitle { font-size: 0.75rem; color: var(--text-secondary); }

/* MODALS & CONTEXT MENU */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-overlay.active { display: flex; }

.modal-box {
  background: var(--bg-card);
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-input {
  width: 100%;
  padding: 10px;
  background: #2a2a2a;
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: 6px;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-action-main { background: var(--accent); color: #000; border: none; padding: 10px 16px; border-radius: 20px; font-weight: bold; cursor: pointer; }
.btn-secondary { background: transparent; color: #fff; border: none; cursor: pointer; }

.context-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 0;
  display: none;
  z-index: 3000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.context-menu.visible { display: block; }
.context-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-size: 0.85rem; cursor: pointer; }
.context-menu-item:hover { background-color: var(--bg-card-hover); }
.context-menu-item svg { width: 16px; height: 16px; fill: currentColor; }

/* MASQUAGE DES ÉLÉMENTS MOBILES SUR DESKTOP */
.mobile-bottom-nav {
  display: none !important;
}

/* ========================================================= */
/* ADAPTATIONS SMARTPHONES ET TABLETTES (<= 768px)           */
/* ========================================================= */
@media (max-width: 768px) {
  .app-container {
    height: calc(100vh - var(--player-height) - var(--bottom-nav-height)) !important;
  }

  .sidebar {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--bottom-nav-height);
    background-color: #000000;
    border-top: 1px solid var(--border-color);
    justify-content: space-around;
    align-items: center;
    z-index: 1100;
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.65rem;
    cursor: pointer;
    flex: 1;
  }

  .mobile-nav-item svg {
    width: 22px !important;
    height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
    fill: currentColor;
  }

  .mobile-nav-item.active {
    color: var(--text-main);
  }

  .player-bar {
    bottom: var(--bottom-nav-height) !important;
    height: 65px;
    padding: 0 10px;
  }

  .player-controls {
    width: auto;
  }

  .progress-bar-container,
  .player-right-options {
    display: none;
  }

  .top-header {
    padding: 0 12px;
  }

  .content-area {
    padding: 12px;
  }

  .search-mode-toggle span {
    display: none;
  }
}