/* Advanced Video Player Styles */

/* Base Player Container */
.player-container {
  position: relative;
  width: 100%;
  height: 100%; /* Fixed: Fill container */
  background: #000 !important;
  overflow: hidden;
  font-family: "Inter", sans-serif;
  user-select: none; /* Prevent text selection on double clicks */
}

.video-element {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: object-fit 0.2s;
}

/* Hide default browser video controls (specifically the center play button) */
.video-element::-webkit-media-controls-start-playback-button,
.video-element::-webkit-media-controls-play-button,
.video-element::-webkit-media-controls-overlay-play-button {
  display: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}

/* Maximized Mode (Double Tap) */
.video-maximized {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 9999 !important;
  background: #000 !important;
  border-radius: 0 !important;
  border: none !important;
  outline: none !important;
  transform: none !important;
  aspect-ratio: auto !important;
}

/* New UI Overlay */
.player-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.8) 0%,
    rgba(0, 0, 0, 0) 20%,
    rgba(0, 0, 0, 0) 60%,
    rgba(0, 0, 0, 0.9) 100%
  );
  pointer-events: none; /* Let clicks pass to video for toggle */
}

/* Show UI on hover/active */
.player-container:hover .player-ui,
.player-ui.active {
  opacity: 1;
}

/* Top Bar (Info / Back) */
.player-top-bar {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
}

.player-title {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  opacity: 0.9;
}

.info-icon {
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.info-icon:hover {
  opacity: 1;
}

/* Bottom Control Bar */
.player-controls-area {
  padding: 20px;
  padding-bottom: 25px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

/* Progress Bar Container */
.progress-container {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  position: relative;
  border-radius: 2px;
  transition: height 0.1s;
}

.progress-container:hover {
  height: 8px; /* Expand on hover */
}

.progress-fill {
  height: 100%;
  background: #ff6b00;
  width: 0%;
  border-radius: 2px;
  position: relative;
  transition: width 0.1s linear;
}

.progress-handle {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.1s;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.progress-container:hover .progress-handle {
  transform: translateY(-50%) scale(1);
}

/* Controls Row */
.controls-row {
  display: flex;
  align-items: center;
  gap: 15px;
  color: white;
}

/* Buttons */
.player-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition:
    background 0.2s,
    transform 0.1s;
}

.player-btn:hover,
.player-btn:focus {
  background: rgba(255, 255, 255, 0.15);
}

.player-btn:active {
  transform: scale(0.95);
}

/* Volume Slider */
.volume-wrapper {
  display: flex;
  align-items: center;
  position: relative;
}

.volume-container {
  display: flex;
  align-items: center;
  width: 0;
  overflow: hidden;
  transition: width 0.3s ease;
  margin-left: 5px;
}

.volume-wrapper:hover .volume-container,
.volume-wrapper:focus-within .volume-container {
  width: 80px;
}

input[type="range"].volume-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  outline: none;
}

input[type="range"].volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
}

/* Time Display */
.time-display-text {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: #ddd;
  margin-right: auto; /* Push right controls to right */
  display: flex;
  align-items: center;
}

/* Right Side Controls */
.right-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Settings Menu Overlay */
.settings-menu {
  position: absolute;
  bottom: 80px;
  right: 20px;
  width: 260px;
  max-height: 70%;
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 10px 0;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.6);
  z-index: 110;
  display: none;
  animation: slideUp 0.15s ease-out;
  pointer-events: auto;
  overflow: hidden; /* Hide scrollbars for main, handle in submenu */
}

.settings-menu.active {
  display: block;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-main {
  width: 100%;
}

.settings-item {
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: #eee;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}

.settings-item span:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-item:hover,
.settings-item:focus {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #ff6b00;
  outline: none;
}

.settings-value {
  opacity: 0.6;
  font-size: 0.8rem;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sub-Menu */
.settings-submenu {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: rgba(20, 20, 20, 0.98);
  z-index: 120;
  display: none;
  flex-direction: column;
  overflow-y: auto; /* Allow scrolling for long lists */
}

.settings-submenu::-webkit-scrollbar {
  width: 4px;
}
.settings-submenu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.settings-submenu.active {
  display: flex;
  animation: slideInRight 0.15s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.submenu-header {
  padding: 12px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: rgba(30, 30, 30, 0.8);
  position: sticky;
  top: 0;
  z-index: 10;
}

.submenu-header:hover {
  background: rgba(60, 60, 60, 0.8);
}

/* Loaders/Errors */
.video-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3.5rem;
  color: #ff6b00;
  z-index: 90;
  pointer-events: none;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.5));
}

.video-error {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 10, 0.9);
  z-index: 95;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  gap: 15px;
  backdrop-filter: blur(5px);
}

.video-error button:hover {
  background: rgba(255, 255, 255, 0.2) !important;
}

/* Fullscreen Helper */
:fullscreen .player-container {
  width: 100vw;
  height: 100vh;
  background: black;
}

body.player-fullscreen-active .top-bar {
  display: none !important;
}

/* Details View Override / Embed Mode */
.details-player-container .player-container {
  border-radius: 8px; /* Round corners if embedded */
}

/* Added Styles for JS Refactor */
.video-error-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.video-error-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.live-badge {
  margin-left: 10px;
  color: #ff3b30; /* Bright Red */
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.6;
  }
}

.settings-item.active {
  color: #ff6b00;
  font-weight: 500;
  background: rgba(255, 107, 0, 0.1); /* Subtle highlight background */
}

/* --- Persistent Dock Styles --- */
.player-dock {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 600px;
  height: 338px;
  z-index: 9999;
  pointer-events: none; /* Allow clicks through empty dock */
  /* Only visible when it has content usually */
}

/* When player is successfully appended to dock, we add this class to keys */
.player-container.player-docked {
  width: 600px !important;
  height: 338px !important;
  position: fixed;
  bottom: 30px;
  right: 30px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  z-index: 10000;
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: visible; /* Allow close button to be seen outside */
}

.player-container.player-docked:hover {
  transform: scale(1.02);
  transition: transform 0.2s;
}

/* Hide some controls when docked */
.player-container.player-docked .player-controls-area {
  display: none; /* Hide full controls */
}
.player-container.player-docked .settings-menu {
  display: none !important; /* Force hide settings */
}
.player-container.player-docked .player-top-bar {
  padding: 10px;
}
.player-container.player-docked .player-title {
  font-size: 0.9rem;
}
.player-container.player-docked .info-icon {
  display: none;
}

/* Add a close/undock button or just rely on click to restore? */
/* Usually click restores. We can add a simple close X */
.player-dock-close {
  position: absolute;
  top: -15px;
  right: -15px;
  width: 40px;
  height: 40px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  display: flex !important; /* Force display flex */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10001;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  border: 2px solid white;
  transition: transform 0.2s;
}
.player-dock-close:hover {
  transform: scale(1.1);
  background: #ff6b81;
}
.player-container.player-docked:hover .player-dock-close {
  display: flex;
}
/* Seek Overlay (YouTube-like) */
.seek-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 15px 25px;
  border-radius: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 1.2rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  z-index: 80;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.2s,
    transform 0.2s;
}

.seek-overlay.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

.seek-overlay i {
  font-size: 1.8rem;
}

.seek-text {
  font-size: 0.9rem;
  opacity: 0.9;
}
