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

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #f9fafb;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', '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: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 语言切换 */
.language-switch {
    display: flex;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: 20px;
    gap: 4px;
}

.lang-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

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

.lang-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.history-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s;
}

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-primary);
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning-color);
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: var(--success-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 用户信息表单 */
.user-info-form {
    max-width: 1000px;
    margin: 0 auto 20px;
    animation: fadeIn 0.5s;
}

.form-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .form-layout {
        grid-template-columns: 1fr;
    }
}

.form-card {
    /* 表单卡片 */
}

.qrcode-card {
    /* 二维码卡片 */
}

.qrcode-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.qrcode-image {
    width: 200px;
    height: 200px;
    border-radius: 8px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group label svg {
    color: var(--primary-color);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input::placeholder {
    color: #9ca3af;
}

/* 主内容区 */
.main-content {
    display: none;
}

.capture-panel {
    max-width: 800px;
    margin: 0 auto;
}

.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.card h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
}

/* 采集模式切换 */
.capture-mode {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: var(--bg-primary);
    padding: 6px;
    border-radius: 12px;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s;
}

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

.mode-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* 采集区域 */
.capture-area {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

#videoElement {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* 镜像显示，符合用户习惯 */
}

#capturedPreview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    /* 不需要镜像，因为canvas绘制时已经处理过镜像 */
}

/* 人脸区域遮罩 */
.face-mask-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none; /* 不阻挡点击事件 */
    transform: scaleX(-1); /* 与视频保持一致的镜像 */
}

.capture-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    gap: 15px;
    z-index: 3;
}

.capture-overlay svg {
    opacity: 0.5;
}

.capture-overlay p {
    font-size: 14px;
    opacity: 0.8;
}

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

.drop-zone {
    width: 100%;
    aspect-ratio: 4/3;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-primary);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.drop-zone svg {
    color: var(--primary-color);
}

.drop-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

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

.preview-container {
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

.preview-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 按钮样式 */
.action-buttons {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

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

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

/* 结果显示 */
.result-container {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 20px;
}

.empty-state p {
    margin-bottom: 8px;
}

.empty-state .hint {
    font-size: 14px;
    opacity: 0.7;
}

.loading-state {
    text-align: center;
    padding: 60px 20px;
}

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

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

.loading-state p {
    color: var(--text-secondary);
    font-size: 14px;
}

.result-display {
    animation: fadeIn 0.5s;
}

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

/* 采集图片预览 */
.captured-image-preview {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.preview-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    padding: 15px;
    border-radius: 12px;
}

.preview-image-container img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    object-fit: contain;
}

/* 报告分节样式 */
.report-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.report-section:last-of-type {
    border-bottom: none;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.section-title svg {
    color: var(--primary-color);
}

/* 基本信息网格 */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    transition: all 0.3s;
}

.info-item:hover {
    background: rgba(102, 126, 234, 0.05);
    transform: translateY(-2px);
}

.info-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    font-size: 16px;
    color: var(--primary-color);
    font-weight: 600;
}

/* 面部特征徽章 */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.feature-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    transition: all 0.3s;
}

.feature-badge:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.badge-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.badge-value {
    font-size: 14px;
    color: var(--primary-color);
    font-weight: 600;
}

/* 性格分析文本 */
.analysis-text {
    padding: 15px;
    background: var(--bg-primary);
    border-radius: 10px;
    border-left: 3px solid var(--primary-color);
}

.analysis-text p {
    line-height: 1.8;
    color: var(--text-primary);
    font-size: 14px;
    margin: 0;
}

/* 职业推荐标签 */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag {
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

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

/* 核心竞争力列表 */
.competencies-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.competency-item {
    padding: 12px 15px;
    background: var(--bg-primary);
    border-radius: 8px;
    border-left: 3px solid var(--success-color);
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.competency-item::before {
    content: '✓';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.competency-item:hover {
    background: rgba(16, 185, 129, 0.05);
    transform: translateX(5px);
}

.result-item {
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 12px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.result-item:hover {
    background: rgba(102, 126, 234, 0.05);
    transform: translateX(5px);
}

.result-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.result-label svg {
    color: var(--primary-color);
}

.result-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

.result-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

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

.result-time span {
    color: var(--text-primary);
    font-weight: 500;
}

/* 历史记录 */
.history-card {
    margin-top: 20px;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

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

.empty-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 40px 0;
}

.history-item {
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.history-item:hover {
    background: rgba(102, 126, 234, 0.05);
    transform: translateX(3px);
}

.history-item strong {
    color: var(--text-primary);
}

/* Toast通知 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    animation: slideIn 0.3s;
    max-width: 400px;
}

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

.toast.show {
    display: flex;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

/* 拍照指南弹窗 */
.photo-guide-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.photo-guide-modal.show {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    max-width: 480px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 18px 25px 15px;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 20px 20px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: white;
    text-align: center;
}

.modal-body {
    padding: 20px 25px;
}

.guide-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 10px;
    transition: all 0.3s;
}

.guide-step:hover {
    background: rgba(102, 126, 234, 0.08);
    transform: translateX(5px);
}

.guide-step:last-child {
    margin-bottom: 0;
}

.step-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
}

.step-content {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    padding-top: 4px;
}

/* 带图片的步骤 */
.guide-step-with-image {
    flex-direction: column;
    align-items: stretch;
}

.guide-step-with-image .step-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.step-text {
    padding-top: 0;
}

.guide-example-image {
    width: 100%;
    max-width: 200px;
    height: auto;
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
    margin: 4px auto 0;
    display: block;
    border: 1px solid var(--border-color);
}

.modal-footer {
    padding: 15px 25px 20px;
    display: flex;
    justify-content: center;
}

.modal-footer .btn {
    min-width: 150px;
    padding: 12px 30px;
}

/* 报告生成成功弹窗 */
.report-success-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.report-success-modal.show {
    display: flex;
}

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

.success-icon {
    margin: 30px auto 20px;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--success-color), #059669);
    border-radius: 50%;
    color: white;
    animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.success-modal .modal-header {
    background: transparent;
    border: none;
    padding: 10px 30px;
}

.success-modal .modal-header h3 {
    color: var(--text-primary);
    font-size: 24px;
}

.success-message {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin: 0;
}

.success-modal .modal-footer {
    gap: 12px;
}

.success-modal .modal-footer .btn {
    flex: 1;
}

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

    .header {
        flex-direction: column;
        gap: 15px;
        padding: 20px;
    }
    
    .header-actions {
        flex-direction: row;
        width: 100%;
        justify-content: center;
    }

    .logo h1 {
        font-size: 20px;
    }

    .card {
        padding: 20px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
    
    .capture-panel {
        max-width: 100%;
    }
    
    /* 移动端弹窗优化 */
    .modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .modal-header h3 {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .guide-step {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .step-number {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .step-content {
        font-size: 14px;
    }
    
    .modal-footer {
        padding: 15px 20px 20px;
    }
    
    .modal-footer .btn {
        width: 100%;
        min-width: auto;
    }
    
    /* 报告成功弹窗移动端优化 */
    .success-icon {
        width: 60px;
        height: 60px;
        margin: 20px auto 15px;
    }
    
    .success-icon svg {
        width: 60px;
        height: 60px;
    }
    
    .success-modal .modal-header h3 {
        font-size: 20px;
    }
    
    .success-message {
        font-size: 14px;
    }
    
    .success-modal .modal-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .success-modal .modal-footer .btn {
        width: 100%;
    }
}

