/* Shared Task Element Styles */

/* ABCD Task Styles */
.abcd-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.abcd-options.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-around;
}

.option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.abcd-options.horizontal .option {
    flex-basis: calc(50% - 10px); /* Two columns */
    margin-bottom: 15px;
}

.option label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex-grow: 1;
}

.option-image {
    max-width: 100px; 
    max-height: 100px;
    margin-right: 10px;
}

.option-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.option-text {
    flex-grow: 1;
    /* Prevent inappropriate text wrapping */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: keep-all;
    white-space: normal;
    hyphens: auto;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
}

/* Prevent text selection for ABCD option text (non-image) in all modes */
.abcd-options .option-text {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Prevent inappropriate text wrapping */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: keep-all;
    white-space: normal;
    hyphens: auto;
    max-width: 100%;
    overflow-x: hidden;
}

/* Ensure option letters stay with their text */
.option-letter {
    display: inline-block;
    white-space: nowrap;
    margin-right: 8px;
    font-weight: bold;
}

/* Prevent splitting of option patterns like "D. text" */
.question-content,
.statement-text,
.option-text {
    /* Ensure text wraps properly without splitting option letters from their text */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: keep-all;
    white-space: normal;
    hyphens: auto;
    max-width: 100%;
    overflow-x: hidden;
    /* Prevent orphaned option letters */
    orphans: 2;
    widows: 2;
}

/* True/False Task Styles */
.truefalse-statements {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.statement-container {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
}

.statement-number {
    font-size: 1em;
    font-weight: 500;
    color: #374151;
    min-width: 20px;
    flex-shrink: 0;
}

.statement-text {
    font-size: 1em;
    line-height: 1.6;
    margin: 0;
    flex: 1;
    /* Prevent inappropriate text wrapping */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: keep-all;
    white-space: normal;
    hyphens: auto;
    max-width: 100%;
    overflow-x: hidden;
}

.truefalse-options {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-shrink: 0;
    margin-left: 15px;
}

.truefalse-options input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 50%;
    background-color: white;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-right: 5px;
}

.truefalse-options input[type="radio"]:hover {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.08);
}

.truefalse-options input[type="radio"]:checked {
    border-color: #3b82f6;
    background-color: #3b82f6;
}

.truefalse-options input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background-color: white;
    border-radius: 50%;
}

.truefalse-options input[type="radio"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.truefalse-options label {
    cursor: pointer;
    font-weight: 500;
    color: #374151;
    font-size: 0.95em;
    user-select: none;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}

.truefalse-options label:hover {
    color: #1f2937;
}

.truefalse-options input[type="radio"]:checked + label {
    color: #1f2937;
    font-weight: 600;
}

/* ---------------------------------------------- */
/* Prevent inner scrollbars in ABCD/TrueFalse UIs */
/* ---------------------------------------------- */
/*
   Sometimes browsers render a vertical scrollbar with arrow buttons
   inside option blocks when a parent container accidentally applies
   overflow: auto or a constrained height. The rules below ensure that
   ABCD and True/False option containers never create their own vertical
   scroll areas and that any scrollbars are hidden across browsers.
*/

/* Disallow inner scrolling entirely (no scroll room) */
.abcd-options,
.abcd-options .option,
.abcd-options label,
.abcd-options .option-text,
.truefalse-statements,
.truefalse-statements .statement-container,
.truefalse-statements .statement-text,
.truefalse-options {
    overflow: hidden !important;
    max-height: none !important;
    overscroll-behavior: none;     /* Prevent scroll chaining/bounce */
    -webkit-overflow-scrolling: auto; /* Disable momentum scroll on iOS */
}

/* Hide scrollbars if any UA still paints them */
.abcd-options,
.abcd-options .option,
.abcd-options label,
.abcd-options .option-text,
.truefalse-statements,
.truefalse-statements .statement-container,
.truefalse-statements .statement-text,
.truefalse-options {
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge legacy */
}

.abcd-options::-webkit-scrollbar,
.abcd-options .option::-webkit-scrollbar,
.abcd-options label::-webkit-scrollbar,
.abcd-options .option-text::-webkit-scrollbar,
.truefalse-statements::-webkit-scrollbar,
.truefalse-statements .statement-container::-webkit-scrollbar,
.truefalse-statements .statement-text::-webkit-scrollbar,
.truefalse-options::-webkit-scrollbar {
    display: none;               /* WebKit */
}

/* Extra safety for LaTeX-rendered content inside options/statements */
.abcd-options mjx-container,
.abcd-options .MathJax,
.truefalse-statements mjx-container,
.truefalse-statements .MathJax {
    display: inline-block;
    max-width: 100%;
    overflow: visible !important;
}

/* Ensure MathJax containers wrap within parent on small screens */
@media (max-width: 768px) {
    mjx-container {
        display: inline-block;
        max-width: 100% !important;
        overflow-wrap: anywhere;
        word-break: break-word;
        white-space: normal !important;
    }
    /* Baseline alignment for inline formulas in task elements */
    mjx-container:not([display="true"]) {
        vertical-align: -0.1em;
    }
    .statement-text mjx-container,
    .option-text mjx-container,
    .question-content mjx-container {
        display: inline-block;
        max-width: 100% !important;
    }
    /* SVG output fallback: prevent overflow of long expressions */
    .MathJax svg,
    mjx-container[jax="SVG"] svg {
        max-width: 100% !important;
        height: auto;
    }
}

/* Hide any descendant scrollbars inside text blocks (e.g., nested spans from MathJax) */
.abcd-options .option-text *,
.truefalse-statements .statement-text * {
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge legacy */
}

.abcd-options .option-text *::-webkit-scrollbar,
.truefalse-statements .statement-text *::-webkit-scrollbar {
    display: none;               /* WebKit */
}

/* Fill Blanks Task Styles */
.fillblanks-container {
    margin-top: 15px;
}

.fillblanks-exercise {
    line-height: 2;
    font-size: 1.1em;
}

.blank-input {
    display: inline-block;
    min-width: 80px;
    min-height: 20px;
    height: 20px;
    padding: 2px 4px;
    margin: 0 2px;
    border: none;
    border-bottom: 2px dotted #666;
    font-size: inherit;
    line-height: 1.1;
    background-color: transparent;
    text-align: center;
    color: #2196F3;
    font-weight: 500;
    -webkit-appearance: none;
    appearance: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
    position: relative;
    vertical-align: top;
    resize: none;
    overflow: hidden;
}

.blank-input:focus {
    outline: none;
    border-bottom: 2px solid #2196F3;
    background-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.15);
}

