/* ==========================================
   慢病管理系统 - 公共样式
   ========================================== */

:root {
    --primary-color: #1890ff;
    --primary-dark: #096dd9;
    --primary-light: #e6f7ff;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --danger-color: #ff4d4f;
    --text-color: #333;
    --text-secondary: #666;
    --text-light: #999;
    --border-color: #e8e8e8;
    --bg-color: #f5f5f5;
    --white: #fff;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-sm: 4px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--bg-color);
    -webkit-font-smoothing: antialiased;
}

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

/* 容器 */
.container {
    max-width: 100%;
    padding: 0 16px;
}

/* 卡片 */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.card-body {
    padding: 16px;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover, .btn-primary:active {
    background: var(--primary-dark);
}

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

.btn-success { background: var(--success-color); color: var(--white); }
.btn-warning { background: var(--warning-color); color: var(--white); }
.btn-danger { background: var(--danger-color); color: var(--white); }

.btn-block {
    display: flex;
    width: 100%;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.3s;
}

.form-control:focus {
    border-color: var(--primary-color);
}

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

select.form-control {
    appearance: none;
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23999' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") no-repeat right 12px center/12px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* 标签 */
.tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-secondary);
}

.tag-primary { background: var(--primary-light); color: var(--primary-color); }
.tag-success { background: #f6ffed; color: var(--success-color); }
.tag-warning { background: #fffbe6; color: var(--warning-color); }
.tag-danger { background: #fff2f0; color: var(--danger-color); }

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

.status-normal { background: var(--success-color); }
.status-warning { background: var(--warning-color); }
.status-danger { background: var(--danger-color); }

/* 数据项 */
.data-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.data-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.data-value {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-color);
}

.data-value.large {
    font-size: 24px;
}

.data-unit {
    font-size: 12px;
    color: var(--text-light);
    margin-left: 4px;
}

/* 空状态 */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* 加载 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

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

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

/* Toast提示 */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius);
    z-index: 9999;
    max-width: 80%;
    text-align: center;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 弹窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* 确认对话框 */
.confirm-dialog {
    background: #fff;
    width: 90%;
    max-width: 360px;
    border-radius: 8px;
    animation: modalFadeIn 0.2s;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.confirm-header {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.confirm-close {
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.confirm-close:hover {
    color: #333;
}

.confirm-body {
    padding: 20px 16px;
}

.confirm-footer {
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.confirm-footer .btn {
    min-width: 70px;
    padding: 8px 16px;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: none;
    width: auto;
    max-width: none;
    max-height: none;
    border-radius: var(--radius);
    overflow: visible;
    z-index: 1001;
}

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

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

.modal-close {
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

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

.modal-footer .btn {
    min-width: 80px;
}

/* 列表 */
.list-item {
    display: flex;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.list-item:active {
    background: var(--bg-color);
}

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

.list-item-title {
    font-size: 15px;
    color: var(--text-color);
    margin-bottom: 4px;
}

.list-item-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

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

/* 网格 */
.grid {
    display: grid;
    gap: 12px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* 快捷入口 */
.quick-entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    background: var(--white);
    border-radius: var(--radius);
    cursor: pointer;
}

.quick-entry:active {
    background: var(--bg-color);
}

.quick-entry-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 8px;
}

.quick-entry-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* 头部导航 */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--white);
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: var(--shadow);
    z-index: 100;
}

.header-title {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
}

.header-back, .header-action {
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-color);
    cursor: pointer;
}

/* 底部导航 */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--white);
    display: flex;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 11px;
    cursor: pointer;
}

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

.tabbar-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

/* 页面内容 */
.page {
    padding-top: 50px;
    padding-bottom: 56px;
    min-height: 100vh;
}

.page-content {
    padding: 12px 0;
}

/* 健康数据卡片 */
.health-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    margin: 12px 16px;
}

.health-card .date {
    font-size: 13px;
    opacity: 0.8;
    margin-bottom: 12px;
}

.health-stats {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.health-stat-item {
    flex: 1;
}

.health-stat-value {
    font-size: 28px;
    font-weight: 600;
}

.health-stat-label {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
}

/* 完成度进度条 */
.progress-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.3s;
}

/* 图表占位 */
.chart-placeholder {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-radius: var(--radius);
    color: var(--text-light);
}

/* 响应式适配 */
@media (min-width: 768px) {
    .container {
        max-width: 750px;
        margin: 0 auto;
    }
}
