/**
 * AQHI Home Page Styles
 * Design based on custom face/body icon cards
 */

/* Color Variables */
:root {
  /* Background */
  --home-bg-primary: #F8F9FA;
  --home-bg-card: #FFFFFF;

  /* Text */
  --home-text-primary: #1F2937;
  --home-text-secondary: #6B7280;
  --home-text-tertiary: #9CA3AF;

  /* Borders */
  --home-border-subtle: rgba(0, 0, 0, 0.06);

  /* Shadows */
  --home-shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);

  /* AQHI Level Colors */
  --aqhi-green: #28CC2D;
  --aqhi-yellow: #FFE135;
  --aqhi-orange: #FF8C01;
  --aqhi-red: #D82E3F;
}

/* Home Page Container */
#page-home {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background: #FFFFFF;
}

#page-home .content-section {
  max-width: 1600px;
  margin: 0 auto;
  padding: 48px 32px 80px 32px;
}

/* Page Header */
.home-page-header {
  text-align: center;
  margin-bottom: 24px;
}

.home-page-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--home-text-primary);
  margin-bottom: 12px;
}

.home-page-subtitle {
  font-size: 1.125rem;
  color: var(--home-text-secondary);
  max-width: 720px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ========================================
   STATUS BANNER (New: current air status)
   ======================================== */
.home-status-banner {
  max-width: 1200px;
  margin: 0 auto 24px auto;
  border-radius: 14px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--home-text-primary);
  box-shadow: var(--home-shadow-card);
  transition: background-color 0.3s;
}

.status-banner-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-banner-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.status-banner-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.status-banner-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
  margin-bottom: 2px;
}

.status-banner-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
}

.status-banner-value .status-aqhi-number {
  font-size: 2rem;
  margin-right: 4px;
}

.status-banner-right {
  text-align: right;
  font-size: 0.8rem;
  color: var(--home-text-secondary);
  flex-shrink: 0;
}

.status-banner-right .status-timestamp {
  font-weight: 600;
}

/* ========================================
   COMPACT SUMMARY STRIP (15 community pills)
   ======================================== */
.home-summary-grid {
  max-width: 1200px;
  margin: 0 auto 32px auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.summary-tile {
  background: var(--home-bg-primary);
  border-radius: 100px;
  padding: 6px 14px 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.summary-tile:hover {
  transform: translateY(-1px);
  background: #EFF1F3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.summary-tile-value {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.summary-tile-name {
  font-size: 0.78rem;
  color: var(--home-text-primary);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

/* ========================================
   AQHI CARDS GRID
   ======================================== */
#home-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* AQHI Card */
.aqhi-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--home-shadow-card);
  display: grid;
  grid-template-columns: 30% 70%;
  min-height: 280px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.aqhi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Left Panel (Colored with Face Icon) */
.card-left {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  gap: 0;
  overflow: hidden;
  min-width: 0;
}

/* Face Icon */
.face-icon {
  width: 200px;
  height: 200px;
  margin-bottom: 0px;
  flex-shrink: 0;
}

.face-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* AQHI Value Section */
.aqhi-value-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 20px;
  padding-top: 0px;
}

/* AQHI Value */
.aqhi-value {
  font-size: 5rem;
  font-weight: 800;
  color: var(--home-text-primary);
  line-height: 1;
  margin-bottom: 20px;
}

/* Risk Level */
.risk-level {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--home-text-primary);
  margin-bottom: 0;
  letter-spacing: 0.05em;
}

/* Location Info */
.location-info {
  text-align: center;
  margin-bottom: 16px;
  margin-top: auto;
}

.community-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--home-text-primary);
  line-height: 1.3;
  display: inline;
}

.district-name {
  font-size: 1rem;
  color: var(--home-text-primary);
  font-weight: 400;
  display: inline;
  margin-left: 6px;
}

/* Card Timestamp */
.card-timestamp {
  text-align: center;
  margin-bottom: 12px;
  font-size: 0.75rem;
  color: var(--home-text-tertiary);
}

.card-timestamp .material-icons {
  font-size: 0.85rem;
  vertical-align: middle;
  margin-right: 2px;
}

/* ========================================
   POLLUTANTS GRID (with colored dots)
   ======================================== */
.pollutants-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
  max-width: 100%;
}

.pollutant-badge {
  background: white;
  border-radius: 20px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.pollutant-name {
  font-weight: 600;
  color: var(--home-text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 0.75rem;
}

.pollutant-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.pollutant-value-small {
  font-weight: 700;
  color: var(--home-text-secondary);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pollutant-unit-small {
  font-size: 0.6rem;
  color: var(--home-text-tertiary);
  margin-left: 1px;
}

/* ========================================
   RIGHT PANEL (Rebalanced layout)
   ======================================== */
.card-right {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* Health Recommendation Section */
.health-section {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  flex: 1;
}

.body-icon {
  width: 200px;
  height: 200px;
  flex-shrink: 0;
}

.body-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.health-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 16px;
}

.health-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--home-text-primary);
  margin-bottom: 8px;
}

.health-recommendation {
  font-size: 1.125rem;
  color: var(--home-text-secondary);
  line-height: 1.5;
}

/* ========================================
   CHART SECTION (Taller with thresholds)
   ======================================== */
.chart-section {
  margin-top: auto;
}

.chart-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--home-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* Chart Container - Taller */
.sparkline-container {
  position: relative;
  width: 100%;
  height: 160px;
}

.sparkline-svg {
  width: 100%;
  height: 100%;
}

/* Chart threshold labels */
.chart-threshold-label {
  font-size: 0.55rem;
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-weight: 600;
}

/* Chart Interactive Elements */
.chart-data-point {
  cursor: pointer;
  transition: opacity 0.2s;
}

.chart-data-point .hover-circle {
  transition: opacity 0.2s;
}

.chart-data-point:hover .hover-circle {
  opacity: 1 !important;
}

.chart-data-point .dot-circle {
  transition: r 0.2s;
}

.chart-data-point:hover .dot-circle {
  r: 4;
}

/* Chart Time Labels */
.chart-time-label {
  font-size: 0.65rem;
  fill: var(--home-text-tertiary);
  font-family: 'LINE Seed Sans TH', sans-serif;
}

/* Tooltip */
.chart-tooltip {
  position: absolute;
  background: var(--home-bg-card);
  border: 1px solid var(--home-border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  white-space: nowrap;
}

.chart-tooltip.visible {
  opacity: 1;
}

.tooltip-time {
  font-size: 0.75rem;
  color: var(--home-text-secondary);
  margin-bottom: 4px;
}

.tooltip-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--home-text-primary);
}

