/* ================================================
   exam_3types.css - Styles for 3-type exam creation
   ================================================ */

/* Section Headers */
.section-exam-type {
    margin-bottom: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.section-exam-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.section-exam-header:hover {
    background: #f8f9fa;
}

.section-exam-header .section-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
}

.section-exam-header .section-badge .badge-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.section-exam-type.type-tracnghiem .badge-number {
    background: linear-gradient(135deg, #7367F0, #9E95F5);
}

.section-exam-type.type-đungsai .badge-number {
    background: linear-gradient(135deg, #FF9F43, #FFB976);
}

.section-exam-type.type-tuluan .badge-number {
    background: linear-gradient(135deg, #00CFE8, #4DD9E8);
}

.section-exam-header .section-title {
    color: #333;
}

.section-exam-header .toggle-icon {
    transition: transform 0.3s;
    color: #999;
}

.section-exam-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.section-exam-body {
    padding: 16px;
    border-top: 1px solid #eee;
}

/* Question counter badges */
.section-exam-header .question-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(115, 103, 240, 0.1);
    color: #7367F0;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.type-đungsai .question-count {
    background: rgba(255, 159, 67, 0.1) !important;
    color: #FF9F43 !important;
}

.type-tuluan .question-count {
    background: rgba(0, 207, 232, 0.1) !important;
    color: #00CFE8 !important;
}

/* ========== PHẦN II - ĐÚNG/SAI ========== */
.item-tf,
.item-essay {
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    margin-bottom: 16px;
    position: relative;
    transition: box-shadow 0.2s;
}

.item-tf:hover,
.item-essay:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.tf-statement-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.tf-statement-item {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 10px 14px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fafbfc;
    transition: all 0.2s;
}

.tf-statement-item:hover {
    background: #f5f5f5;
}

.tf-statement-item .userchoice {
    min-width: 28px;
    font-weight: 700;
    color: #555;
    font-size: 14px;
}

.tf-toggle-group {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.tf-toggle-btn {
    padding: 5px 14px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    color: #888;
    outline: none;
}

.tf-toggle-btn:hover {
    border-color: #bbb;
}

.tf-toggle-btn.active-true {
    background: #28C76F;
    border-color: #28C76F;
    color: #fff;
}

.tf-toggle-btn.active-false {
    background: #EA5455;
    border-color: #EA5455;
    color: #fff;
}

/* Per-statement explanation (Đúng/Sai) */
.tf-statement-explain {
    margin-top: 6px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #FF9F43;
    font-size: 13px;
}

.tf-statement-explain .html--content {
    cursor: pointer;
    min-height: 20px;
}

/* ========== PHẦN III - TỰ LUẬN ========== */
/* (styles consolidated under .item-essay above) */

/* ========== Options management (Part I) ========== */
.btn-remove-option {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    margin-left: 4px;
    transition: color 0.2s;
    outline: none;
}

.btn-remove-option:hover {
    color: #EA5455;
}

.btn-add-option {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px dashed #ccc;
    border-radius: 6px;
    background: transparent;
    color: #888;
    font-size: 13px;
    padding: 6px 12px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
    outline: none;
}

.btn-add-option:hover {
    border-color: #7367F0;
    color: #7367F0;
    background: rgba(115, 103, 240, 0.04);
}

/* Add question button */
.btn-add-question {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: transparent;
    color: #888;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-question:hover {
    border-color: #7367F0;
    color: #7367F0;
    background: rgba(115, 103, 240, 0.04);
}

/* Delete question button */
/* Delete question button - Top Right "X" */
.btn-delete-question {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #FF3B30;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 1;
    /* Always visible */
    z-index: 10;
    box-shadow: 0 2px 6px rgba(255, 59, 48, 0.4);
}

.item-tf:hover .btn-delete-question,
.item-essay:hover .btn-delete-question,
.item-question:hover .btn-delete-question {
    transform: scale(1.1);
}

.btn-delete-question:hover {
    background: #EA5455;
    color: #fff;
}

/* LaTeX modal */
.latex-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.latex-modal {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 500px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.latex-modal h5 {
    margin-bottom: 16px;
    font-weight: 700;
    color: #333;
}

.latex-modal textarea {
    width: 100%;
    min-height: 80px;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
    font-family: monospace;
    font-size: 14px;
    margin-bottom: 12px;
}

.latex-modal .latex-preview {
    min-height: 50px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 16px;
    text-align: center;
}

.latex-modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Level select for questions */
.q-level-select {
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #555;
}

/* Responsive */
@media (max-width: 768px) {
    .tf-statement-item {
        flex-wrap: wrap;
    }

    .tf-toggle-group {
        width: 100%;
        justify-content: flex-end;
    }

    .essay-editor-toolbar {
        gap: 2px;
    }

    .essay-editor-toolbar button {
        padding: 4px 8px;
        font-size: 12px;
    }

    .essay-options {
        flex-direction: column;
        gap: 8px;
    }
}

/* ========== DRAG & DROP ========== */
#app.drag-over {
    background: rgba(115, 103, 240, 0.04);
    border: 2px dashed #7367F0;
    border-radius: 12px;
    transition: all 0.3s;
}

#app.drag-over .noti-drop {
    background: rgba(115, 103, 240, 0.08);
    border-color: #7367F0;
    color: #7367F0;
}

.noti-drop {
    transition: all 0.3s;
}

/* ========== PART I - MC Questions (auto-populated) ========== */
.sectionQuiz .item-question {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    transition: box-shadow 0.2s;
}

.sectionQuiz .item-question:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.sectionQuiz .item-question .heading-elements,
.item-tf .heading-elements,
.item-essay .heading-elements {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.sectionQuiz .item-question .question-title {
    font-weight: 700;
    color: #7367F0;
    font-size: 15px;
}

.sectionQuiz .item-question .content {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.sectionQuiz .item-question .options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sectionQuiz .item-question .userchoice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fafbfc;
    transition: all 0.2s;
}

.sectionQuiz .item-question .userchoice:hover {
    background: #f0f0ff;
}

.sectionQuiz .item-question .userchoice.done {
    background: rgba(40, 199, 111, 0.08);
    border-color: #28C76F;
}

.sectionQuiz .item-question .userchoice .key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: #f0f0f0;
    font-weight: 700;
    font-size: 13px;
    color: #555;
}

.sectionQuiz .item-question .userchoice.done .key {
    background: #28C76F;
    color: #fff;
}

.sectionQuiz .item-question .userchoice .text {
    font-size: 14px;
    line-height: 1.5;
}

.sectionQuiz .item-question .explain {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 13px;
    color: #666;
    border-left: 3px solid #7367F0;
}

.sectionQuiz .item-question .point {
    font-size: 13px;
    color: #888;
}

.sectionQuiz .item-question .level-question,
.item-tf .level-question,
.item-essay .level-question {
    font-size: 12px;
    padding: 3px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 90px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-icon i {
    font-size: 14px;
}

/* ========== TABLES FROM DOCX ========== */
.sectionQuiz table,
.tf-content-preview table,
.essay-content-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}

.sectionQuiz table td,
.sectionQuiz table th,
.tf-content-preview table td,
.tf-content-preview table th,
.essay-content-preview table td,
.essay-content-preview table th {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: center;
}

.sectionQuiz table th,
.tf-content-preview table th,
.essay-content-preview table th {
    background: #f5f5f5;
    font-weight: 700;
}

.sectionQuiz table tr:nth-child(even),
.tf-content-preview table tr:nth-child(even),
.essay-content-preview table tr:nth-child(even) {
    background: #fafbfc;
}

/* ========== IMAGES FROM DOCX ========== */
.sectionQuiz img,
.tf-content-preview img,
.essay-content-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 6px 0;
    display: block;
}

/* ========== HTML CONTENT PREVIEW (TF / Essay) ========== */
.tf-content-preview,
.essay-content-preview {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.7;
}

.tf-content-preview p,
.essay-content-preview p {
    margin: 4px 0;
}

/* Formula images from MathType (WMF converted to PNG) — inline with text */
.sectionQuiz .item-question .content img,
.sectionQuiz .item-question .options img,
.tf-content-preview img,
.essay-content-preview img {
    display: inline;
    vertical-align: middle;
    max-width: 100%;
    height: auto;
}

/* Large standalone images (charts/graphs) — block display */
.sectionQuiz .item-question .content img[src*="image/png"]:not([width]),
.sectionQuiz .item-question .content img[src*="image/jpeg"] {
    display: block;
    margin: 10px 0;
}

/* Force MathJax containers to display inline (override MathJax default block) */
mjx-container[jax="SVG"] {
    display: inline-block !important;
    vertical-align: middle;
}

mjx-container[jax="SVG"]>svg {
    display: inline-block !important;
}

/* Click-to-edit: visual feedback */
.sectionQuiz .html--content {
    cursor: pointer;
    min-height: 24px;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.sectionQuiz .html--content:hover {
    background-color: #f0f7ff;
}

.sectionQuiz .html--content.preview {
    display: none;
}

.sectionQuiz .html--edit {
    width: 100%;
    min-height: 60px;
    font-size: 14px;
    padding: 6px 8px;
}


/* ============================================
   Card header — match exam.js structure
   ============================================ */

/* Override exam.css .btn { min-width:140px } for point badge */
.item-question .card-header .btn.point {
    min-width: auto !important;
    padding: 8px !important;
}

/* ============================================
   Table borders inside question content
   ============================================ */
.item-question .html--content table {
    border-collapse: collapse;
    width: auto;
    margin: 8px 0;
}

.userchoice.center.done {
    background: #2B8138 !important;
}

.item-question .html--content table,
.item-question .html--content th,
.item-question .html--content td {
    border: 1.5px solid #333 !important;
}

.item-question .html--content th,
.item-question .html--content td {
    padding: 6px 12px;
    text-align: center;
}

.item-question .html--content th {
    background: #f0f0f0;
    font-weight: 700;
}

/* ============================================
   TF statement add/remove buttons
   ============================================ */
.btn-remove-statement {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    margin-left: 4px;
    transition: color 0.2s;
    outline: none;
    flex-shrink: 0;
}

.btn-remove-statement:hover {
    color: #EA5455;
}

.btn-add-statement {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px dashed #ccc;
    border-radius: 6px;
    background: transparent;
    color: #888;
    font-size: 13px;
    padding: 6px 12px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
    outline: none;
}

.btn-add-statement:hover {
    border-color: #FF9F43;
    color: #FF9F43;
    background: rgba(255, 159, 67, 0.04);
}

/* ============================================
   Section score edit badge
   ============================================ */
.section-score-edit {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px !important;
    font-size: 14px !important;
    border-radius: 6px;
    white-space: nowrap;
}

.section-score-edit .html--edit {
    width: 70px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    padding: 2px 6px;
    border: 1.5px solid #28C76F;
    border-radius: 4px;
}

/* ================================================
   PLAY MODE - 3-Types Exam Student View
   ================================================ */

/* Section wrappers in play mode */
.section-3types {
    margin-bottom: 2rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    background: #fff;
}

.section-3types-header {
    padding: 14px 20px;
}

.section-3types-header h3 {
    margin: 0;
    font-size: 17px;
    letter-spacing: 0.3px;
}

.section-3types-body {
    padding: 0 16px 16px;
}

/* TF Statement Items */
.tf-statement-item {
    background: #fafbfc;
    border-radius: 8px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.tf-statement-item:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    border-color: #d0d0d0;
}

.tf-statement-content {
    font-size: 15px;
    line-height: 1.6;
}

/* TF Toggle Buttons */
.tf-btn {
    min-width: 64px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px !important;
    font-size: 13px !important;
}

.tf-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tf-btn:active {
    transform: translateY(0);
}

/* Essay Textarea */
.essay-textarea {
    font-size: 15px;
    line-height: 1.7;
    resize: vertical;
    min-height: 120px;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

/* Play Mode Active States (Fix for missing Tailwind JIT) */
.tf-btn.active-true {
    background: #4caf50 !important;
    border-color: #4caf50 !important;
    color: #fff !important;
}

.tf-btn.active-false {
    background: #ff5722 !important;
    border-color: #ff5722 !important;
    color: #fff !important;
}

.essay-textarea:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

/* TinyMCE editor in play mode */
.essay-answer .tox.tox-tinymce {
    border: 1px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
}

.essay-answer .tox .tox-toolbar__primary {
    background: #f9f9f9;
}

.essay-answer .fa-info-circle {
    color: #f59e0b;
}

/* Nav section labels */
.nav-question p.text-sm.font-bold {
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.03);
}

/* ================================================
   RESPONSIVE - Play Mode (3-Types Exam)
   ================================================ */

.section-3types-body .question-content,
.section-3types-body .list-answer .answer-content .content,
.section-3types-body .tf-statement-content,
.section-3types-body .essay-answer,
.module-question .question-content,
.module-question .list-answer .content,
.module-question .tf-statement-content {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    font-size: 19px;
}

/* Answer content wrapper: allow scroll instead of hiding overflow */
.module-question .answer-content {
    overflow: visible;
}

.module-question .answer-content .content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}

/* Answer items must not exceed viewport */
.module-question .answer-item {
    max-width: 100%;
}

/* Flex children need min-width: 0 to allow shrinking */
.module-question .item-question {
    min-width: 0;
    overflow: hidden;
}

/* Tables inside questions: keep table layout, parent handles scroll */
.section-3types-body table,
.module-question table {
    border-collapse: collapse !important;
    min-width: auto;
    white-space: normal;
}

/* Ensure table borders always show (override Tailwind * { border-width: 0 } reset) */
.section-3types-body table td,
.section-3types-body table th,
.module-question .question-content table td,
.module-question .question-content table th,
.module-question .list-answer table td,
.module-question .list-answer table th {
    border: 1px solid #ddd !important;
    padding: 6px 10px;
}

.section-3types-body table th,
.module-question .question-content table th,
.module-question .list-answer table th {
    background: #f5f5f5;
    font-weight: 700;
}

/* MathJax containers should not break layout */
.section-3types-body mjx-container,
.module-question mjx-container {
    overflow-x: auto;
    max-width: 100%;
}

/* === TABLET & BELOW (≤1024px) === */
@media (max-width: 1024px) {
    .section-3types {
        border-radius: 8px;
    }

    .section-3types-header {
        padding: 12px 14px;
    }

    .section-3types-header h3 {
        font-size: 16px;
    }

    .section-3types-body {
        padding: 0 12px 12px;
    }
}

/* === TABLET (≤768px) === */
@media (max-width: 768px) {
    .tf-buttons {
        flex-direction: row;
        gap: 4px;
    }

    .tf-btn {
        min-width: 50px;
        padding: 6px 10px !important;
        font-size: 12px !important;
    }

    .section-3types-header h3 {
        font-size: 15px;
    }

    .section-3types-body {
        padding: 0 10px 10px;
    }

    /* Answer content scrollable */
    .answer-content .content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 19px;
    }

    /* Question & TF content font size */
    .question-content.s-content,
    .tf-statement-content {
        font-size: 19px !important;
    }
}

