/**
 * Dashboard inspiré — style distinct (pas identique à la version Desktop)
 * Accent bas, cartes épurées, icônes intégrées
 */

/* Urgence — 4 stat-mini en ligne */
.page-home .dj-widget-stat-row-compact {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

/* Titres avec icônes — alignement */
.page-home .dj-dashboard-grid-4x2 .dj-widget-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-home .dj-dashboard-grid-4x2 .dj-widget-title i {
  font-size: 0.95rem;
  opacity: 0.85;
  flex-shrink: 0;
}

/* Wrapper fit — s'étire pour remplir l'écran sans scroll */
.dj-dashboard-fit {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0 4px;
}
@media (min-width: 1024px) {
  .dj-dashboard-fit { padding: 0 12px; }
}

/* Courbe de tendance — canvas pleine hauteur du widget */
.page-home .dj-trend-chart-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.page-home .dj-trend-chart-wrap canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
}

/* ── KPI cards dans la grille home ── */
.page-home .dj-kpi-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.page-home .dj-kpi-card {
  padding: 6px 9px 5px;
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(10,54,84,0.04) 0%, rgba(10,54,84,0.07) 100%);
  border: 1px solid rgba(10,54,84,0.08);
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
  cursor: default;
  position: relative;
  overflow: hidden;
}
.page-home .dj-kpi-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(255,255,255,0.25) 100%);
  pointer-events: none;
}
.page-home .dj-kpi-card:hover {
  background: linear-gradient(145deg, rgba(10,54,84,0.07) 0%, rgba(10,54,84,0.11) 100%);
  box-shadow: 0 3px 10px rgba(10,54,84,0.12);
  transform: translateY(-1px);
}

.page-home .dj-kpi-card .dj-kpi-card-lbl {
  display: block;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-home .dj-kpi-card .dj-kpi-card-val {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #0a3654;
  line-height: 1.1;
}

/* ── KPI âge / genre ── */
.page-home #ageBarGroups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  align-content: start;
}

.page-home .dj-ag-kpi {
  background: linear-gradient(145deg, rgba(10,54,84,0.04) 0%, rgba(10,54,84,0.07) 100%);
  border: 1px solid rgba(10,54,84,0.08);
  border-radius: 8px;
  padding: 5px 8px 4px;
  flex-shrink: 0;
}

.page-home .dj-ag-kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.page-home .dj-ag-kpi-lbl {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #475569;
}
.page-home .dj-ag-kpi-total {
  font-size: 0.78rem;
  font-weight: 800;
  color: #0a3654;
  font-variant-numeric: tabular-nums;
}

.page-home .dj-ag-kpi-bar {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}
.page-home .dj-ag-kpi-bar:last-child { margin-bottom: 0; }

