/* ====================
   CSS VARIABLES (THEMES)
   ==================== */
:root[data-theme="dark"] {
  --primary-color: #64b5f6;
  --success-color: #81c784;
  --warning-color: #ffb74d;
  --danger-color: #e57373;
  --background-color: #121212;
  --card-color: #1e1e1e;
  --text-color: #e0e0e0;
  --text-light: #b0b0b0;
  --border-color: #2d2d2d;
  --header-bg: #1a1a1a;
  --header-blue: #0d47a1;
}

:root[data-theme="light"] {
  --primary-color: #2196f3;
  --success-color: #4caf50;
  --warning-color: #ff9800;
  --danger-color: #f44336;
  --background-color: #f5f5f5;
  --card-color: #ffffff;
  --text-color: #333333;
  --text-light: #666666;
  --border-color: #e0e0e0;
  --header-bg: #ffffff;
  --header-blue: #1976d2;
}

/* Default to dark theme */
:root {
  --primary-color: #64b5f6;
  --success-color: #81c784;
  --warning-color: #ffb74d;
  --danger-color: #e57373;
  --background-color: #121212;
  --card-color: #1e1e1e;
  --text-color: #e0e0e0;
  --text-light: #b0b0b0;
  --border-color: #2d2d2d;
  --header-bg: #1a1a1a;
  --header-blue: #0d47a1;
}

/* ====================
   RESET & BASE STYLES
   ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ====================
   HEADER SECTION
   ==================== */
header {
  background: var(--header-blue);
  color: white;
  padding: 0;
  border-bottom: none;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-accent {
  width: 4px;
  height: 40px;
  background-color: #42a5f5;
  border-radius: 2px;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
  margin: 0;
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.header-btn {
  background-color: rgba(66, 165, 245, 0.3);
  border: 1px solid rgba(66, 165, 245, 0.5);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s;
}

.header-btn:hover {
  background-color: rgba(66, 165, 245, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.time-btn {
  font-family: "Courier New", monospace;
  letter-spacing: 1px;
}

.moon-btn {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.moon-btn:hover {
  background-color: rgba(66, 165, 245, 0.5);
  transform: scale(1.05);
}

.moon-icon {
  font-size: 1.1rem;
  filter: brightness(1.2);
}

.error-message {
  max-width: 1200px;
  width: 100%;
  margin: 1rem auto;
  padding: 0.75rem;
  background-color: var(--danger-color);
  color: white;
  border-radius: 8px;
  text-align: center;
  display: none;
}

.error-message.show {
  display: block;
}

/* ====================
   LOADING SPINNER
   ==================== */
.loading-spinner {
  text-align: center;
  padding: 2rem;
  grid-column: 1 / -1;
}

.spinner {
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ====================
   DASHBOARD GRID
   ==================== */
.dashboard {
  max-width: 1400px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  row-gap: 2rem;
}

/* ====================
   CARD STYLES
   ==================== */
.card {
  background-color: var(--card-color);
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  transition: border-color 0.2s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card:hover {
  border-color: var(--primary-color);
}

.weather-card,
.air-quality-card,
.info-card,
.charts-card {
  grid-column: span 1;
}

.card h2 {
  color: var(--text-color);
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.card-content {
  min-height: 150px;
}

.placeholder {
  color: var(--text-light);
  text-align: center;
  padding: 2rem 0;
  font-style: normal;
  opacity: 0.7;
}

/* ====================
   WEATHER CARD CONTENT
   ==================== */
.weather-info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.weather-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.weather-item:last-child {
  border-bottom: none;
}

.weather-item .label {
  font-weight: bold;
  color: var(--text-light);
}

.weather-item .value {
  font-size: 1.2rem;
  color: var(--text-color);
}

.temperature {
  font-size: 2.5rem !important;
  color: var(--text-color) !important;
  font-weight: bold;
}

/* ====================
   AIR QUALITY CARD CONTENT
   ==================== */
.air-quality-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.aqi-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.aqi-value {
  font-size: 3rem;
  font-weight: bold;
  color: var(--text-color);
  line-height: 1;
}

.aqi-status {
  font-size: 1rem;
  font-weight: bold;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  white-space: nowrap;
}

/* AQI Status Colors */
.status-good {
  background-color: var(--success-color);
  color: white;
}

.status-moderate {
  background-color: var(--warning-color);
  color: white;
}

.status-unhealthy {
  background-color: var(--danger-color);
  color: white;
}

.pm25-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  min-width: 150px;
  flex-shrink: 0;
  background-color: transparent;
}

.pm25-item .label {
  font-weight: bold;
  color: var(--text-light);
}

.pm25-item .value {
  font-size: 1.2rem;
  color: var(--text-color);
}

/* ====================
   CHART CONTAINER
   ==================== */
.chart-card {
  grid-column: 1 / -1;
  width: 100%;
}

.chart-container {
  position: relative;
  height: 400px;
  margin-top: 1rem;
}

/* ====================
   CHARTS SECTION (NEW)
   ==================== */
/* Info Section (for left side card) */
.info-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  width: 100%;
}

.info-section:first-child {
  margin-top: 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.info-section h3 {
  font-size: 1.1rem;
  color: var(--text-color);
  margin-bottom: 1rem;
  font-weight: 500;
}

/* Pie Charts Section (for right side card) */
.pie-charts-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-top: 1rem;
  width: 100%;
}

.pie-chart-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.pie-chart-wrapper h3 {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  text-align: center;
  font-weight: 500;
}

.chart-container-small {
  position: relative;
  height: 280px;
  width: 100%;
  min-height: 280px;
}

/* Line Charts Container (Separate card between top and bottom) */
.line-charts-card {
  grid-column: 1 / -1;
  width: 100%;
}

.line-charts-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1rem;
  width: 100%;
}

.line-chart-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.line-chart-wrapper h3 {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  text-align: center;
  font-weight: 500;
}

.chart-container-medium {
  position: relative;
  height: 350px;
  width: 100%;
  min-height: 350px;
}

/* ====================
   FOOTER SECTION
   ==================== */
footer {
  background-color: var(--header-bg);
  color: var(--text-light);
  text-align: center;
  padding: 1.5rem;
  margin-top: auto;
  border-top: 1px solid var(--border-color);
}

footer a {
  color: var(--primary-color);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.footer-note {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* ====================
   RESPONSIVE DESIGN
   ==================== */
@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .weather-card,
  .air-quality-card {
    grid-column: span 1;
  }

  .chart-card {
    grid-column: 1;
  }

  .chart-container {
    height: 300px;
  }

  .line-charts-section {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

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

  .chart-container-small {
    height: 250px;
    min-height: 250px;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.5rem;
  }

  .card {
    padding: 1rem;
  }

  .temperature {
    font-size: 2rem !important;
  }

  .aqi-value {
    font-size: 2rem;
  }

  .air-quality-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .aqi-container {
    width: 100%;
    justify-content: flex-start;
  }

  .pm25-item {
    width: 100%;
    min-width: auto;
  }
}
