/* =======================================================
   KPI Section Styles
======================================================= */

/* Contenedor principal de KPI */
#kpi-section .section-content {
  background-color: white;
  padding-top: 90px;
  overflow-y: auto;
}

/* =============== FILTROS =============== */
.kpi-filters {
  display: flex;
  flex-wrap: wrap;
  background-color: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  justify-content: space-between;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  margin: 5px 10px;
}

.filter-group label {
  font-weight: 500;
  margin-right: 10px;
  color: #333;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background-color: white;
  min-width: 160px;
  font-family: var(--font-family);
  color: #333;
  transition: all 0.3s ease;
}

.filter-select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(20, 10, 154, 0.1);
}

.filter-button {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.filter-button i {
  margin-right: 5px;
}

.filter-button:hover {
  background-color: var(--primary-light);
}

.filter-button.secondary {
  background-color: #e0e0e0;
  color: #333;
}

.filter-button.secondary:hover {
  background-color: #d0d0d0;
}

/* =============== CHARTS CONTAINER =============== */
.kpi-charts-container {
  position: relative;
  min-height: 500px;
}

.kpi-charts-page {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

@media (max-width: 1100px) {
  .kpi-charts-page {
    grid-template-columns: 1fr;
  }
}

/* =============== CHART BOX =============== */
.kpi-chart-box {
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}

.kpi-chart-box:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transform: translateY(-5px);
}

.chart-title {
  background-color: #f8f9fa;
  padding: 15px;
  font-weight: 500;
  color: #333;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-title i {
  margin-right: 10px;
  color: var(--primary);
}

.chart-actions {
  display: flex;
  gap: 8px;
}

.chart-action-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  padding: 5px;
  border-radius: 3px;
  transition: all 0.2s ease;
}

.chart-action-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--primary);
}

.chart-container {
  padding: 20px;
  height: 250px;
  position: relative;
}

.chart-footer {
  padding: 12px 15px;
  border-top: 1px solid #eee;
  background-color: #f8f9fa;
  display: flex;
  justify-content: space-around;
}

.chart-kpi {
  text-align: center;
  padding: 0 10px;
}

.kpi-value {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 3px;
}

.kpi-value.up {
  color: #34a853;
}

.kpi-value.down {
  color: #ea4335;
}

.kpi-value.goal {
  color: #4285f4;
}

.kpi-label {
  font-size: 12px;
  color: #666;
}

/* =============== NAVIGATION =============== */
.kpi-nav-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0 20px 0;
  margin-top: 20px;
}

.kpi-nav-button {
  background-color: var(--primary);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 0 10px;
}

.kpi-nav-button:hover {
  background-color: var(--primary-light);
  transform: scale(1.1);
}

.kpi-nav-button.disabled {
  background-color: #ccc;
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

.kpi-page-dots {
  display: flex;
  gap: 8px;
  margin: 0 20px;
}

.kpi-page-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #d0d0d0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.kpi-page-dot.active {
  background-color: var(--primary);
  transform: scale(1.2);
}

.kpi-page-dot:hover {
  background-color: var(--primary-light);
}

/* =============== MODAL =============== */
.kpi-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  animation: fadeIn 0.3s;
  overflow: auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.kpi-modal-content {
  background-color: white;
  margin: 50px auto;
  padding: 20px;
  border-radius: 10px;
  width: 90%;
  max-width: 1200px;
  height: 80%;
  position: relative;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.kpi-modal-close {
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
  transition: color 0.3s;
}

.kpi-modal-close:hover {
  color: var(--primary);
}

.kpi-modal h3 {
  margin-top: 0;
  padding-bottom: 15px;
  margin-bottom: 20px;
  border-bottom: 1px solid #eee;
  color: var(--primary);
}

.kpi-modal-chart-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 10px;
}

/* =============== ANIMACIONES =============== */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@keyframes chartLoad {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

.kpi-chart-box {
  animation: chartLoad 0.6s ease forwards;
}

.kpi-chart-box:nth-child(1) { animation-delay: 0.1s; }
.kpi-chart-box:nth-child(2) { animation-delay: 0.2s; }
.kpi-chart-box:nth-child(3) { animation-delay: 0.3s; }
.kpi-chart-box:nth-child(4) { animation-delay: 0.4s; }

/* Animación para los KPIs que superan la meta */
.kpi-value.up:after {
  content: "↑";
  margin-left: 4px;
  animation: pulse 2s infinite;
}

.kpi-value.down:after {
  content: "↓";
  margin-left: 4px;
  animation: pulse 2s infinite;
}

/* =============== CANVAS FIX =============== */
/* Fix crucial para asegurar que los canvases se muestren correctamente */
.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}

/* =============== RESPONSIVE ADJUSTMENTS =============== */
@media (max-width: 768px) {
  .kpi-filters {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .filter-group {
    width: 100%;
    margin: 5px 0;
  }
  
  .filter-select {
    width: 100%;
  }
  
  .kpi-charts-page {
    grid-template-columns: 1fr;
  }
  
  .chart-footer {
    flex-direction: column;
    align-items: center;
  }
  
  .chart-kpi {
    margin: 5px 0;
  }
}

/* Actualización para forzar la disposición 2x2 de los gráficos */
.kpi-charts-page {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* Fuerza 2 columnas en todas las resoluciones */
  gap: 20px;
  margin-bottom: 40px;
}

/* Asegura que se mantenga esta estructura en dispositivos móviles más pequeños */
@media (max-width: 768px) {
  .kpi-charts-page {
    grid-template-columns: 1fr; /* En dispositivos muy pequeños, mostrar 1 por fila */
  }
}

/* Asegura que los gráficos mantengan un tamaño adecuado */
.kpi-chart-box {
  min-height: 350px;
}

/* Estilos actualizados para los nuevos filtros de fecha */
.date-filter-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.date-filter-group label {
  margin-right: 5px;
}

.date-filter-group select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background-color: white;
  font-family: var(--font-family);
  color: #333;
  transition: all 0.3s ease;
}

.date-filter-group select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(20, 10, 154, 0.1);
}