/* ===== DASHBOARD.CSS - VERSIÓN CON STICKY HÍBRIDO ===== */

/* 1. DASHBOARD SECTION */
.dashboard-section {
  padding: 2.5rem 0;
  background-color: var(--white);
}

.section-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.8rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.section-header .dashboard-intro {
  color: var(--text-color);
  max-width: 750px;
  margin: 0 auto;
  padding: 1.2rem 0;
  font-size: 1rem;
  line-height: 1.6;
  text-align: center;
}

/* 2. LAYOUT COMPACTO - DESKTOP/TABLET */
.dashboard-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 1.2rem;
  margin-top: 1.2rem;
  /* ¡IMPORTANTE! Sin position: relative aquí */
}

/* Placeholder para sidebar fijo (controlado por JS) */
.sidebar-placeholder {
  display: none;
  visibility: hidden;
  pointer-events: none;
  flex-shrink: 0;
}

/* 3. MENÚ LATERAL - ESTILOS BASE */
.dashboard-sidebar {
  background-color: var(--background-color);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.2rem;
  height: fit-content;
  align-self: start;
  transition: all 0.3s ease;
}

/* Estado cuando JS lo hace fixed */
.dashboard-sidebar.fixed-sidebar {
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  background-color: var(--white);
}

.dashboard-nav {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.dashboard-nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-color);
  opacity: 0.7;
  text-decoration: none;
  position: relative;
  font-size: 0.9rem;
}

.dashboard-nav-item:hover {
  background-color: #f9fafb;
  border-color: #e5e7eb;
  opacity: 1;
}

.dashboard-nav-item.active {
  background-color: rgba(31, 58, 95, 0.05);
  border-color: rgba(31, 58, 95, 0.2);
  color: var(--primary-color);
  font-weight: 600;
  opacity: 1;
}

.dashboard-nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background-color: var(--accent-color);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 22px;
  text-align: center;
}

.nav-icon i {
  font-size: 1rem;
  color: var(--neutral-gray);
}

.dashboard-nav-item.active .nav-icon i {
  color: var(--primary-color);
}

.nav-text {
  flex: 1;
  font-weight: 500;
}

/* ===== STICKY NATIVO SOLO PARA DESKTOP (≥769px) ===== */
@media (min-width: 769px) {
  .dashboard-sidebar {
    position: sticky;
    top: 100px; /* Debajo del header + margen */
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}

/* 4. CONTENIDO PRINCIPAL */
.dashboard-main {
  background-color: var(--white);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.2rem;
  min-height: 800px;
}

.dashboard-page {
  display: none;
}

.dashboard-page.active {
  display: block;
}

.dashboard-page h3 {
  font-size: 1.4rem;
  color: var(--primary-color);
  margin-bottom: 0.8rem;
}

.page-description {
  font-size: 0.95rem;
  color: var(--text-color);
  opacity: 0.8;
  line-height: 1.5;
  margin-bottom: 1.2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid #e5e7eb;
}

/* 5. FILTROS COMPACTOS */
.dashboard-filters {
  margin: 1.2rem 0;
  width: 100%;
  box-sizing: border-box;
}

.filters-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  padding: 1.2rem;
  background-color: var(--background-color);
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  box-sizing: border-box;
  max-width: 100%;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0; /* Permite que se reduzcan en móvil */
}

.filter-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-color);
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-group label i {
  color: var(--primary-color);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.filter-select {
  padding: 0.7rem 0.9rem;
  padding-right: 2rem; /* Espacio adecuado para flecha nativa */
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background-color: var(--white);
  color: var(--text-color);
  font-family: "Inter", sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
  height: 42px;
  width: 100%; /* Ocupa el 100% de su columna */
  box-sizing: border-box;
  max-width: 100%;
  /* DEJAR QUE LA FLECHA NATIVA SE MUESTRE - NO USAR APPEARANCE */
}

.filter-select:hover {
  border-color: var(--primary-color);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.1);
}

.filter-select:not([value="all"]) {
  border-color: var(--primary-color);
  background-color: rgba(31, 58, 95, 0.05);
  font-weight: 500;
}

/* BOTÓN BORRAR FILTROS - SOLO DESKTOP */
.reset-filters-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 8px 12px;
  background-color: transparent;
  color: var(--neutral-gray);
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.reset-filters-btn:hover {
  background-color: #f9fafb;
  color: var(--text-color);
  border-color: var(--neutral-gray);
}

.reset-filters-btn:active {
  transform: scale(0.98);
}

.reset-filters-btn i {
  font-size: 0.75rem;
}

