/* Modern Air Quality Dashboard Styles */

/* Import Mitr and Noto Sans Thai Looped Fonts */
@import url('https://fonts.googleapis.com/css2?family=Mitr:wght@200;300;400;500;600;700&family=Noto+Sans+Thai+Looped:wght@100..900&display=swap');

:root {
  --primary-color: #1e40af;
  --secondary-color: #3b82f6;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --purple-color: #8b5cf6;
  --dark-color: #1f2937;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --border-radius: 12px;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl:
    0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family:
    "Noto Sans Thai Looped",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: #f3f4f6;
  color: var(--gray-800);
  min-height: 100vh;
  font-weight: 400;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

/* Top Navigation Bar */
.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgb(0, 113, 199);
  padding: 0 32px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  height: 70px;
  flex-shrink: 0;
}

.navbar-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.navbar-brand .app-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  margin: 0;
  font-family: "Noto Sans Thai Looped", sans-serif;
}

.navbar-brand .app-subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
  font-weight: 400;
  font-family: "Noto Sans Thai Looped", sans-serif;
}

/* Top Navbar Tabs - Horizontal Layout */
.top-navbar .nav-tabs {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  font-family: "Noto Sans Thai Looped", sans-serif;
}

/* Navbar Right Section */
.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Language Switcher */
.language-switcher {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px;
}

.lang-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: "Noto Sans Thai Looped", sans-serif;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.lang-btn.active {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

/* Mobile Menu Button - Hidden on Desktop */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-btn i {
  font-size: 28px;
}

/* Mobile Menu - Hidden by Default */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mobile-menu.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.mobile-menu-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 85%;
  height: 100%;
  background: white;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
  z-index: 2;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.mobile-menu.active .mobile-menu-content {
  transform: translateX(0);
}

.mobile-menu-close {
  align-self: flex-end;
  background: transparent;
  border: none;
  color: var(--gray-600);
  cursor: pointer;
  padding: 16px;
  font-size: 24px;
}

.mobile-menu-close:hover {
  color: var(--gray-900);
}

.mobile-nav {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 4px;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: transparent;
  border: none;
  color: var(--gray-700);
  cursor: pointer;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: "Noto Sans Thai Looped", sans-serif;
  text-align: left;
}

.mobile-nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.mobile-nav-item.active {
  background: var(--primary-color);
  color: white;
}

.mobile-nav-item i {
  font-size: 24px;
}

.app-container {
  display: flex;
  height: calc(100vh - 70px);
  min-height: calc(100vh - 70px);
  max-height: calc(100vh - 70px);
  overflow: hidden;
  flex: 1;
}

/* Indicator Toggle */
.indicator-toggle {
  display: flex;
  gap: 0;
  background: var(--gray-100);
  border-radius: 8px;
  padding: 4px;
  margin: 15px 0;
}

.toggle-label {
  flex: 1;
  position: relative;
}

.toggle-label input[type="radio"] {
  display: none;
}

.toggle-btn {
  display: block;
  padding: 8px 16px;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 14px;
  color: var(--gray-600);
}

.toggle-label input[type="radio"]:checked + .toggle-btn {
  background: white;
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

/* Data Source Toggle */
.data-source-toggle {
  margin: 15px 0;
  padding: 12px;
  background: var(--gray-50);
  border-radius: 8px;
  border: 1px solid var(--gray-200);
}

.source-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.data-source-toggle .toggle-label {
  display: inline-block;
  width: calc(50% - 4px);
}

.data-source-toggle .toggle-label:first-of-type {
  margin-right: 8px;
}

.refresh-notice {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--warning-color);
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 6px;
  border: 1px solid #fbbf24;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #92400e;
}

.notice-icon {
  font-size: 14px;
  line-height: 1;
}

.notice-text {
  font-weight: 500;
  line-height: 1.3;
}

.toggle-btn:hover {
  color: var(--gray-800);
}

/* Sidebar */
.sidebar {
  width: 380px;
  background: white;
  box-shadow: var(--shadow-xl);
  overflow-y: visible;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar[style*="display: none"] {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

.top-navbar .nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  border-radius: 0;
  white-space: nowrap;
  font-family: "Noto Sans Thai Looped", sans-serif;
}

.top-navbar .nav-tab:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.top-navbar .nav-tab.active {
  color: white;
  background: rgba(255, 255, 255, 0.2);
  border-bottom-color: white;
}

.top-navbar .nav-tab i.material-icons {
  font-size: 20px;
}

/* Page Content */
.page-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.page-content.active {
  display: block;
}

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

.sidebar .content-section {
  padding: 24px;
  overflow-y: visible;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 24px;
  line-height: 1.5;
}

.info-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 16px;
}

.info-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 12px;
}

