/* ═══════════════════════════════════════════════════════════════
   家长端移动端样式框架 v1.0
   主题色：橙色 #FF9800（温暖、亲和）
   设计理念：简洁、清晰、易用，适合移动端家长用户
═══════════════════════════════════════════════════════════════ */

/* ─── 1. CSS变量 ─────────────────────────────────────────────── */
:root {
    /* 主题色 */
    --primary: #FF9800;
    --primary-dark: #F57C00;
    --primary-light: #FFE0B2;
    --primary-bg: #FFF8F0;

    /* 辅助色 */
    --success: #4CAF50;
    --success-bg: #E8F5E9;
    --warning: #FFC107;
    --warning-bg: #FFF8E1;
    --danger: #F44336;
    --danger-bg: #FFEBEE;
    --info: #2196F3;
    --info-bg: #E3F2FD;

    /* 中性色 */
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-light: #BDBDBD;
    --bg-page: #F5F5F5;
    --bg-card: #FFFFFF;
    --border-color: #E0E0E0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

    /* 布局 */
    --nav-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

/* ─── 2. 基础重置 ─────────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    /* 防止iOS弹性滚动影响 */
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button {
    border: none;
    outline: none;
    font-family: inherit;
    cursor: pointer;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* ─── 3. 页面容器 ─────────────────────────────────────────────── */
.page-container {
    min-height: 100vh;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    background: var(--bg-page);
}

/* 顶部栏 */
.page-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 16px 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(255, 152, 0, 0.3);
}

.page-header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.page-header .back-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
}

.page-header .back-btn:active {
    background: rgba(255,255,255,0.35);
}

.page-header .header-action {
    font-size: 24px;
    padding: 4px;
}

/* 内容区域 */
.page-content {
    padding: 16px;
}

/* ─── 4. 卡片系统 ─────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:active {
    transform: scale(0.98);
}

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

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

.card-title .icon {
    font-size: 20px;
    color: var(--primary);
}

/* 孩子信息卡片 */
.child-card {
    position: relative;
    overflow: hidden;
    border-left: 4px solid var(--primary);
}

.child-card .child-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--primary);
    flex-shrink: 0;
}

.child-card .child-info {
    flex: 1;
    min-width: 0;
}

.child-card .child-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.child-card .child-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.child-card .child-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ─── 5. 健康状态标签 ─────────────────────────────────────────── */
.health-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.health-badge.normal {
    background: var(--success-bg);
    color: var(--success);
}

.health-badge.warning {
    background: var(--warning-bg);
    color: #F57C00;
}

.health-badge.danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.health-badge.info {
    background: var(--info-bg);
    color: var(--info);
}

/* 五健模块标签 */
.module-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius);
    background: var(--primary-bg);
    color: var(--primary);
    font-size: 11px;
    gap: 4px;
    transition: all 0.2s;
}

.module-badge:active {
    transform: scale(0.95);
}

.module-badge .num {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.module-badge .label {
    font-size: 10px;
    color: var(--text-secondary);
}

/* ─── 6. 按钮系统 ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
    min-height: 48px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.35);
}

.btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 6px rgba(255, 152, 0, 0.25);
}

.btn-primary:disabled {
    background: var(--text-light);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:active {
    background: var(--primary-bg);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    min-height: 36px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--primary);
    font-size: 18px;
}

/* ─── 7. 表单系统 ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    transition: border-color 0.2s;
    background: white;
}

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

.form-input::placeholder {
    color: var(--text-light);
}

/* 验证码输入组 */
.code-input-group {
    display: flex;
    gap: 12px;
}

.code-input-group .form-input {
    flex: 1;
}

.code-input-group .btn {
    flex-shrink: 0;
    min-width: 110px;
}

.code-input-group .btn:disabled {
    background: var(--text-light);
}

/* 错误提示 */
.form-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

/* ─── 8. 底部导航栏 ─────────────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: white;
    display: flex;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    z-index: 1000;
    border-top: 1px solid var(--border-color);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-secondary);
    transition: color 0.2s;
    padding: 8px 0;
    position: relative;
}

.nav-item .nav-icon {
    font-size: 22px;
    line-height: 1;
}

.nav-item .nav-text {
    font-size: 11px;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

/* 导航消息角标 */
.nav-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 18px);
    min-width: 16px;
    height: 16px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ─── 9. 统计卡片网格 ─────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-card.blue .stat-value { color: var(--info); }
.stat-card.green .stat-value { color: var(--success); }
.stat-card.orange .stat-value { color: var(--primary); }

