/* Import Google Fonts for better typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Global styles */
html, body { 
  height: 100%; 
  margin: 0; 
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f8f9fa;
}

#map { 
  position: absolute; 
  top: 0; 
  bottom: 0; 
  left: 0; 
  right: 400px; 
  transition: right 0.3s ease-in-out;
}

/* Dashboard styles */
#dashboard {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100%;
  background: #f8f9fa;
  color: #2c3e50;
  border-left: 1px solid #e9ecef;
  padding: 2rem;
  overflow-y: auto;
  transition: transform 0.3s ease-in-out;
  z-index: 1000;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

.dashboard-hidden {
  transform: translateX(100%);
}

.dashboard-visible {
  transform: translateX(0);
}

/* Dashboard content styling */
#dashboard h4 {
  color: #2c3e50;
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

#dashboard h5 {
  color: #2c3e50;
  font-weight: 500;
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

#dashboard p {
  color: #5a6c7d;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.form-label {
  color: #2c3e50;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-control {
  background-color: white;
  border: 1px solid #dee2e6;
  color: #2c3e50;
  border-radius: 8px;
  padding: 0.75rem;
  transition: all 0.3s ease;
}

.form-control:focus {
  background-color: white;
  border-color: #667eea;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
  color: #2c3e50;
}

.form-control::placeholder {
  color: #6c757d;
}

.form-check-label {
  color: #2c3e50;
  font-weight: 400;
}

.form-check-input:checked {
  background-color: #28a745;
  border-color: #28a745;
}

/* Enhanced Legend Styles */
.map-legend-container {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%);
  backdrop-filter: blur(10px);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  max-width: 320px;
  z-index: 1001;
  color: #2c3e50;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-family: 'Inter', sans-serif;
}

.map-legend-container .map-description {
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #5a6c7d;
  font-weight: 400;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.map-legend-container .legend-title {
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 16px;
  color: #2c3e50;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.map-legend-container .legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.map-legend-container .legend-item:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: translateX(2px);
}

.map-legend-container .legend-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-right: 12px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
}

.map-legend-container .legend-color::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.3) 50%, transparent 70%);
  pointer-events: none;
}

.map-legend-container .legend-item:nth-child(3) .legend-color {
  background: linear-gradient(135deg, #ff7e40 0%, #e65a2b 100%);
}

.map-legend-container .legend-item:nth-child(4) .legend-color {
  background: linear-gradient(135deg, #fed501 0%, #e6c000 100%);
}

/* Enhanced Title Container */
.map-title-container {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%);
  backdrop-filter: blur(10px);
  padding: 20px 24px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  max-width: 380px;
  margin: 16px;
  z-index: 1001;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-family: 'Inter', sans-serif;
}

.map-title-container .map-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
  color: #2c3e50;
  margin-bottom: 8px;
}

.map-title-container .map-subtitle {
  font-size: 14px;
  margin: 0;
  color: #5a6c7d;
  line-height: 1.4;
  font-weight: 400;
}

/* Button styles */
.btn {
  border-radius: 8px;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  transition: all 0.3s ease;
  border: none;
  font-family: 'Inter', sans-serif;
}

/* Desktop button positioning */
#toggle-dashboard {
  position: absolute;
  bottom: 4rem;
  left: 1rem;
  z-index: 1100;
}

#toggle-legend {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  z-index: 1100;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
  background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(108, 117, 125, 0.4);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 117, 125, 0.6);
}

/* Chart styling improvements */
#injuryChart, #dowChart { 
  width: 100%; 
  height: 250px; 
  margin-bottom: 2rem;
  background: white;
  border-radius: 8px;
  padding: 16px;
  border: 1px solid #e9ecef;
}

/* Form control spacing */
.form-control[type="month"] { 
  margin-bottom: 2rem; 
}

/* Custom scrollbar for dashboard */
#dashboard::-webkit-scrollbar {
  width: 6px;
}

#dashboard::-webkit-scrollbar-track {
  background: #e9ecef;
  border-radius: 3px;
}

#dashboard::-webkit-scrollbar-thumb {
  background: #adb5bd;
  border-radius: 3px;
}

#dashboard::-webkit-scrollbar-thumb:hover {
  background: #6c757d;
}

/* Enhanced cluster styling */
.marker-cluster-small {
  background-color: rgba(255, 126, 64, 0.6);
}

.marker-cluster-small div {
  background-color: rgba(255, 126, 64, 0.8);
}

.marker-cluster-medium {
  background-color: rgba(255, 126, 64, 0.7);
}

.marker-cluster-medium div {
  background-color: rgba(255, 126, 64, 0.9);
}

.marker-cluster-large {
  background-color: rgba(255, 126, 64, 0.8);
}

.marker-cluster-large div {
  background-color: rgba(255, 126, 64, 1);
}

/* Leaflet popup styling */
.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);
}

.leaflet-popup-content {
  margin: 12px 16px;
  font-family: 'Inter', sans-serif;
}

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

