/*
 * Task Page Layout Styles
 * (Flyttet fra page-task-template.php)
 */
body {
    font-family: Arial, sans-serif;
    margin: 20px;
    background-color: #f4f6f9;
}

/* Owner controls (slug view) */
.top-button-row {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.top-button-versions select {
    flex: 0 0 auto;
    width: auto;
    min-width: auto;
    padding: 6px 8px;
    border: 1px solid #cfd6e1;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}
.top-button-row button,
.top-button-row a {
    background-color: #2ecc71;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    padding: 8px 10px;
    font-weight: bold;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.top-button-row button:hover,
.top-button-row a:hover {
    background-color: #27ae60;
}
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.btn-ai {
    background-color: #3498db;
}
.btn-ai:hover {
    background-color: #2d86c9;
}
.ai-loading-spinner {
    display: inline-block;
    vertical-align: middle;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    border: 2px solid #ccc;
    border-top: 2px solid #000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

h1, h2, h3 {
    color: #2c3e50;
}
/* Overskrift Styles */
h1 {
    font-family: 'Arial', sans-serif;
    font-size: 2.5em;
    color: #2c3e50;
    margin: 20px 0 10px;
    line-height: 1.2;
    letter-spacing: 1px;
}
h2 {
    font-family: 'Arial', sans-serif;
    font-size: 2em;
    font-weight: 600;
    color: #34495e;
    margin: 18px 0 10px;
    line-height: 1.3;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 5px;
}
h3 {
    font-family: 'Arial', sans-serif;
    font-size: 1.75em;
    font-weight: 500;
    color: #2c3e50;
    margin: 16px 0 8px;
    line-height: 1.4;
}
h4 {
    font-family: 'Arial', sans-serif;
    font-size: 1.5em;
    font-weight: 500;
    color: #34495e;
    margin: 14px 0 8px;
    line-height: 1.4;
}
p {
    line-height: 1.6;
    color: #34495e;
}
.login-container {
    margin-top: 50px;
    margin-bottom: 30px;
    padding: 20px;
    background-color: #fff;
    border: 2px solid #2c3e50;
    border-radius: 10px;
    box-shadow: 2px 2px 12px rgba(0,0,0,0.1);
}
.login-container input {
    padding: 10px;
    font-size: 16px;
    width: 80%;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}
.login-container button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #2ecc71;
    color: #fff;
}
.hidden {
    display: none;
}
.score-board {
    margin-bottom: 20px;
    padding: 20px;
    border: 2px solid #2c3e50;
    border-radius: 10px;
    background-color: #fff;
    font-weight: bold;
    font-size: 20px;
    color: #2c3e50;
    text-align: center;
}
.scoreboard-box {
    border: 2px solid #ccc;
    background-color: #f9f9f9;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
}
.screenshot-instructions {
    margin-top: 10px;
    font-style: italic;
}
.task-table {
    display: flex;
    flex-wrap: wrap;
    margin-top: 20px;
    gap: 10px;
    justify-content: flex-start;
}
.task-table-cell {
    border: 1px solid #ccc;
    text-align: center;
    padding: 8px 10px;
    flex: 0 1 auto;
    box-sizing: border-box;
    font-size: 14px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    white-space: nowrap;
}
.task-table-cell .task-number {
    font-weight: bold;
    margin-bottom: 3px;
    font-size: 14px;
}
.task-table-cell .task-points {
    font-size: 16px;
}
.task-table-cell.dash {
    color: #999;
}
.task-table-cell.points-3 {
    background-color: #d4edda;
}
.task-table-cell.points-2 {
    background-color: #fff3cd;
}
.task-table-cell.points-1 {
    background-color: #e2d6f9;
}
.task-table-cell.points-0 {
    background-color: #f8d7da;
}
.task-container {
    margin-bottom: 30px;
    padding: 20px; 
    background-color: #fff;
    border: 2px solid #2c3e50;
    border-radius: 10px;
    box-shadow: 2px 2px 12px rgba(0,0,0,0.1);
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}
.task-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 10px;
}
.buttons {
    margin-top: 10px;
}
.unit-answer-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.unit-input {
    margin-left: 2px;
}
.unit-special-button {
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid #b7b7b7;
    border-radius: 999px;
    background-color: #fff;
    color: #1f2d3d;
    cursor: pointer;
    white-space: nowrap;
}
.unit-special-button:hover {
    border-color: #87a7cd;
    background: #f4f8ff;
}
.unit-hint {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}
.unit-special-button:focus-visible,
.lc-unit-special-modal-option:focus-visible,
.lc-unit-special-modal-close:focus-visible {
    outline: 2px solid #5b8bd9;
    outline-offset: 2px;
}
.lc-unit-special-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10055;
}
.lc-unit-special-modal-dialog {
    position: relative;
    width: min(520px, 100%);
    max-height: 80vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #d5dde6;
    padding: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}
.lc-unit-special-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: 1px solid #d5dde6;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}
.lc-unit-special-modal-title {
    margin: 2px 36px 8px 0;
    font-size: 1.15em;
}
.lc-unit-special-modal-description {
    margin: 0 0 14px;
    color: #51606f;
    line-height: 1.45;
}
.lc-unit-special-modal-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
}
.lc-unit-special-modal-option {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-align: left;
    border: 1px solid #cfd9e3;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: #1f2d3d;
    cursor: pointer;
}
.lc-unit-special-modal-option:hover {
    border-color: #87a7cd;
    background: #f4f8ff;
}
.lc-unit-special-modal-option-symbol {
    font-size: 22px;
    font-weight: 600;
    line-height: 1;
}
.lc-unit-special-modal-option-label {
    font-size: 13px;
    color: #51606f;
    line-height: 1.3;
}
.sci-notation {
    display: none;
    align-items: center;
    gap: 1px;
}
.sci-notation.active {
    display: inline-flex;
}
.sci-exponent-input {
    width: 3ch;
    font-size: 0.55em;
    line-height: 1;
    padding: 0 2px;
    height: 1em;
    min-height: 0;
    box-sizing: content-box;
    position: relative;
    top: -1.05em;
}
.sci-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(#ffffff, #f1f1f1);
    border: 1px solid #b7b7b7;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12px;
    line-height: 1;
    font-weight: 600;
    color: #2c2c2c;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.sci-toggle:hover {
    background: #e9f1ff;
    border-color: #7da1d1;
}
.sci-toggle:active {
    background: #dfe9f9;
    box-shadow: none;
    transform: translateY(1px);
}
.sci-toggle:focus-visible {
    outline: 2px solid #5b8bd9;
    outline-offset: 2px;
}
.buttons button {
    margin-top: 10px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #3498db;
    color: #fff;
    margin-right: 10px;
}
.buttons button.keyboard-toggle {
    background-color: #16a085;
    border: 1px solid #0f6f5b;
    position: relative;
    font-weight: 600;
}
.buttons button.keyboard-toggle:hover {
    background-color: #139078;
}
.buttons button.keyboard-toggle.math-keyboard {
    background: linear-gradient(135deg, #16a085 0%, #1abc9c 100%);
    border: 2px solid #0f6f5b;
    box-shadow: 0 2px 4px rgba(22, 160, 133, 0.3);
}
.buttons button.keyboard-toggle.math-keyboard:hover {
    background: linear-gradient(135deg, #139078 0%, #16a085 100%);
    box-shadow: 0 3px 6px rgba(22, 160, 133, 0.4);
    transform: translateY(-1px);
}
.buttons button.keyboard-toggle.math-keyboard::before {
    content: '∑';
    margin-right: 4px;
    font-size: 1.1em;
    font-weight: bold;
}
.buttons button.reset {
    background-color: #e74c3c;
}
.feedback {
    margin-top: 10px;
    font-weight: bold;
}
.feedback.correct {
    color: green;
}
.feedback.error {
    color: red;
}

.task-error {
    margin-top: 10px;
    font-weight: bold;
    color: #c0392b;
}


.feedback.hint {
    color: orange;
}
.hint {
    color: orange;
}
.error {
    color: red;
}
.attempts-info {
    margin-top: 10px;
    font-size: 13px;
    color: #34495e;
}
.draggable-items, .dropzone-items {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px; 
}
.item {
    padding: 15px;
    margin: 5px;
    border: 3px solid #3498db;
    border-radius: 5px;
    text-align: center;
    cursor: grab;
    background-color: #eaf5fd;
    min-width: 180px;
    transition: background-color 0.3s, border-color 0.3s;
    touch-action: none;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}
.item:active {
    cursor: grabbing;
}
.dropzone {
    padding: 20px;
    margin: 5px;
    border: 3px dashed #2980b9;
    border-radius: 5px;
    text-align: center;
    background-color: #eaf2fb;
    min-width: 180px;
    min-height: 60px;
    flex: 1;
    transition: background-color 0.3s, border-color 0.3s;
    box-shadow: 0 0 5px rgba(41, 128, 185, 0.2);
}
.dropzone.hovered {
    border-color: #3498db;
    background-color: #dceeff;
}
.dropzone.correct {
    border-color: green;
    background-color: #d4edda;
}
.dropzone.incorrect {
    border-color: red;
    background-color: #f8d7da;
}
.order-task-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 10px;
    max-width: 100%;
    box-sizing: border-box;
}
.order-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.order-dropzone-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-wrap: nowrap;
    min-width: 0;
    max-width: 100%;
}
.order-draggable-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
}
.order-draggable-items .item {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    box-sizing: border-box;
}
.order-dropzone {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    overflow: hidden;
}
.order-number {
    font-weight: bold;
    color: #2c3e50;
    min-width: 24px;
    flex-shrink: 0;
}
.order-slot {
    flex: 1;
    min-height: 40px;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
.order-dropzone .item {
    margin: 0;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
.text-block {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-left: 4px solid #2c3e50;
    border-radius: 5px;
}
.choice-select {
    margin-left: 5px;
    margin-right: 5px;
    font-size: 16px;
    padding: 8px;
    line-height: 1.5;
}
.lc-text-choice-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 5px;
    vertical-align: middle;
}
.lc-text-choice-trigger,
.lc-text-choice-change {
    border: 1px solid #c6d1dc;
    background: #f8fbff;
    color: #2c3e50;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.2;
}
.lc-text-choice-trigger {
    padding: 8px 12px;
}
.lc-text-choice-change {
    padding: 4px 8px;
    font-size: 12px;
}
.lc-text-choice-trigger:hover,
.lc-text-choice-change:hover {
    background: #edf4ff;
}
.lc-text-choice-trigger:focus-visible,
.lc-text-choice-change:focus-visible,
.lc-text-choice-modal-option:focus-visible,
.lc-text-choice-modal-close:focus-visible {
    outline: 2px solid #5b8bd9;
    outline-offset: 2px;
}
.lc-text-choice-selected {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    border: 1px solid #d5dde6;
    border-radius: 6px;
    background: #fff;
    padding: 5px 10px;
    color: #1f2d3d;
}
.lc-text-choice-selected[hidden],
.lc-text-choice-change[hidden] {
    display: none !important;
}
.lc-text-choice-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10050;
}
.lc-text-choice-modal-dialog {
    position: relative;
    width: min(680px, 100%);
    max-height: 80vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #d5dde6;
    padding: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}
