/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --bg-light: #f7fafc;
    --bg-white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-btn {
    display: inline-block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 10px;
    transition: color 0.3s;
}

.back-btn:hover {
    color: var(--primary-color);
}

.title {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* 主内容区 */
.main {
    padding: 30px 0;
}

/* 模式选择器 */
.mode-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    background: var(--bg-white);
    padding: 8px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.mode-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    border-radius: calc(var(--radius) - 4px);
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
}

.mode-btn:hover {
    background: var(--bg-light);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: var(--shadow-md);
}

.mode-btn .icon {
    font-size: 20px;
}

/* 扫描模式容器 */
.scan-mode {
    display: none;
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 25px;
}

.scan-mode.active {
    display: block;
}

/* 相机容器 */
.camera-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 20px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    aspect-ratio: 4/3;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 优化移动端视频渲染 */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.scan-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    pointer-events: none;
}

.scan-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid var(--success-color);
}

.scan-corner.top-left {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-radius: 8px 0 0 0;
}

.scan-corner.top-right {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-radius: 0 8px 0 0;
}

.scan-corner.bottom-left {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 8px;
}

.scan-corner.bottom-right {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 8px 0;
}

.scan-line {
    position: absolute;
    width: 70%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--success-color), transparent);
    top: 50%;
    left: 15%;
    animation: scan 2s infinite;
    box-shadow: 0 0 10px var(--success-color);
}

@keyframes scan {
    0%, 100% {
        top: 15%;
    }
    50% {
        top: 85%;
    }
}

/* 相机控制按钮 */
.camera-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.camera-status {
    text-align: center;
    margin-top: 15px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* 上传区域 */
.upload-container {
    max-width: 600px;
    margin: 0 auto;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: var(--bg-light);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
}

.upload-icon {
    font-size: 64px;
    margin-bottom: 15px;
}

.upload-area h3 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 18px;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 14px;
}

.preview-container {
    text-align: center;
}

#previewImage {
    max-width: 100%;
    max-height: 500px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s;
}

.btn-icon:hover {
    background: var(--bg-light);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 14px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.3s;
}

.btn-text:hover {
    background: var(--bg-light);
}

/* 结果容器 */
.result-container {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 25px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-light);
}

.result-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.result-type {
    display: inline-block;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 15px;
}

.result-text {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 8px;
    word-break: break-all;
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
}

.result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.result-details {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--bg-light);
}

.detail-item {
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: 10px;
}

.detail-item strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 5px;
}

.detail-item span {
    color: var(--text-secondary);
    font-size: 14px;
}

/* 历史记录 */
.history-container {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 25px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-light);
}

.history-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 4px solid var(--primary-color);
}

.history-item:hover {
    background: var(--border-color);
    transform: translateX(5px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-time {
    color: var(--text-secondary);
    font-size: 12px;
}

.history-text {
    color: var(--text-primary);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 帮助说明 */
.help-section {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 25px;
}

.help-section h2 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-light);
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.help-item {
    text-align: center;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 8px;
    transition: all 0.3s;
}

.help-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.help-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.help-item h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.help-item p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* 底部 */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .title {
        font-size: 24px;
    }

    .mode-selector {
        flex-direction: row;
        gap: 10px;
    }

    .mode-btn {
        flex: 1;
        padding: 12px 16px;
        font-size: 14px;
    }

    .scan-mode {
        padding: 20px;
    }

    .camera-container {
        aspect-ratio: 1/1;
        max-width: 100%;
    }
    
    #video {
        object-fit: contain;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .help-grid {
        grid-template-columns: 1fr;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .upload-icon {
        font-size: 48px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .title {
        font-size: 20px;
    }

    .subtitle {
        font-size: 13px;
    }

    .scan-mode {
        padding: 15px;
    }

    .help-item {
        padding: 15px;
    }

    .help-icon {
        font-size: 36px;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 通知提示 */
.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--bg-white);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

