/* ========================================
   GLOBAL RESET & BASE STYLES
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1a1a1a;
  overflow: hidden;
  background: #0a0e27;
}

/* ========================================
   FULL-SCREEN MAP
   ======================================== */
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ========================================
   FLOATING HEADER BAR
   ======================================== */
#header {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  padding: 16px 24px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 95%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#header:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-left h1 {
  font-size: 20px;
  font-weight: 700;
  color: #0a0e27;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ========================================
   CONTROL GROUPS & LABELS
   ======================================== */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

/* Endpoint toggle checkbox styling */
.endpoint-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 8px;
  border: 2px solid #e5e7eb;
  transition: all 0.2s ease;
}

.endpoint-toggle:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}

.endpoint-toggle label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  text-transform: none;
  letter-spacing: normal;
  user-select: none;
}

.endpoint-toggle input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #3b82f6;
}

/* ========================================
   MODERN SELECT DROPDOWNS
   ======================================== */
.modern-select {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: white;
  color: #1a1a1a;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
  outline: none;
}

.modern-select:hover:not(:disabled) {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modern-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.modern-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f9fafb;
}

/* ========================================
   PRIMARY BUTTON
   ======================================== */
.primary-button {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.primary-button:active:not(:disabled) {
  transform: translateY(0);
}

.primary-button:disabled {
  opacity: 0.5;
}

/* ========================================
   SECONDARY BUTTON
   ======================================== */
.secondary-button {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  background: white;
  border: 2px solid #d1d5db;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 10px;
}

.secondary-button:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.secondary-button:active {
  transform: translateY(0);
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.primary-button.loading .button-text {
  opacity: 0;
}

.primary-button.loading .button-loader {
  display: block;
}

.button-loader {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ========================================
   STATUS PANEL
   ======================================== */
#statusPanel {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  max-width: 600px;
  min-width: 300px;
  transition: all 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

#statusPanel.visible {
  opacity: 1;
  pointer-events: all;
}

#status {
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 4px;
}

#qcResult {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
}

/* ========================================
   LOADING OVERLAY
   ======================================== */
#loadingOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 39, 0.8);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loader-text {
  font-size: 16px;
  font-weight: 600;
  color: white;
  letter-spacing: 0.5px;
}

/* ========================================
   LEGEND STYLES
   ======================================== */
.legend {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  min-width: 220px;
  transition: all 0.3s ease;
}

.legend:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
}

.legend-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
  color: #0a0e27;
  letter-spacing: -0.3px;
}

.legend-section-title {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-top: 12px;
  margin-bottom: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  margin: 8px 0;
  gap: 10px;
  transition: all 0.2s ease;
  padding: 4px;
  border-radius: 6px;
}

.legend-item-small {
  display: flex;
  align-items: center;
  margin: 4px 0 4px 28px;
  gap: 8px;
  font-size: 12px;
  color: #6b7280;
  padding: 2px;
}

.legend-item:hover {
  background: rgba(59, 130, 246, 0.05);
}

.legend-item input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #3b82f6;
}

.legend-item label {
  cursor: pointer;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: #1a1a1a;
  user-select: none;
  flex: 1;
}

.legend-item svg {
  display: block;
  flex-shrink: 0;
}

/* ========================================
   CUSTOM MARKER STYLES
   ======================================== */
.handhole-marker {
  background: transparent !important;
  border: none !important;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  font-family: 'Inter', sans-serif;
}

.leaflet-popup-content {
  font-size: 13px;
  line-height: 1.6;
  margin: 14px 16px;
}

.leaflet-popup-tip {
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 1200px) {
  #header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    top: 10px;
    padding: 16px;
  }

  .header-center {
    width: 100%;
    justify-content: space-between;
  }
}
