/* ============================================================
   Feuille de style — style "émargement" institutionnel
   Sobre, lisible, imprimable. Compatible avec tous les PHP fournis.
   ============================================================ */

:root {
  /* Palette sobre institutionnelle */
  --bg:            #F4F6F8;
  --surface:       #FFFFFF;
  --surface-alt:   #F8FAFC;
  --border:        #D6DCE4;
  --border-strong: #B8C2CE;
  --text:          #1F2933;
  --text-muted:    #5B6773;
  --primary:       #1E4E8C;   /* bleu institutionnel */
  --primary-dark:  #163A69;
  --primary-light: #E8F0FA;
  --success:       #1E7A46;
  --success-light: #E6F4EC;
  --error:         #B3261E;
  --error-light:   #FCE9E7;

  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.container.narrow { max-width: 440px; padding-top: 80px; }

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--border);
}
.hero-icon {
  font-size: 44px;
  margin-bottom: 12px;
  display: inline-block;
}
.hero h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0 0 10px;
  color: var(--primary-dark);
}
.subtitle {
  color: var(--text-muted);
  margin: 0;
  font-size: 15px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card.center { text-align: center; }

.card h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Documents scrollables ---------- */
.doc-reader { margin-bottom: 12px; }

.doc-scroll {
  max-height: 340px;
  overflow-y: auto;
  padding: 22px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  position: relative;
}
.doc-scroll::after {
  content: "";
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: block;
  height: 36px;
  margin: 0 -22px -22px;
  background: linear-gradient(to bottom, transparent, var(--surface-alt));
  pointer-events: none;
}
.doc-scroll h2 {
  font-size: 16px;
  margin: 0 0 14px;
  color: var(--primary);
  border: none;
  padding: 0;
  text-transform: none;
  letter-spacing: 0;
}
.doc-scroll p { margin: 0 0 12px; }

/* Barre de progression */
.doc-progress {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.doc-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width .15s ease;
}

/* Statut */
.doc-status {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 18px;
  transition: color .2s;
}
.doc-status.done {
  color: var(--success);
  font-weight: 600;
}

/* ---------- Champs ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.hint {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Cases à cocher ---------- */
.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.check:hover { background: var(--primary-light); }
.check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}
.check-locked {
  opacity: .55;
  cursor: not-allowed;
}
.check-locked input { cursor: not-allowed; }
.check-unlocked {
  opacity: 1;
  cursor: pointer;
  border-color: var(--success);
  background: var(--success-light);
}

/* ---------- Boutons ---------- */
.btn-primary,
.btn-outline,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background .15s, box-shadow .15s, transform .1s;
}
.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border-strong);
  padding: 9px 18px;
  font-size: 14px;
}
.btn-outline:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
.btn-danger {
  background: var(--error);
  color: #fff;
  padding: 8px 14px;
  font-size: 13px;
}
.btn-danger:hover { background: #8f1d17; }

/* ---------- Alertes ---------- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 14px;
}
.alert ul { margin: 0; padding-left: 20px; }
.alert-error {
  background: var(--error-light);
  color: var(--error);
  border: 1px solid #f3c4c0;
}

/* ---------- Texte légal ---------- */
.legal {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 14px 16px;
  background: var(--surface-alt);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  margin: 20px 0;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  margin-top: 28px;
  font-size: 14px;
  color: var(--text-muted);
}
.footer a {
  color: var(--primary);
  text-decoration: none;
}
.footer a:hover { text-decoration: underline; }

/* ---------- Succès ---------- */
.success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--success-light);
  color: var(--success);
  font-size: 38px;
  font-weight: 700;
  margin-bottom: 18px;
}

/* ---------- Admin : header + stats ---------- */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
}
.admin-header h1 {
  font-size: 24px;
  margin: 0 0 4px;
  color: var(--primary-dark);
}
.muted { color: var(--text-muted); font-size: 14px; margin: 0; }
.center { text-align: center; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-value {
  font-size: 38px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tableau ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
}
thead th {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--primary-light); }
td.right { text-align: right; }
td.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Impression (feuille d'émargement) ---------- */
@media print {
  body { background: #fff; }
  .container { max-width: 100%; padding: 0; }
  .card {
    box-shadow: none;
    border: 1px solid #000;
    page-break-inside: avoid;
  }
  .btn-primary, .btn-outline, .btn-danger,
  .footer, .doc-progress, .doc-status { display: none !important; }
  .doc-scroll { max-height: none; overflow: visible; border: none; }
  .admin-header { border-bottom: 2px solid #000; }
  thead th { background: #eee !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .container { padding: 24px 16px 60px; }
  .card { padding: 20px; }
  .hero h1 { font-size: 22px; }
  .stat-value { font-size: 30px; }
}
.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #b8e0c8;
}
