@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Readex+Pro:wght@160..700&display=swap");

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

body {
  font-family: "DM Sans", "Readex Pro", "Inter", ui-sans-serif, system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  overflow-x: hidden;
}

/* Header Styles */
header {
  background: rgb(39 67 117);
  color: #2c3e50;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 25px;
  max-width: 1400px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4em;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
  gap: 20px;
  width: 100vw;
  list-style: none;
  background: rgb(39 67 117);
  position: absolute;
  top: 100%;
  left: 0;
  padding: 15px 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);

  /* Animation properties */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.nav-links.open {
  display: flex; /* Show when open */
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-links li {
  display: flex;
  width: 100%;
  justify-content: center;
}

.nav-links a,
.nav-links .nav-btn,
.nav-links .nav-action-btn {
  display: block;
  width: 90%;
  text-align: center;
  color: white;
  text-decoration: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 500;
  transition: background-color 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
}
.nav-links .nav-action-btn {
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
}

.nav-links a:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-btn {
  background: transparent;
}

.nav-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.nav-toggle {
  display: inline-flex;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
  z-index: 101;
}

.hamburger {
  width: 28px;
  height: 3px;
  background: #fff;
  border-radius: 2px;
  position: relative;
  display: block;
  transition: all 0.3s;
}
.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  left: 0;
  width: 28px;
  height: 3px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.3s;
}
.hamburger::before {
  top: -9px;
}
.hamburger::after {
  top: 9px;
}

/* Main Container */
.main-container {
  display: grid;
  grid-template-columns: 45% 1fr;
  min-height: 100vh;
  padding-top: 65px;
}

/* Sidebar */
.sidebar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  overflow-y: auto;
  max-height: calc(100vh - 65px);
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.sidebar-content {
  padding: 25px;
}

.app-title {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-radius: 15px;
  margin: -25px -25px 25px -25px;
}

.app-title h1 {
  font-size: 1.8em;
  margin-bottom: 8px;
  font-weight: 700;
}

.app-title p {
  font-size: 0.9em;
  opacity: 0.9;
  line-height: 1.4;
}

.nasa-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8em;
  margin-top: 10px;
  display: inline-block;
}

/* Data Integration Status */
.data-sources {
  background: #f8fafc;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 25px;
  border-left: 4px solid #667eea;
}

.data-sources h3 {
  color: #2c3e50;
  font-size: 1em;
  margin-bottom: 10px;
}

.source-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0;
  font-size: 0.9em;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-active {
  background: #22c55e;
}
.status-limited {
  background: #f59e0b;
}
.status-offline {
  background: #ef4444;
}

/* Search Section */
.search-section {
  margin-bottom: 25px;
}

.search-section label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
  color: #374151;
}

.search-container {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: all 0.3s ease;
  background: white;
}

.search-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #667eea;
  border-top: none;
  border-radius: 0 0 12px 12px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.search-item {
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid #f3f4f6;
}

.search-item:hover {
  background: #f8fafc;
  color: #667eea;
}

/* Location Button */
.location-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 10px;
}

.location-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.location-display {
  margin-top: 12px;
  padding: 10px;
  background: #f0f9ff;
  border-radius: 8px;
  font-size: 0.9em;
  color: #0369a1;
  border-left: 3px solid #0ea5e9;
}

/* Forecast Section */
.forecast-section {
  background: #f8fafc;
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 25px;
}

.forecast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.forecast-title {
  color: #1f2937;
  font-weight: 600;
}

.forecast-time {
  font-size: 0.8em;
  color: #6b7280;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.forecast-item {
  background: white;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #e5e7eb;
}

.forecast-label {
  font-size: 0.8em;
  color: #6b7280;
  margin-bottom: 4px;
}

.forecast-value {
  font-weight: 600;
  color: #1f2937;
}

.forecast-aqi {
  font-size: 1.2em;
}

/* Loading and Error States */
.loading,
.error {
  text-align: center;
  padding: 15px;
  border-radius: 10px;
  margin: 12px 0;
}

.loading {
  background: #eff6ff;
  color: #1d4ed8;
}

.error {
  background: #fef2f2;
  color: #dc2626;
}

