/* ==========================================================================
   1. Variabel Global & Pengaturan Dasar
   ========================================================================== */
:root {
  --primary-color: #3498db; /* Soft Blue */
  --secondary-color: #2980b9;
  --background-color: #f8f9fa;
  --surface-color: #ffffff;
  --text-color: #2c3e50;
  --text-secondary: #7f8c8d;
  --border-color: #e1e8ed;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --hover-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
  --navbar-height: 70px;
  --bottom-nav-height: 70px;
}

[data-theme="dark"] {
  --background-color: #1a1a1a;
  --surface-color: #2d2d2d;
  --text-color: #ffffff;
  --text-secondary: #b0b0b0;
  --border-color: #404040;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  --hover-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.6;
}

/* Kelas untuk mengunci scroll body saat modal terbuka */
.body-modal-open {
  overflow: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ==========================================================================
   2. Navigasi (Atas & Bawah)
   ========================================================================== */
.navbar {
  background-color: var(--surface-color);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--navbar-height);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 100%;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  color: var(--primary-color);
  font-size: 1.5rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.3s ease, color 0.3s ease;
}
.logo:hover {
  transform: scale(1.05);
  color: var(--secondary-color);
}

.nav-center {
  flex: 1;
  max-width: 500px;
  margin: 0 1rem;
}

.search-container {
  display: flex;
  width: 100%;
}

.search-input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 25px 0 0 25px;
  background-color: var(--surface-color);
  color: var(--text-color);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.3s ease;
}
.search-input:focus {
  border-color: var(--primary-color);
}

.search-btn {
  padding: 0.6rem 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0 25px 25px 0;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
.search-btn:hover {
  background-color: var(--secondary-color);
}

.theme-toggle {
  background: none;
  border: 2px solid var(--border-color);
  color: var(--text-color);
  padding: 0.6rem;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
}
.theme-toggle:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.bottom-nav {
  display: none; /* Defaultnya tersembunyi */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--surface-color);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  height: var(--bottom-nav-height);
  justify-content: space-around;
  align-items: center;
  padding: 0.5rem;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  min-width: 60px;
}
.bottom-nav-item.active {
  color: var(--primary-color);
}

/* ==========================================================================
   3. Konten Utama (Filter & Grid Video)
   ========================================================================== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.category-filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 2rem;
  padding: 0.5rem 0;
}

.filter-btn {
  padding: 0.6rem 1.25rem;
  border: 2px solid var(--border-color);
  background-color: var(--surface-color);
  color: var(--text-color);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 0.9rem;
}
.filter-btn:hover, .filter-btn.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.video-card {
  background-color: var(--surface-color);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  cursor: pointer;
}
.video-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--hover-shadow);
}

.video-thumbnail {
  width: 100%;
  aspect-ratio: 16 / 9;
  position: relative;
  background-color: #e0e0e0;
}
.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.3s ease;
}
.video-card:hover .play-overlay {
  background-color: var(--primary-color);
  transform: translate(-50%, -50%) scale(1.1);
}

.video-info {
  padding: 1.25rem;
}

.video-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-color);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-description {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ==========================================================================
   4. Halaman Pencarian
   ========================================================================== */
.search-page-container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
  text-align: center;
}
.search-page-container h2 {
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
}
.search-box {
  display: flex;
  margin-bottom: 2.5rem;
}
#mainSearchInput {
  flex-grow: 1;
  padding: 0.8rem 1.2rem;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 25px 0 0 25px;
  background-color: var(--surface-color);
  color: var(--text-color);
  outline: none;
}
#mainSearchInput:focus {
  border-color: var(--primary-color);
}
#mainSearchBtn {
  padding: 0.8rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0 25px 25px 0;
  cursor: pointer;
  font-size: 1.1rem;
}
.search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  text-align: left;
}
.vidtapz-pick-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: bold;
  background-color: var(--primary-color);
  color: white;
  margin-left: 8px;
}

/* ==========================================================================
   5. Modal Video Player
   ========================================================================== */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

.modal-content {
  background-color: var(--surface-color);
  border-radius: 16px;
  width: 90%;
  max-width: 1200px;
  height: 85vh;
  max-height: 700px;
  overflow: hidden;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}
.modal.active .modal-content {
  transform: scale(1);
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr 350px;
  width: 100%;
  height: 100%;
  align-items: start;
}

