/**
 * Styles for local_unifiedgrader.
 *
 * @package    local_unifiedgrader
 * @copyright  2026 South African Theological Seminary (mathieu@sats.ac.za)
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

/* Unified Grader - local_unifiedgrader styles. */
/* stylelint-disable declaration-no-important */

/* Hide the activity header/description that Moodle injects above our grading interface.
   grade.php uses pagelayout-embedded, so scope to that layout only. */
.pagelayout-embedded .activity-header,
.pagelayout-embedded .activity-description,
.pagelayout-embedded .activity-information {
    display: none !important;
}

.local-unifiedgrader-container {
    height: calc(100vh - 60px);
}

/* Below 1200px the header text wraps — increase header height to accommodate. */
@media (max-width: 1199px) {
    .local-unifiedgrader-container > .d-flex.border-bottom {
        height: 110px !important;
    }
}

.local-unifiedgrader-container [data-region="preview-panel"],
.local-unifiedgrader-container [data-region="marking-panel"] {
    height: 100%;
    overflow-y: auto;
}

.local-unifiedgrader-container [data-region="document-preview"] {
    padding-left: 20px;
}

.local-unifiedgrader-container [data-region="preview-content"] .card-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.local-unifiedgrader-container .note-item {
    background-color: var(--bs-warning-bg-subtle, #fff3cd);
    border-color: var(--bs-warning-border-subtle, #ffe69c);
}

.local-unifiedgrader-container [data-region="file-list"] .list-group-item:hover {
    background-color: var(--bs-primary-bg-subtle, #cfe2ff);
}

.local-unifiedgrader-container [data-region="participant-list"] .list-group-item.active {
    background-color: var(--bs-primary);
    color: var(--bs-white);
}

.local-unifiedgrader-container .saving-indicator {
    opacity: 0.6;
    pointer-events: none;
}

/* Allow the student navigator and comments dropdowns to overflow the fixed-height header. */
.local-unifiedgrader-container [data-region="student-navigator"],
.local-unifiedgrader-container [data-region="student-info-header"] {
    overflow: visible;
}

.local-unifiedgrader-container .local-unifiedgrader-nav-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    z-index: 200;
    background-color: #fff;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    padding: 0.75rem;
}

/* Layout toggle: preview-only — hide grading panel, expand preview to full width. */
.local-unifiedgrader-container.layout-preview-only [data-region="marking-panel-wrapper"] {
    display: none !important;
}

.local-unifiedgrader-container.layout-preview-only [data-region="preview-panel"] {
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

/* Layout toggle: grade-only — hide preview panel, expand grading to full width. */
.local-unifiedgrader-container.layout-grade-only [data-region="preview-panel"] {
    display: none !important;
}

.local-unifiedgrader-container.layout-grade-only [data-region="marking-panel-wrapper"] {
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

.local-unifiedgrader-container [data-region="loading-overlay"] {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 100;
}

/* PDF viewer — continuous scroll page slots. */
.local-unifiedgrader-container .pdf-page-slot,
.local-unifiedgrader-feedback .pdf-page-slot {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

.local-unifiedgrader-container .pdf-page-slot + .pdf-page-slot,
.local-unifiedgrader-feedback .pdf-page-slot + .pdf-page-slot {
    margin-top: 4px;
}

/* PDF viewer. */
.local-unifiedgrader-container [data-region="pdf-viewer"] {
    background-color: var(--bs-gray-200, #e9ecef);
}

.local-unifiedgrader-container [data-region="pdf-page-container"] {
    scrollbar-width: thin;
}

.local-unifiedgrader-container [data-region="pdf-canvas-wrapper"] {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    background-color: #fff;
}

.local-unifiedgrader-container [data-region="pdf-controls"] button {
    line-height: 1;
}

.local-unifiedgrader-container [data-region="pdf-controls"] button:disabled {
    opacity: 0.35;
}

/* Annotation toolbar. */
.local-unifiedgrader-container [data-region="annotation-toolbar"] {
    padding-left: 12px;
}

.local-unifiedgrader-container [data-region="annotation-toolbar-inner"] {
    min-height: 36px;
}

.local-unifiedgrader-container .annotation-color-btn {
    width: 20px;
    height: 20px;
    border: 2px solid transparent !important;
    transition: border-color 0.15s;
}

.local-unifiedgrader-container .annotation-color-btn.active {
    border-color: var(--bs-dark, #212529) !important;
    box-shadow: 0 0 0 1px #fff, 0 0 0 3px var(--bs-dark, #212529);
}

.local-unifiedgrader-container .annotation-color-btn:hover {
    border-color: var(--bs-secondary, #6c757d) !important;
}

/* Comment picker (library + free text) for annotation tool. */
.annotation-comment-picker {
    position: absolute;
    z-index: 10;
    background: #fff;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.375rem;
    padding: 0;
    width: 360px;
    max-height: 420px;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.annotation-comment-picker .picker-library {
    flex: 1 1 auto;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.annotation-comment-picker .picker-tags {
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.06));
    flex-shrink: 0;
}

.annotation-comment-picker .picker-list {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: 240px;
}

.annotation-comment-picker .picker-comment-item {
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.06));
    cursor: pointer;
    transition: background-color 0.1s;
    font-size: 0.8125rem;
    line-height: 1.35;
}

.annotation-comment-picker .picker-comment-item:last-child {
    border-bottom: none;
}

.annotation-comment-picker .picker-comment-item:hover {
    background-color: var(--bs-primary-bg-subtle, #cfe2ff);
}

.annotation-comment-picker .picker-freetext {
    flex-shrink: 0;
    padding: 0.5rem;
}

.annotation-comment-picker .picker-freetext textarea {
    resize: vertical;
    min-height: 48px;
    font-size: 0.8125rem;
}

/* Autocomplete dropdown in the free-text section. */
.annotation-comment-picker .picker-autocomplete {
    display: none;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.25rem;
    background: #fff;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.annotation-comment-picker .picker-ac-item {
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    font-size: 0.78rem;
    line-height: 1.3;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.06));
}

.annotation-comment-picker .picker-ac-item:last-child {
    border-bottom: none;
}

.annotation-comment-picker .picker-ac-item:hover,
.annotation-comment-picker .picker-ac-item.active {
    background-color: var(--bs-primary-bg-subtle, #cfe2ff);
}

/* Autocomplete dropdown for marking guide remark textareas. */
.ug-autocomplete-dropdown {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.25rem;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 2px;
}

.ug-ac-item {
    padding: 0.35rem 0.5rem;
    cursor: pointer;
    font-size: 0.78rem;
    line-height: 1.35;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.06));
}

.ug-ac-item:last-child {
    border-bottom: none;
}

.ug-ac-item:hover,
.ug-ac-item.active {
    background-color: var(--bs-primary-bg-subtle, #cfe2ff);
}

.annotation-comment-picker .picker-empty,
.annotation-comment-picker .picker-loading {
    padding: 1rem;
    text-align: center;
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.8125rem;
}

/* Comment tooltip (read-only hover display). */
.annotation-comment-tooltip {
    position: absolute;
    z-index: 9;
    background: var(--bs-dark, #212529);
    color: #fff;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    max-width: 200px;
    font-size: 0.8125rem;
    line-height: 1.3;
    pointer-events: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
}

/* Word count tooltip for text selection mode. */
.text-selection-wordcount {
    position: absolute;
    z-index: 10;
    background: var(--bs-primary, #0d6efd);
    color: #fff;
    border-radius: 0.75rem;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.25);
}

/* Student feedback view — use full available width, eliminate extra margins/padding. */
.local-unifiedgrader-feedback-page .main-inner {
    max-width: 100% !important;
    margin-bottom: 0 !important;
}

.local-unifiedgrader-feedback-page #region-main {
    max-width: 100% !important;
}

.local-unifiedgrader-feedback-page #page-content {
    padding-bottom: 0 !important;
}

/* Student feedback view — hide breadcrumbs, page heading, and secondary nav.
   Our header bar has a back arrow and activity name, so these are redundant. */
.local-unifiedgrader-feedback-page #page-navbar,
.local-unifiedgrader-feedback-page .breadcrumb-wrapper,
.local-unifiedgrader-feedback-page nav[aria-label="breadcrumb"],
.local-unifiedgrader-feedback-page #page-header,
.local-unifiedgrader-feedback-page .secondary-navigation,
.local-unifiedgrader-feedback-page #page-footer {
    display: none !important;
}

/* Responsive media in marking panel (teacher grading view). */
.local-unifiedgrader-container [data-region="marking-panel"] video,
.local-unifiedgrader-container [data-region="marking-panel"] img,
.local-unifiedgrader-container [data-region="marking-panel"] iframe {
    max-width: 100%;
    height: auto;
}

/* Audio elements need block display and must NOT have height:auto (no intrinsic height). */
.local-unifiedgrader-container [data-region="marking-panel"] audio {
    display: block;
    width: 100%;
    max-width: 100%;
}

/* Feedback display banner — ensure audio/video players render visibly. */
.local-unifiedgrader-container [data-region="feedback-display-content"] audio,
.local-unifiedgrader-container [data-region="feedback-display-content"] video {
    display: block;
    width: 100%;
    margin: 0.5rem 0;
}

/* Student feedback view — responsive media in feedback panel. */
.local-unifiedgrader-feedback .card-body video,
.local-unifiedgrader-feedback .card-body img {
    max-width: 100%;
    height: auto;
}

/* Student feedback view — iframes (embedded videos) need explicit dimensions. */
.local-unifiedgrader-feedback .card-body iframe {
    max-width: 100%;
    min-height: 240px;
}

/* Student feedback view — audio needs block display, no height:auto. */
.local-unifiedgrader-feedback .card-body audio {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0.5rem 0;
}

/* Student feedback view — hide annotation toolbar (read-only mode). */
.local-unifiedgrader-feedback [data-region="annotation-toolbar"] {
    display: none !important;
}

/* Student feedback view — PDF viewer needs the same canvas positioning. */
.local-unifiedgrader-feedback [data-region="pdf-viewer"] {
    background-color: var(--bs-gray-200, #e9ecef);
}

.local-unifiedgrader-feedback [data-region="pdf-canvas-wrapper"] {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    background-color: #fff;
}

.local-unifiedgrader-feedback [data-region="pdf-canvas-wrapper"] .canvas-container {
    position: absolute !important;
    top: 0;
    left: 0;
    z-index: 2 !important;
}

.local-unifiedgrader-feedback [data-region="pdf-page-container"] {
    scrollbar-width: thin;
}

/* PDF.js text layer — transparent text positioned over the PDF canvas for selection. */
[data-region="pdf-text-layer"] {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    line-height: 1.0;
    pointer-events: none;
    overflow: visible;
    opacity: 1;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    -webkit-user-select: none;
    user-select: none;
}

[data-region="pdf-text-layer"] span,
[data-region="pdf-text-layer"] br {
    color: transparent;
    position: absolute;
    white-space: pre;
    transform-origin: 0% 0%;
}

/* When text selection is enabled (select mode or read-only). */
[data-region="pdf-text-layer"].text-selectable {
    z-index: 4 !important;
    -webkit-user-select: text;
    user-select: text;
}

[data-region="pdf-text-layer"].text-selectable span {
    pointer-events: auto;
    cursor: text;
    -webkit-user-select: text;
    user-select: text;
}

[data-region="pdf-text-layer"] ::selection {
    background: rgba(0, 0, 255, 0.25);
    mix-blend-mode: multiply;
}

/* PDF.js link overlay — clickable hyperlinks positioned above all layers. */
[data-region="pdf-link-layer"] {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    pointer-events: none;
    overflow: visible;
}

[data-region="pdf-link-layer"] a {
    pointer-events: auto;
    position: absolute;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

[data-region="pdf-link-layer"] a:hover {
    opacity: 1;
    background: rgba(255, 255, 0, 0.15);
    outline: 2px solid rgba(0, 0, 255, 0.3);
    border-radius: 2px;
}

/* Fabric.js canvas container — Fabric creates a wrapper div that needs positioning. */
.local-unifiedgrader-container [data-region="pdf-canvas-wrapper"] .canvas-container {
    position: absolute !important;
    top: 0;
    left: 0;
    z-index: 2 !important;
}

/* Document info popout. */
.local-unifiedgrader-docinfo-popout {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 280px;
    max-width: calc(100vw - 2rem);
    z-index: 200;
    background: #fff;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    font-size: 0.8125rem;
}

.local-unifiedgrader-docinfo-popout .docinfo-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.06));
}

.local-unifiedgrader-docinfo-popout .docinfo-row:last-child {
    border-bottom: none;
}

.local-unifiedgrader-docinfo-popout .docinfo-label {
    color: var(--bs-secondary-color, #6c757d);
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.local-unifiedgrader-docinfo-popout .docinfo-value {
    text-align: right;
    word-break: break-all;
    font-weight: 500;
}

/* Student profile popout — fixed positioning set by JS for viewport clamping. */
.local-unifiedgrader-profile-popout {
    position: fixed;
    width: 320px;
    max-width: calc(100vw - 2rem);
    z-index: 1050;
    background: #fff;
    border: 2px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

/* Submission comments popout — messenger style. */
.local-unifiedgrader-comments-popout {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 440px;
    max-width: calc(100vw - 2rem);
    max-height: 520px;
    z-index: 200;
    background: #fff;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.75rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
}

.local-unifiedgrader-comments-popout .comments-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.local-unifiedgrader-comments-popout [data-region="comments-list"] {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: 380px;
    padding: 0.75rem;
}

.local-unifiedgrader-comments-popout [data-region="comments-form"] {
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    padding: 0.75rem;
}

/* Shared chat bubble styles (grading popout + student feedback view). */
.comment-bubble {
    margin-bottom: 0.75rem;
    max-width: 85%;
    position: relative;
}

.comment-bubble:last-child {
    margin-bottom: 0;
}

.comment-bubble-own {
    margin-left: auto;
    text-align: right;
}

.comment-bubble-other {
    margin-right: auto;
    text-align: left;
}

.comment-bubble .comment-meta {
    font-size: 0.7rem;
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 0.2rem;
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
}

.comment-bubble-own .comment-meta {
    justify-content: flex-end;
}

.comment-bubble .comment-body {
    padding: 0.5rem 0.875rem;
    border-radius: 1.125rem;
    font-size: 0.875rem;
    line-height: 1.45;
    word-break: break-word;
    display: inline-block;
    text-align: left;
}

.comment-bubble-own .comment-body {
    background-color: var(--bs-primary, #0d6efd);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.comment-bubble-own .comment-body a {
    color: #fff;
    text-decoration: underline;
}

.comment-bubble-other .comment-body {
    background-color: var(--bs-gray-100, #f8f9fa);
    color: var(--bs-body-color, #212529);
    border-bottom-left-radius: 0.25rem;
}

.comment-bubble .comment-delete-btn {
    opacity: 0;
    transition: opacity 0.15s;
    font-size: 0.65rem;
    line-height: 1;
}

.comment-bubble:hover .comment-delete-btn {
    opacity: 0.6;
}

.comment-bubble .comment-delete-btn:hover {
    opacity: 1 !important;
}

/* Student feedback view — comments card. */
.local-unifiedgrader-feedback [data-region="feedback-comments"] [data-region="comments-list"] {
    min-height: 80px;
}

/* Student feedback view — popouts anchored to right (icons are in top-right header). */
.local-unifiedgrader-feedback .local-unifiedgrader-comments-popout,
.local-unifiedgrader-feedback .local-unifiedgrader-files-popout {
    left: auto;
    right: 0;
}

/* Activity overview — popout anchored to right (icon sits at far right of dates row). */
.local-unifiedgrader-activity-comments .local-unifiedgrader-comments-popout {
    left: auto;
    right: 0;
}

/* Collapsible card sections — chevron rotation. */
.local-unifiedgrader-container [data-bs-toggle="collapse"] .collapse-icon {
    transition: transform 0.2s ease;
}

.local-unifiedgrader-container [data-bs-toggle="collapse"].collapsed .collapse-icon {
    transform: rotate(-90deg);
}

/* Chevron rotation when the icon itself is the collapse toggle (rubric section). */
.local-unifiedgrader-container .collapse-icon[data-bs-toggle="collapse"] {
    transition: transform 0.2s ease;
}

.local-unifiedgrader-container .collapse-icon[data-bs-toggle="collapse"].collapsed {
    transform: rotate(-90deg);
}

/* Feedback files filemanager — constrain thumbnails rendered by our custom refresh. */
.local-unifiedgrader-container .filemanager .fp-content .fp-file {
    display: inline-block;
    text-align: center;
    width: 110px;
    vertical-align: top;
    padding: 0.25rem;
    cursor: pointer;
}

.local-unifiedgrader-container .filemanager .fp-content .fp-thumbnail img {
    max-width: 64px;
    max-height: 64px;
}

.local-unifiedgrader-container .filemanager .fp-content .fp-thumbnail {
    position: relative;
    display: inline-block;
}

.local-unifiedgrader-container .filemanager .fp-content .fp-saved-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 1rem;
    color: #198754;
    background: #fff;
    border-radius: 50%;
    line-height: 1;
}

.local-unifiedgrader-container .filemanager .fp-content .fp-filename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
    max-width: 100px;
    margin: 0 auto;
}

/* Forum post plagiarism popout. */
.local-unifiedgrader-plagiarism-popout {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 300px;
    max-width: calc(100vw - 2rem);
    max-height: 320px;
    overflow-y: auto;
    z-index: 200;
    background: #fff;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    font-size: 0.8125rem;
}

.local-unifiedgrader-plagiarism-popout .plagiarism-popout-content a {
    word-break: break-all;
}

.plagiarism-shield-btn:hover {
    text-decoration: none;
    opacity: 0.8;
}

.plagiarism-shield-btn:focus-visible {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Comment library popout — fixed positioning to escape overflow-auto ancestor. */
.local-unifiedgrader-clib-popout {
    position: fixed;
    width: 480px;
    max-width: calc(100vw - 1rem);
    max-height: 600px;
    z-index: 300;
    background: #fff;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.75rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.14);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
}

.local-unifiedgrader-clib-popout .clib-header {
    flex-shrink: 0;
}

.local-unifiedgrader-clib-popout .clib-tags {
    flex-shrink: 0;
}

.local-unifiedgrader-clib-popout .clib-tags .badge {
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    transition: background-color 0.15s;
}

.local-unifiedgrader-clib-popout .clib-tags .badge:hover {
    opacity: 0.85;
}

.local-unifiedgrader-clib-popout .clib-list {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

.local-unifiedgrader-clib-popout .clib-comment-item {
    padding: 0.5rem;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.06));
    cursor: pointer;
    transition: background-color 0.1s;
}

.local-unifiedgrader-clib-popout .clib-comment-item:last-child {
    border-bottom: none;
}

.local-unifiedgrader-clib-popout .clib-comment-item:hover {
    background-color: var(--bs-primary-bg-subtle, #cfe2ff);
}

.local-unifiedgrader-clib-popout .clib-comment-text {
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.local-unifiedgrader-clib-popout .clib-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    padding-top: 0.5rem;
}

/* Comment library clipboard toast. */
.local-unifiedgrader-clib-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bs-dark, #212529);
    color: #fff;
    padding: 0.5rem 1.25rem;
    border-radius: 2rem;
    font-size: 0.8125rem;
    z-index: 9999;
    pointer-events: none;
    animation: clib-toast-fade 2s ease forwards;
}

@keyframes clib-toast-fade {
    0% {
        opacity: 1;
    }
    75% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Comment library modal — wider than default .modal-lg. */
.local-unifiedgrader-clib-modal {
    max-width: 960px;
}

/* Feedback files popout. */
.local-unifiedgrader-files-popout {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 340px;
    max-width: calc(100vw - 2rem);
    max-height: 400px;
    z-index: 200;
    background: #fff;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.75rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    overflow-y: auto;
}

/* Penalty popout — fixed positioning like comment library popout. */
.local-unifiedgrader-penalty-popout {
    position: fixed;
    width: 340px;
    max-width: calc(100vw - 1rem);
    max-height: 400px;
    z-index: 300;
    background: #fff;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.75rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.14);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.local-unifiedgrader-penalty-popout .penalty-section {
    margin-bottom: 0.75rem;
}

.local-unifiedgrader-penalty-popout .penalty-section:last-child {
    margin-bottom: 0;
}

.local-unifiedgrader-penalty-popout .penalty-preset-btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.local-unifiedgrader-penalty-popout .penalty-preset-btn.active {
    background-color: var(--bs-danger, #dc3545);
    color: #fff;
    border-color: var(--bs-danger, #dc3545);
}

.local-unifiedgrader-penalty-popout .penalty-active-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Penalty badges in marking panel and student view. */
.local-unifiedgrader-penalty-badge {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Assignment view — inline submission comments widget. */
.local-unifiedgrader-inline-comments {
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.75rem;
    overflow: hidden;
}

.local-unifiedgrader-inline-comments [data-region="comments-list"] {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.75rem;
}

.local-unifiedgrader-inline-comments [data-region="comments-form"] {
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    padding: 0.75rem;
}

/* Hide the broken feedback section on the quiz view page.
   Gradebook feedback with embedded media (audio/video) cannot serve files
   through the quiz module's pluginfile handler. Students access full feedback
   via the Unified Grader feedback view instead. */
#page-mod-quiz-view #feedback {
    display: none !important;
}
/* stylelint-enable declaration-no-important */
