/* CSS Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1f2937;
  background: linear-gradient(135deg, #0B1E3D 0%, #00B4FF 100%);
  min-height: 100vh;
  height: 100vh;
  line-height: 1.5;
  padding: 12px;
  overflow: hidden;
}

/* Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
  margin: 0 auto;
}

/* Two columns on tablets and wider */
@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Compact mode overrides */
.compact-mode #pollutantSection {
  display: none !important;
}

.compact-mode .dashboard-grid {
  grid-template-columns: 1fr !important;
  gap: 6px !important;
}

.compact-mode .dashboard-card {
  padding: 8px !important;
  border-radius: 10px !important;
  font-size: 13px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
}

.compact-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  margin-left: 8px;
  cursor: pointer;
  color: #00B4FF;
  font-size: 18px;
  transition: color 0.2s;
}

.compact-toggle:hover {
  color: #744DFF;
}

/* Main container wrapper */
#hk-iaq-dashboard {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 24px);
  overflow-y: auto;
}
  .dashboard-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
  }

  .dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  }
  .card-title {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #6b7280;
    letter-spacing: 0.5px;
    text-transform: uppercase;
  }
  /* Preserve units casing inside titles (avoid uppercasing µg/m³) */
  .card-title .unit {
    text-transform: none;
    letter-spacing: normal;
  }
  .card-main {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 36px;
    font-weight: 700;
    flex-wrap: wrap;
    color: #1f2937;
  }

  .card-value {
    font-weight: 800;
    background: linear-gradient(135deg, #00B4FF 0%, #744DFF 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
.risk-pill {
  width: 70px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 24px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #9ca3af;
  white-space: nowrap;
  transition: all 0.3s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
}

.risk-pill:hover {
  transform: scale(1.05);
}
  .card-updated {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 12px;
    font-style: italic;
  }
  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
    gap: 8px;
  }
  .metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 13px;
    color: #4b5563;
    min-width: 0;
    font-weight: 500;
  }
  .icon {
    width: 32px;
    height: 32px;
    margin-bottom: 6px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  }
  .iconBig {
    width: 60px;
    height: 60px;
    margin-bottom: 6px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  }

/* Responsive Design - removed duplicate, keeping only 2 columns max */

/* Mobile optimization */
@media (max-width: 480px) {
  body {
    font-size: 14px;
    padding: 12px;
  }

  .dashboard-card {
    padding: 16px;
    border-radius: 16px;
  }

  .card-title {
    font-size: 12px;
  }

  .card-main {
    font-size: 36px;
  }

  .risk-pill {
    width: 60px;
    font-size: 10px;
    padding: 6px 8px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
  }

  .icon {
    width: 32px;
    height: 32px;
  }

  .iconBig {
    width: 40px;
    height: 40px;
  }

  .modal-content {
    width: 95%;
    border-radius: 20px;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  body {
    background: white;
  }

  .dashboard-card {
    box-shadow: none;
    page-break-inside: avoid;
  }
}

/* Weather Warnings Section */
.warnings-container {
  margin-bottom: 16px;
}

.warning-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  border-left: 3px solid;
  animation: slideIn 0.3s ease-out;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
}

.warning-item:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.warning-item.yellow {
  background-color: #fef3c7;
  border-left-color: #fbbf24;
  color: #92400e;
}

.warning-item.red {
  background-color: #fee2e2;
  border-left-color: #ef4444;
  color: #7f1d1d;
}

.warning-item.black {
  background-color: #f3f4f6;
  border-left-color: #1f2937;
  color: #1f2937;
}

.warning-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  object-fit: contain;
}

.warning-content {
  flex: 1;
  min-width: 0;
}

.warning-title {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 2px;
}

.warning-time {
  font-size: 10px;
  opacity: 0.7;
  font-style: italic;
}

.no-warnings {
  text-align: center;
  color: #6b7280;
  font-size: 12px;
  padding: 8px;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(11, 30, 61, 0.8);
  animation: fadeIn 0.3s ease;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  color: #374151;
}

.modal-close {
  font-size: 32px;
  font-weight: bold;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #374151;
}

.modal-body {
  padding: 20px;
  max-height: calc(90vh - 80px);
  overflow-y: auto;
}

.clickable-icon {
  cursor: pointer;
  transition: all 0.3s ease;
}

