body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  background: #f7f5f3;
}

#map {
  height: 100vh;
  width: 100%;
  z-index: 1;
}

/* OpenRailwayMap color scheme - heavily muted base map to match openrailwaymap.org */
.leaflet-tile-pane .leaflet-layer:first-child {
  filter: grayscale(60%) sepia(15%) hue-rotate(25deg) saturate(0.3) brightness(1.1) contrast(0.9);
}

/* Railway standard layer - main tracks and infrastructure */
.leaflet-tile-pane .leaflet-layer:nth-child(2) {
  filter: saturate(0.8) contrast(1.3) brightness(0.9) hue-rotate(-10deg);
}

/* Railway signals layer - signals and electrification */
.leaflet-tile-pane .leaflet-layer:nth-child(3) {
  filter: saturate(1.1) contrast(1.4) brightness(0.95) hue-rotate(-5deg);
}

.map-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.map-loading::after {
  content: "Loading map...";
  font-size: 1.2em;
  color: #333;
}

.map-error {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  color: #d32f2f;
  text-align: center;
  padding: 20px;
}



/* Geolocation Control */
.leaflet-control-locate {
  background: #fff;
  border: 2px solid rgba(0,0,0,0.2);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: all 0.2s ease;
}

.leaflet-control-locate:hover {
  background: #f0f8f0;
  border-color: #2d5f3f;
  box-shadow: 0 3px 12px rgba(45, 95, 63, 0.3);
}

.locate-button {
  display: block;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  position: relative;
  transition: all 0.2s ease;
}

.locate-button:hover {
  transform: scale(1.05);
}

.locate-button.locating {
  animation: pulse-locate 1.5s infinite;
}

.locate-button.located {
  background-color: rgba(45, 95, 63, 0.1);
}

