/* ===== Theme (tối + mint) ===== */
:root{
  --bg: #0f1216;
  --panel: #151a21;
  --soft: #1a2029;
  --soft-2: #12161c;

  --text: #e8eef5;
  --muted: #9fb0c3;
  --border: #243041;

  --acc: #7be0c3;
  --acc-weak: #20463f;

  --sel-bg: rgba(123, 224, 195, 0.14);
  --sel-border: #2a6d5f;

  --play-bg: rgba(255, 200, 56, 0.16);
  --play-border: #8a6b19;
  --amber: #ffd166;

  --pl-bg: #151b22;     /* Thư viện playlist */
  --info-bg: #141923;   /* Thông tin */

  --shadow: 0 10px 30px rgba(0,0,0,.35);

  --accordion-speed: 0.65s;
}

*{ box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ===== Topbar (full width, sticky) ===== */
.topbar{
  position: sticky;
  top: 0;
  z-index: 1000;
  background: linear-gradient(180deg, #0e1217 0%, #0f1216 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.topbar-inner{
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto; /* 1) nowplaying, 2) audio, 3) controls */
  gap: 10px;
}
.nowplaying{
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}
.song-title{ color: var(--text); font-weight: 600; }

/* Player row: audio control chiếm full ngang */
.player-row #audio-player{
  width: 100%;
  max-width: 100%;
  display: block;
  background: transparent;
}

/* Buttons */
.controls{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.btn{
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--text);
  cursor: pointer;
}
.btn:hover{ filter: brightness(1.05); }
.btn.subtle{
  background: transparent;
  color: var(--muted);
}
.btn.linklike{
  background: transparent;
  border-color: transparent;
  color: var(--acc);
  padding-left: 0;
}
.btn.disabled,
.btn[aria-disabled="true"]{
  opacity: .6;
  pointer-events: none;
}
.random-toggle{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  user-select: none;
}

/* ===== Container & Panels (full width) ===== */
.container{
  width: 100%;
  margin: 14px auto 80px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.panel{
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel h3{
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  color: var(--muted);
  background: var(--soft-2);
}
.playlist-panel{ background: var(--pl-bg); }
.info-panel{ background: var(--info-bg); }

/* Loading text */
.loading{
  padding: 10px 14px;
  color: var(--muted);
}

/* ===== Tag chips ===== */
.tag-suggestions{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px 6px;
}
.tag-chip{
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.tag-chip:hover{ filter: brightness(1.06); }
.tag-chip.active{
  background: var(--sel-bg);
  border-color: var(--sel-border);
  color: var(--text);
}

/* ===== Accordion playlist ===== */
.accordion{ padding: 6px 8px 12px; }

.pl-group{
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 8px 6px;
  background: #0f151c;
  overflow: hidden;
}
.pl-summary{
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  align-items: center;
  user-select: none;
}
.pl-summary::-webkit-details-marker{ display: none; }
.pl-title{ font-weight: 600; }
.pl-count{ color: var(--muted); font-size: 12px; }

.pl-body{
  height: 0;
  overflow: hidden;
  transition: height var(--accordion-speed) ease;
  background: #0c1218;
}
.pl-songs{
  list-style: none;
  margin: 0;
  padding: 6px;
}
.pl-songs li{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.pl-songs li:hover{ background: rgba(255,255,255,0.04); }
.pl-songs li.active{ outline: 1px dashed var(--acc); }
.song-duration{ color: var(--muted); font-size: 12px; }
.song-name{ color: inherit; }

/* Bài đã tải offline → dùng màu chữ giống nút "Tải về" */
.pl-songs li.offline .song-name{ color: var(--acc); }

/* Highlight playlist: đang chọn (mint) & đang phát (vàng) */
.pl-group.selected{
  background: var(--acc-weak);
  border-color: var(--sel-border);
}
.pl-group.playing{
  background: var(--play-bg);
  border-color: var(--play-border);
}
.pl-group.playing .pl-title{ color: var(--amber); }

/* ===== Footer (scroll cùng nội dung, không sticky) ===== */
.footer{
  position: static;   /* <- không còn sticky */
  bottom: auto;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, #0f1216 0%, #0b0e12 100%);
  margin-top: 18px;   /* tạo khoảng cách với nội dung trên */
}

.footer-inner{
  width: 100%;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.db-status.ok{ color: #7ce38b; }
.db-status.sync{ color: #ffd166; }
.db-status.err{ color: #ff7b7b; }

/* ===== Password gate ===== */
.gate-overlay{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8,10,14,0.85);
  z-index: 2000;
  backdrop-filter: blur(2px);
}
.gate-overlay.active{ display: flex; }
.gate-card{
  width: min(94vw, 360px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.gate-card h2{ margin: 0 0 4px; font-size: 18px; }
.gate-card input{
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--soft); color: var(--text);
}
.gate-card button{
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--soft); color: var(--text); cursor: pointer;
}
.gate-card button:hover{ filter: brightness(1.05); }

/* ===== Responsive ===== */
@media (min-width: 900px){
  .topbar-inner{
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
}
