/* ── Documents RH — styles partagés (dashboard + app pointage) ────────
   Écran : cartes, pastilles, overlay lecture mobile, rendu document.
   Impression : en-tête versionné + bloc d'émargement, interface masquée. */

/* ---- Pastilles d'état ---- */
.docrh-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 12px;
  white-space: nowrap;
}
.docrh-chip-ok    { color: #166534; background: #dcfce7; }
.docrh-chip-todo  { color: #92400e; background: #fef3c7; }
.docrh-chip-late  { color: #991b1b; background: #fee2e2; }
.docrh-chip-muted { color: #6b7280; background: #f3f4f6; }

/* ---- Liste de documents (carte par doc) ---- */
.docrh-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1px dashed var(--border, #e5e7eb);
  cursor: pointer;
}
.docrh-item:last-child { border-bottom: none; }
.docrh-item-title { font-weight: 600; }
.docrh-item-sub {
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  margin-top: 2px;
}
.docrh-item-arrow { color: var(--text-muted, #9ca3af); font-size: 18px; flex: none; }

/* ---- Alerte "documents à signer" (onglet pointage) ---- */
.docrh-alerte {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #713f12;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 14px;
}
.docrh-alerte button {
  border: none;
  background: #92400e;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

/* ---- Rendu document (écran) ---- */
.docrh-meta { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 4px; }
.docrh-meta th, .docrh-meta td {
  text-align: left;
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--border, #e5e7eb);
  vertical-align: top;
}
.docrh-meta th { color: var(--text-muted, #6b7280); font-weight: 600; width: 130px; }

.docrh-content { line-height: 1.6; font-size: 15px; }
.docrh-content h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 18px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.docrh-content h3 { font-size: 15px; font-weight: 700; margin: 14px 0 4px; }
.docrh-content p { margin: 8px 0; }
.docrh-content ul { margin: 8px 0; padding-left: 22px; }
.docrh-content li { margin: 5px 0; }

.docrh-checklist { list-style: none !important; padding-left: 2px !important; }
.docrh-checklist li { display: flex; gap: 9px; align-items: flex-start; }
.docrh-checkbox {
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 3px;
  border: 1.5px solid #374151;
  border-radius: 3px;
  background: #fff;
}

/* ---- Zone signature (bas de document) ---- */
.docrh-sign-box {
  margin-top: 18px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 14px;
  background: #fafaf7;
}
.docrh-sign-box label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  cursor: pointer;
}
.docrh-sign-box input[type="checkbox"] { width: 18px; height: 18px; margin-top: 1px; flex: none; }
.docrh-sign-btn {
  margin-top: 12px;
  width: 100%;
  border: none;
  border-radius: 8px;
  background: #16803C;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 12px;
  cursor: pointer;
}
.docrh-sign-btn:disabled { opacity: .45; cursor: not-allowed; }
.docrh-signed-note {
  margin-top: 14px;
  font-size: 13px;
  color: #166534;
  background: #dcfce7;
  border-radius: 8px;
  padding: 10px 12px;
}

/* ---- Overlay lecture (app pointage mobile) ---- */
#docrh-overlay {
  position: fixed;
  inset: 0;
  z-index: 6000;
  background: var(--bg, #f5f5f2);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.docrh-overlay-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-bottom: 1px solid var(--border, #e5e7eb);
  padding: 10px 14px;
}
.docrh-overlay-bar .docrh-back {
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 600;
  color: #16803C;
  cursor: pointer;
  padding: 4px;
  white-space: nowrap;
}
.docrh-overlay-bar .docrh-bar-title {
  flex: 1;
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.docrh-print-btn {
  border: 1px solid var(--border, #d1d5db);
  background: #fff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.docrh-overlay-inner { max-width: 720px; margin: 0 auto; padding: 16px 16px 60px; }
.docrh-doc-header .docrh-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
}
.docrh-doc-header h2 { font-size: 19px; font-weight: 700; margin: 2px 0 2px; }
.docrh-doc-version { font-size: 12px; color: var(--text-muted, #6b7280); margin-bottom: 6px; }
.docrh-ref-note {
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  background: #f3f4f6;
  border-radius: 8px;
  padding: 7px 10px;
  margin: 10px 0;
}

/* Dirigeant (lecture seule) : pas de creation/edition/archivage, mais il
   peut consulter, imprimer et signer (le reglement s'applique aussi a lui). */
.readonly-mode [data-action="showCreateDocRH"],
.readonly-mode [data-action="syncDocsRH"],
.readonly-mode [data-action="showEditDocRH"] { display: none !important; }

/* ---- Cartes par famille de documents (dashboard) ---- */
.docrh-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--text-muted, #6b7280);
}
.docrh-group-card { padding: 0 !important; overflow: hidden; margin-bottom: 16px; }
.docrh-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: #faf8f3;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.docrh-group-icon { display: flex; color: #16803C; }
.docrh-group-icon svg { width: 19px; height: 19px; }
.docrh-group-name { font-size: 15.5px; font-weight: 700; color: #1a1d23; }
.docrh-group-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted, #6b7280);
  background: #eee9df;
  border-radius: 10px;
  padding: 1px 9px;
}

.docrh-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.docrh-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border, #eee);
  vertical-align: middle;
}
.docrh-table tbody tr:last-child td { border-bottom: none; }
.docrh-row { cursor: pointer; }
.docrh-row:hover td { background: #faf9f6; }
.docrh-row-archived { opacity: .55; }
.docrh-cell-title { font-weight: 600; font-size: 14px; }
.docrh-cell-sub { font-size: 12px; color: var(--text-muted, #6b7280); margin-top: 3px; }
.docrh-cell-sign { width: 38%; font-size: 12.5px; }
.docrh-cell-actions { white-space: nowrap; text-align: right; width: 1%; }
.docrh-cell-muted { font-size: 12px; color: var(--text-muted, #6b7280); }

/* État de signature : une phrase, pas une soupe de pastilles */
.docrh-sign-ok { color: #166534; font-weight: 600; white-space: nowrap; }
.docrh-sign-wait { color: var(--text-muted, #6b7280); line-height: 1.45; }
.docrh-sign-count {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  color: #92400e;
  background: #fef3c7;
  border-radius: 10px;
  padding: 1px 8px;
  margin-right: 7px;
  vertical-align: 1px;
}

/* Actions de ligne : liens discrets, pas des boutons pleins */
.docrh-action {
  border: none;
  background: none;
  color: var(--text-muted, #6b7280);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
}
.docrh-action:hover { color: #1a1d23; background: #efede8; }

/* ---- Mobile : le tableau devient une pile de cartes ---- */
@media (max-width: 768px) {
  /* Boutons d'en-tête empilés pleine largeur (convention .page-header) */
  #page-docsrh .page-header > div {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }
  #page-docsrh .page-header .btn { width: 100%; justify-content: center; }

  .docrh-table,
  .docrh-table tbody,
  .docrh-table tr,
  .docrh-table td {
    display: block;
    width: 100%;
  }
  .docrh-table td { padding: 3px 16px; border-bottom: none; }
  .docrh-row { display: block; padding: 12px 0; border-bottom: 1px solid var(--border, #e5e7eb); }
  .docrh-row:last-child { border-bottom: none; }
  .docrh-row:hover td { background: transparent; }
  .docrh-cell-title { font-size: 15px; }
  .docrh-cell-sign { width: auto; padding-top: 6px; }
  .docrh-cell-actions { text-align: left; width: auto; padding-top: 10px; }
  .docrh-cell-actions .docrh-action {
    border: 1px solid var(--border, #e5e7eb);
    background: #fff;
    padding: 7px 14px;
    margin: 0 8px 0 0;
  }
}

/* ══════════ IMPRESSION ══════════ */
#docrh-print-root { display: none; }

@media print {
  @page { size: A4; margin: 16mm 15mm 18mm; }

  body.docrh-printing > *:not(#docrh-print-root) { display: none !important; }
  body.docrh-printing #docrh-print-root {
    display: block;
    background: #fff;
    color: #111;
    font-size: 11.5pt;
    line-height: 1.55;
  }

  .docrh-print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    border-bottom: 2px solid #111;
    padding-bottom: 4px;
    margin-bottom: 14px;
  }
  .docrh-print-brand { font-size: 14pt; font-weight: 700; }
  .docrh-print-headmeta { text-align: right; font-size: 9pt; color: #444; }
  .docrh-print-title { font-size: 16pt; font-weight: 700; margin: 0 0 8px; }

  #docrh-print-root h2, #docrh-print-root h3 {
    break-after: avoid;
    page-break-after: avoid;
  }
  #docrh-print-root li, #docrh-print-root .docrh-meta { break-inside: avoid; }
  #docrh-print-root .docrh-content h2 { border-bottom: 1px solid #999; }
  #docrh-print-root .docrh-meta th { width: 40mm; }

  .docrh-checkbox { border: 1.5pt solid #000; background: #fff; }

  .docrh-print-footer {
    margin-top: 8mm;
    padding-top: 2mm;
    border-top: 1px solid #999;
    font-size: 9pt;
    color: #444;
  }

  .docrh-signature-block {
    display: flex;
    gap: 6mm;
    margin-top: 8mm;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .docrh-signature-frame {
    flex: 1 1 0;
    border: 1pt solid #111;
    padding: 4mm;
    font-size: 10pt;
  }
  .docrh-signature-frame p { margin: 2mm 0 0; }
  .docrh-signature-title { font-weight: 700; margin: 0 !important; }
  .docrh-signature-space { padding-bottom: 16mm; }
}
