/* 文字识别系统样式 */
:root {
    --primary-color: #1890ff;
    --secondary-color: #f0f2f5;
    --text-color: #333;
    --light-text: #666;
    --border-color: #d9d9d9;
    --success-color: #52c41a;
    --error-color: #f5222d;
    --warning-color: #faad14;
    --info-color: #13c2c2;
    --ocr-color: #722ed1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f8f9fa;
    /*padding: 20px;*/
}

.header {
    background: linear-gradient(135deg, #1890ff, #096dd9);
    color: white;
    padding: 30px 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 500;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.header img {
    border-radius: 8px;
}

.header p {
    font-size: 1rem;
    max-width: 800px;
    margin: 0 auto;
    opacity: 0.9;
}

.container-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
}

.container {
    flex: 1;
    min-width: 300px;
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.container h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

/* 上传方式选择 */
.upload-methods {
    display: flex;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.method-tab {
    flex: 1;
    padding: 12px 16px;
    text-align: center;
    cursor: pointer;
    background: #fafafa;
    border-right: 1px solid var(--border-color);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

.method-tab:last-child {
    border-right: none;
}

.method-tab:hover {
    background: #e6f7ff;
}

.method-tab.active {
    background: var(--primary-color);
    color: white;
}

.method-icon {
    font-size: 16px;
}

/* 上传内容区域 */
.upload-content {
    margin-bottom: 25px;
}

.upload-zone, .pdf-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #fafafa;
}

.upload-zone:hover, .pdf-upload-zone:hover {
    border-color: var(--primary-color);
    background-color: #f6ffed;
}

.upload-zone.dragover, .pdf-upload-zone.dragover {
    border-color: var(--primary-color);
    background-color: #e6f3ff;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--light-text);
}

.upload-text {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 8px;
    font-weight: 500;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--light-text);
}

/* 图片预览 */
.image-preview {
    position: relative;
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-preview img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    background-color: #f5f5f5;
}

.remove-image {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    color: var(--error-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-image:hover {
    background: var(--error-color);
    color: white;
}

/* URL输入 */
.url-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.url-input-group label {
    font-weight: 500;
    color: var(--text-color);
}

.url-input-group input {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.url-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.load-url-btn {
    padding: 10px 20px;
    background: var(--info-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    align-self: flex-start;
}

.load-url-btn:hover {
    background: #08979c;
}

.url-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* PDF配置 */
.pdf-config {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
    margin-top: 15px;
}

.pdf-config label {
    font-weight: 500;
    color: var(--text-color);
}

.pdf-config input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 80px;
}

.pdf-info {
    color: var(--light-text);
    font-size: 0.9rem;
}

/* OCR配置 */
.ocr-config {
    margin-bottom: 25px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.ocr-config h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.config-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-item label {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.9rem;
}

.config-item select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s ease;
}

.config-item select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.config-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.config-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.config-options label:hover {
    background-color: #f0f0f0;
}

.config-options input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

/* 认证配置区域 */
.credential-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 25px 0 15px 0;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.credential-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.credential-header label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.credential-inputs {
    margin-bottom: 20px;
}

.credential-inputs label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.credential-inputs input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    transition: border-color 0.3s ease;
}

.credential-inputs input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
}

.credential-tips {
    margin-bottom: 25px;
    padding: 12px;
    background-color: #f6ffed;
    border-left: 4px solid var(--success-color);
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--light-text);
}

.credential-tips a {
    color: var(--primary-color);
    text-decoration: none;
}

.credential-tips a:hover {
    text-decoration: underline;
}

/* 按钮组 */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 25px;
}

.clear-btn, .recognize-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
}