/* ─── 10. 记录表格 ─────────────────────────────────────────────── */
.record-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.record-table th,
.record-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.record-table th {
    background: var(--bg-page);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.record-table tr:last-child td {
    border-bottom: none;
}

.record-table .date {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.record-table .result-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

/* ─── 11. Tab切换 ─────────────────────────────────────────────── */
.tabs {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 4px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-item {
    flex: 1;
    min-width: 80px;
    padding: 10px 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.tab-content {
    display: none;
}

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

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

/* ─── 12. 图表容器 ─────────────────────────────────────────────── */
.chart-container {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.chart-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-wrapper {
    position: relative;
    height: 200px;
}

/* ─── 13. 空状态 ─────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state .empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state .empty-desc {
    font-size: 13px;
    margin-bottom: 20px;
}

/* ─── 14. 登录/注册页特殊样式 ─────────────────────────────────── */
.auth-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
}

.auth-header {
    padding: 48px 24px 32px;
    text-align: center;
    color: white;
}

.auth-header .logo {
    font-size: 48px;
    margin-bottom: 12px;
}

.auth-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-header p {
    font-size: 14px;
    opacity: 0.85;
}

.auth-body {
    flex: 1;
    background: white;
    border-radius: 24px 24px 0 0;
    padding: 28px 20px;
    min-height: 50vh;
    overflow-x: hidden;
    word-wrap: break-word;
    width: 100%;
}
.auth-body > * {
    max-width: 100%;
    box-sizing: border-box;
}
.login-link {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    text-align: center;
}

.auth-footer {
    text-align: center;
    padding: 16px 20px 24px;
    color: rgba(255,255,255,0.7);
    font-size: 13px;
}

.auth-footer a {
    color: white;
    font-weight: 600;
}

/* 步骤指示器 */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    transition: all 0.3s;
}

.step-dot.active {
    width: 24px;
    border-radius: 4px;
    background: var(--primary);
}

/* ─── 15. 加载状态 ─────────────────────────────────────────────── */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--text-secondary);
    gap: 12px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* 骨架屏 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── 16. 快捷操作入口 ─────────────────────────────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 6px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.quick-action:active {
    transform: scale(0.95);
    background: var(--primary-bg);
}

.quick-action .action-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.quick-action .action-icon.weight { background: #E3F2FD; color: #1976D2; }
.quick-action .action-icon.vision { background: #F3E5F5; color: #7B1FA2; }
.quick-action .action-icon.bone { background: #E8F5E9; color: #388E3C; }
.quick-action .action-icon.oral { background: #FFF3E0; color: #E64A19; }
.quick-action .action-icon.mental { background: #FCE4EC; color: #C2185B; }

.quick-action .action-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

/* ─── 17. 消息列表 ─────────────────────────────────────────────── */
.message-list {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.message-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

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

.message-item:active {
    background: var(--bg-page);
}

.message-item.unread {
    background: var(--primary-bg);
}

.message-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-title .unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
}

.message-desc {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-time {
    font-size: 11px;
    color: var(--text-light);
    flex-shrink: 0;
}

/* ─── 18. 报告卡片 ─────────────────────────────────────────────── */
.report-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.report-card::after {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.report-card .report-label {
    font-size: 12px;
    opacity: 0.85;
    margin-bottom: 4px;
}

.report-card .report-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.report-card .report-meta {
    font-size: 12px;
    opacity: 0.75;
}

/* ─── 19. 工具类 ─────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.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; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.font-bold { font-weight: 700; }

/* ─── 20. 动画 ─────────────────────────────────────────────────── */
.slide-up {
    animation: slideUp 0.3s ease;
}

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

/* ─── 21. Toast 提示 ─────────────────────────────────────────── */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 9999;
    transition: transform 0.3s ease;
    max-width: calc(100vw - 40px);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

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

/* ─── 22. 超小屏适配（≤360px） ──────────────────────────────── */
@media screen and (max-width: 360px) {
    .auth-body {
        padding: 24px 14px;
    }
    .auth-header {
        padding: 32px 16px 24px;
    }
    .auth-header h2 {
        font-size: 20px;
    }
    .auth-body h3 {
        font-size: 16px;
    }
    .stats-grid {
        gap: 6px;
    }
    .detail-grid {
        gap: 8px;
    }
    .five-health-grid {
        gap: 4px;
    }
    .five-health-grid .label {
        font-size: 10px;
        white-space: normal;
        word-break: break-all;
    }
    .quick-actions {
        gap: 6px;
    }
    .record-table {
        font-size: 12px;
    }
    .record-table th,
    .record-table td {
        padding: 6px 4px;
    }
}
