/* Styles propres à ERProd (en complément de Bootstrap 5.3)

   COULEURS : toutes passent par les variables ci-dessous, jamais de couleur écrite en dur
   ailleurs dans ce fichier (vérifié par un test). Elles s'appuient sur les variables de Bootstrap
   (--bs-…) : un futur thème n'aura qu'à redéfinir ces deux jeux de variables, par exemple dans
   un bloc  :root[data-theme="sombre"] { … }. */

:root {
  /* Surfaces et texte */
  --erp-fond: var(--bs-body-bg);
  --erp-texte: var(--bs-body-color);
  --erp-texte-discret: var(--bs-gray-600);
  --erp-bordure: var(--bs-gray-400);
  --erp-fond-doux: var(--bs-tertiary-bg);        /* encadrés, blocs de code */
  --erp-fond-doux-2: var(--bs-secondary-bg);     /* badges neutres */
  --erp-fond-piece: #f1f3f5;                      /* pièce jointe du panneau des retours */
  --erp-sombre: var(--bs-dark);                   /* en-têtes foncés (panneau, bouton de connexion) */
  --erp-sur-sombre: var(--bs-white);              /* texte sur fond foncé ou coloré */
  --erp-ombre: rgba(0, 0, 0, .12);
  --erp-ombre-forte: rgba(0, 0, 0, .25);
  --erp-voile: rgba(0, 0, 0, .8);                 /* fond de l'écran de recadrage */
  --erp-voile-clair: rgba(255, 255, 255, .15);

  /* Couleurs de sens */
  --erp-accent: var(--bs-primary);
  --erp-accent-voile: rgba(var(--bs-primary-rgb), .12);
  --erp-danger: var(--bs-danger);
  --erp-succes: var(--bs-success);
  --erp-neutre: var(--bs-secondary);
  --erp-alerte-test: #c62828;                     /* bandeau de l'environnement de test */

  /* Badges des retours */
  --erp-statut-nouveau: var(--bs-warning-bg-subtle);
  --erp-statut-livre: var(--bs-success-bg-subtle);
  --erp-statut-refuse: var(--bs-danger-bg-subtle);
  --erp-priorite-haute: var(--bs-orange);
  --erp-priorite-bloquante: #842029;
  --erp-priorite-basse: var(--bs-gray-500);
}

.bandeau-test {
  background: var(--erp-alerte-test);
  color: var(--erp-sur-sombre);
  text-align: center;
  padding: .35rem;
  font-weight: 600;
}

main { max-width: 1400px; margin: 0 auto; }

.table td, .table th { vertical-align: middle; }
.table-formset td { padding: .25rem; }
.table-formset .form-control, .table-formset .form-select { min-width: 6rem; }

.carte-module { transition: box-shadow .15s; }
.carte-module:hover { box-shadow: 0 .25rem .75rem var(--erp-ombre); }

.page-connexion { max-width: 420px; margin: 3rem auto; }

/* Indicateur de chargement HTMX */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }

/* Formulaires de connexion (django-allauth) */
.page-connexion input:not([type=checkbox]):not([type=hidden]) {
  display: block; width: 100%; padding: .375rem .75rem; margin-bottom: .5rem;
  border: 1px solid var(--erp-bordure); border-radius: .375rem;
}
.page-connexion button[type=submit] {
  background: var(--erp-sombre); color: var(--erp-sur-sombre); border: 0; border-radius: .375rem; padding: .45rem 1rem;
}
.page-connexion h1 { font-size: 1.4rem; margin-bottom: 1rem; }