.locate-icon {
  width: 20px;
  height: 20px;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.locate-button:hover .locate-icon {
  opacity: 0.8;
}

.locate-button.locating .locate-icon {
  filter: hue-rotate(180deg) saturate(1.5);
}

.locate-button.error .locate-icon {
  filter: hue-rotate(-60deg) saturate(1.5);
}

@keyframes pulse-locate {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* Location error message */
.error-message.location-error {
  background: rgba(45, 95, 63, 0.95);
  color: white;
  border-left: 4px solid #4caf50;
}

.error-message.location-error .error-content {
  color: white;
}

.error-message.location-error .error-icon {
  fill: #4caf50;
}

/* Custom Pin Marker Styles */
.custom-pin-marker {
  background: none;
  border: none;
}

.map-pin {
  position: relative;
  width: 30px;
  height: 40px;
  transition: transform 0.3s ease;
}

.pin-head {
  width: 20px;
  height: 20px;
  background: var(--pin-color);
  border-radius: 50%;
  border: 2px solid #ffffff;
  position: absolute;
  top: 2px;
  left: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 2;
}

.pin-point {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 10px solid var(--pin-color);
  position: absolute;
  bottom: 0;
  left: 10px;
  z-index: 1;
  filter: brightness(0.8);
}

.pin-shadow {
  width: 20px;
  height: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 50%;
  position: absolute;
  bottom: -2px;
  left: 5px;
  transform: skew(-10deg);
  z-index: 0;
}

.map-pin:hover {
  transform: scale(1.1) translateY(-2px);
}

.map-pin:hover .pin-shadow {
  width: 22px;
  opacity: 0.3;
}

.custom-pin-marker.animate .map-pin {
  animation: pin-bounce 0.6s ease-out;
}

@keyframes pin-bounce {
  0% { transform: translateY(-20px) scale(0.8); opacity: 0; }
  50% { transform: translateY(-5px) scale(1.1); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Spiderfier Styles - Blue themed colors */
.oms-spider-leg {
  stroke: #1976D2 !important;
  stroke-width: 2px !important;
  stroke-opacity: 0.7 !important;
}

.oms-spider-leg:hover {
  stroke: #42A5F5 !important;
  stroke-width: 3px !important;
  stroke-opacity: 0.9 !important;
}

/* Enhanced marker visibility when spiderfied */
.leaflet-marker-icon.oms-marker-spiderfied .map-pin {
  z-index: 1000 !important;
  transform: scale(1.1) translateY(-2px);
  transition: transform 0.2s ease;
}

.leaflet-marker-icon.oms-marker-spiderfied:hover .map-pin {
  transform: scale(1.2) translateY(-4px);
}

.leaflet-marker-icon.oms-marker-spiderfied .pin-shadow {
  width: 22px;
  opacity: 0.4;
}

/* Popup Styles */
.custom-popup {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0;
  margin-bottom: 10px;
}

.custom-popup .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
}

.custom-popup .leaflet-popup-content {
  margin: 0;
  width: 300px !important;
}

.custom-popup .leaflet-popup-tip {
  background: white;
}

.popup-content {
  display: flex;
  flex-direction: column;
}

.popup-header {
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popup-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #212529;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.status-badge.active {
  background: #d4edda;
  color: #155724;
}

.status-badge.inactive {
  background: #f8d7da;
  color: #721c24;
}

.status-badge.error {
  background: #fff3cd;
  color: #856404;
}

.popup-body {
  padding: 16px;
}

.thumbnail-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  background: #000;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  margin-bottom: 12px;
}

.thumbnail-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: all 0.2s ease;
  cursor: pointer;
  z-index: 10;
  gap: 8px;
}

.thumbnail-preview:hover .play-overlay,
.thumbnail-container:hover .play-overlay {
  opacity: 1;
  background: rgba(0, 0, 0, 0.6);
}

.play-icon {
  width: 48px;
  height: 48px;
  fill: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.play-text {
  color: white;
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  text-align: center;
  user-select: none;
}

.info-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.last-updated,
.coordinates {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6c757d;
  font-size: 13px;
}

.icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.popup-footer {
  padding: 12px 16px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
}

.watch-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: #dc3545;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.watch-button:hover {
  background: #c82333;
  color: white;
}

.watch-button .icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Enhanced Video Preview Styles */
.video-preview {
  position: fixed;
  background: #1a1a1a;
  border-radius: 12px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
  z-index: 1001;
  display: none;
  overflow: hidden;
  border: 1px solid #333;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Size variants */
.video-preview.small {
  width: 320px;
  height: 200px;
}

.video-preview.medium {
  width: 480px;
  height: 300px;
}

.video-preview.large {
  width: 640px;
  height: 400px;
}

/* Animation states */
.video-preview.showing {
  animation: slideInPreview 0.3s ease-out;
}

.video-preview.hiding {
  animation: slideOutPreview 0.2s ease-in;
}

@keyframes slideInPreview {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes slideOutPreview {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
}

/* Header */
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #2a2a2a;
  border-bottom: 1px solid #444;
}

.preview-title {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  margin: 0;
  flex: 1;
}

.preview-controls {
  display: flex;
  gap: 8px;
}

.preview-controls button {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-controls button:hover {
  background: #444;
  color: #fff;
}

.preview-controls svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Quality Selector */
.quality-selector {
  position: absolute;
  top: 48px;
  right: 16px;
  background: #2a2a2a;
  border-radius: 6px;
  border: 1px solid #444;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 10;
}

.quality-selector.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.quality-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quality-option {
  background: none;
  border: none;
  color: #ccc;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  transition: all 0.2s;
}

.quality-option:hover {
  background: #444;
  color: #fff;
}

.quality-option.active {
  background: #0066cc;
  color: #fff;
}

/* Iframe Container */
.iframe-container {
  position: relative;
  width: 100%;
  height: calc(100% - 48px);
}

.video-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Loading Overlay */
.video-preview .loading-overlay {
  position: absolute;
  top: 48px;
  left: 0;
  width: 100%;
  height: calc(100% - 48px);
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: white;
}

.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-text {
  font-size: 14px;
  color: #ccc;
}

.loading-progress {
  width: 200px;
  height: 3px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0066cc, #00aaff);
  transition: width 2s ease-out;
  width: 0%;
}

/* Error Overlay */
.video-preview .error-overlay {
  position: absolute;
  top: 48px;
  left: 0;
  width: 100%;
  height: calc(100% - 48px);
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
}

.error-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.error-icon {
  width: 48px;
  height: 48px;
  fill: #ff4444;
}

.error-text {
  font-size: 14px;
  color: #ccc;
  margin-bottom: 8px;
}

.retry-btn {
  background: #0066cc;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.retry-btn:hover {
  background: #0052a3;
}

/* Mobile Responsive */
.video-preview.mobile {
  width: 90vw !important;
  height: auto !important;
  max-width: 400px;
  max-height: 70vh;
}

.video-preview.mobile .iframe-container {
  aspect-ratio: 16 / 9;
  height: auto;
}

.video-preview.mobile .preview-header {
  padding: 8px 12px;
}

.video-preview.mobile .preview-title {
  font-size: 12px;
}

.video-preview.mobile .preview-controls svg {
  width: 14px;
  height: 14px;
}

.video-preview.mobile .quality-selector {
  right: 8px;
  top: 40px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid transparent;
  border-top: 2px solid #ff6b6b;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.error-icon {
  width: 24px;
  height: 24px;
  fill: #ff6b6b;
  margin-bottom: 8px;
}

/* Error State */
.popup-content.error .error-message {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: #856404;
  background: #fff3cd;
  border-radius: 4px;
  text-align: center;
}

.popup-content.error .error-message .icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes ripple {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #map {
    height: 70vh;
  }
  

  
  .custom-popup .leaflet-popup-content {
    width: 280px !important;
  }
  
  .popup-header h3 {
    font-size: 14px;
  }
  
  .status-badge {
    font-size: 11px;
    padding: 3px 6px;
  }
  
  .popup-body {
    padding: 12px;
  }
  
  .info-container {
    font-size: 12px;
  }
  
  .watch-button {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .video-preview:not(.mobile) {
    width: 90vw !important;
    height: auto !important;
    max-width: 400px;
  }
  
  .video-preview:not(.mobile) .iframe-container {
    aspect-ratio: 16 / 9;
    height: auto !important;
  }
  
  .loading-text,
  .error-text {
    font-size: 12px;
  }
  
  .spinner {
    width: 32px;
    height: 32px;
  }
  
  .error-icon {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  #map {
    height: 60vh;
  }
  

}

/* Touch device specific styles */
@media (hover: none) and (pointer: coarse) {
  .video-preview {
    width: 90vw !important;
    height: auto !important;
    max-width: 400px;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
  }
  
  .video-preview .iframe-container {
    aspect-ratio: 16 / 9;
    height: auto !important;
  }
  
  .preview-controls button {
    padding: 8px;
    min-width: 36px;
    min-height: 36px;
  }
  
  .quality-option {
    padding: 12px 16px;
    font-size: 14px;
  }
}

/* Enhanced dark theme support */
@media (prefers-color-scheme: dark) {
  .video-preview {
    background: #0f0f0f;
    border-color: #2a2a2a;
  }
  
  .preview-header {
    background: #1a1a1a;
    border-bottom-color: #333;
  }
  
  .quality-selector {
    background: #1a1a1a;
    border-color: #333;
  }
}



/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-content {
  background: white;
  padding: 24px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.loading-text {
  margin-top: 12px;
  font-size: 14px;
  color: #555;
}

/* Error messages */
.error-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #fee;
  border: 1px solid #fcc;
  color: #c33;
  padding: 12px 16px;
  border-radius: 6px;
  z-index: 1500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  animation: slideDown 0.3s ease-out;
}

.error-content {
  display: flex;
  align-items: center;
  font-size: 14px;
}

.error-content .error-icon {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  margin-bottom: 0;
  fill: #c33;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Popup styles */
.webcam-popup {
  max-width: 350px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.popup-content {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.popup-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  flex: 1;
  margin-right: 12px;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.active {
  background: #d4edda;
  color: #155724;
}

.status-badge.inactive {
  background: #f8d7da;
  color: #721c24;
}

.status-badge.error {
  background: #f8d7da;
  color: #721c24;
}

.popup-body {
  padding: 16px;
}

.thumbnail-container {
  position: relative;
  width: 100%;
  height: 180px;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.thumbnail-container:hover {
  transform: scale(1.02);
}

.thumbnail-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-overlay {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.loading-thumbnail {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 14px;
}

.error-message-popup {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 14px;
  background: #f8f9fa;
}

.popup-footer {
  padding: 12px 16px;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.watch-button {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: #ff0000;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.watch-button:hover {
  background: #cc0000;
  color: white;
  text-decoration: none;
}

.watch-button .icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  fill: currentColor;
}

.popup-info {
  font-size: 12px;
  color: #6c757d;
}

/* Custom marker styles - Railway signal inspired */
.webcam-marker {
  background: #2d5f3f;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.webcam-marker:hover {
  transform: scale(1.2);
  background: #234a33;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.webcam-marker.active {
  background: #2d5f3f;
  border-color: #ffffff;
  box-shadow: 0 0 12px rgba(45, 95, 63, 0.6);
}

.webcam-marker.inactive {
  background: #8b2635;
  border-color: #ffffff;
  box-shadow: 0 0 12px rgba(139, 38, 53, 0.6);
}

.webcam-marker.unknown {
  background: #b8860b;
  border-color: #ffffff;
  box-shadow: 0 0 12px rgba(184, 134, 11, 0.6);
}

/* Responsive design */
@media (max-width: 768px) {

  
  .webcam-popup {
    max-width: 280px;
  }
  
  .popup-body {
    padding: 12px;
  }
  
  .thumbnail-container {
    height: 140px;
  }
  
  .error-message {
    left: 10px;
    right: 10px;
    transform: none;
    max-width: none;
  }
}

@media (max-width: 480px) {

}

/* Preview Settings Panel */
.preview-settings-panel {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 320px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  border: 1px solid #ddd;
  z-index: 1002;
  display: none;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s ease-out;
}

.preview-settings-panel.visible {
  opacity: 1;
  transform: translateY(0);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  background: #f8f9fa;
  border-radius: 12px 12px 0 0;
}

.settings-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.close-settings-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.close-settings-btn:hover {
  background: #e9ecef;
  color: #333;
}

.close-settings-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.settings-content {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.setting-group {
  margin-bottom: 20px;
}

.setting-group:last-child {
  margin-bottom: 0;
}

.setting-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
}

.setting-group label input[type="checkbox"] {
  margin-right: 8px;
}

.setting-group select,
.setting-group input[type="range"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s;
}

.setting-group select:focus,
.setting-group input:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.range-value {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: #666;
}

.settings-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

.reset-btn,
.save-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.reset-btn {
  background: #f8f9fa;
  color: #666;
  border: 1px solid #dee2e6;
}

.reset-btn:hover {
  background: #e9ecef;
  color: #333;
}

.save-btn {
  background: #0066cc;
  color: white;
}

.save-btn:hover {
  background: #0052a3;
}

/* Settings Notification */
.settings-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #28a745;
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1003;
  opacity: 0;
  transform: translateX(100px);
  transition: all 0.3s ease-out;
  font-size: 14px;
  font-weight: 500;
}

.settings-notification.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Dark theme for settings */
@media (prefers-color-scheme: dark) {
  .preview-settings-panel {
    background: #1a1a1a;
    border-color: #333;
  }
  
  .settings-header {
    background: #2a2a2a;
    border-bottom-color: #444;
  }
  
  .settings-header h3 {
    color: #fff;
  }
  
  .close-settings-btn {
    color: #ccc;
  }
  
  .close-settings-btn:hover {
    background: #444;
    color: #fff;
  }
  
  .setting-group label {
    color: #fff;
  }
  
  .setting-group select,
  .setting-group input {
    background: #2a2a2a;
    border-color: #444;
    color: #fff;
  }
  
  .range-value {
    color: #ccc;
  }
  
  .settings-actions {
    border-top-color: #444;
  }
  
  .reset-btn {
    background: #2a2a2a;
    color: #ccc;
    border-color: #444;
  }
  
  .reset-btn:hover {
    background: #333;
    color: #fff;
  }
}

/* Mobile responsive for settings */
@media (max-width: 768px) {
  .preview-settings-panel {
    width: calc(100vw - 40px);
    max-width: 300px;
  }
}

/* Enhanced Popup System with Integrated Video - No Default Close Button */
.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  /* Force override Leaflet's default padding */
  padding: 0 !important;
  margin: 0 !important;
}

.custom-popup.enhanced .leaflet-popup-content-wrapper {
  min-width: 320px;
  max-width: 380px;
  padding: 0 !important;
  margin: 0 !important;
}

/* Remove default close button space */
.custom-popup.enhanced .leaflet-popup-close-button {
  display: none;
}

/* Ensure popup content has no default spacing */
.custom-popup.enhanced .leaflet-popup-content {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
}

.popup-content {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.4;
  padding: 16px;
  margin: 0;
  box-sizing: border-box;
  position: relative;
}

/* Custom Close Button */
.custom-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.custom-close-btn:hover {
  background: rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
}

.custom-close-btn svg {
  width: 14px;
  height: 14px;
  fill: #666;
  transition: fill 0.2s ease;
}

.custom-close-btn:hover svg {
  fill: #333;
}

/* Video Container Styles */
.video-container {
  position: relative;
  background: #f8f9fa;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  width: 100%;
  box-sizing: border-box;
}

.thumbnail-preview {
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.thumbnail-preview:hover {
  transform: scale(1.02);
}

.thumbnail-preview .thumbnail {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 8px;
}

.thumbnail-preview:hover .play-overlay {
  opacity: 1;
}

.play-icon {
  width: 48px;
  height: 48px;
  fill: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  margin-bottom: 8px;
}

.play-text {
  color: white;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Video Preview Styles */
.video-preview {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.video-preview iframe {
  width: 100%;
  height: 180px;
  border: none;
  display: block;
  box-sizing: border-box;
}

.video-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.video-preview:hover .video-controls {
  opacity: 1;
}

.video-controls button {
  background: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  backdrop-filter: blur(4px);
}

.video-controls button:hover {
  background: rgba(0, 0, 0, 0.9);
}

.video-controls button svg {
  width: 16px;
  height: 16px;
  fill: white;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: #f8f9fa;
  border-radius: 8px;
}

.loading-state .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e0e0;
  border-top: 3px solid #1976D2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

.loading-state span {
  color: #666;
  font-size: 14px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error States */
.temp-error {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(244, 67, 54, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 1000;
  animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0; }
  20%, 80% { opacity: 1; }
}

.fallback-link {
  text-align: center;
  margin-top: 12px;
}

.external-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #1976D2;
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid #1976D2;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.external-link:hover {
  background: #1976D2;
  color: white;
}

.external-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Popup Header Improvements */
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  padding-right: 40px; /* Make room for custom close button */
  border-bottom: 1px solid #e0e0e0;
}

.popup-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  flex: 1;
  margin-right: 12px;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.active {
  background: #e8f5e8;
  color: #2d5f3f;
}

.status-badge.inactive {
  background: #ffebee;
  color: #8b2635;
}

.status-badge.unknown {
  background: #fff8e1;
  color: #b8860b;
}

.status-badge.error {
  background: #ffebee;
  color: #c62828;
}

/* Info Container */
.info-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.last-updated,
.coordinates {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #666;
}

.last-updated .icon,
.coordinates .icon {
  width: 14px;
  height: 14px;
  fill: #999;
  flex-shrink: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
  .custom-popup.enhanced .leaflet-popup-content-wrapper {
    min-width: 300px;
    max-width: 320px;
    padding: 0;
  }
  
  .video-preview iframe {
    height: 180px;
  }
  
  .popup-header h3 {
    font-size: 15px;
  }
  
  .play-icon {
    width: 40px;
    height: 40px;
  }
  
  .play-text {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .custom-popup.enhanced .leaflet-popup-content-wrapper {
    min-width: 280px;
    max-width: 300px;
    padding: 0;
  }
  
  .video-preview iframe {
    height: 160px;
  }
  
  .loading-state {
    padding: 30px 15px;
  }
}

/* Enhanced Play Instruction Overlay */
.play-instruction {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  pointer-events: auto;
}

.play-instruction:hover {
  background: rgba(0, 0, 0, 0.85);
  transform: scale(1.02);
}

.instruction-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  text-align: center;
  transition: transform 0.2s ease;
}

.play-instruction:hover .instruction-content {
  transform: scale(1.1);
}

.instruction-icon {
  width: 48px;
  height: 48px;
  fill: white;
  margin-bottom: 10px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
  transition: all 0.2s ease;
}

.play-instruction:hover .instruction-icon {
  fill: #1976D2;
  transform: scale(1.1);
}

.instruction-content span {
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  transition: color 0.2s ease;
}

.play-instruction:hover .instruction-content span {
  color: #E3F2FD;
}

/* Enhanced Video Error Display */
.video-error {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  border: 1px solid #e0e0e0;
}

.video-error .error-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.video-error .error-icon {
  width: 32px;
  height: 32px;
  fill: #f44336;
}

.video-error .error-message {
  color: #333;
}

.video-error .error-message strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.video-error .error-message p {
  font-size: 12px;
  color: #666;
  margin: 0;
  line-height: 1.4;
}

.error-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.retry-embed-btn,
.open-youtube-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-embed-btn {
  background: #1976D2;
  color: white;
}

.retry-embed-btn:hover {
  background: #1565C0;
  transform: translateY(-1px);
}

.open-youtube-btn {
  background: #ff0000;
  color: white;
}

.open-youtube-btn:hover {
  background: #cc0000;
  transform: translateY(-1px);
}

.retry-embed-btn svg,
.open-youtube-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Mobile responsiveness for error states */
@media (max-width: 480px) {
  .error-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .retry-embed-btn,
  .open-youtube-btn {
    width: 100%;
    max-width: 200px;
    justify-content: center;
  }
  
  .instruction-icon {
    width: 32px;
    height: 32px;
  }
  
  .instruction-content span {
    font-size: 13px;
  }
} 