html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.graphsContainer,
.graphsContainer > div {
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.js-plotly-plot,
.plot-container,
.svg-container {
  max-width: 100% !important;
  overflow-x: hidden !important;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #041f2d 0%, #0a3d4f 100%);

  width: 100%;
  min-height: 100%;
  overflow-y: auto;

  display: flex;
  flex-flow: column;
  align-items: center;

  padding-top: 100px;
  padding-bottom: 180px;
}

.container {
  background: #0f5a7a;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  padding: 40px;
  max-width: 600px;
  width: 100%;
  margin-top: 80px;
}

h1 {
  color: #fff9e6;
  margin-bottom: 10px;
  text-align: center;
}

.control-group {
  margin: 20px 0;
}

.control-group label {
  display: block;
  margin-bottom: 8px;
  color: #fff9e6;
  font-weight: bold;
}

input[type="text"] {
  width: 100%;
  padding: 12px;
  border: 2px solid #ff9a56;
  border-radius: 8px;
  font-size: 14px;
  background: #083d56;
  color: #fff9e6;
  transition: border-color 0.3s;
}

input[type="text"]:focus {
  outline: none;
  border-color: #ff6b35;
}

.btn-send {
  background: #ff6b35;
  color: white;
}

.control-group button {
  width: 100%;
}

.data-display {
  background: #083d56;
  border: 2px solid #ff9a56;
  border-radius: 10px;
  padding: 15px;
  margin: 20px 0;
  min-height: 60px;
  font-family: "Courier New", monospace;
  word-break: break-all;
}

.data-label {
  font-weight: bold;
  color: #ffb88c;
  font-size: 12px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.data-value {
  color: #fff9e6;
  font-size: 14px;
}

/* Rendere il LOG ridimensionabile */
.log {
  position: fixed;
  bottom: 0;
  left: 0;

  width: 100%;
  height: 160px; /* altezza iniziale */
  max-height: 70vh; /* limite superiore */
  min-height: 60px; /* limite inferiore */

  overflow-y: auto;
  overflow-x: hidden;

  background: #0a2d3f;
  color: #fff9e6;
  border-top: 2px solid #ff9a56;

  padding: 12px 18px;
  padding-top: 20px; /* spazio per la maniglia */

  font-family: "Courier New", monospace;
  font-size: 12px;

  box-sizing: border-box;
  z-index: 9999;
}

/* Maniglia di resize */
#log-resize-handle {
  position: absolute;
  top: 0;
  left: 0;

  width: 100%;
  height: 8px;

  cursor: ns-resize;
  background: transparent;
}

/* Effetto visivo sul bordo trascinabile */
#log-resize-handle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: #ff9a56;
  border-radius: 3px;
  opacity: 0.6;
}

.log-entry {
  margin: 3px 0;
  padding: 2px 0;
}

.log-entry.info {
  color: #4ecdc4;
}

.log-entry.success {
  color: #95e1d3;
}

.log-entry.error {
  color: #ff6b5b;
}

.warning {
  background: #1a4d2e;
  border: 1px solid #ff9a56;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #ffb88c;
}

.graphsContainer {
  display: grid;
  gap: 20px;
  width: 100%;
  padding: 20px;

  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "graphBPM object"
    "graphRAW graphFILTERED"
    "graphECO2 graphTVOC";
}

#graphBPM {
  grid-area: graphBPM;
}

#graphECO2 {
  grid-area: graphECO2;
}

#object {
  background: transparent !important;
  grid-area: object;
  width: 100%;
  height: 100%;
  min-height: 300px;
  box-sizing: border-box;
  overflow: hidden;
}

#graphRAW {
  grid-area: graphRAW;
}

#graphFILTERED {
  grid-area: graphFILTERED;
}

#graphTVOC {
  grid-area: graphTVOC;
}

/* 📱 Modalità mobile: layout a UNA colonna */
@media (max-width: 900px) {
  .graphsContainer {
    grid-template-columns: 1fr;
    grid-template-areas:
      "object"
      "graphBPM"
      "graphRAW"
      "graphFILTERED"
      "graphECO2"
      "graphTVOC";
  }
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;

  display: flex;
  justify-content: flex-end; /* elementi allineati verso destra */
  align-items: center;
  gap: 20px;

  background: #0a3d62;
  padding: 12px 20px;
  border-bottom: 2px solid #ff9a56;

  z-index: 9999;
}


.top-bar .status {
  margin: 0; 
  padding: 6px 14px !important;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1; 
  display: flex; 
  align-items: center; 
}


.status.disconnected {
  background: #5d2e2e;
  color: #ff6b5b;
  border: 1px solid #ff6b5b;
}

.status.connected {
  background: #2d5a3d;
  color: #95e1d3;
  border: 1px solid #95e1d3;
}

.btn-connect,
.btn-disconnect {
  width: 140px;
  padding: 10px 0;
  text-align: center;

  background: #0a5f7f;
  color: #fff;
  border: none;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s ease-in-out;
}

.btn {
  padding: 10px 0;
  width: 140px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  transition: 0.2s ease-in-out;
  color: white;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-connect {
  background: linear-gradient(135deg, #ff6b35 0%, #ff9a56 100%);
  color: white;
}

.btn-disconnect {
  background: #ff6b5b;
  color: white;
}

.btn-read {
  background: #4ecdc4;
  color: white;
}

.btn-imu {
  background: #ff9a56;
  color: white;
}

/* Dropdown container */
.dropdown {
  position: relative;
  display: inline-block;
  margin-left: 15px;
}

/* Button dropdown */
.dropdown-btn {
  background-color: #0a5f7f;
  color: white;
  padding: 8px 12px;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  font-size: 14px;
}

.dropdown-btn:hover {
  background-color: #ff9a56;
}

/* Content nascosto */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #0a3d62;
  min-width: 160px;
  padding: 10px;
  border-radius: 6px;
  box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  color: white;
  font-size: 14px;
}

/* Mostra dropdown */
.dropdown:hover .dropdown-content {
  display: block;
}

#data-indicators {
  position: relative;
  margin-right: auto;
}

.status-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin: 0 2px;
  border-radius: 50%;
  background-color: red;
  animation: none;
  font-size: 0.7rem;
  position: relative;
}

.status-indicator.active {
  background-color: green;
  animation: blink 1s infinite;
}

.status-indicator:hover::after {
  content: attr(title);
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: #fff;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
