/**
 * AI INFRA Video Scroll Sync - Styles
 * 滾動同步影片播放器樣式
 */

/* ==================== 播放器容器 ==================== */
.video-scroll-player {
  position: fixed;
  z-index: 10000;
  background: linear-gradient(135deg, rgba(20, 20, 30, 0.98), rgba(30, 20, 40, 0.98));
  border-radius: 12px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(168, 85, 247, 0.3),
    0 0 20px rgba(168, 85, 247, 0.2);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  animation: slideIn 0.6s ease-out;
}

/* 位置變體 */
.video-scroll-player.player-bottom-right {
  bottom: 20px;
  right: 20px;
}

.video-scroll-player.player-bottom-left {
  bottom: 20px;
  left: 20px;
}

.video-scroll-player.player-top-right {
  top: 80px;
  right: 20px;
}

.video-scroll-player.player-top-left {
  top: 80px;
  left: 20px;
}

/* 最小化狀態 */
.video-scroll-player.minimized {
  width: 80px !important;
  height: 80px !important;
  border-radius: 50%;
}

.video-scroll-player.minimized .player-header {
  display: none;
}

/* ==================== 播放器標題列 ==================== */
.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(168, 85, 247, 0.2);
}

.player-title {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
}

.player-controls {
  display: flex;
  gap: 8px;
}

/* ==================== 控制按鈕 ==================== */
.player-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.player-btn:hover {
  background: rgba(168, 85, 247, 0.4);
  transform: translateY(-1px);
}

.player-btn:active {
  transform: translateY(0);
}

.player-btn svg {
  stroke-width: 2;
}

.btn-close:hover {
  background: rgba(239, 68, 68, 0.6);
}

/* 靜音按鈕動畫 */
.sound-wave {
  animation: soundWave 1.5s ease-in-out infinite;
}

@keyframes soundWave {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ==================== 播放器主體 ==================== */
.player-body {
  position: relative;
  width: 400px;
  height: 225px;
  background: #000;
}

.player-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ==================== 最小化後的疊加層 ==================== */
.player-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.9), rgba(0, 217, 255, 0.8));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-expand {
  width: 48px;
  height: 48px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.btn-expand:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.btn-expand svg {
  stroke-width: 2.5;
}

/* ==================== Fallback UI ==================== */
.player-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(0, 217, 255, 0.15));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 20px;
}

.player-fallback p {
  color: #ffffff;
  font-size: 14px;
  margin: 0;
  text-align: center;
}

.btn-play-fallback {
  padding: 12px 24px;
  background: linear-gradient(135deg, #a855f7, #00d9ff);
  border: none;
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

.btn-play-fallback:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
}

.btn-play-fallback:active {
  transform: translateY(0);
}

/* ==================== 動畫效果 ==================== */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==================== 響應式設計 ==================== */
@media (max-width: 768px) {
  .video-scroll-player {
    width: 90vw !important;
    max-width: 360px;
    bottom: 10px !important;
    right: 5% !important;
    left: 5% !important;
  }

  .player-body {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .player-title {
    font-size: 12px;
  }

  .player-btn {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 480px) {
  .video-scroll-player.minimized {
    width: 60px !important;
    height: 60px !important;
  }

  .player-header {
    padding: 8px 12px;
  }

  .player-controls {
    gap: 6px;
  }
}

/* ==================== 避免與 Livechat 衝突 ==================== */
.video-scroll-player.player-bottom-right {
  /* Livechat 在右下角，調整播放器位置 */
  right: 120px; /* 避開 livechat 按鈕 */
}

/* 如果 Livechat 打開，進一步調整 */
@media (min-width: 769px) {
  .video-scroll-player.player-bottom-right {
    right: 20px;
    bottom: 120px; /* 移到 livechat 上方 */
  }
}

/* ==================== 深色模式支援 ==================== */
@media (prefers-color-scheme: light) {
  .video-scroll-player {
    box-shadow:
      0 10px 40px rgba(0, 0, 0, 0.2),
      0 0 0 1px rgba(168, 85, 247, 0.2),
      0 0 20px rgba(168, 85, 247, 0.15);
  }
}

/* ==================== 打印時隱藏 ==================== */
@media print {
  .video-scroll-player {
    display: none !important;
  }
}

/* ==================== 可訪問性增強 ==================== */
.player-btn:focus-visible {
  outline: 2px solid #a855f7;
  outline-offset: 2px;
}

.btn-expand:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* ==================== 懸停提示優化 ==================== */
.player-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  margin-bottom: 8px;
  pointer-events: none;
  z-index: 10001;
}

/* ==================== 性能優化 ==================== */
.video-scroll-player * {
  will-change: auto;
}

.video-scroll-player.minimized {
  will-change: transform;
}
