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

:root {
    --primary-color: #3b82f6;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --background: #f3f4f6;
    --card-background: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

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%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

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

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

header h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 16px;
    opacity: 0.9;
}

/* 标签页样式 */
.tabs {
    display: flex;
    background: #f9fafb;
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    flex: 1;
    padding: 16px 20px;
    background: transparent;
    border: none;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.tab-button:hover {
    background: rgba(59, 130, 246, 0.05);
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    background: white;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

/* 内容区域 */
.content {
    padding: 30px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.tool-section h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* 输入组 */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.input-text {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.input-text:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 选项组 */
.options-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
}

.option-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-item label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.select-field {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.select-field:focus {
    outline: none;
    border-color: var(--primary-color);
}

.color-picker {
    width: 100%;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

/* 按钮组 */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

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

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

/* 结果区域 */
.result-section {
    margin-top: 30px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
    border: 2px dashed var(--border-color);
}

.result-section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.qr-display {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 8px;
    margin-bottom: 15px;
}

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

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 15px;
    color: var(--text-secondary);
}

.upload-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 摄像头区域 */
.camera-section {
    margin-top: 20px;
    padding: 20px;
    background: #1f2937;
    border-radius: 8px;
    text-align: center;
}

#camera-video {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* 预览容器 */
.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 8px;
    margin-bottom: 15px;
}

.preview-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
}

/* 输出组 */
.output-group {
    margin-bottom: 15px;
}

.output-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.output-text {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    background: white;
    resize: vertical;
}

/* 提示消息 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    z-index: 1000;
    max-width: 350px;
}

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

.toast.error {
    background: var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 12px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 24px;
    }

    .content {
        padding: 20px;
    }

    .options-group {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
