/* static/css/file-upload.css - 文件上传相关样式（优化版） */

/* ==================== 上传区域样式 ==================== */
.upload-section, .input-section {
    margin-top: 15px;
}

.upload-area {
    border: 3px dashed var(--primary-color);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    background: #e9ecef;
    border-color: var(--primary-dark);
    transform: scale(1.02);
}

.upload-area.dragover {
    background: #e3f2fd;
    border-color: #1976d2;
    animation: uploadPulse 1s infinite;
}

.upload-area p {
    margin: 8px 0;
    color: var(--text-primary);
}

.upload-area p:first-of-type {
    font-weight: 600;
    font-size: 1.1em;
}

.upload-limits {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    opacity: 0.8;
}

/* 拖拽效果 */
.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(52, 152, 219, 0.1) 50%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.upload-area.dragover::before {
    opacity: 1;
    animation: dragShimmer 1.5s infinite;
}

/* ==================== 文件预览区域 ==================== */
#filePreview {
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.file-preview {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    margin: 10px 0;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.file-preview:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.file-info span {
    color: var(--text-primary);
    font-weight: 500;
}

.file-info .btn {
    padding: 4px 8px;
    font-size: 11px;
    margin: 0;
    background: #dc3545;
    border: none;
    border-radius: 4px;
    transition: all 0.2s;
}

.file-info .btn:hover {
    background: #c82333;
    transform: scale(1.05);
}

/* ==================== OCR结果显示 ==================== */
.ocr-result {
    background: #f1f3f4;
    border-radius: var(--border-radius);
    padding: 10px;
    font-size: 12px;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 10px;
    border: 1px solid #e0e0e0;
    line-height: 1.4;
}

.ocr-result::-webkit-scrollbar {
    width: 6px;
}

.ocr-result::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ocr-result::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ocr-result::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ==================== 进度条样式（修复版） ==================== */
.progress-container {
    background: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    margin: 8px 0;
    height: 28px; /* 增加高度，确保文字显示完整 */
    position: relative;
    border: 1px solid #dee2e6; /* 添加边框增强视觉效果 */
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    position: relative;
    min-width: 40px; /* 确保至少有最小宽度显示百分比 */
}

.progress-bar span {
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 0 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap; /* 防止文字换行 */
    line-height: 1;
}

/* 当进度很小时，将百分比显示在进度条外部 */
.progress-container.low-progress .progress-bar span {
    position: absolute;
    left: 8px;
    color: #333;
    text-shadow: none;
}

/* 上传进度区域 */
.upload-progress {
    margin-top: 15px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid #e9ecef;
}

.upload-progress.hidden {
    display: none;
}

#progressText {
    margin-top: 10px;
    color: #495057;
    font-size: 14px;
    text-align: center;
    font-weight: 500;
}

/* ==================== 文件处理状态提示 ==================== */
.file-processing-status {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.processing-notification {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 4px solid #ffc107;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    animation: fadeInDown 0.3s ease-out;
}

.processing-icon .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ffc107;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.processing-info {
    flex: 1;
}

.processing-info strong {
    color: #495057;
    font-size: 14px;
    display: block;
    margin-bottom: 5px;
}

.processing-info p {
    margin: 3px 0;
    color: #6c757d;
    font-size: 12px;
    line-height: 1.4;
}

.processing-hint {
    color: #28a745 !important;
    font-weight: 500;
}

.processing-dismiss {
    background: none;
    border: none;
    font-size: 18px;
    color: #6c757d;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.processing-dismiss:hover {
    opacity: 1;
    color: #495057;
}

/* ==================== 文件状态指示器 ==================== */
.file-status-indicator {
    margin: 10px 0;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid;
}

.status-info {
    border-left-color: #3498db;
    background-color: #e3f2fd;
    color: #1976d2;
}

.status-success {
    border-left-color: #4caf50;
    background-color: #e8f5e8;
    color: #2e7d32;
}

.status-warning {
    border-left-color: #ff9800;
    background-color: #fff3e0;
    color: #f57c00;
}

.status-error {
    border-left-color: #f44336;
    background-color: #ffebee;
    color: #c62828;
}

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

.status-ready {
    margin-left: auto;
    font-weight: bold;
    color: #4caf50;
}

/* ==================== 文件处理指示器 ==================== */
.file-processing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff3cd;
    color: #856404;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #ffeaa7;
}

.file-processing-indicator .spinner {
    width: 14px;
    height: 14px;
    border-width: 2px;
    margin: 0;
}

.file-success-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #d4edda;
    color: #155724;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.file-error-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8d7da;
    color: #721c24;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* ==================== 文件高亮效果 ==================== */
.file-preview.highlight-processing {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid #ffc107;
    transform: scale(1.02);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.file-preview.cancelling {
    opacity: 0.6;
    background: #f8f9fa;
    border: 2px dashed #6c757d;
}

.file-preview.cancelling .ocr-result {
    color: #6c757d;
}

.file-preview.cancelling .ocr-result::after {
    content: " (正在取消...)";
    font-style: italic;
    color: #dc3545;
}

/* ==================== 批量操作按钮 ==================== */
.batch-actions {
    margin-top: 15px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.batch-actions .file-count {
    color: var(--text-secondary);
    font-size: 14px;
}

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

.batch-actions .btn {
    padding: 6px 12px;
    font-size: 12px;
    margin: 0;
}

/* ==================== 错误提示 ==================== */
.file-validation-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: var(--border-radius);
    padding: 12px;
    margin: 10px 0;
    font-size: 14px;
}

.file-validation-error strong {
    display: block;
    margin-bottom: 5px;
}

/* ==================== 动画效果 ==================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes uploadPulse {
    0%, 100% {
        border-color: #1976d2;
        background: #e3f2fd;
    }
    50% {
        border-color: #2196f3;
        background: #bbdefb;
    }
}

@keyframes dragShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ==================== 响应式调整 ==================== */
@media (max-width: 768px) {
    .processing-notification {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .processing-info {
        order: 1;
    }

    .processing-icon {
        order: 2;
    }

    .processing-dismiss {
        position: absolute;
        top: 10px;
        right: 10px;
        order: 3;
    }

    .file-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .progress-container {
        height: 32px; /* 移动端稍微增加高度 */
    }

    .progress-bar span {
        font-size: 11px;
    }
}

/* ==================== 滚动条优化 ==================== */
#filePreview::-webkit-scrollbar {
    width: 8px;
}

#filePreview::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#filePreview::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#filePreview::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}