/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --surface: #1e1e2a;
  --surface2: #252535;
  --border: rgba(255,255,255,0.07);
  --accent: #e8ff47;
  --accent2: #ff4f8b;
  --text: #f0f0f8;
  --text2: #888899;
  --text3: #555566;
  --player-h: 80px;
  --topbar-h: 60px;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--bg2); border-right: 1px solid var(--border);
  z-index: 200; display: flex; flex-direction: column; gap: 0;
  transform: translateX(-100%); transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.sidebar.open { transform: translateX(0); }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 16px; }
.logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 22px; letter-spacing: -0.5px; color: var(--accent); }
.sidebar-close { background: none; border: none; color: var(--text2); font-size: 16px; cursor: pointer; padding: 4px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.nav-btn {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--text2); font-family: 'DM Sans', sans-serif;
  font-size: 14px; font-weight: 500; cursor: pointer; text-align: left; transition: all .2s;
}
.nav-btn:hover { background: var(--surface); color: var(--text); }
.nav-btn.active { background: var(--surface); color: var(--accent); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-playlists { padding: 20px 12px; flex: 1; overflow-y: auto; }
.sidebar-playlists .section-label { margin-bottom: 10px; }
.pl-sidebar-item {
  padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
  color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: all .2s;
}
.pl-sidebar-item:hover { background: var(--surface); color: var(--text); }

/* ===== OVERLAY ===== */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 150; display: none; }
.overlay.show { display: block; }

/* ===== APP LAYOUT ===== */
.app { display: flex; flex-direction: column; height: 100vh; padding-left: 0; }

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h); background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 16px; flex-shrink: 0; position: relative; z-index: 10;
}
.menu-btn { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; padding: 4px 8px; }
.topbar-logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 18px; color: var(--accent); flex-shrink: 0; }
.topbar-search-wrap { flex: 1; display: flex; gap: 0; max-width: 480px; margin: 0 auto; }
.topbar-search {
  flex: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-family: 'DM Sans', sans-serif;
  font-size: 14px; outline: none; transition: border-color .2s;
}
.topbar-search:focus { border-color: var(--accent); }
.topbar-search-btn {
  background: var(--accent); border: none; color: #000; padding: 8px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; cursor: pointer; font-size: 16px; transition: opacity .2s;
}
.topbar-search-btn:hover { opacity: .85; }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1; overflow-y: auto; padding: 24px 20px;
  padding-bottom: calc(var(--player-h) + 20px);
}

/* ===== VIEWS ===== */
.view { display: none; }
.view.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: 20px; padding: 40px 32px; margin-bottom: 8px; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -40%; right: -10%; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(232,255,71,0.12) 0%, transparent 70%); pointer-events: none;
}
.hero-text { margin-bottom: 28px; }
.hero-text h1 { font-family: 'Syne', sans-serif; font-size: clamp(28px, 5vw, 48px); font-weight: 800; line-height: 1.1; letter-spacing: -1px; }
.hero-text h1 span { color: var(--accent); }
.hero-text p { color: var(--text2); margin-top: 10px; font-size: 15px; }
.hero-search { display: flex; gap: 0; max-width: 520px; }
.search-big {
  flex: 1; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: var(--text); padding: 14px 20px; border-radius: var(--radius) 0 0 var(--radius);
  font-family: 'DM Sans', sans-serif; font-size: 15px; outline: none; backdrop-filter: blur(10px);
  transition: border-color .2s;
}
.search-big:focus { border-color: var(--accent); }
.search-big::placeholder { color: rgba(255,255,255,0.4); }
.search-big-btn {
  background: var(--accent); border: none; color: #000; padding: 14px 24px; font-weight: 700;
  border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; font-family: 'Syne', sans-serif;
  font-size: 14px; letter-spacing: 0.5px; transition: opacity .2s;
}
.search-big-btn:hover { opacity: .9; }

/* ===== SECTION LABEL ===== */
.section-label { font-size: 11px; font-weight: 700; letter-spacing: 2px; color: var(--text3); text-transform: uppercase; }

