/* ===================================================================
 * MyTVBox Web App - Responsive Mobile & Desktop Streaming UI
 * =================================================================== */

:root {
  --nav-height: 64px;
  --bottom-bar-height: 64px;
  --card-radius: 12px;
  --accent-cyan: #00e5ff;
  --accent-glow: rgba(0, 229, 255, 0.35);
  --bg-dark: #080a0f;
  --card-bg: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.1);
  --osd-bg: rgba(11, 13, 19, 0.92);
}

body.app-body {
  background: var(--bg-dark);
  color: #f5f6f8;
  padding-bottom: 80px; /* Space for mobile bottom bar */
}

@media (min-width: 769px) {
  body.app-body {
    padding-bottom: 24px;
  }
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(8, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.source-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  font-size: 13px;
  color: #f5f6f8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.source-badge:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-cyan);
}

.source-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

/* iOS Add to Home Screen Banner */
.ios-banner {
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.15) 0%, rgba(37, 99, 235, 0.15) 100%);
  border-bottom: 1px solid rgba(0, 229, 255, 0.25);
  padding: 10px 16px;
  font-size: 13px;
  color: #d1f7ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ios-banner .close-btn {
  background: none;
  border: none;
  color: #d1f7ff;
  font-size: 18px;
  cursor: pointer;
}

/* Category Filter Bar */
.category-bar-wrap {
  overflow-x: auto;
  white-space: nowrap;
  padding: 14px 20px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.category-bar-wrap::-webkit-scrollbar {
  display: none;
}

.cat-chip {
  display: inline-block;
  padding: 7px 18px;
  margin-right: 8px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #9ba1ac;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-chip:hover, .cat-chip.active {
  background: var(--accent-cyan);
  color: #06070a;
  border-color: var(--accent-cyan);
  font-weight: 700;
  box-shadow: 0 4px 14px var(--accent-glow);
}

/* Poster Cards Grid */
.vod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  padding: 10px 20px 32px;
}

@media (min-width: 600px) {
  .vod-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 18px;
  }
}

@media (min-width: 1024px) {
  .vod-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 22px;
  }
}

.vod-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease, border-color 0.28s ease;
}

.vod-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(0, 229, 255, 0.4);
  box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.7), 0 0 16px -4px var(--accent-glow);
}

.vod-poster-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 2.9;
  background: #141720;
  overflow: hidden;
}

.vod-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.vod-card:hover .vod-poster {
  transform: scale(1.05);
}

.vod-remark {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 8px 6px;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.85) 100%);
  font-size: 11px;
  font-weight: 500;
  color: #00e5ff;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.vod-score {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  color: #ff9800;
  font-size: 11px;
  font-weight: 700;
}

.vod-info {
  padding: 10px 10px 12px;
}

.vod-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  color: #f5f6f8;
}

.vod-meta {
  font-size: 12px;
  color: #7b8393;
  display: flex;
  justify-content: space-between;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-bar-height);
  background: rgba(11, 13, 19, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 95;
  padding-bottom: env(safe-area-inset-bottom);
}

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

.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #7e8797;
  font-size: 11px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  transition: all 0.18s ease;
}

.bottom-tab svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.bottom-tab.active {
  color: var(--accent-cyan);
}

.bottom-tab.active svg {
  filter: drop-shadow(0 0 6px var(--accent-cyan));
}

/* Fullscreen / Modal Video Player */
.player-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.player-modal.active {
  display: flex;
}

.player-video-container {
  position: relative;
  width: 100%;
  height: 56.25vw; /* 16:9 on mobile */
  max-height: 70vh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 960px) {
  .player-modal-body {
    display: flex;
    height: 100vh;
  }
  .player-video-container {
    flex: 1;
    height: 100vh;
    max-height: 100vh;
  }
  .player-sidebar {
    width: 380px;
    height: 100vh;
    background: #0b0d13;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    padding: 20px;
  }
}

.player-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player-controls-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 20%, transparent 80%, rgba(0,0,0,0.85) 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  transition: opacity 0.25s ease;
  pointer-events: auto;
}

.player-controls-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.player-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.player-title-text {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-btn {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.player-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.player-bottom-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-wrap {
  width: 100%;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.progress-bar-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-cyan);
  border-radius: 2px;
  position: relative;
}

.progress-handle {
  position: absolute;
  right: -6px;
  top: -4px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
}

.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #a0a6b2;
}

.time-controls-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Episodes Grid */
.episodes-section {
  padding: 16px 20px;
}

.section-label {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.episodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.ep-btn {
  padding: 10px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.18s ease;
}

.ep-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.ep-btn.active {
  background: var(--accent-cyan);
  color: #06070a;
  border-color: var(--accent-cyan);
  font-weight: 700;
  box-shadow: 0 0 14px var(--accent-glow);
}

/* Line Selector */
.line-selector-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.line-btn {
  padding: 6px 14px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #9ba1ac;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.line-btn.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.12);
}

/* Modals (Source management, Search) */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.dialog-overlay.active {
  display: flex;
}

.dialog-box {
  width: 100%;
  max-width: 520px;
  background: #11141c;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 50px rgba(0,0,0,0.8);
  max-height: 85vh;
  overflow-y: auto;
}

.dialog-title {
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-close {
  background: none;
  border: none;
  color: #8b92a0;
  font-size: 24px;
  cursor: pointer;
}

/* Toast message */
.toast-msg {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(14, 17, 24, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 229, 255, 0.4);
  box-shadow: 0 10px 28px rgba(0,0,0,0.6);
  color: #ffffff;
  padding: 10px 22px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2000;
}

.toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===================================================================
 * App Light Mode Overrides
 * =================================================================== */
[data-theme="light"] body.app-body {
  background: var(--bg-primary);
  color: var(--text-main);
}

[data-theme="light"] .app-header {
  background: rgba(245, 247, 252, 0.88);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .source-badge {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

[data-theme="light"] .cat-chip {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

[data-theme="light"] .cat-chip:hover,
[data-theme="light"] .cat-chip.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

[data-theme="light"] .vod-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .vod-title {
  color: #0f172a;
}

[data-theme="light"] .vod-meta {
  color: #64748b;
}

[data-theme="light"] .mobile-bottom-bar {
  background: rgba(255, 255, 255, 0.94);
  border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .bottom-tab {
  color: #64748b;
}

[data-theme="light"] .bottom-tab.active {
  color: #0284c7;
}

[data-theme="light"] .dialog-box {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .player-sidebar {
  background: #ffffff;
  border-left-color: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

[data-theme="light"] .player-sidebar h2 {
  color: #0f172a;
}

[data-theme="light"] .ep-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

[data-theme="light"] .ep-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

[data-theme="light"] .line-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

[data-theme="light"] .line-btn.active {
  color: #0284c7;
  border-color: #0284c7;
  background: rgba(2, 132, 199, 0.1);
}

