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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2c3e50;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
.header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.main-title {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 2.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

.main-title i {
    color: #3498db;
    font-size: 2.2rem;
}

.subtitle {
    font-size: 1.2rem;
    font-weight: 400;
    color: #7f8c8d;
    margin-left: 10px;
}

.header-links {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.header-links a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.header-links a:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.admin-link {
    background: #1f8a70 !important;
    box-shadow: 0 4px 15px rgba(31, 138, 112, 0.25) !important;
}

.admin-link:hover {
    background: #176b58 !important;
}

.github-link {
    background: #2c3e50 !important;
    box-shadow: 0 4px 15px rgba(44, 62, 80, 0.3) !important;
}

.github-link:hover {
    background: #34495e !important;
    box-shadow: 0 6px 20px rgba(44, 62, 80, 0.4) !important;
}

/* 上传区域样式 */
.upload-section {
    margin-bottom: 30px;
}

.upload-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.model-settings {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 16px;
    margin-bottom: 24px;
}

.model-settings label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #2c3e50;
    font-weight: 600;
}

.model-settings select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d5dce3;
    border-radius: 10px;
    background: white;
    color: #34495e;
    font-size: 0.95rem;
}

.service-status {
    margin: 0 0 16px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

.service-ready { color: #1e8449; background: rgba(39, 174, 96, 0.1); }
.service-switching { color: #9a6700; background: rgba(243, 156, 18, 0.14); }
.service-unavailable { color: #c0392b; background: rgba(192, 57, 43, 0.1); }

.api-key-panel {
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid #dce5eb;
    border-radius: 10px;
    background: #f8fbfd;
}

.api-key-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #34495e;
    font-weight: 700;
    margin-bottom: 10px;
}

.api-key-heading i { color: #1f8a70; }
.api-key-controls { display: flex; gap: 8px; }
.api-key-controls input {
    flex: 1;
    min-width: 0;
    border: 1px solid #d5dce3;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: .95rem;
}
.api-key-controls button {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: #1f8a70;
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}
.api-key-controls .secondary-btn { background: #7f8c8d; }
.api-key-hint { color: #7f8c8d; font-size: .8rem; margin-top: 8px; }

.switch-model-btn {
    align-self: end;
    padding: 11px 18px;
    border: 0;
    border-radius: 10px;
    background: #2c3e50;
    color: white;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
}

.switch-model-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

@media (max-width: 700px) {
    .load-test-header { flex-direction:column; }
    .load-test-form { grid-template-columns:1fr; }
    .load-test-actions { width:100%; }
    .load-test-actions button { flex:1; }
    .load-test-results { grid-template-columns:repeat(2,1fr); }
    .load-test-wide { grid-column:span 2; }
    .model-settings {
        grid-template-columns: 1fr;
    }
    .api-key-controls { flex-wrap: wrap; }
    .api-key-controls input { flex-basis: 100%; }
}

.upload-area {
    border: 3px dashed #bdc3c7;
    border-radius: 20px;
    padding: 32px 24px;
    text-align: center;
    transition: all 0.3s ease;
    background: rgba(248, 249, 250, 0.5);
}

.upload-area:hover,
.upload-area.dragging {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.05);
    transform: translateY(-2px);
}

.upload-icon {
    font-size: 2.8rem;
    color: #3498db;
    margin-bottom: 12px;
}

.upload-title {
    font-size: 1.35rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.upload-subtitle {
    color: #7f8c8d;
    margin-bottom: 18px;
    font-size: 0.95rem;
}

.upload-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 11px 22px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

/* 接口压测区域 */
.load-test-section { background: rgba(255,255,255,.95); border-radius: 20px; padding: 24px; margin-bottom: 30px; box-shadow: 0 8px 32px rgba(0,0,0,.1); }
.load-test-header { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:20px; }
.load-test-header h2 { color:#2c3e50; font-size:1.35rem; margin:0 0 5px; }
.load-test-header p { color:#7f8c8d; font-size:.9rem; }
.load-test-badge { background:#eaf4ff; color:#2980b9; border-radius:999px; padding:6px 11px; font-size:.8rem; white-space:nowrap; }
.load-test-form { display:grid; grid-template-columns:repeat(3, minmax(0,1fr)) auto; gap:14px; align-items:end; }
.load-test-form label { display:flex; flex-direction:column; gap:6px; color:#34495e; font-weight:600; font-size:.9rem; }
.load-test-form input { border:1px solid #d5dce3; border-radius:9px; padding:10px; font-size:.95rem; }
.load-test-actions { display:flex; gap:8px; }
.load-test-actions button { border:0; border-radius:9px; padding:11px 14px; color:#fff; cursor:pointer; font-weight:600; white-space:nowrap; }
.load-test-start { background:#27ae60; } .load-test-stop { background:#e74c3c; }
.load-test-actions button:disabled { opacity:.5; cursor:not-allowed; }
.load-test-file, .load-test-status { color:#667; font-size:.88rem; margin-top:14px; }
.load-test-progress-wrap { display:flex; align-items:center; gap:12px; margin-top:18px; }
.load-test-progress-bar { height:10px; background:#e9eef2; border-radius:99px; overflow:hidden; flex:1; }
.load-test-progress { height:100%; width:0; background:linear-gradient(90deg,#3498db,#27ae60); transition:width .2s; }
.load-test-results { display:grid; grid-template-columns:repeat(6,1fr); gap:10px; margin-top:18px; }
.load-test-stat { background:#f7f9fb; border-radius:10px; padding:12px; min-width:0; }
.load-test-stat span { display:block; color:#7f8c8d; font-size:.78rem; margin-bottom:4px; }
.load-test-stat strong { display:block; color:#2c3e50; font-size:1rem; overflow-wrap:anywhere; }
.load-test-wide { grid-column:span 3; }
.load-test-response { background:#f7f9fb; border-radius:10px; padding:12px; min-width:0; }
.load-test-response span { display:block; color:#7f8c8d; font-size:.78rem; margin-bottom:6px; }
.load-test-response pre { max-height:180px; overflow:auto; margin:0; color:#34495e; font:12px/1.45 Consolas,monospace; white-space:pre-wrap; word-break:break-all; }

/* 结果区域样式 */
.results-section {
    margin-top: 30px;
}

.results-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.result-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.panel-header {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    font-weight: 600;
}

.header-title i {
    font-size: 1.2rem;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.copy-all-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.copy-all-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.copy-all-btn.copied {
    background: #27ae60;
    border-color: #27ae60;
}

.panel-content {
    padding: 30px;
    position: relative;
}

/* 图片样式 */
#detect_img {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: zoom-in;
    display: block;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.image-overlay {
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    transform-origin: 0 0;
    cursor: zoom-in;
    transition: transform 0.2s ease;
    display: block;
    overflow: visible;
}

#ocrCanvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
    z-index: 2;
}



.image-overlay.zoomed {
    cursor: grab;
    z-index: 1000;
    position: relative;
}

.image-overlay.zoomed:hover {
    cursor: grab;
}

.image-overlay.zoomed:active {
    cursor: grabbing;
}

.image-info {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    gap: 15px;
}

.zoom-hint {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(52, 152, 219, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 100;
}

.panel-content:hover .zoom-hint {
    opacity: 1;
}

/* 表格样式 */
.table-container {
    margin-bottom: 20px;
}

.result-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.result-table thead {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.result-table th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
}

.result-table td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.9rem;
    color: #2c3e50;
}

.result-table tbody tr:hover {
    background: #f8f9fa;
}

.row-number {
    font-weight: 600;
    color: #3498db;
    width: 60px;
}

.result-table th:first-child,
.result-table td:first-child {
    width: 60px;
}

.result-table th:last-child,
.result-table td:last-child {
    width: 90px;
    min-width: 90px;
    white-space: nowrap;
}

.recognition-result {
    color: #2c3e50;
    font-weight: 500;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.result-table tr.ocr-highlight td {
    background: rgba(255, 59, 48, 0.12);
}

.result-table tr.ocr-highlight .recognition-result {
    color: #c0392b;
    font-weight: 700;
}

.confidence-score {
    font-weight: 600;
    text-align: center;
    width: 80px;
}

.high-confidence {
    color: #27ae60;
}

.medium-confidence {
    color: #f39c12;
}

.low-confidence {
    color: #e74c3c;
}

/* 性能统计样式 */
.performance-stats {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.stats-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 12px;
}

.runtime-status {
    margin-left: auto;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.runtime-gpu-enabled {
    color: #1e8449;
    background: rgba(39, 174, 96, 0.12);
}

.runtime-gpu-disabled {
    color: #c0392b;
    background: rgba(192, 57, 43, 0.12);
}

.total-performance {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.gpu-enabled {
    color: #27ae60;
}

.gpu-disabled {
    color: #c0392b;
    font-weight: 700;
}

.gpu-status {
    display: block;
    width: 100%;
    padding: 9px 20px;
    border-bottom: 1px solid rgba(192, 57, 43, 0.2);
    background: rgba(192, 57, 43, 0.1);
    font-size: 0.9rem;
    white-space: nowrap;
}

.gpu-unknown {
    color: #7f8c8d;
    background: rgba(127, 140, 141, 0.12);
}

.gpu-status.gpu-enabled {
    background: rgba(39, 174, 96, 0.1);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    position: relative;
    border-left: 4px solid #3498db;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.stat-card.detection {
    border-left-color: #e74c3c;
}

.stat-card.classification {
    border-left-color: #f39c12;
}

.stat-card.recognition {
    border-left-color: #27ae60;
}

.stat-card.request-total {
    border-left-color: #1f8a70;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 12px;
    font-weight: 500;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e50;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}



/* 加载动画样式 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 15px;
}

.loading-spinner {
    text-align: center;
    color: #3498db;
}

.loading-spinner i {
    font-size: 3rem;
    margin-bottom: 15px;
    animation: spin 1s linear infinite;
}

.loading-spinner p {
    font-size: 1.1rem;
    font-weight: 500;
    color: #2c3e50;
}

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

/* 通知样式 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    color: #2c3e50;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 10000;
    border-left: 4px solid #3498db;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left-color: #27ae60;
}

.notification.error {
    border-left-color: #e74c3c;
}

.notification i {
    font-size: 1.2rem;
}

.notification.success i {
    color: #27ae60;
}

.notification.error i {
    color: #e74c3c;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .results-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .container {
        padding: 15px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .main-title {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 20px;
        margin-bottom: 20px;
    }

    .upload-container {
        padding: 20px;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .upload-title {
        font-size: 1.5rem;
    }

    .panel-header {
        padding: 15px 20px;
    }

    .panel-content {
        padding: 20px;
    }

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

    .performance-stats {
        padding: 20px;
    }

    .stats-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .total-performance {
        align-self: flex-end;
    }

    #detect_img {
        max-height: 75vh;
    }

    .header-links {
        justify-content: center;
    }

    .header-links a {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .header {
        padding: 15px;
    }

    .main-title {
        font-size: 1.8rem;
        flex-direction: column;
        gap: 10px;
    }

    .subtitle {
        margin-left: 0;
    }

    .upload-container {
        padding: 15px;
    }

    .upload-area {
        padding: 24px 12px;
    }

    .upload-title {
        font-size: 1.1rem;
    }

    .upload-subtitle {
        font-size: 0.9rem;
    }

    .upload-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .panel-header {
        padding: 12px 15px;
    }

    .header-title {
        font-size: 1.1rem;
    }

    .panel-content {
        padding: 15px;
    }

    #detect_img {
        max-height: 70vh;
    }

    .performance-stats {
        padding: 15px;
    }

    .stat-card {
        padding: 15px;
    }

    .stats-header {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }

    .result-table th,
    .result-table td {
        padding: 8px 6px;
        font-size: 0.85rem;
    }

    .result-table th:first-child,
    .result-table td:first-child {
        width: 42px;
    }

    .result-table th:last-child,
    .result-table td:last-child {
        width: 76px;
        min-width: 76px;
    }

    .notification {
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
    }

    .notification.show {
        transform: translateY(0);
    }
}

/* 拖拽状态 */
body.dragging .upload-area {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
    transform: scale(1.02);
}

/* 动画效果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-section {
    animation: fadeInUp 0.6s ease;
}

.result-panel {
    animation: fadeInUp 0.6s ease 0.1s both;
}

.result-panel:nth-child(2) {
    animation-delay: 0.2s;
}

/* 滚动条样式 */
::-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;
}
