/* Reset CSS */
* {
    box-sizing: border-box;
}

/* Styles généraux */
.print-only {
    display: none !important;
}

/* Screen Only Styles */
.screen-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    background-color: #f8f9fa;
    padding: 20px;
}

.screen-intro h1 {
    font-size: 3rem;
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: bold;
}

.screen-intro h2 {
    font-size: 2rem;
    color: #d4af37;
    margin-bottom: 40px;
}

.screen-intro .actions {
    display: flex;
    gap: 20px;
}

/* Styles d'impression */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        margin: 0;
        padding: 0;
        background: white;
        font-family: Arial, sans-serif;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        font-size: 14px; /* Increased font size for 1 per page */
    }

    .no-print, 
    .screen-intro,
    header, 
    footer, 
    .navbar, 
    .site-title-banner, 
    .header-carousel, 
    #back-to-top,
    .partners-marquee,
    .profile-menu { 
        display: none !important; 
    }

    .print-only {
        display: block !important;
        width: 100%;
    }

    /* --- PAGE STRUCTURES --- */

    /* Common Page Frame */
    .cover-page,
    .toc,
    .domain-intro-page,
    .level-intro-page,
    .formation-card,
    .jpo-section {
        border: 4px solid #2c3e50; /* Thick dark blue border */
        position: relative;
        box-shadow: inset 0 0 0 2px white, inset 0 0 0 6px #d4af37; /* Gold inner border effect */
    }

    /* 1. COVER PAGE (Poster Style) */
    .cover-page {
        width: 210mm;
        height: 296mm; /* Reduced slightly to prevent blank page */
        position: relative;
        page-break-after: always;
        overflow: hidden;
        background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
        display: flex;
        flex-direction: column;
        margin: 0;
        padding: 0;
    }

    .cover-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px 40px;
        height: 150px;
    }

    .header-logo-academie img {
        height: 80px;
        object-fit: contain;
    }

    .header-title-box {
        background-color: #ffe0b2 !important;
        padding: 15px 25px;
        border: 2px solid #ffe0b2;
        box-shadow: inset 0 0 0 1000px #ffe0b2 !important;
    }

    .header-title-box h1 {
        font-size: 20px;
        color: #2c3e50 !important;
        text-align: right;
        margin: 0;
        line-height: 1.2;
        text-transform: uppercase;
        font-weight: bold;
    }

    .cover-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: relative;
    }
    
    .cover-content.domain-mode {
        justify-content: flex-start;
        padding-top: 40px;
    }

    .cover-title-main {
        background-color: #ffe0b2 !important;
        color: #2c3e50 !important;
        padding: 40px 60px;
        transform: rotate(-2deg);
        box-shadow: 10px 10px 0 rgba(0,0,0,0.1), inset 0 0 0 5px white;
        max-width: 80%;
        text-align: center;
        margin-bottom: 60px;
        z-index: 10;
        border: 4px solid #d4af37;
    }

    .cover-title-main h2 {
        font-size: 36px;
        margin: 0;
        text-transform: uppercase;
        letter-spacing: 2px;
        line-height: 1.3;
    }

    .cover-subtitle {
        margin-top: 15px;
        font-size: 18px;
        color: #444;
        font-style: italic;
    }
    
    .domain-estabs-container {
        width: 80%;
        margin-top: 0;
        text-align: left;
        background: white;
        padding: 20px;
        border-radius: 10px;
        border: 1px solid #eee;
    }

    .domain-estabs-title {
        font-size: 18px;
        color: #d4af37;
        margin-bottom: 20px;
        text-align: center;
        text-transform: uppercase;
        border-bottom: 2px solid #d4af37;
        padding-bottom: 10px;
        width: 100%;
        font-weight: bold;
    }

    .domain-estabs-list {
        column-count: 2;
        column-gap: 40px;
        margin: 0;
        padding: 0;
        list-style-type: none;
    }

    .domain-estabs-list li {
        margin-bottom: 8px;
        font-size: 14px;
        break-inside: avoid;
        page-break-inside: avoid;
        color: #2c3e50;
    }

    .cover-footer {
        position: absolute;
        bottom: 40px;
        left: 40px;
        right: 40px;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        height: 100px;
    }

    .footer-logo-lpro img { height: 120px; object-fit: contain; }
    .footer-qr img { width: 100px; height: 100px; object-fit: contain; }
    .footer-logo-greta img { height: 60px; object-fit: contain; }

    /* 2. DOMAIN INTRO PAGE */
    .domain-intro-page {
        width: 210mm;
        height: 296mm;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        page-break-after: always;
        text-align: center;
        background: white;
    }

    .domain-intro-title {
        font-size: 48px;
        color: #2c3e50;
        text-transform: uppercase;
        margin-bottom: 20px;
        border-bottom: 5px solid #d4af37;
        padding-bottom: 20px;
    }

    /* 3. LEVEL SEPARATOR PAGE */
    .level-intro-page {
        width: 210mm;
        height: 296mm;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        page-break-after: always;
        text-align: center;
        background: #f9f9f9 !important; /* Slight grey background */
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .level-intro-domain {
        font-size: 24px;
        color: #666;
        margin-bottom: 20px;
    }

    .level-intro-title {
        font-size: 40px;
        color: #2c3e50;
        font-weight: bold;
    }

    /* 4. FORMATION CARD (2-Column Layout - 1 Per Page) */
    .formation-card {
        padding: 40px; /* Increased padding */
        page-break-after: always !important; /* Force page break after each formation */
        page-break-inside: avoid;
        height: 296mm; /* Use full page height */
        display: flex;
        flex-direction: column;
    }
    
    /* Removed nth-of-type logic to force 1 per page */
    
    .formation-card:last-child {
        page-break-after: always !important; /* Even last one breaks before JPO section */
    }

    .card-header {
        border-bottom: 3px solid #d4af37;
        padding-bottom: 15px;
        margin-bottom: 30px;
        text-align: center;
    }

    .card-title {
        color: #2c3e50;
        font-size: 24px; /* Increased for visibility */
        margin: 0;
        text-transform: uppercase;
        font-weight: bold;
        line-height: 1.3;
    }

    .card-meta {
        font-size: 14px;
        color: #666;
        margin-top: 10px;
    }

    .formation-body {
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    .details-grid-2col {
        column-count: 2;
        column-gap: 40px;
        width: 100%;
        margin-bottom: 20px;
    }

    .establishments-full-width {
        width: 100%;
        background-color: #f8f9fa !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        padding: 20px;
        border-radius: 10px;
        height: fit-content;
        margin-top: 20px; /* Space between details and establishments */
    }

    .estabs-grid-2col {
        column-count: 2;
        column-gap: 40px;
    }

    .estab-item {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 15px;
        background: white;
        padding: 10px;
        border-radius: 5px;
        border-left: 3px solid #d4af37;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .estab-name {
        font-weight: bold;
        color: #2c3e50;
        display: block;
    }
    
    .badge {
        font-size: 10px;
        padding: 3px 6px;
        border-radius: 3px;
        text-transform: uppercase;
        font-weight: bold;
        border: 1px solid #ccc; /* Fallback border */
    }
    
    .badge-warning {
        background-color: #ffc107 !important;
        color: #212529 !important;
        border-color: #ffc107;
    }
    
    .badge-info {
        background-color: #17a2b8 !important;
        color: white !important;
        border-color: #17a2b8;
    }
    
    .badge-secondary {
        background-color: #6c757d !important;
        color: white !important;
        border-color: #6c757d;
    }

    .detail-section {
        margin-bottom: 20px;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .section-label {
        font-weight: bold;
        color: #2c3e50; /* Changed to dark blue for contrast */
        font-size: 14px;
        text-transform: uppercase;
        margin-bottom: 8px;
        border-bottom: 1px solid #eee;
        padding-bottom: 4px;
        display: block;
    }

    /* Icons for Section Labels */
    .section-label::before {
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        margin-right: 10px;
        display: inline-block;
        width: 20px;
        text-align: center;
        color: #d4af37;
        font-size: 16px;
    }

    .label-duree::before { content: "\f017"; } /* Clock */
    .label-famille::before { content: "\f0b1"; } /* Briefcase */
    .label-objectifs::before { content: "\f140"; } /* Bullseye */
    .label-acces::before { content: "\f52b"; } /* Door Open */
    .label-metiers::before { content: "\f508"; } /* User Tie */
    .label-poursuites::before { content: "\f19d"; } /* Graduation Cap */
    .label-etabs::before { content: "\f549"; } /* School */

    /* 5. SOMMAIRE (TOC) - 3 Columns */
    .toc {
        padding: 40px;
        page-break-after: always;
    }

    .toc h3 {
        color: #2c3e50;
        font-size: 32px;
        border-bottom: 3px solid #d4af37;
        padding-bottom: 15px;
        margin-bottom: 20px;
        text-transform: uppercase;
        break-after: avoid;
    }

    .toc-version {
        font-size: 14px;
        color: #666;
        margin-bottom: 30px;
        font-style: italic;
        break-after: avoid;
    }

    .toc-list {
        column-count: 3; /* Changed to 3 columns */
        column-gap: 30px;
        list-style: none;
        padding: 0;
        margin: 0;
        font-size: 12px; /* Slightly smaller for 3 cols */
    }

    .toc-list > li {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 15px;
        display: inline-block; /* Helps with column breaking */
        width: 100%;
    }

    .toc-domain {
        display: block;
        font-weight: bold;
        color: #d4af37;
        margin-bottom: 5px;
        font-size: 13px;
        text-transform: uppercase;
    }

    .toc-levels {
        list-style: none;
        padding-left: 10px;
        margin: 0;
    }

    .toc-levels li {
        margin-bottom: 3px;
    }

    .toc-levels a {
        text-decoration: none;
        color: #2c3e50;
    }

    /* 6. JPO SECTION */
    .jpo-section {
        padding: 40px;
        page-break-before: always;
    }

    .jpo-title {
        color: #2c3e50;
        font-size: 32px;
        border-bottom: 3px solid #d4af37;
        padding-bottom: 15px;
        margin-bottom: 30px;
        text-transform: uppercase;
        text-align: center;
    }

    .jpo-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .jpo-date-group {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 20px;
        border: 1px solid #eee;
        padding: 15px;
        border-radius: 5px;
    }

    .jpo-date-header {
        background-color: #2c3e50 !important;
        color: white !important;
        padding: 8px 15px;
        font-weight: bold;
        margin: -15px -15px 15px -15px;
        border-radius: 5px 5px 0 0;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .jpo-event {
        margin-bottom: 10px;
        font-size: 12px;
        border-bottom: 1px solid #eee;
        padding-bottom: 5px;
    }
    
    .jpo-event:last-child {
        border-bottom: none;
    }

    .jpo-etab {
        font-weight: bold;
        color: #2c3e50;
    }

    .jpo-time {
        color: #d4af37;
        font-weight: bold;
    }
}