/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* 容器 */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* 头部 */
header {
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.header-content > div:first-child {
    flex: 1;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* 语言切换 */
.language-switcher {
    flex-shrink: 0;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.lang-icon {
    width: 20px;
    height: 20px;
}

/* 主内容区 */
main {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    margin-bottom: 2rem;
}

/* 选项卡 */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

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

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* 内容面板 */
.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

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

/* 上传区域 */
.upload-area {
    border: 3px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--background);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: #eff6ff;
    transform: scale(1.02);
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-subtext {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 图片预览区域 */
.image-preview-container {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    background: var(--background);
    animation: fadeIn 0.3s;
}

.image-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.image-preview-header h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
}

.image-preview-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    border-radius: 8px;
    padding: 1rem;
    min-height: 200px;
}

.preview-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: var(--shadow);
}

/* 摄像头容器 */
.camera-container {
    text-align: center;
}

#video {
    width: 100%;
    max-width: 640px;
    height: auto;
    border-radius: 8px;
    background: #000;
    margin-bottom: 1rem;
}

.camera-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.status-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-height: 1.5rem;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

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

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* 结果显示 */
.result-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #eff6ff;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    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: 1rem;
}

.result-header h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.result-text {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    word-break: break-all;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    max-height: 300px;
    overflow-y: auto;
}

.result-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* 历史记录 */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.history-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
}

.history-item {
    background: var(--background);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.history-content {
    color: var(--text-primary);
    word-break: break-all;
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem 0;
}

/* 底部 */
footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    main {
        padding: 1.5rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .header-content > div:first-child {
        text-align: center;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .lang-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .lang-icon {
        width: 18px;
        height: 18px;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .upload-icon {
        width: 48px;
        height: 48px;
    }

    .result-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* 滚动条样式 */
.history-list::-webkit-scrollbar,
.result-text::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track,
.result-text::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb,
.result-text::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb:hover,
.result-text::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* 工具描述区域 */
.description-section {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    margin-bottom: 2rem;
}

.description-section h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    text-align: center;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.feature-card {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--border);
    transition: all 0.3s;
}

.feature-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    width: 48px;
    height: 48px;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* 用户评价区域 */
.reviews-section {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    margin-bottom: 2rem;
}

.reviews-section h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    text-align: center;
}

.reviews-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.review-card {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--border);
    transition: all 0.3s;
}

.review-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.review-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.review-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), #60a5fa);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.review-avatar svg {
    width: 28px;
    height: 28px;
    color: white;
}

.review-info {
    flex: 1;
}

.review-name {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.review-stars {
    display: flex;
    gap: 2px;
}

.review-stars .star {
    color: #fbbf24;
    font-size: 1rem;
}

.review-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* 响应式设计 - 工具描述和评价区域 */
@media (max-width: 768px) {
    .description-section,
    .reviews-section {
        padding: 1.5rem;
    }

    .description-section h2,
    .reviews-section h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .features-grid,
    .reviews-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .feature-card,
    .review-card {
        padding: 1.25rem;
    }

    .feature-icon {
        width: 40px;
        height: 40px;
    }

    .review-avatar {
        width: 40px;
        height: 40px;
    }

    .review-avatar svg {
        width: 24px;
        height: 24px;
    }
}
