/* =========================================
   CORE & BACKGROUND
   ========================================= */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%; 
  overflow: hidden;
  background-color: #000000;
}

#bg-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; 
  pointer-events: none;
}

#video-container {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: black;
  transition: opacity 1.5s ease-in-out;
}

.fade-out {
  opacity: 0;
}

.fade-in {
  opacity: 1;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle, rgba(10, 25, 47, 0.3) 0%, rgba(10, 25, 47, 0.7) 100%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.1;
  backdrop-filter: blur(15px); 
  -webkit-backdrop-filter: blur(15px);
  z-index: 2; 
  pointer-events: none;
}

/* WRAPPER */
.main-wrapper {
  position: fixed;
  inset: 0; 
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom) 20px;
  box-sizing: border-box;
  z-index: 10;
}

/* =========================================
   BASE PLAYER CARD (Optimized for FHD/4K/Mobile)
   ========================================= */
.player-card {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top: 1px solid rgba(255, 255, 255, 0.4);
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  width: 100%;
  max-width: 360px;
  border-radius: 2rem;
  padding: 1.5rem;
  
  /* FITUR ANTI LUBER */
  max-height: 95vh; 
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.cover-image {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 1rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  transition: transform 0.3s ease;
  display: block;
  margin: 0 auto;
  flex-shrink: 0; /* Mencegah gambar gepeng saat layar sempit */
}

.song-title { 
  font-size: 1.15rem; 
  font-weight: bold; 
  color: #ffffff; 
  text-align: center; 
}

.song-meta-text p,
.song-meta-text span {
    color: #ffffff !important;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5) !important;
    letter-spacing: 0.02em;
}

.song-meta-text { 
    font-size: 0.8rem; 
    color: #ffffff !important;
    opacity: 1 !important;
    text-align: center; 
    margin-top: 8px; 
    margin-bottom: 10px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.duration-text { 
    font-size: 0.7rem; 
    color: #ffffff !important; 
    opacity: 1 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Seek Bar */
.seek-bar {
  width: 100%; height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px; 
  appearance: none; 
  outline: none;

  background-image: linear-gradient(#f01657, #f01657);
  background-size: 0% 100%;
  background-repeat: no-repeat;
}
.seek-bar::-webkit-slider-thumb {
  appearance: none; 
  width: 14px; 
  height: 14px;
  background: #e4e4e7; 
  border-radius: 50%;
}

/* Controls */
.controls-container {
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}
.controls-container button {
    color: rgba(255, 255, 255, 0.8) !important;
    opacity: 1;
    transition: all 0.2s ease; 
    background: none; 
    border: none; 
    cursor: pointer;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.controls-container button.active-control {
  color: #f01657 !important;
  filter: drop-shadow(0 0 8px rgba(240, 22, 87, 1));
}

.controls-container button:hover { 
  color: #ffffff !important; 
  transform: scale(1.15); 
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}
.controls-container button:active { transform: scale(0.9); }

.play-btn {
    color: #f01657 !important;
    padding: 1.1rem; 
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
}

/* Icon sizes */
.icon-sm { width: 18px; height: 18px;}
.icon-md { width: 28px; height: 28px;}
.icon-lg { width: 24px; height: 24px;}

/* Search & Playlist */
.search-input {
  width: 100%; background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2); border-radius: 0.75rem;
  padding: 0.6rem 1rem; color: #e4e4e7; outline: none;
  font-size: 16px;
  flex-shrink: 0;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.playlist-title { 
  font-size: 0.8rem; 
  color: #ffffff !important;
  opacity: 1; 
  text-transform: uppercase; 
  letter-spacing: 0.1em; 
  margin-top: 10px;
}

/* Playlist Area (Scrollable & Optimized) */
.song-list-container { 
  flex-grow: 1; /* Mengambil sisa ruang kartu */
  overflow-y: auto; 
  padding-right: 5px; 
  margin-top: 8px;
  min-height: 0; /* Penting untuk Flexbox */
}

/* Custom Scrollbar Playlist */
.song-list-container::-webkit-scrollbar {
    width: 4px;
}
.song-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

#song-list li {
  padding: 4px 12px; 
  border-radius: 8px; 
  cursor: pointer;
  font-size: 0.7rem; 
  transition: background 0.2s; 
  margin-bottom: 2px;
  list-style: none; 
  color: #ffffff !important;
}

#song-list li span {
  color: rgba(255, 255, 255, 0.7) !important;
}

#song-list li:hover { background: rgba(240, 22, 87, 1); }
#song-list li.active-song { 
    background: #f01657 !important; 
    color: #ffffff !important;
}
#song-list li.active-song span {
    color: #ffffff !important;
    opacity: 1 !important;
}

/* =========================================
   RESPONSIVE: PC / TABLET / 4K
   ========================================= */
@media (min-width: 768px) {
  .player-card {
    max-width: 500px; 
    padding: 2.5rem;
    max-height: 90vh !important;
  }
  .cover-image { width: 250px; height: 250px; }
  .song-title { font-size: 1.5rem; margin-bottom: 0.5rem; }
  .song-meta-text { font-size: 0.85rem; }
  .duration-text { font-size: 0.8rem; }
  
  .icon-sm { width: 22px; height: 22px; }
  .icon-md { width: 34px; height: 34px; }
  .icon-lg { width: 32px; height: 32px; }
  
  .play-btn { padding: 1.25rem; }
  .search-input { padding: 0.75rem 1rem; }
  .playlist-title { font-size: 0.8rem; margin-bottom: 10px; }

  /* FIX 4K LUBER: Playlist elastis tapi mentok di 7-8 lagu */
  .song-list-container {
    flex-grow: 0 !important;
    height: auto !important; 
    /* Di 4K layar lebih lega, kita bisa set max-height sedikit lebih tinggi 
       sekitar 280px-300px agar muat 7-8 lagu dengan padding PC */
    max-height: 300px !important; 
    overflow-y: auto !important;
    margin-top: 15px !important;
  }
  
  /* Di PC, playlist bisa lebih panjang tapi tetap aman karena max-height kartu */
  #song-list li { font-size: 0.85rem; padding: 8px 14px; }
}

/* =========================================
   FIX KHUSUS DESKTOP RESOLUSI RENDAH (FHD)
   Aktif jika lebar layar PC >= 1024px DAN tinggi layar <= 1000px
   (Ini tidak akan mengganggu tampilan HP karena HP lebarnya kecil)
   ========================================= */
@media (min-width: 1024px) and (max-height: 1000px) {
  
  /* 1. Paksa Card Player Center & Fit di layar */
  .player-card {
    max-height: 90vh !important; /* Batasi tinggi total kartu */
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    /* Sedikit kurangi padding luar agar space konten lebih luas */
    padding: 1rem !important; 
    max-width: 350px !important; /* Sedikit rampingkan di FHD */
  }

  /* 2. Kecilkan Cover Art agar hemat tempat */
  .cover-image {
    width: 130px !important; /* Dari aslinya 160px/250px */
    height: 130px !important;
    margin-bottom: 0.5rem !important;
  }

  /* 3. Padatkan area teks informasi lagu */
  .song-title {
    font-size: 1rem !important;
  }
  .song-meta-text {
    margin-top: 4px !important;
    margin-bottom: 4px !important;
    font-size: 0.75rem !important;
  }
  .song-meta-text p {
    margin: 1px 0 !important; /* Rapatkan jarak antar baris */
  }

  /* 4. Padatkan area Controls (tombol-tombol) */
  .controls-container {
    margin-bottom: 0.75rem !important;
  }
  /* Kecilkan padding tombol play biar gak makan tempat */
  .play-btn {
    padding: 0.8rem !important;
  }
  
  /* 5. Padatkan Input Search */
  .search-input {
    padding: 0.5rem 0.75rem !important;
    font-size: 14px !important;
  }

  /* 6. Atur ulang Playlist Container agar Fit & Scroll */
  .playlist-title {
    margin-top: 5px !important;
    margin-bottom: 5px !important;
  }

  .song-list-container {
    flex-grow: 0 !important; /* Paksa ambil sisa ruang */
    overflow-y: auto !important; /* Aktifkan scrollbar */
    height: auto !important;
    max-height: 195px !important;
    min-height: 0 !important;
    margin-top: 5px !important;
    padding-bottom: 5px; /* Sedikit nafas di bawah */
  }

  .song-list-container::-webkit-scrollbar {
    display: none; 
  }

  /* 7. Padatkan jarak list lagu */
  #song-list li {
    padding: 6px 10px !important;
    font-size: 0.65rem !important;
    line-height: 1.2 !important;
    margin-bottom: 2px !important;
  }
}

