/* style.css - 全局样式（改造版） */

/* 基础变量 */
:root {
  --primary-color: #87CEEB;
  --primary-dark: #1E90FF;
  --bg-color: #F5F7FA;
  --card-bg: #FFFFFF;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-hint: #999999;
  --success-color: #52C41A;
  --danger-color: #FF4D4F;
  --warning-color: #FAAD14;
  --border-color: #E8E8E8;
  --shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--bg-color);
}

#app {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--bg-color);
  position: relative;
}

#page-container {
  padding-bottom: 20px;
}

/* 通用卡片样式 */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
}

/* 加载状态 */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
}

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

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

.loading-text {
  margin-top: 8px;
  color: var(--text-hint);
  font-size: 12px;
}

/* 空状态 */
.empty-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.empty-text {
  color: var(--text-hint);
  font-size: 14px;
}

/* 通用按钮 */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: #FFFFFF;
  border: none;
  border-radius: 22px;
  padding: 10px 30px;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:active {
  opacity: 0.8;
}

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

/* 标签样式 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.tag-success {
  background: rgba(82, 196, 26, 0.1);
  color: var(--success-color);
}

.tag-danger {
  background: rgba(255, 77, 79, 0.1);
  color: var(--danger-color);
}

.tag-warning {
  background: rgba(250, 173, 20, 0.1);
  color: var(--warning-color);
}

/* 分割线 */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: 10px 0;
}

/* ===================== */
/* 首页样式 */
/* ===================== */

/* 配置面板 */
.config-panel {
  padding: 30px 16px;
}

.config-card {
  padding: 24px 16px;
}

.config-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
}

.config-desc {
  font-size: 13px;
  color: var(--text-hint);
  text-align: center;
  margin-bottom: 20px;
}

.config-form {
  margin-bottom: 20px;
}

.form-item {
  margin-bottom: 12px;
}

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

.form-input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 12px;
  font-size: 14px;
  background: var(--bg-color);
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}

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

.form-input:disabled {
  opacity: 0.6;
}

.config-btn {
  width: 100%;
  margin-top: 8px;
}

.config-error {
  margin-top: 10px;
  text-align: center;
  color: var(--danger-color);
  font-size: 12px;
}

/* 主界面 */
.main-view {
  padding: 12px 16px;
}

/* 错误提示 */
.error-container {
  padding-top: 30px;
}

.error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
}

.error-icon {
  font-size: 30px;
  margin-bottom: 8px;
}

.error-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-align: center;
}

.retry-btn {
  width: 120px;
  height: 36px;
  line-height: 36px;
  padding: 0;
  font-size: 14px;
}

/* 选择器区域 */
.selector-area {
  padding: 10px 12px;
}

.selector-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.selector-item + .selector-item {
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  margin-top: 2px;
}

.selector-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex-shrink: 0;
}

.selector-value {
  display: flex;
  align-items: center;
  font-size: 14px;
  color: var(--primary-dark);
  max-width: 200px;
  cursor: pointer;
}

.selector-select {
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--primary-dark);
  outline: none;
  cursor: pointer;
  max-width: 180px;
}

.selector-arrow {
  margin-left: 4px;
  font-size: 12px;
  color: var(--text-hint);
}

/* ===================== */
/* 筛选区域样式（新增） */
/* ===================== */

.filter-area {
  padding: 10px 12px;
}

.filter-row {
  display: flex;
  align-items: center;
  padding: 6px 0;
}

.filter-row + .filter-row {
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
  margin-top: 4px;
}

.filter-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-right: 8px;
  min-width: 52px;
}

.filter-value {
  display: flex;
  align-items: center;
  flex: 1;
}

.filter-select {
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  font-size: 13px;
  color: var(--primary-dark);
  outline: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  flex: 1;
  max-width: 140px;
}

/* 检查类型chips */
.filter-row-type {
  flex-wrap: wrap;
}

.type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.type-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  -webkit-user-select: none;
}

.type-chip:active {
  transform: scale(0.95);
}

.type-chip.chip-active {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: #FFFFFF;
  border-color: transparent;
  font-weight: 500;
}

/* 成员信息卡片 */
.member-card {
  padding: 14px 12px;
}

.member-info {
  display: flex;
  align-items: center;
}

.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.member-avatar-all {
  font-size: 20px;
  background: linear-gradient(135deg, #B8E6F0, var(--primary-color));
}

.member-detail {
  margin-left: 10px;
}

.member-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.member-meta {
  display: flex;
  align-items: center;
  margin-top: 3px;
}

.meta-item {
  font-size: 12px;
  color: var(--text-hint);
  margin-right: 8px;
}

/* 健康摘要卡片 */
.summary-card {
  padding: 14px 0;
}

.summary-row {
  display: flex;
  align-items: center;
}

.summary-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.summary-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.summary-label {
  font-size: 11px;
  color: var(--text-hint);
}

.summary-divider {
  width: 1px;
  height: 30px;
  background: var(--border-color);
}

.text-danger {
  color: var(--danger-color) !important;
}

.text-success {
  color: var(--success-color) !important;
}

/* 器官分类区域 */
.organ-section {
  margin-top: 6px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-left: 4px;
}

.organ-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.organ-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s;
}

.organ-item:active {
  transform: scale(0.95);
}

