/* Assistant pro — theme sobre, institutionnel. Lisible sur telephone et PC. */
:root {
  --navy: #16244e;
  --navy-profond: #0c1738;
  --rouge: #c01627;
  --bleu: #2f5fb0;
  --gris: #8b9199;
  --fond: #f4f7fc;
  --carte: #ffffff;
  --texte: #1b2540;
  --bord: #dde4f0;
  --ombre: 0 1px 3px rgba(12, 23, 56, .12), 0 1px 2px rgba(12, 23, 56, .08);
  --rayon: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* En-tete */
.entete {
  background: var(--carte);
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--navy), var(--rouge)) 1;
  padding: env(safe-area-inset-top) 16px 0;
  position: sticky; top: 0; z-index: 10;
  box-shadow: var(--ombre);
}
.marque { display: flex; align-items: center; gap: 12px; padding: 14px 0 10px; }
.pastille {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--navy), var(--bleu));
  flex: 0 0 auto;
}
.marque h1 { font-size: 19px; margin: 0; color: var(--navy); letter-spacing: .2px; }
.sous-titre { margin: 2px 0 0; font-size: 12.5px; color: var(--gris); text-transform: capitalize; }

.onglets { display: flex; gap: 4px; }
.onglet {
  border: 0; background: none; padding: 10px 14px; cursor: pointer;
  font-size: 14px; color: var(--gris); font-weight: 600;
  border-bottom: 2.5px solid transparent; transition: .15s;
}
.onglet:hover { color: var(--navy); }
.onglet.actif { color: var(--navy); border-bottom-color: var(--rouge); }

/* Vues */
main { max-width: 820px; margin: 0 auto; padding: 16px; }
.vue { display: none; }
.vue.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.barre {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.champ-date { display: flex; align-items: center; gap: 8px; }
.champ-date label { font-size: 13px; color: var(--gris); font-weight: 600; }

/* Controles */
input, textarea, select {
  font: inherit; color: var(--texte);
  border: 1px solid var(--bord); border-radius: 8px; padding: 9px 11px;
  background: var(--carte); width: 100%;
}
input[type="date"] { width: auto; }
#champ-recherche { font-size: 16px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--bleu); box-shadow: 0 0 0 3px rgba(47,95,176,.15);
}

.bouton {
  background: var(--navy); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: .15s; white-space: nowrap;
}
.bouton:hover { background: var(--bleu); }
.lien {
  background: none; border: 0; color: var(--bleu); cursor: pointer;
  font-size: 13.5px; font-weight: 600; padding: 6px 8px; border-radius: 6px;
}
.lien:hover { background: rgba(47,95,176,.1); }
.lien.danger { color: var(--rouge); }
.lien.danger:hover { background: rgba(192,22,39,.1); }