/* ===== TRACK LIST ===== */
.track-list { display: flex; flex-direction: column; gap: 2px; }
.track-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s; position: relative;
}
.track-item:hover { background: var(--surface); }
.track-item.playing { background: rgba(232,255,71,0.07); }
.track-item.playing .track-title { color: var(--accent); }
.track-num {
  width: 24px; text-align: center; font-size: 13px; color: var(--text3); flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.track-item.playing .track-num { color: var(--accent); }
.track-thumb {
  width: 44px; height: 44px; border-radius: 8px; background: var(--surface2); flex-shrink: 0;
  overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--text3); font-size: 18px;
}
.track-thumb img { width: 100%; height: 100%; object-fit: cover; }
.track-info { flex: 1; min-width: 0; }
.track-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-artist { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.track-duration { font-size: 12px; color: var(--text3); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.track-actions { display: flex; gap: 4px; flex-shrink: 0; }
.track-fav-btn, .track-add-btn {
  background: none; border: none; color: var(--text3); cursor: pointer; font-size: 14px;
  padding: 4px 6px; border-radius: 6px; transition: all .15s; opacity: 0;
}
.track-item:hover .track-fav-btn,
.track-item:hover .track-add-btn { opacity: 1; }
.track-fav-btn.active { color: var(--accent2); opacity: 1; }
.track-fav-btn:hover { color: var(--accent2); background: rgba(255,79,139,0.1); }
.track-add-btn:hover { color: var(--accent); background: rgba(232,255,71,0.1); }

/* Skeleton */
.skeleton {
  height: 60px; background: var(--surface); border-radius: var(--radius-sm); margin: 2px 0;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{ opacity: .4; } 50%{ opacity: .8; } }

/* ===== SEARCH PAGE ===== */
.search-page-header { margin-bottom: 24px; }
.search-page-header h2 { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; margin-bottom: 16px; }
.search-wrap { display: flex; gap: 0; }
.search-inp {
  flex: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: var(--radius) 0 0 var(--radius); font-family: 'DM Sans', sans-serif;
  font-size: 15px; outline: none; transition: border-color .2s;
}
.search-inp:focus { border-color: var(--accent); }
.btn-search {
  background: var(--accent); border: none; color: #000; padding: 12px 22px;
  border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; font-size: 18px; font-weight: 700; transition: opacity .2s;
}
.btn-search:hover { opacity: .85; }

/* ===== FAVORITES ===== */
#view-favorites h2, #view-playlists h2 { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; margin-bottom: 20px; }

/* ===== PLAYLISTS ===== */
.playlists-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.btn-create {
  background: var(--accent); color: #000; border: none; padding: 10px 18px; border-radius: var(--radius-sm);
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; cursor: pointer; transition: opacity .2s;
}
.btn-create:hover { opacity: .85; }
.playlists-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.playlist-card {
  background: var(--surface); border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: transform .2s, background .2s; position: relative;
}
.playlist-card:hover { transform: translateY(-2px); background: var(--surface2); }
.playlist-card-cover {
  width: 100%; aspect-ratio: 1; border-radius: var(--radius-sm); background: var(--surface2);
  display: flex; align-items: center; justify-content: center; font-size: 32px; margin-bottom: 12px;
  overflow: hidden; position: relative;
}
.playlist-card-cover-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; width: 100%; height: 100%; }
.playlist-card-cover-grid img { width: 100%; height: 100%; object-fit: cover; }
.playlist-card-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist-card-count { font-size: 12px; color: var(--text2); margin-top: 4px; }
.playlist-card-del {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.5); border: none;
  color: var(--text2); border-radius: 50%; width: 24px; height: 24px; cursor: pointer; display: none;
  align-items: center; justify-content: center; font-size: 12px; transition: color .15s;
}
.playlist-card:hover .playlist-card-del { display: flex; }
.playlist-card-del:hover { color: var(--accent2); }

/* ===== PLAYLIST DETAIL ===== */
.back-btn {
  background: none; border: none; color: var(--text2); cursor: pointer; font-size: 14px; padding: 0;
  margin-bottom: 20px; display: flex; align-items: center; gap: 8px; transition: color .15s;
}
.back-btn:hover { color: var(--text); }
.playlist-detail-header { display: flex; gap: 24px; align-items: flex-end; margin-bottom: 32px; }
.playlist-cover-big {
  width: 140px; height: 140px; border-radius: var(--radius); background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 48px; flex-shrink: 0; overflow: hidden;
}
.playlist-detail-info h2 { font-family: 'Syne', sans-serif; font-size: 24px; font-weight: 800; margin: 6px 0 4px; }
.playlist-detail-info p { color: var(--text2); font-size: 13px; margin-bottom: 16px; }
.btn-play-all {
  background: var(--accent); color: #000; border: none; padding: 10px 22px; border-radius: 50px;
  font-weight: 700; font-family: 'Syne', sans-serif; font-size: 13px; cursor: pointer; transition: opacity .2s;
}
.btn-play-all:hover { opacity: .85; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .3; }
.empty-state p { color: var(--text2); line-height: 1.6; }

