/**
 * 移动端播放器优化样式
 * 整合了移动端播放器的所有样式，避免重复定义
 * ========== 优化8：去除重复CSS代码 ==========
 */

/* ========== 移动端播放器基础样式 ========== */
/* 统一的媒体查询断点变量（使用CSS自定义属性） */
:root {
  --mobile-breakpoint-sm: 480px;
  --mobile-breakpoint-md: 768px;
  --mobile-breakpoint-lg: 1024px;
  
  /* 安全区域变量 */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
}

/* ========== 移动端播放器容器 ========== */
body.mobile-player-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

.mobile-player-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: var(--available-vh, 100dvh);
  height: var(--available-vh, 100vh);
  background: #000;
  overflow: hidden;
  z-index: 1000;
  overscroll-behavior: none;
  touch-action: pan-y pinch-zoom;
  -webkit-overflow-scrolling: auto;
  
  /* iOS安全区域适配 */
  padding-top: var(--safe-area-top);
  padding-bottom: var(--safe-area-bottom);
  padding-left: var(--safe-area-left);
  padding-right: var(--safe-area-right);
}

/* ========== 视频区域 ========== */
.video-area {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overscroll-behavior: none;
  touch-action: none;
}

.video-wrapper {
  width: 100%;
  height: 100%;
  overscroll-behavior: none;
  touch-action: none;
  /* GPU加速 */
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
  pointer-events: auto;
  background-color: #000;
  overscroll-behavior: none;
  /* 注意：视频元素不添加GPU加速属性！
     原因：在iOS Safari上，will-change/transform会与原生视频解码器冲突，
     导致暂停后恢复播放时画面冻结但声音正常的问题 */
}

/* ========== 移动端头部 ========== */
.mobile-header {
  position: absolute;
  top: var(--safe-area-top, 0);
  left: 0;
  width: 100%;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  /* GPU加速 */
  transform: translateZ(0);
  backface-visibility: hidden;
}

.mobile-header .btn-outline {
  flex-shrink: 0;
  z-index: 102;
  width: 67px;
  height: 67px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  background: transparent;
  border: none;
  position: absolute;
  top: 10px;
  left: 10px;
  transform: translate(5px, 5px);
}

.mobile-header .btn-outline i {
  font-size: 32px;
}

/* ========== 集数指示器 ========== */
.episode-indicator {
  display: inline-block;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  text-align: center;
  min-width: 120px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  z-index: 101;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* GPU加速 */
  transform: translateZ(0);
}

.episode-indicator span {
  color: #ff6b6b;
  font-weight: 700;
  font-size: 15px;
}

.episode-indicator:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.05);
}

.mobile-episode-indicator {
  position: relative;
  z-index: 101;
  margin: 0 auto;
}

/* ========== 移动端交互区域 ========== */
.mobile-interactive-area {
  position: absolute;
  right: calc(10px + var(--safe-area-right, 0px));
  top: 60%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 100;
}

/* ========== 剧集列表容器 ========== */
.mobile-episode-list-container {
  position: absolute;
  right: 60px;
  top: 60%;
  transform: translateY(-50%);
  width: 60px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 10px;
  padding: 10px 5px;
}

.mobile-episode-list-container .episodes {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mobile-episode-list-container .episode-item {
  width: 100%;
  height: 40px;
  font-size: 14px;
}

/* ========== 互动按钮 ========== */
.mobile-interaction-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  /* GPU加速 */
  transform: translateZ(0);
  backface-visibility: hidden;
}

.control-button {
  width: 50px;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* GPU加速 */
  transform: translateZ(0);
  will-change: transform, opacity;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.control-button:active {
  transform: scale(0.95);
}

/* ========== 底部进度条 ========== */
.mobile-progress-container {
  position: absolute;
  bottom: var(--safe-area-bottom, 0);
  left: 0;
  right: 0;
  padding: 10px 15px;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  z-index: 50;
}

.progress-container {
  width: 100%;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  cursor: pointer;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: #ff6b6b;
  border-radius: 2px;
  transition: width 0.1s linear;
}

.progress-time {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}

/* ========== 底部剧集列表 ========== */
.bottom-episode-list {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-area-bottom, 0px));
  z-index: 200;
  max-height: 60vh;
  overflow-y: auto;
  /* GPU加速 */
  transform: translateZ(0);
}

.episode-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.episode-list-header h3 {
  color: white;
  font-size: 18px;
  font-weight: 600;
}

.episode-list-header .close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 5px 10px;
}

/* ========== 响应式设计（整合媒体查询） ========== */

