/* FLUWEIR — dashboard.css · sinóptico / telemetría (SCADA) */

.dash {
  background: radial-gradient(1200px 600px at 70% -10%, rgba(35,176,224,0.14), transparent 55%),
    linear-gradient(170deg, #081F33 0%, #0B3C5D 100%);
  color: var(--blanco);
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
}

.dash .container { max-width: 1320px; }

/* ----- Top bar ----- */
.dash-top {
  display: flex; align-items: center; gap: 18px; padding: 22px 0 6px; flex-wrap: wrap;
}
.dash-top h1 { font-size: 1.35rem; display: flex; align-items: center; gap: 10px; }
.dash-top .live {
  display: inline-flex; align-items: center; gap: 7px; font-size: 0.78rem;
  color: var(--verde); font-weight: 600;
}
.dash-top .live::before {
  content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--verde);
  animation: pulse-dot 1.8s infinite;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(52,199,89,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(52,199,89,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,199,89,0); }
}
.dash-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.dash-actions .btn { font-size: 0.82rem; padding: 8px 14px; }

/* ----- Alarm bar ----- */
.alarm-bar {
  border-radius: 12px; padding: 10px 14px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: rgba(229,72,77,0.14); border: 1px solid rgba(229,72,77,0.4);
}
.alarm-bar.ok { background: rgba(52,199,89,0.12); border-color: rgba(52,199,89,0.4); }
.alarm-bar .bell { font-size: 1.2rem; }
.alarm-bar .msg { font-size: 0.92rem; flex: 1 1 300px; }
.alarm-bar .msg b { color: var(--blanco); }
.alarm-bar .btn-min {
  background: rgba(255,255,255,0.12); color: var(--blanco);
  border: 1px solid rgba(255,255,255,0.25); font-size: 0.82rem; padding: 7px 12px;
  border-radius: 8px; cursor: pointer;
}

/* ----- Legend ----- */
.dash-legend {
  display: flex; gap: 18px; font-size: 0.78rem; color: rgba(255,255,255,0.8);
  padding: 6px 0 14px; flex-wrap: wrap;
}
.dash-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dash-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.i-green { background: var(--verde); } .i-amar { background: var(--amarillo); } .i-red { background: var(--rojo); }

/* ----- Flujo: línea principal ----- */
.flow-main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 16px;
}
@media (max-width: 960px) {
  .flow-main { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

/* ----- Nodo ----- */
.node {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px; padding: 14px 16px; position: relative; cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.node:hover { transform: translateY(-2px); border-color: rgba(35,176,224,0.5); }
.node::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  border-radius: 14px 14px 0 0;
}
.node.s-green::before { background: var(--verde); }
.node.s-yellow::before { background: var(--amarillo); }
.node.s-red::before { background: var(--rojo); }

.node-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.node-head .ni {
  width: 30px; height: 30px; border-radius: 8px; background: rgba(35,176,224,0.16);
  display: grid; place-items: center; font-size: 16px;
}
.node-head .t { font-weight: 700; font-size: 0.88rem; }
.node-head .st {
  margin-left: auto; font-size: 0.68rem; font-weight: 700; border-radius: 6px;
  padding: 2px 7px; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7);
}

.sensor {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-top: 1px dashed rgba(255,255,255,0.09); font-size: 0.85rem;
}
.sensor .k { color: rgba(255,255,255,0.62); font-size: 0.76rem; }
.sensor .v { font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.sensor .v small { font-weight: 600; color: rgba(255,255,255,0.5); font-size: 0.68rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.d-green { background: var(--verde); }
.dot.d-yellow { background: var(--amarillo); }
.dot.d-red { background: var(--rojo); }

/* mini barra de nivel */
.bar {
  height: 6px; border-radius: 6px; background: rgba(255,255,255,0.12);
  overflow: hidden; flex: 1; min-width: 40px; max-width: 54px; margin-left: 8px;
}
.bar > i { display: block; height: 100%; border-radius: 6px; }
.bar .b-green { background: var(--verde); }
.bar .b-yellow { background: var(--amarillo); }
.bar .b-red { background: var(--rojo); }

.autonomy {
  border-top: 1px dashed rgba(255,255,255,0.12); margin-top: 8px; padding-top: 8px;
  font-size: 0.8rem; color: var(--agua-claro); display: flex; align-items: center; gap: 7px;
}

/* ----- Tuberías con agua fluyendo ----- */
.pipe { position: relative; height: 14px; }
.pipe .track { position: absolute; left: 0; right: 0; top: 5px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--agua) 12%, var(--agua) 88%, transparent);
  opacity: 0.55; }
.pipe .drop {
  position: absolute; top: 3px; left: -12px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--agua); box-shadow: 0 0 8px var(--agua);
  animation: flow-x 2.6s linear infinite; opacity: 0.95;
}
.pipe .drop.d2 { animation-delay: -1.3s; opacity: 0.55; width: 5px; height: 5px; top: 4px; }
@keyframes flow-x {
  from { left: -12px; }
  to { left: calc(100% - 4px); }
}
/* tubería vertical (responsive) */
.pipe.v .track { top: 0; left: 5px; right: auto; bottom: 0; width: 2px; height: 100%;
  background: linear-gradient(180deg, transparent, var(--agua) 12%, var(--agua) 88%, transparent); }