.lc-text-choice-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: 1px solid #d5dde6;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}
.lc-text-choice-modal-title {
    margin: 2px 36px 12px 0;
    font-size: 1.2em;
}
.lc-text-choice-modal-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
}
.lc-text-choice-modal-option {
    width: 100%;
    text-align: left;
    border: 1px solid #cfd9e3;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: #1f2d3d;
    cursor: pointer;
    line-height: 1.35;
}
.lc-text-choice-modal-option:hover {
    border-color: #87a7cd;
    background: #f4f8ff;
}
.lc-text-choice-modal-option.is-selected {
    border-color: #2d86c9;
    background: #eaf3ff;
}
.fill-in-blank {
    display: inline-block;
    width: auto;
    text-align: center;
    padding: 5px;
    margin: 0 5px;
    border: 1px solid #ccc;
    border-radius: 5px;
}
.mathlive-field {
    display: inline-block;
    min-width: 8ch;
    max-width: 95%;
    vertical-align: middle;
}
.mathlive-field.auto-expand {
    font-size: 1.06em;
    line-height: 1.3;
}
.auto-expand {
    font-size: 16px;
    padding: 8px;
    line-height: 1.5;
}
.cas-editor-container {
    margin-top: 10px;
    margin-bottom: 10px;
}
.cas-editor-applet {
    width: 600px;
    height: 300px;
    border: 1px solid #aaa;
    margin-bottom: 10px;
}
.graph-block-container {
    margin-bottom: 30px;
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 8px;
}
table, th, td {
    height: calc(4px * 2 + 1.5em);
    min-width: calc(8px * 4);
    padding: 4px 8px;
    border: 1px solid black;
    border-collapse: collapse;
}

