/* Dashboard Styles */

/* Base Styles */
:root {
  --primary-color: #3498db;
  --secondary-color: #2ecc71;
  --accent-color: #e74c3c;
  --background-color: #f8f9fa;
  --card-background: #ffffff;
  --text-color: #333333;
  --border-color: #e0e0e0;
  --positive-color: #2ecc71;
  --negative-color: #e74c3c;
  --chart-grid-color: #ecf0f1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
  padding: 20px;
}

/* Header Styles */
header {
  margin-bottom: 20px;
}

h1 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-color);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  background-color: var(--card-background);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.control-group {
  display: flex;
  align-items: center;
  margin: 5px 10px;
}

.control-group label {
  margin-right: 10px;
  font-weight: 500;
}

select, button {
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background-color: white;
  font-size: 14px;
}

button {
  cursor: pointer;
  background-color: var(--primary-color);
  color: white;
  border: none;
  transition: background-color 0.2s;
  margin-left: 10px;
}

button:hover {
  background-color: #2980b9;
}

button.paused {
  background-color: var(--accent-color);
}

/* Stats Container */
.stats-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 20px;
}

.stat-box {
  flex: 1;
  min-width: 200px;
  background-color: var(--card-background);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin: 0 10px 10px 0;
  text-align: center;
}

.stat-box:last-child {
  margin-right: 0;
}

.stat-box div:first-child {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 14px;
  color: #666;
}

.positive {
  color: var(--positive-color);
}

.negative {
  color: var(--negative-color);
}

/* Charts Container */
.charts-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.chart-box {
  background-color: var(--card-background);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  width: calc(50% - 10px);
  overflow: hidden; /* Prevent overflow */
  position: relative; /* For proper positioning */
}

.chart-box.full-width {
  width: 100%;
}

.chart-box h2 {
  margin-bottom: 15px;
  font-size: 18px;
  color: var(--text-color);
}

.chart {
  width: 100%;
  height: 300px; /* Fixed height instead of 100% */
  min-height: 200px;
  max-width: 100%; /* Ensure it doesn't exceed container */
  overflow: hidden; /* Prevent chart overflow */
  position: relative;
}

/* Ensure SVG elements inside charts are properly contained */
.chart svg {
  max-width: 100%;
  height: auto;
  overflow: visible; /* Allow SVG content to be visible but contained */
}

/* Footer */
footer {
  text-align: center;
  margin-top: 20px;
  padding: 15px;
  background-color: var(--card-background);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

footer p {
  margin: 5px 0;
  font-size: 14px;
  color: #666;
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--card-background);
  padding: 10px 15px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  font-size: 14px;
}

.status-item {
  display: flex;
  align-items: center;
}

.status-label {
  font-weight: 500;
  margin-right: 5px;
}

.connection-status {
  padding: 3px 8px;
  border-radius: 4px;
  background-color: var(--secondary-color);
  color: white;
  font-weight: 500;
  transition: all 0.3s ease;
}

.connection-status.connected {
  background-color: var(--secondary-color);
  animation: pulse-green 2s infinite;
}

.connection-status.connecting {
  background-color: #f39c12;
  animation: pulse-orange 1s infinite;
}

.connection-status.disconnected {
  background-color: var(--accent-color);
}

.connection-status.simulation {
  background-color: #9b59b6;
  animation: pulse-purple 2s infinite;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes pulse-orange {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes pulse-purple {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* Loading Indicator */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading-spinner {
  border: 5px solid #f3f3f3;
  border-top: 5px solid var(--primary-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 15px;
  font-weight: 500;
}

/* Error Message */
.error-message {
  background-color: #ffebee;
  color: var(--accent-color);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: none;
}

/* No Data Message */
.no-data-message {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  color: #666;
  font-style: italic;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .chart-box {
    width: 100%;
    padding: 10px; /* Reduce padding on mobile */
  }
  
  .chart {
    height: 250px; /* Smaller height on mobile */
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .stats-container {
    flex-direction: column;
  }
  
  .stat-card {
    margin-bottom: 10px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }
  
  .chart {
    height: 200px; /* Even smaller on very small screens */
  }
  
  .chart-box {
    padding: 8px;
  }
}
  
  .control-group {
    margin: 5px 0;
  }
  
  .stat-box {
    width: 100%;
    margin-right: 0;
  }
}