.filtres { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.puce {
  border: 1px solid var(--bord); background: var(--carte); color: var(--gris);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.puce.actif { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Listes / cartes */
.liste { display: flex; flex-direction: column; gap: 10px; }
.carte {
  background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 14px 16px; box-shadow: var(--ombre); cursor: pointer; transition: .12s;
  border-left: 4px solid var(--gris);
}
.carte:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(12,23,56,.14); }
.carte.fait { opacity: .58; border-left-color: #43a047; }
.carte.en_cours { border-left-color: var(--bleu); }
.carte.a_faire { border-left-color: var(--rouge); }
.carte.type-compte_rendu { border-left-color: var(--bleu); }
.carte.type-procedure { border-left-color: var(--navy); }

.carte-haut { display: flex; align-items: baseline; gap: 10px; }
.carte-titre { font-weight: 700; font-size: 15.5px; color: var(--navy); flex: 1; }
.carte-meta { font-size: 12px; color: var(--gris); white-space: nowrap; }
.carte-extrait { margin: 6px 0 0; font-size: 13.5px; color: #4a5878; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11.5px; color: var(--bleu); background: rgba(47,95,176,.1);
  padding: 2px 8px; border-radius: 999px; font-weight: 600; }

.statut-bouton {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  border: 0; cursor: pointer; text-transform: uppercase; letter-spacing: .3px;
}
.s-a_faire { background: rgba(192,22,39,.12); color: var(--rouge); }
.s-en_cours { background: rgba(47,95,176,.12); color: var(--bleu); }
.s-fait { background: rgba(67,160,71,.15); color: #2e7d32; }

.vide { text-align: center; color: var(--gris); padding: 40px 20px; font-size: 14px; }
.section-titre { font-size: 12px; font-weight: 700; color: var(--gris);
  text-transform: uppercase; letter-spacing: .5px; margin: 8px 2px 2px; }

/* Modale */
.modale-fond {
  position: fixed; inset: 0; background: rgba(7,15,38,.5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
  padding: 0; backdrop-filter: blur(2px);
}
.modale-fond[hidden] { display: none; }
.modale {
  background: var(--carte); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px;
  padding: 20px; max-height: 90vh; overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.modale h2 { margin: 0 0 16px; color: var(--navy); font-size: 18px; }
.modale-form-champ { margin-bottom: 13px; }
.modale-form-champ label { display: block; font-size: 12.5px; font-weight: 600;
  color: var(--gris); margin-bottom: 5px; }
.modale-form-rangee { display: flex; gap: 10px; }
.modale-form-rangee > * { flex: 1; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.modale-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }

@media (min-width: 620px) {
  .modale-fond { align-items: center; }
  .modale { border-radius: 16px; }
}

/* --- Ajouts bloc A ----------------------------------------------------- */
.onglets { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.onglet { white-space: nowrap; }
.filtres .sep { width: 1px; align-self: stretch; background: var(--bord); margin: 2px 2px; }
.aide { margin: 0; font-size: 12.5px; color: var(--gris); flex: 1; }

/* Badges de type d'action */
.type-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
.t-appel { background: rgba(67,160,71,.15); color: #2e7d32; }
.t-relance { background: rgba(192,22,39,.12); color: var(--rouge); }
.t-tache { background: rgba(47,95,176,.12); color: var(--bleu); }
.t-note { background: rgba(139,145,153,.18); color: #5b636e; }
.carte.type-appel { border-left-color: #43a047; }
.carte.type-relance { border-left-color: var(--rouge); }
.carte.type-note { border-left-color: var(--gris); }
.carte.source-capture { border-left-style: dashed; }

.carte-pied { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-appeler {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  background: #43a047; color: #fff; padding: 6px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 700;
}
.btn-appeler:hover { background: #2e7d32; }
.contact-lien { font-size: 12.5px; color: var(--gris); }

/* Cartes contact */
.carte.contact { border-left-color: var(--bleu); cursor: pointer; }
.contact-init { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--navy), var(--bleu)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.contact-rangee { display: flex; align-items: center; gap: 12px; }

/* Liste de fichiers joints (dans la modale) */
.fichiers-zone { margin-top: 14px; border-top: 1px solid var(--bord); padding-top: 12px; }
.fichiers-zone h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--gris); margin: 0 0 8px; }
.fichier-ligne { display: flex; align-items: center; gap: 8px; padding: 7px 0;
  font-size: 13.5px; border-bottom: 1px solid var(--fond); }
.fichier-ligne a { color: var(--bleu); text-decoration: none; flex: 1; font-weight: 600; }
.fichier-taille { font-size: 11.5px; color: var(--gris); }
.btn-export { display: inline-block; margin-top: 6px; }

/* Éditeur plein écran (prise de notes) */
.editeur { position: fixed; inset: 0; background: var(--fond); z-index: 60;
  display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 0; }
.editeur[hidden] { display: none; }
.editeur-barre { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--bord); background: var(--carte); }
.editeur-etat { flex: 1; font-size: 12.5px; color: var(--gris); }
.editeur-titre { border: 0; border-radius: 0; font-size: 19px; font-weight: 700;
  color: var(--navy); padding: 14px 16px 6px; background: transparent; }
.editeur-titre:focus { box-shadow: none; }
.editeur-corps { flex: 1; border: 0; border-radius: 0; resize: none; font-size: 16px;
  line-height: 1.6; padding: 8px 16px 16px; background: transparent; }
.editeur-corps:focus { box-shadow: none; }

/* IA + réglages */
.btn-reglages { background: none; border: 0; font-size: 20px; cursor: pointer;
  padding: 4px 6px; border-radius: 8px; line-height: 1; }
.btn-reglages:hover { background: var(--fond); }
.bouton.ia { background: linear-gradient(135deg, #5a86d8, #2f5fb0); }
.bouton.ia:hover { background: linear-gradient(135deg, #2f5fb0, #16244e); }
.lien.ia { color: #2f5fb0; }
.lien.ia:hover { background: rgba(47,95,176,.12); }
.bouton:disabled, .lien:disabled { opacity: .55; cursor: progress; }

#reponse-ia:empty { display: none; }
.reponse-ia { background: var(--carte); border: 1px solid var(--bord); border-left: 4px solid var(--bleu);
  border-radius: var(--rayon); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--ombre); }
.reponse-ia h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--bleu); }
.reponse-ia .corps { font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; color: var(--texte); }
.reponse-ia .sources { margin-top: 10px; font-size: 12px; color: var(--gris); }
.reglages-statut { font-size: 13px; font-weight: 600; padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; }
.statut-ok { background: rgba(67,160,71,.15); color: #2e7d32; }
.statut-non { background: rgba(192,22,39,.1); color: var(--rouge); }
.reglages-aide { font-size: 12px; color: var(--gris); margin: -6px 0 12px; line-height: 1.4; }

/* Écran d'authentification */
.auth-fond { position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(160deg, var(--navy-profond), #13234c);
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-fond[hidden] { display: none; }
.auth-carte { background: var(--carte); border-radius: 16px; padding: 28px 24px;
  width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.35); text-align: center; }
.auth-carte .pastille { width: 48px; height: 48px; border-radius: 12px; margin: 0 auto 14px; }
.auth-carte h2 { margin: 0 0 6px; color: var(--navy); font-size: 20px; }
.auth-sous { margin: 0 0 18px; font-size: 13.5px; color: var(--gris); line-height: 1.45; }
.auth-carte input { margin-bottom: 12px; font-size: 16px; }
.auth-erreur { background: rgba(192,22,39,.1); color: var(--rouge); font-size: 13px;
  font-weight: 600; padding: 9px 11px; border-radius: 8px; margin-bottom: 12px; }
.auth-erreur[hidden] { display: none; }
#auth-code { text-transform: uppercase; letter-spacing: 1px; font-family: ui-monospace, monospace; }
.code-secours { font-family: ui-monospace, monospace; font-size: 20px; font-weight: 700;
  letter-spacing: 1px; color: var(--navy); background: var(--fond); border: 1px dashed var(--bleu);
  border-radius: 10px; padding: 14px; margin-bottom: 12px; word-break: break-all; }

/* ===== Notes : recherche + calendrier ===== */
.lbl-bureau { display: none; }
#notes-recherche { font-size: 16px; margin-bottom: 14px; }
#notes-recherche[hidden], .calendrier[hidden], #notes-jour-titre[hidden] { display: none; }
.calendrier { background: var(--carte); border: 1px solid var(--bord); border-radius: 12px;
  padding: 14px; margin-bottom: 14px; box-shadow: var(--ombre); }
.cal-tete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-tete h3 { margin: 0; font-size: 16px; color: var(--navy); text-transform: capitalize; }
.cal-nav { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--bleu);
  padding: 2px 12px; border-radius: 8px; line-height: 1; }
.cal-nav:hover { background: var(--fond); }
.cal-grille { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendrier { max-width: 440px; }
.cal-jour-nom { text-align: center; font-size: 11px; font-weight: 700; color: var(--gris);
  text-transform: uppercase; padding: 4px 0; min-width: 0; overflow: hidden; }
.cal-cell { aspect-ratio: 1; min-width: 0; border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 13.5px; cursor: pointer;
  border: 1.5px solid transparent; }
.cal-cell:hover { background: var(--fond); }
.cal-cell.vide { cursor: default; }
.cal-cell.aujourdhui { border-color: var(--bleu); font-weight: 700; }
.cal-cell.actif { background: var(--navy); color: #fff; }
.cal-cell.a-notes { font-weight: 700; color: var(--navy); }
.cal-cell.a-notes.actif { color: #fff; }
.cal-pastille { width: 5px; height: 5px; border-radius: 50%; background: var(--rouge); margin-top: 3px; }
.cal-cell.actif .cal-pastille { background: #fff; }

/* ===== Version BUREAU (barre latérale) ===== */
@media (min-width: 900px) {
  body { display: flex; align-items: stretch; min-height: 100vh; }
  .entete { position: sticky; top: 0; height: 100vh; flex: 0 0 240px; width: 240px;
    border-bottom: none; border-image: none; border-right: 1px solid var(--bord);
    box-shadow: none; display: flex; flex-direction: column; padding: 0; }
  .marque { padding: 22px 18px 14px; }
  .onglets { flex-direction: column; gap: 5px; padding: 10px 12px; overflow-y: auto; }
  .onglet { width: 100%; text-align: left; justify-content: flex-start; border-bottom: none;
    border-radius: 10px; padding: 12px 14px; font-size: 15px; }
  .onglet.actif { background: var(--navy); color: #fff; border-bottom: none; }
  .onglet.actif:hover { background: var(--bleu); }
  .lbl-bureau { display: inline; }
  .entete::after { content: ""; display: block; margin-top: auto;
    height: 3px; background: linear-gradient(90deg, var(--navy), var(--rouge)); }
  main { flex: 1; max-width: 1100px; margin: 0 auto; padding: 26px 34px; width: 100%; }
  .liste { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .section-titre { grid-column: 1 / -1; }
  .editeur-corps { min-height: 55vh; }
}

/* ===== Refonte navigation : barre du bas (mobile) + FAB ===== */
.btn-icone { background: none; border: 0; font-size: 20px; cursor: pointer;
  padding: 4px 6px; border-radius: 8px; line-height: 1; }
.btn-icone:hover { background: var(--fond); }
.onglet .ic { font-size: 15px; }

/* Mobile (défaut) : onglets du haut cachés, barre du bas visible */
.onglets { display: none; }
.barre-onglets { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: flex-end; justify-content: space-around;
  background: var(--carte); border-top: 1px solid var(--bord);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(12,23,56,.07); }
.bo { background: none; border: 0; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 2px; font-size: 10.5px; color: var(--gris); flex: 1; padding: 3px 0; font-weight: 600; }
.bo .ic { font-size: 21px; }
.bo.actif { color: var(--navy); }
.bo-fab { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--navy); color: #fff; font-size: 32px; line-height: 1; font-weight: 300;
  box-shadow: 0 4px 12px rgba(12,23,56,.35); transform: translateY(-12px); }
.bo-fab:active { transform: translateY(-12px) scale(.94); }
main { padding-bottom: 88px; }

@media (min-width: 900px) {
  .onglets { display: flex; }
  .onglet { display: flex; align-items: center; gap: 11px; }
  .barre-onglets, .mobile-only { display: none !important; }
  main { padding-bottom: 26px; }
}

/* Sur mobile, le bouton « + » central (FAB) remplace les boutons d'ajout en tête de vue */
@media (max-width: 899px) {
  #btn-new-action, #btn-new-note, #btn-new-fiche, #btn-new-contact { display: none; }
}

/* Onglets de l'éditeur de note (Corrigée / Brute) */
.editeur-onglets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 0 10px; }
.editeur-onglets .puce { font-size: 12.5px; padding: 5px 12px; }

/* Badge "À traiter" (note non traitée par l'IA) + corbeille */
.badge-traiter { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  background: rgba(239,159,39,.18); color: #a56100; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; align-self: center; margin-right: 2px; }
.carte.a-traiter { border-left-color: #ef9f27; border-left-style: dashed; }
.btn-icone.danger { color: var(--rouge); font-size: 18px; }
.btn-icone.danger:hover { background: rgba(192,22,39,.1); }

/* ===== Assistant conversationnel ===== */
#vue-recherche.active { display: flex; flex-direction: column; height: calc(100dvh - 168px); }
.assistant-log { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column;
  gap: 10px; padding: 6px 2px 12px; }
.bulle { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: 14.5px;
  line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.bulle.assistant { background: var(--carte); border: 1px solid var(--bord);
  align-self: flex-start; border-bottom-left-radius: 4px; color: var(--texte); }
.bulle.moi { background: var(--navy); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.assistant-saisie { flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 8px 0 4px; border-top: 1px solid var(--bord); background: var(--fond); }
.assistant-saisie input { flex: 1; font-size: 16px; }
#assistant-envoyer { padding: 9px 15px; font-size: 16px; }
#toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(16px);
  background: #1e7d34; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 13.5px;
  font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.28); opacity: 0; pointer-events: none;
  transition: .25s; z-index: 60; max-width: 90%; text-align: center; }
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 900px) {
  #vue-recherche.active { height: calc(100dvh - 90px); max-width: 760px; }
  #toast { bottom: 30px; }
}