.clear-btn {
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.clear-btn:hover {
    background-color: #e6f7ff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.recognize-btn {
    background-color: var(--primary-color);
    color: white;
}

.recognize-btn:hover {
    background-color: #096dd9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
}

.recognize-btn:disabled, .clear-btn:disabled {
    background-color: #f5f5f5;
    color: #bfbfbf;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 按钮提示 */
.btn-hint {
    margin-top: 10px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--light-text);
    background-color: #fff7e6;
    border: 1px solid #ffd591;
    border-radius: 4px;
    text-align: center;
}

/* 加载动画 */
.loading {
    display: none;
    text-align: center;
    margin: 25px 0;
    padding: 20px;
    background-color: #f6ffed;
    border-radius: 8px;
    border: 1px solid #b7eb8f;
}

.loading-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 4px solid var(--primary-color);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 结果容器 */
.result-container {
    min-height: 400px;
    padding: 20px;
}

.error-message {
    color: var(--error-color);
    background-color: #fff2f0;
    border: 1px solid #ffccc7;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 20px;
    font-weight: 500;
}

/* 识别统计 */
.recognition-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: linear-gradient(135deg, #f6ffed, #d9f7be);
    border-radius: 8px;
    border-left: 4px solid var(--success-color);
}

.stats-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stats-label {
    font-size: 0.85rem;
    color: var(--light-text);
    margin-bottom: 5px;
}

.stats-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--success-color);
}

/* 文本内容区域 */
.text-content {
    background: #fafafa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.text-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: flex-end;
}

.text-btn {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.text-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.text-display {
    display: flex;
    margin-bottom: 15px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.text-tab {
    flex: 1;
    padding: 10px 16px;
    text-align: center;
    cursor: pointer;
    background: #f5f5f5;
    border-right: 1px solid var(--border-color);
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.text-tab:last-child {
    border-right: none;
}

.text-tab:hover {
    background: #e6f7ff;
}

.text-tab.active {
    background: var(--primary-color);
    color: white;
}

.text-panel {
    display: none;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.text-panel.active {
    display: block;
}

#recognized-text {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: none;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    background: transparent;
}

#recognized-text:focus {
    outline: none;
}

/* 详细结果 */
.detailed-results {
    padding: 15px;
}

.text-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.3s ease;
}

.text-line:hover {
    background-color: #f9f9f9;
}

.text-line:last-child {
    border-bottom: none;
}

.line-content {
    flex: 1;
    margin-right: 15px;
    font-size: 14px;
    line-height: 1.5;
}

.line-confidence {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    font-size: 12px;
    color: var(--light-text);
    min-width: 80px;
}

.confidence-avg {
    font-weight: 600;
    color: var(--primary-color);
}

.confidence-range {
    font-size: 11px;
    color: var(--light-text);
}

/* 段落结果 */
.paragraph-section {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
    border-left: 4px solid var(--info-color);
}

.paragraph-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--info-color);
}

.paragraph-item {
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e8e8e8;
}

.paragraph-lines {
    font-size: 13px;
    color: var(--light-text);
    margin-bottom: 5px;
}

.paragraph-content {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color);
}

/* 状态指示器 */
.status-indicator {
    display: flex;
    align-items: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--light-text);
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 6px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 10px;
    background-color: #d9d9d9;
    transition: all 0.3s ease;
}

.status-dot.active {
    background-color: var(--success-color);
    animation: pulse 1.5s infinite;
}

.status-dot.processing {
    background-color: var(--primary-color);
    animation: pulse 1s infinite;
}

.status-dot.error {
    background-color: var(--error-color);
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
        flex-direction: column;
        gap: 10px;
    }

    .container-wrapper {
        flex-direction: column;
    }

    .button-group {
        flex-direction: column;
        gap: 12px;
    }

    .credential-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .recognition-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .text-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .config-options {
        grid-template-columns: 1fr;
    }

    .text-line {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .line-confidence {
        align-items: flex-start;
        flex-direction: row;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
    }

    .header {
        padding: 20px 15px;
    }

    .upload-zone, .pdf-upload-zone {
        padding: 30px 15px;
    }

    .recognition-stats {
        grid-template-columns: 1fr;
    }

    .method-tab {
        font-size: 12px;
        padding: 10px 8px;
    }

    .method-tab span:last-child {
        display: none;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}