/* E-Map and PTZ Styles - iSurveillance VMS 4.0 */

.view-map {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Enforce auto height for E-Map header with nested rows to bring the title closer to top and group filters underneath */
.view-map .view-header.compact {
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  margin-top: -20px !important; /* Shift entire header up by another 10px (total 20px) as requested! */
  margin-bottom: 12px !important;
  padding: 0 !important;
  padding-top: 2px !important; /* Move title closer to top bar! */
  border-bottom: 1px solid rgba(0, 242, 254, 0.08) !important;
  box-sizing: border-box !important;
}

.view-map .header-title-row {
  display: flex !important;
  width: 100% !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.view-map .header-sub-row {
  display: flex !important;
  width: 100% !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-top: 4px !important;
}

.view-map .authority-selector.no-border-bg {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin-top: -2px !important;
  margin-bottom: 4px !important;
}

.view-map .authority-selector.no-border-bg .selector-title {
  margin-left: 0 !important;
  padding-left: 0 !important;
  font-size: 11px !important;
  color: rgba(255, 255, 255, 0.6) !important;
}

.view-map .view-header.compact h2 {
  font-size: 22px !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  white-space: nowrap !important;
}

.view-map .view-header.compact h2 .subtitle {
  font-size: 10.5px !important;
  margin-left: 8px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 250px !important;
  display: inline-block !important;
  vertical-align: baseline !important;
}

.layer-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.layer-selector .label {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

.layer-btn {
  background: transparent;
  border: 1px solid rgba(0, 242, 254, 0.15);
  color: rgba(255,255,255,0.7);
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.layer-btn:hover {
  background: rgba(0, 242, 254, 0.1);
  color: #fff;
}

.layer-btn.active {
  background: var(--primary);
  color: #070b19;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 0 10px var(--primary-glow);
}

/* Map Grid */
.map-body-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  flex: 1 !important;
  overflow: hidden;
}

.map-canvas-container {
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #02040b;
}

.high-tech-map {
  width: 100%;
  height: 100%;
  position: relative;
}

.grid-scanning-map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(0, 242, 254, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 242, 254, 0.04) 1px, transparent 1px);
  background-size: 25px 25px;
  pointer-events: none;
}

.map-roads-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Map pins */
.map-pin {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(7, 11, 25, 0.85);
  border: 1px solid var(--border-glass);
  padding: 4px 8px;
  border-radius: 20px;
  cursor: pointer;
  z-index: 20;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.map-pin:hover, .map-pin.selected {
  transform: scale(1.1);
  background: rgba(14, 21, 46, 0.95);
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

.pin-icon {
  font-size: 11px;
}

.pin-label {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

.pin-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Color states */
.map-pin.online .pin-pulse { background: var(--green); box-shadow: 0 0 6px var(--green); }
.map-pin.offline .pin-pulse { background: var(--red); box-shadow: 0 0 6px var(--red); animation: pulse-red 1.2s infinite; }
.map-pin.maintenance .pin-pulse { background: var(--amber); box-shadow: 0 0 6px var(--amber); }

/* PTZ Panel */
.ptz-control-panel {
  padding: 15px;
  display: flex;
  flex-direction: column;
  background: rgba(14, 21, 46, 0.5);
  overflow-y: auto;
}

.selected-cam-banner {
  background: rgba(0, 242, 254, 0.05);
  border: 1px solid rgba(0, 242, 254, 0.15);
  border-radius: 4px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.selected-cam-banner .cam-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary);
  font-weight: bold;
}

.selected-cam-banner .cam-name {
  font-size: 13px;
  color: #fff;
  font-weight: 600;
}

.quick-live-preview {
  height: 160px;
  background: #000;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}

.preview-overlay {
  position: absolute;
  top: 6px;
  left: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: var(--primary);
  font-size: 9px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid rgba(0, 242, 254, 0.2);
}

.offline-placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
  gap: 6px;
  font-size: 12px;
}

.offline-placeholder .warning-icon {
  font-size: 24px;
  animation: blink-badge 1s infinite alternate;
}

.offline-placeholder .sub {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
}

/* Command Echo Tracker */
.command-echo-container {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(0, 242, 254, 0.08);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 15px;
}

.echo-title-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 8px;
}

.echo-state {
  font-weight: bold;
}
.echo-state.Idle { color: rgba(255,255,255,0.4); }
.echo-state.Sent { color: var(--amber); }
.echo-state.Received { color: var(--primary); }
.echo-state.Executing { color: var(--secondary); }

.echo-tracker-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tracker-step {
  font-size: 9px;
  color: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 3px;
  flex: 1;
  text-align: center;
  margin: 0 2px;
  transition: all 0.2s ease;
}

.tracker-step.active {
  background: rgba(0, 242, 254, 0.1);
  color: var(--primary);
  border-color: var(--primary);
}

.tracker-step.done {
  background: rgba(16, 172, 132, 0.1);
  color: var(--green);
  border-color: var(--green);
}

.echo-feedback-message {
  font-size: 10px;
  color: var(--primary);
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 2px;
}

/* Joystick Controls */
.ptz-joystick-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.ptz-joystick-section.disabled, .preset-controls-section.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.ptz-joystick {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.5);
}

.joy-btn {
  position: absolute;
  background: rgba(14, 21, 46, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  transition: all 0.2s;
}

.joy-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.joy-btn.up { top: 6px; }
.joy-btn.down { bottom: 6px; }
.joy-btn.left { left: 6px; }
.joy-btn.right { right: 6px; }

.joy-center {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
}

.zoom-focus-controls {
  flex: 1;
  margin-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zoom-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.zoom-row span {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
}

.zoom-btn {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
  margin-right: 4px;
}

.zoom-btn:hover {
  background: rgba(0, 242, 254, 0.06);
  border-color: var(--primary);
  color: #fff;
}

/* Presets & Speed Slider */
.slider-row {
  margin-bottom: 12px;
}

.slider-row .label {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 4px;
  display: block;
}

.range-slider {
  width: 100%;
  accent-color: var(--primary);
  background: rgba(255,255,255,0.08);
}

.preset-row {
  display: flex;
  gap: 8px;
}

.select-ctrl {
  flex: 1;
  background: rgba(7, 11, 25, 0.9);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 3px;
  padding: 6px;
  font-size: 11px;
}

.btn-primary {
  background: var(--primary);
  color: #070b19;
  border: none;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
  box-shadow: 0 0 10px var(--primary-glow);
  transition: transform 0.2s;
}

.btn-primary:hover {
  transform: scale(1.03);
}

/* Empty State */
.ptz-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.3);
  text-align: center;
  padding: 20px;
  gap: 15px;
}

.ptz-empty-state .compass-graphic {
  font-size: 40px;
  animation: float-compass 3s infinite ease-in-out;
}

@keyframes float-compass {
  0% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

/* Full-width Map Layout */
.map-body-grid.full-width {
  grid-template-columns: 1fr;
}

/* Leaflet High-tech Dark Theme Styling Overrides */
.leaflet-container {
  background: #02040b !important;
}

.leaflet-bar {
  background: rgba(14, 21, 46, 0.8) !important;
  border: 1px solid var(--border-glass) !important;
  border-radius: 4px !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}
.leaflet-bar a {
  background: transparent !important;
  color: var(--primary) !important;
  border-bottom: 1px solid rgba(0, 242, 254, 0.15) !important;
  transition: all 0.2s;
}
.leaflet-bar a:hover {
  background: rgba(0, 242, 254, 0.1) !important;
  color: #fff !important;
}
.leaflet-control-layers {
  background: rgba(14, 21, 46, 0.85) !important;
  border: 1px solid var(--border-glass) !important;
  color: #e2e8f0 !important;
  font-family: var(--font-family) !important;
  font-size: 11px !important;
  border-radius: 6px !important;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37) !important;
}
.leaflet-control-layers-list {
  padding: 4px;
}
.leaflet-control-layers-base label {
  margin: 4px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.leaflet-control-attribution {
  background: rgba(7, 11, 25, 0.8) !important;
  color: rgba(255, 255, 255, 0.4) !important;
  font-size: 9px !important;
  border-top-left-radius: 4px;
}
.leaflet-control-attribution a {
  color: var(--primary) !important;
}

/* Custom Sci-Fi Camera Markers (Dynamic SVG pin from icon_cctv1.svg) */
.custom-marker-icon {
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-svg-container {
  width: 32px;
  height: 36px;
  position: relative;
  transition: transform 0.2s ease-in-out;
  z-index: 2;
}

/* Svg path colors depending on online/offline/maintenance status */
/* Online: Green theme */
.custom-marker-icon.online .svg-pin-bg { fill: rgba(16, 172, 132, 0.75); }
.custom-marker-icon.online .svg-pin-border { fill: var(--green); filter: drop-shadow(0 0 3px var(--green-glow)); }

/* Offline: Red theme */
.custom-marker-icon.offline .svg-pin-bg { fill: rgba(238, 82, 83, 0.75); }
.custom-marker-icon.offline .svg-pin-border { fill: var(--red); filter: drop-shadow(0 0 3px var(--red-glow)); }

/* Maintenance: Amber theme */
.custom-marker-icon.maintenance .svg-pin-bg { fill: rgba(255, 159, 67, 0.75); }
.custom-marker-icon.maintenance .svg-pin-border { fill: var(--amber); filter: drop-shadow(0 0 3px var(--amber-glow)); }

/* Selection/Active Hover state: Cyan theme override! */
.custom-marker-icon.selected .svg-pin-bg, 
.custom-marker-icon:hover .svg-pin-bg { 
  fill: rgba(7, 11, 25, 0.9) !important; 
}
.custom-marker-icon.selected .svg-pin-border, 
.custom-marker-icon:hover .svg-pin-border { 
  fill: var(--primary) !important; 
  filter: drop-shadow(0 0 6px var(--primary-glow)) !important;
}

/* Pulse rings positioned right at the teardrop pointer anchor (bottom center) */
.custom-marker-icon .marker-pulse-ring {
  position: absolute;
  bottom: 0px;
  left: 16px;
  transform: translate(-50%, 50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
}

.custom-marker-icon.online .marker-pulse-ring {
  border: 2px solid var(--green);
  animation: marker-pulse-green 1.8s infinite;
}
.custom-marker-icon.offline .marker-pulse-ring {
  border: 2px solid var(--red);
  animation: marker-pulse-red 1.2s infinite;
}
.custom-marker-icon.maintenance .marker-pulse-ring {
  border: 2px solid var(--amber);
  animation: marker-pulse-amber 1.8s infinite;
}

/* Hover Device ID Popout Bubble */
.marker-hover-id {
  position: absolute;
  bottom: 42px; /* Positioned above the pin */
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background: rgba(7, 11, 25, 0.95);
  border: 1px solid var(--border-glass);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.custom-marker-icon:hover .marker-hover-id,
.custom-marker-icon.selected .marker-hover-id {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

/* Marker hover zoom scale */
.custom-marker-icon:hover .marker-svg-container,
.custom-marker-icon.selected .marker-svg-container {
  transform: scale(1.15);
}

/* Theme Toggle Button Styles */
.theme-toggle-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px !important;
  background: rgba(14, 21, 46, 0.5) !important;
  border: 1px solid var(--border-glass) !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  margin-left: 6px !important;
  flex-shrink: 0;
  white-space: nowrap;
}

.theme-toggle-container .selector-title {
  font-size: 11px !important;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  white-space: nowrap;
}


.theme-toggle-btn.active {
  border-color: var(--primary) !important;
  background: rgba(0, 242, 254, 0.1) !important;
  color: var(--primary) !important;
  box-shadow: 0 0 10px var(--primary-glow);
}

/* E-Map Dark Mode Base Map - Tone down the neon styling for a premium, stable dark slate and steel-blue finish. */
.map-dark-mode {
  background-color: #070b19 !important; /* Premium background base */
}

.map-dark-mode .leaflet-tile-pane {
  filter: invert(100%) hue-rotate(180deg) brightness(80%) contrast(100%) saturate(60%) !important;
  transition: filter 0.3s ease;
}

@keyframes marker-pulse-green {
  0% { transform: translate(-50%, 50%) scale(0.6); opacity: 0.8; }
  100% { transform: translate(-50%, 50%) scale(1.6); opacity: 0; }
}

@keyframes marker-pulse-red {
  0% { transform: translate(-50%, 50%) scale(0.6); opacity: 0.9; }
  100% { transform: translate(-50%, 50%) scale(1.8); opacity: 0; }
}

@keyframes marker-pulse-amber {
  0% { transform: translate(-50%, 50%) scale(0.6); opacity: 0.8; }
  100% { transform: translate(-50%, 50%) scale(1.6); opacity: 0; }
}

/* Floating Preview Window Styles */
.floating-preview-window {
  position: absolute;
  width: 360px;
  z-index: 1000; /* Must be above leaflet elements */
  display: flex;
  flex-direction: column;
  background: rgba(10, 16, 38, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
  transition: width 0.3s ease, height 0.3s ease, left 0.1s ease, top 0.1s ease;
}

/* Glow Border Effect */
.floating-preview-window:hover {
  border-color: var(--primary-glow);
  box-shadow: 0 12px 40px rgba(0, 242, 254, 0.15), inset 0 1px 1px rgba(0, 242, 254, 0.2);
}

.floating-preview-window.maximized {
  position: absolute;
  left: 5% !important;
  top: 5% !important;
  width: 90% !important;
  height: 90% !important;
  z-index: 1001;
}

/* Header */
.floating-preview-window .window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(7, 11, 25, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: move;
  user-select: none;
}

.drag-handle-indicator {
  color: rgba(255, 255, 255, 0.3);
  font-size: 12px;
  margin-right: 6px;
}

.window-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.cam-status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.cam-status-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }
.cam-status-dot.maintenance { background: var(--amber); box-shadow: 0 0 6px var(--amber); }

.window-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.win-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.2s;
}

.win-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.win-btn.close {
  font-size: 16px;
  line-height: 12px;
}
.win-btn.close:hover {
  color: #fff;
  background: var(--red);
}

/* Body */
.window-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.floating-preview-window.maximized .window-body {
  height: calc(100% - 37px);
}

/* Video Area */
.floating-video-area {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.floating-preview-window.maximized .floating-video-area {
  flex: 1;
  aspect-ratio: auto;
}

.floating-hls-player, .floating-mjpeg-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Video OSD Overlay */
.video-osd {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  z-index: 10;
  font-size: 10px;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.65);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.osd-live-tag {
  color: var(--primary);
  font-weight: 700;
  position: relative;
  padding-left: 10px;
}
.osd-live-tag::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  animation: blink-badge 1s infinite alternate;
}

/* PTZ Section */
.floating-ptz-section {
  padding: 12px;
  background: rgba(7, 11, 25, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ptz-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-joystick-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.compact-joystick {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.c-joy-btn {
  position: absolute;
  background: rgba(14, 21, 46, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 8px;
  transition: all 0.2s;
  padding: 0;
}

.c-joy-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 6px var(--primary-glow);
}

.c-joy-btn.up { top: 3px; }
.c-joy-btn.down { bottom: 3px; }
.c-joy-btn.left { left: 3px; }
.c-joy-btn.right { right: 3px; }

.c-joy-center {
  font-size: 7px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
}

.compact-ptz-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.c-ctrl-group {
  display: flex;
  gap: 4px;
}

.c-ptz-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 9px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
}

.c-ptz-btn:hover {
  background: rgba(0, 242, 254, 0.06);
  border-color: var(--primary);
  color: #fff;
}

.c-preset-row {
  display: flex;
  gap: 4px;
}

.c-select {
  flex: 1;
  background: rgba(7, 11, 25, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 3px;
  padding: 4px;
  font-size: 9px;
  outline: none;
}

.c-btn-primary {
  background: var(--primary);
  color: #070b19;
  border: none;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 9px;
  cursor: pointer;
  transition: all 0.2s;
}
.c-btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 6px var(--primary-glow);
}

/* PTZ Command Echo Panel inside popup */
.c-echo-panel {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  padding: 6px;
  font-size: 9px;
}

.c-echo-header {
  display: flex;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 2px;
}

.c-echo-msg {
  color: var(--primary);
  text-align: center;
  padding: 2px;
}

.state-indicator {
  font-weight: 700;
}
.state-indicator.Idle { color: rgba(255, 255, 255, 0.4); }
.state-indicator.Sent { color: var(--amber); }
.state-indicator.Received { color: var(--primary); }
.state-indicator.Executing { color: var(--secondary); }

/* Video loss inside popup */
.floating-preview-window .video-loss-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.floating-preview-window .loss-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--red);
}

.floating-preview-window .loss-content .warning-icon {
  font-size: 24px;
  animation: blink-badge 1s infinite alternate;
}

.floating-preview-window .loss-content .loss-text {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 1px;
}

.floating-preview-window .offline-placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.4);
  gap: 8px;
  padding: 20px;
}

.floating-preview-window .offline-placeholder .warning-icon {
  font-size: 28px;
  animation: blink-badge 1s infinite alternate;
}

.floating-preview-window .offline-placeholder .main-msg {
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
}

.floating-preview-window .offline-placeholder .sub-msg {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.25);
}

/* Authority Selector Toggles */
.header-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.authority-selector {
  display: flex;
  align-items: center;
  gap: 6px !important;
  background: rgba(14, 21, 46, 0.5) !important;
  border: 1px solid var(--border-glass) !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  flex-shrink: 0;
  white-space: nowrap;
}

.authority-selector .selector-title {
  font-size: 11px !important;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  white-space: nowrap;
}

.selector-chips {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.chip-checkbox-label {
  display: flex;
  align-items: center;
  gap: 4px !important;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1px 6px !important;
  border-radius: 10px !important;
  font-size: 11px !important;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  user-select: none;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  white-space: nowrap;
  line-height: 1.1 !important;
}

.chip-checkbox-label:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.chip-checkbox-input {
  display: none; /* Hide standard input completely */
}

.chip-status-dot {
  width: 4px !important;
  height: 4px !important;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: all 0.2s;
}

/* Checked state */
.chip-checkbox-label.checked {
  background: rgba(0, 0, 0, 0.3);
  border-color: var(--chip-color);
  color: #fff;
  font-weight: bold;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.05), inset 0 0 4px rgba(255, 255, 255, 0.02);
}

.chip-checkbox-label.checked .chip-status-dot {
  background: var(--chip-color);
  box-shadow: 0 0 6px var(--chip-color);
}

/* markercluster Sci-Fi Dark-Purple Glassmorphic Styles */
.marker-cluster-custom {
  background: rgba(16, 12, 38, 0.75) !important;
  border: 1.5px solid var(--primary) !important;
  box-shadow: 0 0 12px var(--primary-glow) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: var(--primary) !important;
  text-shadow: 0 0 5px var(--primary-glow) !important;
  font-weight: 800 !important;
  font-family: var(--font-mono) !important;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s; /* Exclude transform to prevent Leaflet zoom alignment lag! */
}

.marker-cluster-custom:hover {
  background: rgba(24, 16, 56, 0.85) !important;
  border-color: #fff !important;
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.4) !important;
}

