/* ══════════════════════════════════════════════════════════════════
   DataLab — Sistema Responsive Completo
   Targets: 320px phones | tablets | iPads | laptops | desktops
   Breakpoints: <480 | <576 | <768 | <992 | <1200 | ≥1400
   ══════════════════════════════════════════════════════════════════ */

/* ─── 1. BASE & SCROLLING ─────────────────────────────────────── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
* { box-sizing: border-box; }

/* Improve touch scrolling on iOS */
.module-chips-row,
.table-responsive,
#sidenav-main,
.dl-drawer-panel {
  -webkit-overflow-scrolling: touch;
}

/* ─── 2. CONTAINER / PAGE PADDING ────────────────────────────── */
/* Bootstrap px-5 = 3rem per side — reduce for smaller screens */

@media (max-width: 1199.98px) {
  .container-fluid.px-5 {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
  }
  main > .px-5,
  main .ed-page-body.px-5,
  main .gd-page-body.px-5,
  main .inv-page-body.px-5 {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
  }
}

@media (max-width: 991.98px) {
  .container-fluid.px-5 {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
  }
  main > .px-5,
  main .ed-page-body.px-5,
  main .gd-page-body.px-5,
  main .inv-page-body.px-5 {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
  }
}

@media (max-width: 767.98px) {
  .container-fluid.px-5 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  main > .px-5,
  main .ed-page-body.px-5,
  main .gd-page-body.px-5,
  main .inv-page-body.px-5 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}

@media (max-width: 575.98px) {
  .container-fluid.px-5 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  main > .px-5,
  main .ed-page-body.px-5,
  main .gd-page-body.px-5,
  main .inv-page-body.px-5 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

/* ─── 3. SIDENAV ──────────────────────────────────────────────── */
#sidenav-main {
  overflow-y: auto;
  will-change: transform;
}

/* Better touch target for sidenav links */
@media (max-width: 991.98px) {
  #sidenav-main.module-shell-sidenav .nav-link {
    padding: 0.75rem 0.85rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ─── 4. NAVBAR (TOP) ─────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .module-shell-navbar {
    padding-top: 0.55rem !important;
    padding-bottom: 0.55rem !important;
  }
  .module-shell-navbar .container-fluid {
    gap: 0.35rem;
  }
  /* Ensure hamburger is accessible */
  #iconNavbarSidenav {
    padding: 0.5rem !important;
    min-width: 44px;
    min-height: 44px;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
}

/* ─── 5. MODULE CHIP NAV ──────────────────────────────────────── */
.ed-module-nav,
.gd-module-nav,
.inv-module-nav {
  padding-bottom: 0.25rem;
}

.module-chips-row {
  padding-bottom: 0.35rem;
  gap: 0.45rem !important;
}

/* Touch target improvement on mobile */
@media (max-width: 991.98px) {
  .module-chip {
    min-height: 38px;
    padding: 0.42rem 0.85rem;
    font-size: 0.78rem;
  }
}

@media (max-width: 767.98px) {
  .ed-module-nav,
  .gd-module-nav,
  .inv-module-nav {
    padding-top: 0.85rem;
    padding-bottom: 0.1rem;
  }
  .module-chip {
    padding: 0.38rem 0.75rem;
    font-size: 0.76rem;
  }
}

@media (max-width: 479.98px) {
  .module-chip {
    padding: 0.32rem 0.65rem;
    font-size: 0.73rem;
  }
}

/* ─── 6. HERO BANNER — todas las variantes (ed, gd, inv) ─────── */
:is(.ed-hero, .gd-hero, .inv-hero) {
  padding: 1.75rem 2rem;
}

@media (max-width: 1199.98px) {
  :is(.ed-hero, .gd-hero, .inv-hero) {
    padding: 1.5rem 1.75rem;
  }
}

@media (max-width: 991.98px) {
  :is(.ed-hero, .gd-hero, .inv-hero) {
    padding: 1.5rem;
  }
  :is(.ed-hero-inner, .gd-hero-inner, .inv-hero-inner) {
    flex-direction: column !important;
    gap: 1.25rem !important;
  }
  :is(.ed-hero-text, .gd-hero-text, .inv-hero-text) {
    width: 100%;
  }
}

