/* Header and App Layout */
.app-header {
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;

  /* GLASS TECH STYLE - UPDATED */
  /* 1. Lower Opacity: Changed from 0.85 to 0.60 so you can see through it */
  background: rgba(15, 23, 42, 0.6);

  /* 2. Add Saturation: This makes the glass look "premium" and clear */
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%); /* Critical for iPhone */

  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);

  /* SAFE AREA FIX */
  padding-top: env(safe-area-inset-top);
  padding-left: 1rem;
  padding-right: 1rem;
  height: calc(70px + env(safe-area-inset-top));

  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Adjust the logo to sit nicely within the content area */
.app-logo {
  height: 32px; /* Slightly smaller for elegance */
  max-width: 150px;
  object-fit: contain;
  display: block;
}

/* Icons in header */
.profile-icon,
.header-icon {
  width: 36px; /* refined size */
  height: 36px;
  object-fit: contain;
  cursor: pointer;
  filter: brightness(0) invert(1);
  opacity: 0.9;
  transition: opacity 0.2s;
}

.profile-icon:hover,
.header-icon:hover {
  opacity: 1;
}

.app-logo {
  height: 40px;
  max-height: 50px;
  max-width: 150px;
  margin: 0 auto;
  display: block;
  object-fit: contain;
}

/* Icons in header */
.profile-icon,
.header-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  cursor: pointer;
  filter: brightness(0) invert(1);
}

/* Position profile and log icons */
#profileMenuButton {
  position: static;
}

#toggleLogButton {
  position: static;
}

/* App Controls */
#appControls {
  display: none;
  width: 100%;
  max-width: 700px;
  padding-bottom: 2rem;
}

/* === PREMIUM GRID STATUS CAPSULE === */
.grid-status-center {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Reduced from 15px to 5px */
  margin-top: 85px;
  margin-bottom: 0; /* Ensure no bottom push */
}

.grid-status-indicator {
  display: flex;
  align-items: center;
  gap: 12px;

  /* Size & Shape */
  font-family: "League Spartan", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 10px 24px;
  border-radius: 50px; /* Perfect Capsule */

  /* GLASS STYLE (Matches Header & Motor Box) */
  background: rgba(30, 41, 59, 0.7); /* See-through Slate */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);

  color: #e2e8f0; /* Soft White Text */
  transition: all 0.3s ease;

  /* Initial Position */
  margin: 0 auto;
}

/* Status Colors & Glows */
.grid-status-indicator.online {
  border-color: rgba(34, 197, 94, 0.3); /* Green Tint Border */
  background: rgba(34, 197, 94, 0.1); /* Subtle Green Tint BG */
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.15);
}

.grid-status-indicator.offline {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.15);
}

.grid-status-indicator.unknown {
  border-color: rgba(234, 179, 8, 0.3);
  background: rgba(234, 179, 8, 0.1);
}

/* The Dot */
.grid-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #64748b; /* Grey default */
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dot Colors with Pulse */
.grid-status-indicator.online .grid-dot {
  background: #22c55e; /* Neon Green */
  box-shadow:
    0 0 0 2px rgba(34, 197, 94, 0.3),
    0 0 15px #22c55e;
  animation: pulseGreen 2s infinite;
}

.grid-status-indicator.offline .grid-dot {
  background: #ef4444; /* Neon Red */
  box-shadow:
    0 0 0 2px rgba(239, 68, 68, 0.3),
    0 0 15px #ef4444;
}

.grid-status-indicator.unknown .grid-dot {
  background: #eab308; /* Yellow */
  box-shadow:
    0 0 0 2px rgba(234, 179, 8, 0.3),
    0 0 15px #eab308;
}

/* Pulse Animation */
@keyframes pulseGreen {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* Sensor panel */
/* === HERO GAUGES (Instrument Style - Labels Inside) === */
.sensor-panel,
#dhtDataDisplay {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;

  width: 100%;
  max-width: 600px;

  /* TIGHTER SPACING: */
  margin: 5px auto 0 auto; /* Removed bottom margin completely */

  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Container for the two gauges */
.gauges-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px; /* Reduced gap slightly for tighter look */
  width: 100%;
}

/* Gauge Card Wrapper */
.gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: auto;
}

/* THE SIZE CONTROL */
.gauge-wrapper {
  position: relative;
  /* Keep big size, we are saving space by moving labels inside */
  width: 160px;
  height: 160px;
}

/* The SVG */
.gauge-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.5));
}

/* Animation */
.gauge-anim {
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Center Text Area */
.gauge-center {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0; /* Removed padding to allow transform positioning */
}

.gauge-value {
  font-family: "League Spartan", sans-serif;
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
  color: #fff;

  /* LIFT UP: Move number higher to make room for label */
  transform: translateY(-10px);
}

.gauge-value small {
  font-size: 0.4em;
  opacity: 0.7;
  margin-left: 2px;
  font-weight: 600;
  transform: translateY(-5px);
  display: inline-block;
}

/* Labels MOVED INSIDE the Gauge */
.gauge-label {
  position: absolute;
  /* Position matches the "bottom curve" inside the gauge */
  top: 62%;
  left: 0;
  width: 100%;
  text-align: center;
  margin: 0;

  font-family: "League Spartan", sans-serif;
  font-size: 0.85rem; /* Slightly smaller for internal fit */
  font-weight: 700;
  letter-spacing: 2px;
  color: #64748b; /* Muted slate */
  text-transform: uppercase;
  pointer-events: none; /* Let clicks pass through */
}

/* TIMESTAMP FIX: Pull it UP */
.sensor-timestamp {
  text-align: center;
  /* Changed from margin-top: 10px to -10px to tuck it under the gauges */
  margin-top: -10px;
  padding-bottom: 5px;
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
  opacity: 0.8;
  z-index: 10; /* Ensure it sits on top if overlaps slightly */
}

/* Loading overlay and spinner */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  text-align: center;
  padding: 1rem;
}

.loading-overlay .spinner {
  margin-top: 1rem;
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-colour);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
