/* ==========================================================================
   PRINT WIDGETS CSS — CÔ LẬP WIDGET BÀI TẬP CHUẨN SGK (.ex-*) TRONG TỜ A4
   --------------------------------------------------------------------------
   - Tuân thủ LUẬT 4: tiền tố riêng .ex-mcq-, .ex-match-, .ex-fill-,
     .ex-trace-, .ex-scram-, .ex-read-.
   - Bảo vệ từng khối câu hỏi không bị cắt đôi khi sang trang (break-inside: avoid),
     nhưng cho phép .ws-section dài tự động ngắt qua nhiều trang A4.
   ========================================================================== */

.ws-header {
    border-bottom: 2px solid #0f172a;
    padding-bottom: 6px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.ws-teacher-brand {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    color: #334155;
    letter-spacing: 0.02em;
}

.ws-title {
    font-size: 16px;
    font-weight: 800;
    margin: 2px 0;
    text-transform: uppercase;
    color: #0f172a;
    line-height: 1.3;
}

.ws-student-info {
    font-size: 12px;
    margin-top: 5px;
    padding-bottom: 2px;
    border-bottom: 1px dotted #334155;
    color: #1e293b;
}

.ws-code-badge {
    border: 2px solid #0f172a;
    padding: 4px 10px;
    font-weight: 800;
    font-size: 13px;
    border-radius: 4px;
    text-align: center;
    white-space: nowrap;
    color: #0f172a;
    background: #f8fafc;
}

/* Cho phép .ws-section dài ngắt qua nhiều trang, nhưng KHÔNG tách tiêu đề rời câu 1 */
.ws-section {
    margin-bottom: 8px;
    page-break-inside: auto;
    break-inside: auto;
}

.ws-section-title {
    font-size: 12.8px;
    font-weight: 700;
    background: #f1f5f9;
    border-left: 4px solid #0f172a;
    padding: 3px 8px;
    margin-bottom: 6px;
    color: #0f172a;
    page-break-after: avoid;
    break-after: avoid;
}

/* Chống cắt đôi từng câu hỏi đơn lẻ, đoạn văn đọc hiểu, dòng bảng và hình ảnh */
.question-block,
.exercise-item,
.ex-trace-item,
.ex-mcq-item,
.ex-fill-grid > div,
.ex-scram-item,
.ex-read-box,
.ex-read-passage,
.ex-match-table tr,
.sheet img {
    page-break-inside: avoid;
    break-inside: avoid;
}

.ex-trace-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.ex-trace-item {
    border: 1px dashed #64748b;
    padding: 4px 8px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: repeating-linear-gradient(to bottom, transparent 0px, transparent 9px, #cbd5e1 10px);
}

.ex-trace-word-dots {
    font-size: 18px;
    letter-spacing: 3px;
    color: #94a3b8;
    font-weight: 600;
}

.trace-phonetic {
    white-space: nowrap;
}

.ex-match-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.ex-match-table td {
    padding: 3px 6px;
    border: 1px solid #cbd5e1;
}

.ex-mcq-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
    font-size: 12.1px;
}

.ex-mcq-item.mcq-item-wide {
    grid-column: 1 / -1;
}

.ex-mcq-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 8px;
    font-size: 12px;
    margin-top: 2px;
    padding-left: 8px;
}

.ex-mcq-options.cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px 6px;
}

.ex-mcq-options.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 10px;
}

.ex-mcq-options.cols-1 {
    grid-template-columns: 1fr;
    gap: 1px;
}

.ex-fill-wordbank {
    border: 1px solid #0f172a;
    padding: 4px 10px;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 700;
    text-align: center;
    border-radius: 4px;
    background: #ffffff;
}

.ex-fill-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 14px;
    font-size: 12.5px;
}

.first-letter-hint {
    display: none;
    font-weight: 700;
    color: #475569;
}

body.show-first-letter .first-letter-hint {
    display: inline;
}

body.hide-wordbank .ex-fill-wordbank {
    display: none;
}

body.hide-answer-key #answer-key-sheet,
body.hide-answer-key .ak-cont-sheet {
    display: none !important;
}

.ex-scram-item,
.ex-read-box {
    font-size: 12.5px;
    margin-bottom: 4px;
}

.ex-read-passage {
    border: 1px solid #94a3b8;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 5px;
    line-height: 1.42;
}

.a4-footer-bar {
    border-top: 1.5px solid #0f172a;
    padding-top: 5px;
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #0f172a;
}

.footer-site-box {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: max-content;
}

.footer-site-url {
    color: #0f172a;
    font-weight: 700;
    text-decoration: none;
}

[contenteditable="true"]:hover {
    outline: 1px dashed #2563eb;
    background: rgba(37, 99, 235, 0.04);
}

