/* ============================================================
   阿尔兹海默症预防与监护平台 — 全局样式
   ============================================================ */

/* --- 基础重置与变量 --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #4a90d9;
  --color-primary-light: #6ba3e0;
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-text: #333333;
  --color-text-secondary: #666666;
  --color-border: #e0e0e0;
  --color-danger: #e74c3c;
  --font-size-base: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 22px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

/* --- 老年模式：大字体高对比度 --- */
#app-container.elderly-mode {
  --font-size-base: 20px;
  --font-size-lg: 24px;
  --font-size-xl: 30px;
}

#app-container.elderly-mode button {
  min-height: 48px;
  min-width: 48px;
  font-size: var(--font-size-lg);
}

#app-container.elderly-mode input,
#app-container.elderly-mode textarea,
#app-container.elderly-mode select {
  font-size: var(--font-size-lg);
  padding: 12px 16px;
}

#app-container.elderly-mode .nav-tab {
  font-size: 14px;
}
#app-container.elderly-mode .nav-icon {
  font-size: 26px;
}

/* --- 通用元素 --- */
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: var(--font-size-base);
  transition: opacity 0.2s;
}

button:active {
  opacity: 0.8;
}

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

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

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

input,
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--font-size-base);
}

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

/* --- 卡片 --- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* --- 页面容器 --- */
.page-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

/* --- App 容器 --- */
#app-container {
  min-height: 100vh;
}

.main-content {
  min-height: 100vh;
}
.main-content.has-nav {
  padding-top: 56px; /* 导航栏高度 */
}

/* ============================================================
   导航栏 (NavBar)
   ============================================================ */

.main-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 6px;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 11px;
  transition: color 0.15s;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.nav-tab--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.nav-icon {
  font-size: 20px;
  line-height: 1.2;
}
.nav-label {
  margin-top: 2px;
  white-space: nowrap;
}

/* ============================================================
   链接按钮 (通用)
   ============================================================ */

.link-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  padding: 2px 4px;
  font-size: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ============================================================
   模态框 (通用)
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

/* ============================================================
   登录页
   ============================================================ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-title {
  font-size: 24px;
  margin-bottom: 24px;
  color: var(--color-primary);
}

.form-group {
  text-align: left;
  margin-bottom: 16px;
}

.error-msg {
  color: var(--color-danger);
  font-size: 14px;
  margin-bottom: 12px;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.btn-group button {
  width: 100%;
}

/* ============================================================
   我的老人页
   ============================================================ */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.page-header h1 {
  font-size: var(--font-size-xl);
}

.current-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  font-size: 14px;
  background: #eef5fc;
}
.current-actions {
  font-size: 13px;
}

