/**
 * 全年龄综合健康管理平台 - 全局样式
 * UI配色参考京东健康APP风格
 * 主色调：医疗清新绿 #00A862
 * 辅助色：浅绿 #E8F7EF、深绿 #007A45
 * 背景色：浅灰 #F7F9FA
 * 卡片：纯白 #FFFFFF
 * 危险色：#FF4D4F
 */

/* ==================== CSS变量 ==================== */
:root {
    --primary: #00A862;           /* 京东健康医疗绿 */
    --primary-light: #E8F7EF;     /* 浅薄荷绿 */
    --primary-dark: #007A45;      /* 深色辅助绿 */
    --primary-gradient: linear-gradient(135deg, #00A862, #00C873); /* 绿色渐变 */
    --bg-page: #F7F9FA;           /* 页面浅灰背景 */
    --bg-white: #FFFFFF;          /* 卡片纯白 */
    --text-primary: #333333;      /* 主要文字 */
    --text-secondary: #666666;    /* 次要文字 */
    --text-muted: #999999;        /* 辅助文字 */
    --border-color: #E8E8E8;      /* 边框色 */
    --danger: #FF4D4F;            /* 危险/异常红 */
    --danger-light: #FFF1F0;      /* 浅红背景 */
    --success: #00A862;           /* 成功绿 */
    --warning: #FAAD14;           /* 警告黄 */
    --info: #1890FF;              /* 信息蓝 */
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --sidebar-width: 240px;
    --navbar-height: 56px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    color: var(--primary-dark);
}

/* ==================== 顶部导航栏 ==================== */
.navbar {
    background: var(--primary-gradient);
    box-shadow: var(--shadow-md);
    padding: 0 1rem;
    height: var(--navbar-height);
    z-index: 1030;
}

.navbar-brand {
    color: #fff !important;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.5px;
}

.navbar-brand i {
    font-size: 1.3rem;
}

.navbar .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.9rem;
}
.navbar .nav-link:hover {
    color: #fff !important;
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.3);
}
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.dropdown-menu {
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0;
}
.dropdown-item {
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
}
.dropdown-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

/* ==================== 左侧导航栏 ==================== */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 1020;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
}

.sidebar-nav {
    padding: 0.5rem 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 1.2rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}
.sidebar-nav .nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}
.sidebar-nav .nav-link i {
    width: 20px;
    margin-right: 10px;
    font-size: 1rem;
    text-align: center;
}

.sidebar-nav .nav-section {
    padding: 0.8rem 1.2rem 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* ==================== 主内容区域 ==================== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
    padding-bottom: 2rem;
}

.content-wrapper {
    padding: 1.5rem;
    max-width: 1400px;
}

/* ==================== 移动端底部导航 ==================== */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-white);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 56px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
    z-index: 1030;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 0.3rem 0;
    transition: color 0.2s;
    text-decoration: none;
}
.mobile-nav-item i {
    font-size: 1.2rem;
    margin-bottom: 2px;
}
.mobile-nav-item.active,
.mobile-nav-item:hover {
    color: var(--primary);
}

/* ==================== 页面标题 ==================== */
.page-title {
    margin-bottom: 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid var(--primary-light);
}
.page-title h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.page-title h2 i {
    color: var(--primary);
    margin-right: 8px;
}
.page-title .subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ==================== 卡片样式 ==================== */
.card {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: var(--bg-white);
    transition: box-shadow 0.3s ease;
    overflow: hidden;
}
.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.2rem;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
}
.card-header i {
    color: var(--primary);
    margin-right: 8px;
}

.card-body {
    padding: 1.2rem;
}

/* ==================== 统计卡片 ==================== */
.stat-card {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--bg-white);
    height: 100%;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 0.8rem;
}
.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.stat-icon.green {
    background: var(--primary-light);
    color: var(--primary);
}
.stat-icon.blue {
    background: #E6F7FF;
    color: var(--info);
}
.stat-icon.orange {
    background: #FFF7E6;
    color: var(--warning);
}
.stat-icon.red {
    background: var(--danger-light);
    color: var(--danger);
}

/* ==================== 按钮样式 ==================== */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.2rem;
    transition: all 0.3s ease;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #009958, #00B868);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 168, 98, 0.3);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 0.5rem 1.2rem;
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border: none;
    border-radius: var(--radius-sm);
}
.btn-danger:hover {
    background: #E04040;
}

.btn-success {
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
}
.btn-success:hover {
    background: var(--primary-dark);
}

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.82rem;
}

/* ==================== 表单样式 ==================== */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 98, 0.15);
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.form-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ==================== 表格样式 ==================== */
.table {
    font-size: 0.88rem;
}

.table thead th {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
    border-bottom: 2px solid var(--primary);
    padding: 0.8rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.7rem 0.8rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}

.table tbody tr:hover {
    background-color: #FAFFFE;
}

.table-responsive {
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* ==================== 标签/徽章 ==================== */
.badge {
    font-weight: 500;
    padding: 0.35em 0.7em;
    border-radius: 6px;
    font-size: 0.75rem;
}

.badge-success {
    background: var(--primary-light);
    color: var(--primary-dark);
}

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

.badge-warning {
    background: #FFF7E6;
    color: #D48806;
}

.badge-info {
    background: #E6F7FF;
    color: #0070C0;
}

/* ==================== 提示框 ==================== */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.88rem;
}

