/*
 * Habillage commun des documents commerciaux imprimables.
 *
 * Objectifs de cette feuille :
 * - compacter proprement la partie haute des factures et proformas ;
 * - supprimer l'effet de carte arrondie autour du tableau principal ;
 * - conserver un rendu stable a l'ecran comme a l'impression.
 */

.document-sheet-body {
  padding: 0.85rem 1rem 1rem !important;
}

/*
 * Police cible des documents commerciaux.
 *
 * On reste volontairement sur des polices systeme pour ne pas alourdir le
 * projet et pour conserver un rendu fiable a l'ecran comme a l'impression.
 */
.document-sheet {
  font-family: Calibri, "Segoe UI", Arial, sans-serif !important;
  background: #ffffff !important;
  color: #0f172a !important;
}

.document-sheet .text-muted {
  color: #475569 !important;
}

.document-sheet.document-sheet .text-dark,
.document-sheet.document-sheet .text-dark:not(.badge) {
  color: #0f172a !important;
}

.document-sheet.document-sheet .border-dark {
  border-color: #0f172a !important;
}

.document-sheet.document-sheet .bg-light,
.document-sheet.document-sheet .bg-white {
  background-color: #f8fafc !important;
  color: #0f172a !important;
}

.document-header-row {
  margin-bottom: 0.75rem;
  align-items: flex-start;
}

.document-company-logo {
  display: block;
  max-height: 108px;
  max-width: 200px;
  margin-bottom: 0.5rem !important;
}

.document-company-column h2 {
  margin-bottom: 0.25rem;
  line-height: 1.08;
}

.document-company-meta {
  line-height: 1.28;
}

.document-company-meta > div + div {
  margin-top: 0.08rem;
}

.document-regime-label,
.document-company-meta > div:last-child {
  margin-top: 0.3rem !important;
}

