/* =============================================
   Nubi — Diagrama animado del sistema
   ============================================= */

.nubi-diagram-wrap {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-lg);
}

.nubi-diagram-wrap--dark {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.nubi-diagram-host {
  line-height: 0;
  background: linear-gradient(180deg, #f0f8fc 0%, #d4eaf5 100%);
}

.nubi-diagram-host--dark {
  background: #0a1e35;
}

.nubi-diagram {
  width: 100%;
  height: auto;
  display: block;
  min-height: 280px;
}

.nubi-base-image {
  pointer-events: none;
}

/* Bomba giratoria */
.nubi-pump-rotor {
  transform-origin: center;
  transform-box: fill-box;
  transition: opacity 0.4s ease;
}

.nubi-diagram.is-pumping .nubi-pump-rotor {
  animation: nubiPumpSpin 1.2s linear infinite;
}

@keyframes nubiPumpSpin {
  to { transform: rotate(360deg); }
}

/* Flujo de agua en tuberías */
.nubi-flow-dot {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.nubi-diagram.is-pumping .nubi-flow-dot {
  opacity: 1;
}

/* Ondas LoRa */
.nubi-lora-pulse {
  opacity: 0;
  transform-origin: center;
  transform-box: fill-box;
}

.nubi-diagram.is-transmitting .nubi-lora-pulse {
  animation: nubiLoraPulse 1.8s ease-out infinite;
}

.nubi-diagram.is-transmitting .nubi-lora-pulse:nth-child(2) { animation-delay: 0.45s; }
.nubi-diagram.is-transmitting .nubi-lora-pulse:nth-child(3) { animation-delay: 0.9s; }

.nubi-lora-path {
  opacity: 0.35;
  transition: opacity 0.5s ease;
}

.nubi-diagram.is-transmitting .nubi-lora-path {
  opacity: 1;
}

.nubi-diagram.is-transmitting .nubi-lora-pulse {
  animation: nubiLoraPulse 1.6s ease-out infinite;
}

.nubi-diagram.is-transmitting .nubi-lora-pulse:nth-child(2) {
  animation-delay: 0.5s;
}

.nubi-lora-label {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.nubi-diagram.is-transmitting .nubi-lora-label {
  opacity: 1;
}

.nubi-telegram-pop,
.nubi-alert-badge {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.nubi-diagram.is-notifying .nubi-telegram-pop {
  opacity: 1;
  transform: translateY(0);
}

.nubi-diagram.is-alert .nubi-alert-badge {
  opacity: 1;
  transform: translateY(0);
}

.nubi-diagram.is-pumping .nubi-pump-ring {
  opacity: 0.75;
  animation: nubiPumpRing 1.4s ease-out infinite;
}

@keyframes nubiPumpRing {
  0%   { transform: scale(0.85); opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0; }
}

@keyframes nubiLoraPulse {
  0%   { opacity: 0.8; transform: scale(0.6); }
  100% { opacity: 0;   transform: scale(2); }
}

/* Agua en tanques */
.nubi-water {
  transition: y 1.8s ease-in-out, height 1.8s ease-in-out;
}

.nubi-gauge-ring {
  transition: stroke-dashoffset 1.8s ease-in-out, stroke 0.4s ease;
}

.nubi-gauge-text,
.nubi-status-text {
  transition: fill 0.4s ease;
}

/* Barra de fase */
.nubi-phase-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--gray-200);
}

.nubi-diagram-wrap--dark .nubi-phase-bar {
  background: rgba(0, 15, 35, 0.82);
  border-top-color: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.nubi-phase-bar__steps {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.nubi-phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-200);
  transition: background 0.3s ease, transform 0.3s ease;
}

.nubi-phase-dot.is-active {
  background: var(--cyan);
  transform: scale(1.25);
}

.nubi-phase-dot.is-done {
  background: var(--green);
}

.nubi-phase-bar__text {
  flex: 1;
  min-width: 0;
}

.nubi-phase-bar__text strong {
  display: block;
  font-size: 0.88rem;
  color: var(--navy);
  margin-bottom: 2px;
}

.nubi-phase-bar__text span {
  font-size: 0.78rem;
  color: var(--gray-600);
}

.nubi-diagram-wrap--dark .nubi-phase-bar__text strong {
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.nubi-diagram-wrap--dark .nubi-phase-bar__text span {
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* Pasos numerados bajo diagrama producto */
.nubi-steps-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 20px 20px;
  background: rgba(255,255,255,0.92);
  border-top: 1px solid var(--gray-200);
}

.nubi-step-chip {
  text-align: center;
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  background: #fff;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
}

.nubi-step-chip.is-active {
  border-color: var(--cyan);
  background: rgba(0, 174, 239, 0.08);
  box-shadow: 0 0 0 1px var(--cyan);
}

.nubi-step-chip__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 800;
  margin-bottom: 6px;
  transition: background 0.3s, color 0.3s;
}

.nubi-step-chip.is-active .nubi-step-chip__num {
  background: var(--cyan);
  color: #fff;
}

.nubi-step-chip p {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--navy-mid);
  line-height: 1.3;
}

/* Tarjetas producto — columna izquierda */
.product-card--illus {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  text-align: left;
}

.product-card--illus:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0, 33, 71, 0.12);
}

