/* ===== layout.css - 布局样式：主体、作业纸、题目样式、打印、响应式 ===== */

/* 主体布局 */
.main {
    display: flex;
    min-height: 600px;
}

/* 预览面板 */
.preview-panel {
    flex: 1;
    overflow: auto;
    padding: 24px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: var(--km-bg-secondary);
}

/* 作业纸（A4比例，欢乐彩色风格） */
.paper {
    width: 794px;
    min-height: 1123px;
    background: var(--km-bg);
    padding: 40px 50px 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    flex-shrink: 0;
    border-radius: 4px;
    position: relative;
}

/* 顶部装饰条 */
.paper-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 3px dashed var(--km-primary-light);
}
.paper-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--km-primary);
    margin-bottom: 4px;
    font-family: var(--km-kaiti);
}
.paper-title i {
    margin: 0 8px;
}
.paper-subtitle {
    font-size: 13px;
    color: var(--km-text-muted);
    margin-bottom: 12px;
}
.paper-info {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 14px;
    color: var(--km-text-secondary);
}
.paper-info span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.paper-info .blank {
    display: inline-block;
    min-width: 60px;
    border-bottom: 1px solid var(--km-text-muted);
    height: 18px;
}

/* 题目区块 */
.question-section {
    margin-bottom: 24px;
}
.section-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--km-text);
    margin-bottom: 14px;
    padding: 6px 14px;
    background: var(--km-primary-light);
    border-radius: var(--km-radius);
    border-left: 4px solid var(--km-primary);
    display: inline-block;
}
.section-title.pink { background: #fdf2f8; border-left-color: var(--km-pink); color: var(--km-pink); }
.section-title.blue { background: #eff6ff; border-left-color: var(--km-blue); color: var(--km-blue); }
.section-title.green { background: #f0fdf4; border-left-color: var(--km-green); color: var(--km-green); }
.section-title.purple { background: #f5f3ff; border-left-color: var(--km-purple); color: var(--km-purple); }
.section-title.yellow { background: var(--km-bg-warm); border-left-color: var(--km-yellow); color: #a16207; }

/* 题目行 */
.question-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 14px;
}
.question-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--km-bg);
    border: 2px solid var(--km-border-light);
    border-radius: var(--km-radius);
    min-height: 56px;
    font-size: 20px;
    font-weight: 600;
}
.question-num {
    font-size: 14px;
    color: var(--km-text-muted);
    font-weight: 700;
    min-width: 20px;
}
.emoji-group {
    font-size: 28px;
    letter-spacing: 2px;
    line-height: 1.2;
}
.math-symbol {
    font-size: 24px;
    color: var(--km-primary);
    font-weight: 800;
}
.equals-line {
    display: inline-block;
    width: 50px;
    border-bottom: 2px solid var(--km-text-muted);
    height: 24px;
    text-align: center;
    font-size: 18px;
    color: var(--km-green);
    font-weight: 700;
}
.equals-line.has-answer {
    border-bottom: none;
    color: var(--km-green);
}

/* 数数题 */
.count-question {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--km-bg-warm);
    border: 2px solid #fde68a;
    border-radius: var(--km-radius);
}
.count-question .emoji-group {
    font-size: 32px;
}
.count-question .question-text {
    font-size: 16px;
    color: var(--km-text-secondary);
}

/* 连线题 */
.match-question {
    display: flex;
    gap: 40px;
    padding: 16px;
    background: var(--km-bg);
    border: 2px solid var(--km-border-light);
    border-radius: var(--km-radius);
}
.match-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.match-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    font-weight: 700;
    height: 40px;
}
.match-num {
    width: 40px;
    height: 40px;
    background: var(--km-blue);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
}
.match-dot {
    width: 12px;
    height: 12px;
    background: var(--km-text-muted);
    border-radius: 50%;
}

/* 比多少题（纵向布局：图案在上，圆圈在中，问题在下） */
.compare-question {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    background: #f0fdf4;
    border: 2px solid #bbf7d0;
    border-radius: var(--km-radius);
}
.compare-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.compare-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    width: 100%;
}
.compare-side {
    flex: 1;
    text-align: center;
    min-width: 100px;
}
.compare-side .emoji-group {
    font-size: 30px;
    display: block;
    line-height: 1.3;
    word-break: break-all;
}
.compare-side-label {
    font-size: 12px;
    color: var(--km-text-muted);
    margin-top: 2px;
    display: block;
}
.compare-vs {
    font-size: 18px;
    font-weight: 800;
    color: var(--km-red);
    flex-shrink: 0;
}
.compare-circle-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    width: 100%;
}
.compare-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid var(--km-text-muted);
    border-radius: 50%;
    font-size: 18px;
    font-weight: 800;
    color: var(--km-green);
    background: #fff;
}
.compare-q {
    font-size: 15px;
    color: var(--km-text-secondary);
    text-align: center;
    font-weight: 600;
}

