/**
 * Dossier de financement — feuille de style dediee.
 * Le layout report.php ne charge ni global.css ni responsive.css : le document
 * doit sortir propre a l'impression (A4) sans heriter du chrome du site.
 */

* { box-sizing: border-box; }

.report-body {
    margin: 0;
    padding: 0 0 var(--space-3xl);
    background: #e2e8f0;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* ====== Barre d'action (ecran uniquement) ====== */
.report-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.report-toolbar-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
}

.report-toolbar-back:hover { color: var(--primary); }

.report-print-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: var(--text-white);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.report-print-btn:hover { background: var(--primary-dark); }

/* ====== Bandeau specimen (apercu public) ====== */
.report-specimen-banner {
    max-width: 820px;
    margin: var(--space-lg) auto 0;
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--primary);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    background: var(--primary-bg);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.5;
}

.report-specimen-banner a {
    color: var(--primary);
    font-weight: 700;
    white-space: nowrap;
}

/* ====== Feuille ====== */
.report {
    position: relative;
    max-width: 820px;
    margin: var(--space-xl) auto;
    padding: var(--space-2xl);
    background: var(--bg-white);
    box-shadow: var(--shadow-lg);
}

/* Filigrane "SPÉCIMEN" — ecran ET impression, pour que l'apercu gratuit
   ne puisse pas etre presente comme un vrai dossier. */
.report-body--specimen .report::before {
    content: "SPÉCIMEN";
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 5.5rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: rgba(124, 58, 237, 0.08);
    pointer-events: none;
    z-index: 0;
    white-space: nowrap;
}

.report-body--specimen .report > * { position: relative; z-index: 1; }

.report-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--primary);
}

.report-head-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.05rem;
    font-weight: 500;
}

.report-head-brand strong { font-weight: 800; }

.report-head-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.report-title {
    margin: var(--space-lg) 0 var(--space-xs);
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.report-subtitle {
    margin: 0 0 var(--space-xl);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.report-section { margin-bottom: var(--space-2xl); }

.report-section h2 {
    margin: 0 0 var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
    font-size: 1.25rem;
    font-weight: 700;
}

.report-section h3 {
    margin: var(--space-lg) 0 var(--space-sm);
    font-size: 1rem;
    font-weight: 700;
}

.report-section p { margin: 0 0 var(--space-md); }

/* ====== KPI ====== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
}

.kpi-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.kpi-formula {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.is-positive { color: var(--positive); }
.is-negative { color: var(--negative); }

.report-lede {
    padding: var(--space-md);
    border-left: 3px solid var(--primary);
    background: var(--primary-bg);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ====== Tableaux ====== */
.report-table {
    width: 100%;
    margin-bottom: var(--space-lg);
    border-collapse: collapse;
    font-size: 0.88rem;
}

.report-table caption {
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: left;
    font-style: italic;
}

.report-table thead th {
    padding: var(--space-sm);
    border-bottom: 2px solid var(--border);
    background: var(--bg);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
}

.report-table tbody th {
    padding: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
    font-weight: 500;
    text-align: left;
}

.report-table tbody td {
    padding: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
}

.report-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.report-table .row-total th,
.report-table .row-total td {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    font-weight: 700;
}

.report-table tbody th small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 400;
}

.row-flag {
    display: block;
    margin-top: 2px;
    color: var(--negative);
    font-size: 0.72rem;
    font-style: normal;
}

.row-best th,
.row-best td {
    background: var(--positive-bg);
    font-weight: 700;
}

.row-out th,
.row-out td { opacity: 0.55; }

.report-table.amort tbody tr:nth-child(even) th,
.report-table.amort tbody tr:nth-child(even) td {
    background: var(--bg);
}

/* ====== Encarts ====== */
.report-note,
.report-verdict {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.report-note {
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-secondary);
}

.report-verdict {
    border-left: 3px solid var(--primary);
    background: var(--primary-bg);
    font-size: 0.95rem;
    font-weight: 500;
}

.report-limits {
    margin: 0 0 var(--space-md);
    padding-left: var(--space-lg);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.report-limits li { margin-bottom: var(--space-sm); }

.report-disclaimer {
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ====== Aperçu avant paiement (embarqué dans le dashboard) ======
   Rejoue le vrai livrable rempli avec la saisie de l'acheteur, mais clampé,
   filigrané et coiffé d'un dégradé : on prouve le document sans en livrer la
   version propre. Doit rester visible sous le CTA, y compris sur mobile. */
.report-preview {
    position: relative;
    margin: var(--space-lg) 0;
}

.report-preview-sheet {
    position: relative;
    max-height: 560px;
    overflow: hidden;
    padding: var(--space-md) var(--space-md) 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: #e2e8f0;
    -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 62%, transparent 100%);
}

/* La feuille interne : on neutralise les marges d'impression pour tenir dans le cadre. */
.report-preview-sheet .report {
    max-width: none;
    margin: 0 auto;
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

.report-preview-stamp {
    position: absolute;
    top: 46%;
    left: 50%;
    z-index: 3;
    transform: translate(-50%, -50%) rotate(-24deg);
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(124, 58, 237, 0.16);
    pointer-events: none;
    white-space: nowrap;
}

.report-preview-veil {
    margin: 0;
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: var(--primary-bg);
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.5;
}

/* ====== Mobile ====== */
@media (max-width: 720px) {
    .report { margin: 0; padding: var(--space-lg); box-shadow: none; }
    .kpi-row { grid-template-columns: 1fr; }
    .report-head { flex-direction: column; align-items: flex-start; }
    .report-head-meta { align-items: flex-start; }
    .report-title { font-size: 1.5rem; }
}

@media (max-width: 900px) {
    .report-preview-sheet { max-height: 440px; padding: var(--space-sm) var(--space-sm) 0; }
    .report-preview-sheet .report { padding: var(--space-md); }
    .report-preview-stamp { font-size: 2.6rem; }
}

/* ====== Impression ====== */
@page {
    size: A4;
    margin: 14mm 12mm;
}

@media print {
    .report-body { background: #fff; padding: 0; font-size: 10.5pt; }
    .no-print { display: none !important; }

    .report {
        max-width: none;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }

    .report-section { margin-bottom: 18pt; }
    .page-break { break-before: page; page-break-before: always; }

    .report-section,
    .report-table,
    .kpi-row,
    .report-lede,
    .report-note,
    .report-verdict { break-inside: avoid; page-break-inside: avoid; }

    .report-table.amort { break-inside: auto; page-break-inside: auto; }
    .report-table.amort thead { display: table-header-group; }
    .report-table tr { break-inside: avoid; page-break-inside: avoid; }

    h2, h3 { break-after: avoid; page-break-after: avoid; }

    /* Filigrane specimen repete sur chaque page imprimee. */
    .report-body--specimen::before {
        content: "SPÉCIMEN";
        position: fixed;
        top: 45%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(-30deg);
        font-size: 90pt;
        font-weight: 800;
        letter-spacing: 0.1em;
        color: rgba(124, 58, 237, 0.10);
        z-index: 0;
    }

    .report-body--specimen .report::before { display: none; }
}