.blank-input::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #2196F3, #64B5F6);
    transform: scaleX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.blank-input:focus::before {
    transform: scaleX(1);
}

.blank-input::placeholder {
    color: #aaa; 
    opacity: 0.7;
}

/* Ensure multi-line blank inputs (textareas) have left-aligned text */
textarea.blank-input {
    text-align: left;
}

/* Matching Task Styles */
.matching-container {
    margin: 20px 0;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid #ccc; /* Adjusted border */
    padding: 20px;
    border-radius: 8px;
}

.matching-instruction {
    font-style: italic;
    color: #666;
    margin-bottom: 15px;
}

.matching-columns {
    display: flex;
    align-items: flex-start; /* Align items to top */
    gap: 20px; /* Reduced gap */
    margin-top: 15px;
    justify-content: center;
}

.matching-middle-text {
    display: flex;
    align-items: center;
    justify-content: center;
    font-style: italic;
    min-height: 50px; /* Reduced height */
    width: 120px; /* Reduced width */
    padding: 0 15px;
    text-align: center;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
}

.left-column, .right-column {
    width: 250px; /* Reduced width */
    display: flex;
    flex-direction: column;
    gap: 8px; /* Reduced gap */
}

.matching-item {
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    user-select: none;
    word-wrap: break-word;
    border: 1px solid #aaa;
    text-align: left;
}

.matching-item.selected {
    background-color: #e3f2fd;
    border: 1px solid #2196F3;
}

.matching-item.matched {
    background-color: #e8f5e9;
    border: 1px solid #4CAF50;
}

.matching-item:hover:not(.selected):not(.matched) {
    background-color: #e9ecef;
    border-color: #666;
}

.matching-item.selected:hover {
    background-color: #d4e9fc;
    border-color: #1976D2;
}

.matching-item.matched:hover {
    background-color: #d5ecd6;
    border-color: #388E3C;
}

/* Word Choice Task Styles */
.wordchoice-container {
    margin-top: 15px;
}

.wordchoice-text {
    margin-bottom: 15px;
}

.wordchoice-option {
    margin-bottom: 10px;
}

.wordchoice-option p {
    font-weight: bold;
    margin-bottom: 5px;
}

.wordchoice-option label {
    display: block; /* Or inline-block if preferred */
    margin-right: 15px;
    margin-bottom: 5px;
}