.organ-icon-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(135, 206, 235, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.organ-icon-wrap.organ-abnormal {
  background: rgba(255, 77, 79, 0.1);
}

.organ-icon {
  font-size: 18px;
}

.organ-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  background: var(--danger-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.badge-text {
  font-size: 9px;
  color: #FFFFFF;
  font-weight: 600;
}

.organ-name {
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 1px;
}

.organ-count {
  font-size: 10px;
  color: var(--text-hint);
}

/* ===================== */
/* 器官详情页样式 */
/* ===================== */

/* 器官头部 */
.organ-header {
  display: flex;
  align-items: center;
  padding: 14px 12px;
}

.organ-header-icon {
  font-size: 28px;
  margin-right: 10px;
}

.organ-header-info {
  flex: 1;
}

.organ-header-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.organ-header-member {
  font-size: 12px;
  color: var(--text-hint);
  margin-top: 2px;
  display: block;
}

/* ===================== */
/* 时间线样式（新增） */
/* ===================== */

.timeline-section {
  margin-top: 6px;
}

.timeline-list {
  margin-top: 2px;
}

.timeline-group {
  padding: 12px;
  margin-bottom: 10px;
}

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

.timeline-date {
  display: flex;
  align-items: center;
}

.timeline-date-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  margin-right: 8px;
  flex-shrink: 0;
}

.timeline-date-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.timeline-hospital {
  font-size: 12px;
  color: var(--text-hint);
}

.timeline-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-indicator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-color);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.timeline-indicator:active {
  background: rgba(135, 206, 235, 0.12);
}

.ti-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.ti-value-wrap {
  display: flex;
  align-items: baseline;
  flex-shrink: 0;
  margin-right: 8px;
}

.ti-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.ti-unit {
  font-size: 11px;
  color: var(--text-hint);
  margin-left: 2px;
}

.abnormal-arrow {
  font-size: 13px;
  font-weight: 700;
  color: var(--danger-color);
  margin-left: 3px;
}

.ti-range {
  display: flex;
  align-items: center;
  width: 100%;
  margin-top: 4px;
  padding-left: 0;
}

.range-label {
  font-size: 11px;
  color: var(--text-hint);
}

.range-value {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ===================== */
/* 趋势页样式 */
/* ===================== */

.trend-header {
  padding: 14px 12px;
}

.trend-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.trend-indicator-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.trend-status {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.status-normal {
  background: rgba(82, 196, 26, 0.1);
  color: var(--success-color);
}

.status-abnormal {
  background: rgba(255, 77, 79, 0.1);
  color: var(--danger-color);
}

.trend-value-row {
  display: flex;
  align-items: baseline;
  margin-bottom: 4px;
}

.trend-current-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.trend-unit {
  font-size: 13px;
  color: var(--text-hint);
  margin-left: 4px;
}

.trend-range-row {
  display: flex;
  align-items: center;
  margin-top: 4px;
}

.trend-range-label {
  font-size: 12px;
  color: var(--text-hint);
  margin-right: 4px;
}

.trend-range-value {
  font-size: 12px;
  color: var(--primary-dark);
  font-weight: 500;
}

/* 图表区域 */
.chart-area {
  padding: 12px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: block;
}

.chart-container {
  width: 100%;
  height: 200px;
  position: relative;
}

.chart-canvas {
  width: 100%;
  height: 100%;
}

/* 悬浮提示 */
.chart-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.75);
  color: #FFFFFF;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 11px;
  pointer-events: none;
  transform: translate(-50%, -120%);
  white-space: nowrap;
  z-index: 10;
  display: none;
}

.tooltip-date {
  display: block;
  font-size: 10px;
  opacity: 0.8;
  margin-bottom: 2px;
}

.tooltip-value {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

/* 历史记录区域 */
.history-section {
  margin-top: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
}

.history-left {
  display: flex;
  flex-direction: column;
}

.history-date {
  font-size: 12px;
  color: var(--text-hint);
  margin-bottom: 2px;
}

.history-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-right {
  flex-shrink: 0;
}

/* ===================== */
/* 底部导航栏 */
/* ===================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-hint);
  transition: color 0.2s;
}

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

.nav-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.nav-label {
  font-size: 10px;
}

/* 返回按钮 */
.back-btn {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  color: var(--primary-dark);
  cursor: pointer;
  margin-bottom: 10px;
  padding: 4px 0;
}

.back-btn:active {
  opacity: 0.7;
}

/* Toast */
#toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: rgba(0, 0, 0, 0.75);
  color: #FFFFFF;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  animation: toastFadeIn 0.2s ease;
  margin-bottom: 8px;
}

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

/* 页面切换 */
.page-enter {
  animation: pageSlideIn 0.2s ease;
}

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

/* 底部留空给导航栏 */
.has-bottom-nav {
  padding-bottom: 70px;
}

/* ===================== */
/* 响应式微调 */
/* ===================== */

@media screen and (max-width: 360px) {
  .organ-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .type-chip {
    padding: 3px 8px;
    font-size: 11px;
  }

  .filter-label {
    min-width: 44px;
    font-size: 12px;
  }
}

@media screen and (min-width: 420px) {
  .timeline-indicator {
    flex-wrap: nowrap;
  }

  .ti-range {
    width: auto;
    margin-top: 0;
    margin-left: auto;
    flex-shrink: 0;
  }
}