/* 6. CONTENEDOR PARA TABLA Y GRÁFICO */
.dashboard-visuals-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.2rem;
}

.visuals-section {
  min-width: 0;
}

.visuals-section h4 {
  font-size: 1rem;
  color: var(--primary-color);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid #f3f4f6;
}

.section-description {
  font-size: 0.95rem;
  color: var(--text-color);
  opacity: 0.8;
  line-height: 1.5;
  margin-bottom: 1.2rem;
  padding-bottom: 1.2rem;
}

.section-description small {
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.8;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

/* FIX RESPONSIVE CHARTS */
.dashboard-visuals-container,
.visuals-section {
  min-width: 0;
}

.visualization-container {
  min-width: 0;
  overflow-x: auto;
}

.visualization-container canvas {
  max-width: 100% !important;
  height: auto !important;
}

/* ===== ESTILOS PARA SUBSECCIÓN DE ACCESIBILIDAD ===== */
#accessibility-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid #e5e7eb;
}

#accessibility-section .subsection-header {
  margin-bottom: 2rem;
}

/* 7. VISUALIZATION CONTAINER */
.visualization-container {
  margin-top: 1.2rem;
  border-radius: 10px;
  overflow: hidden;
  min-height: 350px;
  background-color: var(--background-color);
  padding: 1.5rem;
}

.visualization-container .data-message {
  text-align: center;
  padding: 30px 16px;
  color: var(--neutral-gray);
}

.visualization-container .message-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.visualization-container .data-message h4 {
  color: var(--text-color);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.visualization-container .data-message p {
  margin-bottom: 1rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.95rem;
  line-height: 1.5;
}

.visualization-container .data-message ul {
  text-align: left;
  max-width: 500px;
  margin: 1.5rem auto;
  padding-left: 1.5rem;
}

.visualization-container .data-message li {
  margin-bottom: 0.5rem;
  color: var(--text-color);
  font-size: 0.9rem;
}

.visualization-container .data-message em {
  display: block;
  margin-top: 1.5rem;
  font-style: italic;
  color: var(--neutral-gray);
  font-size: 0.9rem;
}

/* 8. TABLET (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 220px 1fr;
    gap: 1.5rem;
  }

  .filters-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .reset-filters-btn {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
  }

  .section-header .dashboard-intro {
    max-width: 90%;
  }
}

/* ===== KPIs ===== */
.kpi-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.kpi-card {
  background: var(--white);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  border-left: 4px solid var(--primary-color);
  transition: all 0.3s ease;
  border: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  gap: 14px;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(31, 58, 95, 0.08);
}

.kpi-card-icon {
  font-size: 1.3rem;
  color: var(--primary-color);
  background: var(--background-color);
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 14px;
}

.kpi-card-content {
  padding: 14px 14px 14px 0;
  flex: 1;
}

.kpi-card-label {
  font-size: 0.78rem;
  color: var(--neutral-gray);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 3px;
  font-weight: 600;
  font-family: "Inter", sans-serif;
}

.kpi-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-color);
  font-family: "JetBrains Mono", monospace;
  margin-bottom: 1px;
  line-height: 1.1;
}

.kpi-card-subtext {
  font-size: 0.78rem;
  color: var(--neutral-gray);
  font-weight: 400;
  font-family: "Inter", sans-serif;
}