.info-card p {
  color: var(--gray-700);
  line-height: 1.6;
  margin-bottom: 8px;
}

.info-card ul {
  color: var(--gray-700);
  line-height: 1.8;
}

.info-card ul li {
  margin-bottom: 4px;
}

.formula-box {
  background: var(--gray-50);
  border-left: 4px solid var(--primary-color);
  padding: 16px;
  border-radius: 4px;
  margin: 12px 0;
  font-family: 'Courier New', monospace;
}

.aqhi-levels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.level-item {
  background: var(--gray-50);
  border-left: 4px solid;
  padding: 12px 16px;
  border-radius: 4px;
}

.level-value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.level-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.level-desc {
  font-size: 0.875rem;
  color: var(--gray-600);
  line-height: 1.5;
}

/* Two-column AQHI levels layout */
.aqhi-table-header {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  gap: 16px;
  background: rgb(0, 53, 116);
  color: white;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 0.95rem;
}

.header-level,
.header-general,
.header-atrisk {
  text-align: center;
}

.level-item-with-columns {
  background: var(--gray-50);
  border-left: 4px solid;
  padding: 16px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.level-row {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.level-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.level-value {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

.level-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  text-align: center;
}

.level-desc {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--gray-700);
}

/* Health Advice Table Styles */
.advice-type-section {
  margin-bottom: 32px;
}

.advice-type-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-200);
}

.advice-type-title i.material-icons {
  font-size: 1.5rem;
  color: var(--primary-color);
}

.advice-group-card {
  background: var(--gray-50);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--gray-200);
}

.advice-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 12px;
}

.advice-group-header i.material-icons {
  font-size: 1.25rem;
  color: var(--gray-600);
}

.advice-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.advice-row {
  display: flex;
  align-items: stretch;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  border-left: 4px solid;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.advice-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.advice-level {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  text-align: center;
  min-width: 100px;
  flex-shrink: 0;
}

.advice-text {
  flex: 1;
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--gray-700);
  line-height: 1.6;
  display: flex;
  align-items: center;
}

.indicator-section {
  padding: 24px;
  border-bottom: 1px solid var(--gray-200);
}

/* Statistics Panel */
.stats-section {
  padding: 24px;
  border-bottom: 1px solid var(--gray-200);
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  background: var(--gray-50);
  padding: 16px;
  border-radius: var(--border-radius);
  border: 1px solid var(--gray-200);
  transition: all 0.2s ease;
}

.stat-card:hover {
  background: white;
  box-shadow: var(--shadow-md);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--gray-600);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.category-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: between;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: 8px;
  font-size: 0.875rem;
}

.category-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 8px;
}

.category-count {
  margin-left: auto;
  font-weight: 600;
  color: var(--gray-700);
}

/* Main Content Area (for About and Health pages) */
.main-content {
  flex: 1;
  position: relative;
  overflow-y: auto;
  background: white;
  display: none;
  width: 100%;
  height: calc(100vh - 70px);
  min-height: calc(100vh - 70px);
  max-height: calc(100vh - 70px);
}

.main-content.active {
  display: block;
}

.main-content .content-section {
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px 32px 80px 32px;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--gray-600);
  margin-bottom: 32px;
}

/* Map Container */
.map-container {
  flex: 1;
  position: relative;
  display: block;
  background: #e5e7eb;
  min-height: calc(100vh - 70px);
}

.map-container.hidden {
  display: none;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
  z-index: 1;
  background: #e5e7eb;
}

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

.control-button {
  background: white;
  border: none;
  padding: 12px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
}

.control-button:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-1px);
}