/* =========================================
   FIX KHUSUS SMARTPHONE (iOS / 6.1" Focus)
   Optimasi untuk Add to Home Screen
   ========================================= */
@media (max-width: 500px) {
  
  #bg-video {
    /* 50% horizontal (tengah), 60% vertical (agak turun) 
       Ubah 60% ke angka lebih besar (misal 70%) kalau mau lebih turun lagi */
    object-position: 50% 100% !important;
  }

  /* 1. Hilangkan area hitam & pastikan wrapper memenuhi layar penuh */
  .main-wrapper {
    padding: 0 !important;
    height: 100vh !important;
    height: -webkit-fill-available !important; /* Fix untuk iOS Safari */
    display: flex !important;
    align-items: flex-end !important; /* Kita ganti ke flex-end agar bisa kita dorong dari bawah */
    justify-content: center !important;
    padding-bottom: 40px !important; /* Atur jarak kartu dari ujung bawah layar (Home Bar) */
  }

  /* 2. Turunkan posisi kartu agar tidak terlalu 'nyundul' ke atas */
  .player-card {
    margin-top: 20px !important; /* Memberi jarak dari area notch/jam */
    /* Kalau mau diturunkan lagi secara manual, ubah angka 10px ini (makin besar makin turun) */
    transform: translateY(60px) !important;
    max-height: 85vh !important; /* Sisakan ruang di bawah agar tidak luber */
    padding: 1.2rem !important;
    width: 88% !important;
  }

  /* 3. Kecilkan Cover Art dikit lagi buat ruang playlist */
  .cover-image {
    width: 130px !important;
    height: 130px !important;
  }

  /* 4. Batasi Playlist Mentok 5 Lagu (Mode Smartphone) */
  .song-list-container {
    flex-grow: 0 !important;
    height: auto !important;
    /* Tinggi sekitar 145px - 155px biasanya pas untuk 5 lagu di HP */
    max-height: 145px !important; 
    overflow-y: auto !important;
    margin-top: 5px !important;
    padding-bottom: 5px !important;
  }

  /* 5. Sembunyikan scrollbar di HP agar estetik */
  .song-list-container::-webkit-scrollbar {
    display: none !important;
  }

  /* 6. Rapikan jarak antar lagu di HP */
  #song-list li {
    padding: 6px 10px !important;
    font-size: 0.7rem !important;
    margin-bottom: 2px !important;
  }
}

