/* ══════════════════════════════════════════════
   Góc Phim Tiểu Bạch — Custom Styles
   Extracted from inline <style> in index.html
   ══════════════════════════════════════════════ */

/* ─── Base ─── */
body {
  background-color: #0f1115;
  color: #e2e8f0;
  font-family: "Be Vietnam Pro", sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ─── Typography ─── */
h1,
h2,
h3,
h4 {
  text-wrap: balance;
}

/* ─── Glassmorphism Header ─── */
.glass {
  background: rgba(15, 17, 21, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: env(safe-area-inset-top);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0f1115;
}

::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(to bottom, #ef4444, #fb923c);
}

/* ─── Movie Card ─── */
.movie-card {
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.movie-card img {
  aspect-ratio: 2 / 3;
  content-visibility: auto;
}

.movie-card:hover {
  transform: translateY(-8px);
}

/* ─── Text Gradient ─── */
.text-gradient {
  background: linear-gradient(to right, #ef4444, #fb923c, #ffffff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ─── Hero Section ─── */
.hero-bg {
  background-color: #0f1115;
  background-image:
    radial-gradient(at 0% 0%, hsla(0, 72%, 20%, 0.4) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(28, 80%, 20%, 0.3) 0, transparent 50%);
}

/* ─── Animations ─── */
@keyframes heartbeat {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.animate-heartbeat {
  animation: heartbeat 1.5s infinite ease-in-out;
}

@keyframes fadeOut {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes shine {
  0% {
    background-position: 200% center;
  }

  100% {
    background-position: -200% center;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ─── Fullscreen (Desktop) ─── */
@media (min-width: 769px) {
  .is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    background-color: black !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
  }
}

#player-wrapper.is-fullscreen #video-container {
  height: calc(100dvh - 56px) !important;
}

body.fullscreen-active {
  overflow: hidden !important;
  position: fixed !important;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ─── Mobile Player (60/40 split) ─── */
@media (max-width: 768px) {
  #video-modal {
    padding: 0 !important;
  }

  #modal-container {
    height: 100vh !important;
    height: 100dvh !important;
    width: 100vw !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column !important;
  }

  /* Player area expands to fill remaining space */
  #player-wrapper {
    flex: 1 !important;
    width: 100vw !important;
    height: auto !important;
  }

  /* Calculate height: 100% minus the 3.5rem (56px) header */
  #video-container {
    height: calc(100% - 3.5rem) !important;
  }

  #video-frame {
    height: 100% !important;
    width: 100% !important;
  }

  /* Sidebar takes up 40% but allows shrinking */
  #modal-container > div:last-child {
    flex: 0 0 40vh !important;
    width: 100vw !important;
  }

  /* When fullscreen toggled on mobile (Bulletproof iOS Safari Compatibility) */
  #modal-container.is-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: 0 !important;
    background-color: black !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #modal-container.is-fullscreen #player-wrapper {
    position: relative !important;
    inset: auto !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    background-color: black !important;
  }

  #modal-container.is-fullscreen #video-container {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
  }

  #modal-container.is-fullscreen #video-frame {
    height: 100% !important;
    width: 100% !important;
  }

  /* Hide sidebar when fullscreen */
  #modal-container.is-fullscreen > div:last-child {
    display: none !important;
  }

  /* Auto-hide header controls when fullscreen */
  #modal-container.is-fullscreen .flex-none.h-14 {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  #modal-container.is-fullscreen:active .flex-none.h-14,
  #modal-container.is-fullscreen .flex-none.h-14:hover {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ─── Mobile Sidebar Toggle ─── */
@media (max-width: 1023px) {
  .sidebar-mobile-collapsed {
    display: none !important;
  }
}

/* ─── Player Controls ─── */
.player-controls-auto-hide {
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.player-controls-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Affiliate Buttons ─── */
.btn-tet {
  background: linear-gradient(90deg, #dc2626 0%, #fcd34d 50%, #dc2626 100%);
  background-size: 200% auto;
  animation: shine 3s linear infinite;
}

.btn-pink {
  background: linear-gradient(to right, #ec4899, #be185d);
}

.btn-orange {
  background: linear-gradient(to right, #f97316, #ea580c);
}

.btn-affiliate-hero {
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-affiliate-hero:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.6);
}

/* ─── Affiliate Floating Button ─── */
.affiliate-floating-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 40;
  animation: slideIn 0.4s ease-out;
}

@media (max-width: 768px) {
  .affiliate-floating-btn {
    bottom: 15px;
    right: 15px;
  }
}

/* ─── Smart Affiliate Bar (Mobile) ─── */
.affiliate-smart-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 55;
  background: linear-gradient(
    to right,
    rgba(24, 27, 33, 0.98),
    rgba(15, 17, 21, 0.98)
  );
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
  display: none;
  animation: slideUp 0.3s ease-out;
}

.affiliate-smart-bar.visible {
  display: flex;
}

/* ─── Server Buttons ─── */
.server-btn {
  padding: 10px 18px;
  min-height: 40px;
  /* Improved tap target */
  font-size: 12px;
  font-weight: 700;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-color: rgba(255, 255, 255, 0.05);
  color: #9ca3af;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s,
    border-color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.server-btn.active {
  background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  color: white;
  border-color: transparent;
}

/* ─── Guide Content ─── */
#guide-content {
  transition:
    opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.hidden-guide {
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
}

.visible-guide {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ─── Accessibility ─── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .movie-card:hover {
    transform: none;
  }
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid #f97316;
  outline-offset: 2px;
}

/* ─── Modal Touch ─── */
#donate-modal,
#video-modal {
  overscroll-behavior: contain;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── Skip Link ─── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 9999;
  background: #f97316;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}

.skip-link:focus {
  position: fixed;
  left: 16px;
  top: 16px;
  width: auto;
  height: auto;
  overflow: visible;
}

/* ─── Genre Filter Chips ─── */
.genre-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  min-height: 36px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background-color: rgba(255, 255, 255, 0.04);
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.genre-chip:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
}

.genre-chip.active {
  background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

/* ─── Mobile Bottom Episode Bar ─── */
.mobile-ep-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(24, 27, 33, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

@media (min-width: 1024px) {
  .mobile-ep-bar {
    display: none;
  }
}

/* ─── Fade in animation ─── */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}
