body {
  font-family: Arial, sans-serif;
  background-color: white;
  margin: 0;
  padding: 0;
}

.container {
  position: relative;
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.config-link {
  /* inline in header now; no absolute positioning so it stays in the topbar flow */
  padding: 8px 12px;
  background-color: #007bff;
  color: white;
  text-align: center;
  text-decoration: none;
  border-radius: 5px;
  margin-left: 8px;
}

.config-link:hover {
  background-color: #0056b3;
}

.back-link {
  display: inline-block;
  margin-bottom: 20px;
  padding: 10px 20px;
  background-color: #007bff;
  color: white;
  text-align: center;
  text-decoration: none;
  border-radius: 5px;
}

.back-link:hover {
  background-color: #0056b3;
}

button {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 14px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

button:hover {
  background-color: #0056b3;
}

.devices {
  margin-bottom: 20px;
}

#moduleList {
  margin-top: 20px;
}

#messages {
  border: 1px solid #ccc;
  padding: 10px;
  margin-top: 20px;
  max-height: 200px;
  overflow-y: auto;
}

h1 {
  text-align: center;
  color: #333;
}

.module {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background-color: #f7f9fa;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.module h2 {
  margin-top: 0;
}

.device {
  margin-bottom: 10px;
}

/* Layout improvements */
.main-layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 18px 20px 40px 20px;
}

.video-panel {
  min-width: 280px;
  max-width: 360px;
}

#videoElement {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #ddd;
  display: block;
}

.content-panel {
  flex: 1 1 auto;
#eventList, .event-list {
  width: 280px;
  max-height: 200px;
  overflow: auto;
  border-left: 1px solid #eee;
  padding-left: 10px;
  font-size: 13px;
}
.event-list .event-item {
  padding: 6px 4px;
  border-bottom: 1px solid #f1f1f1;
}
.event-list .event-item .time {
  color: #666;
  font-size: 12px;
}

.badge {
  display: inline-block;
  min-width: 20px;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 18px;
  color: #fff;
  background: #ff5722;
  border-radius: 12px;
  text-align: center;
}
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.topbar {
  position: relative;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  flex: 1 1 auto;
  text-align: center;
  margin: 0;
}

.top-controls { display:flex; gap:8px; align-items:center }
.mini { padding:6px 10px; font-size:0.9rem }

/* Logs panel */
.logs-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 320px; /* sit above chart when both open */
  background: #ffffff;
  /* border-top e box-shadow movidos para :not(.collapsed) */
  transition: max-height 0.3s ease, transform 0.25s ease;
  z-index: 1000;
  overflow: hidden;
}
.logs-panel.collapsed {
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  box-shadow: none !important;
}
.logs-panel:not(.collapsed) {
  max-height: 260px;
  border-top: 1px solid #ddd;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.06);
}
.logs-header { display:flex; justify-content:space-between; align-items:center; padding:8px 12px; border-bottom:1px solid #eee }
.logs-body { padding:8px 12px; height:200px; overflow:auto; font-family: monospace; font-size: 0.9rem; background:#fafafa }

/* Chart panel (hidden by default, similar behavior to logs) */
.chart-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  /* border-top e box-shadow movidos para :not(.collapsed) */
  transition: max-height 0.3s ease, transform 0.25s ease;
  z-index: 1000;
  overflow: hidden;
}
.chart-panel.collapsed {
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  box-shadow: none !important;
}
.chart-panel:not(.collapsed) {
  max-height: 320px;
  border-top: 1px solid #ddd;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.06);
}
.chart-header { display:flex; justify-content:space-between; align-items:center; padding:8px 12px; border-bottom:1px solid #eee }
.chart-body { padding:8px 12px; height:300px; overflow:auto; }
.chart-body canvas { width:100% !important; height:240px !important; }

@media (max-width: 760px) {
  .main-layout { flex-direction: column; padding: 12px }
  .video-panel { max-width: 100%; }
  .topbar h1 { font-size: 1.2rem }
}

.device label {
  display: block;
  margin-bottom: 5px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:checked + .slider:before {
  transform: translateX(26px);
}