:root {
  --primary: #1976d2;
  --secondary: #42a5f5;
  --accent: #90caf9;
  --dark: #0d47a1;
  --light: #e3f2fd;
  --shadow: rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #f9f9f9;
  color: #333;
  line-height: 1.6;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header Styles */
header {
  background: linear-gradient(135deg, var(--primary), var(--dark));
  color: white;
  padding: 1.5rem 0;
  box-shadow: 0 2px 15px var(--shadow);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
}

.logo i {
  font-size: 2.5rem;
  margin-right: 15px;
  color: var(--accent);
}

.logo h1 {
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

/* Main Content */
.dashboard {
  padding: 2rem 0;
}

.dashboard-header {
  margin-bottom: 2.5rem;
  text-align: center;
  background: linear-gradient(135deg, var(--light), #ffffff);
  padding: 2.5rem;
  border-radius: 15px;
  box-shadow: 0 5px 15px var(--shadow);
  border-left: 5px solid var(--accent);
}

.dashboard-header h2 {
  color: var(--dark);
  font-size: 2.4rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.dashboard-header p {
  color: #555;
  font-size: 1.2rem;
}

/* Status Cards */
.status-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.status-card {
  background: linear-gradient(135deg, white, var(--light));
  border-radius: 15px;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 5px 15px var(--shadow);
  transition: all 0.3s ease;
  border-bottom: 4px solid var(--primary);
}

.status-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.status-card i {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1.2rem;
  background: rgba(46, 125, 50, 0.1);
  width: 70px;
  height: 70px;
  line-height: 70px;
  border-radius: 50%;
}

.status-card h3 {
  font-size: 1.3rem;
  color: #444;
  margin-bottom: 0.8rem;
  font-weight: 600;
}

.status-card .value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--dark);
  text-shadow: 1px 1px 1px rgba(0,0,0,0.05);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 2rem;
}

.chart-container {
  background-color: white;
  border-radius: 15px;
  padding: 2rem;
  box-shadow: 0 5px 15px var(--shadow);
  transition: transform 0.3s ease;
  border-top: 4px solid var(--secondary);
}

.chart-container:hover {
  transform: translateY(-5px);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f0f0f0;
}

.chart-header h3 {
  color: var(--dark);
  font-size: 1.4rem;
  font-weight: 600;
}

/* Chart Controls */
.chart-controls {
  display: flex;
  gap: 0.5rem;
}

.chart-header button {
  background: var(--light);
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.5rem;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  transition: all 0.2s ease;
}

.chart-header button:hover {
  background-color: var(--primary);
  color: white;
}

.chart-content {
  width: 100%;
  height: 320px;
  border-radius: 10px;
  overflow: hidden;
}

/* Footer */
footer {
  background: var(--dark);
  color: white;
  padding: 3rem 0;
  margin-top: 4rem;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 3rem;
}

.footer-column h3 {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  color: var(--light);
  position: relative;
  padding-bottom: 0.5rem;
}

.footer-column h3:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 50px;
  height: 2px;
  background: var(--accent);
}

.footer-column p {
  margin-bottom: 1rem;
}

.footer-bottom {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 10001; /* Higher than fullscreen charts */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background-color: white;
  margin: 5% auto;
  padding: 0;
  border-radius: 15px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

.modal-header {
  background: linear-gradient(135deg, var(--primary), var(--dark));
  color: white;
  padding: 1.5rem;
  border-radius: 15px 15px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.close {
  font-size: 2rem;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.close:hover {
  opacity: 0.7;
}

.modal-body {
  padding: 2rem;
  max-height: 60vh;
  overflow-y: auto;
}

.config-section {
  margin-bottom: 1.5rem;
}

.config-section label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--dark);
}

.config-section select,
.config-section input[type="color"],
.config-section input[type="range"] {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.config-section select:focus,
.config-section input:focus {
  outline: none;
  border-color: var(--primary);
}

.config-section input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
  transform: scale(1.2);
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--dark);
}

.btn-secondary {
  background-color: #f5f5f5;
  color: #666;
}

.btn-secondary:hover {
  background-color: #e0e0e0;
}

/* Alert Styles */
.alert-container {
  margin-bottom: 2rem;
}

.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  border-left: 4px solid;
}

.alert-warning {
  background-color: #fff3cd;
  border-color: #ffc107;
  color: #856404;
}

/* Control Panel */
.control-panel {
  background: white;
  border-radius: 15px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 5px 15px var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.control-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-control {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.btn-control:hover {
  background: var(--dark);
  transform: translateY(-2px);
}

.last-update {
  color: #666;
  font-size: 0.9rem;
}

/* Statistics Panel */
.stats-panel {
  background: white;
  border-radius: 15px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 5px 15px var(--shadow);
  border-top: 4px solid var(--accent);
}

.stats-panel h3 {
  color: var(--dark);
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.stat-item h4 {
  color: var(--primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.stat-values {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-values span {
  color: #555;
}

/* Fullscreen Chart */
.chart-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: white;
  border-radius: 0;
  margin: 0;
  padding: 20px;
  box-shadow: none;
  transition: all 0.3s ease;
}

.chart-container.fullscreen .chart-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f0f0;
}

.chart-container.fullscreen .chart-header h3 {
  font-size: 1.8rem;
}

.chart-container.fullscreen .chart-content {
  height: calc(100vh - 120px) !important;
  width: 100% !important;
  border-radius: 10px;
  overflow: hidden;
}

.chart-container.fullscreen .chart-content iframe {
  width: 100% !important;
  height: 100% !important;
}

/* Ensure modal buttons work in fullscreen */
.chart-container.fullscreen .chart-controls {
  z-index: 10000;
  position: relative;
}

.chart-container.fullscreen .chart-controls button {
  background: var(--primary);
  color: white;
  border: 2px solid white;
}

.chart-container.fullscreen .chart-controls button:hover {
  background: var(--dark);
  transform: scale(1.1);
}

/* Escape hint for fullscreen */
.chart-container.fullscreen::before {
  content: "Press ESC or click outside to exit fullscreen";
  position: absolute;
  top: 10px;
  right: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 12px;
  border-radius: 5px;
  font-size: 0.8rem;
  z-index: 10000;
  opacity: 0;
  animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0; }
  20%, 80% { opacity: 1; }
}

/* Modal Input Styles */
.modal-body input[type="number"] {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
}

/* Responsive Adjustments */
@media screen and (max-width: 768px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .chart-content {
    height: 260px;
  }
  
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .dashboard-header h2 {
    font-size: 2rem;
  }
  
  .status-card {
    padding: 1.5rem;
  }
  
  .control-panel {
    flex-direction: column;
    text-align: center;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}