/* style.css */

/* Global Reset and Variables */
:root {
  --primary-color: #2a2a2a; /* Nền tối chính */
  --secondary-color: #121212; /* Nền tối phụ, cho sidebar */
  --text-color: #ffffff; /* Màu chữ sáng */
  --accent-color: #1ed760; /* Màu nhấn xanh lá (Spotify-like) */
  --hover-color: #404040; /* Màu nền khi hover */
  --active-color: #3b3b3b; /* Màu nền cho trạng thái active/được chọn */
  --progress-bar-fill: #1ed760;
  --progress-bar-track: #535353;
  --mobile-sidebar-width: 300px;
}

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--primary-color);
  color: var(--text-color);
  font-family: "Poppins", sans-serif;
  height: 100vh;
  overflow-x: hidden;
}

/* -------------------------------------------------------------------------- */
/* SIDEBAR LEFT                                */
/* -------------------------------------------------------------------------- */

.sidebar-left {
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  height: 100%;
  background-color: var(--secondary-color);
  padding: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease-in-out;
}

.sb-logo {
  font-size: 24px;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 30px;
  text-align: center;
}

.sb-menu,
.sb-playlists ul {
  list-style: none;
}

.sb-menu li,
.sb-playlists .sb-item {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  margin-bottom: 5px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  color: #b3b3b3; /* Màu chữ nhạt hơn cho mục menu */
  transition: color 0.2s, background-color 0.2s;
}

.sb-menu li i {
  margin-right: 10px;
  font-size: 16px;
}

.sb-menu li:hover,
.sb-playlists .sb-item:hover {
  color: var(--text-color);
}

.sb-menu li.active {
  background-color: var(--active-color);
  color: var(--text-color);
  font-weight: 600;
}

.sb-playlists {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--hover-color);
}

.sb-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b3b3b3;
  margin-bottom: 10px;
  padding: 0 15px;
}

.sb-playlists .sb-item {
  padding-left: 15px; /* Giữ padding ngang giống menu item */
}

/* -------------------------------------------------------------------------- */
/* MAIN PLAYER                                */
/* -------------------------------------------------------------------------- */

.player {
  margin-left: 250px; /* Bằng chiều rộng sidebar */
  padding: 20px;
  min-height: 100vh;
  transition: margin-left 0.3s ease-in-out;
}

/* Dashboard */
.dashboard {
  position: sticky;
  top: 0;
  background-color: var(--primary-color);
  padding: 20px 0;
  margin-bottom: 20px;
  border-radius: 10px;
  text-align: center;
  z-index: 50;
  transition: padding 0.3s, background-color 0.3s;
}

header h4 {
  color: #a7a7a7;
  font-size: 12px;
}

header h2 {
  font-size: 24px;
  margin-bottom: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* CD */
.cd {
  margin: 0 auto;
  width: 200px;
  transition: width 0.3s, opacity 0.3s; /* Thêm transition cho width và opacity */
}

.cd-thumb {
  width: 100%;
  padding-top: 100%; /* Tạo hình tròn */
  border-radius: 50%;
  background-color: #333;
  background-size: cover;
  margin-bottom: 20px;
  animation: rotate 10s linear infinite;
  animation-play-state: paused;
}

.cd-thumb.fade {
  opacity: 0;
  transition: opacity 0.4s;
}

.playing .cd-thumb {
  animation-play-state: running;
}

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

/* Control */
.control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 70px;
  padding: 18px 0;
}

.control .btn {
  color: #909090;
  padding: 18px;
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s;
}

.control .btn:hover {
  color: var(--text-color);
}

.control .btn-toggle-play {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 24px;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-color);
  margin: 0 10px;
  box-shadow: 0 0 10px rgba(30, 215, 96, 0.5);
  transition: background-color 0.2s, transform 0.1s;
}

.control .btn-toggle-play:active {
  transform: scale(0.95);
}

.control .icon-pause {
  display: none;
}

.playing .icon-pause {
  display: block;
}

.playing .icon-play {
  display: none;
}

.btn-repeat.active,
.btn-random.active {
  color: var(--accent-color) !important;
}

/* Progress */
.progress {
  width: 80%;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--progress-bar-track);
  cursor: pointer;
  outline: none;
  margin-top: 10px;
}

/* Progress bar styling (Webkit - Chrome, Safari) */
.progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: var(--progress-bar-fill);
  cursor: pointer;
}

/* Progress bar styling (Moz - Firefox) */
.progress::-moz-range-thumb {
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: var(--progress-bar-fill);
  cursor: pointer;
  border: none;
}