/* Legend - Hidden on map, now in sidebar */
.map-legend {
  display: none;
}

/* Sidebar Legend */
.map-legend-sidebar {
  margin-top: 8px;
}

.legend-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-900);
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--gray-700);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Station Info Panel */
.station-info {
  position: absolute;
  top: 20px;
  left: 20px;
  background: white;
  padding: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  z-index: 1001;
  min-width: 300px;
  max-width: 600px;
  width: 550px;
  display: none;
  animation: slideIn 0.3s ease;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

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

.station-header {
  display: flex;
  justify-content: between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.station-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
  flex: 1;
}

.close-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-button:hover {
  background: var(--gray-100);
  color: var(--gray-600);
}

.station-aqi {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.station-aqi-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.25rem;
}

.station-details {
  flex: 1;
}

.station-category {
  font-weight: 600;
  margin-bottom: 4px;
}

.station-time {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* Station History Chart */
.station-history {
  margin-top: 20px;
  padding-top: 20px;
  padding-bottom: 20px;
  border-top: 1px solid var(--gray-200);
}

#chart-canvas-container {
  position: relative;
  margin-bottom: 20px;
}

#station-history-chart {
  padding-bottom: 60px;
}

.history-toggle {
  display: flex;
  gap: 8px;
}

.history-btn {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: "Noto Sans Thai Looped", sans-serif;
}

.history-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.history-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Loading States */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--gray-500);
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error {
  background: #fef2f2;
  color: #dc2626;
  padding: 16px;
  border-radius: var(--border-radius);
  border: 1px solid #fecaca;
  text-align: center;
  font-size: 0.875rem;
}

/* Thai AQI Colors (5 stages) */
.aqi-very-good {
  background-color: #06b6d4; /* cyan */
}
.aqi-good {
  background-color: #10b981; /* green */
}
.aqi-moderate {
  background-color: #f59e0b; /* yellow */
}
.aqi-unhealthy {
  background-color: #f97316; /* orange */
}
.aqi-very-unhealthy {
  background-color: #ef4444; /* red */
}

/* Color variants for text */
.text-aqi-very-good {
  color: #06b6d4;
}
.text-aqi-good {
  color: #10b981;
}
.text-aqi-moderate {
  color: #f59e0b;
}
.text-aqi-unhealthy {
  color: #f97316;
}
.text-aqi-very-unhealthy {
  color: #ef4444;
}

/* AQHI Colors (separate from AQI) */
.aqhi-low {
  background-color: #10b981; /* green - Low (0-3.9) */
}
.aqhi-moderate {
  background-color: #f59e0b; /* yellow - Moderate (4-6.9) */
}
.aqhi-high {
  background-color: #ef4444; /* red - High (7-9.9) */
}
.aqhi-very-high {
  background-color: #7f1d1d; /* dark red - Very High (10+) */
}

/* AQHI text colors */
.text-aqhi-low {
  color: #10b981;
}
.text-aqhi-moderate {
  color: #f59e0b;
}
.text-aqhi-high {
  color: #ef4444;
}
.text-aqhi-very-high {
  color: #7f1d1d;
}

