/* Global styles */
:root {
  --primary-color: #2196f3;
  --secondary-color: #0d8aee;
  --text-color: #e0e0e0;
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --header-bg: #1e1e1e;
  --border-color: #333;
  --shadow: 0 2px 5px rgba(0,0,0,0.3);
  --spinner-color: #2196f3;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header styles */
header {
  background-color: var(--header-bg);
  box-shadow: var(--shadow);
  position: fixed;
  padding: 0 20px;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  z-index: 10;
  transition: background-color 0.3s;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary-color);
}

.logo-icon {
  font-size: 1.5rem;
}

.logo h1 {
  font-weight: 500;
  font-size: 1.5rem;
}

.header-nav {
  display: flex;
  gap: 15px;
  align-items: center;
}

.admin-link {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--primary-color);
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  transition: all 0.2s;
}

.admin-link:hover {
  background-color: rgba(0, 120, 215, 0.1);
  color: var(--secondary-color);
}

/* Main content */
main {
  margin-top: 40px;
}

.content-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 40px); /* Full viewport height */
  width: 100%;
  overflow: hidden; /* Prevents scrolling */
}

.video-wrapper {
  width: 100%;
  max-height: 40vh;
  position: relative;
  overflow: hidden; /* This is crucial to prevent overflow */
}

/* These are the key fixes for VideoJS */
.video-wrapper .video-js {
  width: 100%;
  height: 0 !important; /* Override any height set by VideoJS */
  padding-top: min(56.25%, 40vh) !important; /* Key fix: use min() to limit height */
}

/* Fix positioning of VideoJS elements */
.video-wrapper .video-js .vjs-tech {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* Maintains aspect ratio */
  max-height: 100%;
}

/* Ensure controls stay properly positioned */
.video-wrapper .vjs-control-bar {
  width: 100%;
  bottom: 0;
}


.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 4px solid var(--spinner-color);
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

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

/* Webcam title overlay */
.webcam-title-overlay {
  position: absolute;
  top: 15px;
  left: 15px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 14px;
  z-index: 4;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Map section */
.map-section {
  flex: 1 0 auto; /* Grow to fill remaining space, don't shrink */
  overflow-y: auto; /* Allow scrolling if content exceeds available space */
  position: relative; /* Important for absolute positioning of the location button */
}

#map {
  width: 100%;
  height: 100%;
}

/* Location button */
.location-button {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background-color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease;
}

.location-button i {
  color: #2196f3;
  font-size: 18px;
}

.location-button:hover {
  background-color: #f5f5f5;
  transform: scale(1.05);
}

.location-button:active {
  background-color: #e0e0e0;
  transform: scale(0.95);
}

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

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(33, 150, 243, 0); }
  100% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0); }
}

/* User location marker */
.user-location-marker {
  position: relative;
}

.user-location-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background-color: #2196f3;
  border: 2px solid white;
  border-radius: 50%;
  z-index: 1001;
}

.user-location-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  background-color: rgba(33, 150, 243, 0.4);
  border-radius: 50%;
  z-index: 1000;
  animation: pulsate 2s ease-out infinite;
}

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

/* Map markers customization */
.custom-marker {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 30px !important;
  height: 30px !important;
  background-color: #0078d7;
  border-radius: 50%;
  color: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  transition: all 0.2s;
}

.custom-marker.offline {
  background-color: #777;
}

.custom-marker.active {
  background-color: #ff5722;
  transform: scale(1.2);
  z-index: 1000;
}

.active-webcam-badge {
  position: absolute;
  text-align: center;
  top: calc(40px + 5px);
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 70%;  
  padding: 3px 6px;
  border-radius: 20px;
  z-index: 999;
  opacity: 0.6;
  display: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-webcam-badge.visible {
  display: inline-block;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 0.8; transform: translate(-50%, 0); }
}

/* Custom marker cluster styling */
.custom-cluster-icon {
  background: transparent;
}

.cluster-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: rgba(38, 128, 235, 0.8);
  color: white;
  font-weight: bold;
  box-shadow: 0 0 0 4px rgba(38, 128, 235, 0.4);
  transition: all 0.2s ease;
}

.cluster-icon.small {
  font-size: 12px;
}

.cluster-icon.medium {
  font-size: 14px;
  background-color: rgba(252, 176, 69, 0.8);
  box-shadow: 0 0 0 4px rgba(252, 176, 69, 0.4);
}

.cluster-icon.large {
  font-size: 16px;
  background-color: rgba(235, 77, 77, 0.8);
  box-shadow: 0 0 0 4px rgba(235, 77, 77, 0.4);
}

.cluster-icon:hover {
  transform: scale(1.1);
}

/* Ensures smooth transition when markers are added/removed from clusters */
.leaflet-marker-icon,
.leaflet-marker-shadow {
  transition: opacity 0.3s ease;
}

/* Animation for cluster hover effect */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.leaflet-cluster-anim .custom-cluster-icon:hover .cluster-icon {
  animation: pulse 1.5s infinite;
}