@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@300;400;500;600;700;800&display=swap');

/* ═══════════════════════════════════════════════════════════════
   Smart AirNet
   Space Grotesk + JetBrains Mono | Emerald/Teal Accent (#00BFA5)
 ═══════════════════════════════════════════════════════════════ */

@tailwind base;
@tailwind components;
@tailwind utilities;

/* ── Design Tokens ── */
:root {
  --bg-main:        #f1f5f9;
  --bg-surface:     #ffffff;
  --bg-surface-2:   #f8fafc;
  --bg-card:        #ffffff;
  --bg-card-hover:  #ffffff;

  --border-color:   #e2e8f0;
  --border-light:   #f1f5f9;
  --border-active:  #00bfa5;

  --text-main:      #0f172a;
  --text-secondary: #475569;
  --text-muted:     #64748b;
  --text-on-dark:   #ffffff;

  --primary:        #00bfa5;
  --primary-light:  #00d6b9;
  --primary-dim:    #009688;

  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  --font-sans: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --shadow-sm:   0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md:   0 6px 20px rgba(15, 23, 42, 0.05);
  --shadow-lg:   0 12px 32px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 4px 18px rgba(15, 23, 42, 0.04);
}

/* ── Base Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  width: 100%;
}

body {
  background-color: #f1f5f9;
  color: #0f172a;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  width: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Fluid Media Resets */
img, svg, video, canvas {
  max-width: 100%;
  height: auto;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Custom Light Glassmorphism & Card Utilities ── */
.glass-panel-light {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
}

.card-light {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-2xl);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-light:hover {
  border-color: #cbd5e1;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

/* ── Animations ── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.85; transform: scale(1.02); }
}

.loading-spinner { animation: spin 1s linear infinite; }
.pulse-glow { animation: pulseGlow 3s infinite ease-in-out; }

/* ═══════════════════════════════════════════════════════════════
   Fluid Responsive Layout System
   ═══════════════════════════════════════════════════════════════ */

/* Header */
.app-header {
  padding: 12px clamp(14px, 3vw, 28px);
  width: 100%;
}

.app-header-brand {
  font-size: clamp(17px, 2.5vw, 20px);
}

.app-header-brand-logo {
  width: 38px;
  height: 38px;
}

/* Main container */
.app-main {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(16px, 2.5vw, 28px) clamp(12px, 2.5vw, 28px) 60px;
  box-sizing: border-box;
}

.page-container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Hero layout — responsive fluid flex */
.hero-card-responsive {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(16px, 3vw, 28px);
  width: 100%;
  padding: clamp(20px, 3.5vw, 32px) !important;
}

.hero-left-col {
  flex: 1 1 280px;
  min-width: 0;
  width: 100%;
}

.hero-right-col {
  flex: 0 1 auto;
  width: 260px;
  max-width: 100%;
}

/* AQI number */
.hero-metric-val {
  font-size: clamp(48px, 11vw, 76px) !important;
  line-height: 1 !important;
}

/* Pollutant & Weather Grids — fluid auto-fit */
.grid-pollutants {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: clamp(10px, 1.5vw, 16px);
  width: 100%;
}

.grid-weather {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: clamp(10px, 1.5vw, 16px);
  width: 100%;
}

/* Table wrappers */
.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px;
}

.table-responsive-wrapper::-webkit-scrollbar {
  height: 6px;
}

/* Charts — responsive fluid height */
.chart-responsive {
  height: clamp(220px, 32vw, 300px);
  width: 100%;
}

/* Filter chips */
.filter-chips-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-chips-container::-webkit-scrollbar { display: none; }

/* Nav */
.app-nav-pills {
  overflow-x: auto;
  scrollbar-width: none;
}
.app-nav-pills::-webkit-scrollbar { display: none; }

.app-station-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Section gap */
.section-gap {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2.5vw, 24px);
}

/* Page headings */
.page-heading {
  font-size: clamp(20px, 3vw, 24px);
  font-weight: 700;
  color: #0f172a;
}

.page-subheading {
  font-size: 13px;
  color: #64748b;
  margin-top: 4px;
}














.overview-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  width: 100%;
}

.overview-core-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 16px 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.overview-bar-scale {
  display: none;
}