.marker-cluster-custom:hover .cluster-core {
  transform: scale(1.1); /* Scale the core on hover instead of the parent container */
}

.cluster-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transition: transform 0.2s ease-in-out; /* Smooth transition for hover scaling */
}

.cluster-number {
  font-size: 13px;
  line-height: 14px;
}

.cluster-label {
  font-size: 8px;
  opacity: 0.7;
  margin-top: -1px;
}

/* Size classes */
.marker-cluster-custom.medium {
  border-color: var(--secondary) !important;
  color: var(--secondary) !important;
  box-shadow: 0 0 12px rgba(165, 94, 234, 0.35) !important;
  text-shadow: 0 0 5px rgba(165, 94, 234, 0.35) !important;
}
.marker-cluster-custom.medium:hover {
  box-shadow: 0 0 20px rgba(165, 94, 234, 0.5) !important;
}

.marker-cluster-custom.large {
  border-color: var(--amber) !important;
  color: var(--amber) !important;
  box-shadow: 0 0 15px rgba(255, 159, 67, 0.35) !important;
  text-shadow: 0 0 5px rgba(255, 159, 67, 0.35) !important;
}
.marker-cluster-custom.large:hover {
  box-shadow: 0 0 22px rgba(255, 159, 67, 0.5) !important;
}

