/* ============================================
   CSS IMPRESSION AUTOMATISMES
   Version finale optimisée
   ============================================ */

@media print {
    /* Configuration page */
    @page {
        size: A4;
        margin: 0.7cm 0.4cm;
    }
    
    /* Reset général */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-sizing: border-box;
    }
    
    body {
        margin: 0;
        padding: 0;
        background: white !important;
        font-family: Arial, sans-serif;
        font-size: 9pt;
        line-height: 1.15;
        color: #000 !important;
    }
    
    /* ========== MASQUAGE ÉLÉMENTS UI ========== */
    .no-print,
    button,
    .btn,
    nav,
    header,
    footer,
    .notions-toggle-btn,
    .notions-content,
    .selection-section,
    .math-toolbar,
    #prevBtn,
    #nextBtn,
    #validateBtn,
    #nextQuestionBtn,
    #scoreBtn,
    #print-buttons-container,
    .leaderboard-panel {
        display: none !important;
    }
    
    /* ========== EN-TÊTE ÉLÈVE (questions) ========== */
    .print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 12px;
        border: 2px solid #000;
        border-radius: 6px;
        margin-bottom: 12px;
        background: #f5f5f5 !important;
        page-break-after: avoid;
        page-break-inside: avoid;
    }
    
    .print-field {
        font-size: 10pt;
        font-weight: bold;
        color: #000 !important;
        white-space: nowrap;
    }
    
    /* ========== TITRES ========== */
    .print-title {
        text-align: center;
        font-size: 13pt;
        font-weight: bold;
        margin: 8px 0;
        color: #000 !important;
        page-break-after: avoid;
    }
    
    .print-subtitle {
        text-align: center;
        font-size: 10pt;
        margin: 5px 0 12px 0;
        color: #333 !important;
    }
    
    /* ========== LAYOUT 2 COLONNES ========== */
    .questions-container,
    .corrections-container {
        columns: 2;
        column-gap: 10px;
        column-rule: 1px solid #bbb;
        margin: 0;
        padding: 0;
    }
    
    /* ========== QUESTIONS ========== */
    .question-item {
        break-inside: avoid;
        page-break-inside: avoid;
        margin: 0 0 7px 0;
        padding: 6px;
        border: 1px solid #333;
        border-radius: 3px;
        background: white !important;
    }
    
    .question-number {
        display: inline-block;
        background: #555 !important;
        color: white !important;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        text-align: center;
        line-height: 20px;
        font-size: 10px;
        font-weight: bold;
        margin-right: 6px;
        vertical-align: middle;
        flex-shrink: 0;
    }
    
    .question-text {
        font-size: 9pt !important;
        line-height: 1.2 !important;
        margin: 4px 0 !important;
        color: #000 !important;
        display: inline;
    }
    
    /* ========== LIGNE RÉPONSE ========== */
    .answer-line {
        border-bottom: 1px solid #000;
        height: 18px;
        margin-top: 5px;
    }
    
    /* ========== CORRECTIONS ========== */
    .corrections-page-break {
        page-break-before: always !important;
        display: block !important;
        height: 0;
        margin: 0;
    }
    
    .corrections-title {
        text-align: center;
        font-size: 14pt;
        font-weight: bold;
        margin: 15px 0;
        color: #000 !important;
        page-break-after: avoid;
    }
    
    .answer-box {
        background: #e8f5e9 !important;
        border-left: 3px solid #4caf50 !important;
        padding: 4px;
        margin-top: 4px;
        font-size: 8pt !important;
        color: #000 !important;
    }
    
    .answer-box strong {
        color: #2e7d32 !important;
    }
    
    /* ========== OPTIMISATIONS SUPPLÉMENTAIRES ========== */
    h1, h2, h3 {
        margin: 5px 0 !important;
        padding: 0 !important;
        page-break-after: avoid;
        color: #000 !important;
    }
    
    p {
        margin: 3px 0 !important;
        page-break-inside: avoid;
    }
    
    /* Éviter coupure des éléments importants */
    .print-header,
    .print-title,
    .question-item,
    .answer-box {
        page-break-inside: avoid !important;
    }
}

/* ========== MODE ÉCRAN (masquer éléments print) ========== */
@media screen {
    .print-header,
    .print-title,
    .print-subtitle,
    .corrections-page-break,
    .corrections-title,
    .answer-line {
        display: none !important;
    }
}