/* Data Sections */
.data-section {
  display: none;
  margin-bottom: 25px;
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.data-section.show {
  display: block;
  animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-title {
  color: #1f2937;
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* AQI Display */
.aqi-display {
  text-align: center;
  padding: 25px;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-radius: 15px;
  margin-bottom: 20px;
}

.aqi-value {
  font-size: 3em;
  font-weight: 700;
  margin-bottom: 5px;
}

.aqi-label {
  font-size: 0.9em;
  color: #64748b;
  margin-bottom: 8px;
}

.aqi-category {
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 500;
  font-size: 0.9em;
}

/* Pollutant Display */
.pollutant {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 10px;
  border-left: 4px solid; /* Color set by utility class */
}

.pollutant-info {
  display: flex;
  align-items: center;
  flex: 1;
}

.pollutant-name {
  font-weight: 600;
  width: 70px;
  color: #374151;
}

.pollutant-source {
  font-size: 0.7em;
  color: #6b7280;
  margin-left: 5px;
}

.pollutant-bar {
  height: 6px;
  flex: 1;
  margin: 0 12px;
  border-radius: 12px;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
}

.pollutant-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease-out;
  position: relative;
}

.pollutant-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.pollutant-value {
  font-weight: 500;
  min-width: 90px;
  text-align: right;
  font-size: 0.9em;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
}
.info-icon {
  cursor: pointer;
  margin-left: 10px;
  color: #6b7280;
  font-size: 1.1em;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.info-icon:hover {
  background: #667eea;
  color: white;
  transform: scale(1.1);
}

/* Health Recommendations */
.health-section {
  background: white;
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 25px;
}

.health-alert {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 15px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.alert-icon {
  font-size: 1.5em;
  flex-shrink: 0;
}

.alert-content h4 {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 1.1em;
}

.alert-content p {
  font-size: 0.95em;
  line-height: 1.4;
}

.alert-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.alert-btn {
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  margin-right: 10px;
  transition: all 0.2s ease;
}

.alert-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.recommendations-list {
  background: #f0f9ff;
  border-radius: 12px;
  padding: 16px;
  border-left: 4px solid #0ea5e9;
}

.recommendations-list h4 {
  color: #0c4a6e;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.recommendations-list ul {
  margin: 0;
  padding-left: 20px;
}

.recommendations-list li {
  margin-bottom: 8px;
  line-height: 1.5;
  color: #1e40af;
}

/* Historical Trends */
.trends-section {
  background: white;
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 25px;
}

.trend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}
.trend-item {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.trend-item:last-child {
  border-bottom: none;
}

.trend-period {
  font-weight: 500;
  color: #374151;
}

.trend-change {
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}

/* Map Container */
.map-container {
  position: relative;
  background: #1f2937;
}

#map {
  width: 100%;
  height: calc(100vh - 80px);
}

/* Map Controls */
.map-controls {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-control-btn {
  background: rgba(255, 255, 255, 0.95);
  border: none;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.map-control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: white;
  border-radius: 20px;
  padding: 30px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal.show .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 25px;
  font-size: 2em;
  color: #9ca3af;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #374151;
}

/* Footer */
footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  padding: 12px 25px;
  text-align: center;
  font-size: 0.85em;
  color: #6b7280;
  z-index: 500;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

footer a {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
  margin: 0 8px;
}

footer a:hover {
  text-decoration: underline;
}

.data-attribution {
  margin-top: 5px;
  font-size: 0.8em;
  opacity: 0.8;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .nav-toggle {
    display: inline-flex;
  }

  .main-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    padding-top: 60px;
  }

  .sidebar {
    box-shadow: none;
    max-height: 50vh;
    order: 2;
  }

  .map-container {
    order: 1;
    height: 50vh;
  }

  #map {
    height: 50vh;
  }

  footer {
    position: static;
    order: 3;
  }
}

@media (min-width: 1024px) {
  .nav-toggle {
    display: none;
  }
  .nav-links {
    /* On desktop, make it a static row */
    position: static;
    flex-direction: row;
    width: auto;
    background: none;
    box-shadow: none;
    /* Ensure it's always visible on desktop */
    opacity: 1;
    visibility: visible;
    transform: none;
    padding: 0;
    gap: 10px;
  }
  .nav-links li,
  .nav-links a,
  .nav-links .nav-btn {
    width: auto;
  }
}

@media (max-width: 768px) {
  nav {
    padding: 12px 20px;
  }

  .logo {
    font-size: 1.2em;
  }

  .nav-links {
    gap: 0;
  }

  .nav-btn {
    padding: 8px 16px;
    font-size: 0.9em;
  }

  .sidebar-content {
    padding: 20px;
  }

  .app-title h1 {
    font-size: 1.5em;
  }

  .aqi-value {
    font-size: 2.5em;
  }

  .pollutant {
    flex-wrap: wrap;
  }

  .pollutant-value {
    width: 100%;
    text-align: left;
  }

  .forecast-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .map-controls {
    top: 10px;
    right: 10px;
  }

  .modal-content {
    padding: 25px;
    margin: 20px;
  }
}

@media (max-width: 480px) {
  .main-container {
    padding-top: 60px;
    padding: 15px;
  }

  .section-title {
    font-size: 1.1em;
  }
}

/* Utility classes */
.hidden {
  display: none !important;
}
.show {
  display: block !important;
}

/* Hamburger active (open) */
.nav-toggle.active .hamburger {
  background: transparent;
}
.nav-toggle.active .hamburger::before {
  transform: rotate(45deg) translate(6px, 6px);
}
.nav-toggle.active .hamburger::after {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Loading animations */
.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #f3f4f6;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 10px auto;
}

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

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.pollutant-source {
  font-size: 0.75em;
  color: #6b7280;
  font-weight: normal;
}

/* Enhanced trend indicators */
.trend-improving {
  color: #22c55e;
}

.trend-stable {
  color: #f59e0b;
}

.trend-worsening {
  color: #ef4444;
}

/* Forecast enhancements */
.forecast-item {
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s ease;
}

.forecast-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.1);
}

