/* =====================================================================
   app.css — l'apparence du site (bibliothèque, dossiers, éditeur).
   La mise en page des documents eux-mêmes est dans fiche.css.
   ===================================================================== */
:root {
  --bleu: #1ea0e6; --bleu-fonce: #0b72b5; --bleu-clair: #e6f3fc; --orange: #f5921e;
  --fond: #f4f6f9; --carte: #fff; --texte: #1b1f24; --discret: #6b7480; --trait: #dfe4ea; --rouge: #d6363b;
  --ombre: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: "Poppins", Arial, sans-serif; font-size: 15px; color: var(--texte); background: var(--fond); }
a { color: inherit; text-decoration: none; }
h1 { font-size: 26px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
small, .discret { color: var(--discret); font-size: 13px; }
.discret { margin: 4px 0 0; }

/* ---------- Barre du haut ---------- */
.barre { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; border-bottom: 1px solid var(--trait); padding: 10px 24px; position: sticky; top: 0; z-index: 20; }
.marque { display: flex; align-items: center; gap: 12px; font-family: "Londrina Solid", sans-serif; font-weight: 900; font-size: 22px; text-transform: uppercase; }
.marque img { height: 34px; }
.barre nav { display: flex; align-items: center; gap: 20px; font-size: 14px; }
.barre nav a:hover, .lien:hover { color: var(--bleu-fonce); }
.lien { background: none; border: 0; font: inherit; color: var(--discret); cursor: pointer; padding: 0; }

/* ---------- Boutons et champs ---------- */
.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--trait); background: #fff; color: var(--texte); cursor: pointer; white-space: nowrap; list-style: none; }
.bouton::-webkit-details-marker { display: none; }
.bouton:hover { border-color: var(--bleu); color: var(--bleu-fonce); }
.bouton.principal { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.bouton.principal:hover { background: var(--bleu-fonce); color: #fff; }
.bouton.danger { color: var(--rouge); }
.bouton.danger:hover { border-color: var(--rouge); background: #fdecec; color: var(--rouge); }
.bouton.large { width: 100%; padding: 11px; }
.bouton.rond { width: 34px; height: 34px; padding: 0; border-radius: 50%; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
input:where(:not([type=radio]):not([type=checkbox]):not([type=range])), select { display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid var(--trait); border-radius: 9px; background: #fff; color: var(--texte); }
input:focus, select:focus, .bouton:focus-visible { outline: 2px solid var(--bleu); outline-offset: 1px; }
.message { max-width: 1080px; margin: 16px auto 0; background: #fff8e6; border: 1px solid #f3d38a; border-radius: 10px; padding: 11px 16px; font-size: 14px; }

/* ---------- Mise en page générale ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; }
.page.etroit { max-width: 520px; }
.centre { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: 14px; padding: 22px; box-shadow: var(--ombre); margin-top: 18px; }
.connexion { width: 100%; max-width: 380px; text-align: center; margin: 0; }
.connexion img { height: 70px; margin-bottom: 8px; }
.connexion h1 { font-size: 22px; }
.connexion label { text-align: left; }
.connexion .discret { margin-bottom: 20px; }
.titre-page { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.titre-page > div:first-child { flex: 1; min-width: 220px; }
.titre-page input[type=search] { width: 250px; margin: 0; }
.section { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--discret); margin: 30px 0 12px; }
.fil { margin: 0 0 12px; font-size: 14px; color: var(--discret); }
.fil a:hover { color: var(--bleu-fonce); }
.pastille { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 10px; }
.vide { text-align: center; font-size: 44px; color: var(--discret); padding: 50px 20px; background: #fff; border: 1px dashed var(--trait); border-radius: 14px; }
.vide p { font-size: 15px; margin: 8px 0 0; }

/* ---------- Petits menus déroulants ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.bulle { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 280px; background: #fff; border: 1px solid var(--trait); border-radius: 12px; box-shadow: 0 10px 30px rgba(20, 30, 50, .16); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.bulle label { margin: 0; }
.bulle .ligne { display: block; width: 100%; text-align: left; background: none; border: 0; font: inherit; font-size: 14px; padding: 7px 8px; border-radius: 7px; cursor: pointer; color: var(--texte); }
.bulle .ligne:hover { background: var(--bleu-clair); }
.bulle .ligne.rouge { color: var(--rouge); }
.couleurs { display: flex; gap: 8px; }
.couleurs label { margin: 0; cursor: pointer; }
.couleurs input { position: absolute; opacity: 0; }
.couleurs span { display: block; width: 26px; height: 26px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--trait); }
.couleurs input:checked + span { box-shadow: 0 0 0 2px var(--texte); }

/* ---------- Bibliothèque : dossiers ---------- */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.dossier { display: block; position: relative; padding-top: 14px; transition: transform .12s; }
.dossier:hover { transform: translateY(-3px); }
.dossier .onglet { position: absolute; top: 0; left: 0; width: 42%; height: 26px; background: var(--c); border-radius: 10px 14px 0 0; }
.dossier .corps { position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; min-height: 128px; padding: 18px; background: #fff; border: 1px solid var(--trait); border-top: 5px solid var(--c); border-radius: 0 14px 14px 14px; box-shadow: var(--ombre); }
.dossier b { font-size: 16px; line-height: 1.3; }
.recents { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.recent { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--trait); border-radius: 12px; padding: 12px 14px; }
.recent:hover { border-color: var(--bleu); }
.recent b, .recent small { display: block; }
.recent b { font-size: 14px; }
.picto { font-size: 26px; }

/* ---------- Dossier : fichiers ---------- */
.fichiers { margin-top: 24px; }
.fichier { background: #fff; border: 1px solid var(--trait); border-radius: 14px; box-shadow: var(--ombre); display: grid; grid-template-columns: 1fr auto; position: relative; }
.fichier:hover { border-color: var(--bleu); }
.fichier .apercu { grid-column: 1 / -1; height: 110px; display: grid; place-items: center; background: linear-gradient(180deg, var(--bleu-clair), #fff); border-radius: 14px 14px 0 0; }
.fichier .apercu .picto { font-size: 46px; }
.fichier .infos { padding: 12px 6px 14px 16px; min-width: 0; }
.fichier .infos b { display: block; font-size: 14.5px; line-height: 1.35; }
.fichier > .menu { padding: 10px 10px 0 0; }

/* ---------- Administration ---------- */
.en-ligne { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; align-items: end; }
.en-ligne h2 { grid-column: 1 / -1; }
.en-ligne .bouton { margin-bottom: 12px; }
.client .tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.client .actions { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--trait); }
.client .actions form { display: flex; gap: 6px; align-items: center; }
.client .actions input, .client .actions select { margin: 0; width: 210px; padding: 7px 10px; }
.badge { background: var(--bleu-clair); color: var(--bleu-fonce); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }

/* =====================================================================
   ÉDITEUR
   ===================================================================== */
body.editeur { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: #e9edf2; }
.ed-haut { display: flex; align-items: center; gap: 10px; background: #fff; padding: 8px 14px; border-bottom: 1px solid var(--trait); }
.ed-haut .retour { font-size: 13px; color: var(--discret); white-space: nowrap; }
.ed-haut .retour:hover { color: var(--bleu-fonce); }
.ed-haut #titre { flex: 1; min-width: 100px; margin: 0; border-color: transparent; font-weight: 700; font-size: 16px; padding: 6px 8px; }
.ed-haut #titre:hover { border-color: var(--trait); }
#etat { font-size: 13px; color: var(--discret); white-space: nowrap; min-width: 120px; text-align: right; }
#etat.erreur { color: var(--rouge); font-weight: 600; }

.ed-outils { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; background: #fff; padding: 6px 14px; border-bottom: 1px solid var(--trait); min-height: 46px; }
.ed-outils button, .ed-outils select { font: inherit; font-size: 14px; height: 32px; min-width: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px; background: none; cursor: pointer; color: var(--texte); width: auto; margin: 0; display: inline-block; }
.ed-outils button:hover, .ed-outils select:hover { background: var(--bleu-clair); }
.ed-outils button.actif { background: var(--bleu-clair); border-color: var(--bleu); }
.ed-outils button:disabled { opacity: .35; cursor: default; background: none; }
.ed-outils .sep { width: 1px; height: 22px; background: var(--trait); margin: 0 6px; }
.ed-outils .t-cle { color: var(--bleu-fonce); font-weight: 700; }
.ed-outils .t-surligne { background: #fff1a8; }
#contexte { display: flex; align-items: center; gap: 3px; margin-left: auto; background: var(--creme, #fdf1de); border-radius: 9px; padding: 2px 6px; font-size: 13px; }
#contexte b { margin: 0 6px; color: #b8690a; }

.ed-corps { flex: 1; display: flex; min-height: 0; }
.ed-blocs { width: 232px; flex: none; background: #fff; border-right: 1px solid var(--trait); overflow-y: auto; padding: 14px 12px 30px; }
.ed-blocs h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--discret); margin: 16px 4px 6px; }
.ed-blocs h3:first-child { margin-top: 0; }
.ed-blocs p { font-size: 12px; color: var(--discret); margin: 0 4px 10px; line-height: 1.45; }
.ed-blocs button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; font: inherit; font-size: 13.5px; padding: 7px 8px; border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; color: var(--texte); }
.ed-blocs button:hover { background: var(--bleu-clair); border-color: var(--bleu); }
.ed-blocs button span { width: 22px; text-align: center; flex: none; }

.ed-zone { flex: 1; overflow: auto; padding: 28px 40px 120px 64px; position: relative; scroll-behavior: smooth; }
.feuille { background: #fff; width: fit-content; margin: 0 auto; padding: 13mm 15mm 20mm; box-shadow: 0 2px 20px rgba(20, 30, 50, .13); min-height: 297mm; position: relative; }
#fiche { outline: none; min-height: 250mm; }
#fiche > * { position: relative; }
#fiche img { cursor: pointer; }
#fiche .lignes, #fiche .saut-page { cursor: pointer; }
#fiche .saut-page { height: 22px; margin: 14px -15mm; background: repeating-linear-gradient(90deg, #b6c2cf 0 8px, transparent 8px 16px) center / 100% 2px no-repeat; }
#fiche .saut-page::after { content: "saut de page"; position: absolute; left: 50%; transform: translateX(-50%); top: 2px; background: #fff; padding: 0 10px; font-size: 11px; color: var(--discret); }

/* Cadre et poignée du bloc sélectionné */
#cadre { position: absolute; pointer-events: none; border: 1.5px solid var(--bleu); border-radius: 6px; opacity: .55; }
#poignee { position: absolute; display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--trait); border-radius: 9px; padding: 3px; box-shadow: var(--ombre); }
#poignee button { width: 28px; height: 26px; border: 0; background: none; border-radius: 6px; cursor: pointer; font-size: 14px; padding: 0; }
#poignee button:hover { background: var(--bleu-clair); }
#poignee button.rouge:hover { background: #fdecec; }

/* Fenêtres (aperçu PDF, historique) */
.fenetre { position: fixed; inset: 0; z-index: 50; background: rgba(15, 25, 40, .55); display: grid; place-items: center; padding: 24px; }
.fenetre .boite { background: #fff; border-radius: 14px; width: min(1000px, 100%); height: min(92vh, 100%); display: flex; flex-direction: column; overflow: hidden; }
.fenetre .boite.petite { width: min(460px, 100%); height: auto; max-height: 80vh; }
.fenetre .tete { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--trait); }
.fenetre .tete b { flex: 1; }
.fenetre iframe { flex: 1; border: 0; background: #666; }
.fenetre .liste { overflow-y: auto; padding: 10px; }
.fenetre .liste button { display: block; width: 100%; text-align: left; font: inherit; padding: 10px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.fenetre .liste button:hover { background: var(--bleu-clair); }
.option { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 400; margin: 0; cursor: pointer; }

#b-blocs { display: none; }
.grille > *, .recents > * { min-width: 0; }
.recent span { min-width: 0; overflow-wrap: anywhere; }
.barre .nom { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =====================================================================
   TÉLÉPHONE (écran de moins de 760 px de large)
   ===================================================================== */
@media (max-width: 760px) {
  /* Les champs font 16 px : en dessous, l'iPhone zoome tout seul quand on tape dedans */
  input:where(:not([type=radio]):not([type=checkbox]):not([type=range])), select { font-size: 16px; }
  .txt { display: none; }

  /* ---------- Barre du haut ---------- */
  .barre { padding: 8px 12px; gap: 8px; }
  .marque { font-size: 17px; gap: 8px; }
  .marque img { height: 28px; }
  .barre nav { gap: 12px; font-size: 13px; min-width: 0; }
  .barre .nom { max-width: 84px; }

  /* ---------- Pages ---------- */
  .page { padding: 18px 14px 50px; }
  h1 { font-size: 21px; line-height: 1.25; }
  .message { margin: 12px 14px 0; }
  .titre-page { gap: 10px; }
  .titre-page > div:first-child { flex-basis: 100%; }
  .titre-page input[type=search] { width: 100%; order: 3; }
  .titre-page .menu { flex: 1; }
  .titre-page .menu > summary { width: 100%; }
  .section { margin: 22px 0 10px; }
  .carte { padding: 16px; }

  /* Dossiers et fichiers : 2 colonnes */
  .grille { grid-template-columns: 1fr 1fr; gap: 12px; }
  .dossier .corps { min-height: 104px; padding: 12px; }
  .dossier b { font-size: 14px; overflow-wrap: anywhere; }
  .recents { grid-template-columns: 1fr; gap: 8px; }
  .fichier .apercu { height: 74px; }
  .fichier .apercu .picto { font-size: 34px; }
  .fichier .infos { padding: 10px 2px 12px 12px; }
  .fichier .infos b { font-size: 13.5px; overflow-wrap: anywhere; }
  .fichier > .menu { padding: 8px 6px 0 0; }

  /* Les petits menus deviennent un panneau en bas de l'écran */
  .bulle, .bulle.droite { position: fixed; left: 10px; right: 10px; bottom: 10px; top: auto; width: auto; z-index: 60; max-height: 80dvh; overflow-y: auto; box-shadow: 0 0 0 100vmax rgba(15, 25, 40, .45), 0 10px 30px rgba(20, 30, 50, .3); }
  .bulle .ligne { padding: 11px 8px; font-size: 15px; }

  /* Administration */
  .client .tete { flex-direction: column; align-items: stretch; }
  .client .actions { flex-direction: column; gap: 10px; }
  .client .actions form { flex-wrap: wrap; }
  .client .actions input, .client .actions select { width: 100%; flex: 1 1 100%; }
  .client .actions .bouton { flex: 1; }

  /* ---------- Éditeur ---------- */
  .ed-haut { padding: 6px 8px; gap: 6px; }
  .ed-haut .retour { font-size: 20px; padding: 4px 6px; }
  .ed-haut #titre { font-size: 16px; padding: 6px; }
  .ed-haut .bouton { padding: 8px 10px; font-size: 16px; }
  #etat { min-width: 0; font-size: 0; }                       /* on ne garde qu'une pastille de couleur */
  #etat::before { content: "●"; font-size: 14px; color: #2e9e6b; }
  #etat.erreur::before { color: var(--rouge); }

  /* Barre d'outils : une seule ligne, qu'on fait glisser du doigt */
  .ed-outils { flex-wrap: nowrap; overflow-x: auto; padding: 4px 8px; min-height: 44px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .ed-outils::-webkit-scrollbar { display: none; }
  .ed-outils > * { flex: none; }
  .ed-outils button, .ed-outils select { height: 36px; min-width: 36px; }
  /* Les outils de contexte (ligne, image…) flottent au-dessus des boutons du bas */
  #contexte { position: fixed; left: 8px; right: 8px; bottom: 62px; z-index: 30; margin: 0; padding: 4px 8px; overflow-x: auto; box-shadow: var(--ombre); border: 1px solid #f3c98c; }
  #contexte button { height: 36px; flex: none; }

  .ed-zone { padding: 10px 8px 130px; }
  .feuille { margin: 0; }

  /* Poignée du bloc : en bas à gauche, à l'horizontale */
  #poignee { position: fixed; left: 8px !important; top: auto !important; bottom: 10px; flex-direction: row; z-index: 30; padding: 4px; }
  #poignee button { width: 40px; height: 38px; font-size: 17px; }

  /* Bouton « ＋ Bloc » en bas à droite, et la liste des blocs en panneau */
  #b-blocs { display: inline-flex; position: fixed; right: 8px; bottom: 10px; z-index: 30; padding: 11px 16px; font-size: 15px; box-shadow: var(--ombre); }
  .ed-blocs { display: none; position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 62dvh; z-index: 40; border-right: 0; border-top: 1px solid var(--trait); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(20, 30, 50, .25); padding: 14px 12px 24px; }
  .ed-blocs.ouvert { display: block; }
  .ed-blocs button { padding: 10px 8px; font-size: 15px; }

  .fenetre { padding: 8px; }
}
.recent .picto { flex: none; }
