/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部 */
.header {
    text-align: center;
    padding: 30px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.header .subtitle {
    opacity: 0.9;
    font-size: 14px;
}

/* Tab 导航 */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: white;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 15px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #f0f2f5;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

/* 内容区域 */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 卡片 */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.card h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #333;
}

.card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: #444;
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input {
    flex: 1;
}

.btn-icon {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* 按钮 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd6;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f0f2f5;
    color: #666;
}

.btn-secondary:hover {
    background: #e4e6e9;
}

.btn-danger {
    background: #ff4757;
    color: white;
}

.btn-danger:hover {
    background: #e8424f;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-large {
    padding: 14px 28px;
    font-size: 16px;
    width: 100%;
}

/* 状态消息 */
.status-message {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
}

.status-message.info {
    background: #e7f3ff;
    color: #0c5460;
}

/* 答案管理 */
.answer-sets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.answer-set {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.answer-set h3 {
    text-align: center;
    margin-bottom: 16px;
    color: #667eea;
}

/* 上传区域 */
.upload-zone,
.exam-upload-zone {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.upload-zone:hover,
.upload-zone.dragover,
.exam-upload-zone:hover,
.exam-upload-zone.dragover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-zone input[type="file"],
.exam-upload-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-zone p,
.exam-upload-zone p {
    color: #666;
    margin-bottom: 4px;
}

.upload-zone .hint,
.exam-upload-zone .hint {
    font-size: 12px;
    color: #999;
}

.upload-zone.large,
.exam-upload-zone.large {
    padding: 50px 20px;
}

.answer-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 12px 0;
    font-size: 13px;
    color: #666;
}

.answer-actions {
    display: flex;
    gap: 8px;
}

/* 已选文件 */
.selected-files {
    margin: 16px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.selected-files p {
    font-size: 14px;
    margin-bottom: 8px;
}

#file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.file-tag {
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
}

/* 进度条 */
.progress-bar {
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: #666;
}

/* 统计 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 13px;
    color: #666;
}

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

tr:hover {
    background: #f8f9ff;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 1000px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    text-align: right;
}

/* 结果详情 */
.result-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.result-image {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
}

.result-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* 图片导航 */
.image-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
    padding: 8px;
    background: #e9ecef;
    border-radius: 6px;
}

.image-nav button {
    min-width: 80px;
}

.image-nav button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#image-page-info {
    font-weight: 500;
    color: #555;
    min-width: 50px;
    text-align: center;
}

/* 错误答案行标红 */
.score-table tr.wrong {
    background: #fff5f5;
}

.score-table tr.wrong td {
    color: #c92a2a;
}