@media (max-width: 767.98px) {
  :is(.ed-hero, .gd-hero, .inv-hero) {
    padding: 1.25rem;
    border-radius: 14px !important;
    margin-bottom: 1rem !important;
  }
  :is(.ed-hero-title, .gd-hero-title, .inv-hero-title) {
    font-size: clamp(1.25rem, 4vw, 1.65rem) !important;
    margin-bottom: 0.45rem;
  }
  :is(.ed-hero-desc, .gd-hero-desc, .inv-hero-desc) {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 0.85rem;
  }
  :is(.ed-hero-kicker, .gd-hero-kicker, .inv-hero-kicker) {
    font-size: 0.68rem;
    padding: 0.2rem 0.65rem;
    margin-bottom: 0.55rem;
  }
}

@media (max-width: 575.98px) {
  :is(.ed-hero, .gd-hero, .inv-hero) {
    padding: 1rem;
    border-radius: 12px !important;
  }
  :is(.ed-hero-title, .gd-hero-title, .inv-hero-title) {
    font-size: clamp(1.1rem, 5vw, 1.4rem) !important;
  }
  :is(.ed-hero-desc, .gd-hero-desc, .inv-hero-desc) {
    font-size: 0.82rem;
    margin-bottom: 0.65rem;
    max-width: 100% !important;
  }
}

/* Filter badges inside hero — touch targets */
@media (max-width: 767.98px) {
  .ed-filter-badge,
  .gd-filter-badge {
    padding: 0.3rem 0.85rem;
    font-size: 0.76rem;
    min-height: 34px;
  }
}

/* ─── 7. KPI CARDS ────────────────────────────────────────────── */
/* All KPI groups: stack col → row wrap on tablet/phone */

@media (max-width: 991.98px) {
  :is(.ed-kpi-group, .gd-kpi-group, .inv-kpi-group) {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 0.65rem !important;
  }
  :is(.ed-kpi, .gd-kpi, .inv-kpi) {
    flex: 1 1 calc(50% - 0.5rem) !important;
    min-width: 0 !important;
    padding: 0.8rem 0.95rem;
  }
  :is(.ed-kpi-value, .gd-kpi-value, .inv-kpi-value) {
    font-size: 1.35rem;
  }
}

@media (max-width: 767.98px) {
  :is(.ed-kpi, .gd-kpi, .inv-kpi) {
    flex: 1 1 calc(50% - 0.4rem) !important;
    min-width: 130px !important;
    padding: 0.7rem 0.8rem;
    gap: 0.7rem;
  }
  :is(.ed-kpi-value, .gd-kpi-value, .inv-kpi-value) {
    font-size: 1.25rem;
  }
  :is(.ed-kpi-icon, .gd-kpi-icon, .inv-kpi-icon) {
    width: 36px !important;
    height: 36px !important;
    font-size: 0.95rem;
    flex-shrink: 0;
  }
  :is(.ed-kpi-label, .gd-kpi-label, .inv-kpi-label) {
    font-size: 0.69rem;
  }
}

@media (max-width: 479.98px) {
  :is(.ed-kpi, .gd-kpi, .inv-kpi) {
    flex: 1 1 calc(50% - 0.35rem) !important;
    min-width: 0 !important;
    padding: 0.6rem 0.7rem;
    gap: 0.55rem;
  }
  :is(.ed-kpi-value, .gd-kpi-value, .inv-kpi-value) {
    font-size: 1.15rem;
  }
  :is(.ed-kpi-icon, .gd-kpi-icon, .inv-kpi-icon) {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.85rem;
    border-radius: 8px !important;
  }
  :is(.ed-kpi-label, .gd-kpi-label, .inv-kpi-label) {
    font-size: 0.65rem;
    letter-spacing: 0.04em;
  }
}

/* ─── 8. DASHBOARD LAYOUT ─────────────────────────────────────── */
@media (max-width: 991.98px) {
  :is(.ed-dashboard-wrap, .gd-dashboard-wrap, .inv-dashboard-wrap) {
    flex-direction: column !important;
  }
  :is(.ed-sidebar, .gd-sidebar, .inv-sidebar) {
    width: 100% !important;
    position: static !important;
  }
}

