/**
 * CMA - Styles Communs pour Impression PDF
 * Melis Technology - 2025
 * Optimisé pour impression N&B et couleur
 * Compatible OCR
 */

/* ==========================================
   RESET & BASE
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 210mm;
    height: 297mm;
    margin: 0;
    padding: 0;
    font-family: 'Arial', 'Helvetica', sans-serif;
    font-size: 11pt;
    line-height: 1.4;
    color: #000;
    background: #fff;
}

/* ==========================================
   PAGE SETUP
   ========================================== */
@page {
    size: A4 portrait;
    margin: 15mm 15mm 15mm 15mm;
}

.page {
    width: 210mm;
    height: 297mm;
    padding: 15mm;
    background: white;
    position: relative;
    page-break-after: always;
}

.page:last-child {
    page-break-after: auto;
}

/* ==========================================
   HEADER SECTION
   ========================================== */
.header {
    border-bottom: 3pt solid #000;
    padding-bottom: 8mm;
    margin-bottom: 8mm;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Logo CMA - Simple et adapté N&B */
.logo-section {
    flex: 0 0 auto;
}

.cma-logo {
    display: inline-block;
    border: 2pt solid #000;
    padding: 3mm 5mm;
    margin-bottom: 2mm;
}

.logo-acronym {
    font-size: 24pt;
    font-weight: bold;
    letter-spacing: 2pt;
    color: #000;
}

.logo-text {
    font-size: 8pt;
    line-height: 1.3;
    font-weight: normal;
    margin-top: 1mm;
}

.logo-text strong {
    font-weight: bold;
}

/* Title Section */
.title-section {
    flex: 1;
    text-align: center;
    padding: 0 5mm;
}

.page-title {
    font-size: 18pt;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1pt;
    margin-bottom: 2mm;
}

.page-subtitle {
    font-size: 10pt;
    font-weight: normal;
}

/* Info Section */
.info-section {
    flex: 0 0 auto;
    text-align: right;
    font-size: 9pt;
}

.info-line {
    margin-bottom: 1mm;
}

.info-label {
    font-weight: bold;
}

/* ==========================================
   CANDIDATE INFORMATION
   ========================================== */
.candidate-info {
    border: 2pt solid #000;
    padding: 5mm;
    margin-bottom: 6mm;
}

.candidate-info-title {
    font-size: 12pt;
    font-weight: bold;
    margin-bottom: 3mm;
    text-transform: uppercase;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3mm;
}

.info-field {
    margin-bottom: 3mm;
}

.info-field:last-child {
    margin-bottom: 0;
}

.field-label {
    font-size: 9pt;
    font-weight: bold;
    margin-bottom: 1mm;
    text-transform: uppercase;
}

.field-value {
    border-bottom: 1pt solid #000;
    min-height: 6mm;
    padding: 1mm 2mm;
    font-size: 10pt;
}

/* ==========================================
   INSTRUCTIONS BOX
   ========================================== */
.instructions-box {
    border: 2pt solid #000;
    padding: 4mm;
    margin-bottom: 6mm;
    background: #f5f5f5;
}

.instructions-title {
    font-size: 11pt;
    font-weight: bold;
    margin-bottom: 2mm;
}

.instructions-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.instructions-list li {
    padding-left: 5mm;
    margin-bottom: 1.5mm;
    position: relative;
    font-size: 9pt;
    line-height: 1.4;
}

.instructions-list li:before {
    content: "▪";
    position: absolute;
    left: 0;
    font-size: 12pt;
}

.instructions-list li strong {
    font-weight: bold;
}

/* ==========================================
   ANSWER GRID QCM
   ========================================== */
.answer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4mm;
    margin-bottom: 6mm;
}

.question-block {
    border: 1.5pt solid #000;
    padding: 3mm;
    background: white;
    page-break-inside: avoid;
}

.question-header {
    font-weight: bold;
    font-size: 10pt;
    margin-bottom: 2mm;
    padding-bottom: 1mm;
    border-bottom: 1pt solid #000;
}

.answers-row {
    display: flex;
    justify-content: space-between;
    gap: 2mm;
}

.answer-box {
    flex: 1;
    border: 1.5pt solid #000;
    min-height: 10mm;
    text-align: center;
    padding: 2mm;
    background: white;
}