/* Cases à cocher multiples (activités…) sur une ligne */
.cases-multiples > div { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.cases-multiples label { font-weight: normal; }
.cases-multiples input { margin-right: .3rem; }
[hidden] { display: none !important; }

/* Retours (bugs et demandes) : panneau du bandeau et outils de sélection / capture */
.retours-icone { vertical-align: -4px; }
.retours-panneau {
  position: fixed; top: 4rem; right: 1rem; width: 380px; max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 5rem); overflow: auto; z-index: 1080;
  background: var(--erp-fond); border: 1px solid var(--erp-bordure); border-radius: .5rem; box-shadow: 0 .5rem 1.5rem var(--erp-ombre-forte);
}
.retours-panneau.retours-discret { opacity: .35; }
.retours-entete {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .5rem .75rem; background: var(--erp-sombre); color: var(--erp-sur-sombre); cursor: move; user-select: none; touch-action: none;
  border-radius: .5rem .5rem 0 0; font-weight: 600; font-size: .95rem;
}
.retours-corps { padding: .75rem; }
.retours-aide { font-size: .75rem; color: var(--erp-texte-discret); margin: .25rem 0 .5rem; }
.retours-piece { background: var(--erp-fond-piece); border-radius: .25rem; padding: .25rem .5rem; margin-bottom: .5rem; }
.retours-vignettes { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.retours-vignette { position: relative; }
.retours-vignette img { width: 96px; height: 64px; object-fit: cover; border: 1px solid var(--erp-bordure); border-radius: .25rem; }
.retours-vignette .btn-close { position: absolute; top: -6px; right: -6px; background-color: var(--erp-fond); border-radius: 50%; padding: .3rem; font-size: .6rem; }
.retours-en-selection, .retours-en-selection * { cursor: crosshair !important; }
.retours-surbrillance {
  position: fixed; z-index: 1079; pointer-events: none;
  outline: 2px solid var(--erp-accent); background: var(--erp-accent-voile);
}
.retours-surbrillance::after {
  content: attr(data-libelle); position: absolute; left: 0; top: -1.4rem; white-space: nowrap;
  background: var(--erp-accent); color: var(--erp-sur-sombre); font: .75rem/1.2 monospace; padding: .15rem .35rem; border-radius: .2rem;
}
.retours-recadrage {
  position: fixed; inset: 0; z-index: 1090; background: var(--erp-voile);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem;
}
.retours-consigne { color: var(--erp-sur-sombre); margin-bottom: .5rem; }
.retours-cadre { position: relative; cursor: crosshair; touch-action: none; user-select: none; }
.retours-cadre img { display: block; max-width: 95vw; max-height: 80vh; }
.retours-selection { position: absolute; border: 2px dashed var(--erp-sur-sombre); background: var(--erp-voile-clair); pointer-events: none; }
.retours-code { max-height: 16rem; overflow: auto; background: var(--erp-fond-doux); padding: .5rem; font-size: .75rem; white-space: pre-wrap; }
.badge.retours-type-bug { background: var(--erp-danger); }
.badge.retours-type-modification { background: var(--erp-accent); }
.badge.retours-type-nouveaute { background: var(--erp-succes); }
.badge.retours-type-autre { background: var(--erp-neutre); }
.badge[class*="retours-statut-"] { background: var(--erp-fond-doux-2); color: var(--erp-texte); }
.badge.retours-statut-nouveau { background: var(--erp-statut-nouveau); }
.badge.retours-statut-livre { background: var(--erp-statut-livre); }
.badge.retours-statut-refuse { background: var(--erp-statut-refuse); }
.badge.retours-statut-annule { background: var(--erp-fond-doux-2); color: var(--bs-secondary-color); text-decoration: line-through; }
/* Statuts des devis */
.badge[class*="devis-statut-"] { background: var(--erp-fond-doux-2); color: var(--erp-texte); }
.badge.devis-statut-brouillon { background: var(--erp-statut-nouveau); }
.badge.devis-statut-emis { background: var(--bs-info-bg-subtle); }
.badge.devis-statut-accepte { background: var(--erp-statut-livre); }
.badge.devis-statut-refuse, .badge.devis-statut-annule { background: var(--erp-statut-refuse); }
.badge.devis-statut-commande { background: var(--erp-statut-livre); }
.badge.devis-statut-expire { background: var(--erp-fond-doux-2); color: var(--bs-secondary-color); }
.badge.retours-priorite-haute { background: var(--erp-priorite-haute); }
.badge.retours-priorite-bloquante { background: var(--erp-priorite-bloquante); }
.badge.retours-priorite-basse { background: var(--erp-priorite-basse); }

/* Formulaires : champs alignés en haut ; une case à cocher seule dans une rangée de champs
   descend à la hauteur des zones de saisie (sinon elle s'aligne sur les libellés) */
.grille-champs:has(.form-control, .form-select) > [data-champ] > .form-check { margin-top: 1.55rem; }

/* Fil d'Ariane */
.entete-fixe { z-index: 1030; }
.fil-ariane { --bs-breadcrumb-margin-bottom: 0; font-size: .85rem; background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color-translucent); }
.fil-ariane-contenu { max-width: 1400px; margin: 0 auto; padding: .4rem calc(var(--bs-gutter-x, 1.5rem) * .5); }

/* Ligne terminée (ex. rattachement clôturé) : grisée mais toujours modifiable */
.ligne-terminee > td { opacity: .55; }
.ligne-terminee:hover > td, .ligne-terminee:focus-within > td { opacity: 1; }

/* Lignes : croix de suppression (R-0003) et ligne marquée pour suppression */
.bouton-croix { font-size: 1rem; line-height: 1; text-decoration: none; }
.ligne-supprimee > td { opacity: .45; text-decoration: line-through; }
.ligne-supprimee > td:last-child { opacity: 1; text-decoration: none; }

.champ-ordre { width: 5.5rem; }

/* Bulles d'aide (R-0015) : libellé souligné en pointillé quand l'aide est activée */
.aide-active .libelle-aide { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.bouton-aide { font-weight: 700; min-width: 2rem; }
.bouton-aide:not(.active) { opacity: .55; }

/* Annotation des captures (R-0004) */
.retours-cadre canvas { display: block; max-width: 95vw; max-height: 75vh; cursor: crosshair; touch-action: none; }
[data-annotation-outil].active { outline: 2px solid var(--erp-accent); }
html { scroll-padding-top: var(--hauteur-entete, 0px); }
.filtre-choix { min-width: 14rem; }

/* R-0046 : en-têtes de colonnes triables */
.lien-tri { color: inherit; text-decoration: none; white-space: nowrap; }
.lien-tri:hover, .lien-tri:focus-visible { text-decoration: underline; }
.lien-tri .fleche-tri { font-size: .7em; margin-left: .25rem; }
.lien-tri:not(.actif) .fleche-tri { opacity: .35; }

/* R-0051 : flèche des ensembles dépliables */
.deplier { text-decoration: none; line-height: 1; }
.deplier .fleche-deplier { display: inline-block; transition: transform .15s; }
.deplier[aria-expanded="true"] .fleche-deplier { transform: rotate(90deg); }

/* R-0052 : menu d'export assez large pour être lisible */
.export-retours { width: min(26rem, calc(100vw - 2rem)); }
