@use '../styles/variables' as *;

.player-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  max-width: 100%; /* 确保不会超出视口宽度 */
  background-color: #000;
  overflow-y: auto; /* 允许垂直滚动 */
  overflow-x: hidden; /* 防止水平溢出 */
  position: relative;
  scrollbar-width: none; /* Firefox隐藏滚动条 */
  -ms-overflow-style: none; /* IE和Edge隐藏滚动条 */
  box-sizing: border-box; /* 确保padding不会增加宽度 */
  
  /* 为Webkit浏览器隐藏滚动条 */
  &::-webkit-scrollbar {
    display: none;
  }
  
  /* 视频播放区域 - 顶部 */
  .video-area {
    position: relative;
    flex: 1;
    min-height: 300px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    overflow: hidden;
    
    .video-js {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      
      // 确保video元素占满容器
      video {
        width: 100%;
        height: 100%;
        object-fit: contain; // 保持宽高比
      }
      
      // 修正视频控制条样式
      .vjs-control-bar {
        background-color: rgba(0, 0, 0, 0.7);
        z-index: 200 !important;
        bottom: 0 !important;
        position: absolute !important;
        display: flex !important;
        pointer-events: auto !important;
        min-height: 3em !important;
        
        // 确保所有按钮可点击
        button {
          z-index: 210 !important;
          pointer-events: auto !important;
          cursor: pointer !important;
          min-width: 3em !important;
          height: 100% !important;
          position: relative !important;
          
          &:hover {
            color: $primary-color;
          }
        }
        
        .vjs-button {
          pointer-events: auto !important;
          cursor: pointer !important;
        }
      }
      
      // 确保控制栏在视频内容之上
      .vjs-tech {
        z-index: 10 !important;
      }
      
      .vjs-poster {
        z-index: 9 !important;
      }
      
      // 确保控制栏显示区域不被其他元素遮挡
      &.vjs-user-active .vjs-control-bar,
      .vjs-control-bar {
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
      }
      
      // 修复控制栏按钮布局
      .vjs-control {
        z-index: 210 !important;
        pointer-events: auto !important;
        position: relative !important;
        flex: none !important;
        width: 3em !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
      }
      
      // 防止元素上的覆盖层阻止点击
      .vjs-menu-button-popup {
        z-index: 220 !important;
        
        .vjs-menu {
          z-index: 230 !important;
          pointer-events: auto !important;
          
          .vjs-menu-content {
            pointer-events: auto !important;
          }
        }
      }
      
      .vjs-progress-control {
        position: absolute !important;
        top: -15px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 15px !important;
        padding-top: 5px !important;
        pointer-events: auto !important;
        cursor: pointer !important;
        z-index: 100 !important;
        transition: height 0.1s ease;
        
        &:hover {
          height: 20px !important;
          top: -20px !important;
        }
        
        .vjs-progress-holder {
          margin: 0 !important;
          height: 8px !important;
          cursor: pointer !important;
          pointer-events: auto !important;
          
          &:hover {
            height: 10px !important;
          }
          
          .vjs-play-progress {
            background-color: $primary-color !important;
            height: 100% !important;
          }
          
          .vjs-load-progress {
            height: 100% !important;
            background-color: rgba(255, 255, 255, 0.3) !important;
          }
          
          .vjs-mouse-display, .vjs-time-tooltip {
            z-index: 102 !important;
          }
        }
      }
      
      &.vjs-fluid {
        padding-top: 0;
      }
      
      .vjs-big-play-button {
        background-color: rgba(24, 144, 255, 0.7);
        border: none;
        border-radius: 50%;
        width: 80px;
        height: 80px;
        line-height: 80px;
        font-size: 40px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        
        &:hover {
          background-color: $primary-color;
        }
      }
      
      &.vjs-playing,
      &.vjs-has-started {
        .vjs-big-play-button {
          display: none !important;
          opacity: 0 !important;
          visibility: hidden !important;
          pointer-events: none !important;
        }
      }
      
      /* 清晰度切换控件 */
      .vjs-resolution-button {
        color: white;
        background-color: rgba(0, 0, 0, 0.5);
        border-radius: 4px;
        padding: 0 8px;
        
        &:hover {
          background-color: rgba(24, 144, 255, 0.7);
        }
      }
    }
    
    .player-loading, .player-error {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background-color: rgba(0, 0, 0, 0.7);
      color: white;
      z-index: 10;
      
      .error-message {
        margin-bottom: 20px;
        font-size: 16px;
        max-width: 80%;
        text-align: center;
      }
      
      .error-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        margin-bottom: 15px;
      }
    }
  }
  
  /* 视频信息详情区域 - 中部 */
  .media-info-area {
    width: 100%;
    background-color: #141414;
    color: $text-color;
    padding: 0;
    
    .media-info-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 20px;
      background-color: #1f1f1f;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
      
      h2 {
        font-size: 20px;
        margin: 0;
        color: #fff;
      }
      
      .toggle-info-btn {
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.8);
        cursor: pointer;
        font-size: 16px;
        display: flex;
        align-items: center;
        transition: all 0.3s;
        
        &:hover {
          color: $primary-color;
        }
        
        &.collapsed .arrow-icon {
          transform: rotate(180deg);
        }
      }
    }
    
    .media-info-content {
      padding: 15px 20px;
      max-height: 300px;
      overflow-y: auto;
      transition: max-height 0.3s ease-out;
      
      &.collapsed {
        max-height: 0;
        padding: 0 20px;
        overflow: hidden;
      }
      
      h3 {
        font-size: 16px;
        margin-bottom: 10px;
        color: rgba(255, 255, 255, 0.9);
      }
      
      p {
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 10px;
        color: rgba(255, 255, 255, 0.7);
      }
      
      .tags-list {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 15px;
        
        .tag {
          background-color: rgba(24, 144, 255, 0.2);
          color: $primary-color;
          border-radius: 12px;
          padding: 2px 10px;
          font-size: 12px;
        }
      }
    }
  }
  
  /* 剧集选择区域 - 底部 */
  .episodes-area {
    width: 100%;
    background-color: #1a1a1a;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px 0;
    
    .episodes-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 20px 10px;
      
      h3 {
        font-size: 16px;
        margin: 0;
        color: #fff;
      }
      
      .episode-controls {
        display: flex;
        gap: 10px;
      }
    }
    
    .episodes-list {
      padding: 5px 20px;
      overflow-x: auto;
      white-space: nowrap;
      display: flex;
      gap: 10px;
      scrollbar-width: thin;
      scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
      
      &::-webkit-scrollbar {
        height: 6px;
      }
      
      &::-webkit-scrollbar-track {
        background: transparent;
      }
      
      &::-webkit-scrollbar-thumb {
        background-color: rgba(255, 255, 255, 0.3);
        border-radius: 6px;
      }
      
      .episode-item {
        min-width: 120px;
        height: 80px;
        position: relative;
        border-radius: 4px;
        overflow: hidden;
        cursor: pointer;
        background-color: #2a2a2a;
        
        &:hover {
          box-shadow: 0 0 0 2px $primary-color;
        }
        
        &.active {
          box-shadow: 0 0 0 2px $primary-color;
          
          &::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(24, 144, 255, 0.2);
          }
        }
        
        .episode-number {
          position: absolute;
          top: 5px;
          left: 5px;
          background-color: rgba(0, 0, 0, 0.7);
          color: #fff;
          border-radius: 4px;
          padding: 2px 6px;
          font-size: 12px;
          z-index: 1;
        }
        
        .episode-title {
          position: absolute;
          bottom: 0;
          left: 0;
          width: 100%;
          background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
          padding: 20px 8px 8px;
          color: #fff;
          font-size: 12px;
          white-space: normal;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }
    }
  }

  /* 推荐内容区域 - 底部 */
  .recommended-area {
    margin-top: 16px;
    background-color: rgba(30, 30, 30, 0.5);
    border-radius: 8px;
    margin-bottom: 16px;
    
    .recommended-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 16px 8px; /* 减少底部内边距 */
      
      h3 {
        font-size: 15px; /* 减小标题字号 */
        margin: 0;
        color: #fff;
      }
    }
    
    .recommended-content {
      padding: 6px 16px 6px; /* 减少上下内边距 */
      
      .loading-container {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100px; /* 减少最小高度 */
      }
      
      .no-recommendations {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100px; /* 减少最小高度 */
        color: rgba(255, 255, 255, 0.5);
      }
      
      .recommended-items {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        padding-bottom: 10px;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
        
        &::-webkit-scrollbar {
          height: 6px;
        }
        
        &::-webkit-scrollbar-track {
          background: transparent;
        }
        
        &::-webkit-scrollbar-thumb {
          background-color: rgba(255, 255, 255, 0.3);
          border-radius: 6px;
        }
        
        .recommended-item {
          min-width: 140px;
          width: 140px;
          background-color: #2a2a2a;
          border: none;
          
          &:hover {
            box-shadow: 0 0 0 2px #1890ff;
          }
          
          .ant-card-cover {
            height: 180px;
            overflow: hidden;
            
            img {
              width: 100%;
              height: 100%;
              object-fit: cover;
            }
          }
          
          .ant-card-body {
            padding: 8px;
            background-color: #2a2a2a;
          }
          
          .ant-card-meta-title {
            color: #fff;
            font-size: 13px;
            margin-bottom: 2px;
            white-space: normal;
            display: -webkit-box;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
            overflow: hidden;
          }
          
          .ant-card-meta-description {
            color: rgba(255, 255, 255, 0.65);
            font-size: 12px;
          }
          
          .recommended-item-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
          }
        }
      }
    }
  }
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  color: #fff;
  font-size: 18px;
}

