/* Onglets du dashboard */

/* Conteneur d'onglets */
.dashboard-tabs {
  margin-bottom: 2rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  /* Important: ne pas couper le sticky des onglets */
  overflow: visible;
}

/* En-tête */
.tabs-header {
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #dee2e6;
}

.tabs-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: #6c757d;
  line-height: 1.4;
}

/* Boutons d'onglet */
.tab-buttons {
  display: flex;
  justify-content: center; /* largeur auto, groupe centré */
  gap: 0.5rem;
  padding: 0.5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  background: #f8f9fa;
  border-bottom: none; /* supprime la barre */
  position: static; /* désactivé: pas de sticky */
  top: auto;
  z-index: auto;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  transition: padding 180ms ease, gap 180ms ease, box-shadow 180ms ease;
  border-radius: 12px;
  /* Empêche double-tap zoom sur la zone onglets sans bloquer le scroll horizontal */
  touch-action: pan-x; /* autorise uniquement le défilement horizontal */
}

.tab-buttons::-webkit-scrollbar { display: none; }

.tab-btn {
  background: white;
  border: 1px solid var(--line);
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  color: #6c757d;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  position: relative;
  min-width: auto;
  max-width: 220px;
  transform: translateY(0);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: padding 180ms ease, transform 180ms ease;
}

/* Mode compact désactivé */
.tab-buttons.is-compact { padding: 0.5rem; gap: 0.5rem; }
.tab-buttons.is-compact .tab-btn { padding: 0.85rem 1.25rem; min-width: auto; max-width: 220px; transform: none; font-size: 1rem; gap: 0.25rem; }
.tab-btn .tab-label {
  display: inline-block;
  opacity: 1;
  max-width: 20ch;
  overflow: hidden;
  white-space: normal; /* autoriser le retour à la ligne sur desktop */
  transition: opacity 160ms ease, max-width 200ms ease, margin 160ms ease;
}
.tab-buttons.is-compact .tab-btn .tab-label { opacity: 1; max-width: 20ch; margin-left: 0; pointer-events: auto; }
.tab-buttons.is-compact .tab-btn .tab-icon { font-size: 1.1em; display: inline-block !important; }
.tab-buttons.is-compact .tab-btn svg { width: 20px; height: 20px; display: inline-block !important; }
/* Neutralisation: garder le décalage par défaut */
.tab-buttons.is-compact .tab-btn .lucide-icon { margin-right: 0; vertical-align: -2px; width: 20px; height: 20px; }

.tab-btn:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 6%, white 94%); }

.tab-btn.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 500; /* éviter un changement de taille à l'activation */
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Supprimer l'ancien indicateur (barre) */
.tab-btn::before { content: none; }

.tab-icon { display: none; margin-right: 0; font-size: 1.1em; vertical-align: middle; }

/* Réactiver explicitement les icônes en mode compact */
.tab-buttons.is-compact .tab-btn .tab-icon,
.tab-buttons.is-compact .tab-btn svg {
  display: inline-block;
}
@media (max-width: 768px){ .tab-icon { margin-right: 0; font-size: 1em; } }

/* Contenus */
.dashboard-tabs .tab-content { display: none; }
.dashboard-tabs .tab-content.active { display: block; }

/* Responsive <= 768px: une seule ligne défilante, icônes seules */
@media (max-width: 768px){
  .tab-buttons {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    gap: 0.35rem;
    padding: 0.4rem 0.4rem;
    border-bottom: none;
  }
  .tab-btn {
    padding: 0.5rem 0.6rem;
    font-size: 0.95rem;
    line-height: 1;
    white-space: nowrap;
    min-width: auto;
    max-width: none;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Réduit les gestes interprétés comme zoom dans la zone bouton */
    touch-action: manipulation; /* tap/clic seulement, pas de double-tap zoom */
  }
  .tab-btn.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 500;
  }
  /* En responsive, toujours montrer les icônes */
  .tab-buttons button.tab-btn .tab-icon { margin-right: 0; display: inline-flex; align-items: center; justify-content: center; }
  .tab-buttons button.tab-btn svg { width: 20px; height: 20px; display: inline-block; }
  /* Ajuster précisément l'alignement des icônes Lucide en responsive */
  .tab-btn .lucide-icon { width: 20px; height: 20px; margin-right: 0; vertical-align: -2px; }
  .tab-btn .tab-label { display: none; }
  .tabs-header { padding: 1rem 1rem 0.75rem 1rem; }
  .tabs-subtitle { font-size: 0.8rem; }
}

/* Très petits écrans */
@media (max-width: 360px){
  .tab-buttons { gap: 0.25rem; }
  .tab-btn { padding: 0.45rem 0.5rem; }
  .tab-icon { display: inline-block; margin: 0; }
  .tabs-header { padding: 0.75rem 0.75rem 0.5rem 0.75rem; }
  .tabs-title { font-size: 1rem; }
  .tabs-subtitle { font-size: 0.75rem; }
}

/* L’icône à l’intérieur (span.tab-icon ou SVG direct) */
@media (min-width: 769px){
  .tab-buttons:not(.is-compact) button.tab-btn .tab-icon,
  .tab-buttons:not(.is-compact) button.tab-btn svg {
    display: none;
  }
}

/* Dashboard: limiter le conteneur des onglets pour que le fond/ombre
   aient la même largeur que les cartes en dessous */
#main-dashboard-content .dashboard-tabs.container-limited-large {
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}

/* Dashboard: aligner la barre d'onglets sur la largeur compacte (920px) */
#main-dashboard-content .tab-buttons {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}