/* =========================================
   FIX KHUSUS IPHONE 4.7" (SE / 7 / 8)
   Fokus: Mencegah luber di layar pendek
   ========================================= */
@media (max-height: 670px) and (max-width: 400px) {
  
  /* 1. Perkecil padding utama agar kartu tidak terlalu tinggi */
  .player-card {
    padding: 1rem !important;
    transform: translateY(60px) !important; /* Kurangi dorongan ke bawah agar muat */
    max-height: 95vh !important;
  }

  /* 2. Cover Art diperkecil lagi */
  .cover-image {
    width: 110px !important;
    height: 110px !important;
    margin-bottom: 0.25rem !important;
  }

  /* 3. Rapikan teks meta agar tidak makan tempat */
  .song-title {
    font-size: 0.95rem !important;
  }
  .song-meta-text {
    font-size: 0.7rem !important;
    margin-top: 2px !important;
    margin-bottom: 5px !important;
  }
  .song-meta-text p {
    margin: 0 !important;
  }

  /* 4. Controls sedikit dipadatkan */
  .controls-container {
    margin-bottom: 0.5rem !important;
  }
  .play-btn {
    padding: 0.6rem !important;
  }
  .icon-md { width: 24px; height: 24px; }
  .icon-lg { width: 22px; height: 22px; }

  /* 5. PEMBATASAN PLAYLIST (3-4 Lagu) */
  .song-list-container {
    /* Tinggi sekitar 100px - 115px biasanya pas untuk 3-4 lagu */
    max-height: 110px !important; 
    margin-top: 4px !important;
  }

  #song-list li {
    padding: 5px 10px !important;
    font-size: 0.65rem !important;
  }

  .playlist-title {
    margin-top: 2px !important;
    margin-bottom: 4px !important;
    font-size: 0.7rem !important;
  }
}