/* ─── 9. CHART GRID: 2 columnas en tablets (576px–991px) ──────── */
/* Equivalente a col-md-6 en contexto de dashboard */
@media (min-width: 576px) and (max-width: 991.98px) {
  .ed-main .row > .col-lg-6,
  .gd-main .row > .col-lg-6,
  .inv-main .row > .col-lg-6 {
    flex: 0 0 auto !important;
    width: 50% !important;
  }
}

@media (max-width: 575.98px) {
  .ed-main .row > .col-lg-6,
  .gd-main .row > .col-lg-6,
  .inv-main .row > .col-lg-6 {
    flex: 0 0 auto !important;
    width: 100% !important;
  }
}

/* ─── 10. CHART CARDS ─────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .ed-chart-card .card-body { padding: 1.1rem 1.15rem 0.95rem; }
}

@media (max-width: 767.98px) {
  .ed-chart-card .card-body { padding: 1rem; }
  .ed-chart-header { gap: 0.35rem; margin-bottom: 0.75rem; }
  .ed-chart-title { font-size: 0.86rem !important; }
  .ed-chart-kicker { font-size: 0.64rem; }
  .ed-chart-actions { gap: 0.25rem; }
  .ed-btn-export {
    width: 30px !important;
    height: 30px !important;
    font-size: 0.75rem !important;
    min-width: 30px;
    min-height: 30px;
  }
}

@media (max-width: 575.98px) {
  .ed-chart-card .card-body { padding: 0.85rem 0.8rem; }
  .ed-chart-kicker { font-size: 0.62rem; }
  .ed-chart-title { font-size: 0.82rem !important; }
  .ed-btn-export {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.72rem !important;
    border-radius: 5px !important;
  }
}

/* ─── 11. SECTION HEADERS ─────────────────────────────────────── */
@media (max-width: 767.98px) {
  .ed-section-header { margin-bottom: 1rem; }
  .ed-section-icon {
    width: 34px !important;
    height: 34px !important;
    font-size: 0.9rem;
    border-radius: 8px !important;
    flex-shrink: 0;
  }
  .ed-section-title { font-size: 0.98rem !important; }
  .ed-section-sub { font-size: 0.75rem; }
}

@media (max-width: 479.98px) {
  .ed-section-icon { width: 30px !important; height: 30px !important; }
  .ed-section-title { font-size: 0.92rem !important; }
}

/* ─── 12. TAB NAVIGATION ──────────────────────────────────────── */
@media (max-width: 991.98px) {
  .ed-tabs-bar { gap: 0.4rem; }
  .ed-tabs-bar .chip-tab,
  .ed-tab-btn {
    min-height: 40px;
    padding: 0.5rem 1.2rem;
    font-size: 0.845rem;
  }
}

@media (max-width: 767.98px) {
  .ed-tabs-bar { gap: 0.35rem; margin-bottom: 1rem !important; }
  .ed-tabs-bar .chip-tab,
  .ed-tab-btn {
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
  }
  .ed-tabs-bar .chip-tab i,
  .ed-tab-btn i { font-size: 0.88rem; }
}

