/* ===== MEDIA OVERLAY STYLES ===== */

/* Simple Media Overlay - Fixed class name consistency */
.simple-media-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  /* 100dvh: usable height on portrait touch screens (browser chrome); 100vh fallback */
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  background: rgba(0, 0, 0, 0.85) !important;
  z-index: 1999 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease-in, transform 0.3s ease-in;
  box-sizing: border-box !important;
}

.simple-media-overlay.fade-in {
  opacity: 1;
  transform: translateY(0);
}

/* Make toolbar semi-transparent when media is active */
.simple-media-overlay.fade-in ~ #broadcast-toolbar {
  background: rgba(0, 0, 0, 0.7) !important;
  backdrop-filter: blur(15px) !important;
}

.media-content {
  position: relative;
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.media-loading {
  display: none; /* Hide loading animation */
}

.media-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
}

.drawing-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  width: 100%;
  height: 100%;
  z-index: 1001;
}

/* contain: portrait (or landscape) media fits the visible area without cropping — best for portrait screens */
.media-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  object-fit: contain;
  object-position: center center;
  vertical-align: middle;
  z-index: 100;
}

.media-video {
  width: 100%;
  max-width: 100vw;
  height: calc(100vh - 80px);
  height: calc(100dvh - 80px);
  max-height: calc(100dvh - 80px);
  object-fit: contain;
  object-position: center;
  box-shadow: none;
  border: none;
  outline: none;
  pointer-events: auto;
  cursor: pointer;
  background: #000;
  z-index: 100;
}

/* Custom Video Controls */
.video-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: calc(100vh - 80px); /* Leave space for controls */
  display: flex;
  flex-direction: column;
  z-index: 1000; /* Ensure video container is above canvas */
  background: #000;
}

.video-controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 15px;
  background: none; /* Remove background */
  padding: 12px 20px;
  border-radius: 12px;
  opacity: 1; /* Always visible for touch screens */
  transition: opacity 0.3s ease;
  z-index: 2000; /* Same as main toolbar z-index */
  pointer-events: auto; /* Ensure controls are clickable */
  min-width: 300px;
  box-shadow: none; /* Remove shadow */
}

.video-play-pause {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.video-play-pause:hover {
  background: rgba(255, 255, 255, 0.2);
}

.video-progress-container {
  flex: 1;
  height: 20px;
  display: flex;
  align-items: center;
}

.video-progress-bar {
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
  cursor: pointer;
  position: relative;
  box-shadow: none;
  border: none;
  outline: none;
}

.video-progress-fill {
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 1px;
  transition: width 0.1s ease;
}

.media-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #ff6b6b;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.8);
  padding: 30px;
  border-radius: 15px;
  backdrop-filter: blur(10px);
}

.error-icon {
  font-size: 48px;
  margin-bottom: 20px;
}
.media-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  transition: opacity 0.3s ease;
  opacity: 0.5;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.media-close-btn:hover {
  opacity: 1;
}

/* L.cascadeButtons customization */
.leaflet-control-cascade-buttons {
  background: rgba(0, 0, 0, 0.85) !important;
  border: 2px solid #00a8ff !important;
  border-radius: 12px !important;
  backdrop-filter: blur(10px) !important;
}

.leaflet-control-cascade-buttons .cascade-button {
  background: linear-gradient(135deg, #2c3e50, #34495e) !important;
  border: 1px solid #00a8ff !important;
  color: white !important;
  font-size: 18px !important;
  border-radius: 8px !important;
  margin: 2px !important;
  transition: all 0.3s ease !important;
}

.leaflet-control-cascade-buttons .cascade-button:hover,
.leaflet-control-cascade-buttons .cascade-button:active {
  background: linear-gradient(135deg, #00a8ff, #0078d4) !important;
  transform: scale(0.95) !important;
  box-shadow: 0 0 10px rgba(0, 168, 255, 0.5) !important;
}

/* Media Selector Overlay */
.media-selector {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2500;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(10px);
}

.media-selector-content {
  background: rgba(0, 0, 0, 0.95);
  border: 2px solid #00a8ff;
  border-radius: 15px;
  padding: 30px;
  max-width: 80vw;
  max-height: 80vh;
  overflow-y: auto;
}

.media-selector-content h3 {
  color: #00a8ff;
  text-align: center;
  margin-bottom: 20px;
  font-size: 24px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.media-item {
  background: #2c3e50;
  border: 2px solid #34495e;
  border-radius: 10px;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: white;
}

.media-item:hover {
  border-color: #00a8ff;
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(0, 168, 255, 0.3);
}

.media-item img, .media-item video {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 5px;
  margin-bottom: 10px;
}

.media-item .media-name {
  font-size: 14px;
  font-weight: bold;
  color: #00a8ff;
}

.close-selector {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: block;
  margin: 0 auto;
  transition: all 0.2s ease;
}

.close-selector:hover {
  background: #c0392b;
  transform: scale(1.05);
}

/* Full-Screen Media Overlay */
.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.fullscreen-overlay.fade-in {
  opacity: 1;
}

#fullscreen-content {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#fullscreen-content img, 
#fullscreen-content video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.close-fullscreen {
  position: absolute;
  top: 30px;
  right: 30px;
  font-size: 24px;
  background: rgba(231, 76, 60, 0.4);
  color: #fff;
  border: 5px solid red;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  z-index: 3000;
  transition: all 0.2s ease;
  backdrop-filter: blur(5px);
}

.close-fullscreen:hover {
  background: rgba(192, 57, 43, 0.6);
  transform: scale(1.1);
}

/* Drawing overlay for telestration on media */
.drawing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1500; /* Below video controls */
}

.drawing-overlay.active {
  pointer-events: all;
}

/* Make toolbar semi-transparent when media is full-screen */
.fullscreen-overlay.fade-in ~ #broadcast-toolbar {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(15px);
}

/* Legacy Media Controls (keeping for compatibility) */
.media-controls {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #00a8ff;
  border-radius: 15px;
  padding: 20px;
  z-index: 2000;
  backdrop-filter: blur(10px);
}

.media-controls h3 {
  color: #00a8ff;
  text-align: center;
  margin-bottom: 15px;
}

.media-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
}

.media-buttons button {
  padding: 8px 15px;
  background: linear-gradient(135deg, #00a8ff, #0078d4);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.media-buttons button:hover {
  background: linear-gradient(135deg, #0078d4, #005a9e);
  transform: scale(1.05);
}

#mediaCanvas {
  border: 2px solid #00a8ff;
  border-radius: 8px;
  background: #000;
}