/* Contenu HTML des documents (déjà nettoyé à l'enregistrement) : tableaux, code et citations lisibles */
.contenu-document { overflow-wrap: anywhere; }
.contenu-document table { border-collapse: collapse; max-width: 100%; margin-bottom: 1rem; }
.contenu-document th, .contenu-document td { border: 1px solid var(--bs-border-color); padding: .25rem .5rem; vertical-align: top; }
.contenu-document th { background-color: var(--bs-tertiary-bg); }
.contenu-document pre { background-color: var(--bs-tertiary-bg); padding: .5rem; overflow-x: auto; }
.contenu-document blockquote { border-left: .25rem solid var(--bs-border-color); padding-left: 1rem; color: var(--bs-secondary-color); }

/* ------------------------------------------------------------------ */
/* Structure de l'application : menu à gauche, barre du haut, contenu   */
/* ------------------------------------------------------------------ */
:root { --psa-menu-bg: #1b2433; --psa-menu-largeur: 16.5rem; --psa-barre-hauteur: 3.5rem; }
[data-bs-theme="dark"] { --psa-menu-bg: #14171d; }

.ico { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.app { display: flex; min-height: 100vh; }
.app-contenu { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.contenu { flex: 1 1 auto; width: 100%; max-width: 1600px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }

/* Menu : fixe à gauche sur grand écran, tiroir (bouton ☰) sur tablette et mobile */
@media (min-width: 992px) {
  .menu-lateral { flex: 0 0 var(--psa-menu-largeur); width: var(--psa-menu-largeur); position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--psa-menu-bg); border-right: 1px solid rgba(255, 255, 255, .06); scrollbar-width: thin; }
}
#menu { --bs-offcanvas-bg: var(--psa-menu-bg); --bs-offcanvas-width: 18rem; --bs-offcanvas-border-width: 0; }
#menu .offcanvas-header { padding: .35rem .75rem .35rem 0; }
#menu .offcanvas-body { padding: 0; display: block; }
@media (min-width: 992px) { #menu .offcanvas-body { display: block; } }

.marque { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; text-decoration: none; padding: 1rem 1.1rem; }
.marque img { border-radius: .45rem; }
.menu { padding: 0 .6rem 1.5rem; }
.menu-lien { display: block; color: rgba(255, 255, 255, .72); text-decoration: none; border-radius: .45rem; padding: .4rem .75rem; font-size: .92rem; line-height: 1.35; }
.menu-lien:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.menu-lien.actif { background: var(--bs-primary); color: #fff; font-weight: 500; }
.menu-principal { display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; margin-bottom: .35rem; font-weight: 500; font-size: .95rem; color: rgba(255, 255, 255, .88); }
.menu-titre { display: flex; width: 100%; align-items: center; gap: .65rem; background: none; border: 0; color: rgba(255, 255, 255, .88); padding: .55rem .75rem; border-radius: .45rem; font-weight: 500; font-size: .95rem; text-align: left; }
.menu-titre:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.menu-titre:not(.collapsed) { color: #fff; }
.menu-titre span { flex: 1 1 auto; }
.menu-titre .chevron { width: .9rem; height: .9rem; opacity: .55; transition: transform .2s ease; }
.menu-titre:not(.collapsed) .chevron { transform: rotate(180deg); }
.menu-liens { list-style: none; margin: .1rem 0 .4rem 1.45rem; padding: 0 0 0 .5rem; border-left: 1px solid rgba(255, 255, 255, .12); }
.menu-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: rgba(255, 255, 255, .42); margin: .65rem 0 .15rem 2.1rem; }
.menu-groupe-bas { margin-top: .8rem; padding-top: .8rem; border-top: 1px solid rgba(255, 255, 255, .1); }
.menu-lien:focus-visible, .menu-titre:focus-visible, .marque:focus-visible { outline: 2px solid #6ea8fe; outline-offset: -2px; }

.ico-petit { width: .8rem; height: .8rem; }
.menu-rubrique { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: rgba(255, 255, 255, .42); margin: 1rem 0 .25rem .75rem; }
.menu-favoris { margin-top: 0; margin-bottom: .3rem; }
.menu-favoris .menu-lien { display: flex; align-items: center; gap: .4rem; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-favoris .ico-petit { opacity: .5; fill: currentColor; }

/* Menu d'un client : en-tête du client en cours, avec retour à la liste */
.menu-client { margin: 0 0 .75rem; padding: .35rem; border-radius: .6rem; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); }
.menu-retour { display: flex; align-items: center; gap: .4rem; color: rgba(255, 255, 255, .6); font-size: .78rem; text-decoration: none; padding: .2rem .4rem .35rem; }
.menu-retour:hover { color: #fff; }
.menu-client-nom { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; padding: .3rem .4rem; border-radius: .45rem; min-width: 0; }
.menu-client-nom:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.menu-client-initiale { flex: none; width: 2.1rem; height: 2.1rem; border-radius: .5rem; background: var(--bs-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.menu-client-texte { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.menu-client-texte strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.menu-client-texte small { color: rgba(255, 255, 255, .55); }

/* Barre du haut : recherche, création rapide, mode nuit, notifications, compte */
.barre { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .5rem; min-height: var(--psa-barre-hauteur); padding: env(safe-area-inset-top) max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left)); background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); }
.barre-actions { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.barre-recherche { position: relative; flex: 1 1 auto; min-width: 0; max-width: 30rem; display: flex; align-items: center; margin: 0; }
.barre-recherche .ico { position: absolute; left: .7rem; color: var(--bs-secondary-color); pointer-events: none; }
.barre-recherche input { width: 100%; padding: .42rem 3.4rem .42rem 2.2rem; border-radius: .55rem; border: 1px solid transparent; background: var(--bs-tertiary-bg); color: var(--bs-body-color); font-size: .92rem; }
.barre-recherche input:focus { outline: 0; border-color: var(--bs-primary); background: var(--bs-body-bg); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .2); }
.barre-recherche kbd { position: absolute; right: .55rem; font-size: .68rem; background: var(--bs-secondary-bg); color: var(--bs-secondary-color); padding: .1rem .35rem; }

.btn-icone { display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; padding: 0; border: 0; background: transparent; color: inherit; border-radius: .5rem; }
.btn-icone:hover { background: var(--bs-tertiary-bg); color: inherit; }
.pastille { position: absolute; top: .05rem; right: -.1rem; font-size: .62rem; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--bs-primary); color: #fff; font-weight: 600; font-size: .9rem; }
.menu-notifications { width: 24rem; min-width: 22rem; max-width: 92vw; }

/* Bouton de mode nuit : la lune en mode clair, le soleil en mode nuit */
[data-bs-theme="dark"] .icone-lune, [data-bs-theme="light"] .icone-soleil { display: none !important; }

/* Pages hors connexion (connexion, mot de passe oublié…) : pas de menu, le contenu au centre */
.invite { min-height: 100vh; display: flex; flex-direction: column; }
.invite-entete { display: flex; align-items: center; justify-content: space-between; padding: .5rem 1rem; }
.invite .marque { color: var(--bs-body-color); padding: .5rem 0; }
.invite .contenu { max-width: 1140px; }

/* ------------------------------------------------------------------ */
/* Mode nuit : les teintes « claires » de Bootstrap deviennent sombres  */
/* ------------------------------------------------------------------ */
[data-bs-theme="dark"] .text-bg-light { background-color: var(--bs-tertiary-bg) !important; color: var(--bs-body-color) !important; }
[data-bs-theme="dark"] .list-group-item-light { background-color: var(--bs-tertiary-bg); color: var(--bs-body-color); }
[data-bs-theme="dark"] .card { --bs-card-bg: var(--bs-body-bg); }

/* ------------------------------------------------------------------ */
/* Mobile et tablette                                                   */
/* ------------------------------------------------------------------ */
.contenu > .d-flex.justify-content-between { flex-wrap: wrap; gap: .5rem; }
.table-responsive { -webkit-overflow-scrolling: touch; }

@media (max-width: 767.98px) {
  .contenu { padding: 1rem 1rem 3rem; }
  .barre { gap: .25rem; }
  /* 16 px minimum dans les champs : sinon iOS zoome sur la page à la saisie */
  .form-control, .form-select, .form-control-sm, .form-select-sm, .barre-recherche input { font-size: 1rem; }
  .menu-notifications { position: fixed !important; left: .5rem !important; right: .5rem !important; top: calc(var(--psa-barre-hauteur) + .25rem) !important; transform: none !important; min-width: 0; }
  .card-body, .card-header { padding-left: .9rem; padding-right: .9rem; }
  h1.h3, h1.h4 { font-size: 1.3rem; }
}

/* Écrans tactiles : cibles plus grandes */
@media (pointer: coarse) {
  .menu-lien { padding: .6rem .75rem; }
  .menu-titre { padding: .7rem .75rem; }
  .dropdown-item { padding-top: .55rem; padding-bottom: .55rem; }
  .btn-sm { --bs-btn-padding-y: .4rem; --bs-btn-padding-x: .7rem; }
  .pagination .page-link { padding: .5rem .85rem; }
}

/* Impression : ni menu ni barre */
@media print {
  .menu-lateral, .barre { display: none !important; }
  .contenu { max-width: none; padding: 0; }
}

/* ------------------------------------------------------------------ */
/* Aide en ligne                                                        */
/* ------------------------------------------------------------------ */
.menu-aide { min-width: 21rem; max-width: 92vw; }
@media (max-width: 575.98px) { .menu-aide { position: fixed !important; left: .5rem !important; right: .5rem !important; top: calc(var(--psa-barre-hauteur) + .25rem) !important; transform: none !important; min-width: 0; } }

.aide-recherche { display: flex; gap: .5rem; align-items: center; max-width: 46rem; position: relative; }
.aide-recherche .ico { position: absolute; left: 1rem; color: var(--bs-secondary-color); z-index: 2; }
.aide-recherche input { padding-left: 2.6rem; }
.aide-carte { transition: border-color .15s, transform .15s; }
.aide-carte:hover { border-color: var(--bs-primary); transform: translateY(-1px); }

.aide-mise-en-page { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 2rem; align-items: start; }
@media (max-width: 991.98px) { .aide-mise-en-page { grid-template-columns: minmax(0, 1fr); gap: 1rem; } }
.aide-sommaire { position: sticky; top: calc(var(--psa-barre-hauteur) + 1rem); max-height: calc(100vh - var(--psa-barre-hauteur) - 2rem); overflow-y: auto; font-size: .9rem; }
@media (max-width: 991.98px) { .aide-sommaire { position: static; max-height: none; } }
.aide-accueil-lien { display: inline-block; margin-bottom: .5rem; text-decoration: none; }
.aide-groupe { margin-bottom: .75rem; }
.aide-groupe-titre { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 600; margin-bottom: .15rem; }
.aide-lien { display: block; padding: .2rem .6rem; border-left: 2px solid var(--bs-border-color); color: var(--bs-body-color); text-decoration: none; }
.aide-lien:hover { color: var(--bs-primary); border-left-color: var(--bs-primary); }
.aide-lien.actif { border-left-color: var(--bs-primary); color: var(--bs-primary); font-weight: 600; }

.aide-article { max-width: 60rem; min-width: 0; }
.aide-toc { background: var(--bs-tertiary-bg); border-radius: .5rem; padding: .75rem 1rem; margin-bottom: 1.25rem; font-size: .92rem; }
.aide-toc ul { padding-left: 1.1rem; }
.aide-corps { line-height: 1.65; }
.aide-corps h2 { font-size: 1.3rem; margin-top: 2rem; padding-top: .75rem; border-top: 1px solid var(--bs-border-color); scroll-margin-top: calc(var(--psa-barre-hauteur) + 1rem); }
.aide-corps h3 { font-size: 1.05rem; margin-top: 1.25rem; }
.aide-corps table { width: 100%; margin-bottom: 1rem; font-size: .92rem; }
.aide-corps th, .aide-corps td { border: 1px solid var(--bs-border-color); padding: .35rem .6rem; vertical-align: top; }
.aide-corps th { background: var(--bs-tertiary-bg); }
.aide-corps kbd { white-space: nowrap; }
.aide-pied { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--bs-border-color); }

.aide-figure { margin: 1.25rem 0; border: 1px solid var(--bs-border-color); border-radius: .6rem; overflow: hidden; background: var(--bs-body-bg); }
.aide-figure a { display: block; background: #fff; line-height: 0; }
.aide-figure img { width: 100%; height: auto; display: block; }
.aide-figure-mobile img { max-width: 22rem; margin: 0 auto; }
.aide-figure figcaption { padding: .75rem 1rem; font-size: .9rem; }
.aide-legende { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .35rem; }
.aide-legende li { display: flex; gap: .6rem; align-items: flex-start; }
.aide-pastille { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #e8590c; color: #fff; font-weight: 700; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; }

.aide-note, .aide-astuce, .aide-attention { border-left: 4px solid; border-radius: .4rem; padding: .6rem .9rem; margin: 1rem 0; }
.aide-note { border-color: var(--bs-info); background: var(--bs-info-bg-subtle); }
.aide-astuce { border-color: var(--bs-success); background: var(--bs-success-bg-subtle); }
.aide-attention { border-color: var(--bs-warning); background: var(--bs-warning-bg-subtle); }
.aide-note > :last-child, .aide-astuce > :last-child, .aide-attention > :last-child { margin-bottom: 0; }
.aide-etapes { counter-reset: etape; list-style: none; padding-left: 0; }
.aide-etapes > li { counter-increment: etape; position: relative; padding-left: 2.4rem; margin-bottom: .7rem; }
.aide-etapes > li::before { content: counter(etape); position: absolute; left: 0; top: .05rem; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--bs-primary); color: #fff; font-weight: 700; font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; }