/* === MOBILE (≤576px) === */
@media (max-width: 576px) {

    /* Section headers */
    .section-3types-header {
        padding: 10px 12px;
    }

    .section-3types-header h3 {
        font-size: 14px;
        letter-spacing: 0;
    }

    .section-3types-body {
        padding: 0 8px 8px;
    }

    .section-3types {
        margin-bottom: 1rem;
        border-radius: 6px;
    }

    /* Question items */
    .section-3types-body .item-question {
        padding: 10px !important;
    }

    /* TF statement items */
    .tf-statement-item {
        padding: 8px !important;
    }

    .tf-buttons {
        flex-direction: row;
        gap: 3px;
        width: 100%;
        justify-content: flex-end;
        margin-top: 6px;
    }

    .tf-btn {
        min-width: 44px;
        padding: 5px 8px !important;
        font-size: 11px !important;
    }

    /* Head question bar */
    .head-question {
        padding: 8px 10px !important;
        gap: 2px !important;
        flex-wrap: wrap;
    }

    .head-question .title {
        font-size: 13px;
    }

    .head-question .point {
        font-size: 11px;
        padding: 4px 8px !important;
    }

    /* Essay */
    .essay-textarea {
        font-size: 13px;
        min-height: 80px;
        padding: 8px !important;
    }

    .essay-answer label {
        font-size: 13px;
    }

    /* Question content text */
    .question-content {
        font-size: 14px !important;
    }

    /* Answer items - label on left, content on right */
    .answer-content .answer {
        width: 36px !important;
        font-size: 13px;
    }

    .answer-content .content {
        padding: 6px 8px !important;
        font-size: 13px;
        white-space: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Hide click overlay on mobile - <label> wrapper handles clicks natively */
    .click-overlay {
        display: none !important;
    }

    /* Module question font size */
    .module-question {
        font-size: 1rem;
    }
}

/* === VERY SMALL MOBILE (≤400px) === */
@media (max-width: 400px) {
    .section-3types-header h3 {
        font-size: 13px;
    }

    .tf-btn {
        min-width: 38px;
        padding: 4px 6px !important;
        font-size: 10px !important;
    }

    .head-question .title {
        font-size: 12px;
    }

    .answer-content .answer {
        font-size: 12px;
        padding: 3px 8px !important;
    }
}

/* Editable user choice */
.userchoice[contenteditable="true"] {
    cursor: text;
}

/* ================================================
   PLAY MODE FIX - Ensure all answers are clickable
   ================================================ */

/* Force ALL answer wrapper elements to be clickable */
.module-question .answer-item,
.module-question [item-answer],
.list-answer .answer-item,
.list-answer [item-answer] {
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
}

/* Click overlay ensures clicks work on ALL answers, even over MathJax */
.click-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    cursor: pointer;
}

