:root{
  --green:#16a34a; --green-dark:#0f7a38; --soft:#ecfdf5; --text:#0f172a;
  --muted:#475569; --white:#fff; --border:#e2e8f0;
  --shadow:0 10px 25px rgba(2,6,23,.06);
}

/* Base */
*{ box-sizing:border-box; }
html{ height:100%; }

body{
  margin:0;
  padding:0;
  min-height:100%;
  display:flex;
  flex-direction:column;          /* header / main / footer en colonne */
  font-family:Inter,system-ui,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--soft);
  color:var(--text);
}

a{ color:inherit; text-decoration:none; }
a:focus,button:focus,input:focus,select:focus,textarea:focus{
  outline:3px solid #22c55e55; outline-offset:2px;
}

.container{ max-width:1100px; margin:0 auto; padding:20px; }

/* Header */
.header{ background:var(--green); color:#fff; box-shadow:var(--shadow); }
.nav{ display:flex; justify-content:space-between; align-items:center; padding:18px 20px; gap:10px; flex-wrap:wrap; }
.brand{ display:flex; gap:12px; align-items:center; }
.logo{ width:34px; height:34px; border-radius:50%; background:radial-gradient(circle at 30% 30%,#22c55e 0,#16a34a 60%,#0f7a38 100%); }
.brand strong{ font-size:clamp(20px,3vw,32px); }
.menu{ display:flex; gap:16px; align-items:center; flex-wrap:wrap; }
.menu a{ color:#eaffea; padding:8px 10px; border-radius:10px; }
.menu a:hover{ background:#15803d; }

/* Hero */
.hero{ padding:50px 20px; text-align:center; }
.hero h1{ margin:0 0 10px; font-size:clamp(28px,5vw,46px); }
.hero p{ margin:6px auto 0; max-width:820px; color:#0b3b1f; }

/* Boutons */
.btn{
  display:inline-block; background:var(--green); color:#fff; border:0;
  border-radius:14px; padding:12px 16px; font-weight:800; box-shadow:var(--shadow); cursor:pointer;
}
.btn:hover{ background:var(--green-dark); }
.btn-outline{ background:transparent; border:2px solid var(--green); color:var(--green); }
.btn.xxs{ padding:2px 6px; font-size:.72rem; border-radius:6px; }
button.link{ background:none; border:0; color:var(--green); cursor:pointer; }
button.link.xxs{ font-size:.72rem; }

/* Niveaux */
.levels{ display:flex; gap:16px; justify-content:center; flex-wrap:wrap; margin-top:20px; }
.level-btn{ display:inline-block; background:#16a34a; color:#fff; padding:18px 22px; border-radius:16px; font-weight:800; box-shadow:var(--shadow); }
.level-btn:hover{ background:#0f7a38; }

/* === GRILLES GÉNÉRIQUES (sessions, niveaux, séquences…) === */
.grid{
  display:grid;
  gap:1.25rem;
  grid-template-columns:repeat(2,minmax(0,1fr)); /* 2 cartes par ligne */
}

/* 3 cartes par ligne (comme session.php) */
.grid-3{ grid-template-columns:repeat(3,minmax(0,1fr)); }

/* 2 cartes par ligne (pour sequence.php) */
.grid-2{ grid-template-columns:repeat(2,minmax(0,1fr)); }

/* Grille responsive */
@media (max-width:1100px){
  .grid-3, .grid-2{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}
@media (max-width:720px){
  .grid, .grid-3, .grid-2{
    grid-template-columns:1fr; /* 1 carte par ligne sur mobile */
  }
}

/* Cartes */
.card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px;
  box-shadow:var(--shadow);
  font-size:.9rem;

  /* IMPORTANT WYSIWYG: ne coupe pas le contenu */
  overflow:visible;

  /* évite que Chrome imprime en coupant l’intérieur d’une carte */
  break-inside:avoid;
  page-break-inside:avoid;
}
.card h3{ margin:8px 0 6px; }

/* Badge */
.badge{
  display:inline-block;
  background:#dcfce7;
  color:#065f46;
  border:1px solid #bbf7d0;
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
}

/* TABLEAUX — compacts et confinés */
.table{
  width:100%;
  border-collapse:separate; border-spacing:0;
  background:#fff; border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow);
  overflow:hidden; max-width:100%; table-layout:fixed;
  font-size:.78rem;
}
.table th,.table td{
  padding:8px 10px;
  border-bottom:1px solid var(--border);
  text-align:left; vertical-align:middle;

  /* ⚠️ pour éviter des surprises print: autoriser les retours */
  word-break:break-word;
  white-space:normal;
}
.table th{
  background:#f8fafc; color:var(--muted); text-transform:uppercase; font-weight:600; font-size:.7rem;
}
.table tr:hover td{ background:#f9fdfb; }

/* Colonnes étroites pour “Liste des séquences” */
.col-pub{ width:64px; text-align:center; }
.col-level{ width:56px; text-align:center; }
.col-num{ width:48px; text-align:center; }
.col-actions{ width:140px; text-align:center; }
.col-title{ width:auto; }
.col-title .title-text{ display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:100%; }
.table .sep{ margin:0 4px; color:#94a3b8; }

/* Formulaires */
input,select,textarea{
  width:100%;
  padding:10px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
  font-size:.9rem;
}
.row{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }

/* CASES À COCHER — ultra compactes */
.checkbox-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(160px,1fr));
  gap:4px; margin:6px 0;
}
.checkbox-grid > label{
  display:flex; align-items:center; gap:6px;
  padding:3px 5px; border:0; border-radius:6px;
  background:transparent; box-shadow:none; line-height:1.2;
}
.checkbox-grid input[type="checkbox"]{ margin:0; transform:scale(0.9); }
.checkbox-grid span{
  font-size:.82rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.checkbox-grid > label:hover{ background:#f1f5f9; }

/* Divers */
.footer{
  background:#0f5132; color:#eaffe7;
  margin-top:40px;
}
.footer .container{ padding:26px 20px; }
.small{ font-size:13px; color:var(--muted); }
.actions a{ margin-right:10px; }
.notice{ background:#ecfeff; border:1px solid #a5f3fc; padding:10px; border-radius:10px; }
.error{ color:#b91c1c; }
.back{ display:inline-block; margin:8px 0; color:#0f5132; }

/* main = zone centrale qui doit “pousser” le footer en bas */
.main{ flex:1; }

@media (max-width:700px){
  .row{ grid-template-columns:1fr; }
  .card{ font-size:.85rem; padding:10px; }
  .table{ font-size:.74rem; }
  .table th,.table td{ padding:6px 8px; }
  .checkbox-grid{ grid-template-columns:1fr; }
}

/* Style des titres de séquence */
.card h3{
  margin:8px 0 6px;
  line-height:1.3;
  font-size:1rem;
}
.card h3 .seq-num{
  color:#007bff;
  font-weight:700;
  display:block;
  margin-bottom:4px;
}
.card h3 .seq-title{
  color:#0f172a;
  font-weight:600;
  display:block;
}

/* Mots clés en bleu (Séquence, Séance) */
.kw-blue{ color:#007bff; font-weight:700; }

/* Niveau (5e/4e/3e) mis en valeur */
.kw-level{ color:#007bff; font-weight:700; font-size:1.1rem; }

/* Lien d'action principal (Ouvrir / Télécharger) */
.link-primary{ color:#007bff; font-weight:700; text-decoration:none; }
.link-primary:hover{ text-decoration:underline; }

/* “Séquence 1” sous le H1 : plus grand et dense */
.seq-meta{
  font-size:1.35rem;
  font-weight:800;
  margin:2px 0 10px;
  line-height:1.1;
}

/* lien “⟵ 3e” en haut : bleu + plus grand */
.back-level{
  color:#007bff;
  font-weight:700;
  font-size:1.15rem;
}
.back-level:hover{ text-decoration:underline; }

/* --- Bloc complet de chaque document dans l'administration --- */
ul.docs-admin li.doc-item{
  margin:8px 0;
  padding:12px;
  border:1px solid #dcdfe3;
  border-radius:10px;
  background:#f6f7f9;
  box-shadow:0 1px 2px rgba(0,0,0,0.04);
}
ul.docs-admin li.doc-item:hover{ background:#eef1f5; }

/* liens "Ouvrir" en bleu */
a.ouvrir, a.ouvrir:visited{
  color:#007bff;
  font-weight:600;
  text-decoration:underline;
}
a.ouvrir:hover{ text-decoration-thickness:2px; }

.card a{
  color:#0066ff;
  font-weight:600;
}

.session-list li{ margin-bottom:12px; }

/* --- Cartes de documents dans les séances / séquences (fond bleu clair) --- */
.doc-card{
  margin:8px 0;
  padding:10px;
  border-radius:10px;
  border:1px solid #bfdbfe;
  background:#eff6ff;
}

/* =========================================================
   WYSIWYG A4 (écran = impression = PDF)
   ========================================================= */

/*
  UTILISATION (recommandée) :
  - Sur les pages à imprimer/PDF : entoure le contenu par <div class="sheet"> ... </div>
  - Mets ta grille des cartes dedans.
*/
.sheet{
  width:210mm;
  min-height:297mm;
  padding:10mm;                 /* marges papier */
  box-sizing:border-box;
  background:#fff;
  margin:12px auto;
  box-shadow:var(--shadow);
  border:1px solid var(--border);
}

/* Optionnel: si tu veux une zone “à imprimer” sans toucher trop au HTML */
.print-area{
  width:210mm;
  min-height:297mm;
  padding:10mm;
  box-sizing:border-box;
  background:#fff;
  margin:12px auto;
  box-shadow:var(--shadow);
  border:1px solid var(--border);
}

/* Pour les pages WYSIWYG, on stabilise les unités (évite surprises à l’impression) */
.sheet, .print-area{
  font-size:10pt;
  line-height:1.2;
}

/* Si tes cartes “étiquettes” doivent être strictes, utilise mm plutôt que rem */
.sheet .grid, .print-area .grid{
  gap:6mm;
}

/* =========================================================
   Impression / PDF
   ========================================================= */
@page{
  size:A4;
  margin:0;   /* la marge est gérée par .sheet/.print-area */
}

@media print{
  html, body{
    margin:0 !important;
    padding:0 !important;
    background:#fff !important;
  }

  /* On évite header/footer du site si besoin (décommente si tu veux)
  .header, .footer, .nav, .menu, .hero { display:none !important; }
  */

  /* La feuille prend exactement la page */
  .sheet, .print-area{
    margin:0 !important;
    width:210mm !important;
    min-height:297mm !important;
    height:297mm !important;
    box-shadow:none !important;
    border:none !important;
    page-break-after:always;
  }

  /* Empêche coupures internes */
  .card{
    break-inside:avoid !important;
    page-break-inside:avoid !important;
  }

  /* Conserve couleurs de fond (si tu en as) */
  *{
    -webkit-print-color-adjust:exact;
    print-color-adjust:exact;
  }
}