/* Audio element hidden */
#audio {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* PLAYLIST                                  */
/* -------------------------------------------------------------------------- */

.playlist {
  margin-top: 30px;
  padding-bottom: 80px; /* Đảm bảo có khoảng trống cuộn cuối cùng */
}

.song {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.song:hover:not(.active) {
  background-color: var(--hover-color);
}

.song.active {
  background-color: var(--active-color);
}

.song.active .body .title,
.song.active .body .author {
  color: var(--accent-color);
}

.song .thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  margin-right: 10px;
}

.song .body {
  flex-grow: 1;
  max-width: calc(100% - 100px); /* Giới hạn chiều rộng để chữ không tràn */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song .title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song .author {
  font-size: 12px;
  color: #a7a7a7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song .option {
  padding: 8px;
  font-size: 14px;
  color: #a7a7a7;
  cursor: pointer;
}

/* -------------------------------------------------------------------------- */
/* RESPONSIVE                                 */
/* -------------------------------------------------------------------------- */

/* Mobile menu button and overlay */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 101;
  font-size: 24px;
  color: var(--text-color);
  cursor: pointer;
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 99;
  display: none;
}

.sidebar-overlay.active {
  display: block;
}

/* Mobile & Tablet (<= 1024px) */
@media (max-width: 1024px) {
  /* Ẩn sidebar theo mặc định trên mobile */
  .sidebar-left {
    transform: translateX(calc(-1 * var(--mobile-sidebar-width)));
    width: var(--mobile-sidebar-width);
  }

  .sidebar-left.active {
    transform: translateX(0);
  }

  /* Kích hoạt nút menu */
  .mobile-menu-btn {
    display: block;
  }

  /* Player chiếm toàn bộ chiều rộng, không còn margin trái */
  .player {
    margin-left: 0;
    padding: 10px;
  }

  /* Đảm bảo dashboard vẫn hoạt động cuộn */
  .dashboard {
    padding: 15px 0;
  }

  /* Giới hạn kích thước CD trên màn hình nhỏ hơn */
  .cd {
    width: 180px;
  }

  header h2 {
    font-size: 20px;
  }

  .control .btn {
    padding: 12px;
    font-size: 16px;
  }

  .control .btn-toggle-play {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .progress {
    width: 90%;
  }

  .playlist {
    margin-top: 10px;
  }
}

/* Mobile (<= 740px) */
@media (max-width: 740px) {
  /* Tối ưu hóa cho màn hình điện thoại */
  .dashboard {
    /* Đảm bảo khi cuộn lên, CD sẽ co nhỏ và biến mất mượt mà */
    padding: 10px 0;
  }

  /* CD: Kích thước ban đầu nhỏ hơn */
  .cd {
    width: 150px;
  }

  header h2 {
    font-size: 18px;
  }

  .control {
    padding: 10px 0;
    gap: 50px;
  }

  .control .btn {
    padding: 10px;
  }

  .control .btn-toggle-play {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .song {
    padding: 8px 10px;
  }

  .song .title {
    font-size: 15px;
  }

  .song .author {
    font-size: 11px;
  }

  .progress {
    width: 95%;
  }
}

@media (max-width: 480px) {
  .control {
    padding: 10px 0;
    gap: 0px;
    justify-content: space-between;
  }
}

/* -------------------------------------------------------------------------- */
/* CD Rotate Animation Fix for Mobile                  */
/* -------------------------------------------------------------------------- */

/* Đảm bảo transition mượt mà cho CD khi cuộn xuống (theo chức năng JS) */
.cd {
  will-change: width, opacity;
}

/* Đảm bảo sidebar transition mượt mà */
.sidebar-left {
  will-change: transform;
}

/* style.css (đã có trong câu trả lời trước) */

.sb-menu li,
.sb-playlists .sb-item {
  /* ... (các style mặc định) */
  color: #b3b3b3; /* Màu chữ nhạt hơn cho mục menu */
  transition: color 0.2s, background-color 0.2s;
}

/* Style cho trạng thái ACTIVE */
.sb-playlists .sb-item.active {
  background-color: var(--active-color); /* Nền tối hơn */
  color: var(--text-color); /* Chữ trắng sáng */
  font-weight: 600; /* In đậm */
}

.time {
  display: flex;
  justify-content: space-between;
  width: 80%;
  margin: 6px auto 0;
  font-size: 12px;
  color: #b3b3b3;
}