.page-home .dj-ag-kpi-sex {
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}
.page-home .dj-ag-kpi-sex-h { color: #1565a3; }
.page-home .dj-ag-kpi-sex-f { color: #be185d; }

.page-home .dj-ag-kpi-track {
  height: 6px;
  background: rgba(10,54,84,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.page-home .dj-ag-kpi-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.page-home .dj-ag-kpi-fill-h {
  background: linear-gradient(90deg, #1565a3, #1e88d4);
}
.page-home .dj-ag-kpi-fill-f {
  background: linear-gradient(90deg, #be185d, #ec4899);
}

.page-home .dj-ag-kpi-num {
  font-size: 0.62rem;
  font-weight: 600;
  color: #334155;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.page-home .dj-ag-kpi-num em {
  font-style: normal;
  font-size: 0.56rem;
  color: #94a3b8;
  margin-left: 2px;
}

/* Accent — widget Origine (pays) */
.page-home .dj-widget-enreg-stats .dj-kpi-card {
  background: linear-gradient(145deg, rgba(8,145,178,0.05) 0%, rgba(8,145,178,0.09) 100%);
}
.page-home .dj-widget-enreg-stats .dj-kpi-card .dj-kpi-card-val { color: #0891b2; }

/* Profil — layout 2 colonnes + ligne ethnies */
.page-home .dj-profil-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 6px 10px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.page-home .dj-profil-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.page-home .dj-profil-ethnies-row {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Lignes compactes label + valeur pour profil */
.page-home .dj-profil-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  background: linear-gradient(145deg, rgba(109,40,217,0.04) 0%, rgba(109,40,217,0.08) 100%);
  border: 1px solid rgba(109,40,217,0.08);
}
.page-home .dj-profil-row-lbl {
  font-size: 0.58rem;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.page-home .dj-profil-row-val {
  font-size: 0.78rem;
  font-weight: 800;
  color: #6d28d9;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Titre de sous-bloc profil */
.page-home .dj-profil-block-title {
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  display: block;
  margin-bottom: 3px;
}

/* Tags ethnies dans home */
.page-home .dj-widget-profil .dj-tag-list { gap: 4px; }
.page-home .dj-widget-profil .dj-tag {
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 0.58rem;
  font-weight: 600;
  background: rgba(180,83,9,0.10);
  border: 1px solid rgba(180,83,9,0.20);
  color: #92400e;
}

/* Couleurs d'accent par widget */
.page-home .dj-widget-flux .dj-kpi-card {
  background: linear-gradient(145deg, rgba(21,101,163,0.05) 0%, rgba(21,101,163,0.09) 100%);
}
.page-home .dj-widget-flux .dj-kpi-card .dj-kpi-card-val { color: #1565a3; }

.page-home .dj-widget-residence .dj-kpi-card {
  background: linear-gradient(145deg, rgba(21,128,61,0.05) 0%, rgba(21,128,61,0.09) 100%);
}
.page-home .dj-widget-residence .dj-kpi-card .dj-kpi-card-val { color: #15803d; }

.page-home .dj-widget-pbs .dj-kpi-card {
  background: linear-gradient(145deg, rgba(185,28,28,0.05) 0%, rgba(185,28,28,0.09) 100%);
}
.page-home .dj-widget-pbs .dj-kpi-card .dj-kpi-card-val { color: #b91c1c; }

.page-home .dj-widget-profil .dj-kpi-card {
  background: linear-gradient(145deg, rgba(109,40,217,0.05) 0%, rgba(109,40,217,0.09) 100%);
}
.page-home .dj-widget-profil .dj-kpi-card .dj-kpi-card-val { color: #6d28d9; }

/* Footer inspiré — badge centré (style distinct du Desktop) */
.dj-footer-inspired {
  margin-top: 20px;
  padding: 14px 20px;
  font-size: 0.88rem;
  border-radius: var(--card-radius-sm);
}

/* ═══════════════════════════════════════════
   TABLET + MOBILE — ≤ 1024px
   Scroll natif, désactivation du fit-to-screen
   ═══════════════════════════════════════════ */
@media (max-width: 1024px) {

  /* Scroll natif — lever toutes les contraintes de hauteur fixe */
  body.page-home {
    height: auto !important;
    overflow: auto !important;
  }
  .page-home .site-main {
    max-height: none !important;
    overflow: visible !important;
  }
  .dj-dashboard-fit {
    height: auto !important;
    overflow: visible !important;
    flex: none !important;
  }
  .page-home .dj-dashboard {
    height: auto !important;
    flex: none !important;
    overflow: visible !important;
    gap: 8px;
  }

  /* Grille : supprimer les 1fr rows qui s'effondrent sans hauteur parent */
  .page-home .dj-dashboard-grid-4x2 {
    height: auto !important;
    overflow: visible !important;
    grid-template-rows: unset !important;    /* annule repeat(4,1fr) */
    grid-auto-rows: minmax(220px, auto);     /* chaque ligne ≥ 220px */
  }

  /* Widgets : les stats reprennent flex:1 normalement */
  .page-home .dj-dashboard-grid-4x2 .dj-widget {
    overflow: visible !important;
  }
  .page-home .dj-dashboard-grid-4x2 .dj-widget-stats,
  .page-home .dj-dashboard-grid-4x2 .dj-origin-chips {
    overflow: visible !important;
    min-height: 0;
  }

  /* Courbe : hauteur fixe pour que le canvas existe */
  .page-home .dj-trend-chart-wrap {
    height: 160px !important;
    flex: none !important;
  }
}

/* ═══════════════════════════════════════════
   MOBILE — ≤ 768px
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Grille 1 colonne */
  .page-home .dj-dashboard-grid-4x2 {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
  .page-home .dj-dashboard-grid-4x2 .dj-widget {
    min-height: 0 !important;
    padding: 12px 14px;
  }

  /* KPI cards 2 colonnes */
  .page-home .dj-kpi-cards { grid-template-columns: 1fr 1fr; }

  /* Âge/genre 2 colonnes */
  .page-home #ageBarGroups { grid-template-columns: 1fr 1fr; }

  /* Profil 1 colonne */
  .page-home .dj-profil-stats { grid-template-columns: 1fr !important; }
  .page-home .dj-profil-ethnies-row { grid-column: 1 !important; }

  /* Hero strip empilé */
  .page-home .dj-hero-strip-compact .dj-hero-strip-content {
    flex-direction: column !important;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
  }
  .page-home .dj-hero-strip-compact .dj-hero-title {
    display: block !important;
    border-right: none !important;
    padding-right: 0 !important;
    font-size: 0.85rem;
    white-space: normal;
  }
  .page-home .dj-hero-kpis-inline {
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    gap: 4px !important;
  }
  .page-home .dj-hero-kpis-inline .dj-hero-kpi {
    min-width: calc(33.33% - 6px);
    flex: 1 1 calc(33.33% - 6px);
  }

  /* Bandeau d'urgence */
  .dj-alert-urgent-compact { font-size: 0.72rem; }

  /* Footer masqué */
  .page-home .dj-home-footer-badge { display: none; }

  .page-home .site-main { padding: 6px 10px 24px !important; }
}

/* ═══════════════════════════════════════════
   TRÈS PETITS ÉCRANS — ≤ 420px
   ═══════════════════════════════════════════ */
@media (max-width: 420px) {
  .page-home .dj-kpi-cards { grid-template-columns: 1fr; }
  .page-home #ageBarGroups { grid-template-columns: 1fr; }
  .page-home .dj-hero-kpis-inline .dj-hero-kpi {
    min-width: calc(50% - 4px);
    flex: 1 1 calc(50% - 4px);
  }
  .page-home .dj-ag-kpi-num { font-size: 0.58rem; }
}

/* ═══════════════════════════════════════════
   NAVIGATION — hamburger ≤ 1024px
   ═══════════════════════════════════════════ */
@media (max-width: 1024px) {

  /* Bouton hamburger (injecté par JS) */
  .dj-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    color: #fff;
    width: 34px;
    height: 28px;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
  }

  /* Nav repliée par défaut */
  .dj-nav {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.28s ease;
  }
  .dj-nav.dj-nav-open {
    max-height: 260px;
  }

  /* Liens en grille 3×N compacte */
  .dj-nav-list {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    padding: 6px;
    flex-wrap: unset !important;
    justify-content: unset !important;
  }
  .dj-nav-list > li { display: contents; }
  .dj-nav-link {
    flex-direction: column;
    font-size: 0.6rem;
    padding: 5px 2px;
    gap: 2px;
    text-align: center;
    border-radius: 6px;
  }
  .dj-nav-link i { font-size: 1rem; }
  .dj-nav-link span { font-size: 0.58rem; }
}