.elderly-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.elderly-row {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px 14px;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.elderly-row.selected {
  border-color: var(--color-primary);
  background: #f0f6fd;
}

.elderly-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.elderly-info h3 {
  font-size: 15px;
  margin-bottom: 1px;
}
.elderly-info p {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.check-icon {
  color: var(--color-primary);
  font-size: 20px;
  font-weight: bold;
  margin-left: auto;
}

.btn-detail {
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: var(--radius);
  margin-left: 8px;
  min-height: auto;
  min-width: auto;
}

.add-row {
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
}
.add-icon {
  font-size: 26px;
}

.form-row {
  display: flex;
  gap: 10px;
}
.form-row .form-group {
  flex: 1;
}

.modal-content h2 {
  margin-bottom: 16px;
}
.modal-content .btn-group {
  flex-direction: row;
  gap: 10px;
  margin-top: 16px;
}
.modal-content .btn-group button {
  flex: 1;
}

/* ============================================================
   患者详情页
   ============================================================ */

.btn-back {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 16px;
  padding: 0;
}

.select-btn {
  width: 100%;
  margin-bottom: 14px;
}

.selected-hint {
  text-align: center;
  color: var(--color-primary);
  font-size: 13px;
  margin-bottom: 14px;
  padding: 8px;
  background: #eef5fc;
  border-radius: var(--radius);
}

.info-card {
  margin-bottom: 20px;
}

.info-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.info-row .label {
  width: 100px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}
.info-row .value {
  flex: 1;
}

.qr-section {
  text-align: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed #ddd;
}

.qr-preview {
  display: block;
  margin: 0 auto;
  border-radius: 8px;
}

.qr-hint {
  font-size: 13px;
  color: #999;
  margin: 8px 0 4px;
}

.qr-btn {
  width: 100%;
  margin-top: 14px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 20px 8px;
}
.action-card:active {
  transform: scale(0.97);
}
.action-icon {
  font-size: 28px;
}

/* ============================================================
   疾病信息页
   ============================================================ */

.page-title {
  font-size: var(--font-size-xl);
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  margin-bottom: 16px;
  border-radius: var(--radius);
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0;
  font-size: 13px;
}
.tab-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.article-card {
  margin-bottom: 10px;
  cursor: pointer;
}
.article-card h3 {
  font-size: 15px;
  margin-bottom: 4px;
}
.article-date {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.empty {
  text-align: center;
  color: var(--color-text-secondary);
  padding: 40px 0;
}

.article-body {
  margin-top: 12px;
  line-height: 1.8;
  font-size: 15px;
}

/* ============================================================
   会忆大厅 (记忆相册)
   ============================================================ */

.subtitle {
  color: var(--color-text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.empty-prompt {
  text-align: center;
  padding: 60px 0;
  color: var(--color-text-secondary);
  font-size: 15px;
}

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

.photo-item {
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}
.photo-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.photo-caption {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-detail img {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.detail-info {
  margin-bottom: 12px;
}

/* ============================================================
   训练大厅
   ============================================================ */

.current-patient {
  color: var(--color-text-secondary);
  font-size: 14px;
  margin: 4px 0 16px;
}

.game-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.game-card {
  text-align: center;
  cursor: pointer;
  padding: 24px 12px;
}
.game-card:active {
  transform: scale(0.97);
}
.game-icon {
  font-size: 36px;
}
.game-card h3 {
  margin: 8px 0 4px;
  font-size: 16px;
}
.game-card p {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.reaction-box {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: var(--font-size-xl);
  cursor: pointer;
  background: var(--color-border);
  user-select: none;
}
.reaction-box.waiting {
  background: #e74c3c;
  color: #fff;
}
.reaction-box.ready {
  background: #2ecc71;
  color: #fff;
}
.reaction-box.result {
  background: var(--color-primary);
  color: #fff;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.memory-card {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-border);
  border-radius: var(--radius);
  font-size: 28px;
  cursor: pointer;
  user-select: none;
}
.memory-card.flipped {
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.score {
  text-align: center;
  font-size: var(--font-size-lg);
}

.records-section {
  margin-top: 8px;
}
.records-section h3 {
  margin-bottom: 10px;
  font-size: 15px;
}
.record-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 13px;
}

/* ============================================================
   QR 公开信息页
   ============================================================ */

.qr-public {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.qr-info {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.qr-info h2 {
  font-size: var(--font-size-xl);
  margin-bottom: 24px;
}

.qr-info .info-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-lg);
}

.qr-info .info-row.highlight {
  background: #fff8e1;
  margin: 0 -20px;
  padding: 12px 20px;
}

.qr-info .info-row a {
  color: var(--color-primary);
  font-weight: bold;
  text-decoration: none;
}

.notice {
  margin-top: 24px;
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 1.8;
}

/* ============================================================
   游戏区域
   ============================================================ */

.game-area {
  margin-bottom: 16px;
}
.game-area h3 {
  margin-bottom: 12px;
}

/* ============================================================
   加载/禁用状态
   ============================================================ */

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 响应式：小屏照片网格改为2列 */
@media (max-width: 360px) {
  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .action-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