.result-summary {
    margin-bottom: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.result-summary p {
    margin: 4px 0;
}

.result-actions {
    margin-top: 16px;
    display: flex;
    gap: 12px;
}

.result-actions select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

/* Radio 组 */
.radio-group {
    display: flex;
    gap: 20px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式 - 平板 */
@media (max-width: 768px) {
    .app {
        padding: 12px;
    }

    .header {
        padding: 20px 16px;
        border-radius: 8px;
    }

    .header h1 {
        font-size: 22px;
    }

    .answer-sets {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .result-detail {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-wrap: wrap;
        padding: 6px;
        gap: 6px;
    }

    .tab-btn {
        flex: 1 1 45%;
        padding: 10px 12px;
        font-size: 14px;
    }

    .card {
        padding: 16px;
        border-radius: 8px;
    }

    .modal-content {
        width: 95%;
        max-height: 85vh;
        border-radius: 8px;
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-body {
        padding: 16px;
    }

    /* 表格横向滚动 */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    th, td {
        padding: 10px 8px;
        font-size: 13px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .radio-group {
        flex-wrap: wrap;
        gap: 12px;
    }

    .answer-actions {
        flex-direction: column;
    }

    .answer-actions .btn {
        width: 100%;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions select,
    .result-actions .btn {
        width: 100%;
    }

    /* 图片导航移动端 */
    .image-nav {
        gap: 10px;
        padding: 6px;
    }

    .image-nav button {
        min-width: 60px;
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* 响应式 - 手机 */
@media (max-width: 480px) {
    .app {
        padding: 8px;
    }

    .header {
        padding: 16px 12px;
        margin-bottom: 12px;
    }

    .header h1 {
        font-size: 18px;
    }

    .header .subtitle {
        font-size: 12px;
    }

    .tabs {
        padding: 4px;
        gap: 4px;
        margin-bottom: 12px;
    }

    .tab-btn {
        flex: 1 1 48%;
        padding: 8px 6px;
        font-size: 12px;
        border-radius: 6px;
    }

    .card {
        padding: 12px;
        margin-bottom: 12px;
    }

    .card h2 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .card h3 {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-group label {
        font-size: 13px;
        margin-bottom: 4px;
    }

    .form-group input[type="text"],
    .form-group input[type="password"],
    .form-group select {
        padding: 8px 10px;
        font-size: 14px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .btn-large {
        padding: 12px 20px;
        font-size: 14px;
    }

    .btn-small {
        padding: 5px 10px;
        font-size: 12px;
    }

    .upload-zone,
    .exam-upload-zone {
        padding: 20px 12px;
    }

    .upload-zone p,
    .exam-upload-zone p {
        font-size: 14px;
    }

    .upload-zone.large,
    .exam-upload-zone.large {
        padding: 30px 12px;
    }

    .answer-set {
        padding: 12px;
    }

    .answer-set h3 {
        font-size: 15px;
        margin-bottom: 12px;
    }

    .answer-info {
        font-size: 12px;
        margin: 8px 0;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-item {
        padding: 12px 8px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-label {
        font-size: 11px;
    }

    .selected-files {
        padding: 10px;
        margin: 12px 0;
    }

    .selected-files p {
        font-size: 13px;
    }

    .file-tag {
        font-size: 11px;
        padding: 3px 8px;
    }

    .progress-bar {
        height: 16px;
    }

    .progress-text {
        font-size: 12px;
    }

    /* 弹窗全屏 */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-header {
        padding: 12px;
    }

    .modal-header h3 {
        font-size: 16px;
    }

    .modal-body {
        padding: 12px;
    }

    .modal-footer {
        padding: 12px;
    }

    /* 表格 */
    table {
        min-width: 500px;
        font-size: 12px;
    }

    th, td {
        padding: 8px 6px;
    }

    /* 答案编辑表格输入框 */
    .answer-table input[type="text"],
    .answer-table input[type="number"] {
        font-size: 12px;
        padding: 4px 6px;
    }

    .q-id {
        width: 50px !important;
    }

    .q-score {
        width: 50px !important;
    }

    /* 结果列表 */
    .result-table {
        min-width: 550px;
    }

    /* Radio 组垂直排列 */
    .radio-group {
        flex-direction: column;
        gap: 8px;
    }

    .radio-group label {
        font-size: 14px;
    }

    /* 图片导航小屏 */
    .image-nav {
        gap: 8px;
        padding: 4px;
    }

    .image-nav button {
        min-width: 50px;
        font-size: 11px;
        padding: 5px 8px;
    }

    #image-page-info {
        font-size: 12px;
    }

    /* 状态消息 */
    .status-message {
        font-size: 13px;
        padding: 8px 12px;
    }

    /* 输入框带按钮 */
    .input-with-btn {
        flex-direction: column;
    }

    .input-with-btn .btn-icon {
        width: 100%;
    }
}

/* 超小屏幕 */
@media (max-width: 360px) {
    .tab-btn {
        font-size: 11px;
        padding: 6px 4px;
    }

    .header h1 {
        font-size: 16px;
    }

    .stat-value {
        font-size: 18px;
    }

    .btn {
        font-size: 12px;
    }
}

/* 横屏优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 100vh;
    }

    .header {
        padding: 12px;
    }

    .header h1 {
        font-size: 18px;
        margin-bottom: 4px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
    }

    .tab-btn {
        min-height: 44px;
    }

    .form-group input[type="text"],
    .form-group input[type="password"],
    .form-group select {
        min-height: 44px;
    }

    .radio-group label {
        min-height: 44px;
        padding: 8px 0;
    }
}
