/* --- General Layout & Typography --- */
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: #f5f6fa;
  color: #1f1f1f;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  align-items: center;
}

.container {
  max-width: 1200px;
  width: 100%;
  padding: 20px 40px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  flex: 1;
}

header {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0; /* For GSAP animation */
}

header img {
  height: 50px;
}

#status {
  color: #6c6c6c;
  font-weight: 500;
  min-height: 20px;
  text-align: center;
  opacity: 0; /* For GSAP animation */
  margin-top: 15px; /* Add this line for spacing */
}

/* --- Main Content Containers --- */
.main-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  flex-wrap: wrap;
  width: 100%;
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 25px;
  flex: 1 1 400px;
  opacity: 0; /* For GSAP animation */
}

.chart-container {
  flex: 1 1 450px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  opacity: 0; /* For GSAP animation */
  align-items: center; /* Add this line */
}

/* --- Cards & Widgets --- */
.meter-card,
.info-box,
.chart-wrapper,
#history-table {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.07);
}

.meter-card {
  padding: 15px;
  text-align: center;
}

.meter-card h4 {
  margin-top: 0;
  margin-bottom: 5px;
  font-size: 1em;
  color: #6c6c6c;
  font-weight: 500;
}

.meter-card .value {
  font-size: 2.2em;
  font-weight: 700;
  color: #1f1f1f;
}

#dl-gauge,
#ul-gauge {
  width: 100%;
  height: 180px;
}

.info-box {
  padding: 20px 25px; /* Increased padding */
  font-size: 0.9em;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px; /* Increased gap */
  width: 100%;
  box-sizing: border-box;
}

.info-box span {
  font-weight: 500;
  color: #6c6c6c;
}

.info-box .info-value {
  color: #1f1f1f;
  font-weight: 600;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 220px;
  padding: 20px; /* Increased padding */
  box-sizing: border-box;
}

/* --- Interactive Elements --- */
#startBtn {
  padding: 14px 40px;
  font-size: 1.2em;
  font-weight: 600;
  background: #730094;
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: block;
  transition: all 0.3s ease;
  margin-top: 20px;
  box-shadow: 0 5px 15px rgba(115, 0, 148, 0.3);
  opacity: 0; /* For GSAP animation */
}

#startBtn:hover:not(:disabled) {
  background: #8f00ba;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(143, 0, 186, 0.4);
}

#startBtn:disabled {
  background: #ccc;
  cursor: not-allowed;
  box-shadow: none;
}

/* --- History Section --- */
.history-container {
  width: 100%;
  max-width: 900px;
  margin-top: 30px;
  opacity: 0; /* For GSAP animation */
}

.history-container h3 {
  text-align: center;
  font-weight: 600;
}

.history-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.history-actions button {
  padding: 6px 12px;
  font-size: 0.8em;
  background: #e0e0e0;
  color: #333;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.history-actions button:hover {
  background: #d0d0d0;
}

#history-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  font-size: 0.9em;
  table-layout: fixed;
}

#history-table th,
#history-table td {
  padding: 14px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#history-table th {
  background-color: #f9f9fb;
  font-weight: 600;
  color: #333;
}

/* --- Footer --- */
footer {
  text-align: center;
  padding: 15px;
  font-size: 0.85em;
  color: #6c6c6c;
}

/* --- Interactive Elements --- */

/* ... existing #startBtn styles ... */

/* --- Modal Styles --- */
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1000; /* Sit on top */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto; /* Enable scroll if needed */
  background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.modal-content {
  background-color: #fefefe;
  margin: 10% auto; /* 10% from the top and centered */
  padding: 25px 30px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 80%;
  max-width: 900px;
  position: relative;
  animation: slide-down 0.4s ease-out;
}

@keyframes slide-down {
  from { transform: translateY(-30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.close-btn {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  line-height: 1;
}

.close-btn:hover,
.close-btn:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

.modal-table-container {
  max-height: 50vh; /* Limit height and allow scrolling */
  overflow-y: auto;
  margin-top: 15px;
}

/* Style for the new history button in the footer */
.link-button {
  background: none;
  border: none;
  color: #730094;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.9em;
  padding: 5px;
  margin-bottom: 10px;
}
.link-button:hover {
  color: #5a0075;
}
footer p {
  margin: 0;
}