/**
 * Ahs Custom YouTube Player Styles
 * Modern, responsive, and optimized player design
 */

/* Player Container */
.ahs-youtube-player {
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.3s ease;
}

.ahs-youtube-player:hover {
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4);
}

/* Video Wrapper - 16:9 Aspect Ratio */
.ahs-video-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  border-radius: 12px;
}

.ahs-player-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.ahs-player-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Click overlay to block YouTube title/share/more videos */
.ahs-click-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 15%;
  z-index: 2;
  pointer-events: auto;
}

/* Strict Mode - Block all clicks on video frame */
.ahs-click-overlay.strict-mode-active {
  height: 100%;
  background: transparent;
  pointer-events: auto;
  cursor: default;
  z-index: 5;
}

/* When strict mode is active, make iframe not clickable */
.ahs-youtube-player[data-strict-mode="1"] .ahs-player-container {
  pointer-events: none !important;
}

.ahs-youtube-player[data-strict-mode="1"] .ahs-player-container iframe {
  pointer-events: none !important;
  user-select: none !important;
}

/* Controls in strict mode desktop: selalu tampil di bawah video (position relative) */
.ahs-youtube-player[data-strict-mode="1"] .ahs-controls {
  pointer-events: auto !important;
  z-index: 15 !important;
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  background: #0f0f0f !important;
  padding: 15px !important;
  margin: 0 !important;
  border-radius: 0 0 12px 12px !important;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3) !important;
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
  transition: none !important;
}

/* Strict mode mobile/fullscreen: controls dipindah JS ke dalam video-wrapper, jadi overlay */
/* Pakai data attribute untuk specificity lebih tinggi dari rule strict-mode di atas */
.ahs-youtube-player[data-strict-mode="1"] .ahs-video-wrapper .ahs-controls {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent) !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  display: block !important;
  transition: opacity 0.3s ease, visibility 0.3s ease !important;
  z-index: 10 !important;
}

.ahs-youtube-player[data-strict-mode="1"] .ahs-video-wrapper .ahs-controls.visible {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Solid background for control buttons in strict mode */
.ahs-youtube-player[data-strict-mode="1"] .ahs-btn {
  background: var(--ahs-primary-color, #ff0000) !important;
  border-radius: 6px !important;
}

.ahs-youtube-player[data-strict-mode="1"] .ahs-btn svg {
  fill: #ffffff !important;
}

.ahs-youtube-player[data-strict-mode="1"] .ahs-btn:hover {
  opacity: 0.8 !important;
}

.ahs-youtube-player[data-strict-mode="1"] .ahs-btn:active {
  opacity: 0.6 !important;
  transform: scale(0.95) !important;
}

/* Progress bar styling in strict mode */
.ahs-youtube-player[data-strict-mode="1"] .ahs-progress-bar {
  background: rgba(255, 255, 255, 0.2) !important;
}

.ahs-youtube-player[data-strict-mode="1"] .ahs-progress-container {
  margin-bottom: 20px !important;
}

/* Make video wrapper rounded only on top in strict mode */
.ahs-youtube-player[data-strict-mode="1"] .ahs-video-wrapper {
  border-radius: 12px 12px 0 0 !important;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3) !important;
  cursor: default !important;
  flex-shrink: 0 !important;
}

/* Remove box-shadow from main container in strict mode */
.ahs-youtube-player[data-strict-mode="1"] {
  box-shadow: none !important;
  background: transparent !important;
  overflow: visible !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Hide center play button in strict mode */
.ahs-youtube-player[data-strict-mode="1"] .ahs-center-play-btn {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Lazy Load Thumbnail */
.ahs-thumbnail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: pointer;
  background: linear-gradient(to bottom, rgba(0,0,0,0.3), rgba(0,0,0,0.5));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.ahs-thumbnail-overlay:hover {
  background: linear-gradient(to bottom, rgba(0,0,0,0.2), rgba(0,0,0,0.4));
}

/* Center Play Button (appears when paused) */
.ahs-center-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.ahs-center-play-btn.show {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.ahs-center-play-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: translate(-50%, -50%) scale(1.1);
}

.ahs-center-play-btn:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.ahs-center-play-btn svg {
  width: 40px;
  height: 40px;
  fill: white;
  pointer-events: none;
}

.ahs-thumbnail-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
}

.ahs-play-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  border: none;
  cursor: pointer;
  padding: 0;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.ahs-play-button:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.ahs-play-button svg {
  width: 40px;
  height: 40px;
  fill: white;
  pointer-events: none;
}

/* Controls Container */
.ahs-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  padding: 20px 15px 10px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.ahs-controls.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Progress Bar */
.ahs-progress-container {
  position: relative;
  width: 100%;
  margin-bottom: 10px;
  height: 6px;
  cursor: pointer;
}

.ahs-progress-bar {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: height 0.2s ease;
}

.ahs-progress-bar:hover {
  height: 8px;
}

.ahs-progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--ahs-primary-color, #ff0000);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.ahs-progress-bar:hover::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
}

.ahs-progress-bar::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--ahs-primary-color, #ff0000);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.ahs-progress-bar:hover::-moz-range-thumb {
  width: 16px;
  height: 16px;
}