@media (max-width: 479.98px) {
  .ed-tabs-bar .chip-tab,
  .ed-tab-btn {
    padding: 0.42rem 0.85rem;
    font-size: 0.79rem;
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* ─── 13. FILTER SIDEBAR (ed, gd, inv) ─────────────────────────── */
@media (max-width: 991.98px) {
  :is(.ed-filter-card, .gd-filter-card, .inv-filter-card) .card-body {
    padding: 1rem;
  }
  .ed-filter-section,
  .gd-filter-section,
  .inv-filter-section {
    margin-bottom: 0.9rem;
  }
}

/* ─── 14. SIDEBAR ANTIGUA (.sidebar-menu) — mobile overlay ───── */
/* Para bienestar, icfes, programas-academicos */
@media (max-width: 991.98px) {
  .sidebar-menu.dl-mobile-open {
    display: block !important;
    position: fixed !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: min(340px, 92vw) !important;
    z-index: 1050 !important;
    overflow-y: auto !important;
    padding: 1.1rem !important;
    background: #fff !important;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.2) !important;
    border-radius: 20px 0 0 20px !important;
    margin: 0 !important;
    border: none !important;
    animation: dlSlideInRight 0.25s ease;
  }
}

@keyframes dlSlideInRight {
  from { transform: translateX(100%); opacity: 0.8; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* Backdrop for mobile sidebar */
.dl-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1049;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  cursor: pointer;
}
.dl-sidebar-backdrop.active { display: block; }

/* Mobile filter FAB button */
.dl-filter-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1040;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00594e, #007a6d);
  color: #fff;
  border: none;
  box-shadow: 0 4px 20px rgba(0, 89, 78, 0.42), 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dl-filter-fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 28px rgba(0, 89, 78, 0.48), 0 3px 10px rgba(0, 0, 0, 0.18);
}
.dl-filter-fab:active {
  transform: translateY(0) scale(0.96);
}

/* Mobile drawer header (for existing inline-style drawers) */
.dl-drawer-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(0, 89, 78, 0.1);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.dl-drawer-panel-title {
  color: #00594e;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}
.dl-drawer-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.dl-drawer-close-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #1e293b;
}

/* Mobile drawer close button inside sidebar-menu on mobile */
.dl-sidebar-close {
  display: none;
}
@media (max-width: 991.98px) {
  .sidebar-menu.dl-mobile-open .dl-sidebar-close {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0, 89, 78, 0.1);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
    padding-top: 0.25rem;
  }
}

/* ─── 15. TABLES ──────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .table-responsive { border-radius: 10px; }
}

@media (max-width: 767.98px) {
  .table { font-size: 0.83rem; }
  .table th, .table td { padding: 0.45rem 0.5rem; white-space: nowrap; }
  #tablaDesercionRetencionWrapper { max-height: 340px; }
}

@media (max-width: 479.98px) {
  .table { font-size: 0.78rem; }
  .table th, .table td { padding: 0.38rem 0.4rem; }
}

/* ─── 16. TALENTO — TH TAB LAYOUT ────────────────────────────── */
@media (max-width: 767.98px) {
  .th-tab-layout {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  .th-filters-col {
    position: static !important;
    order: 0 !important;
  }
}

/* ─── 17. MODULE SHELL HERO (bienestar / older pages) ────────── */
@media (max-width: 991.98px) {
  .module-shell-hero.w-25 {
    width: 100% !important;
    min-width: 0 !important;
  }
}

@media (max-width: 767.98px) {
  .module-shell-hero {
    width: 100% !important;
    padding: 1rem !important;
    border-radius: 14px !important;
  }
  .module-shell-hero-title { font-size: 0.92rem !important; }
  .module-shell-hero-meta { width: 100% !important; }
}

/* ─── 18. BIENESTAR — layout fixes ───────────────────────────── */
/* Fix pill-actions / older chip tabs on small screens */
@media (max-width: 767.98px) {
  .pill-actions-row {
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
  }
  .pill-action {
    flex: 1 1 auto !important;
    font-size: 0.78rem !important;
  }
}

/* ─── 19. LOADER ──────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .loader-img { width: 50%; }
}
@media (max-width: 479.98px) {
  .loader-img { width: 62%; }
}

/* ─── 20. FOOTER ──────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .footer { margin-top: 1.5rem; }
  .nav-footer { flex-wrap: wrap; justify-content: center; gap: 0.25rem; }
  .footer .col-lg-6 { text-align: center !important; }
}

/* ─── 21. ACCESSIBILITY & TOUCH TARGETS ──────────────────────── */
@media (max-width: 991.98px) {
  .ed-btn-export { min-width: 36px; min-height: 36px; }
  .chip-tab { min-height: 40px; }
  .module-chip { min-height: 36px; }
  .btn { min-height: 38px; }
  .form-select { min-height: 40px; }
  /* Increase noUiSlider handle size for touch */
  .noUi-handle {
    width: 20px !important;
    height: 20px !important;
    right: -10px !important;
    top: -9px !important;
  }
}

/* ─── 22. BIENESTAR KPI CARDS (bootstrap-based) ──────────────── */
@media (max-width: 767.98px) {
  .card-stats .card-body { padding: 1rem; }
  .card-stats .numbers h1 { font-size: 1.65rem; }
}
@media (max-width: 479.98px) {
  .card-stats .numbers h1 { font-size: 1.45rem; }
}

/* ─── 23. STICKY HEADER IN TABLES ────────────────────────────── */
@media (max-width: 767.98px) {
  .table thead th { font-size: 0.78rem; padding: 0.45rem 0.5rem; }
}

/* ─── 24. CARD GLASS IMPROVEMENTS ON MOBILE ──────────────────── */
@media (max-width: 767.98px) {
  .card-glass, .ed-chart-card, .gd-chart-card {
    border-radius: 14px !important;
  }
}
@media (max-width: 575.98px) {
  .card-glass, .ed-chart-card, .gd-chart-card {
    border-radius: 12px !important;
  }
}

/* ─── 25. ORIENTACIÓN: landscape en teléfono ─────────────────── */
@media (orientation: landscape) and (max-height: 500px) {
  :is(.ed-hero, .gd-hero, .inv-hero) {
    padding: 0.85rem 1.1rem !important;
    margin-bottom: 0.75rem !important;
  }
  :is(.ed-hero-title, .gd-hero-title, .inv-hero-title) {
    font-size: 1.15rem !important;
  }
  :is(.ed-hero-desc, .gd-hero-desc, .inv-hero-desc) {
    display: none !important;
  }
  :is(.ed-kpi-group, .gd-kpi-group, .inv-kpi-group) {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 0.5rem !important;
  }
  :is(.ed-kpi, .gd-kpi, .inv-kpi) {
    flex: 0 0 auto !important;
    min-width: 140px !important;
    padding: 0.5rem 0.7rem !important;
  }
  .module-shell-navbar {
    padding-top: 0.4rem !important;
    padding-bottom: 0.4rem !important;
  }
}

/* ─── 26. LARGE DESKTOP (≥1400px) ────────────────────────────── */
@media (min-width: 1400px) {
  :is(.ed-hero, .gd-hero, .inv-hero) {
    padding: 2rem 2.5rem;
  }
  :is(.ed-kpi, .gd-kpi, .inv-kpi) {
    padding: 1rem 1.25rem;
  }
  .ed-chart-card .card-body { padding: 1.5rem 1.5rem 1.25rem; }
}

/* ─── 27. iPad Pro / Laptop (992px–1199px) ───────────────────── */
@media (min-width: 992px) and (max-width: 1199.98px) {
  :is(.ed-hero, .gd-hero, .inv-hero) {
    padding: 1.6rem 1.85rem;
  }
  :is(.ed-hero-title, .gd-hero-title, .inv-hero-title) {
    font-size: clamp(1.4rem, 2vw, 1.85rem) !important;
  }
  :is(.ed-kpi, .gd-kpi, .inv-kpi) {
    min-width: 160px;
  }
}

/* ─── 28. PRINT ───────────────────────────────────────────────── */
@media print {
  #sidenav-main,
  .module-shell-navbar,
  .dl-filter-fab,
  .dl-sidebar-backdrop,
  #mobileFiltersDrawer {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  :is(.ed-hero, .gd-hero, .inv-hero),
  .ed-chart-card {
    break-inside: avoid;
    box-shadow: none !important;
  }
  .container-fluid.px-5 {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* ─── 29. SCROLL IMPROVEMENTS ────────────────────────────────── */
/* Horizontal scroll para chips en mobile — hide scrollbar visually */
.module-chips-row {
  scrollbar-width: none;
}
.module-chips-row::-webkit-scrollbar { display: none; }

/* Horizontal scroll para tables */
.table-responsive::-webkit-scrollbar { height: 5px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(0, 89, 78, 0.35);
  border-radius: 999px;
}

/* ─── 30. DROPDOWN MENUS MOBILE ──────────────────────────────── */
@media (max-width: 575.98px) {
  .dropdown-menu {
    width: calc(100vw - 2rem);
    max-width: 320px;
  }
}