/* 超小屏幕（小于480px） */
@media (max-width: 479px) {
  .mobile-header .btn-outline {
    width: 55px;
    height: 55px;
  }
  
  .mobile-header .btn-outline i {
    font-size: 28px;
  }
  
  .control-button {
    width: 45px;
    height: 45px;
  }
  
  .episode-indicator {
    font-size: 12px;
    padding: 6px 12px;
    min-width: 100px;
  }
}

/* 小屏幕到中等屏幕（480px-768px） */
@media (min-width: 480px) and (max-width: 768px) {
  .control-button {
    width: 50px;
    height: 50px;
  }
}

/* 横屏模式适配 */
@media (orientation: landscape) and (max-width: 896px) {
  .mobile-interaction-buttons {
    right: calc(5px + var(--safe-area-right, 0px));
    gap: 10px;
  }
  
  .control-button {
    width: 40px;
    height: 40px;
  }
  
  .mobile-header {
    padding: 5px 10px;
  }
}

/* PC端隐藏移动端元素 */
@media (min-width: 769px) {
  .mobile-player-container {
    display: none;
  }
  
  .mobile-episode-indicator {
    display: none;
  }
}

/* 移动端隐藏PC端元素 */
@media (max-width: 768px) {
  .desktop-player-container {
    display: none;
  }
  
  .desktop-episode-indicator {
    display: none;
  }
}

/* ========== 骨架屏样式 ========== */
.skeleton-video-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #000;
  z-index: 10;
  /* GPU加速 */
  transform: translateZ(0);
}

.skeleton-video {
  width: 100%;
  height: 60%;
  background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

.skeleton-controls {
  width: 80%;
  height: 60px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.skeleton-control-item {
  background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-control-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-progress {
  flex: 1;
  height: 4px;
}

.skeleton-episode-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  /* GPU加速 */
  transform: translateZ(0);
}

.skeleton-episode-item {
  height: 40px;
  background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

.skeleton-shimmer {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== 手势反馈样式 ========== */
.gesture-edge-preview {
  position: absolute;
  left: 0;
  right: 0;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  transition: all 0.2s ease-out;
  /* GPU加速 */
  transform: translateZ(0);
  will-change: transform, opacity;
}

.gesture-preview-top {
  background: linear-gradient(to bottom, rgba(255,107,107,0.8), transparent);
  top: 0;
  padding-top: 20px;
  align-items: flex-start;
}

.gesture-preview-bottom {
  background: linear-gradient(to top, rgba(107,255,107,0.8), transparent);
  bottom: 0;
  padding-bottom: 20px;
  align-items: flex-end;
}

.gesture-preview-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  pointer-events: none;
}

.gesture-preview-content i {
  font-size: 24px;
  animation: gestureBounce 0.6s ease-in-out infinite;
}

.gesture-preview-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

@keyframes gestureBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ========== 权限弹窗样式 ========== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  /* GPU加速 */
  transform: translateZ(0);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #1a1a1a;
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  position: relative;
  color: white;
  margin-top: var(--safe-area-top, 5%);
  margin-bottom: var(--safe-area-bottom, 5%);
  /* GPU加速 */
  transform: translateZ(0);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  margin-top: 20px;
}

#permissionMessage {
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 20px;
}

#purchaseOptions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ========== 缓冲指示器样式 ========== */
#bufferingIndicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  /* GPU加速 */
  will-change: transform, opacity;
}

.buffering-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ff6b6b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.buffering-text {
  color: white;
  font-size: 14px;
}

/* ========== 滑动提示样式 ========== */
#swipeHint {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 16px 32px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: bold;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  /* GPU加速 */
  will-change: transform, opacity;
}

/* ========== 隐藏播放页面的语言切换器 ========== */
.mobile-player-page .language-switcher,
.desktop-player-container .language-switcher {
  display: none !important;
}

/* ========== 高对比度模式支持 ========== */
@media (prefers-contrast: high) {
  .episode-indicator {
    border: 2px solid white;
  }
  
  .control-button {
    border: 1px solid rgba(255, 255, 255, 0.5);
  }
}

/* ========== 减少动画模式支持 ========== */
@media (prefers-reduced-motion: reduce) {
  .skeleton-video,
  .skeleton-control-item,
  .skeleton-episode-item,
  .skeleton-shimmer {
    animation: none;
    background: #1a1a1a;
  }
  
  .gesture-preview-content i {
    animation: none;
  }
  
  .spinner {
    animation: none;
    border-top-color: #ff6b6b;
  }
}

/* ========== 暗色模式增强 ========== */
@media (prefers-color-scheme: dark) {
  .modal-content {
    background: #0a0a0a;
  }
  
  .bottom-episode-list {
    background: rgba(0, 0, 0, 0.98);
  }
}
