/* ==========================================================================
   PHIEUBAITAP.NET — CONTENT PROTECTION, ANTI-COPY & AUTHORIZED PRINT GUARD
   - Bảo vệ vùng đề thi (.sheet, .question-block, .passage-content) chống bôi đen/kéo thả.
   - Whitelist tuyệt đối cho <input>, <textarea>, <select>, [contenteditable="true"].
   - Khóa in trái phép (Ctrl+P thô): bắt buộc đi qua luồng Authorized Print chuẩn A4.
   ========================================================================== */

/* 1. CHỐNG BÔI ĐEN SAO CHÉP TRÊN VÙNG ĐỀ BÀI & ĐỌC HIỂU */
.sheet,
.worksheet-container,
.question-block,
.passage-content,
.ws-section,
.ex-read-passage,
.ex-read-box,
.ex-mcq-item,
.ex-scram-item,
.ex-match-table,
.qr-reading-content {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* 2. WHITELIST TUYỆT ĐỐI CHO Ô NHẬP LIỆU HỌC SINH & CHẾ ĐỘ SỬA TRỰC TIẾP GIÁO VIÊN */
input,
textarea,
select,
option,
[contenteditable="true"],
[contenteditable="true"] *,
.student-ans-input,
.allow-user-select {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
    pointer-events: auto !important;
}

/* 3. CHỐNG KÉO THẢ ẢNH, MÃ QR, BIỂU ĐỒ SVG TRÊN TỜ GIẤY A4 */
.sheet img,
.sheet svg,
.sheet canvas {
    pointer-events: none !important;
    -webkit-user-drag: none !important;
    user-select: none !important;
}

/* 4. LỚP WATERMARK CANVAS/SVG CHỐNG XÓA DOM (ZERO PAGINATION IMPACT) */
.pbt-wm-guard {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: none !important;
    pointer-events: none !important;
    user-select: none !important;
    z-index: 2 !important;
    overflow: hidden !important;
    background-repeat: repeat !important;
    background-position: center center !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* Tránh chồng chữ kép với lớp SSR cũ khi in thực tế trên tài khoản Free */
@media print {
    body.pbt-canvas-wm-active:not(.is-vip-user) .sheet > .a4-watermark-layer .wm-diagonal-wrap {
        opacity: 0 !important;
    }
}

/* 5. CẢNH BÁO BẢN QUYỀN KHI IN TRÁI PHÉP (MẶC ĐỊNH ẨN TRÊN MÀN HÌNH) */
.unauthorized-print-warning {
    display: none !important;
}

/* 6. Ô NHẬP ĐÁP ÁN TƯƠNG TÁC CHO CHẾ ĐỘ HỌC SINH / LUYỆN TẬP */
.student-ans-input {
    display: inline-block;
    min-width: 130px;
    padding: 3px 8px;
    font-size: 0.92em;
    font-weight: 600;
    color: #0f172a;
    background: #f8fafc;
    border: 1.5px solid #94a3b8;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.student-ans-input:focus {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.student-ans-input.is-ans-correct {
    border-color: #16a34a !important;
    background: #f0fdf4 !important;
    color: #15803d !important;
}

.student-ans-input.is-ans-wrong {
    border-color: #dc2626 !important;
    background: #fef2f2 !important;
    color: #b91c1c !important;
}

.student-mcq-opt {
    cursor: pointer !important;
    border-radius: 6px;
    padding: 2px 6px;
    transition: background-color 0.12s ease;
}

.student-mcq-opt:hover {
    background: #eff6ff;
}

.student-mcq-opt.is-picked {
    background: #dbeafe;
    outline: 1.5px solid #2563eb;
}

.student-mcq-opt.is-ans-correct {
    background: #dcfce7 !important;
    outline: 1.5px solid #16a34a !important;
}

.student-mcq-opt.is-ans-wrong {
    background: #fee2e2 !important;
    outline: 1.5px solid #dc2626 !important;
}

/* 7. SMART PRINT GUARD — CHẶN IN THÔ TRÁI PHÉP, BẢO TOÀN 100% PAPER-CSS KHI HỢP LỆ */
@media print {
    body.authorized-print .unauthorized-print-warning,
    .student-practice-bar {
        display: none !important;
        visibility: hidden !important;
    }

    body.authorized-print .sheet > .pbt-wm-guard {
        display: block !important;
        visibility: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