/* Custom marker styles */
.custom-marker {
  background: transparent !important;
  border: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Top Navigation Bar - Mobile */
  .top-navbar {
    flex-direction: row;
    height: 60px;
    min-height: 60px;
    padding: 12px 16px;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
  }

  .navbar-brand .app-title {
    font-size: 1.25rem;
  }

  .navbar-brand .app-subtitle {
    font-size: 0.7rem;
  }

  /* Hide desktop navigation on mobile */
  .desktop-nav {
    display: none !important;
  }

  /* Show mobile menu button */
  .mobile-menu-btn {
    display: block;
  }

  /* Show mobile menu */
  .mobile-menu {
    display: block;
  }

  /* Show language switcher on mobile navbar */
  .navbar-right .language-switcher {
    display: flex;
  }

  /* App Container - Mobile */
  .app-container {
    flex-direction: column;
    min-height: calc(100vh - 60px);
  }

  /* Sidebar - Mobile (Full Width) */
  .sidebar {
    width: 100%;
    min-height: 50vh;
    order: 2;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }

  /* Map Container - Mobile */
  .map-container {
    height: 50vh;
    min-height: 50vh;
    max-height: 50vh;
    order: 1;
    width: 100%;
    overflow: hidden;
    position: relative;
  }

  .map-container:not(.hidden) {
    display: block !important;
  }

  .map-container.hidden {
    display: none !important;
  }

  #map {
    width: 100% !important;
    height: 50vh !important;
    min-height: 50vh !important;
    max-height: 50vh !important;
    position: absolute;
    top: 0;
    left: 0;
  }

  /* Main Content - Mobile (Full Width) */
  .main-content {
    width: 100%;
    height: auto;
    min-height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }

  .content-section {
    padding: 24px 16px;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .page-subtitle {
    font-size: 0.875rem;
  }

  /* Station Info Panel - Mobile */
  .station-info {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90%;
    max-width: 350px;
    max-height: 80vh;
    overflow-y: auto;
    animation: fadeIn 0.3s ease !important;
  }

  /* Stats Grid - Mobile */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .weather-info {
    grid-template-columns: 1fr;
  }

  /* Info Cards - Mobile */
  .info-card {
    padding: 16px;
  }

  .info-card h3 {
    font-size: 1rem;
  }

  /* AQHI Levels - Mobile */
  .aqhi-levels {
    gap: 8px;
  }

  .level-item {
    padding: 10px 12px;
  }

  .level-value {
    font-size: 1rem;
  }

  /* AQHI Table with Columns - Mobile */
  .aqhi-table-header {
    display: none;
  }

  .level-item-with-columns {
    padding: 12px;
  }

  .level-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .level-info {
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-200);
  }

  .level-info .level-value {
    font-size: 1.5rem;
  }

  .level-info .level-label {
    font-size: 0.875rem;
  }

  .recommendation-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .recommendation-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .mobile-only {
    display: block;
  }

  .level-desc {
    font-size: 0.875rem;
    line-height: 1.6;
    padding-left: 12px;
    position: relative;
  }

  .level-desc::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--gray-500);
    font-weight: bold;
  }

  /* Language Switcher - Mobile */
  .language-switcher {
    align-self: flex-end;
    width: auto;
  }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 769px) {
  .mobile-only {
    display: none;
  }

  .recommendation-item {
    display: contents;
  }
}

@media (max-width: 480px) {
  .top-navbar {
    padding: 10px 12px;
    height: 56px;
    min-height: 56px;
  }

  .navbar-brand .app-title {
    font-size: 1.1rem;
  }

  .navbar-brand .app-subtitle {
    display: none;
  }

  .top-navbar .nav-tab {
    padding: 10px 12px;
    font-size: 0.75rem;
  }

  .top-navbar .nav-tab span {
    display: none;
  }

  .top-navbar .nav-tab i.material-icons {
    font-size: 20px;
  }

  /* App Container - Small Mobile */
  .app-container {
    min-height: calc(100vh - 56px);
  }

  /* Map Container - Small Mobile */
  .map-container {
    height: 50vh;
    min-height: 50vh;
    max-height: 50vh;
    position: relative;
  }

  #map {
    width: 100% !important;
    height: 50vh !important;
    min-height: 50vh !important;
    max-height: 50vh !important;
    position: absolute;
    top: 0;
    left: 0;
  }

  /* Sidebar - Small Mobile */
  .sidebar {
    min-height: 50vh;
    background: white;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }

  .indicator-section,
  .stats-section {
    padding: 12px;
  }

  .section-title {
    font-size: 0.9rem;
  }

  .content-section {
    padding: 20px 12px;
  }

  .page-title {
    font-size: 1.25rem;
  }

  /* Advice Table - Mobile */
  .advice-row {
    flex-direction: column;
  }

  .advice-level {
    min-width: 100%;
    padding: 8px 12px;
  }

  .advice-text {
    padding: 12px;
  }

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

  .control-button {
    width: 40px;
    height: 40px;
    padding: 8px;
  }

  /* Station History Chart Mobile Fixes */
  .station-history {
    overflow-x: hidden;
    max-width: 100%;
  }

  #chart-canvas-container {
    max-width: 100%;
    overflow-x: hidden;
  }

  #history-chart-canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  .history-btn {
    /* Larger tap targets for mobile */
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px; /* iOS recommended minimum tap target */
    touch-action: manipulation; /* Disable double-tap zoom */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
  }

  .history-toggle {
    gap: 12px; /* More space between buttons on mobile */
  }
}

