/* ==============================================================================
   WAAT.cl - Portal de Telemetría Energética & SCADA de Clientes
   Módulo CSS: Estilos dedicados para la interfaz del Portal (app.html)
   ============================================================================== */

.portal-header {
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(8px);
  margin-bottom: 2rem;
}

.portal-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.node-badge-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.node-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.node-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.25rem;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.live-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* KPI Dashboard Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: rgba(245, 158, 11, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.kpi-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.kpi-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-icon {
  font-size: 1.25rem;
  opacity: 0.85;
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.kpi-unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kpi-subtext .highlight-amber { color: var(--accent-amber); font-weight: 600; }
.kpi-subtext .highlight-green { color: var(--accent-emerald); font-weight: 600; }
.kpi-subtext .highlight-purple { color: #c084fc; font-weight: 600; }

/* Barra de SOC Batería */
.battery-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.battery-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #34d399);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
  transition: width 0.8s ease;
}

/* Diagrama de Flujo Energético Activo */
.power-flow-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.flow-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flow-diagram-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  align-items: center;
}

@media (max-width: 768px) {
  .flow-diagram-container {
    grid-template-columns: 1fr;
  }
}

.flow-node {
  background: rgba(11, 15, 25, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  position: relative;
}

.flow-node.active-solar { border-color: rgba(245, 158, 11, 0.6); }
.flow-node.active-battery { border-color: rgba(16, 185, 129, 0.6); }
.flow-node.active-grid { border-color: rgba(192, 132, 252, 0.6); }
.flow-node.active-load { border-color: rgba(6, 182, 212, 0.6); }

.flow-node-icon { font-size: 1.8rem; margin-bottom: 0.25rem; }
.flow-node-name { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.flow-node-power { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700; color: var(--text-main); }

/* Contenedores de Gráficos Embebidos Kiosk */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.chart-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(17, 24, 39, 0.4);
}

.chart-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.chart-card-badge {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.chart-frame {
  width: 100%;
  height: 380px;
  border: none;
  background: #0b0f19;
  display: block;
}

/* Acciones y Switcher de Consola */
.portal-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-scada {
  background: rgba(31, 41, 55, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-scada:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}