/* Loading animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.map-legend-container,
.map-title-container {
  animation: fadeIn 0.6s ease-out;
}

/* Hover effects for interactive elements */
.legend-item:hover .legend-color {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  #map {
    right: 0 !important;
  }

  #dashboard {
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    background: #f8f9fa;
  }

  /* Mobile button positioning and sizing */
  #toggle-dashboard {
    position: absolute;
    bottom: 60px;
    left: 12px;
    z-index: 1100;
    font-size: 10px;
    padding: 0.25rem 0.5rem;
    max-width: 70px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    height: 28px;
    min-height: 28px;
    border-radius: 6px;
  }

  #toggle-legend {
    position: absolute;
    bottom: 20px;
    left: 12px;
    z-index: 1100;
    font-size: 10px;
    padding: 0.25rem 0.5rem;
    max-width: 70px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    height: 28px;
    min-height: 28px;
    border-radius: 6px;
  }

  /* Fix legend positioning and width for mobile */
  #map-legend {
    display: none;
    position: absolute !important;
    bottom: 80px;
    left: 12px;
    right: 12px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: calc(100vw - 24px);
    max-width: none;
  }

  /* Improve legend content for mobile */
  .map-legend-container {
    max-width: none;
    width: 100%;
  }

  .map-legend-container .legend-item {
    padding: 12px 16px;
    margin-bottom: 12px;
  }

  .map-legend-container .legend-color {
    width: 20px;
    height: 20px;
    margin-right: 16px;
  }

  .map-legend-container .legend-item div {
    flex: 1;
  }

  .map-legend-container .legend-item strong {
    font-size: 15px;
    display: block;
    margin-bottom: 2px;
  }

  .map-legend-container .legend-item small {
    font-size: 13px;
    line-height: 1.3;
  }

  /* Center title container at the top for mobile */
  .map-title-container {
    margin: 12px auto;
    padding: 16px 20px;
    max-width: calc(100vw - 24px);
    left: 50%;
    transform: translateX(-50%);
    right: auto;
  }

  .map-title-container .map-title {
    font-size: 18px;
  }

  .map-title-container .map-subtitle {
    font-size: 13px;
  }

  /* Mobile-specific dashboard improvements */
  #dashboard h4 {
    font-size: 1.3rem;
    margin-bottom: 0.8rem;
  }

  #dashboard h5 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
  }

  #dashboard p {
    font-size: 14px;
    margin-bottom: 1.2rem;
  }

  .form-control {
    padding: 0.6rem;
    font-size: 14px;
  }

  #injuryChart, #dowChart {
    height: 200px;
    margin-bottom: 1.5rem;
  }

  /* Better touch targets for mobile */
  .form-check {
    margin-bottom: 0.8rem;
  }

  .form-check-input {
    transform: scale(1.2);
    margin-right: 0.5rem;
  }

  .form-check-label {
    font-size: 14px;
    padding-top: 2px;
  }
}

/* Responsive improvements */
@media (max-width: 480px) {
  .map-legend-container {
    max-width: calc(100vw - 24px);
    margin: 0 12px;
  }
  
  .map-title-container {
    max-width: calc(100vw - 24px);
    margin: 12px;
  }

  /* Extra small screen optimizations */
  #dashboard {
    padding: 1rem;
  }

  #dashboard h4 {
    font-size: 1.2rem;
  }

  #dashboard h5 {
    font-size: 1rem;
  }

  #dashboard p {
    font-size: 13px;
  }

  .form-control {
    padding: 0.5rem;
    font-size: 13px;
  }

  #injuryChart, #dowChart {
    height: 180px;
    padding: 12px;
  }

  /* Additional mobile legend improvements */
  #map-legend {
    bottom: 70px;
    left: 8px;
    right: 8px;
    width: calc(100vw - 16px);
    padding: 16px;
  }

  .map-legend-container .legend-item {
    padding: 10px 12px;
    margin-bottom: 10px;
  }

  .map-legend-container .legend-color {
    width: 18px;
    height: 18px;
    margin-right: 12px;
  }

  .map-legend-container .legend-item strong {
    font-size: 14px;
  }

  .map-legend-container .legend-item small {
    font-size: 12px;
  }

  /* Better title positioning for very small screens */
  .map-title-container {
    max-width: calc(100vw - 24px);
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    padding: 12px 16px;
  }

  .map-title-container .map-title {
    font-size: 16px;
  }

  .map-title-container .map-subtitle {
    font-size: 12px;
  }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
  #dashboard {
    padding: 1rem;
  }

  #injuryChart, #dowChart {
    height: 150px;
  }

  .map-title-container {
    padding: 12px 16px;
    max-width: calc(100vw - 24px);
    left: 50%;
    transform: translateX(-50%);
    right: auto;
  }

  .map-title-container .map-title {
    font-size: 16px;
  }

  .map-title-container .map-subtitle {
    font-size: 12px;
  }

  /* Landscape legend improvements */
  #map-legend {
    bottom: 60px;
    max-height: 40vh;
  }

  .map-legend-container .legend-item {
    padding: 8px 12px;
    margin-bottom: 8px;
  }

  .map-legend-container .legend-color {
    width: 16px;
    height: 16px;
    margin-right: 10px;
  }

  .map-legend-container .legend-item strong {
    font-size: 13px;
  }

  .map-legend-container .legend-item small {
    font-size: 11px;
  }
}