/* Extra small screens and landscape phones */
@media (max-width: 480px) and (max-height: 600px) {
  .app-container {
    min-height: calc(100vh - 56px);
  }

  .map-container {
    height: 45vh;
    min-height: 45vh;
    max-height: 45vh;
  }

  .sidebar {
    min-height: 55vh;
    overflow-y: auto;
    background: white;
    position: relative;
  }
}

/* Landscape orientation fixes */
@media (orientation: landscape) and (max-height: 500px) {
  /* Compact navbar for landscape */
  .top-navbar {
    height: auto;
    min-height: 50px;
    max-height: 120px;
    padding: 6px 12px;
    flex-wrap: wrap;
  }

  .navbar-brand .app-title {
    font-size: 0.95rem;
  }

  .navbar-brand .app-subtitle {
    display: none;
  }

  /* Hide desktop nav tabs in tight landscape */
  .desktop-nav {
    display: none !important;
  }

  /* Show mobile menu button */
  .mobile-menu-btn {
    display: block !important;
  }

  /* Enable mobile menu */
  .mobile-menu {
    display: block !important;
  }

  /* Language switcher - keep visible and functional */
  .language-switcher {
    display: flex !important;
    transform: scale(0.9);
  }

  .lang-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .app-container {
    height: calc(100vh - 50px);
    min-height: calc(100vh - 50px);
    max-height: calc(100vh - 50px);
    flex-direction: row;
  }

  .map-container {
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    width: 65% !important;
    order: 1;
    position: relative;
  }

  #map {
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
  }

  .sidebar {
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    width: 35% !important;
    order: 2;
    background: white;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .indicator-section,
  .stats-section {
    padding: 12px;
    background: white;
  }

  .section-title {
    font-size: 0.8rem;
  }

  .indicator-toggle {
    padding: 3px;
  }

  .toggle-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .map-legend-sidebar .legend-item {
    font-size: 0.75rem;
  }

  /* Main content for other pages */
  .main-content {
    height: calc(100vh - 50px) !important;
    min-height: calc(100vh - 50px) !important;
    max-height: calc(100vh - 50px) !important;
  }
}

/* Landscape for larger devices (tablets) */
@media (orientation: landscape) and (min-height: 500px) and (max-width: 1024px) {
  .top-navbar {
    height: 60px;
    min-height: 60px;
    padding: 8px 16px;
  }

  .navbar-brand .app-title {
    font-size: 1.1rem;
  }

  .navbar-brand .app-subtitle {
    display: none;
  }

  /* Ensure mobile menu works in landscape */
  .mobile-menu-btn {
    display: none;
  }

  .mobile-menu {
    display: none;
  }

  /* Keep language switcher visible */
  .language-switcher {
    display: flex !important;
  }

  .app-container {
    height: calc(100vh - 60px);
    min-height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
    flex-direction: row;
  }

  .map-container {
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    width: 60%;
    order: 1;
    position: relative;
  }

  #map {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
  }

  .sidebar {
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    width: 40%;
    order: 2;
    background: white;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .indicator-section,
  .stats-section {
    padding: 16px;
    background: white;
  }

  .section-title {
    font-size: 0.875rem;
  }

  .main-content {
    height: calc(100vh - 60px);
    min-height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
  }
}

/* Ensure sections always have white background on mobile */
@media (max-width: 768px) {
  .indicator-section,
  .stats-section,
  .map-legend-sidebar {
    background: white;
  }
}

/* Desktop-specific fixes for station panel scrolling */
@media (min-width: 769px) {
  /* Ensure station panel can scroll on desktop */
  .station-info {
    overflow-y: auto !important;
    max-height: calc(100vh - 40px) !important;
  }

  /* Prevent body scroll when station panel is open */
  body.station-panel-open {
    overflow: hidden;
  }

  /* Ensure chart legend is visible on desktop */
  #station-history-chart {
    min-height: 450px;
    padding-bottom: 80px !important;
  }

  #chart-canvas-container {
    min-height: 400px;
    margin-bottom: 30px !important;
  }
}

