/* 健康数据记录平台 - 样式 */

:root {
    --primary: #07C160;
    --primary-dark: #05903C;
    --secondary: #576B95;
    --bg: #F5F5F5;
    --card-bg: #FFFFFF;
    --text: #333333;
    --text-secondary: #666666;
    --text-light: #999999;
    --border: #E5E5E5;
    --danger: #E54D42;
    --warning: #FF9800;
    --success: #07C160;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body { padding-bottom: 80px; }

.container { max-width: 480px; margin: 0 auto; padding: 0 16px; }

/* 页面头部 */
.page-header { padding: 20px 0 16px; }
.page-title { font-size: 20px; font-weight: 600; }
.page-subtitle { font-size: 13px; color: var(--text-light); margin-top: 4px; }

/* 卡片 */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 仪表盘卡片 */
.dashboard-card { display: none; }
.dashboard-card.show { display: block; }

.dashboard-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dashboard-card-name { font-size: 14px; font-weight: 600; color: #333; }
.dashboard-card-date { font-size: 12px; color: var(--text-light); }

.dashboard-card-value { font-size: 24px; font-weight: 700; }
.dashboard-card-value .unit { font-size: 14px; font-weight: 400; color: var(--text-light); margin-left: 4px; }
.dashboard-card-value .label { font-size: 14px; color: #666; margin-left: 8px; }

/* 底部导航 */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 100;
}

.tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-light);
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.tabbar a.active { color: var(--primary); }

.tabbar a svg { width: 22px; height: 22px; }
.tabbar a span:first-child { font-size: 20px; }

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    outline: none;
    -webkit-appearance: none;
}

.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-primary:active { background: var(--primary-dark); }
.btn-primary:disabled { background: #B8E8C4; cursor: not-allowed; }
.btn-secondary { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-block { width: 100%; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--card-bg);
}
.form-input:focus { border-color: var(--primary); }
.form-input.error { border-color: var(--danger); }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 6px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 6px; }

/* 快捷记录 */
.quick-record { display: flex; flex-direction: column; gap: 12px; }
.quick-record-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.quick-record-item:last-child { border-bottom: none; }
.quick-record-label { display: flex; align-items: center; gap: 8px; }
.quick-record-icon {
    width: 32px;
    height: 32px;
    background: #E8F8EE;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}
.quick-record-name { font-size: 15px; }
.quick-record-input {
    width: 100px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    text-align: right;
    outline: none;
}
.quick-record-input:focus { border-color: var(--primary); }
.quick-record-unit { font-size: 13px; color: var(--text-light); margin-left: 6px; }

/* 列表 */
.list { background: var(--card-bg); border-radius: var(--radius); overflow: hidden; }
.list-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--bg); }
.list-item-icon {
    width: 40px;
    height: 40px;
    background: #E8F8EE;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 18px;
    margin-right: 12px;
}
.list-item-content { flex: 1; }
.list-item-title { font-size: 15px; font-weight: 500; }
.list-item-desc { font-size: 13px; color: var(--text-light); margin-top: 2px; }
.list-item-value { font-size: 16px; font-weight: 600; text-align: right; }
.list-item-meta { font-size: 12px; color: var(--text-light); margin-top: 2px; }

/* 图表 */
.chart-container { background: var(--card-bg); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.chart-title { font-size: 16px; font-weight: 600; }
.chart-canvas { width: 100%; height: 240px; }

/* 时间筛选 */
.period-tabs { display: flex; gap: 8px; }
.period-tab {
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.period-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 登录页 */
.login-container { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 20px; background: var(--bg); }
.login-header { text-align: center; margin-bottom: 30px; }
.login-logo { width: 64px; height: 64px; background: var(--primary); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; color: #fff; margin-bottom: 12px; }
.login-title { font-size: 20px; font-weight: 600; }
.login-subtitle { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.login-form { background: var(--card-bg); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.login-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-light); }
.login-footer a { color: var(--primary); text-decoration: none; }

/* 空状态 */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-light); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 14px; }
.empty-state-hint { font-size: 13px; margin-top: 6px; }

/* 页面 */
.page { display: none; }
.page.active { display: block; }

/* 加载中 */
.loading { text-align: center; padding: 40px; color: var(--text-light); }

/* 个人资料 */
.profile-header { display: flex; align-items: center; gap: 16px; padding: 20px; background: var(--card-bg); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); }
.profile-avatar { width: 56px; height: 56px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff; font-weight: 600; }
.profile-name { font-size: 18px; font-weight: 600; }
.profile-username { font-size: 13px; color: var(--text-light); margin-top: 2px; }

/* 趋势徽章 */
.trend-badge { display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.trend-badge.up { background: #FFF0F0; color: var(--danger); }
.trend-badge.down { background: #F0FFF0; color: var(--success); }
.trend-badge.stable { background: #F5F5F5; color: var(--text-light); }

/* 指标卡片网格 */
.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
}
.metric-card:active { transform: scale(0.98); }
.metric-card-header { display: flex; align-items: center; justify-content: space-between; }
.metric-card-name { font-size: 13px; color: var(--text-secondary); }
.metric-card-icon { width: 20px; height: 20px; color: var(--primary); }
.metric-card-value { font-size: 24px; font-weight: 700; }
.metric-card-unit { font-size: 13px; font-weight: 400; color: var(--text-light); margin-left: 4px; }
.metric-card-footer { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }

/* SPA 间距工具类 */
.mt-16 { margin-top: 16px; }
.metric-card-date { color: var(--text-light); }

/* 指标点选 chips（趋势页） */
.metric-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 7px 14px; border-radius: 18px; border: 1px solid var(--border);
    background: #fff; color: var(--text-secondary); font-size: 13px; cursor: pointer;
    -webkit-tap-highlight-color: transparent; transition: all .15s;
}
.chip:active { transform: scale(.96); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 周期/通用按钮选中态 */
.btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 列表右侧箭头 */
.list-item-arrow { font-size: 20px; color: var(--text-light); margin-left: 6px; line-height: 1; }

/* 弹窗（我的页面：修改资料 / 修改密码） */
.modal-overlay {
    position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,.45);
    display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 560px) { .modal-overlay { align-items: center; } }
.modal {
    width: 100%; max-width: 480px; background: #fff;
    border-radius: 14px 14px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close { border: none; background: none; font-size: 24px; line-height: 1; color: var(--text-light); cursor: pointer; padding: 0 4px; }
.modal-body { font-size: 14px; }