/* Base CSS variables and design tokens */
:root {
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Premium HSL Color Palette */
  --bg-color: #0b0c15;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --accent-color: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.4);
  
  /* Glassmorphism details */
  --card-bg: rgba(17, 18, 36, 0.45);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-border-focus: rgba(59, 130, 246, 0.4);
  
  /* Sensor specific colors */
  --color-temp: #ff5252;
  --color-hum: #00e5ff;
  --color-press: #e040fb;
  --color-pm25: #00e676;
  --color-pm10: #ffea00;

  /* Quality states */
  --state-excellent: #10b981;
  --state-good: #84cc16;
  --state-moderate: #eab308;
  --state-poor: #f97316;
  --state-bad: #ef4444;
}

/* Reset & Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Ambient Glowing Background Spots */
.glow-spot {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
}

.spot-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
  top: -100px;
  left: -100px;
}

.spot-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
  bottom: -200px;
  right: -100px;
}

.spot-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #ec4899 0%, transparent 70%);
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Main Container Layout */
.container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 10;
}

/* Glassmorphism Card Style */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  position: relative;
}

/* Station Selector Component */
.station-selector-card {
  display: flex;
  padding: 6px;
  gap: 8px;
  background: rgba(17, 18, 36, 0.6);
}

.station-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex: 1;
  text-align: center;
}

.station-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.station-tab-btn.active {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

/* Header Component */
.header {
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.highlight {
  background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Live Badge with Pulse Animation */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 9999px;
  width: fit-content;
  transition: all 0.3s ease;
}

.live-badge.archive-mode {
  background: rgba(249, 115, 22, 0.15);
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.live-badge.archive-mode .pulse-dot {
  background-color: var(--state-poor);
  box-shadow: none;
  animation: none;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--state-excellent);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 0 8px var(--state-excellent);
  animation: pulse 1.8s infinite;
}

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

.live-badge.archive-mode .badge-text {
  color: var(--text-primary);
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1.1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.header-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
}

.time-display {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Metrics Visibility Selector Component */
.metrics-selector-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.selector-label {
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.switch-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.switch-container {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.switch-container input {
  display: none;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.switch-container:hover .switch-label {
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.switch-container input:checked + .switch-label {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.25s ease;
}

.switch-container input:checked + .switch-label .bullet.temp { background: var(--color-temp); box-shadow: 0 0 10px var(--color-temp); }
.switch-container input:checked + .switch-label .bullet.hum { background: var(--color-hum); box-shadow: 0 0 10px var(--color-hum); }
.switch-container input:checked + .switch-label .bullet.press { background: var(--color-press); box-shadow: 0 0 10px var(--color-press); }
.switch-container input:checked + .switch-label .bullet.pm25 { background: var(--color-pm25); box-shadow: 0 0 10px var(--color-pm25); }
.switch-container input:checked + .switch-label .bullet.pm10 { background: var(--color-pm10); box-shadow: 0 0 10px var(--color-pm10); }

/* Readings Grid Layout */
.readings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  width: 100%;
}

.readings-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 170px;
}

.readings-card:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 15px 45px -15px rgba(0, 0, 0, 0.7);
}

.card-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: var(--accent-color);
}

.temp-card .card-glow { background: var(--color-temp); }
.hum-card .card-glow { background: var(--color-hum); }
.press-card .card-glow { background: var(--color-press); }
.pm25-card .card-glow { background: var(--color-pm25); }
.pm10-card .card-glow { background: var(--color-pm10); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-icon {
  font-size: 1.3rem;
}

.card-value {
  font-size: 2.3rem;
  font-weight: 700;
  font-family: var(--font-title);
  margin: 0.5rem 0;
}

.card-value .unit {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 2px;
}

.card-footer {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Quality indicators / badges */
.aqi-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.aqi-excellent { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.aqi-good { background: rgba(132, 204, 22, 0.2); color: #a3e635; border: 1px solid rgba(132, 204, 22, 0.4); }
.aqi-moderate { background: rgba(230, 179, 8, 0.2); color: #facc15; border: 1px solid rgba(230, 179, 8, 0.4); }
.aqi-poor { background: rgba(249, 115, 22, 0.2); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.4); }
.aqi-bad { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }

/* Main Content Area */
.main-content {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 1.25rem;
}

/* Tabs styles */
.tabs-container {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--accent-color);
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
}

/* Archive Datepicker Component */
.archive-picker-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.datepicker-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.datepicker-wrapper {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 2px 8px;
  gap: 6px;
}

.date-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  padding: 6px 4px;
}

/* Custom Calendar Icon Styling in Input */
.date-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.date-input::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.reset-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-primary);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.reset-btn:hover {
  background: var(--state-bad);
  color: white;
}

.reset-btn.hidden {
  display: none;
}

/* Chart Canvas Wrapper */
.chart-container {
  position: relative;
  width: 100%;
  height: 400px;
}

/* No data overlay */
.no-data-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 12, 21, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  z-index: 100;
}

.no-data-overlay.hidden {
  display: none !important;
}

.no-data-text {
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1.5rem 3rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* Footer Section */
.footer {
  text-align: center;
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-note {
  opacity: 0.6;
  font-size: 0.75rem !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  body {
    padding: 1rem 0.5rem;
  }
  
  .header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.25rem;
  }

  .header-right {
    text-align: left;
  }

  .title {
    font-size: 1.8rem;
  }

  .main-content {
    padding: 1.25rem;
  }

  .content-header {
    flex-direction: column;
    align-items: stretch;
  }

  .tabs-container {
    justify-content: space-around;
  }

  .archive-picker-container {
    justify-content: space-between;
  }

  .chart-container {
    height: 300px;
  }
}