/* Health Recommendations Styles */
.health-recommendations {
  margin-top: 15px;
  padding: 15px;
  background: var(--gray-50);
  border-radius: var(--border-radius);
  border: 1px solid var(--gray-200);
}

.health-recommendations h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.population-groups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}

.population-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 70px;
  gap: 4px;
}

.population-group:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.population-group.active {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
}

.population-group .material-icons {
  font-size: 28px !important;
  display: block;
  width: 100%;
  text-align: center;
  line-height: 1;
  margin: 0;
  vertical-align: middle;
}

.population-group.active .material-icons {
  color: white;
}

.population-group span:not(.material-icons) {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  color: inherit;
}

.health-recommendation-text {
  background: white;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  font-size: 13px;
  line-height: 1.4;
  color: var(--gray-700);
  min-height: 60px;
  display: flex;
  align-items: center;
}

.health-recommendation-text.no-selection {
  color: var(--gray-500);
  font-style: italic;
  text-align: center;
}

/* Footer */
.footer {
  background: #ffffff;
  padding: 24px 32px;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.footer-logo {
  height: 60px;
  width: auto;
}

/* Community Data Page Styles */
.community-map-section {
  display: flex;
  gap: 24px;
  margin: 24px 0;
  min-height: 600px;
  position: relative;
}

.community-map {
  flex: 2;
  height: 600px;
  max-height: 600px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  background: var(--gray-100);
  position: relative;
}

/* Community Popup Styles */
.community-leaflet-popup .leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0;
  font-family: 'Noto Sans Thai Looped', sans-serif;
}

.community-leaflet-popup .leaflet-popup-content {
  margin: 0;
  min-width: 200px;
  font-family: 'Noto Sans Thai Looped', sans-serif;
}

.community-popup {
  padding: 16px;
  font-family: 'Noto Sans Thai Looped', sans-serif;
}

.community-popup h4 {
  margin: 0 0 12px 0;
  color: var(--primary-color);
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Noto Sans Thai Looped', sans-serif;
}

.community-popup p {
  margin: 6px 0;
  font-size: 0.875rem;
  color: var(--gray-700);
  line-height: 1.5;
  font-family: 'Noto Sans Thai Looped', sans-serif;
}

.community-popup strong {
  color: var(--gray-900);
  font-weight: 500;
  font-family: 'Noto Sans Thai Looped', sans-serif;
}

.community-info-panel {
  flex: 1;
  background: white;
  padding: 24px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  max-height: 600px;
  overflow-y: auto;
}

.community-info-panel h3 {
  color: var(--gray-900);
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.community-info-panel p {
  color: var(--gray-600);
  line-height: 1.6;
  margin-bottom: 16px;
}

.community-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--gray-50);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--primary-color);
  border-radius: 50%;
  color: white;
}

.stat-icon i {
  font-size: 24px;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-top: 4px;
}

/* Community Detail View */
.community-detail {
  padding: 16px 0;
}

.community-detail h4 {
  color: var(--primary-color);
  margin: 16px 0 8px;
  font-size: 1rem;
}

.community-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 12px 0;
}

.community-detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.community-detail-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.community-detail-value {
  font-size: 1rem;
  color: var(--gray-900);
  font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #page-community .content-section {
    padding: 16px;
  }

  #page-community .page-title,
  #page-community .page-subtitle {
    padding: 0 0;
  }

  .community-map-section {
    flex-direction: column;
    min-height: auto;
    margin: 0;
    gap: 16px;
  }

  .community-map {
    height: 50vh;
    max-height: 50vh;
    min-height: 300px;
    width: 100%;
    border-radius: 0;
    position: relative;
  }

  .community-info-panel {
    max-height: none;
    margin: 0 16px;
  }

  .community-stats-grid {
    grid-template-columns: 1fr;
  }

  .community-detail-grid {
    grid-template-columns: 1fr;
  }

  #page-community .info-card {
    margin: 0 16px;
  }
}