.forecast-label {
  font-size: 0.85em;
  color: #6b7280;
  margin-bottom: 4px;
}

.forecast-value {
  font-size: 1.2em;
  font-weight: 700;
  margin-bottom: 4px;
}

.enhanced-forecast {
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.enhanced-forecast:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.forecast-trend {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 0.8em;
}

.forecast-pollutant-detail {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.forecast-aqi-big {
  font-size: 2em;
  font-weight: bold;
  text-align: center;
}

.forecast-category-big {
  text-align: center;
  font-weight: 600;
  margin-bottom: 15px;
}

.enhanced-trend {
  border-left: 4px solid #e5e7eb;
  transition: all 0.2s ease;
}

.enhanced-trend:hover {
  border-left-color: #667eea;
  background: #f8fafc;
}

.trend-details {
  margin-top: 5px;
  opacity: 0.7;
}

.historical-chart {
  margin-top: 15px;
  padding: 15px;
  background: #f9fafb;
  border-radius: 8px;
}

.mini-chart {
  display: flex;
  align-items: end;
  gap: 2px;
  height: 60px;
  margin-top: 10px;
}

.chart-bar {
  flex: 1;
  min-width: 3px;
  border-radius: 2px 2px 0 0;
  transition: all 0.2s ease;
}

.chart-bar:hover {
  opacity: 0.8;
  transform: scaleY(1.1);
}

/* --- AQI Color Utility Classes --- */
/* Used for .aqi-category, .pollutant border-color, .pollutant-bar-fill background, etc. */

.aqi-category.aqi-good,
.pollutant.aqi-good {
  border-left-color: #22c55e;
}
.pollutant-bar-fill.aqi-good {
  background-color: #22c55e;
}

.aqi-category.aqi-moderate,
.pollutant.aqi-moderate {
  border-left-color: #f59e0b;
}
.pollutant-bar-fill.aqi-moderate {
  background-color: #f59e0b;
}

.aqi-category.aqi-unhealthy-sensitive,
.pollutant.aqi-unhealthy-sensitive {
  border-left-color: #ef4444;
}
.pollutant-bar-fill.aqi-unhealthy-sensitive {
  background-color: #ef4444;
}

.aqi-category.aqi-unhealthy,
.pollutant.aqi-unhealthy {
  border-left-color: #dc2626;
}
.pollutant-bar-fill.aqi-unhealthy {
  background-color: #dc2626;
}

.aqi-category.aqi-very-unhealthy,
.pollutant.aqi-very-unhealthy {
  border-left-color: #991b1b;
}
.pollutant-bar-fill.aqi-very-unhealthy {
  background-color: #991b1b;
}

.aqi-category.aqi-hazardous,
.pollutant.aqi-hazardous {
  border-left-color: #7f1d1d;
}
.pollutant-bar-fill.aqi-hazardous {
  background-color: #7f1d1d;
}