.modal-video-main {
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.video-player {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.video-player iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* --- Gaya Panel Kontrol Kustom --- */
.modal-player-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background-color: var(--background-color);
  border-radius: 8px;
  margin-top: 1rem;
}

.control-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.control-btn:hover {
  background-color: var(--border-color);
}
.control-btn.active {
    color: var(--primary-color);
}

.progress-bar {
  flex-grow: 1;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--border-color);
  outline: none;
  border-radius: 4px;
  cursor: pointer;
}
.progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
}
.progress-bar::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.time-display {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 5px;
  background: var(--border-color);
  outline: none;
  border-radius: 2.5px;
  transition: width 0.3s ease;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
}
.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* --- Gaya Menu Pengaturan Kualitas --- */
.settings-container {
    position: relative;
}

.quality-menu {
    display: none;
    position: absolute;
    bottom: 120%; /* Muncul di atas tombol */
    right: 0;
    background-color: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0.5rem;
    z-index: 10;
    width: 120px;
}

.quality-menu.active {
    display: block;
}

.quality-option {
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.quality-option:hover {
    background-color: var(--border-color);
}

.quality-option.selected {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}
/* ---------------------------------- */


.modal-video-info {
  padding-bottom: 16px;
}
.modal-video-info h3 {
  font-size: 1.4rem;
  margin: 0;
}
.modal-video-info p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.modal-related-videos {
  background-color: var(--background-color);
  padding: 20px;
  overflow-y: auto;
  border-left: 1px solid var(--border-color);
  height: 100%;
  box-sizing: border-box;
}
.modal-related-videos h4 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.related-video-item {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}
.related-video-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
}
[data-theme="dark"] .related-video-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}
.related-video-item img {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 6px;
}
.related-video-info .related-title {
  font-size: 0.9rem;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.related-video-info .related-channel {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: block;
  margin-top: 4px;
}
.related-loading, .related-error {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.3);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.2s ease;
}
.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.6);
  transform: rotate(90deg);
}

/* ==========================================================================
   6. Komponen Lain (Loading, Footer, dll)
   ========================================================================== */
.loading, .no-results {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
  display: none; /* Defaultnya tersembunyi */
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.loading i, .no-results i {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.footer {
  background-color: var(--surface-color);
  text-align: center;
  padding: 2rem;
  margin-top: 3rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   7. Desain Responsif (Media Queries)
   ========================================================================== */
.mobile-menu-btn, .mobile-menu, .desktop-only {
    display: none; /* Sembunyikan semua elemen mobile & desktop-only secara default */
}

/* Tampilkan elemen desktop di layar besar */
@media (min-width: 769px) {
    .desktop-only {
        display: flex;
    }
}

@media (max-width: 992px) {
  .modal-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .modal-video-main {
      flex-shrink: 0;
  }
  .modal-related-videos {
    flex-grow: 1;
    overflow-y: auto;
    border-left: none;
    border-top: 1px solid var(--border-color);
    min-height: 0;
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: var(--bottom-nav-height);
  }
  .desktop-only {
    display: none;
  }
  .mobile-menu-btn, .bottom-nav {
    display: flex;
  }
  .logo-text {
    display: none;
  }
  .main-content {
    padding: 1rem;
  }
  .video-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* --- Gaya untuk Menu Hamburger --- */
  .mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
  }

  .mobile-menu {
    display: none; /* Dikelola oleh JavaScript */
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    box-shadow: var(--shadow);
  }

  .mobile-menu-content {
    padding: 1rem;
  }
  
  .modal-video-main {
      padding: 10px;
  }
    
  .modal-player-control {
    position: relative;
    z-index: 2;
    background-color: var(--background-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
    flex-shrink: 0;
    width: 100%;
  }
    .video-player {
    position: relative;
    z-index: 1;
  }
  .progress-bar {
    order: -1;
    width: 100%;
    flex-basis: 100%;
  }
  .time-display {
      margin-left: auto;
  }

  .mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    transition: all 0.3s ease;
  }
  .mobile-nav-link:hover, .mobile-nav-link.active {
    background-color: rgba(52, 152, 219, 0.1);
    color: var(--primary-color);
  }
  .mobile-nav-link i {
    font-size: 1.3rem;
  }
  .mobile-nav-link span {
    font-weight: 600;
  }
  .mobile-nav-link p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: auto;
  }
}

/* Tambahkan di style.css */
.fullscreen-close-btn {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  display: none; /* default sembunyi */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}
.fullscreen-close-btn:hover {
  background: rgba(0,0,0,0.85);
}
