/* ==========================================================================
   AQMPWS public dashboard — light/dark "information design" theme
   Inspired by Swiss/German/Japanese transit & signage typography:
   strong grid, generous whitespace, restrained color used only for status.
   ========================================================================== */

:root {
  /* Light theme (default) */
  --bg: #EEF2F6;
  --surface: #FFFFFF;
  --surface-alt: #F4F7FA;
  --border: #E1E7ED;
  --text-primary: #16222E;
  --text-secondary: #44586B;
  --text-muted: #748496;
  --accent: #0B5FB0;
  --accent-soft: #E5F0FB;
  --shadow: 0 2px 16px rgba(16, 34, 51, 0.06);
}

[data-theme="dark"] {
  --bg: #0B1420;
  --surface: #15212F;
  --surface-alt: #1B2838;
  --border: #283A4D;
  --text-primary: #F2F6FA;
  --text-secondary: #AEC0D2;
  --text-muted: #7E93A8;
  --accent: #5AB0FF;
  --accent-soft: #1E3349;
  --shadow: 0 2px 20px rgba(0, 0, 0, 0.45);
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: "Noto Sans", "Noto Sans Devanagari", "Segoe UI", "Nirmala UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* Fade transition used during the EN <-> Hindi language switch */
.lang-fade {
  transition: opacity 0.3s ease;
}

.lang-fade.fading {
  opacity: 0;
}

/* ----------------------------- Layout ----------------------------- */

.dashboard {
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

.header,
.footer,
.aqi-card,
.panel {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}

/* ----------------------------- Header ----------------------------- */

.header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px;
}

.logos {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.logo-slot {
  width: clamp(44px, 3.6vw, 64px);
  height: clamp(44px, 3.6vw, 64px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo-fallback {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  font-size: clamp(9px, 0.75vw, 12px);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.title-block {
  flex: 2;
  min-width: 0;
  text-align: center;
}

.title-block h1 {
  font-size: clamp(16px, 1.6vw, 30px);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-block .location {
  margin-top: 4px;
  font-size: clamp(15px, 1.3vw, 22px);
  color: var(--text-secondary);
}

.header-controls {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(12px, 1.6vw, 28px);
}

.lang-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: clamp(11px, 0.9vw, 15px);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.lang-option {
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.lang-option.active {
  background: var(--accent);
  color: var(--surface);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: clamp(13px, 1.05vw, 18px);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #3D9A5E;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3D9A5E;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61, 154, 94, 0.45); }
  50%      { box-shadow: 0 0 0 6px rgba(61, 154, 94, 0); }
}

.live-indicator.offline {
  color: #E0483E;
}

.live-indicator.offline .live-dot {
  background: #E0483E;
  animation: none;
}

.clock {
  font-size: clamp(16px, 1.4vw, 25px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

.theme-toggle {
  width: clamp(34px, 2.6vw, 44px);
  height: clamp(34px, 2.6vw, 44px);
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle .icon {
  width: 55%;
  height: 55%;
}

.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ----------------------------- Main grid ----------------------------- */

.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(280px, 22vw, 400px) minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  gap: 18px;
}

.aqi-card { grid-row: 1 / 3; grid-column: 1; }
.panel-pm { grid-row: 1; grid-column: 2; }
.panel-gases { grid-row: 1; grid-column: 3; }
.panel-weather { grid-row: 2; grid-column: 2 / 4; }

.aqi-card,
.panel {
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.panel-title {
  font-size: clamp(15px, 1.15vw, 19px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.panel-title small {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 6px;
}

/* ----------------------------- AQI gauge card ----------------------------- */

.aqi-card {
  align-items: center;
  text-align: center;
  justify-content: space-evenly;
}

.aqi-card .panel-title {
  align-self: flex-start;
}

.gauge-wrap {
  position: relative;
  width: min(85%, 340px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.gauge {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 14;
}

.gauge-progress {
  fill: none;
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 534.07;
  stroke-dashoffset: 534.07;
  stroke: var(--text-muted);
  transition: stroke-dashoffset 1s ease, stroke 0.6s ease;
}

.gauge-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-value {
  font-size: clamp(58px, 7vw, 118px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.gauge-unit {
  margin-top: 6px;
  font-size: clamp(14px, 1.1vw, 19px);
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--text-muted);
}

/* ----------------------------- Mood face ----------------------------- */

.mood-face {
  width: clamp(56px, 6.5vw, 100px);
  height: clamp(56px, 6.5vw, 100px);
}

.mood-eye {
  fill: var(--mood-color, var(--text-primary));
  transition: fill 0.6s ease;
}

.mood-mouth {
  fill: none;
  stroke: var(--mood-color, var(--text-primary));
  stroke-width: 5;
  stroke-linecap: round;
  transition: d 0.6s ease, stroke 0.6s ease;
}

.mood-brows {
  stroke: var(--mood-color, var(--text-primary));
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0;
  transition: stroke 0.6s ease, opacity 0.4s ease;
}

.mood-brows.visible {
  opacity: 1;
}

.aqi-badge {
  display: inline-block;
  padding: 8px 24px;
  border-radius: 999px;
  font-size: clamp(18px, 1.7vw, 29px);
  font-weight: 800;
  background: var(--surface-alt);
  color: var(--text-secondary);
  margin-bottom: 12px;
  transition: background-color 0.4s ease, color 0.4s ease;
}

.aqi-dominant {
  font-size: clamp(15px, 1.2vw, 19px);
  color: var(--text-secondary);
  min-height: 1.4em;
}

/* ----------------------------- Stat grids ----------------------------- */

.stat-grid {
  flex: 1;
  display: grid;
  gap: clamp(8px, 1.6vh, 14px);
  min-height: 0;
}

.stat-grid-col {
  grid-template-rows: repeat(3, 1fr);
}

.stat-grid-2x2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, 1fr);
}

.stat-grid-weather {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, 1fr);
}

.stat {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-alt);
  border-radius: 14px;
  padding: clamp(10px, 1.2vw, 20px);
  min-height: 68px;
  min-width: 0;
  transition: background-color 0.4s ease;
}

.stat-icon {
  width: clamp(26px, 2.7vw, 41px);
  height: clamp(26px, 2.7vw, 41px);
  color: var(--accent);
  flex-shrink: 0;
}

.stat-formula {
  font-size: clamp(19px, 1.9vw, 29px);
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 2.3em;
}

.stat-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-value {
  font-size: clamp(20px, 4vh, 52px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-label {
  font-size: clamp(13px, 1.05vw, 17px);
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

/* Compass icon (rotating needle over a static ring) */

.compass-icon {
  position: relative;
}

.compass-ring,
.compass-needle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.compass-ring {
  color: var(--border);
}

.compass-needle {
  color: var(--accent);
  transform-origin: 50% 50%;
  transition: transform 0.8s ease;
}

/* ----------------------------- Footer ----------------------------- */

.footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 28px;
}

/* ----------------------------- AQI scale bar ----------------------------- */

.aqi-scale {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.aqi-scale-track {
  position: relative;
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
}

.aqi-scale-seg {
  height: 100%;
}

.aqi-scale-good        { flex: 10; background: #3D9A5E; }
.aqi-scale-satisfactory { flex: 10; background: #A4C639; }
.aqi-scale-moderate    { flex: 20; background: #F2C12E; }
.aqi-scale-poor        { flex: 20; background: #F08A3C; }
.aqi-scale-verypoor    { flex: 20; background: #E0483E; }
.aqi-scale-severe      { flex: 20; background: #A12C3B; }

.aqi-scale-marker {
  position: absolute;
  top: -4px;
  left: 0%;
  width: 4px;
  height: 22px;
  border-radius: 2px;
  background: var(--text-primary);
  box-shadow: 0 0 0 2px var(--surface);
  transform: translateX(-50%);
  transition: left 1s ease;
}

.aqi-scale-labels {
  display: flex;
  font-size: clamp(11px, 0.9vw, 14px);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

.aqi-scale-labels .aqi-scale-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}

/* ----------------------------- Footer meta row ----------------------------- */

.footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.aqi-pill {
  flex-shrink: 0;
  padding: 6px 18px;
  border-radius: 999px;
  font-size: clamp(16px, 1.3vw, 21px);
  font-weight: 800;
  background: var(--surface-alt);
  color: var(--text-secondary);
  transition: background-color 0.4s ease, color 0.4s ease;
}

.footer-advisory {
  font-size: clamp(16px, 1.3vw, 21px);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer-right {
  font-size: clamp(14px, 1.2vw, 19px);
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.footer-right.stale {
  color: #E0483E;
  font-weight: 800;
}

/* ----------------------------- Responsive fallback ----------------------------- */

@media (max-width: 1100px) {
  body { overflow: auto; }

  .dashboard {
    height: auto;
    min-height: 100vh;
  }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .aqi-card,
  .panel-pm,
  .panel-gases,
  .panel-weather {
    grid-row: auto;
    grid-column: auto;
  }

  .gauge-wrap {
    width: min(60vw, 280px);
  }

  .stat-grid-weather {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }

  .title-block { display: none; }
  .header { justify-content: space-between; }
}