/* 数字排序题 */
.sequence-question {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: #f5f3ff;
    border: 2px solid #ddd6fe;
    border-radius: var(--km-radius);
}
.seq-num {
    width: 44px;
    height: 44px;
    background: var(--km-purple);
    color: #fff;
    border-radius: var(--km-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
}
.seq-blank {
    width: 44px;
    height: 44px;
    border: 2px dashed var(--km-purple);
    border-radius: var(--km-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--km-green);
    background: #faf5ff;
}
.seq-arrow {
    font-size: 18px;
    color: var(--km-text-muted);
}

/* 图案加减题 */
.calc-question {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fdf2f8;
    border: 2px solid #fbcfe8;
    border-radius: var(--km-radius);
}
.calc-question .emoji-group {
    font-size: 26px;
}

/* 底部鼓励语 */
.paper-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 16px;
    border-top: 2px dashed var(--km-border-light);
    font-size: 15px;
    color: var(--km-primary);
    font-weight: 700;
}
.paper-footer i {
    margin: 0 6px;
}

/* 统一版权页脚 */
.tool-footer {
    text-align: center;
    padding: 20px 0 12px;
    font-size: 12px;
    color: var(--km-text-muted);
    border-top: 1px solid var(--km-border-light);
    margin-top: 24px;
}

/* ===== 打印 ===== */
@media print {
    /* --- 基础打印样式（始终生效） --- */
    html, body {
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .toolbar, .input-panel, .tool-footer {
        display: none !important;
    }
    .main {
        width: 100% !important;
        height: auto !important;
        display: block !important;
    }
    .preview-panel {
        width: 100% !important;
        padding: 0 !important;
        overflow: visible !important;
        display: block !important;
    }
    .paper {
        width: 100% !important;
        min-height: auto !important;
        box-shadow: none !important;
        padding: 12mm 12mm 10mm !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    .question-item, .count-question, .compare-question,
    .sequence-question, .calc-question, .match-question {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    @page {
        size: A4;
        margin: 0;
    }

    /* --- 紧凑模式（开启"打印紧凑"开关时生效） --- */
    body.print-compact .paper {
        padding: 8mm 10mm 6mm !important;
    }
    body.print-compact .paper-header {
        margin-bottom: 10px !important;
        padding-bottom: 8px !important;
    }
    body.print-compact .paper-title {
        font-size: 20px !important;
        margin-bottom: 2px !important;
    }
    body.print-compact .paper-subtitle {
        font-size: 11px !important;
        margin-bottom: 6px !important;
    }
    body.print-compact .paper-info {
        gap: 14px !important;
        font-size: 12px !important;
    }
    body.print-compact .paper-info .blank {
        min-width: 44px !important;
        height: 14px !important;
    }
    body.print-compact .question-section {
        margin-bottom: 10px !important;
    }
    body.print-compact .section-title {
        font-size: 14px !important;
        margin-bottom: 6px !important;
        padding: 3px 10px !important;
    }
    body.print-compact .question-row {
        gap: 8px !important;
        margin-bottom: 6px !important;
    }
    body.print-compact .count-question {
        padding: 6px 12px !important;
        min-height: auto !important;
    }
    body.print-compact .count-question .emoji-group {
        font-size: 24px !important;
    }
    body.print-compact .count-question .question-text {
        font-size: 13px !important;
    }
    body.print-compact .equals-line {
        width: 36px !important;
        height: 20px !important;
        font-size: 15px !important;
    }
    body.print-compact .compare-question {
        padding: 8px 14px !important;
        gap: 8px !important;
    }
    body.print-compact .compare-main {
        gap: 5px !important;
    }
    body.print-compact .compare-row {
        gap: 16px !important;
    }
    body.print-compact .compare-side .emoji-group {
        font-size: 24px !important;
    }
    body.print-compact .compare-side-label {
        font-size: 10px !important;
    }
    body.print-compact .compare-vs {
        font-size: 14px !important;
    }
    body.print-compact .compare-circle {
        width: 28px !important;
        height: 28px !important;
        font-size: 14px !important;
    }
    body.print-compact .compare-q {
        font-size: 12px !important;
    }
    body.print-compact .sequence-question {
        padding: 6px 12px !important;
        gap: 4px !important;
    }
    body.print-compact .seq-num,
    body.print-compact .seq-blank {
        width: 36px !important;
        height: 36px !important;
        font-size: 18px !important;
    }
    body.print-compact .seq-arrow {
        font-size: 14px !important;
    }
    body.print-compact .calc-question {
        padding: 6px 12px !important;
        gap: 6px !important;
    }
    body.print-compact .calc-question .emoji-group {
        font-size: 22px !important;
    }
    body.print-compact .math-symbol {
        font-size: 18px !important;
    }
    body.print-compact .match-question {
        padding: 8px 14px !important;
    }
    body.print-compact .match-item {
        height: 32px !important;
        font-size: 18px !important;
        gap: 6px !important;
    }
    body.print-compact .match-num {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
    }
    body.print-compact .match-item .emoji-group {
        font-size: 20px !important;
    }
    body.print-compact .paper-footer {
        margin-top: 10px !important;
        padding-top: 8px !important;
        font-size: 12px !important;
    }
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
    .main {
        flex-direction: column;
        height: auto;
    }
    .input-panel {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid var(--km-border-light);
        max-height: none;
    }
    .preview-panel {
        padding: 12px;
    }
    .paper {
        width: 100%;
        padding: 24px 16px;
        min-height: auto;
    }
}