.cluster-pulse-ring {
  position: absolute;
  top: -2px;
  left: -2px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(0, 242, 254, 0.15);
  animation: cluster-pulse-anim 2.5s infinite;
  pointer-events: none;
  z-index: -1;
}

.marker-cluster-custom.medium .cluster-pulse-ring {
  border-color: rgba(165, 94, 234, 0.15);
  animation-delay: 0.5s;
}

.marker-cluster-custom.large .cluster-pulse-ring {
  border-color: rgba(255, 159, 67, 0.15);
  animation-delay: 1s;
}

@keyframes cluster-pulse-anim {
  0% { transform: scale(0.9); opacity: 0.9; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Fixed Right-Pinned Video Preview Panel */
.right-pinned-preview-panel {
  position: absolute;
  top: 15px;
  left: calc(100% - 720px); /* Mathematically identical to right: 240px with width 480px, but enables gorgeous coordinate transitions! */
  width: 480px; /* Enlarged from 380px to 480px */
  height: auto; /* Shrink height to fit content! */
  max-height: calc(100% - 30px);
  z-index: 1000; /* Must overlay Leaflet elements */
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.06) !important; /* Premium frosted glass tint! */
  backdrop-filter: blur(10px) saturate(180%) !important; /* High frosted glass transparency */
  -webkit-backdrop-filter: blur(10px) saturate(180%) !important;
  border: 1.5px solid rgba(0, 242, 254, 0.45) !important; /* Glowing high-tech cybernetic cyan edge */
  border-radius: 12px; /* Sleeker rounded glass pane corners */
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.8), 
    0 0 25px rgba(0, 242, 254, 0.35), /* Neon cyan external glow (User request: stronger glow) */
    inset 0 0 12px rgba(0, 242, 254, 0.15), /* Tech inner cyan glow */
    inset 0 1px 2px rgba(255, 255, 255, 0.25) !important; /* 3D bevel glass highlight refraction */
  overflow: hidden;
  transform: translate3d(0, 0, 0); /* Explicitly set starting coordinates for smooth CSS interpolation */
  will-change: transform, top, left, width, height;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: 
    top 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    left 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    width 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    height 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.45s ease,
    opacity 0.45s ease; /* Premium macOS-style ultra-smooth exponential ease-out */
  pointer-events: auto;
}