.clickable-icon:hover {
  transform: scale(1.15) rotate(5deg);
  filter: drop-shadow(0 4px 12px rgba(0, 180, 255, 0.5));
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Health Advice Section */
.health-advice {
  background: linear-gradient(135deg, rgba(0, 180, 255, 0.1), rgba(116, 77, 255, 0.1));
  border-left: 4px solid #00B4FF;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.4;
}

.health-advice-icon {
  font-size: 16px;
  margin-right: 8px;
}

.health-advice-text {
  color: #1f2937;
  font-weight: 500;
}

/* Share Button */
.share-button {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #00B4FF 0%, #744DFF 100%);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 180, 255, 0.3);
  white-space: nowrap;
}

.share-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 180, 255, 0.4);
}

.share-button:active {
  transform: translateY(0);
}

/* Trend Indicators */
.trend-indicator {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  font-size: 14px;
  font-weight: 700;
}

.trend-up {
  color: #ef4444;
}

.trend-down {
  color: #22c55e;
}

.trend-neutral {
  color: #9ca3af;
}

/* Pollutant average values */
.pollutant-avg {
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  margin-left: 4px;
}

/* Wind indicator */
.wind-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
/* Rotation wrapper to avoid transform conflicts with pulse animation */
.wind-rot { display: inline-block; transform-origin: 50% 50%; }
/* Inner arrow handles pulse (scale) only */
.wind-arrow { display: inline-block; color: #00B4FF; font-size: 16px; transform-origin: 50% 50%; animation: windPulse 2s ease-in-out infinite; }
@keyframes windPulse { 0%,100%{ transform: scale(1) } 50%{ transform: scale(1.15) } }
.wind-dir { font-size: 12px; color: #4b5563; }

/* Activity recommendations */
.activity-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 768px) { .activity-list { grid-template-columns: repeat(2, 1fr); } }
.activity-item { display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,0.7); border: 1px solid rgba(0,0,0,0.04); border-radius: 10px; padding: 10px 12px; gap: 12px; }
.activity-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.activity-icon { width: 28px; height: 28px; flex-shrink: 0; object-fit: contain; }
.activity-label { font-weight: 600; color: #111827; }
.activity-reason { margin-top: 2px; font-size: 11px; color: #6b7280; line-height: 1.3; }
.activity-badge { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 999px; flex-shrink: 0; }
.badge-good { background: #dcfce7; color: #166534; }
.badge-caution { background: #fef9c3; color: #854d0e; }
.badge-avoid { background: #fee2e2; color: #991b1b; }

/* Make pills clickable for info modal */
.clickable-pill { cursor: pointer; }

/* Help Button */
.help-button {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #6b7280;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.help-button:hover {
  background: white;
  color: #374151;
  border-color: #00B4FF;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 180, 255, 0.2);
}

/* Tutorial Overlay */
.tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
}

.tutorial-overlay.active {
  pointer-events: auto;
}

.tutorial-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  animation: fadeIn 0.3s ease;
}

.tutorial-tooltip {
  position: absolute;
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  max-width: 320px;
  z-index: 10000;
  animation: slideUp 0.3s ease;
}

.tutorial-tooltip::before {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border: 10px solid transparent;
}

.tutorial-tooltip.arrow-top::before {
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  border-bottom-color: white;
}

.tutorial-tooltip.arrow-bottom::before {
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  border-top-color: white;
}

.tutorial-tooltip.arrow-left::before {
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  border-right-color: white;
}

.tutorial-tooltip.arrow-right::before {
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  border-left-color: white;
}

.tutorial-content h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
}

.tutorial-content p {
  margin: 0 0 16px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #4b5563;
}

.tutorial-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.tutorial-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.tutorial-btn-primary {
  background: linear-gradient(135deg, #00B4FF 0%, #744DFF 100%);
  color: white;
}

.tutorial-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 180, 255, 0.4);
}

.tutorial-btn-secondary {
  background: #f3f4f6;
  color: #6b7280;
}

.tutorial-btn-secondary:hover {
  background: #e5e7eb;
  color: #374151;
}

.tutorial-highlight {
  position: relative;
  z-index: 9998;
  box-shadow: 0 0 0 4px rgba(0, 180, 255, 0.5), 0 0 0 99999px rgba(0, 0, 0, 0.7);
  border-radius: 12px;
  pointer-events: auto;
}