/* assets/css/player.css - Modern Custom HTML5 Video Player */
.custom-player-wrapper {
  position: relative;
  width: 100%;
  max-height: 75vh;
  min-height: 220px;
  background: #000;
  border-radius: var(--radius, 12px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

/* Portrait / Vertical Video (Reels / Shorts) Handling */
.custom-player-wrapper.is-portrait {
  max-height: 82vh;
}
@media (max-width: 768px) {
  .custom-player-wrapper.is-portrait {
    max-height: 80vh;
    height: auto;
  }
}

.custom-player-wrapper video {
  width: 100%;
  height: 100%;
  max-height: 75vh;
  object-fit: contain;
  background: #000;
  display: block;
  cursor: pointer;
}

.custom-player-wrapper.is-portrait video {
  max-height: 82vh;
  object-fit: contain;
}

/* Center Big Play Button */
.cp-center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.cp-center-icon {
  width: 72px;
  height: 72px;
  background: rgba(255, 42, 84, 0.9);
  background: linear-gradient(135deg, #ff2a54 0%, #ff6b4a 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.8rem;
  padding-left: 5px;
  box-shadow: 0 0 30px rgba(255, 42, 84, 0.6);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.cp-center-play:hover .cp-center-icon {
  transform: scale(1.12);
  box-shadow: 0 0 45px rgba(255, 42, 84, 0.85);
}

.custom-player-wrapper.is-playing .cp-center-play {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.85);
}

/* Loading Spinner */
.cp-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  pointer-events: none;
}

.cp-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: #ff2a54;
  border-radius: 50%;
  animation: cpSpin 0.8s linear infinite;
}

@keyframes cpSpin {
  to { transform: rotate(360deg); }
}

/* Double Tap Feedback Overlays */
.cp-tap-left, .cp-tap-right {
  position: absolute;
  top: 0;
  bottom: 60px;
  width: 40%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  transition: opacity 0.2s ease;
}
.cp-tap-left { left: 0; border-radius: 0 100px 100px 0; }
.cp-tap-right { right: 0; border-radius: 100px 0 0 100px; }
.cp-tap-left.active, .cp-tap-right.active {
  opacity: 1;
}
.cp-tap-left i, .cp-tap-right i {
  font-size: 1.8rem;
  margin-bottom: 4px;
}
.cp-tap-left span, .cp-tap-right span {
  font-size: 0.8rem;
  font-weight: 700;
}

/* Controls Overlay */
.cp-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1rem 1rem 0.65rem;
  background: linear-gradient(to top, rgba(5, 5, 12, 0.95) 0%, rgba(5, 5, 12, 0.75) 50%, rgba(5, 5, 12, 0) 100%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 8;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-player-wrapper.is-playing.hide-controls .cp-controls {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Progress Bar Container */
.cp-progress-container {
  position: relative;
  width: 100%;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}

.cp-progress-bar {
  position: relative;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  transition: height 0.15s ease;
}

.cp-progress-container:hover .cp-progress-bar,
.cp-progress-container.is-dragging .cp-progress-bar {
  height: 8px;
}

.cp-progress-buffer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  transition: width 0.2s ease;
}

.cp-progress-played {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #ff2a54 0%, #ff6b4a 100%);
  border-radius: 4px;
}

.cp-progress-thumb {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 42, 84, 0.8);
  transition: transform 0.15s ease;
  pointer-events: none;
}

.cp-progress-container:hover .cp-progress-thumb,
.cp-progress-container.is-dragging .cp-progress-thumb {
  transform: translateY(-50%) scale(1);
}

/* Time Tooltip on Hover */
.cp-time-tooltip {
  position: absolute;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(15, 15, 25, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  pointer-events: none;
  display: none;
  white-space: nowrap;
}

/* Controls Row */
.cp-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.cp-ctrl-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cp-btn {
  background: transparent;
  border: none;
  color: #f1f5f9;
  font-size: 1.05rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.cp-btn:hover {
  color: #ff2a54;
  background: rgba(255, 255, 255, 0.1);
}

.cp-btn:active {
  transform: scale(0.92);
}

.cp-btn-badge {
  position: absolute;
  bottom: 5px;
  right: 5px;
  font-size: 0.55rem;
  font-weight: 800;
  line-height: 1;
}

/* Volume Slider */
.cp-volume-group {
  display: flex;
  align-items: center;
  position: relative;
}

.cp-volume-slider-wrapper {
  width: 0;
  overflow: hidden;
  transition: width 0.2s ease, margin 0.2s ease;
  display: flex;
  align-items: center;
}

.cp-volume-group:hover .cp-volume-slider-wrapper {
  width: 65px;
  margin-left: 4px;
  margin-right: 4px;
}

.cp-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.cp-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #ff2a54;
  border-radius: 50%;
  cursor: pointer;
}

/* Time Display */
.cp-time-display {
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-left: 0.4rem;
  white-space: nowrap;
}

.cp-time-sep {
  margin: 0 3px;
  opacity: 0.6;
}

/* Speed Dropdown Menu */
.cp-speed-container {
  position: relative;
}

.cp-speed-btn {
  font-size: 0.8rem;
  font-weight: 700;
  width: auto;
  padding: 0 8px;
}

.cp-speed-menu {
  position: absolute;
  bottom: 42px;
  right: 0;
  background: #151528;
  border: 1px solid rgba(255, 42, 84, 0.3);
  border-radius: 8px;
  padding: 4px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  display: none;
  min-width: 110px;
  z-index: 10;
}

.cp-speed-menu.show {
  display: block;
}

.cp-speed-opt {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.cp-speed-opt:hover {
  background: rgba(255, 42, 84, 0.2);
  color: #ff2a54;
}

.cp-speed-opt.active {
  color: #ff2a54;
  font-weight: 800;
}

/* Mobile Tweaks */
@media (max-width: 600px) {
  .cp-btn {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  .cp-volume-group:hover .cp-volume-slider-wrapper {
    display: none;
  }
  .cp-time-display {
    font-size: 0.72rem;
    margin-left: 0.2rem;
  }
  .cp-controls {
    padding: 0.75rem 0.6rem 0.4rem;
  }
}

/* Fullscreen Mode Fix */
.custom-player-wrapper:fullscreen,
.custom-player-wrapper:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  background: #000 !important;
}
.custom-player-wrapper:fullscreen video,
.custom-player-wrapper:-webkit-full-screen video {
  max-height: 100vh !important;
}
