/* dashboard-layout.css · Layout reorganizado del dashboard con widget de barras */

/* ============================================= */
/*      DASHBOARD MAIN LAYOUT (1 COLUMNA)       */
/* ============================================= */
.dashboard-main-layout {
  display: block;
  margin-bottom: 24px;
}

#section-dashboard {
  position: relative;
}

#section-dashboard.is-loading > :not(.dashboard-loading-overlay) {
  pointer-events: none;
  opacity: 0.4;
  filter: blur(1.6px);
}

.dashboard-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.dashboard-loading-overlay[hidden] {
  display: none !important;
}

.dashboard-loading-card {
  width: min(460px, 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.dashboard-loading-spinner {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 3px solid rgba(59, 130, 246, 0.18);
  border-top-color: var(--primary);
  animation: dashboardSpin 0.8s linear infinite;
}

@keyframes dashboardSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.dashboard-loading-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.dashboard-loading-status {
  font-size: 12px;
  color: var(--muted);
}

.dashboard-loading-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  overflow: hidden;
}

.dashboard-loading-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--chart-blue));
  transition: width 0.18s ease;
}

.dashboard-loading-progress-text {
  align-self: flex-end;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

body.theme-dark .dashboard-loading-overlay {
  background: rgba(0, 0, 0, 0.5);
}

body.theme-dark .dashboard-loading-card {
  box-shadow: none;
  background: var(--surface);
}

/* Columna principal: KPIs + Mini-KPIs */
.dashboard-left-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

/* ============================================= */
/*          KPI GRID COMPACTO                   */
/* ============================================= */
.kpi-grid-compact {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* ============================================= */
/*      FIREWALL WIDGET CARD (Estilo Invertido) */
/* ============================================= */
.firewall-widget-card {
  background: var(--panel);
  height: 100%;
  border-radius: var(--radius-lg);
  padding: 20px;
  color: #000000;
  position: relative;
  border: none;
  box-shadow: 0 6px 18px rgba(16,24,40,.06);
  display: flex;
  flex-direction: column;
}

/* Header del Widget */
.firewall-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.firewall-title {
  font-size: 18px;
  font-weight: 500;
  color: #111111;
  font-family: inherit;
}

.firewall-menu-btn {
  background: #D5D5D5;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  border: none;
  transition: background 0.2s ease;
}

.firewall-menu-btn:hover {
  background: #C5C5C5;
}

.firewall-dot {
  width: 2px;
  height: 2px;
  background: #777777;
  border-radius: 50%;
}

/* ============================================= */
/*          MINI KPIs GRID                       */
/* ============================================= */
.mini-kpis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media(max-width:768px){
  .mini-kpis-grid{
    grid-template-columns: 1fr;
  }

  .mini-kpis-grid .mini-kpi-card:first-child{
    grid-column: 1;
  }

  .mini-kpis-grid .mini-kpi-card:nth-child(2),
  .mini-kpis-grid .mini-kpi-card:nth-child(3){
    grid-column: auto;
  }

  .mini-kpis-grid{
    grid-template-columns: repeat(2, 1fr);
  }

  .mini-kpis-grid .mini-kpi-card:first-child{
    grid-column: 1 / -1;
  }
}

.mini-kpi-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mini-kpi-blue { background: #3B82F6; }
.mini-kpi-green { background: #10B981; }
.mini-kpi-violet { background: #8B5CF6; }

.mini-kpi-blue .mini-kpi-label,
.mini-kpi-blue .mini-kpi-value,
.mini-kpi-green .mini-kpi-label,
.mini-kpi-green .mini-kpi-value,
.mini-kpi-violet .mini-kpi-label,
.mini-kpi-violet .mini-kpi-value {
  color: #FFFFFF;
}

.mini-kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mini-kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mini-kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.mini-chart {
  height: 100px;
  width: 100%;
  position: relative;
}

/* Valor Principal */
.firewall-value {
  font-size: 32px;
  font-weight: 600;
  color: #FFFFFF;
  margin-bottom: 24px;
  letter-spacing: -0.03em;
}

/* Contenedor del Gráfico de Barras */
.firewall-chart-container {
  flex-grow: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 12px;
  gap: 8px;
}

/* Estructura de cada Barra */
.firewall-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  flex: 1;
  position: relative;
  min-width: 0;
}

/* Barra Visual */
.firewall-bar {
  width: 100%;
  border-radius: 6px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 0;
  min-height: 0;
  max-height: 100%;
  opacity: 0;
  will-change: height, opacity;
  overflow: hidden;
}

/* Relleno de la Barra (Gradiente Índigo) */
.firewall-bar-fill {
  width: 100%;
  flex: 1;
  background: linear-gradient(180deg, rgba(98, 126, 234, 0.4) 0%, rgba(26, 46, 80, 1) 100%);
  border-radius: 6px;
  min-height: 0;
}

/* Tapa de la Barra (Blanca) */
.firewall-bar-cap {
  width: 70%;
  height: 4px;
  background: #FFFFFF;
  border-radius: 4px;
  margin-bottom: 6px;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

/* Valor de la Barra (encima) */
.firewall-bar-value {
  margin-bottom: 8px;
  font-size: 32px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1;
  text-align: center;
}

/* Etiqueta del KPI (Eje X) */
.firewall-x-label {
  margin-top: 10px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Badge Flotante (Porcentaje) */
.firewall-badge-float {
  position: absolute;
  top: -36px;
  background: rgba(98, 126, 234, 0.95);
  color: #FFFFFF;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  animation: firewall-floatIn 0.5s ease-out 0.8s forwards;
  white-space: nowrap;
  z-index: 10;
}

.firewall-badge-float::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px 4px 0;
  border-style: solid;
  border-color: rgba(98, 126, 234, 0.95) transparent transparent transparent;
}

/* Animaciones */
@keyframes firewall-growBar {
  from {
    height: 0;
    opacity: 0;
  }
  to {
    height: var(--bar-height);
    opacity: 1;
  }
}

@keyframes firewall-floatIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================= */
/*          RESPONSIVE                          */
/* ============================================= */

/* Tablets grandes (1200px - 1440px) */
@media (max-width: 1440px) {
  .firewall-value {
    font-size: 28px;
  }
  
  .firewall-title {
    font-size: 16px;
  }
  
  .kpi-grid-compact {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Tablets (768px - 1200px) */
@media (max-width: 1200px) {
  .dashboard-main-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .firewall-widget-card {
    min-height: 340px;
  }
  
  .filters-grid-compact {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .kpi-grid-compact {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Móviles (hasta 768px) */
@media (max-width: 768px) {
  .dashboard-main-layout {
    grid-template-columns: 1fr;
  }
  
  .filters-grid-compact {
    grid-template-columns: 1fr;
    gap:8px;
  }
  
  .kpi-grid-compact {
    grid-template-columns: repeat(2, 1fr);
    gap:8px;
  }
  
  .firewall-widget-card {
    min-height: 300px;
    padding: 16px;
  }
  
  .firewall-value {
    font-size: 24px;
    margin-bottom: 16px;
  }
  
  .firewall-bar-value {
    font-size: 24px;
    margin-bottom: 6px;
  }
  
  .firewall-chart-container {
    gap: 6px;
  }
  
  .firewall-x-label {
    font-size: 10px;
  }
}

@media (max-width: 768px) {
  .dashboard-loading-overlay {
    padding: 12px;
  }
}
