:root {
  --primary-color: #4a6da7; /* Default (used as fallback) */
  --secondary-color: #2e86de;
  --accent-color: #54a0ff;
  --background-color: #f5f9fc;
  --card-background: #ffffff;
  --text-color: #2d3436;
  --text-secondary: #636e72;
  --border-radius: 12px;
  --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  --temperature-color: #f39c12;
  --humidity-color: #3498db;
  --air-quality-color: #9b59b6;
  --success-color: #2ecc71;
  --warning-color: #e74c3c;
}

/* Indoor mode */
.indoor-mode {
  --primary-color: #4a6da7; /* Blue tone for indoor */
  --secondary-color: #2e86de;
  --accent-color: #54a0ff;
}

/* Outdoor mode */
.outdoor-mode {
  --primary-color: #2ecc71; /* Green tone for outdoor */
  --secondary-color: #27ae60;
  --accent-color: #55efc4;
}

/* Dark mode variables */
.dark-mode {
  --primary-color: #2e5c88; /* Adjusted for dark mode indoor */
  --secondary-color: #1b5299;
  --accent-color: #3a7bd5;
  --background-color: #121212;
  --card-background: #1e1e1e;
  --text-color: #ecf0f1;
  --text-secondary: #bdc3c7;
  --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.dark-mode.outdoor-mode {
  --primary-color: #27ae60; /* Dark mode outdoor */
  --secondary-color: #219653;
  --accent-color: #55efc4;
}

#toggle-mode-btn {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.3s ease;
}

#toggle-mode-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.dark-mode #toggle-mode-btn {
  background-color: rgba(255, 255, 255, 0.1);
}

.dark-mode #toggle-mode-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
  padding: 0;
  margin: 0;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  padding: 1.5rem;
  text-align: center;
  position: relative;
  margin-bottom: 2rem;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  box-shadow: var(--box-shadow);
}

.header h1 {
  font-size: 1.8rem;
  margin: 0;
  font-weight: 600;
}

/* Main content container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Dark mode toggle */
.dark-mode-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: white;
  font-size: 1.2rem;
}

.dark-mode-toggle:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* Error message */
#connection-error {
  background-color: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  border-radius: var(--border-radius);
  padding: 1rem;
  margin: 1rem auto;
  text-align: center;
  font-weight: 500;
  max-width: 600px;
  box-shadow: var(--box-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.dark-mode #connection-error {
  background-color: rgba(231, 76, 60, 0.3);
  color: #ff7675;
}

/* Reading cards */
.readings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.reading-card {
  background-color: var(--card-background);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--box-shadow);
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.reading-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
}

.reading-icon {
  font-size: 2rem;
  margin-bottom: 0.8rem;
}

.reading-card.temperature .reading-icon {
  color: var(--temperature-color);
}

.reading-card.humidity .reading-icon {
  color: var(--humidity-color);
}

.reading-card.air-quality .reading-icon {
  color: var(--air-quality-color);
}

.reading-card.hpa .reading-icon {
  color: #2ECC71;
}

.reading-label {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  display: block;
}

.reading-value {
  font-size: 2.5rem;
  font-weight: 700;
  display: block;
  margin-bottom: 0.3rem;
}

.temperature .reading-value {
  color: var(--temperature-color);
}

.humidity .reading-value {
  color: var(--humidity-color);
}

.air-quality .reading-value {
  color: var(--air-quality-color);
}

.hpa .reading-value {
  color: #2ECC71;
}

.units {
  font-size: 1rem;
  color: var(--text-secondary);
}

.update-info {
  text-align: center;
  margin: 1rem 0 2rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Chart sections */
.chart-section {
  margin: 2rem 0;
}

.section-header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.section-icon {
  margin-right: 0.8rem;
  color: var(--accent-color);
}

.chart-container {
  background-color: var(--card-background);
  border-radius: var(--border-radius);
  padding: 1rem;
  box-shadow: var(--box-shadow);
  height: 300px;
  margin-bottom: 1.5rem;
}

/* Solar information */
.solar-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.solar-card {
  background-color: var(--card-background);
  border-radius: var(--border-radius);
  padding: 1.2rem;
  box-shadow: var(--box-shadow);
  text-align: center;
}

.solar-icon {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  color: #f1c40f;
}

.solar-label {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.solar-value {
  font-size: 1.4rem;
  font-weight: 600;
}

/* History section */
.history-section {
  margin: 2rem 0;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.history-box {
  background-color: var(--card-background);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--box-shadow);
}

.history-date {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
}

.history-data {
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.history-range {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
  border-radius: calc(var(--border-radius) / 2);
  background-color: rgba(0, 0, 0, 0.05);
  margin: 0.5rem 0;
}

.dark-mode .history-range {
  background-color: rgba(255, 255, 255, 0.05);
}

#loading-message {
  text-align: center;
  padding: 1rem;
  color: var(--text-secondary);
}

/* Back to top button */
.back-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  opacity: 0.8;
  z-index: 1000;
}

.back-top:hover {
  opacity: 1;
  transform: translateY(-3px);
}

.back-top.hide {
  opacity: 0;
  transform: translateY(100px);
  pointer-events: none;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
  .header h1 {
    font-size: 1.5rem;
  }
  
  .reading-value {
    font-size: 2rem;
  }
  
  .chart-container {
    height: 250px;
  }
  
  .section-header h2 {
    font-size: 1.3rem;
  }
}

@media screen and (max-width: 480px) {
  .header {
    padding: 1rem;
  }
  
  .dark-mode-toggle {
    top: 0.7rem;
    right: 0.7rem;
    width: 35px;
    height: 35px;
  }
  
  .readings-grid {
    grid-template-columns: 1fr;
  }
  
  .reading-card {
    padding: 1.2rem;
  }
  
  .chart-container {
    height: 200px;
    padding: 0.8rem;
  }
  
  .solar-info,
  .history-grid {
    grid-template-columns: 1fr;
  }
}