/* 基础样式 */
body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* 标题样式 */
h1, h2 {
    color: #2c3e50;
}

/* 表单样式 */
.line-group {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 15px;
    display: inline-block;
    margin-right: 20px;
}

.form-group label {
    display: inline-block;
    margin-bottom: 5px;
    font-weight: bold;
    margin-right: 5px;
}

.horizontal-group {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

button {
    background-color: #3498db;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 5px;
}

button:hover {
    background-color: #2980b9;
}

/* 图片预览区域 */
.image-preview {
    margin-top: 20px;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* 消息提示 */
.flash-messages {
    padding: 10px;
    margin-bottom: 20px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
}

/* 头部样式 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.logout {
    color: #e74c3c;
    text-decoration: none;
}

.logout:hover {
    text-decoration: underline;
}

/* 各个功能区域 */
.upload-section,
.recognition-section,
.upload-text-section {
    background-color: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.view-section {
    background-color: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow: auto;
}

/* 识别和上传区域水平布局 */
.recognition-section .form-group,
.upload-text-section .form-group {
    width: 100%;
    margin-bottom: 10px;
}

.recognition-section textarea,
.upload-text-section textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 250px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* 按钮样式调整 */
.recognition-section button,
.upload-text-section button {
    margin-bottom: 10px;
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.recognition-section button:disabled,
.upload-text-section button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* 水平排列识别和上传区域 */
.text-area-container {
    display: flex;
    gap: 20px;
}

.text-area-container > div {
    flex: 1;
}

#classname {
    height: 40px;
}

#data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
th, td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.multiselect-dropdown {
    position: relative;
    display: inline-block;
    width: 300px;
}

.dropdown-button {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #3498db;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 100%;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.dropdown-content label {
    display: block;
    padding: 8px 12px;
    cursor: pointer;
}

.dropdown-content label:hover {
    background-color: #f1f1f1;
}

.dropdown-content input[type="checkbox"] {
    margin-right: 10px;
}

/* 多模态批改页 */
.grading-page {
    max-width: 1040px;
}

.submission-actions { display: flex; gap: 28px; flex-wrap: wrap; }
.submission-actions button { min-width: 190px; font-size: 16px; font-weight: 600; }
.submission-actions button:disabled { background: #aeb7bf; cursor: not-allowed; }
.status-badge.pending_manual { background: #fff2cc; color: #854d0e; }

.grading-page header h1,
.grading-card h2,
.grading-card h3 {
    margin-top: 0;
}

.grading-page header nav {
    display: flex;
    gap: 18px;
}

.grading-page .change {
    color: #23689b;
    text-decoration: none;
}

.muted {
    color: #68737d;
    margin-top: 4px;
}

.grading-card {
    background: #fff;
    padding: 24px;
    margin-bottom: 22px;
    border-radius: 10px;
    box-shadow: 0 4px 18px rgba(30, 50, 70, 0.08);
}

.form-row {
    display: grid;
    grid-template-columns: minmax(240px, 0.8fr) minmax(300px, 1.2fr);
    gap: 22px;
    align-items: end;
}

.form-row .form-group {
    display: block;
    margin-right: 0;
}

.form-row label {
    display: block;
}

.form-row select,
.form-row input {
    width: 100%;
    min-height: 42px;
    padding: 8px;
    border: 1px solid #cfd6dc;
    border-radius: 6px;
    background: #fff;
    box-sizing: border-box;
}

#submit-grading {
    font-size: 16px;
    font-weight: 600;
    min-width: 190px;
}

#submit-grading:disabled {
    background: #aeb7bf;
    cursor: not-allowed;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin: 12px 0 18px;
}

.preview-grid figure {
    margin: 0;
    padding: 8px;
    border: 1px solid #dce2e7;
    border-radius: 7px;
    background: #f9fbfc;
}

.preview-grid img {
    width: 100%;
    height: 150px;
    object-fit: contain;
    background: #fff;
}

.preview-grid figcaption {
    margin-top: 6px;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.selection-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.selection-toolbar button, .preview-grid .remove-image { background: #fff; color: #b42318; border: 1px solid #d7b0ab; padding: 6px 12px; }
.selection-toolbar button:disabled, .preview-grid .remove-image:disabled { color: #68737d; border-color: #ddd; cursor: not-allowed; }
.selection-toolbar p { margin: 0; color: #68737d; }

.error-message {
    color: #b42318;
    min-height: 1.5em;
}

.status-heading,
.score-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.status-badge {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 999px;
    background: #e7edf2;
    font-size: 14px;
}

.status-badge.active { background: #e6f1ff; color: #175cd3; }
.status-badge.completed { background: #dcfae6; color: #067647; }
.status-badge.needs_review { background: #fff2cc; color: #854d0e; }
.criterion-details { margin: 20px 0; border: 1px solid #cbd5df; border-radius: 8px; padding: 14px; overflow-wrap: anywhere; }
.criterion-details summary { cursor: pointer; font-weight: bold; color: #245777; }
.criterion-item { padding: 12px 0; border-top: 1px solid #e0e5ea; margin-top: 12px; }
.criterion-item h3 { font-size: 1rem; line-height: 1.6; }
.criterion-item h3 span { display: inline-block; color: #245777; }
.criterion-item .result-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.unreadable-warning { color: #a31515; background: #fff1f1; border: 1px solid #dc7373; border-radius: 6px; padding: 12px; overflow-wrap: anywhere; }
.unreadable-marker { color: #b00020; background: #ffe4e7; font-weight: bold; text-decoration: underline; }
button.unreadable-link { display: block; color: #a31515; background: white; border: 1px solid #dc7373; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; }
.status-badge.failed { background: #fee4e2; color: #b42318; }

.status-message,
.result-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.progress-track {
    height: 5px;
    overflow: hidden;
    background: #e9eef2;
    border-radius: 999px;
}

.progress-bar {
    width: 35%;
    height: 100%;
    background: #3498db;
    border-radius: inherit;
    animation: grading-progress 1.4s ease-in-out infinite alternate;
}

@keyframes grading-progress {
    from { transform: translateX(-100%); }
    to { transform: translateX(285%); }
}

.score-summary {
    margin: 24px 0 6px;
    padding: 18px;
    border-radius: 8px;
    background: #f3f8fc;
}

.score-summary strong {
    font-size: 28px;
    color: #145b86;
}

.table-scroll {
    overflow-x: auto;
}

.score-table {
    width: 100%;
    border-collapse: collapse;
}

.score-table th,
.score-table td {
    vertical-align: top;
    border-bottom: 1px solid #e5e9ed;
}

.score-table th:nth-child(2),
.score-table td:nth-child(2) {
    width: 110px;
    white-space: nowrap;
}

.warning-box {
    margin-top: 18px;
    padding: 14px 18px;
    border: 1px solid #f4c95d;
    border-radius: 7px;
    background: #fff9e8;
}

[hidden] {
    display: none !important;
}

@media (max-width: 720px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .grading-page header {
        align-items: flex-start;
        gap: 12px;
    }

    .grading-card {
        padding: 18px;
    }
}
