/* CSS Variables for consistent theming */
:root {
  /* Base colors - warmer, more sophisticated palette */
  --bg-primary: #1a1a1f;
  --bg-secondary: #242429;
  --bg-card: #2d2d35;
  --bg-card-hover: #353540;

  /* Text colors with better contrast */
  --text-primary: #f7f7f8;
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;

  /* Temperature-based colors */
  --temp-cold: #60a5fa;
  --temp-cool: #3b82f6;
  --temp-neutral: #10b981;
  --temp-warm: #f59e0b;
  --temp-hot: #ef4444;

  /* Action colors - more distinct and accessible */
  --action-open: #10b981;
  --action-closed: #6b7280;
  --action-neutral: #3b82f6;
  --action-outside: #06b6d4;

  /* UI colors */
  --border-subtle: #3f3f46;
  --shadow-color: rgba(0, 0, 0, 0.4);
  --hover-glow: rgba(99, 102, 241, 0.1);

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

h1 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  min-height: 95vh;
  line-height: 1.6;
}

main {
  flex: 1 0 auto;
}

footer {
  flex-shrink: 0;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 50px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 32px;
}

a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--text-primary);
}

.refresh-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

button {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  background-color: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.2s ease;
  min-height: 44px;
  box-shadow: 0 1px 3px var(--shadow-color);
}

button:hover {
  background-color: var(--bg-card-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow-color);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px var(--shadow-color);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

button.refreshing {
  background-color: var(--action-neutral);
  color: white;
  cursor: wait;
}

.last-update {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.timestamp-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auto-refresh-status {
  font-size: 0.875rem;
  color: var(--action-open);
  background-color: rgba(16, 185, 129, 0.1);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-weight: 500;
}

#refreshCountdown {
  font-weight: 600;
  color: var(--action-open);
}

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin: 24px 0;
}

.sensor-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 6px -1px var(--shadow-color);
  transition: all 0.3s ease;
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}

/* Temperature-based gradient backgrounds */
.sensor-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--temp-cool) 0%,
    var(--temp-neutral) 50%,
    var(--temp-warm) 100%
  );
  opacity: 0.8;
}

.sensor-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px -5px var(--shadow-color);
  border-color: rgba(99, 102, 241, 0.3);
  background-color: var(--bg-card-hover);
}

.sensor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.sensor-location {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
}

.sensor-temp {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Temperature color coding */
.temp-cold {
  color: var(--temp-cold) !important;
}
.temp-cool {
  color: var(--temp-cool) !important;
}
.temp-neutral {
  color: var(--temp-neutral) !important;
}
.temp-warm {
  color: var(--temp-warm) !important;
}
.temp-hot {
  color: var(--temp-hot) !important;
}

/* Temperature trend indicators */
.trend-indicator {
  font-size: 1.5rem;
  margin-right: 8px;
  font-weight: normal;
  vertical-align: middle;
}

.trend-rising {
  color: var(--temp-warm);
}

.trend-falling {
  color: var(--temp-cool);
}

.trend-stable {
  color: var(--text-muted);
}

.recommendation-boxes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.recommendation-box {
  text-align: center;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.recommendation-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.recommendation-box:hover::before {
  left: 100%;
}

.recommendation-box:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px -2px var(--shadow-color);
}

.action-box.open {
  background-color: var(--action-open);
  color: white;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.action-box.closed {
  background-color: var(--action-closed);
  color: white;
  box-shadow: 0 2px 4px rgba(107, 114, 128, 0.3);
}

.action-box.outside {
  background-color: var(--action-outside);
  color: white;
  box-shadow: 0 2px 4px rgba(6, 182, 212, 0.3);
}

.action-box.neutral {
  background-color: var(--action-neutral);
  color: white;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.reason-box {
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 400;
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(8px);
}

.outside-card .sensor-header {
  margin-bottom: 0;
}

.error-message {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--temp-hot);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  text-align: center;
  margin: 24px 0;
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-weight: 500;
}

.data-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin: 24px 0;
  padding: 20px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  gap: 20px;
  border: 1px solid var(--border-subtle);
}

#sensorTimestamp,
#refreshTimestamp {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Responsive design */
@media (max-width: 600px) {
  .sensor-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .refresh-controls button {
    width: 100%;
    min-height: 48px;
  }

  .last-update {
    text-align: center;
  }

  .data-info {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .timestamp-info {
    text-align: center;
  }

  .sensor-card {
    padding: 20px;
  }

  .recommendation-box {
    padding: 14px;
    font-size: 1rem;
  }

  footer {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
}

/* Smooth transitions for dynamic content */
* {
  transition:
    color 0.3s ease,
    background-color 0.3s ease;
}
