@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&display=swap');

:root {
  /* Royal Night Palette */
  --bg-dark: #02040a;
  --bg-panel: #0f172a;

  /* Glass Variables */
  --glass-surface: rgba(15, 23, 42, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.03);

  /* Accents (Elegant Gold/Amber) */
  --primary: #fbbf24; /* Soft Gold */
  --primary-glow: rgba(251, 191, 36, 0.3);
  --secondary: #d97706; /* Darker Amber */

  /* Text */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --radius: 24px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: "Outfit", sans-serif; }
html, body { height: 100%; }

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-dark);
  /* Deep atmospheric background */
  background-image: 
    radial-gradient(at 0% 0%, rgba(251, 191, 36, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(15, 23, 42, 0.5) 0px, transparent 50%);
  color: var(--text-main);
  padding: 20px;
  overflow: hidden;
}

/* ============================= */
/* MAIN CONTAINER */
/* ============================= */
.app-container {
  width: 100%;
  max-width: 450px;
  height: 85vh;
  min-height: 600px;
  border-radius: var(--radius);
  position: relative;
  background: var(--glass-surface);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: grid;
  grid-template-columns: 1fr;
  transition: max-width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}

.app-container.playlist-active {
  max-width: 900px;
  grid-template-columns: 1fr 380px;
}

/* ============================= */
/* PLAYER SECTION */
/* ============================= */
.player-section {
  padding: 30px;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 2;
}

/* --- Top Bar --- */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.timer-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition);
}

.timer-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--primary);
  border-color: var(--primary);
}

.search-wrapper { flex: 1; margin-right: 10px; position: relative; }
#searchInput {
  width: 100%; padding: 10px 15px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: white; outline: none;
  font-size: 14px;
}

/* Timer Popup */
.timer-popup {
  position: absolute;
  top: 75px; right: 30px;
  width: 200px;
  background: #1e293b;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 15px;
  display: none;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.timer-popup.active { display: block; animation: fadeIn 0.2s ease; }
.timer-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.timer-options button {
  background: rgba(255,255,255,0.05); border: none; padding: 6px;
  border-radius: 8px; color: var(--text-muted); cursor: pointer;
}
.timer-options button:hover { background: var(--primary); color: #000; }

/* --- Cover Art --- */
.cover-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 10px 0 25px 0;
}
.cover-wrapper img {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0 20px 40px -5px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.1);
}

/* --- Track Info & Volume Meta --- */
.meta-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
  width: 100%;
}

.track-info { flex: 1; text-align: center; }
.track-info h2 { 
  font-size: 22px; font-weight: 600; color: var(--text-main); margin-bottom: 6px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.track-info p { font-size: 14px; color: var(--primary); letter-spacing: 0.5px; font-weight: 500; }

/* Volume Styling */
.volume-wrapper { position: relative; }
#volumeBtn {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
#volumeBtn:hover { background: rgba(255,255,255,0.1); color: var(--primary); }

.volume-popup {
  position: absolute;
  bottom: 50px; left: 0;
  width: 40px; height: 120px;
  background: #1e293b;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 15px 0;
  display: flex; justify-content: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: all 0.3s ease;
  z-index: 10;
}
.volume-popup.show { opacity: 1; pointer-events: auto; visibility: visible; bottom: 55px; }

#volumeSlider {
  width: 4px; height: 100%;
  -webkit-appearance: slider-vertical;
}

/* --- Progress Bar --- */
.progress-container { display: flex; align-items: center; gap: 12px; margin-bottom: 25px; }
.progress-container span { font-size: 11px; color: var(--text-muted); width: 35px; }

input[type="range"] {
  -webkit-appearance: none; flex: 1; height: 4px;
  background: rgba(255,255,255,0.1); border-radius: 4px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px;
  background: var(--primary); border-radius: 50%;
  box-shadow: 0 0 15px var(--primary);
}

/* --- Controls --- */
.controls {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding: 0 10px;
}
.controls button {
  background: transparent; border: none; color: var(--text-main);
  font-size: 18px; cursor: pointer; transition: var(--transition);
  width: 45px; height: 45px; display: grid; place-items: center; border-radius: 50%;
}
.controls button:hover { color: var(--primary); background: rgba(255,255,255,0.03); }

.play-btn {
  width: 70px !important; height: 70px !important; font-size: 24px !important;
  background: linear-gradient(135deg, var(--primary), var(--secondary)) !important;
  color: #000 !important;
  box-shadow: 0 10px 25px rgba(217, 119, 6, 0.4);
}
.play-btn:hover { transform: scale(1.05); }

/* ============================= */
/* PLAYLIST SECTION (Desktop) */
/* ============================= */
.playlist-section {
  background: rgba(0,0,0,0.2);
  border-left: 1px solid var(--glass-border);
  padding: 25px;
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.app-container.playlist-active .playlist-section { display: flex; }

.playlist-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--glass-border);
}

#playlist-ul { list-style: none; overflow-y: auto; flex: 1; }
#playlist-ul::-webkit-scrollbar { width: 4px; }
#playlist-ul::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }

#playlist-ul li {
  padding: 12px 15px; margin-bottom: 8px; border-radius: 12px;
  background: rgba(255,255,255,0.02); color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; gap: 12px; font-size: 14px;
}
#playlist-ul li.active {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.1), transparent);
  border-left: 3px solid var(--primary); color: var(--primary);
}

/* ============================= */
/* MOBILE POPUP LIST */
/* ============================= */
.music-list {
  position: fixed; bottom: -100%; left: 0; right: 0;
  background: #111827; border-radius: 24px 24px 0 0;
  padding: 25px; z-index: 1000; height: 60vh;
  display: flex; flex-direction: column;
  transition: bottom 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.music-list.show { bottom: 0; }
#music-list-ul { list-style: none; overflow-y: auto; }
#music-list-ul li {
  padding: 15px; border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--text-muted); display: flex; gap: 15px; align-items: center;
}
#music-list-ul li.active { color: var(--primary); }

/* ============================= */
/* RESPONSIVE */
/* ============================= */
@media (max-width: 950px) {
  .app-container.playlist-active { max-width: 450px; grid-template-columns: 1fr; }
  .playlist-section { display: none !important; }
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Keep search bar focused and clear while playlist expands */
#searchInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    background: rgba(0, 0, 0, 0.4);
}

/* Ensure the playlist section appears smoothly */
.playlist-section {
    animation: fadeIn 0.4s ease-out;
}