/* Hide both player types by default */
#video-container,
#audio-container {
  display: none;
}

/* Outer layout container */
.csl-player-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  position: relative;
  background-color: black;
  max-width: 1300px;
  min-height: 564.75px;
  overflow: hidden; /* Prevent overflow issues */
  z-index: 0;
}

/* Video styling */
.csl-player-container video {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  display: block;
  background-color: black;
  z-index: 1 !important;
}

/* Ensure Shaka UI elements are properly positioned */
.shaka-video-container {
  width: 100% !important;
  height: 100% !important;
  position: relative !important;
  background-color: black;
}

/* Ensure control panel is visible */
.shaka-control-panel {
  position: relative !important;
  width: 100% !important;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8)) !important;
  z-index: 10000 !important;
  opacity: 1 !important;
  transition: opacity 0.3s ease !important;
}

/* Ensure bottom controls are full width and at the bottom */
.shaka-bottom-controls {
  width: 98% !important;
  padding: 0 !important;
  z-index: 10001 !important;
}

/* Ensure buttons are visible */
.shaka-control-panel button {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Cast button styling */
.shaka-cast-button {
  color: white !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Ensure spinner overlay doesn't interfere with controls */
.shaka-spinner-container {
  z-index: 50 !important;
}

/* Audio container */
#audio-container {
  display: none;
  width: 100%;
  background-color: #000;
  padding: 1em 0;
  text-align: center;
}

#audio-container audio {
  width: 90%;
  max-width: 600px;
}

/* Loading overlay */
#player-loading-message {
  position: absolute;
  inset: 0;
  z-index: 200; /* Higher than controls */
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.85);
  pointer-events: none; /* Allow clicks through when hidden */
}

#player-loading-message img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

/* Show loading message when visible */
#player-loading-message:not([style*="display: none"]) {
  pointer-events: auto;
}

/* Responsive design */
@media (max-width: 768px) {
  .csl-player-container {
    min-height: 200px;
  }

  .shaka-control-panel {
    padding: 8px !important;
  }

  .shaka-control-panel button {
    margin: 0 4px !important;
  }
}

/* Ensure controls are always accessible */
.shaka-controls-container:hover .shaka-control-panel,
.shaka-controls-container:focus-within .shaka-control-panel,
.shaka-controls-container.shaka-controls-shown .shaka-control-panel {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Force show controls on touch devices */
@media (hover: none) and (pointer: coarse) {
  .shaka-control-panel {
    opacity: 1 !important;
    visibility: visible !important;
  }
}

/* Debug styles - remove these once working */
/*
.csl-player-container * {
  border: 1px solid rgba(255, 0, 0, 0.1);
}

#video-container {
  border: 2px solid green !important;
}

#video {
  border: 2px solid blue !important;
}

.shaka-control-panel {
  border: 2px solid yellow !important;
}
*/

/* Ensure overflow menu and settings text is white */
.shaka-overflow-menu,
.shaka-overflow-menu *,
.shaka-settings-menu,
.shaka-settings-menu * {
  color: white !important;
}