/* ========================================
   SKELETON LOADING ANIMATION
   ======================================== */
.skeleton-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--home-shadow-card);
  display: grid;
  grid-template-columns: 30% 70%;
  min-height: 280px;
}

.skeleton-left {
  background: #E5E7EB;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.skeleton-right {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skeleton-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
}

.skeleton-line {
  height: 16px;
  border-radius: 8px;
  background: #E5E7EB;
}

.skeleton-line.short {
  width: 40%;
}

.skeleton-line.medium {
  width: 65%;
}

.skeleton-line.long {
  width: 85%;
}

.skeleton-line.full {
  width: 100%;
}

.skeleton-block {
  height: 100px;
  border-radius: 12px;
  background: #E5E7EB;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.skeleton-card .skeleton-circle,
.skeleton-card .skeleton-line,
.skeleton-card .skeleton-block {
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Also pulse the banner/grid skeletons */
.skeleton-banner,
.skeleton-tile {
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-banner {
  max-width: 1200px;
  margin: 0 auto 24px auto;
  height: 80px;
  border-radius: 14px;
  background: #E5E7EB;
}

.skeleton-tile {
  height: 32px;
  width: 140px;
  border-radius: 100px;
  background: #E5E7EB;
}

/* Loading State */
.card-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--home-text-tertiary);
}

/* No Data State */
.chart-no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 140px;
  color: var(--home-text-tertiary);
  font-size: 0.875rem;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet */
@media (max-width: 1024px) {
  .aqhi-card {
    grid-template-columns: 30% 70%;
  }

  .skeleton-card {
    grid-template-columns: 30% 70%;
  }

  .face-icon {
    width: 120px;
    height: 120px;
  }

  .body-icon {
    width: 150px;
    height: 150px;
  }

  .aqhi-value {
    font-size: 3.5rem;
  }

  .home-summary-grid {
    gap: 6px;
  }
}

/* Mobile: Vertical Card Layout */
@media (max-width: 768px) {
  #page-home .content-section {
    padding: 24px 16px 80px 16px;
  }

  .home-page-header {
    margin-bottom: 20px;
  }

  .home-page-title {
    font-size: 1.75rem;
  }

  .home-page-subtitle {
    font-size: 0.95rem;
  }

  /* Status Banner mobile */
  .home-status-banner {
    flex-direction: column;
    text-align: center;
    padding: 16px 20px;
    gap: 8px;
  }

  .status-banner-left {
    justify-content: center;
  }

  .status-banner-right {
    text-align: center;
  }

  /* Summary Grid mobile */
  .home-summary-grid {
    gap: 6px;
    justify-content: flex-start;
  }

  .summary-tile {
    padding: 4px 10px 4px 6px;
    gap: 6px;
  }

  .summary-tile-value {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  .summary-tile-name {
    font-size: 0.7rem;
  }

  /* Vertical card layout */
  .aqhi-card,
  .skeleton-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    min-height: auto;
  }

  /* Top section (colored background with face icon) */
  .card-left {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    gap: 12px;
    text-align: center;
  }

  .face-icon {
    width: 120px;
    height: 120px;
    margin-bottom: 16px;
  }

  .aqhi-value-section {
    margin-bottom: 16px;
    padding-top: 0;
  }

  .aqhi-value {
    font-size: 4rem;
    margin-bottom: 12px;
  }

  .risk-level {
    font-size: 1rem;
    margin-bottom: 16px;
  }

  .location-info {
    text-align: center;
    margin-top: 0;
    margin-bottom: 16px;
  }

  .community-name {
    font-size: 0.95rem;
    display: block;
  }

  .district-name {
    font-size: 0.875rem;
    display: block;
    margin-left: 0;
    margin-top: 4px;
  }

  .pollutants-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
    max-width: 320px;
  }

  .pollutant-badge {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  /* Bottom section (white background with body icon and health info) */
  .card-right {
    padding: 24px 20px;
    background: var(--home-bg-card);
  }

  .health-section {
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
    gap: 20px;
  }

  .body-icon {
    width: 180px;
    height: 180px;
    order: 1;
  }

  .health-text {
    order: 2;
    text-align: center;
    margin-top: 0;
    padding-top: 0;
  }

  .health-title {
    font-size: 1.5rem;
    margin-bottom: 12px;
  }

  .health-recommendation {
    font-size: 1rem;
    line-height: 1.6;
  }

  .chart-section {
    margin-top: 24px;
  }

  .chart-title {
    font-size: 0.7rem;
    margin-bottom: 8px;
  }

  .sparkline-container {
    height: 120px;
  }

  /* Skeleton mobile */
  .skeleton-left {
    padding: 24px;
  }
}

/* Small screens */
@media (max-width: 480px) {
  .summary-tile-name {
    font-size: 0.65rem;
  }
}