.alert-success {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-left: 4px solid var(--primary);
}

.alert-danger {
    background: var(--danger-light);
    color: #A8071A;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #FFF7E6;
    color: #AD6800;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #E6F7FF;
    color: #0050B3;
    border-left: 4px solid var(--info);
}

/* ==================== 状态标记 ==================== */
.status-normal {
    color: var(--primary);
    font-weight: 600;
}
.status-warning {
    color: var(--warning);
    font-weight: 600;
}
.status-danger {
    color: var(--danger);
    font-weight: 600;
}

/* 血糖异常高亮 */
.abnormal-high {
    background-color: var(--danger-light) !important;
    border-left: 3px solid var(--danger);
}
.abnormal-low {
    background-color: #FFF7E6 !important;
    border-left: 3px solid var(--warning);
}
.abnormal-row {
    animation: abnormalPulse 2s ease-in-out infinite;
}

@keyframes abnormalPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* ==================== 分页样式 ==================== */
.pagination .page-link {
    color: var(--primary);
    border-color: var(--border-color);
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    font-size: 0.85rem;
}
.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.pagination .page-link:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ==================== 模态框 ==================== */
.modal-content {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    background: var(--primary-light);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.2rem;
}
.modal-title {
    font-weight: 600;
    font-size: 1rem;
}
.btn-close {
    filter: none;
}

/* ==================== 首页模块入口卡片 ==================== */
.module-card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.8rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    height: 100%;
    background: var(--bg-white);
    border: 2px solid transparent;
}
.module-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}
.module-card .module-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 1rem;
}
.module-card .module-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}
.module-card .module-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.module-icon.bg-green {
    background: var(--primary-light);
    color: var(--primary);
}
.module-icon.bg-blue {
    background: #E6F7FF;
    color: var(--info);
}
.module-icon.bg-orange {
    background: #FFF7E6;
    color: var(--warning);
}
.module-icon.bg-purple {
    background: #F0E6FF;
    color: #722ED1;
}

/* ==================== 分析结果卡片 ==================== */
.analysis-card {
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.analysis-card h5 {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
}
.analysis-card h5 i {
    margin-right: 8px;
}

.analysis-conclusion {
    background: linear-gradient(135deg, var(--primary-light), #f0faf5);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.2rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 1rem;
}

.analysis-advice {
    background: #E6F7FF;
    border-left: 4px solid var(--info);
    padding: 1rem 1.2rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 1rem;
}

.analysis-warning {
    background: var(--danger-light);
    border-left: 4px solid var(--danger);
    padding: 1rem 1.2rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 1rem;
}

/* ==================== ECharts图表容器 ==================== */
.chart-container {
    width: 100%;
    min-height: 350px;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 1rem;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    color: var(--border-color);
}
.empty-state p {
    font-size: 0.9rem;
}

/* ==================== 登录页面 ==================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #E8F7EF 0%, #F7F9FA 50%, #E6F7FF 100%);
    padding: 2rem;
}

.login-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: var(--primary-gradient);
    padding: 2rem;
    text-align: center;
    color: #fff;
}
.login-header h3 {
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}
.login-header p {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
}
.login-header i {
    font-size: 2.5rem;
    margin-bottom: 0.8rem;
    display: block;
}

.login-body {
    padding: 2rem;
}

.login-footer {
    text-align: center;
    padding: 0 2rem 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ==================== 工具类 ==================== */
.text-primary { color: var(--primary) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--primary) !important; }
.text-warning { color: var(--warning) !important; }
.bg-primary-light { background-color: var(--primary-light) !important; }
.bg-danger-light { background-color: var(--danger-light) !important; }

.fs-sm { font-size: 0.82rem; }
.fw-600 { font-weight: 600; }
.mb-0 { margin-bottom: 0 !important; }

/* ==================== 响应式适配 ==================== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0;
        padding-bottom: 70px; /* 为底部导航留空间 */
    }

    .content-wrapper {
        padding: 1rem;
    }

    .stat-card {
        margin-bottom: 0.8rem;
    }

    .module-card {
        margin-bottom: 0.8rem;
        padding: 1.2rem;
    }

    .page-title h2 {
        font-size: 1.2rem;
    }

    .table-responsive {
        font-size: 0.82rem;
    }

    .card-body {
        padding: 1rem;
    }

    .chart-container {
        min-height: 280px;
    }

    .login-card {
        max-width: 100%;
    }
}

@media (max-width: 575.98px) {
    .navbar-brand {
        font-size: 1rem;
    }

    .content-wrapper {
        padding: 0.8rem;
    }

    .btn {
        font-size: 0.85rem;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    .mobile-nav-item span {
        font-size: 0.65rem;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .sidebar,
    .navbar,
    .mobile-nav,
    .btn,
    .pagination {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
    }
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }
}

/* ==================== 动画 ==================== */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* ==================== 滚动条美化 ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ==================== 食谱/方案推荐卡片 ==================== */
.recipe-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.8rem;
    margin-bottom: 0.5rem;
}
.recipe-card .meal-time {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}
.recipe-card .meal-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ==================== 进度条 ==================== */
.progress {
    height: 8px;
    border-radius: 4px;
    background: #f0f0f0;
}
.progress-bar {
    border-radius: 4px;
    background: var(--primary-gradient);
}