/* MathJax elements should never block clicks */
.list-answer mjx-container,
.list-answer mjx-container *,
.module-question mjx-container,
.module-question mjx-container * {
    pointer-events: none !important;
}

/* Radio input */
.module-question input[type="radio"],
.list-answer input[type="radio"] {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Visual feedback: highlight selected answer */
.answer-item input[type="radio"]:checked~.answer-content {
    border: 1px solid #2f842b !important;
}

.answer-item input[type="radio"]:checked~.answer-content .answer {
    background: linear-gradient(90deg, #2f842b 0%, #167479 100%) !important;
    color: #fff !important;
}

/* Remove .done class styling in play mode */
.module-question .answer-item.done,
.module-question .userchoice.done,
.module-question .center.done,
.list-answer .answer-item.done {
    background: #fafbfc !important;
    border-color: #ebebeb !important;
    pointer-events: auto !important;
}


.userchoice[contenteditable="true"]:focus {
    outline: none;
    border-color: #7367F0;
    box-shadow: 0 0 0 2px rgba(115, 103, 240, 0.2);
    background: #fff;
    color: #7367F0;
    z-index: 5;
}

.item-question.dragging,
.item-tf.dragging,
.item-essay.dragging {
    opacity: 0.5;
    border: 2px dashed #7367F0;
}

/* ================================================
   RESULT VIEW - Table borders in .examing wrapper
   ================================================ */
.examing .question-content table,
.examing .tf-statement-content table,
.examing .essay-result table {
    border-collapse: collapse !important;
    margin: 8px 0;
}

.examing .question-content table td,
.examing .question-content table th,
.examing .tf-statement-content table td,
.examing .tf-statement-content table th {
    border: 1px solid #999 !important;
    padding: 6px 10px;
}

.examing .question-content table th,
.examing .tf-statement-content table th {
    background: #f5f5f5;
    font-weight: 700;
}

/* ================================================
   QUESTION CONTENT - Rich text rendering
   Match edit view (TinyMCE) styling for play/result
   ================================================ */
.question-content.s-content {
    font-size: 19px;
    line-height: 1.8;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.question-content.s-content p {
    margin-bottom: 0.4em;
    line-height: 1.8;
}

.question-content.s-content p:last-child {
    margin-bottom: 0;
}

/* MathJax v3 SVG inline rendering */
.question-content.s-content mjx-container {
    display: inline !important;
    margin: 0;
    vertical-align: baseline;
    font-size: 100% !important;
}

.question-content.s-content mjx-container[display="true"] {
    display: block !important;
    margin: 8px 0;
    text-align: center;
}

/* Answer content */
.answer-content .content {
    font-size: 19px;
    line-height: 1.8;
}

.answer-content .content mjx-container {
    display: inline !important;
    margin: 0;
    vertical-align: baseline;
    font-size: 100% !important;
}

/* Guide / Explanation content */
.guide.s-content,
.title-question-guide+.guide {
    font-size: 21px !important;
    line-height: 1.8;
    background: #2C8234 !important;
}

/* Hide scrollbar artifacts inside guide/explanation section */
.guide p,
.guide .s-content p {
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
}

.guide::-webkit-scrollbar,
.guide p::-webkit-scrollbar,
.guide *::-webkit-scrollbar {
    display: none !important;
    height: 0 !important;
    width: 0 !important;
}

.guide {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Hide any checkbox/input elements accidentally in guide content */
.guide input[type="checkbox"],
.guide input[type="radio"] {
    display: none !important;
}

/* Essay result content */
.essay-result .s-content,
.essay-result>div {
    font-size: 15px;
    line-height: 1.8;
}

/* ================================================
   ANSWER CONTENT - MathJax SVG overflow fixes
   ================================================ */

/* Only scale BLOCK (display) MathJax formulas to fit container */
.answer-content .content mjx-container[display="true"],
.answer-content .content mjx-container[display="true"]>svg,
.question-content.s-content mjx-container[display="true"],
.question-content.s-content mjx-container[display="true"]>svg {
    max-width: 100%;
    height: auto !important;
}

/* Inline MathJax: do NOT restrict width - let text flow naturally */
.answer-content .content mjx-container:not([display="true"]),
.question-content.s-content mjx-container:not([display="true"]) {
    display: inline !important;
}

/* Answer content overflow - block flow for inline MathJax, no flex shrink */
.answer-content .content {
    display: block !important;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    line-height: 1.8;
    padding-top: 10px;
    padding-bottom: 10px;
}

.answer-content .content:hover {
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Webkit scrollbar - ultra thin, no arrows */
.answer-content .content::-webkit-scrollbar {
    height: 3px;
    background: transparent;
}

.answer-content .content::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.answer-content .content::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
}

.answer-content .content:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

/* Hide scrollbar arrow buttons completely */
.answer-content .content::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

/* Hide any vertical scrollbar on answer and question content */
.answer-content .content::-webkit-scrollbar:vertical,
.question-content.s-content::-webkit-scrollbar:vertical {
    width: 0;
    display: none;
}

/* Remove click overlay so scrollbar is interactive */
.answer-item .click-overlay {
    pointer-events: none;
}

/* Re-enable pointer events on the label itself for radio selection */
.answer-item {
    cursor: pointer;
}

.answer-item input[type="radio"] {
    cursor: pointer;
}

.answer-item .answer-content {
    cursor: pointer;
    position: relative;
    z-index: 1;
}

/* ================================================
   TF STATEMENT CONTENT - Same fixes as MC answers
   ================================================ */

/* Block flow for inline MathJax, prevent flex shrink */
.tf-statement-content {
    display: block !important;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    line-height: 1.8;
    font-size: 19px;
}

.tf-statement-content:hover {
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Inline MathJax in TF: flow naturally */
.tf-statement-content mjx-container:not([display="true"]) {
    display: inline !important;
    font-size: 100% !important;
}

/* Block MathJax in TF: scale to fit */
.tf-statement-content mjx-container[display="true"],
.tf-statement-content mjx-container[display="true"]>svg {
    max-width: 100%;
    height: auto !important;
}

/* Webkit scrollbar - ultra thin, no arrows */
.tf-statement-content::-webkit-scrollbar {
    height: 3px;
    background: transparent;
}

.tf-statement-content::-webkit-scrollbar-track {
    background: transparent;
}

.tf-statement-content::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
}

.tf-statement-content:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

.tf-statement-content::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

.tf-statement-content::-webkit-scrollbar:vertical {
    width: 0;
    display: none;
}