/*
 * IMMGO — Charte : boutons (primaire, secondaire, fantôme, danger, icône), puces de filtre et onglets
 * Auteur : Jacks Ngalangala
 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--e-2);
  min-height: var(--hauteur-controle);
  min-width: var(--hauteur-controle);
  padding: 0 var(--e-5);
  border: 1px solid transparent;
  border-radius: var(--r-moyen);
  font-size: var(--taille-corps);
  font-weight: var(--graisse-forte);
  line-height: 1;
  white-space: nowrap; /* jamais de libellé sur deux lignes ni coupé : voir .btn-icone-seule */
  overflow: hidden;
  user-select: none;
  transition:
    background var(--duree) var(--courbe),
    border-color var(--duree) var(--courbe),
    transform var(--duree) var(--courbe);
}
.btn svg {
  flex: none;
  width: 20px;
  height: 20px;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled,
.btn[aria-busy='true'] {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Primaire : une seule par écran, l'action qui fait avancer */
.btn-primaire {
  background: var(--or);
  color: var(--texte-sur-or);
}
.btn-primaire:hover:not(:disabled) {
  background: var(--or-fonce);
}

/* Secondaire : action utile mais pas principale */
.btn-secondaire {
  background: var(--surface);
  color: var(--texte);
  border-color: var(--trait-fort);
}
.btn-secondaire:hover:not(:disabled) {
  border-color: var(--or);
  background: var(--surface-douce);
}

/* Fantôme : Retour, Annuler, liens d'action */
.btn-fantome {
  background: transparent;
  color: var(--texte-second);
}
.btn-fantome:hover:not(:disabled) {
  background: var(--neutre-pale);
  color: var(--texte);
}

/* Danger : seulement dans une fenêtre de confirmation, jamais en bout de formulaire */
.btn-danger {
  background: var(--danger);
  color: var(--texte-sur-danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-fonce);
}

.btn-petit {
  min-height: var(--hauteur-controle-petit);
  min-width: var(--hauteur-controle-petit);
  padding: 0 var(--e-3);
  font-size: var(--taille-petit);
  border-radius: var(--r-petit);
}
.btn-petit svg {
  width: 18px;
  height: 18px;
}
.btn-large {
  width: 100%;
}

/* Icône seule : carré, le libellé reste lisible par aria-label et title */
.btn-icone,
.btn-icone-seule {
  padding: 0;
  width: var(--hauteur-controle);
}
.btn-icone.btn-petit,
.btn-icone-seule.btn-petit {
  width: var(--hauteur-controle-petit);
}
.btn-icone-seule .btn-libelle {
  display: none;
}

/* Bouton rond sur fond sombre (cloche, retour dans l'en-tête mobile) */
.btn-sur-nuit {
  background: var(--nuit-surface-haute);
  color: var(--nuit-texte);
  border-color: var(--nuit-trait);
}
.btn-sur-nuit:hover:not(:disabled) {
  background: var(--nuit-trait);
}

/* Indicateur d'attente dans un bouton */
.btn[aria-busy='true']::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-tourne 0.7s linear infinite;
}
@keyframes btn-tourne {
  to {
    transform: rotate(360deg);
  }
}

/* Pastille de notification posée sur un bouton icône */
.btn-pastille {
  position: relative;
}
.btn-pastille::before {
  content: '';
  position: absolute;
  top: 10px;
  right: 11px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface);
}
.btn-sur-nuit.btn-pastille::before {
  box-shadow: 0 0 0 2px var(--nuit-surface-haute);
}

/* Barre d'actions : primaire à droite, retour à gauche */
.barre-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--e-3);
}
.barre-actions .btn-primaire {
  margin-left: auto;
}

/* ─── Puces (filtres rapides) ─── */
.puces {
  display: flex;
  gap: var(--e-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.puce {
  flex: none;
  min-height: 40px;
  padding: 0 var(--e-4);
  border: 1px solid var(--trait);
  border-radius: var(--r-pilule);
  background: var(--surface);
  color: var(--texte-second);
  font-size: var(--taille-petit);
  font-weight: var(--graisse-moyenne);
  white-space: nowrap;
}
.puce[aria-pressed='true'] {
  background: var(--texte);
  border-color: var(--texte);
  color: var(--surface);
}

/* ─── Onglets ─── */
.onglets {
  display: flex;
  gap: var(--e-1);
  padding: var(--e-1);
  border-radius: var(--r-moyen);
  background: var(--neutre-pale);
  overflow-x: auto;
  scrollbar-width: none;
}
.onglet {
  flex: 1 0 auto;
  min-height: 40px;
  padding: 0 var(--e-4);
  border: 0;
  border-radius: var(--r-petit);
  background: transparent;
  color: var(--texte-second);
  font-size: var(--taille-petit);
  font-weight: var(--graisse-forte);
  white-space: nowrap;
}
.onglet[aria-selected='true'] {
  background: var(--surface);
  color: var(--texte);
  box-shadow: var(--ombre-1);
}
