/* ==================== 全局样式 ==================== */
:root {
    --primary-color: #4A90E2;
    --primary-hover: #357ABD;
    --success-color: #2ECC71;
    --success-hover: #27AE60;
    --danger-color: #E74C3C;
    --warning-color: #F39C12;
    --bg-color: #F5F7FA;
    --bg-white: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --border-color: #E0E6ED;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* ==================== 头部样式 ==================== */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #667eea 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
}

.title {
    font-size: 2.5em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 15px;
}

.title .icon {
    font-size: 1.2em;
    animation: rotate 10s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.95;
    font-weight: 300;
}

.help-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ==================== 上传区域 ==================== */
.upload-area {
    padding: 60px 30px;
    text-align: center;
    background: var(--bg-color);
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-md);
    margin: 30px;
    transition: var(--transition);
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.05);
    transform: scale(1.02);
}

.upload-content {
    max-width: 500px;
    margin: 0 auto;
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 20px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.upload-area h2 {
    font-size: 1.8em;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.upload-hint {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 1.1em;
}

.upload-btn {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 15px 40px;
    border-radius: var(--radius-sm);
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.upload-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.upload-note {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* ==================== 处理区域 ==================== */
.process-area {
    padding: 30px;
}

.preview-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 30px;
}

.preview-box {
    flex: 1;
    max-width: 500px;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.preview-title {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: var(--text-primary);
    text-align: center;
}

.canvas-wrapper {
    background: white;
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.canvas-wrapper canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

.image-info {
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--text-secondary);
    text-align: center;
}

.preview-arrow {
    font-size: 3em;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    margin-top: 60px;
}

/* ==================== 检测结果 ==================== */
.detection-result {
    background: linear-gradient(135deg, #2ECC71 0%, #27AE60 100%);
    color: white;
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-icon {
    font-size: 2em;
    background: rgba(255, 255, 255, 0.2);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-text strong {
    display: block;
    font-size: 1.2em;
    margin-bottom: 5px;
}

.result-text p {
    opacity: 0.9;
    font-size: 0.95em;
}

/* ==================== 控制按钮 ==================== */
.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    font-size: 1.2em;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: var(--success-hover);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ==================== 高级选项 ==================== */
.advanced-options {
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 25px;
}

.advanced-options h4 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.option-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.option-group:last-child {
    margin-bottom: 0;
}

.option-group label {
    min-width: 100px;
    font-weight: 500;
}

.option-group select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1em;
    background: white;
}

.option-group input[type="range"] {
    flex: 1;
}

#paddingValue {
    min-width: 30px;
    font-weight: 600;
    color: var(--primary-color);
}

/* ==================== 进度条 ==================== */
.progress-bar {
    text-align: center;
    padding: 30px;
    background: var(--bg-color);
    border-radius: var(--radius-md);
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#progressText {
    color: var(--text-secondary);
    font-size: 1.1em;
}

/* ==================== 模态框 ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.8em;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger-color);
    transform: scale(1.2);
}

.modal-body {
    padding: 30px;
}

.modal-body h3 {
    color: var(--text-primary);
    margin: 25px 0 15px;
    font-size: 1.3em;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body ol,
.modal-body ul {
    margin-left: 25px;
    margin-bottom: 20px;
}

.modal-body li {
    margin-bottom: 10px;
    line-height: 1.8;
}

.modal-body p {
    margin-bottom: 15px;
    line-height: 1.8;
}

.modal-body strong {
    color: var(--primary-color);
}

/* ==================== 页脚 ==================== */
.footer {
    background: var(--bg-color);
    padding: 30px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.footer p {
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.footer-note {
    font-size: 0.9em;
}

/* ==================== 工具类 ==================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.text-warning {
    color: var(--warning-color);
}