.product-card__visual {
  flex: 0 0 100px;
  width: 100px;
  height: auto;
  min-height: 100px;
  background: linear-gradient(180deg, #eef6fb 0%, #d4eaf5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-bottom: none;
  border-right: 1px solid var(--gray-200);
}

.product-card__visual svg {
  width: 100%;
  max-width: 72px;
  height: auto;
}

.product-card__body {
  flex: 1;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.product-card--illus h3 { font-size: 1rem; margin-bottom: 6px; }

.product-card--illus p {
  font-size: 0.85rem;
  margin-bottom: 0;
  line-height: 1.5;
}

/* Proceso: flow cards */
.flow--illus { gap: 16px; margin-bottom: 40px; }

.flow--compact {
  margin-top: 40px;
  opacity: 0.92;
}

.flow-card {
  flex: 1;
  min-width: 200px;
  max-width: 260px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-lg);
  padding: 20px 16px 24px;
  text-align: center;
  transition: transform var(--transition), background var(--transition);
}

.flow-card:hover {
  transform: translateY(-4px);
  background: rgba(255,255,255,0.1);
}

.flow-card__visual {
  height: 100px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-card__visual svg { width: 90px; height: 90px; }

.flow-card__step {
  display: inline-block;
  width: 28px;
  height: 28px;
  background: var(--cyan);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 800;
  border-radius: 50%;
  line-height: 28px;
  margin-bottom: 10px;
}

.flow-card h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; }
.flow-card p { font-size: 0.8rem; opacity: 0.75; line-height: 1.5; }

.section--dark .flow-card {
  background: rgba(0, 18, 40, 0.65);
  border-color: rgba(255, 255, 255, 0.18);
}

.section--dark .flow-card h4 {
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.section--dark .flow-card p {
  color: rgba(255, 255, 255, 0.9);
  opacity: 1;
}

.section--dark .flow-card.is-active {
  background: rgba(0, 174, 239, 0.18);
  border-color: rgba(0, 174, 239, 0.55);
  box-shadow: 0 0 0 1px rgba(0, 174, 239, 0.25);
}

.flow-connector {
  display: flex;
  align-items: center;
  color: var(--cyan);
  opacity: 0.4;
  font-size: 1.25rem;
  padding-top: 40px;
}

.system-diagram-v2 {
  max-width: 960px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .nubi-steps-row { grid-template-columns: repeat(2, 1fr); }
  .nubi-phase-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .flow-connector { display: none; }
  .flow--illus { flex-direction: column; align-items: center; }
  .flow-card { max-width: 100%; width: 100%; }
}
