/* Ajustements propres à l'application (le thème visuel est dans theme.css). */

.qr-code svg {
  width: 200px;
  height: 200px;
}

/* Sections de fiche : titre à gauche, actions à droite */
.section-fiche .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.section-fiche dl {
  margin-bottom: 0;
}


/* Modale htmx : les formulaires enveloppent en-tête, corps et pied dans un <form>.
   Bootstrap ne rend le corps défilant que s'il est enfant direct de .modal-content :
   le formulaire reprend donc la mise en page en colonne pour que seul le corps défile. */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.modal-dialog-scrollable .modal-content > form > .modal-body {
  overflow-y: auto;
}

/* Bouton réduit à une icône : le libellé est porté par title (survol) et aria-label (lecteurs d'écran). */
.btn-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
}

/* Aperçu d'une pièce jointe : modale à la hauteur de l'écran, le document occupe tout le corps. */
.modale-apercu .modal-content {
  height: calc(100vh - 2 * var(--bs-modal-margin));
}

/* Le corps prend toute la place libre ; son contenu y est positionné en absolu : une hauteur en %
   sur un enfant direct d'élément flexible ne se résout pas (l'iframe retomberait à 150 px). */
.modale-apercu .modal-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.apercu-piece-jointe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.apercu-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 1rem;
}

/* Cloche des notifications (barre latérale) et pastille « non lue » de la page des notifications. */
.cloche {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  color: var(--ata-texte-doux);
}

.cloche:hover,
.cloche.active {
  background: var(--ata-marine-pale);
  color: var(--ata-marine);
}

.cloche .nombre {
  position: absolute;
  top: 0;
  right: -2px;
  min-width: 1.15rem;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ata-orange);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}

.notification-pastille {
  flex-shrink: 0;
  width: 0.55rem;
  height: 0.55rem;
  margin-top: 0.45rem;
  border-radius: 999px;
}

.notification-pastille.non-lue {
  background: var(--ata-orange);
}

/* Graphiques du tableau de bord : hauteur fixe, le canevas suit la largeur de la carte. */
.graphique {
  position: relative;
  height: 220px;
}

/* Liste de sélection ouverte depuis une modale : rattachée au body, au-dessus de la modale. */
body > .ts-dropdown {
  z-index: 1060;
}

/* Arborescence des services : retrait par niveau. */
.arborescence-services .service-niveau {
  display: inline-block;
  padding-left: calc(var(--niveau, 0) * 1.5rem);
}

/* Classes tenant lieu d'attributs style, interdits par la CSP (valeurs calculées : voir appliquerStyles dans site.js). */
.texte-multiligne { white-space: pre-line; }
.texte-mini { font-size: 0.75rem; }
.texte-sur-nuit { color: #c9d6e8; }
.cellule-alerte { color: var(--ata-danger); white-space: normal; }
.largeur-max-10 { max-width: 10rem; }
.largeur-max-12 { max-width: 12rem; }
.largeur-max-14 { max-width: 14rem; }
.largeur-max-16 { max-width: 16rem; }
.largeur-max-28 { max-width: 28rem; }
.largeur-max-40 { max-width: 40rem; }
.largeur-min-20 { min-width: 20rem; }
.largeur-min-22 { min-width: 22rem; }
.largeur-11 { width: 11rem; }
.largeur-30pc { width: 30%; }
.progress.progress-fine { height: 0.5rem; }
.monogramme.rond.petit { width: 26px; height: 26px; font-size: 0.65rem; }
.fond-valide { background: var(--ata-succes-point); }
.fond-en-validation { background: var(--ata-attente-point); }
.fond-brouillon { background: #c4ccd8; }

/* Indicateur de requête : règles que htmx injecterait sinon dans un élément style (includeIndicatorStyles à faux). */
.htmx-indicator { opacity: 0; visibility: hidden; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; visibility: visible; transition: opacity 200ms ease-in; }

/* --- Marque --------------------------------------------------------------------- */
.marque {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.barre-laterale .marque .logo {
  height: 32px;
  margin-left: 0.25rem;
}

.nom-application {
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--bs-emphasis-color);
}

/* --- Navigation fluide ------------------------------------------------------------ */
/* Barre de chargement fine, en haut de page, pendant une requête htmx. */
#barre-chargement {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 2000;
  background: var(--ata-orange);
  transform-origin: left;
  pointer-events: none;
}

#barre-chargement.htmx-request {
  animation: chargement 1.2s ease-out infinite;
}