.answer-label {
    font-weight: bold;
    font-size: 11pt;
    display: block;
}

/* ==========================================
   FREE ANSWER ZONES
   ========================================== */
.free-answer-section {
    margin-bottom: 6mm;
}

.question-title {
    font-weight: bold;
    font-size: 10pt;
    margin-bottom: 2mm;
    padding: 2mm;
    background: #f5f5f5;
    border-left: 3pt solid #000;
}

.answer-lines {
    border: 1.5pt solid #000;
    padding: 3mm;
    min-height: 50mm;
    background: white;
}

.answer-line {
    border-bottom: 1pt solid #ccc;
    min-height: 6mm;
    margin-bottom: 1mm;
}

.answer-line:last-child {
    border-bottom: none;
}

/* ==========================================
   QUESTIONS PAGE
   ========================================== */
.question-item {
    margin-bottom: 6mm;
    page-break-inside: avoid;
}

.question-number {
    font-weight: bold;
    font-size: 11pt;
    margin-bottom: 2mm;
}

.question-text {
    font-size: 10pt;
    line-height: 1.5;
    margin-bottom: 3mm;
    padding: 2mm;
    background: #f9f9f9;
    border-left: 2pt solid #000;
}

.options-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.option-item {
    padding: 2mm 0;
    padding-left: 8mm;
    position: relative;
    border-bottom: 1pt dashed #ccc;
}

.option-item:last-child {
    border-bottom: none;
}

.option-letter {
    position: absolute;
    left: 0;
    font-weight: bold;
    font-size: 10pt;
}

/* ==========================================
   FOOTER
   ========================================== */
.footer {
    position: absolute;
    bottom: 10mm;
    left: 15mm;
    right: 15mm;
    border-top: 1pt solid #000;
    padding-top: 2mm;
    font-size: 8pt;
    display: flex;
    justify-content: space-between;
}

.footer-left {
    text-align: left;
}

.footer-right {
    text-align: right;
}

/* ==========================================
   OCR OPTIMIZATION
   ========================================== */
/* Zones OCR avec fond blanc pur et bordures nettes */
.ocr-zone {
    background: #ffffff !important;
    border: 2pt solid #000000 !important;
    padding: 2mm;
}

/* Cases à cocher carrées pour OCR */
.checkbox-area {
    display: inline-block;
    width: 8mm;
    height: 8mm;
    border: 2pt solid #000;
    background: white;
    margin-right: 2mm;
    vertical-align: middle;
}

/* Code-barres / QR zone */
.barcode-zone {
    border: 2pt solid #000;
    padding: 3mm;
    text-align: center;
    margin: 4mm 0;
}

.barcode-placeholder {
    height: 15mm;
    background: white;
    border: 1pt dashed #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8pt;
    color: #666;
}

/* ==========================================
   PRINT OPTIMIZATION
   ========================================== */
@media print {
    html, body {
        width: 210mm;
        height: 297mm;
        margin: 0;
        padding: 0;
    }
    
    .page {
        page-break-after: always;
        page-break-inside: avoid;
    }
    
    .page:last-child {
        page-break-after: auto;
    }
    
    .question-block,
    .question-item,
    .free-answer-section {
        page-break-inside: avoid;
    }
    
    /* Forcer les bordures noires */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }
    
    /* Supprimer les backgrounds en N&B sauf zones OCR */
    .instructions-box,
    .question-text {
        background: white !important;
    }
    
    .ocr-zone,
    .answer-box {
        background: white !important;
    }
}

/* ==========================================
   BLACK & WHITE MODE
   ========================================== */
.bw-mode {
    background: white !important;
}

.bw-mode .instructions-box,
.bw-mode .question-text {
    background: white !important;
}

.bw-mode .footer {
    color: #000 !important;
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */
.text-bold {
    font-weight: bold;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.no-break {
    page-break-inside: avoid;
}

.mt-small {
    margin-top: 2mm;
}

.mt-medium {
    margin-top: 4mm;
}

.mt-large {
    margin-top: 6mm;
}

.mb-small {
    margin-bottom: 2mm;
}

.mb-medium {
    margin-bottom: 4mm;
}

.mb-large {
    margin-bottom: 6mm;
}