/* =============================================== */
/* MÓVIL: DISEÑO OPTIMIZADO (≤768px) - STICKY CSS PURO */
/* =============================================== */
@media (max-width: 768px) {
  /* A. LAYOUT GENERAL - ASEGURAR CONTENEDOR PARA STICKY */
  .dashboard-section {
    position: relative;
    overflow: visible !important; /* IMPORTANTE: no hidden */
  }

  /* CORRECCIÓN: ELIMINAR EL SELECTOR DUPLICADO */
  .dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: static; /* ← CRÍTICO: Sin relative para que sticky funcione */
  }

  .dashboard-main {
    padding: 1rem;
    min-height: auto;
  }

  .dashboard-page h3 {
    font-size: 1.3rem;
  }

  .page-description {
    font-size: 0.9rem;
  }

  .dashboard-visuals-container {
    gap: 2.5rem;
  }

  /* B. TEXTO INTRODUCTORIO EN MÓVIL */
  .section-header .dashboard-intro {
    max-width: 90%;
    font-size: 0.95rem;
  }

  /* C. SIDEBAR COMO MENÚ HORIZONTAL STICKY (CSS ONLY) */
  .dashboard-sidebar {
    position: sticky !important;
    top: 72px !important; /* Debajo del header */
    z-index: 90 !important;
    margin-bottom: 0.5rem;
    padding: 0.8rem;
    border-radius: 8px;
    background-color: var(--white) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    /* Forzar sticky */
    align-self: auto !important;
    transform: translateZ(0); /* Acelerar hardware */
  }

  /* ASEGURAR QUE EL CONTENEDOR PADRE PERMITA STICKY */
  .dashboard-section .container,
  .dashboard-main {
    overflow: visible !important;
    position: relative;
  }

  /* D. MENÚ HORIZONTAL - GRID RESPONSIVE (3 elementos) */
  .dashboard-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0;
  }

  .dashboard-nav-item {
    min-width: auto;
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
    justify-content: center;
    border: 1px solid #e5e7eb;
    background-color: var(--white);
    text-align: center;
  }

  .nav-icon {
    display: none;
  }

  .dashboard-nav-item.active {
    border-top: 3px solid var(--accent-color);
    background-color: rgba(31, 58, 95, 0.05);
  }

  .dashboard-nav-item.active::before {
    display: none;
  }

  .nav-text {
    text-align: center;
    white-space: normal;
  }

  /* E. OCULTAR PLACEHOLDER EN MÓVIL */
  .sidebar-placeholder {
    display: none !important;
  }

  /* F. FILTROS EN 2 FILAS (GRID 2×2) */
  .filters-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto auto;
    gap: 0.8rem;
    padding: 0.5rem;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
  }

  .filter-group:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .filter-group:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
  }

  .filter-group:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
  }

  .filter-group:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
  }

  .filter-group label {
    font-size: 0.8rem;
    color: var(--primary-color);
    opacity: 0.9;
  }

  .filter-select {
    font-size: 0.9rem;
    padding: 0.75rem;
    height: 44px;
    background-color: white;
    border: 1px solid #cbd5e1;
  }

  /* G. ELIMINAR BOTÓN BORRAR FILTROS EN MÓVIL */
  .reset-filters-btn {
    display: none;
  }

  /* H. VISUALIZATION CONTAINER EN MÓVIL */
  .visualization-container {
    padding: 1rem;
    min-height: 300px;
  }

  .visualization-container .data-message {
    padding: 20px 10px;
  }

  .visualization-container .data-message h4 {
    font-size: 1.1rem;
  }

  .visualization-container .data-message ul {
    padding-left: 1rem;
  }

  /* I. KPIs EN MÓVIL */
  .kpi-cards-container {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kpi-card {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }

  .kpi-card-icon {
    margin-left: 12px;
    margin-bottom: 0;
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .kpi-card-content {
    padding: 12px 12px 12px 0;
    width: calc(100% - 54px);
  }

  .kpi-card-value {
    font-size: 1.4rem;
  }

  /* J. SUBSECCIÓN ACCESIBILIDAD Y SENIORITY EN MÓVIL */
  #accessibility-section,
  #seniority-section {
    margin-top: 3rem;
    padding-top: 3rem;
  }
}

/* =============================================== */
/* MÓVILES MUY PEQUEÑOS (≤480px) */
/* =============================================== */
@media (max-width: 480px) {
  .dashboard-sidebar {
    position: sticky !important;
    top: 73px !important; /* Header más compacto */
    padding: 0.6rem;
  }

  .dashboard-nav {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }

  .dashboard-nav-item {
    padding: 0.5rem 0.3rem;
    font-size: 0.82rem;
  }

  .dashboard-main {
    padding: 0.8rem;
  }

  .dashboard-page h3 {
    font-size: 1.2rem;
  }

  .filter-select {
    padding: 0.6rem 0.8rem;
    height: 40px;
    font-size: 0.85rem;
  }

  .visualization-container {
    padding: 0.8rem;
  }

  .section-header .dashboard-intro {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .kpi-card {
    gap: 8px;
  }

  .kpi-card-icon {
    margin-left: 10px;
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .kpi-card-value {
    font-size: 1.3rem;
  }
}

/* =============================================== */
/* ORIENTACIÓN HORIZONTAL EN MÓVIL */
/* =============================================== */
@media (max-width: 768px) and (orientation: landscape) {
  .dashboard-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard-nav-item {
    font-size: 0.8rem;
    padding: 0.4rem 0.3rem;
  }

  .kpi-cards-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== AJUSTES ESPECÍFICOS PARA MATRIZ DE ACCESIBILIDAD ===== */
#accessibility-heatmap-container {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: auto;
}

#accessibility-heatmap-container .table-container {
  width: 100%;
  margin: 0;
}