/* Wrapper for tables so they can scroll horizontally on small screens (added by JS) */
.lc-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0.5em 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}
.loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s;
}
.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #3498db;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
    margin-bottom: 20px;
}
.loading-text {
    font-size: 18px;
    color: #2c3e50;
    font-weight: 500;
    text-align: center;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile responsive adjustments */
@media screen and (max-width: 768px) {
    /* Reduce base font size on mobile */
    body {
        font-size: 16px; /* Reduced from default */
        margin: 15px;
    }
    
    h1 {
        font-size: 1.8em; /* Reduced from 2.5em */
        margin: 15px 0 8px;
        letter-spacing: 0.5px;
    }
    
    h2 {
        font-size: 1.5em; /* Reduced from 2em */
        margin: 14px 0 8px;
    }
    
    h3 {
        font-size: 1.3em; /* Reduced from 1.75em */
        margin: 12px 0 6px;
    }
    
    h4 {
        font-size: 1.2em; /* Reduced from 1.5em */
        margin: 10px 0 6px;
    }
    
    p {
        font-size: 16px;
        line-height: 1.4;
    }
    
    /* Ensure LaTeX content scales better */
    .MathJax {
        font-size: 1.1em !important;
        max-width: 100% !important;
        overflow-x: auto !important;
    }
    
    .MathJax_Display {
        font-size: 1.2em !important;
        margin: 0.5em 0 !important;
    }
    
    /* Inline math */
    .MathJax[jax="CHTML"][display="true"] {
        font-size: 1.1em !important;
        margin: 0.5em 0 !important;
    }
    
    /* Display math */
    .MathJax[jax="CHTML"][display="false"] {
        font-size: 1.0em !important;
    }
    
    /* Better spacing around math in text */
    p .MathJax {
        margin: 0 2px !important;
    }
    
    /* Adjust form elements */
    .choice-select {
        font-size: 14px;
        padding: 6px 8px;
        margin: 2px;
        line-height: 1.3;
    }
    .lc-text-choice-inline {
        margin: 2px;
        gap: 4px;
    }
    .lc-text-choice-trigger {
        font-size: 13px;
        padding: 6px 9px;
    }
    .lc-text-choice-selected {
        font-size: 13px;
        padding: 4px 8px;
    }
    .lc-text-choice-change {
        font-size: 11px;
        padding: 3px 7px;
    }
    .lc-text-choice-modal {
        padding: 12px;
    }
    .lc-text-choice-modal-dialog {
        width: 100%;
        max-height: 86vh;
        padding: 12px;
    }
    .lc-text-choice-modal-options {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .lc-text-choice-modal-option {
        padding: 10px;
        font-size: 14px;
    }
    .lc-unit-special-modal {
        padding: 12px;
    }
    .lc-unit-special-modal-dialog {
        width: 100%;
        max-height: 86vh;
        padding: 12px;
    }
    .lc-unit-special-modal-options {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .auto-expand,
    .fill-in-blank {
        font-size: 14px;
        padding: 6px 8px;
        line-height: 1.3;
    }
    
    /* Checkbox and radio labels */
    .radio-group label {
        font-size: 16px;
        line-height: 1.4;
    }
    
    /* Task containers – allow horizontal scroll when content (e.g. tables) is wide */
    .task-container {
        padding: 15px;
        margin-bottom: 20px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Tables: ensure horizontal scroll is obvious on touch devices */
    .lc-table-wrapper {
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0.75em;
    }
    
    /* Login container adjustments */
    .login-container {
        margin-top: 30px;
        padding: 15px;
    }
    
    .login-container input {
        width: 90%;
        font-size: 16px;
        padding: 12px;
    }
    
    /* Score board adjustments */
    .score-board {
        font-size: 18px;
        padding: 15px;
    }
    
    /* Task table adjustments */
    .task-table-cell {
        padding: 6px 8px;
        font-size: 13px;
    }
    
    .task-table-cell .task-number {
        font-size: 13px;
    }
    
    .task-table-cell .task-points {
        font-size: 14px;
    }
    
    /* Button adjustments */
    .buttons button {
        padding: 10px 14px;
        font-size: 15px;
        margin: 8px 8px 0 0;
    }
    
    /* CAS editor adjustments */
    .cas-editor-applet {
        width: 100%;
        max-width: 600px;
        height: 250px;
    }
    
    /* Drag and drop adjustments */
    .item, .dropzone {
        min-width: 140px;
        padding: 12px;
        margin: 3px;
        font-size: 15px;
    }

    .order-task-layout {
        grid-template-columns: 1fr;
    }
    
    /* Text block adjustments */
    .text-block {
        padding: 12px;
        margin-bottom: 15px;
    }
}
