:root {
  --bg: #0b1220;
  --card: #111827;
  --text: #ffffff;
  --subtext: #9ca3af;
}

.light {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #111827;
  --subtext: #4b5563;
}

body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 0;
  margin: 0;
}

/* Container - center and constrain width */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Status Bar */
.status-bar {
  background: var(--card);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.indicator-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.indicator-dot.live {
  background: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.indicator-dot.stale {
  background: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.indicator-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

#statusText {
  color: var(--subtext);
  font-weight: 500;
}

.last-updated {
  color: var(--subtext);
  font-size: 13px;
}

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

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

button {
  background: #1f2937;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s;
}

button:hover {
  background: #374151;
}

.section {
  margin-top: 20px;
}

.section h2 {
  margin-bottom: 15px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.card h3 {
  margin-top: 0;
}

.sensor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 15px;
}

.sensor-item {
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 6px;
}

.sensor-label {
  font-size: 12px;
  color: var(--subtext);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.sensor-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.sensor-item .value {
  font-size: 28px;
  margin: 0;
}

.value {
  font-size: 40px;
  font-weight: bold;
  margin: 10px 0;
}

.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  margin-top: 10px;
}

.badge.stable {
  background: #065f46;
  color: #10b981;
}

.badge.drying {
  background: #78350f;
  color: #f59e0b;
}

.badge.critical {
  background: #7f1d1d;
  color: #ef4444;
}

.meta {
  margin-top: 10px;
  font-size: 14px;
  color: var(--subtext);
  white-space: pre-line;
}

.forecast-text {
  white-space: pre-wrap;
  margin-bottom: 15px;
}

canvas {
  margin-top: 20px;
  max-width: 100%;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  margin-left: 15px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  background-color: #374151;
  border-radius: 34px;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transition: background-color 0.3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.3s;
}

input:checked + .slider {
  background-color: #10b981;
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Responsive Design */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    width: 100%;
    margin-top: 10px;
  }

  .cards {
    flex-direction: column;
  }
}

/* Auth Section */
.auth-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-container {
  background: var(--card);
  border-radius: 8px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.auth-container h2 {
  text-align: center;
  color: var(--text);
  margin-bottom: 30px;
  font-size: 28px;
}

#authForm, #signupForm {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#authForm input, #signupForm input {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 14px;
}

#authForm input::placeholder, #signupForm input::placeholder {
  color: var(--subtext);
}

#authForm button, #signupForm button {
  padding: 12px;
  border: none;
  border-radius: 4px;
  background: #3b82f6;
  color: white;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

#authForm button:hover, #signupForm button:hover {
  background: #2563eb;
}

#authForm button:disabled, #signupForm button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#authForm button:last-child, #signupForm button:last-child {
  background: #6b7280;
}

#authForm button:last-child:hover, #signupForm button:last-child:hover {
  background: #4b5563;
}

#authForm button:last-child:disabled, #signupForm button:last-child:disabled {
  opacity: 0.6;
}

#authError {
  text-align: center;
  font-size: 14px;
  margin-top: 15px;
}
/* Admin panel input readability */
#adminPanel input[type="text"] {
  background: #1f2937 !important;
  color: #f9fafb !important;
  border: 1px solid #4b5563 !important;
}

#adminPanel input[type="text"]::placeholder {
  color: #d1d5db !important;
}

#adminPanel input[type="text"]:-webkit-autofill,
#adminPanel input[type="text"]:-webkit-autofill:hover,
#adminPanel input[type="text"]:-webkit-autofill:focus {
  -webkit-text-fill-color: #f9fafb;
  -webkit-box-shadow: 0 0 0px 1000px #1f2937 inset;
  transition: background-color 9999s ease-in-out 0s;
}