.pipe.v .drop { left: 3px; top: -12px; animation: flow-y 2.6s linear infinite; }
.pipe.v .drop.d2 { animation-delay: -1.3s; }
@keyframes flow-y {
  from { top: -12px; }
  to { top: calc(100% - 4px); }
}

/* ----- Secciones del sinóptico ----- */
.stage-label {
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255,255,255,0.45); margin: 26px 0 8px; font-weight: 700;
}
.stage-label::before { content: '—'; margin-right: 8px; color: var(--agua); }

.flow-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
@media (max-width: 960px) { .flow-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } }

/* ----- Panel lateral de detalle ----- */
.side-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 100%; max-width: 430px;
  background: #0B3C5D; color: var(--blanco); z-index: 60;
  transform: translateX(105%); transition: transform 0.28s ease;
  box-shadow: -18px 0 40px rgba(0,0,0,0.4); overflow-y: auto;
}
.side-panel.open { transform: translateX(0); }
.side-panel-head {
  padding: 18px 22px; border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0;
  background: rgba(11,60,93,0.96); backdrop-filter: blur(6px); z-index: 2;
}
.side-panel-head .ni {
  width: 36px; height: 36px; border-radius: 9px; background: rgba(35,176,224,0.18);
  display: grid; place-items: center; font-size: 19px;
}
.side-panel-head .t { font-size: 1.05rem; font-weight: 700; }
.side-panel-head .st { font-size: 0.72rem; font-weight: 700; border-radius: 6px;
  padding: 2px 8px; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.75); }
.side-panel-head .close { margin-left: auto; background: none; border: 0; color: #fff;
  font-size: 1.5rem; cursor: pointer; line-height: 1; }
.sp-body { padding: 18px 22px 34px; }

.sp-sensor { margin-bottom: 18px; }
.sp-sensor .k { display: flex; justify-content: space-between; font-size: 0.78rem; color: rgba(255,255,255,0.6); }
.sp-sensor .sp-v { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.sp-sensor .sp-v small { font-size: 0.9rem; font-weight: 600; color: rgba(255,255,255,0.5); margin-left: 4px; }
.spark { width: 100%; height: 48px; margin-top: 8px; display: block; }

.sp-ctrls h5 {
  font-size: 0.78rem; color: rgba(255,255,255,0.6); margin: 20px 0 8px;
  letter-spacing: 0.05em; text-transform: uppercase; font-weight: 700;
}
.sp-btn { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle {
  flex: 1; min-width: 110px; text-align: center; font-size: 0.8rem; font-weight: 700;
  padding: 10px 8px; border-radius: 8px; background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18); color: var(--blanco); cursor: pointer;
}
.toggle.on { background: var(--agua); color: var(--azul-pro); border-color: var(--agua); }
.toggle.warn.on { background: var(--rojo); border-color: var(--rojo); }

.sp-slider label { font-size: 0.78rem; color: rgba(255,255,255,0.6); display: block; margin: 12px 0 4px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 5px;
  border-radius: 6px; background: rgba(255,255,255,0.2); outline: none; margin: 4px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--agua); cursor: pointer; box-shadow: 0 0 6px var(--agua);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border: 0; border-radius: 50%;
  background: var(--agua); cursor: pointer;
}
.slider-val { display: flex; justify-content: space-between; font-size: 0.78rem; color: rgba(255,255,255,0.7); }

.sp-note { font-size: 0.78rem; color: rgba(255,255,255,0.5); margin-top: 18px; line-height: 1.5; }
.sp-note b { color: rgba(255,255,255,0.8); }

/* ----- Backdrop ----- */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 59;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

/* ----- Responsive del sinóptico ----- */
@media (max-width: 820px) {
  .pipe.h { display: none; }      /* ocultar tuberías horizontales */
  .pipe.v { display: block; }
  .flow-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .flow-grid { grid-template-columns: 1fr; }
}

/* ----- Tabla de sensores en páginas de producto ----- */
.sensor-table td:first-child { font-weight: 600; }