.video-is-playing {
  .video-js .vjs-big-play-button {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
}

body.video-playing-state,
body.video-is-playing {
  .video-js .vjs-big-play-button {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
}

/* 码流选择下拉菜单样式 */
.format-select-dropdown {
  .ant-dropdown-menu {
    background-color: rgba(30, 30, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    
    .ant-dropdown-menu-item {
      color: #fff;
      
      &:hover {
        background-color: rgba(24, 144, 255, 0.2);
      }
      
      &.active {
        background-color: rgba(24, 144, 255, 0.3);
        color: $primary-color;
      }
    }
  }
}

/* 响应式布局 */
@media (max-width: 768px) {
  .player-container {
    .video-area {
      min-height: 30vh;
    }
    
    .media-info-area {
      .media-info-content {
        max-height: 200px;
      }
    }
    
    .episodes-area {
      .episodes-list {
        .episode-item {
          min-width: 100px;
          height: 70px;
        }
      }
    }
  }
} 

/* 字幕样式优化 */
.video-js .vjs-text-track-display {
  pointer-events: none;
  position: absolute;
  bottom: 4em;
  left: 0;
  right: 0;
  text-align: center;
}

.video-js .vjs-text-track-cue {
  background-color: rgba(0, 0, 0, 0.75);
  color: white;
  padding: 0.2em 0.5em;
  border-radius: 4px;
  font-size: 1.2em;
  line-height: 1.4;
  display: inline-block;
  max-width: 80%;
  margin-bottom: 0.5em;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

/* 字幕选择器样式 */
.subtitle-selector {
  background-color: #1a1a1a;
  color: white;
  border-radius: 4px;
  padding: 10px;
  
  h4 {
    color: white;
    margin-bottom: 10px;
    font-size: 16px;
    text-align: center;
  }
  
  .ant-list {
    max-height: 250px;
    overflow-y: auto;
    
    .ant-list-item {
      cursor: pointer;
      padding: 8px 12px;
      color: rgba(255, 255, 255, 0.8);
      transition: all 0.3s;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
      
      &:hover {
        background-color: rgba(24, 144, 255, 0.2);
        color: white;
      }
      
      &.active {
        background-color: rgba(24, 144, 255, 0.3);
        color: #1890ff;
      }
    }
  }
}

/* 字幕按钮样式 */
.vjs-subtitle-button {
  font-size: 0.8em !important;
  padding: 0 10px !important;
  cursor: pointer;
  background-color: transparent;
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  margin: 0 5px;
  
  &:hover {
    color: #1890ff;
  }
}

/* 音量控制样式 */
.video-js .vjs-volume-panel {
  margin-right: 10px !important;
  transition: width 0.3s ease;
  
  &.vjs-hover, &:hover, &:focus, &:active {
    width: 8em !important;
  }
  
  .vjs-volume-control {
    opacity: 1 !important;
    width: 5em !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    z-index: 101 !important;
    
    &.vjs-volume-vertical {
      height: 8em !important;
      width: 3em !important;
      bottom: 5em !important;
      background-color: rgba(0, 0, 0, 0.7) !important;
      border-radius: 4px !important;
    }
  }
  
  .vjs-mute-control {
    width: 3em !important;
    cursor: pointer !important;
    
    &:hover {
      color: $primary-color !important;
    }
  }
  
  .vjs-volume-bar {
    margin: 1.35em 0.45em !important;
    background-color: rgba(255, 255, 255, 0.3) !important;
    
    .vjs-volume-level {
      background-color: $primary-color !important;
    }
    
    &.vjs-slider-vertical {
      width: 0.5em !important;
      height: 5em !important;
      margin: 1em auto !important;
    }
  }
}

/* 设置内容区域的最小高度，确保内容可以滚动 */
.media-info-area, 
.episodes-area, 
.recommended-area {
  min-height: min-content;
}

/* 确保播放器内容区域有一个最小总高度 */
.player-content {
  min-height: 120vh; /* 确保始终有足够空间可滚动 */
} 