/* ===== A4 打印样式 - 所见即所得 ===== */

@media print {
    /* 页面设置 */
    @page {
        size: A4 portrait;
        margin: 0;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        margin: 0;
        padding: 0;
        background: white;
    }

    /* 隐藏非打印元素 */
    .screen-header,
    .config-panel,
    .toast {
        display: none !important;
    }

    /* 隐藏主容器的flex布局 */
    .app-container {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* 隐藏预览区域的外边距 */
    .preview-area {
        padding: 0 !important;
        display: block !important;
    }

    #paperContainer {
        display: block !important;
    }

    /* A4纸样式 */
    .a4-paper {
        width: 100% !important;
        min-height: 100vh !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 12mm 10mm !important;
        page-break-after: always;
        page-break-inside: avoid;
    }

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

    /* 题目网格 - 使用style属性中的列数设置，不覆盖 */
    .problem-grid {
        gap: 3mm 5mm !important;
        min-height: auto !important;
    }

    /* 题目项 */
    .problem-item {
        padding: 2mm 1mm !important;
        border-bottom: 1px solid #ddd !important;
        page-break-inside: avoid;
    }

    .problem-item:hover {
        background: none !important;
    }

    .problem-number {
        color: #000 !important;
    }

    .problem-answer {
        color: #000 !important;
    }

    .problem-answer.hidden {
        display: none !important;
    }

    /* 答案区域 */
    .paper-answer {
        page-break-inside: avoid;
    }

    /* 页脚 */
    .paper-footer {
        position: fixed;
        bottom: 5mm;
        left: 10mm;
        right: 10mm;
    }
}

/* 横向打印支持 */
@media print and (orientation: landscape) {
    @page {
        size: A4 landscape;
        margin: 0;
    }

    .answer-grid {
        grid-template-columns: repeat(8, 1fr) !important;
    }
}