/* ---------- Base ---------- */
body {
  font-family: 'Orbitron', Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: #f4f4f4;
  color: #333;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* ---------- Dashboard Grid ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 60px);
}

/* ---------- Panels ---------- */
.panel {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, z-index 0s linear 0.2s;
  overflow: hidden;
  box-sizing: border-box;
}

.panel:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.12);
}

.panel.active {
  /* Grow effect for rotation */
  transition: transform 0.5s ease, z-index 0s;
  z-index: 10; /* stay on top while active */
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: clamp(1rem, 2vw, 1.5rem);
  margin: 0 0 1rem 0;
}

.panel-logo {
  height: 60px;
  width: auto;
  margin-left: 1rem;
}

/* ---------- Dial ---------- */
.dial-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 70%;
  max-width: 260px;
  height: auto;
  aspect-ratio: 1 / 1;
  margin: auto;
  max-height: 60%;
}

.dial-value {
  position: absolute;
  pointer-events: none;
  text-align: center;
}

.power-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--power-value-color, #0072ce);
  font-family: 'Orbitron', sans-serif;
  font-weight: var(--power-value-font-weight, bold);
  text-align: center;
  font-size: 20%;
  width: 100%;
}

/* ---------- System Info Panel ---------- */
#systemInfo {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
}

#systemInfo table {
  width: 60%;
  margin-top: 1rem;
  border-collapse: collapse;
  color: #222;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border-radius: 8px;
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
  font-size: clamp(0.8rem, 1.2vw, 1rem);
}

#systemInfo td {
  padding: 0.5rem 0.8rem;
  vertical-align: middle;
  border-bottom: 1px solid #e0e0e0;
}

#systemInfo tr:last-child td {
  border-bottom: none;
}

#systemInfo tr:nth-child(even) {
  background: #f9f9f9;
}

#systemInfo tr:nth-child(odd) {
  background: #fff;
}

#systemInfo td:first-child {
  width: 55%;
  color: #555;
  font-weight: normal;
  text-align: left;
  padding-right: 0.5rem;
}

#systemInfo td:last-child {
  font-weight: bold;
  color: #0072ce;
  text-align: left;
  padding-left: 0.5rem;
}

#systemInfo td span.unit {
  font-weight: normal;
  color: #888;
  margin-left: 0.2rem;
}

/* ---------- Canvas Styling ---------- */
canvas {
  max-width: 100%;
  height: auto;
}

/* ---------- Typography ---------- */
h2 {
  margin: 0 0 1rem 0;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  font-weight: 500;
}

p {
  margin: 0.25rem 0;
  font-size: clamp(0.9rem, 1vw, 1rem);
}

/* ---------- CSS Variables ---------- */
:root {
  --dial-main-color: #f59542;
  --dial-bg-color: #e0e0e0;
  --dial-cutout:70%;
  --chart-line-color: #0072ce;
  --chart-fill-color: rgba(0,114,206,0.2);
  --power-value-color: #0072ce;
  --power-value-font-weight: bold;
}

/* ---------- Rotate Button ---------- */
#rotateButton {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background-color: #0072ce; /* blue when rotation off */
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.6; /* slightly faded */
  z-index: 100;
  transition: background-color 0.3s, opacity 0.3s;
}

#rotateButton.active {
  background-color: grey; /* grey when rotation active */
}

/* ---------- Responsive Design ---------- */

/* Tablets */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
  }

  .panel {
    width: 100%;
    box-sizing: border-box;
    padding: 1rem;
  }

  .dial-container {
    width: 60%;
    max-width: 220px;
    max-height: 55%;
  }

  .power-value {
    font-size: 11%;
  }

  #systemInfo table {
    width: 70%;
  }

  /* Hide rotate button on single column */
  #rotateButton {
    display: none;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 0.8rem;
    height: auto;
    padding: 1rem;
  }

  .panel {
    padding: 1rem;
    width: 100%;
  }

  .panel-title {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    text-align: center;
    justify-content: center;
  }

  .panel-logo {
    height: 40px;
    margin-left: 0.5rem;
  }

  .dial-container {
    width: 55%;
    max-width: 180px;
    max-height: 50%;
  }

  .power-value {
    font-size: 10%;
  }

  #systemInfo table {
    width: 90%;
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
  }

  /* Hide rotate button on mobile */
  #rotateButton {
    display: none;
  }
}

/* Ultra-wide */
@media (min-aspect-ratio: 16/9) {
  .power-value {
    font-size: 13%;
  }
}

/* Short Landscape / Smart Displays */
@media (max-width: 1100px) and (max-height: 650px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.5rem;
    height: 100vh;
  }

  .panel {
    padding: 0.5rem;
    min-height: 0;
    overflow: hidden;
  }

  canvas {
    max-height: 100%;
  }

  .dial-container {
    width: 70%;
    max-height: 50%;
  }

  .power-value {
    font-size: 09%;
  }

  #systemInfo table {
    width: 80%;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
  }
}