@keyframes chargement {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* Fondu court entre deux pages : au-delà de 150 ms, l'application paraîtrait plus lente. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 120ms;
}

@media (prefers-reduced-motion: reduce) {
  #barre-chargement.htmx-request { animation: none; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

/* --- Listes et fiches ------------------------------------------------------------- */
.entete-tri {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.entete-tri:hover {
  color: var(--bs-link-color);
}

/* Texte saisi sur plusieurs lignes (désignations, conditions). */
.texte-lignes {
  white-space: pre-line;
}

.totaux {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1.5rem;
  max-width: 340px;
  margin-left: auto;
}

.totaux dt {
  font-weight: 500;
  color: var(--ata-texte-doux);
}

.totaux dd {
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

.totaux .total {
  padding-top: 0.5rem;
  border-top: 1px solid var(--ata-bordure);
  font-weight: 800;
  color: var(--ata-texte);
}


/* --- Éditeur de lignes ------------------------------------------------------------- */
.editeur-lignes th,
.editeur-lignes td {
  padding: 0.35rem;
  vertical-align: top;
}

.editeur-lignes .form-control {
  padding: 0.3rem 0.45rem;
  font-size: 0.875rem;
}

.editeur-lignes .col-quantite { width: 5.5rem; }
.editeur-lignes .col-unite { width: 5rem; }
.editeur-lignes .col-prix { width: 8rem; }
.editeur-lignes .col-taux { width: 4.5rem; }
.editeur-lignes .col-total { width: 8rem; text-align: right; white-space: nowrap; padding-top: 0.6rem; }
.editeur-lignes .col-actions { width: 5.5rem; white-space: nowrap; }

.etat-sauvegarde {
  min-height: 1.25rem;
}

.col-quantite-saisie {
  width: 7rem;
}

.ajout-catalogue {
  max-width: 24rem;
}

/* --- Pilotage et trésorerie ------------------------------------------------------------ */
:root {
  --ata-graphe-1: #1a66c2;
  --ata-graphe-2: #f06000;
}
[data-bs-theme="dark"] {
  --ata-graphe-1: #4a8fe0;
  --ata-graphe-2: #dc6f22;
}
.indicateurs .indicateur .valeur {
  font-size: 1.6rem;
  white-space: nowrap;
}
.graphique {
  position: relative;
  height: 260px;
}
.operation {
  background: var(--ata-surface);
  border: 1px solid var(--ata-bordure);
  border-radius: var(--ata-rayon-carte);
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  outline: none;
}
.operation.selectionnee {
  border-color: var(--ata-marine);
  box-shadow: 0 0 0 1px var(--ata-marine);
}
.operation-entete {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.85rem;
  align-items: baseline;
  margin-bottom: 0.5rem;
}
.operation-libelle {
  flex: 1 1 16rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.operation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.compte-resultat .sous-total th,
.compte-resultat .sous-total td {
  font-weight: 700;
  background: var(--ata-surface-douce);
}
.compte-resultat .total th,
.compte-resultat .total td {
  font-size: 1.05rem;
}

/* --- Palette de commandes --------------------------------------------------------------- */
.bouton-palette {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin: 0.75rem 0 0.25rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.8125rem;
  color: var(--ata-texte-doux);
  background: var(--ata-surface-douce);
  border: 1px solid var(--ata-bordure);
  border-radius: 10px;
}
.bouton-palette:hover {
  border-color: var(--ata-bordure-forte);
}
.palette-resultats {
  max-height: 55vh;
  overflow-y: auto;
}
.palette-groupe {
  padding: 0.5rem 0.5rem 0.15rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ata-texte-doux);
}
.palette-lien {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  color: var(--ata-texte);
  text-decoration: none;
}
.palette-lien:hover,
.palette-lien:focus {
  background: var(--ata-marine-pale);
  outline: none;
}