/* Control Buttons */
.ahs-controls-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.ahs-controls-left,
.ahs-controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ahs-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  outline: none;
}

.ahs-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.ahs-btn:active {
  transform: scale(0.95);
}

.ahs-btn svg {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

/* Seek Buttons */
.ahs-seek-backward,
.ahs-seek-forward {
  position: relative;
}

.ahs-seek-value {
  position: absolute;
  font-size: 10px;
  font-weight: bold;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Volume Controls */
.ahs-volume-slider-container {
  width: 0;
  overflow: hidden;
  transition: width 0.3s ease;
}

.ahs-controls-left:hover .ahs-volume-slider-container,
.ahs-volume-slider-container:hover {
  width: 80px;
}

.ahs-volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.ahs-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
}

.ahs-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Time Display */
.ahs-time-display {
  font-size: 13px;
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
}

/* Speed Control */
.ahs-speed-control {
  position: relative;
}

.ahs-speed-btn {
  min-width: 45px;
}

.ahs-speed-value {
  font-size: 13px;
  font-weight: 600;
}

.ahs-speed-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 10px;
  background: rgba(28, 28, 28, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.ahs-speed-control:hover .ahs-speed-menu,
.ahs-speed-menu:hover {
  display: flex;
}

.ahs-speed-menu button {
  background: none;
  border: none;
  color: #fff;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  transition: background 0.2s ease;
}

.ahs-speed-menu button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ahs-speed-menu button.active {
  background: var(--ahs-primary-color, #ff0000);
  font-weight: 600;
}

/* Quality Control */
.ahs-quality-control {
  position: relative;
}

.ahs-quality-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 10px;
  background: rgba(28, 28, 28, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 100px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.ahs-quality-control:hover .ahs-quality-menu,
.ahs-quality-menu:hover {
  display: flex;
}

.ahs-quality-menu button {
  background: none;
  border: none;
  color: #fff;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  transition: background 0.2s ease;
}

.ahs-quality-menu button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ahs-quality-menu button.active {
  background: var(--ahs-primary-color, #ff0000);
  font-weight: 600;
}

/* Fullscreen Styles */
.ahs-youtube-player:fullscreen,
.ahs-youtube-player:-webkit-full-screen,
.ahs-youtube-player:-moz-full-screen,
.ahs-youtube-player:-ms-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none !important;
  border-radius: 0;
}

.ahs-youtube-player:fullscreen .ahs-video-wrapper,
.ahs-youtube-player:-webkit-full-screen .ahs-video-wrapper,
.ahs-youtube-player:-moz-full-screen .ahs-video-wrapper {
  padding-bottom: 0;
  height: 100%;
}

.ahs-youtube-player:fullscreen .ahs-controls,
.ahs-youtube-player:-webkit-full-screen .ahs-controls,
.ahs-youtube-player:-moz-full-screen .ahs-controls,
.ahs-youtube-player:-ms-fullscreen .ahs-controls {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
}

/* Fullscreen with Strict Mode */
.ahs-youtube-player[data-strict-mode="1"]:fullscreen,
.ahs-youtube-player[data-strict-mode="1"]:-webkit-full-screen,
.ahs-youtube-player[data-strict-mode="1"]:-moz-full-screen,
.ahs-youtube-player[data-strict-mode="1"]:-ms-fullscreen {
  display: block !important;
  position: relative !important;
  background: #000 !important;
}

.ahs-youtube-player[data-strict-mode="1"]:fullscreen .ahs-video-wrapper,
.ahs-youtube-player[data-strict-mode="1"]:-webkit-full-screen .ahs-video-wrapper,
.ahs-youtube-player[data-strict-mode="1"]:-moz-full-screen .ahs-video-wrapper,
.ahs-youtube-player[data-strict-mode="1"]:-ms-fullscreen .ahs-video-wrapper {
  position: relative !important;
  height: 100vh !important;
  padding-bottom: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.ahs-youtube-player[data-strict-mode="1"]:fullscreen .ahs-controls,
.ahs-youtube-player[data-strict-mode="1"]:-webkit-full-screen .ahs-controls,
.ahs-youtube-player[data-strict-mode="1"]:-moz-full-screen .ahs-controls,
.ahs-youtube-player[data-strict-mode="1"]:-ms-fullscreen .ahs-controls {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100vw !important;
  border-radius: 0 !important;
  pointer-events: auto !important;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.7)) !important;
  padding: 25px 20px 20px !important;
  z-index: 2147483647 !important;
  min-height: 90px !important;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5) !important;
  opacity: 0 !important;
  visibility: hidden !important;
  display: block !important;
  transition: opacity 0.3s ease, visibility 0.3s ease !important;
}

.ahs-youtube-player[data-strict-mode="1"]:fullscreen .ahs-controls.visible,
.ahs-youtube-player[data-strict-mode="1"]:-webkit-full-screen .ahs-controls.visible,
.ahs-youtube-player[data-strict-mode="1"]:-moz-full-screen .ahs-controls.visible,
.ahs-youtube-player[data-strict-mode="1"]:-ms-fullscreen .ahs-controls.visible {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Loading State */
.ahs-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 16px;
  z-index: 3;
}

/* Responsive Design */
@media (max-width: 768px) {
  .ahs-controls {
    padding: 12px 8px 6px;
  }

  .ahs-btn {
    padding: 4px;
  }

  .ahs-btn svg {
    width: 18px;
    height: 18px;
  }

  .ahs-time-display {
    font-size: 10px;
  }

  .ahs-controls-left,
  .ahs-controls-right {
    gap: 3px;
  }

  .ahs-volume-slider-container {
    display: none;
  }

  .ahs-speed-menu,
  .ahs-quality-menu {
    min-width: 80px;
    font-size: 11px;
  }

  .ahs-play-button svg {
    width: 50px;
    height: 35px;
  }

  .ahs-center-play-btn {
    width: 60px;
    height: 60px;
  }

  .ahs-center-play-btn svg {
    width: 30px;
    height: 30px;
  }
}

@media (max-width: 480px) {
  .ahs-seek-backward,
  .ahs-seek-forward {
    display: none;
  }

  .ahs-controls-bottom {
    gap: 3px;
  }

  .ahs-btn {
    padding: 3px;
  }

  .ahs-btn svg {
    width: 16px;
    height: 16px;
  }

  .ahs-time-display {
    font-size: 9px;
  }

  .ahs-center-play-btn {
    width: 50px;
    height: 50px;
  }

  .ahs-center-play-btn svg {
    width: 25px;
    height: 25px;
  }
}

/* Accessibility */
.ahs-btn:focus-visible {
  outline: 2px solid var(--ahs-primary-color, #ff0000);
  outline-offset: 2px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .ahs-youtube-player {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  }
}

/* Print Styles */
@media print {
  .ahs-controls {
    display: none;
  }
}