.right-pinned-preview-panel.patrolling-layout {
  left: calc(100% - 500px) !important; /* Move closer to right edge (20px right margin) during patrol */
}

.right-pinned-preview-panel:hover {
  border-color: rgba(0, 242, 254, 0.75) !important; /* Extremely sharp glow on hover */
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.85), 
    0 0 40px rgba(0, 242, 254, 0.6), /* Amplified glow on hover */
    inset 0 0 15px rgba(0, 242, 254, 0.25),
    inset 0 1px 3px rgba(255, 255, 255, 0.35) !important;
}

/* Maximized View Style Overrides - Centered inside E-Map block and kept smaller than E-Map container */
.right-pinned-preview-panel.maximized {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate3d(-50%, -50%, 0) !important;
  width: 70% !important; /* Constrained width relative to map container */
  max-width: 800px !important; /* Cap it at a very elegant 800px */
  height: auto !important;
  max-height: 80% !important; /* Cap it at 80% of map container height */
  z-index: 2000 !important;
  background: rgba(255, 255, 255, 0.08) !important; /* Lighter frosted glass */
  backdrop-filter: blur(30px) saturate(220%) !important;
  -webkit-backdrop-filter: blur(30px) saturate(220%) !important;
  border: 1.5px solid rgba(0, 242, 254, 0.55) !important; /* Prominent glowing border when maximized */
  border-radius: 16px;
  box-shadow: 
    0 35px 80px rgba(0, 0, 0, 0.9), 
    0 0 50px rgba(0, 242, 254, 0.45), /* Expanded primary glow */
    inset 0 0 20px rgba(0, 242, 254, 0.2),
    inset 0 1px 3px rgba(255, 255, 255, 0.35), 
    inset 0 -1px 2px rgba(255, 255, 255, 0.15) !important;
}