/* ── Mobile Layout Adaptations (< 768px) ── */
@media (max-width: 767px) {
  /* ─ Mobile Charts Grid Override ─ */
  .mobile-chart-grid {
    grid-template-columns: 1fr !important;
  }
  /* 1. Global Spacing & App Shell */
  html, body {
    font-size: 13px !important;
  }

  .app-header {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px !important;
    min-height: calc(52px + env(safe-area-inset-top, 0px)) !important;
  }

  .app-header .app-header-brand-icon {
    width: 28px !important;
    height: 28px !important;
  }

  .app-header .app-header-title {
    font-size: 15px !important;
  }

  .app-header .app-header-subtitle {
    font-size: 8.5px !important;
  }

  .app-main {
    padding: 8px 10px calc(80px + env(safe-area-inset-bottom, 20px)) !important;
    max-width: 100vw !important;
  }

  .page-container {
    padding: 2px 2px 24px !important;
  }

  .section-gap {
    gap: 10px !important;
  }

  /* 2. Headings & Typography */
  h1 {
    font-size: 17px !important;
    letter-spacing: -0.01em !important;
    line-height: 1.25 !important;
  }

  h2 {
    font-size: 14.5px !important;
    line-height: 1.25 !important;
  }

  h3 {
    font-size: 13px !important;
    line-height: 1.25 !important;
  }

  .page-heading {
    font-size: 17px !important;
  }

  .page-subheading {
    font-size: 10.5px !important;
    line-height: 1.35 !important;
  }

  /* 3. Sub-tab Switcher Pills */
  .subtab-pill-container {
    padding: 3px !important;
    gap: 4px !important;
    width: 100% !important;
    display: flex !important;
  }

  .subtab-pill-btn {
    flex: 1 !important;
    padding: 7px 8px !important;
    font-size: 12px !important;
    gap: 5px !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  .subtab-pill-btn svg {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0 !important;
  }

  .desktop-only-inline {
    display: none !important;
  }

  .mobile-only-inline {
    display: inline !important;
  }

  /* 4. Hero Card & Main AQI / Weather Score */
  .hero-card-responsive {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 14px 14px !important;
    border-radius: 16px !important;
    gap: 10px !important;
  }

  .hero-left-col {
    width: 100% !important;
    flex: none !important;
  }

  .hero-metric-container {
    flex-direction: row !important;
    align-items: center !important;
    gap: 14px !important;
    margin-bottom: 10px !important;
    flex-wrap: nowrap !important;
  }

  .hero-metric-val {
    font-size: 50px !important;
    line-height: 1 !important;
  }

  .hero-score-badge {
    padding: 3px 10px !important;
    font-size: 12px !important;
    border-radius: 999px !important;
  }

  .hero-temp-icon {
    font-size: 30px !important;
  }

  .hero-right-col {
    width: 100% !important;
    padding: 12px 14px !important;
    border-radius: 14px !important;
    margin-top: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  /* 5. Scale Bar inside Hero Card */
  .hero-scale-bar-track {
    height: 8px !important;
  }

  .hero-scale-bar-indicator {
    width: 14px !important;
    height: 14px !important;
  }

  /* 6. Pollutant & Weather Card Grids */
  .overview-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .grid-pollutants {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* Last card full-width if odd total (5 pollutants) */
  .grid-pollutants > *:nth-child(5) {
    grid-column: span 2 !important;
  }

  .grid-weather {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .sensor-card-mobile {
    padding: 10px 10px !important;
    border-radius: 14px !important;
    gap: 8px !important;
  }

  .sensor-card-val-mobile {
    font-size: 20px !important;
  }

  
  

  

  

  

  

  

  

  

  

  

  

  

  

  /* 8. Compact Cards in General */
  .mobile-card-compact {
    padding: 12px 12px !important;
    border-radius: 14px !important;
    margin-bottom: 12px !important;
  }

  /* Touch target & interaction polish */
  button, a, input, select {
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
  }

  /* Filter chips horizontal scroll strip on mobile */
  .filter-chips-container {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding: 3px 2px !important;
    gap: 6px !important;
    width: 100% !important;
  }
  .filter-chips-container::-webkit-scrollbar {
    display: none !important;
  }
  .filter-chips-container > * {
    flex-shrink: 0 !important;
  }

  
  .mobile-stats-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
  }
  .mobile-stats-grid > div {
    padding: 8px 10px !important;
    font-size: 11px !important;
    border-radius: 10px !important;
    display: flex !important;
    flex-direction: column !important;
    justifyContent: center !important;
  }

  /* Ultra compact 3-column stats grid */
  .mobile-stats-grid-compact {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
  }
  .mobile-stats-grid-compact > div {
    padding: 6px 4px !important;
    font-size: 10px !important;
    border-radius: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
  }

  /* Date inputs on mobile */
  input[type="date"] {
    font-size: 12.5px !important;
    padding: 6px 10px 6px 32px !important;
    border-radius: 10px !important;
    height: 38px !important;
    max-width: 100% !important;
  }

  /* 9. Charts on Mobile */
  .chart-responsive {
    height: 175px !important;
  }

  /* Charts two-up grid → single column on mobile */
  .mobile-chart-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Utility to stack items strictly on mobile */
  .mobile-stack {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  /* 10. Data Tables — compact, always horizontally scrollable */
  .table-responsive-wrapper {
    border-radius: 12px !important;
  }

  .table-responsive-wrapper table {
    font-size: 10px !important;
    min-width: max-content !important;
  }

  .table-responsive-wrapper th,
  .table-responsive-wrapper td {
    padding: 5px 6px !important;
    white-space: nowrap !important;
  }

  .mobile-hide {
    display: none !important;
  }

  /* 11. Modal Dialogs */
  .pollutant-modal-content {
    width: 94vw !important;
    max-width: 94vw !important;
    max-height: 88vh !important;
    padding: 16px 14px !important;
    border-radius: 18px !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .pollutant-modal-close-btn {
    top: 12px !important;
    right: 12px !important;
    width: 32px !important;
    height: 32px !important;
  }

  .desktop-only-nav {
    display: none !important;
  }

  .mobile-only-header {
    display: flex !important;
  }

  @media (max-width: 420px) {
    .mobile-live-badge span:last-child {
      display: none !important;
    }
    .mobile-live-badge {
      padding: 6px !important;
    }
  }

  /* 12. Native Mobile Bottom Navigation Bar */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(56px + env(safe-area-inset-bottom, 20px)) !important;
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(24px) saturate(1.2) !important;
    -webkit-backdrop-filter: blur(24px) saturate(1.2) !important;
    border-top: 1px solid rgba(226, 232, 240, 0.6) !important;
    align-items: flex-start !important;
    justify-content: space-around !important;
    z-index: 100 !important;
    box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.04) !important;
    padding: 6px 8px env(safe-area-inset-bottom, 20px) !important;
  }

  .mobile-bottom-nav-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    height: 100% !important;
    border: none !important;
    background: transparent !important;
    color: #64748b !important;
    cursor: pointer !important;
    padding: 3px 0 !important;
    gap: 3px !important;
    position: relative !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: color 0.15s ease !important;
  }

  .mobile-bottom-nav-item.active {
    color: #00bfa5 !important;
    font-weight: 700 !important;
  }

  .mobile-bottom-nav-icon-wrap {
    position: relative !important;
    width: 26px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .mobile-bottom-nav-icon {
    width: 20px !important;
    height: 20px !important;
    transition: transform 0.15s ease !important;
  }

  .mobile-bottom-nav-item.active .mobile-bottom-nav-icon {
    transform: scale(1.12) !important;
    color: #00bfa5 !important;
  }

  .mobile-bottom-nav-label {
    font-size: 10.5px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    line-height: 1 !important;
  }

  .mobile-bottom-nav-indicator {
    position: absolute !important;
    bottom: -2px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 14px !important;
    height: 3px !important;
    border-radius: 999px !important;
    background-color: #00bfa5 !important;
    box-shadow: 0 1px 6px rgba(0, 191, 165, 0.45) !important;
  }

  .hero-metric-unit {
    font-size: 18px !important;
  }

  

  /* Extra compact mobile phones (<= 480px) */
  @media (max-width: 480px) {
    .hero-metric-val {
      font-size: 44px !important;
    }
    .hero-score-badge {
      font-size: 12px !important;
      padding: 4px 10px !important;
    }
    .subtab-pill-btn {
      font-size: 11px !important;
      padding: 6px 6px !important;
    }
    .mobile-stats-grid {
      grid-template-columns: 1fr 1fr !important;
      gap: 5px !important;
    }
    .mobile-stats-grid > div {
      padding: 6px 8px !important;
      font-size: 10.5px !important;
    }
    .chart-responsive {
      height: 155px !important;
    }
    .sensor-card-val-mobile {
      font-size: 17px !important;
    }
    .grid-pollutants {
      gap: 6px !important;
    }
    .sensor-card-mobile {
      padding: 8px 9px !important;
      gap: 6px !important;
    }
  }
}

@media (min-width: 768px) {
  .desktop-only-nav {
    display: flex !important;
  }

  .mobile-only-header {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: none !important;
  }

  .desktop-only-inline {
    display: inline !important;
  }

  .mobile-only-inline {
    display: none !important;
  }
}

/* ── Smartboards & 4K (≥ 1920px) ── */
@media (min-width: 1920px) {
  .app-main {
    max-width: 1840px !important;
    padding: 36px 40px 80px !important;
  }

  .page-container {
    max-width: 1840px !important;
  }

  .hero-metric-val {
    font-size: 96px !important;
  }

  .grid-pollutants {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 20px !important;
  }

  .grid-weather {
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 20px !important;
  }

  .chart-responsive {
    height: 340px;
  }
}

/* Overview Dashboard Specific Layouts */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
}

.overview-core-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (max-width: 767px) {
  .overview-page-root {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 4px !important;
  }
  
  .overview-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .overview-core-card {
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    background: #ffffff;
    border: 1px solid #e2e8f0;
  }
}

/* DataRequestModal Mobile Overrides */
.data-request-modal {
  width: 100%;
  max-width: 700px;
  background: #ffffff;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  font-family: var(--font-sans);
}

.data-request-modal-header {
  padding: 28px 24px;
  background: linear-gradient(to right, #0f172a, #1e293b);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  color: #ffffff;
}

.data-request-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.data-request-buttons {
  display: flex;
  gap: 16px;
}

@media (max-width: 600px) {
  .data-request-modal {
    border-radius: 16px;
    max-height: 95vh;
  }
  .data-request-modal-header {
    padding: 20px 16px;
  }
  .data-request-modal-body {
    padding: 16px;
  }
  .data-request-buttons {
    flex-direction: column;
    gap: 12px;
  }
}

/* Responsive adjustments for the top header to prevent mobile overflow */
@media (max-width: 850px) {
  .global-location-badge {
    display: none !important;
  }
}
