/* ===================================
   SkinMirror Design System
   ================================== */

/* 设计令牌 (Design Tokens) */
:root {
    /* 主色调 - 渐变 */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-cta: linear-gradient(135deg, #00d9ff 0%, #764ba2 100%);
    --gradient-bg: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    
    /* 语义色 */
    --color-success: #00e676;
    --color-warning: #ffab40;
    --color-error: #ff5252;
    --color-info: #00d9ff;
    
    /* 中性色 */
    --color-text-primary: #ffffff;
    --color-text-secondary: rgba(255, 255, 255, 0.7);
    --color-text-muted: rgba(255, 255, 255, 0.4);
    --color-surface: rgba(255, 255, 255, 0.08);
    --color-surface-elevated: rgba(255, 255, 255, 0.12);
    --color-border: rgba(255, 255, 255, 0.1);
    
    /* 字体规范 */
    --font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    --text-xs: 10px;
    --text-sm: 12px;
    --text-base: 14px;
    --text-lg: 16px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 32px;
    --text-4xl: 48px;
    
    /* 字重 */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    
    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* 阴影 */
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.25);
    --shadow-button: 0 8px 32px rgba(102, 126, 234, 0.4);
    --shadow-glow: 0 0 40px rgba(0, 217, 255, 0.3);
    
    /* 间距（基于 4px 网格） */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
}

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

body {
    font-family: var(--font-family);
    background: var(--gradient-bg);
    color: var(--color-text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 页面容器 */
.page {
    display: none;
    min-height: 100vh;
    padding-bottom: 83px; /* 为底部导航预留空间 */
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* ===================================
   首页 - Home Page
   ================================== */

/* 顶部问候区 */
.greeting-section {
    display: flex;
    align-items: center;
    padding: var(--space-6);
    gap: var(--space-4);
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.greeting-text {
    flex: 1;
}

.greeting-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-1);
}

.greeting-subtitle {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

/* 核心 CTA 区域 */
.cta-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-10) var(--space-6);
}

.cta-button {
    width: 160px;
    height: 160px;
    border-radius: var(--radius-full);
    background: var(--gradient-cta);
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    box-shadow: var(--shadow-glow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    color: white;
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}

.cta-button:hover,
.cta-button:active {
    transform: scale(0.95);
    box-shadow: 0 0 50px rgba(0, 217, 255, 0.5);
}

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

.cta-hint {
    margin-top: var(--space-4);
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

/* 统计卡片区 */
.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
    padding: 0 var(--space-6);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    text-align: center;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

/* 历史记录区 */
.history-section {
    padding: 0 var(--space-6) var(--space-6);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.section-header h3 {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}

.view-more {
    font-size: var(--text-sm);
    color: var(--color-info);
    text-decoration: none;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.history-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 80px;
}

.history-info {
    flex: 1;
}

.history-date {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2);
}

.history-summary {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.history-score {
    background: var(--gradient-primary);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    padding: var(--space-10) var(--space-6);
    color: var(--color-text-muted);
    font-size: var(--text-base);
}

/* ===================================
   底部导航 - Tab Bar
   ================================== */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 83px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 100;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    transition: all 0.3s ease;
    padding: var(--space-2);
}

.tab-item.active {
    color: var(--color-info);
}

.tab-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.tab-item.active .tab-icon {
    transform: translateY(-2px) scale(1.1);
}

/* ===================================
   相机页 - Camera Page
   ================================== */
.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.nav-back,
.nav-action {
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: var(--text-base);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav-back svg,
.nav-action svg {
    width: 24px;
    height: 24px;
}

.nav-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}

.camera-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 200px);
    background: #000;
    overflow: hidden;
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 人脸检测框 */
.face-outline {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 240px;
    height: 320px;
    border: 2px dashed var(--color-info);
    border-radius: 50%;
    pointer-events: none;
    transition: border-color 0.3s ease;
}

.face-outline.detected {
    border-style: solid;
    border-color: var(--color-success);
}

.face-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid var(--color-info);
}

.face-corner.tl {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
    border-radius: 20px 0 0 0;
}

.face-corner.tr {
    top: -2px;
    right: -2px;
    border-left: none;
    border-bottom: none;
    border-radius: 0 20px 0 0;
}

.face-corner.bl {
    bottom: -2px;
    left: -2px;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 20px;
}

.face-corner.br {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
    border-radius: 0 0 20px 0;
}

.camera-hints {
    position: absolute;
    bottom: var(--space-6);
    left: 0;
    right: 0;
    text-align: center;
}

.hint-text {
    font-size: var(--text-base);
    color: white;
    margin-bottom: var(--space-3);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.env-status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--color-surface);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--text-base);
}

.status-icon {
    font-size: var(--text-lg);
}

.env-status.good .status-icon {
    color: var(--color-success);
}

.env-status.warning .status-icon {
    color: var(--color-warning);
}

.env-status.error .status-icon {
    color: var(--color-error);
}

/* 拍照控制区 */
.camera-controls {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: var(--space-6);
}