.document-meta-column {
  padding-top: 0.1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.document-title-banner {
  margin-bottom: 0.4rem !important;
}

.document-title-banner h3 {
  line-height: 1;
}

.document-title-number {
  margin-bottom: 0.25rem;
  line-height: 1.1;
}

.document-meta-column > h5 {
  margin-bottom: 0.25rem;
  line-height: 1.1;
}

.document-meta-column .small {
  line-height: 1.25;
}

.document-meta-column .small + .small {
  margin-top: 0.08rem;
}

.document-client-row {
  margin-bottom: 0.75rem;
}

.document-client-box {
  padding: 0.55rem 0.75rem !important;
}

.document-client-box .row.mt-1 {
  margin-top: 0.25rem !important;
}

/*
 * Le style global des tableaux applique un conteneur arrondi.
 * Sur les documents commerciaux, on neutralise cet habillage
 * pour retrouver un tableau net et strictement rectangulaire.
 */
.document-lines-shell {
  margin-top: 0;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
}

.document-lines-shell > .table {
  margin-bottom: 0.85rem;
  border-radius: 0 !important;
  border-collapse: collapse !important;
  border-spacing: 0;
  border: 1.6px solid #0f172a !important;
  border-top: 1.8px solid #0f172a !important;
  background: #ffffff !important;
  color: #0f172a !important;
  font-size: 0.95rem;
  line-height: 1.25;
}

.document-lines-shell > .table,
.document-lines-shell > .table thead,
.document-lines-shell > .table tbody,
.document-lines-shell > .table tfoot,
.document-lines-shell > .table tr,
.document-lines-shell > .table th,
.document-lines-shell > .table td {
  border-radius: 0 !important;
}

/*
 * Lisibilite renforcee des lignes facture/proforma.
 *
 * Les documents doivent rester "papier" meme quand l'application est en
 * theme sombre : fond blanc, texte noir, bordures visibles et montants nets.
 */
.document-lines-shell > .table > thead > tr > th {
  background: #0d6efd !important;
  color: #ffffff !important;
  border: 1.3px solid #0f172a !important;
  padding: 0.82rem 0.75rem !important;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0;
  vertical-align: middle;
}

.document-lines-shell > .table > tbody > tr > *,
.document-lines-shell > .table > tfoot > tr > * {
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
  padding: 0.78rem 0.72rem !important;
  vertical-align: middle;
}

.document-lines-shell > .table > tbody > tr:nth-of-type(odd) > * {
  background: #ffffff !important;
}

.document-lines-shell > .table > tbody > tr:nth-of-type(even) > * {
  background: #f3f6fb !important;
}

.document-lines-shell > .table > tbody > tr:hover > * {
  background: #edf4ff !important;
}

.document-lines-shell > .table > tbody td:first-child {
  font-weight: 700;
}

.document-lines-shell > .table > tbody td:nth-last-child(1),
.document-lines-shell > .table > tbody td:nth-last-child(2),
.document-lines-shell > .table > tbody td:nth-last-child(3),
.document-lines-shell > .table > tfoot td.text-end {
  font-variant-numeric: tabular-nums;
}

.document-lines-shell > .table > tbody td.text-end,
.document-lines-shell > .table > tbody td.fw-bold,
.document-lines-shell > .table > tfoot td.text-end {
  color: #020617 !important;
}

.document-lines-shell > .table > tfoot > tr > * {
  background: #f8fafc !important;
}

.document-lines-shell > .table > tfoot > tr:first-child > * {
  border-top: 1.4px solid #94a3b8 !important;
}

.document-lines-shell > .table > tfoot tr.small > * {
  font-size: 0.9rem;
  font-weight: 700;
}

.document-lines-shell > .table > tfoot tr.bg-light > * {
  background: #eaf2ff !important;
  border-top: 1.8px solid #0f172a !important;
  border-bottom: 1.8px solid #0f172a !important;
  color: #020617 !important;
}

.document-lines-shell > .table > tfoot tr.bg-light td:last-child {
  font-size: 1.15rem !important;
  font-weight: 900 !important;
}

.document-lines-shell > .table .badge {
  font-weight: 800;
}

/*
 * En impression, la bordure superieure du tableau peut devenir tres faible,
 * surtout avec les variantes Bootstrap appliquees au thead.
 * On la renforce explicitement sur la table et sur la premiere rangee
 * d'en-tete pour garantir une ligne bien visible dans la facture et la proforma.
 */
.document-lines-shell > .table > thead {
  border-top: 1.8px solid #0f172a !important;
}

.document-lines-shell > .table > thead > tr:first-child > th {
  border-top: 1.8px solid #0f172a !important;
  border-color: #0f172a !important;
}

@media print {
  .document-sheet-body {
    padding: 0 !important;
  }

  .document-header-row {
    margin-bottom: 0.45rem !important;
  }

  .document-company-logo {
    max-height: 74px !important;
    margin-bottom: 0.35rem !important;
  }

  .document-company-column h2 {
    margin-bottom: 0.15rem;
  }

  .document-company-meta {
    line-height: 1.18;
  }

  .document-regime-label,
  .document-company-meta > div:last-child {
    margin-top: 0.18rem !important;
  }

  .document-title-banner {
    margin-bottom: 0.25rem !important;
  }

  .document-title-number {
    margin-bottom: 0.15rem;
  }

  .document-meta-column > h5 {
    margin-bottom: 0.15rem;
  }

  .document-client-row {
    margin-bottom: 0.45rem !important;
  }

  .document-client-box {
    padding: 0.35rem 0.5rem !important;
  }

  .document-lines-shell > .table {
    margin-bottom: 0.5rem !important;
    border: 1.4px solid #000 !important;
    border-top: 1.6px solid #000 !important;
    font-size: 0.88rem !important;
  }

  .document-lines-shell > .table > thead {
    border-top: 1.6px solid #000 !important;
  }

  .document-lines-shell > .table > thead > tr:first-child > th {
    border-top: 1.6px solid #000 !important;
    border-color: #000 !important;
  }

  .document-lines-shell > .table > thead > tr > th {
    background: #0d6efd !important;
    color: #ffffff !important;
    border-color: #000 !important;
    padding: 0.45rem 0.5rem !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .document-lines-shell > .table > tbody > tr > *,
  .document-lines-shell > .table > tfoot > tr > * {
    border-color: #9ca3af !important;
    padding: 0.42rem 0.5rem !important;
  }

  .document-lines-shell > .table > tbody > tr:nth-of-type(even) > *,
  .document-lines-shell > .table > tfoot > tr > * {
    background: #f5f7fb !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .document-lines-shell > .table > tfoot tr.bg-light > * {
    background: #eaf2ff !important;
    border-top-color: #000 !important;
    border-bottom-color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