/* ===== PLAYER BAR ===== */
.player-bar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--player-h);
  background: rgba(14,14,20,0.96); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border); display: flex; align-items: center;
  gap: 12px; padding: 0 16px; z-index: 100;
}
.player-track-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; max-width: 260px; }
.player-thumb {
  width: 44px; height: 44px; border-radius: 8px; background: var(--surface); flex-shrink: 0;
  overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--text3); font-size: 18px;
}
.player-thumb img { width: 100%; height: 100%; object-fit: cover; }
.player-meta { min-width: 0; flex: 1; }
.player-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.fav-btn { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; flex-shrink: 0; transition: color .15s; }
.fav-btn.active { color: var(--accent2); }
.fav-btn:hover { color: var(--accent2); }
.player-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ctrl-btn {
  background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px;
  padding: 6px; border-radius: 50%; transition: all .15s;
}
.ctrl-btn:hover { color: var(--text); background: var(--surface); }
.ctrl-btn.play-pause {
  background: var(--accent); color: #000; width: 38px; height: 38px; font-size: 14px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
}
.ctrl-btn.play-pause:hover { opacity: .9; background: var(--accent); }
.shuffle-btn.active { color: var(--accent); }
.player-right { flex: 1; display: flex; flex-direction: column; gap: 6px; max-width: 320px; min-width: 0; }
.progress-wrap { display: flex; align-items: center; gap: 8px; }
.time { font-size: 10px; color: var(--text3); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.progress-bar {
  flex: 1; height: 3px; background: var(--surface2); border-radius: 2px; cursor: pointer;
  position: relative; transition: height .15s;
}
.progress-bar:hover { height: 5px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; transition: width .5s linear; }
.volume-wrap { display: flex; align-items: center; gap: 8px; }
.vol-icon { font-size: 12px; }
.volume-slider {
  flex: 1; -webkit-appearance: none; appearance: none; height: 3px;
  background: var(--surface2); border-radius: 2px; outline: none; cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text); cursor: pointer;
}
.add-to-playlist-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text2);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .15s;
}
.add-to-playlist-btn:hover { background: var(--surface2); color: var(--accent); border-color: var(--accent); }

/* ===== MODALS ===== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 300;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal.open { display: flex; animation: fadeIn .2s ease; }
.modal-box {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 24px; width: 100%; max-width: 360px;
}
.modal-title { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 800; margin-bottom: 20px; }
.modal-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: var(--radius-sm); font-family: 'DM Sans', sans-serif;
  font-size: 14px; outline: none; margin-bottom: 20px; transition: border-color .2s;
}
.modal-input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-btn {
  padding: 10px 20px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; transition: opacity .2s;
}
.modal-btn.cancel { background: var(--surface); color: var(--text2); }
.modal-btn.confirm { background: var(--accent); color: #000; }
.modal-btn:hover { opacity: .85; }
.playlist-pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; margin-bottom: 20px; }
.playlist-pick-item {
  padding: 12px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
  background: var(--surface); transition: background .15s; display: flex; align-items: center; gap: 10px;
}
.playlist-pick-item:hover { background: var(--surface2); color: var(--accent); }
.playlist-pick-icon { font-size: 18px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: calc(var(--player-h) + 16px); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface2); color: var(--text); padding: 10px 20px; border-radius: 50px;
  font-size: 13px; z-index: 400; opacity: 0; transition: all .3s; pointer-events: none; white-space: nowrap;
  border: 1px solid var(--border);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== LOADING OVERLAY ===== */
.searching-overlay {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 40px; color: var(--text2); font-size: 14px;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--surface2);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .player-right { display: none; }
  .player-track-info { max-width: 180px; }
  .hero { padding: 28px 20px; }
  .hero-text h1 { font-size: 26px; }
  .hero-search { flex-direction: column; gap: 10px; }
  .search-big, .search-big-btn { border-radius: var(--radius) !important; }
  .playlists-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .playlist-detail-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .playlist-cover-big { width: 100%; height: 180px; }
}
@media (max-width: 400px) {
  .player-controls .ctrl-btn:first-child,
  .player-controls .ctrl-btn:last-child { display: none; }
  .player-track-info { max-width: 140px; }
}

/* ===== SEARCH SUGGESTIONS ===== */
.topbar-search-wrap {
  position: relative;
}
.search-wrap {
  position: relative;
}
.hero-search {
  position: relative;
}
.search-suggestions {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg2, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: 10px;
  z-index: 999;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  margin-top: 4px;
}
.sugg-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text1, #fff);
  display: flex;
  gap: 8px;
  align-items: center;
  transition: background 0.15s;
}
.sugg-item:hover {
  background: var(--accent, #7c3aed22);
}
.sugg-item span {
  color: var(--text3, #888);
  font-size: 12px;
}

/* ===== BRASIL FLAG BADGE ===== */
#brasilTopList {
  border-left: 3px solid #009c3b;
  padding-left: 4px;
  margin-bottom: 8px;
}

/* ===== GENRE CHIPS ===== */
.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.genre-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.genre-chip:hover {
  background: var(--surface2);
  color: var(--text);
}
.genre-chip.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

/* ===== RECENT SEARCHES ===== */
.recent-searches {
  margin-bottom: 16px;
}
.recent-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  margin: 0 6px 6px 0;
  transition: all .2s;
}
.recent-chip:hover {
  background: var(--surface2);
  color: var(--text);
}
.recent-chip span {
  color: var(--text3);
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 50%;
  transition: background .15s;
}
.recent-chip span:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}