.control-btn {
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: var(--text-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
}

.control-btn svg {
    width: 32px;
    height: 32px;
}

.capture-btn {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-full);
    border: 4px solid white;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.capture-btn:active {
    transform: scale(0.95);
}

.capture-inner {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: white;
}

/* ===================================
   分析中页面 - Loading Page
   ================================== */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-6);
}

.photo-preview {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-8);
    position: relative;
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(4px);
}

.photo-preview::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--color-info), transparent);
    animation: scan 2s linear infinite;
}

.loading-dots {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--color-info);
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }
.loading-dots span:nth-child(4) { animation-delay: 0.16s; }
.loading-dots span:nth-child(5) { animation-delay: 0.32s; }

.loading-text {
    font-size: var(--text-lg);
    margin-bottom: var(--space-6);
}

.progress-container {
    width: 100%;
    max-width: 300px;
    margin-bottom: var(--space-8);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--color-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-2);
}

.progress-fill {
    height: 100%;
    background: var(--gradient-cta);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
}

.progress-percent {
    text-align: center;
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

.analysis-steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    text-align: left;
}

.step-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-base);
}

.step-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-item.active .step-icon {
    color: var(--color-info);
    animation: pulse 1s infinite;
}

.step-item.completed .step-icon {
    color: var(--color-success);
}

.step-item.completed .step-icon::before {
    content: '✓';
}

/* ===================================
   结果页 - Results Page
   ================================== */
.results-content {
    padding: var(--space-6);
    padding-bottom: calc(var(--space-6) + 83px);
}

.result-timestamp {
    text-align: center;
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-6);
}

/* 综合评分 */
.score-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: var(--space-8);
}

.score-circle {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: var(--space-4);
}

.score-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--color-surface);
    stroke-width: 8;
}

.ring-progress {
    fill: none;
    stroke: url(#scoreGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s ease;
}

.score-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.score-number {
    font-size: var(--text-4xl);
    font-weight: var(--font-bold);
    line-height: 1;
}

.score-unit {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
}

.score-label {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

#score-status {
    font-weight: var(--font-semibold);
}

#score-status.good {
    color: var(--color-success);
}

#score-status.medium {
    color: var(--color-warning);
}

#score-status.poor {
    color: var(--color-error);
}

/* 雷达图 */
.radar-section {
    margin-bottom: var(--space-8);
}

.section-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-4);
}

#radar-chart {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

/* 详细分析 */
.details-section {
    margin-bottom: var(--space-8);
}

.detail-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.detail-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
}

.detail-emoji {
    font-size: var(--text-xl);
}

.detail-status {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
}

.detail-status.good {
    background: rgba(0, 230, 118, 0.2);
    color: var(--color-success);
}

.detail-status.medium {
    background: rgba(255, 171, 64, 0.2);
    color: var(--color-warning);
}

.detail-status.poor {
    background: rgba(255, 82, 82, 0.2);
    color: var(--color-error);
}

.detail-progress {
    height: 6px;
    background: var(--color-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-3);
}

.detail-progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.detail-advice {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* 免责声明 */
.disclaimer {
    background: rgba(255, 171, 64, 0.1);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
    font-size: var(--text-sm);
    line-height: 1.6;
    color: var(--color-text-secondary);
}

.disclaimer p {
    margin-bottom: var(--space-2);
}

.disclaimer p:last-child {
    margin-bottom: 0;
}

/* 底部按钮 */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.btn-primary,
.btn-secondary {
    height: 48px;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.btn-primary {
    background: var(--gradient-cta);
    color: white;
    box-shadow: var(--shadow-button);
}

.btn-primary:hover,
.btn-primary:active {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
    background: transparent;
    color: white;
    border: 1px solid white;
}

.btn-secondary:hover,
.btn-secondary:active {
    background: var(--color-surface);
}

/* ===================================
   个人中心页 - Profile Page
   ================================== */
.profile-header {
    text-align: center;
    padding: var(--space-8) var(--space-6);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 0 auto var(--space-4);
    background: var(--color-surface);
    border: 3px solid var(--color-border);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2);
}

.profile-usage {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

.profile-stats {
    padding: 0 var(--space-6) var(--space-6);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
}

.profile-stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    text-align: center;
}

.settings-section {
    padding: 0 var(--space-6) var(--space-6);
}

.settings-list {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.setting-item {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    color: var(--color-text-primary);
    transition: background 0.2s ease;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item:hover {
    background: var(--color-surface-elevated);
}

.setting-icon {
    font-size: var(--text-2xl);
    margin-right: var(--space-3);
}

.setting-label {
    flex: 1;
    font-size: var(--text-base);
}

.setting-value {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.setting-arrow {
    font-size: var(--text-2xl);
    color: var(--color-text-muted);
}

/* 切换开关 */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 28px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-surface);
    transition: 0.3s;
    border-radius: var(--radius-full);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: var(--radius-full);
}

input:checked + .toggle-slider {
    background: var(--gradient-primary);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* ===================================
   响应式设计
   ================================== */
@media (min-width: 768px) {
    .page {
        max-width: 414px;
        margin: 0 auto;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }
}
