/* ===== Conditions Generales de Vente B2B (/cgv) =====
   Document contractuel : la lisibilite prime sur l'effet. Fond clair dans
   tous les themes (un contrat se lit et s'imprime sur fond blanc), largeur de
   ligne bornee, ancres decalees sous la barre de navigation fixe. */

.cgv-page {
    --cgv-encre: #1e293b;
    --cgv-encre-douce: #475569;
    --cgv-trait: #e2e8f0;
    --cgv-fond: #f5f6fb;
    --cgv-carte: #ffffff;
    --cgv-bleu: #4f46e5;
    --cgv-violet: #7c3aed;
    --cgv-lien: #4338ca;
    --cgv-lien-survol: #6d28d9;
    background: var(--cgv-fond);
    color: var(--cgv-encre);
    padding: 88px 0 72px;
    min-height: 100vh;
}

.cgv-conteneur {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

.cgv-page a:not(.cgv-bouton):not(.cgv-retour-haut) {
    color: var(--cgv-lien);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.cgv-page a:not(.cgv-bouton):not(.cgv-retour-haut):hover { color: var(--cgv-lien-survol); }
.cgv-page a:focus-visible,
.cgv-page button:focus-visible {
    outline: 3px solid var(--cgv-violet);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---- Barre d'actions ---- */
.cgv-barre {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 20px;
}
.cgv-statut {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.cgv-statut--vigueur { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.cgv-statut--future { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.cgv-statut--archive { background: #fffbeb; color: #92400e; border-color: #fde68a; }

.cgv-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cgv-bouton {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 9px 16px;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--cgv-bleu);
    background: var(--cgv-carte);
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none !important;
    transition: background-color .15s ease, border-color .15s ease;
}
.cgv-bouton:hover { background: #eef2ff; border-color: #a5b4fc; }
.cgv-bouton--principal {
    color: #fff;
    background: linear-gradient(135deg, var(--cgv-bleu), var(--cgv-violet));
    border-color: transparent;
}
.cgv-bouton--principal:hover { background: linear-gradient(135deg, #4338ca, #6d28d9); }
.cgv-bouton--discret { border-color: var(--cgv-trait); color: var(--cgv-encre-douce); }
.cgv-bouton-detail { font-weight: 400; color: var(--cgv-encre-douce); }

/* ---- Corps : en-tete, sommaire, document ---- */
.cgv-corps {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
}

.cgv-entete {
    background: var(--cgv-carte);
    border: 1px solid var(--cgv-trait);
    border-top: 4px solid var(--cgv-violet);
    border-radius: 16px;
    padding: 32px 36px;
    scroll-margin-top: 110px;
}
.cgv-surtitre {
    margin: 0 0 6px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cgv-violet);
}
.cgv-titre {
    margin: 0 0 6px;
    font-size: clamp(1.7rem, 3.2vw, 2.4rem);
    font-weight: 800;
    line-height: 1.2;
    color: #0f172a;
}
.cgv-sous-titre {
    margin: 0 0 18px;
    font-size: 1.05rem;
    color: var(--cgv-encre-douce);
}
.cgv-version {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0;
    padding: 10px 16px;
    font-size: 1rem;
    color: #312e81;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
}
.cgv-version-sep { color: #818cf8; }

.cgv-sommaire {
    background: var(--cgv-carte);
    border: 1px solid var(--cgv-trait);
    border-radius: 16px;
    padding: 20px 22px;
}
.cgv-sommaire-titre {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}
.cgv-sommaire ol {
    margin: 0;
    padding-left: 1.6em;
    font-size: 0.9rem;
    line-height: 1.45;
    columns: 2 260px;
    column-gap: 28px;
}
.cgv-sommaire li { margin: 0 0 6px; break-inside: avoid; color: var(--cgv-encre-douce); }
.cgv-sommaire a { text-decoration: none; }
.cgv-sommaire a:hover { text-decoration: underline; }

.cgv-document {
    background: var(--cgv-carte);
    border: 1px solid var(--cgv-trait);
    border-radius: 16px;
    padding: 12px 40px 32px;
    min-width: 0;
}

@media (min-width: 1080px) {
    .cgv-corps {
        grid-template-columns: 280px minmax(0, 1fr);
        grid-template-areas:
            "entete entete"
            "sommaire document";
        align-items: start;
    }
    .cgv-entete { grid-area: entete; }
    .cgv-sommaire {
        grid-area: sommaire;
        position: sticky;
        top: 96px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
    .cgv-sommaire ol { columns: auto; }
    .cgv-document { grid-area: document; }
}

/* ---- Articles ---- */
.cgv-article {
    max-width: 74ch;
    padding: 22px 0 8px;
    border-bottom: 1px solid #eef0f5;
    scroll-margin-top: 104px;
}
.cgv-article:last-of-type { border-bottom: 0; }
.cgv-article h2 {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin: 0 0 14px;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
    color: #0f172a;
}
.cgv-art-num {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cgv-violet);
}
.cgv-article h3 {
    margin: 22px 0 10px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e1b4b;
}
.cgv-article p,
.cgv-article li,
.cgv-article dd {
    font-size: 1rem;
    line-height: 1.72;
    color: var(--cgv-encre);
}
.cgv-article p { margin: 0 0 12px; }
.cgv-article ul,
.cgv-article ol { margin: 0 0 14px; padding-left: 1.4em; }
.cgv-article li { margin-bottom: 6px; }
.cgv-num {
    display: inline-block;
    min-width: 2.6em;
    margin-right: 4px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--cgv-bleu);
}

.cgv-encadre {
    margin: 12px 0 14px;
    padding: 16px 20px;
    background: #f8f9ff;
    border-left: 4px solid var(--cgv-bleu);
    border-radius: 0 10px 10px 0;
}
.cgv-encadre p { margin: 0 0 4px; }
.cgv-encadre p:last-child { margin-bottom: 0; }

.cgv-exemple {
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    font-size: 0.95rem !important;
}

.cgv-definitions { margin: 0 0 12px; }
.cgv-definitions dt {
    margin-top: 12px;
    font-weight: 700;
    color: #1e1b4b;
}
.cgv-definitions dd { margin: 2px 0 0; }

.cgv-tableau-conteneur {
    overflow-x: auto;
    margin: 12px 0 16px;
    border: 1px solid var(--cgv-trait);
    border-radius: 10px;
}
.cgv-tableau {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.cgv-tableau caption {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--cgv-encre-douce);
    caption-side: top;
}
.cgv-tableau th,
.cgv-tableau td {
    padding: 10px 14px;
    text-align: left;
    vertical-align: top;
    border-top: 1px solid var(--cgv-trait);
    line-height: 1.5;
}
.cgv-tableau thead th {
    background: #f1f3fb;
    font-size: 0.85rem;
    color: #1e1b4b;
}
.cgv-tableau tbody th { font-weight: 600; color: #1e1b4b; }

.cgv-clause-apparente {
    margin: 16px 0 8px;
    padding: 18px 22px;
    background: #fff7ed;
    border: 2px solid #ea580c;
    border-radius: 12px;
}
.cgv-clause-apparente-titre {
    margin: 0 0 10px !important;
    font-size: 1rem !important;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #9a3412 !important;
}

.cgv-pied {
    max-width: 74ch;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid #eef0f5;
    font-size: 0.9rem;
    color: var(--cgv-encre-douce);
}
.cgv-pied p { margin: 0 0 4px; }

/* ---- Versions ---- */
.cgv-versions {
    margin-top: 24px;
    padding: 24px 32px;
    background: var(--cgv-carte);
    border: 1px solid var(--cgv-trait);
    border-radius: 16px;
    scroll-margin-top: 104px;
}
.cgv-versions h2 { margin: 0 0 8px; font-size: 1.2rem; font-weight: 700; color: #0f172a; }
.cgv-versions p { color: var(--cgv-encre-douce); line-height: 1.6; }
.cgv-empreinte {
    font-size: 0.78rem;
    word-break: break-all;
    color: var(--cgv-encre);
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 6px;
}
.cgv-pastille {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #065f46;
    background: #d1fae5;
    border-radius: 999px;
}
.cgv-liens-juridiques { margin: 14px 0 0; font-size: 0.92rem; }
.cgv-visuellement-cache {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---- Retour en haut (ancre : fonctionne sans JavaScript) ---- */
.cgv-retour-haut {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff !important;
    text-decoration: none !important;
    background: linear-gradient(135deg, var(--cgv-bleu), var(--cgv-violet));
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.28);
}

@media (max-width: 640px) {
    .cgv-page { padding: 80px 0 88px; }
    .cgv-conteneur { padding: 0 12px; }
    .cgv-entete { padding: 22px 18px; }
    .cgv-document { padding: 4px 18px 22px; }
    .cgv-versions { padding: 18px; }
    .cgv-sommaire ol { columns: auto; }
    .cgv-bouton { width: 100%; justify-content: center; }
    .cgv-actions { width: 100%; }
    .cgv-num { min-width: 0; }
    .cgv-tableau { font-size: 0.82rem; }
    .cgv-tableau th, .cgv-tableau td { padding: 8px 7px; }
    .cgv-tableau caption { padding: 8px 7px; }
    .cgv-empreinte { font-size: 0.7rem; }
    .cgv-retour-haut span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .cgv-retour-haut { right: 12px; bottom: 12px; padding: 10px 13px; }
}

@media (prefers-reduced-motion: no-preference) {
    html:has(.cgv-page) { scroll-behavior: smooth; }
}

/* ---- Impression / enregistrement en PDF depuis le navigateur ---- */
@media print {
    @page { size: A4; margin: 16mm 15mm 18mm; }
    html, body { background: #fff !important; }
    body > *:not(main),
    main > *:not(.cgv-page),
    .cgv-barre,
    .cgv-retour-haut,
    .cgv-versions,
    .skip-link { display: none !important; }
    .cgv-page { padding: 0; background: #fff; min-height: 0; }
    .cgv-conteneur { max-width: none; padding: 0; }
    .cgv-corps { display: block; }
    .cgv-entete, .cgv-sommaire, .cgv-document {
        border: 0; border-radius: 0; padding: 0; box-shadow: none; position: static; max-height: none; overflow: visible;
    }
    .cgv-entete { border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 14px; }
    .cgv-sommaire { margin-bottom: 10px; page-break-after: always; }
    .cgv-sommaire ol { columns: 2; }
    .cgv-article, .cgv-pied { max-width: none; }
    .cgv-page, .cgv-article p, .cgv-article li, .cgv-article dd { color: #000; font-size: 10.5pt; line-height: 1.5; }
    .cgv-article h2 { font-size: 13pt; page-break-after: avoid; }
    .cgv-article h3 { page-break-after: avoid; }
    .cgv-page a { color: #000; text-decoration: none; }
    .cgv-tableau-conteneur { overflow: visible; }
    .cgv-tableau, .cgv-clause-apparente, .cgv-encadre, .cgv-exemple { page-break-inside: avoid; }
    .cgv-clause-apparente { background: #fff; border: 2px solid #000; }
    .cgv-clause-apparente-titre { color: #000 !important; }
    .cgv-version { background: #fff; border: 1px solid #000; color: #000; }
}
