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

: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;
}

/* 顶部导航 */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar h1 {
    font-size: 18px;
    font-weight: 600;
}

.navbar .back-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    text-decoration: none;
}

.navbar .nav-right {
    display: flex;
    gap: 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: 24px;
    height: 24px;
}

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

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

/* 指标卡片网格 */
.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);
    transition: transform 0.2s, box-shadow 0.2s;
    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;
    color: var(--text);
}

.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;
}

.metric-card-date {
    color: var(--text-light);
}

.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);
}

/* 表单 */
.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;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* 按钮 */
.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%;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}

/* 快捷记录 */
.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: 120px;
    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);
    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 {
    text-align: right;
    font-size: 16px;
    font-weight: 600;
}

.list-item-meta {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

.heart-rate-annotation {
    color: #e74c3c;
    font-size: 14px;
    font-weight: 500;
    margin-left: 6px;
}

.list-item-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-light);
    margin-left: 8px;
}

/* 图表容器 */
.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;
    transition: all 0.2s;
}

.period-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #FFFFFF;
}

/* 状态提示 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* 页面切换 */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* 加载状态 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-light);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

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

/* Toast */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.75);
    color: #FFFFFF;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    animation: fadeInUp 0.3s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: none;
}

.modal-overlay.active {
    display: block;
}

.modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: 16px 16px 0 0;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 201;
    transform: translateY(100%);
    transition: transform 0.3s;
}

.modal.active {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    cursor: pointer;
}

.modal-body {
    padding: 16px;
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

/* 历史记录 */
.record-date-group {
    margin-bottom: 16px;
}

.record-date-label {
    font-size: 13px;
    color: var(--text-light);
    padding: 8px 0;
    position: sticky;
    top: 56px;
    background: var(--bg);
    z-index: 10;
}

/* 页面标题 */
.page-header {
    padding: 20px 0 16px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 个人资料 */
.avatar-section {
    text-align: center;
    padding: 20px 0;
}

.avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #E8F8EE;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: var(--primary);
    font-size: 32px;
    font-weight: 600;
    overflow: hidden;
}

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

/* 工具类 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-light { color: var(--text-light); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

/* 登录页 */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #E8F8EE 0%, #F5F5F5 100%);
}

.auth-header {
    padding: 60px 32px 40px;
    text-align: center;
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: white;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.auth-form {
    flex: 1;
    padding: 0 24px;
}

.auth-footer {
    padding: 20px 24px 40px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
}

/* 防抖提示 */
.input-hint-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.normal-range {
    font-size: 12px;
    color: var(--text-light);
}

/* 状态指示 */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.normal { background: var(--success); }
.status-dot.abnormal { background: var(--danger); }
.status-dot.unknown { background: var(--text-light); }