/* Multi-Answer Task Styles */
.multianswer-container {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.answer-part {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.answer-part label {
    font-weight: bold;
}

.element-answer {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1em;
}

/* Open Answer Task Styles */
.open-answer-container {
    margin-top: 15px;
}

.open-answer {
    width: 100%;
    min-height: 120px;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    resize: vertical;
    background-color: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.open-answer:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.open-answer::placeholder {
    color: #9ca3af;
    font-style: italic;
}

/* Table Task Styles */
.question-table {
    margin-top: 20px;
}

.table-text, .table-instruction {
    margin-bottom: 10px;
}

.question-table table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.question-table th,
.question-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.question-table th {
    background-color: #f8f9fa;
}

.editable-cell {
    background-color: #eef; /* Light blue background for editable cells */
}

.readonly-cell {
    background-color: #f9f9f9;
}

.table-input {
    width: 100%;
    padding: 6px;
    border: 1px solid #bbb;
    border-radius: 3px;
    box-sizing: border-box;
}

.table-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Text Area Styles */
textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    font-size: 1em;
    line-height: 1.5;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    white-space: pre-wrap; /* Preserve line breaks but wrap text */
    word-wrap: break-word; /* Break long words if necessary */
    box-sizing: border-box; /* Include padding in width calculation */
}

/* Ensure text areas in task content don't cause horizontal scroll */
.task-content textarea {
    max-width: 100%;
    box-sizing: border-box;
}

/* Przecinki Task Result Styles - Seamless white background design */
.result-przecinki {
    background-color: white;
    border: none;
    padding: 0;
    margin: 20px 0;
    font-family: 'Georgia', 'Times New Roman', serif;
}

.result-sentence {
    font-size: 18px;
    line-height: 1.8;
    color: #2c3e50;
    margin: 20px 0;
    padding: 25px;
    background-color: white;
    border: none;
    text-align: justify;
    word-wrap: break-word;
}

.result-sentence .word {
    display: inline;
    font-weight: normal;
    color: #2c3e50;
    letter-spacing: 0.3px;
}

.comma-result {
    display: inline-block;
    position: relative;
    margin: 0 2px;
    font-size: 20px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.comma-result.correct-comma {
    color: #27ae60;
    background-color: rgba(46, 204, 113, 0.1);
    border-radius: 3px;
    padding: 2px 4px;
}

.comma-result.incorrect-comma {
    color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
    border-radius: 3px;
    padding: 2px 4px;
}

.comma-result.missing-comma {
    color: #f39c12;
    background-color: rgba(243, 156, 18, 0.1);
    border-radius: 3px;
    padding: 2px 4px;
}

.comma-result.no-comma {
    color: transparent;
    background-color: transparent;
}

.missing-comma-indicator {
    color: #f39c12;
    font-weight: bold;
    font-size: 16px;
    background-color: rgba(243, 156, 18, 0.15);
    border-radius: 3px;
    padding: 1px 3px;
    margin: 0 2px;
}

.przecinki-summary {
    background-color: white;
    border: none;
    padding: 20px 25px;
    margin: 20px 0;
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 16px;
    line-height: 1.6;
    color: #2c3e50;
}

.przecinki-summary p {
    margin: 10px 0;
    color: #2c3e50;
}

.przecinki-summary .correct {
    color: #27ae60;
    font-weight: bold;
}

.przecinki-summary .incorrect {
    color: #e74c3c;
    font-weight: bold;
}

.przecinki-summary .missing {
    color: #f39c12;
    font-weight: bold;
}

/* Mobile optimizations for przecinki results */
@media screen and (max-width: 768px) {
    .result-sentence {
        font-size: 19px;
        line-height: 1.9;
        padding: 20px 15px;
        text-align: left;
    }
    
    .result-sentence .word {
        letter-spacing: 0.4px;
    }
    
    .comma-result {
        font-size: 22px;
        margin: 0 3px;
    }
    
    .missing-comma-indicator {
        font-size: 18px;
        margin: 0 3px;
    }
    
    .przecinki-summary {
        padding: 15px;
        font-size: 17px;
    }
}

/* Tablet optimizations for przecinki results */
@media (min-width: 769px) and (max-width: 1024px) {
    .result-sentence {
        font-size: 19px;
        line-height: 1.85;
        padding: 30px 20px;
    }
}

/* Large screen optimizations for przecinki results */
@media (min-width: 1025px) {
    .result-sentence {
        font-size: 20px;
        line-height: 1.9;
        padding: 35px 30px;
        max-width: 900px;
        margin: 40px auto;
    }
    
    .przecinki-summary {
        max-width: 900px;
        margin: 40px auto;
        padding: 25px 30px;
    }
}

/* High contrast mode support for przecinki results */
@media (prefers-contrast: high) {
    .result-sentence,
    .result-sentence .word,
    .przecinki-summary,
    .przecinki-summary p {
        color: #000000;
    }
    
    .comma-result.correct-comma {
        color: #006600;
        background-color: rgba(0, 102, 0, 0.2);
    }
    
    .comma-result.incorrect-comma {
        color: #cc0000;
        background-color: rgba(204, 0, 0, 0.2);
    }
    
    .comma-result.missing-comma,
    .missing-comma-indicator {
        color: #cc6600;
        background-color: rgba(204, 102, 0, 0.2);
    }
}

/* Print styles for przecinki results */
@media print {
    .result-sentence,
    .przecinki-summary {
        background-color: transparent;
        color: #000000;
        font-size: 14pt;
        line-height: 1.6;
    }
    
    .result-sentence .word {
        color: #000000;
    }
    
    .comma-result {
        background-color: transparent;
    }
    
    .comma-result.correct-comma {
        color: #000000;
    }
    
    .comma-result.incorrect-comma {
        color: #000000;
        text-decoration: line-through;
    }
    
    .comma-result.missing-comma,
    .missing-comma-indicator {
        color: #000000;
        font-style: italic;
    }
} 