/* ==========================================================================
   BUTTON COMPONENTS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  line-height: 1;
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  width: fit-content;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Un bouton-lien (<a class="btn">, rendu par btn() quand href est passé)
   n'a pas de :disabled natif — l'alias couvre les deux écritures. */
.btn.disabled,
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Anneau de focus clavier — TOUTE la famille bouton (2026-08-27 : le fichier
   n'avait AUCUN :focus-visible ; même motif que badges.css/tables.css). */
.btn:focus-visible,
.btn-icon:focus-visible,
.btn-remove:focus-visible,
.btn-document-action:focus-visible,
.btn-group .btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-loading {
  opacity: 0.8;
  cursor: wait;
}

/* Pendant le chargement, l'icône du bouton laisse sa place au spinner que
   BtnLoader injecte : la largeur reste quasi stable au lieu de s'élargir
   d'une icône. Un bouton à icône seule montre le spinner seul — voulu. */
.btn-loading svg {
  display: none;
}

/* Button Variants */
.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
}

.btn-ghost.text-error {
  background: var(--surface);
  /* css-color-ok: liséré red-200 historique — entre --state-red-bg et --error */
  border: 1px solid #fecaca;
  color: var(--error);
}

.btn-ghost.text-error:hover:not(:disabled) {
  background: white;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--error-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover:not(:disabled) {
  background: var(--warning-hover);
  border-color: var(--warning-hover);
  color: white;
}

/* Button Sizes */
.btn-xs {
  padding: var(--space-1) var(--space-2);
  font-size: 0.75rem;
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: 0.75rem;
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: 1rem;
}

/* Pleine largeur — pied de modale étroite, CTA de colonne. Promu depuis
   build (project-builder.css) le 2026-08-27 ; pendant du fullWidth mobile. */
.btn-block {
  width: 100%;
  justify-content: center;
}

/* Bouton .btn icône-seule — rendu par btn(…, ['icon_only' => true]), qui
   IMPOSE l'aria-label (le libellé y passe). Padding égal des deux axes :
   le bouton devient carré, l'icône est seule et centrée. Distinct de
   .btn-icon ci-dessous (bouton flottant autonome hors famille .btn). */
.btn-icon-only { padding: var(--space-3); }
.btn-icon-only.btn-sm { padding: var(--space-2); }
.btn-icon-only.btn-xs { padding: var(--space-1); }

/* Special Button Types */
.btn-icon {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.btn-icon:hover:not(:disabled) {
  background: var(--surface);
}

.btn-icon:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-icon.text-error {
  color: var(--error);
}

.btn-remove {
  background: var(--error);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition);
}

.btn-remove:hover:not(:disabled) {
  background: var(--error-hover);
}

.btn-remove:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-document-action {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-document-action:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-document-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-document-action.text-error {
  color: var(--error);
}

.btn-document-action.text-error:hover:not(:disabled) {
  background: var(--state-red-bg);
  /* css-color-ok: liséré red-300 historique */
  border-color: #fca5a5;
}
/* .pricing-toggle (pill switch Devis / Méthode) — déplacé le 2026-08-28 vers
   build/public/assets/css/components/erp-modules.css : tous ses consommateurs
   sont des vues build (BreakdownRendererService, atelier, project-view,
   project-builder). Le contrôle segmenté PLATEFORME est .btn-group ci-dessous. */

/* ==========================================================================
   GROUPE DE BOUTONS SEGMENTÉ — bascule de vue (liste / kanban), etc.
   ==========================================================================
   Promu ici le 2026-08-01. Le motif était redéfini dans 4 CSS de module
   (build/projects.css, build/tickets.css, xorizo/tickets.css) avec des valeurs
   voisines — et /configurator/dossiers rendait un `.btn-group` sans jamais en
   définir la mise en forme, seulement l'état actif : sa bascule table/kanban
   n'était donc pas segmentée du tout, contrairement à celle de /projects.
   Les surcharges locales restantes gagnent toujours (une CSS de module est
   chargée après main.css) — cette règle ne change donc que ce qui n'était
   habillé nulle part. */
.btn-group {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.btn-group .btn {
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
}
.btn-group .btn:last-child { border-right: none; }
.btn-group .btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--surface);
}