.right-pinned-preview-panel.maximized .pinned-video-area {
  width: 100% !important;
  aspect-ratio: 16 / 9 !important; /* Lock strict 16:9 proportional scaling! */
  height: auto !important;
  max-height: calc(100% - 46px) !important;
}

/* Header style with OSD text and status dot */
.pinned-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent !important; /* Truly 100% transparent header blending with panel glass! */
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pinned-panel-header .cam-status-dot {
  width: 8px;
  height: 8px;
}

.pinned-panel-header .cam-id {
  font-weight: 800;
  color: var(--primary);
  text-shadow: 0 0 5px var(--primary-glow);
  font-size: 13.5px;
}

.pinned-panel-header .cam-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Header Action Buttons */
.pinned-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.panel-action-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.panel-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.panel-action-btn.zoom-btn:hover {
  color: var(--primary);
  box-shadow: 0 0 6px var(--primary-glow);
}

.panel-action-btn.close-btn:hover {
  color: var(--red);
  background: rgba(238, 82, 83, 0.15);
}

/* Video content taking up the central space */
.pinned-video-area {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9; /* Fit exact 16:9 camera stream aspect ratio! */
  background: transparent !important; /* Transparent background! */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pinned-video-area .floating-hls-player, 
.pinned-video-area .floating-mjpeg-player,
.pinned-video-area .hls-video-player,
.pinned-video-area .mjpeg-image-player {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Changed from contain to cover to ensure full-bleed fill! */
  background: transparent !important; /* Transparent background inside video tag */
  opacity: 1 !important; /* Keep video itself 100% opaque for maximum clarity! */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

/* Override Video Loss Overlay for Pinned Panel to be Semi-Transparent */
.right-pinned-preview-panel .video-loss-overlay {
  background-color: rgba(6, 10, 22, 0.5) !important; /* Transparent backdrop for video loss */
}

/* Force video-player-wrapper transparent inside the preview panel to override live.css background: #000 */
.right-pinned-preview-panel .video-player-wrapper {
  background: transparent !important;
}

/* Light theme map preview panel styles for optimal contrast */
.right-pinned-preview-panel.light-theme-panel {
  background: rgba(240, 244, 248, 0.2) !important; /* Premium ultra-transparent macOS-style light frosted glass (User request: 0.2 transparency!) */
  border: 1.5px solid rgba(14, 21, 46, 0.15) !important; /* Subtle dark refracting boundary */
  box-shadow: 
    0 15px 40px rgba(0, 0, 0, 0.28), /* Pronounced shadow for depth */
    0 4px 15px rgba(0, 0, 0, 0.12),
    inset 0 1px 2px rgba(255, 255, 255, 0.8), 
    inset 0 -1px 1px rgba(255, 255, 255, 0.3) !important;
}

.right-pinned-preview-panel.light-theme-panel:hover {
  border-color: rgba(14, 21, 46, 0.25) !important;
  box-shadow: 
    0 22px 50px rgba(0, 0, 0, 0.35), /* More pronounced shadow on hover */
    0 8px 25px rgba(0, 0, 0, 0.18),
    inset 0 1px 3px rgba(255, 255, 255, 0.9) !important;
}

/* Highly pronounced shadow for maximized state in light mode */
.right-pinned-preview-panel.light-theme-panel.maximized {
  background: rgba(240, 244, 248, 0.55) !important; /* More transparent macOS-style heavy frosted glass */
  border: 2px solid rgba(14, 21, 46, 0.2) !important; /* Well-defined boundary */
  box-shadow: 
    0 35px 85px rgba(0, 0, 0, 0.38), /* Strongest shadow under maximized light view */
    0 12px 36px rgba(0, 0, 0, 0.18),
    inset 0 1px 3px rgba(255, 255, 255, 0.9), 
    inset 0 -1px 2px rgba(255, 255, 255, 0.4) !important;
}

.right-pinned-preview-panel.light-theme-panel .pinned-panel-header {
  background: rgba(240, 244, 248, 0.2) !important; /* Highly transparent banner background for light mode (User request: 0.2!) */
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-bottom: 1px solid rgba(14, 21, 46, 0.1) !important;
}

.right-pinned-preview-panel.light-theme-panel .pinned-panel-header .cam-id {
  color: #007090 !important; /* High contrast dark cyan ID */
  text-shadow: none !important; /* No glow on light background */
}

.right-pinned-preview-panel.light-theme-panel .pinned-panel-header .cam-name {
  color: #0e152e !important; /* Deep navy text for maximum readability */
  font-weight: 700 !important;
}

.right-pinned-preview-panel.light-theme-panel .panel-action-btn {
  color: rgba(14, 21, 46, 0.6) !important; /* Darker actionable buttons */
}

.right-pinned-preview-panel.light-theme-panel .panel-action-btn:hover {
  background: rgba(0, 0, 0, 0.05) !important;
  color: #0e152e !important;
}

/* Offline state sub message contrast */
.right-pinned-preview-panel.light-theme-panel .offline-placeholder .sub-msg {
  color: rgba(14, 21, 46, 0.6) !important; /* Dark gray sub text for offline state */
  font-weight: 600 !important;
}

/* Snappier Leaflet cluster merge/split animations (safe — only affects visual clustering transitions)
   We do NOT use !important here so Leaflet can temporarily disable the transition inline during zoom. */
.leaflet-cluster-anim .leaflet-marker-icon, 
.leaflet-cluster-anim .leaflet-marker-shadow {
  transition: transform 0.18s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.18s ease-in;
}

/* NOTE: Do NOT override .leaflet-zoom-animated transition-duration!
   Leaflet calculates marker positions internally based on its default 250ms zoom duration.
   Forcing a different duration via CSS causes markers to land at incorrect intermediate positions,
   resulting in markers "stuck" outside their clusters after zoom. */

/* 360 Auto Cruise Icon styling and animations */
.icon-360 {
  cursor: pointer;
  transition: all 0.25s ease;
}

.icon-360:hover {
  filter: drop-shadow(0 0 6px var(--primary-glow)) !important;
  transform: scale(1.2);
}

.icon-360.cruising {
  color: #00ff88 !important;
  filter: drop-shadow(0 0 8px rgba(0, 255, 136, 0.95)) !important;
}

.icon-360.cruising circle {
  animation: spin-circle 8s linear infinite;
  transform-origin: center;
}

@keyframes spin-circle {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

