/* =============================================================================
   Impression
   1) Pages ordinaires de l'application (chargé avec media="print") : on masque
      l'interface et on garde le contenu.
   2) Documents (gabarit app/views/print.php, chargé pour tous les médias) :
      feuille A4 avec en-tête et mentions légales.
   ============================================================================= */

@page { size: A4; margin: 12mm 14mm 26mm; }

@media print {
    body { background: #fff; color: #000; }
    .entete, .menu, .compte, .actions, .message, .bouton, .doc-outils { display: none !important; }
    .contenu { max-width: none; padding: 0; }
    .carte { border: 0; box-shadow: none; padding: 0; }
    a { color: #000; text-decoration: none; }
    .tableau th, .tableau td { border-bottom: 1px solid #999; }
}

/* --- Documents --------------------------------------------------------------- */
.doc-corps {
    margin: 0;
    background: #e9ecf0;
    color: #111;
    font: 10.5pt/1.4 "Segoe UI", Roboto, Arial, sans-serif;
}

.doc-outils {
    position: sticky; top: 0; z-index: 1;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: .6rem 1rem; background: #1f4e79;
}
.doc-outils a { color: #fff; }
.doc-outils button {
    min-height: 40px; padding: .4rem 1rem; border: 0; border-radius: 6px;
    background: #fff; color: #1f4e79; font: inherit; font-weight: 600; cursor: pointer;
}

.doc-feuille {
    width: 210mm; max-width: 100%; min-height: 297mm;
    margin: 1rem auto; padding: 12mm 14mm;
    background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
    display: flex; flex-direction: column;
}

.doc-entete {
    display: flex; align-items: center; gap: 6mm;
    padding-bottom: 4mm; border-bottom: 2px solid #1f4e79;
}
.doc-logo { max-width: 45mm; max-height: 28mm; object-fit: contain; }
.doc-societe p { margin: 0; }
.doc-raison { font-size: 15pt; font-weight: 700; color: #1f4e79; letter-spacing: .02em; }
.doc-activites { font-size: 9pt; font-style: italic; color: #444; margin-bottom: 1mm !important; }

.doc-contenu { flex: 1; padding: 8mm 0; }
.doc-titre { font-size: 14pt; font-weight: 700; text-align: center; letter-spacing: .05em; }

.doc-pied {
    border-top: 1px solid #999; padding-top: 2mm;
    font-size: 7.5pt; color: #333; text-align: center;
}
.doc-pied p { margin: 0; }

.doc-exemple { color: #555; }

/* --- Devis, factures, avoirs --------------------------------------------------- */
.doc-vente { position: relative; color: #111; font-size: 10.5pt; line-height: 1.4; }
.doc-vente p { margin: 0; }
.doc-filigrane {
    margin: 0 0 4mm !important; padding: 2mm; text-align: center; font-weight: 700; letter-spacing: .1em;
    color: #b3261e; border: 2px dashed #b3261e;
}
.doc-bloc-haut { display: flex; justify-content: space-between; gap: 8mm; margin-bottom: 5mm; }
.doc-titre-gauche { text-align: left; margin-bottom: 1mm !important; font-size: 15pt; color: #1f4e79; }
.doc-client { min-width: 70mm; max-width: 90mm; padding: 3mm 4mm; border: 1px solid #1f4e79; border-radius: 2mm; }
.doc-client-libelle { font-size: 8pt; text-transform: uppercase; letter-spacing: .08em; color: #555; }
.doc-client-nom { font-weight: 700; font-size: 11.5pt; }
.doc-references { border-collapse: collapse; margin-bottom: 4mm; }
.doc-references th { text-align: left; padding: .5mm 4mm .5mm 0; color: #555; font-weight: 600; vertical-align: top; white-space: nowrap; }
.doc-references td { padding: .5mm 0; }
.doc-lignes { width: 100%; border-collapse: collapse; margin-bottom: 4mm; }
.doc-lignes th { background: #1f4e79; color: #fff; padding: 1.5mm 2mm; text-align: left; font-size: 9pt; }
.doc-lignes td { padding: 1.5mm 2mm; border-bottom: 1px solid #ccc; vertical-align: top; }
.doc-lignes .nombre, .doc-totaux td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-lignes tbody tr { break-inside: avoid; }
.doc-totaux { margin-left: auto; border-collapse: collapse; min-width: 80mm; break-inside: avoid; }
.doc-totaux th { text-align: left; padding: 1mm 4mm 1mm 0; font-weight: 600; }
.doc-totaux td { padding: 1mm 0; }
.doc-total-ttc th, .doc-total-ttc td { border-top: 2px solid #1f4e79; font-size: 12pt; font-weight: 700; color: #1f4e79; padding-top: 2mm; }
.doc-lettres { margin: 5mm 0 3mm !important; break-inside: avoid; }
.doc-mention { margin-top: 1.5mm !important; font-size: 9.5pt; }
.doc-signature { display: flex; justify-content: flex-end; margin-top: 8mm; break-inside: avoid; }
.doc-signature p { width: 70mm; height: 28mm; border: 1px dashed #999; padding: 2mm; text-align: center; color: #555; font-size: 9pt; }

/* --- Bon de livraison ---------------------------------------------------------- */
.doc-options { color: #fff; font-size: .95rem; }
.doc-options a { color: #fff; }
.doc-options strong { color: #fff; text-decoration: underline; }
.doc-exemplaire { margin-top: 1mm !important; font-size: 8.5pt; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #555; }
.doc-receptions { display: flex; gap: 6mm; margin-top: 8mm; break-inside: avoid; }
.doc-cadre { flex: 1; min-height: 38mm; border: 1px solid #999; border-radius: 2mm; padding: 2.5mm 3mm; font-size: 9.5pt; }
.doc-cadre p { margin: 0 0 2mm !important; }
.doc-cadre-titre { font-weight: 700; color: #1f4e79; }
.doc-cadre-note { font-size: 8.5pt; font-style: italic; color: #444; }

/* --- Lettre de relance ---------------------------------------------------------- */
.doc-objet { margin: 6mm 0 4mm !important; }
.doc-paragraphe { margin: 0 0 3mm !important; text-align: justify; }
.doc-lettre .doc-lignes { margin-top: 4mm; }

/* Aperçu dans l'application */
.apercu-document { overflow-x: auto; }
@media screen and (max-width: 700px) {
    .doc-bloc-haut { flex-direction: column; }
    .doc-client { min-width: 0; max-width: none; }
    .doc-signature { display: none; }
    .doc-receptions { flex-direction: column; }
}

@media print {
    .doc-corps { background: #fff; }
    .doc-feuille { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
    .doc-feuille + .doc-feuille { break-before: page; }   /* 2e exemplaire sur une nouvelle page */
    /* Le pied se répète en bas de chaque page imprimée */
    .doc-pied { position: fixed; bottom: -18mm; left: 0; right: 0; }
}

@media screen and (max-width: 820px) {
    .doc-feuille { margin: 0; padding: 6mm; min-height: 0; }
    .doc-entete { flex-direction: column; align-items: flex-start; }
}
