/* 医路相伴·愈见安康 Patient UI
 * 与当前在线原型的 mp.css 对齐，同时保留旧页面使用的兼容类名。
 */

:root {
  --mp-primary: #07c160;
  --mp-primary-dark: #06ad56;
  --mp-blue: #2b6cb0;
  --mp-blue-light: #4299e1;
  --mp-bg: #f5f5f5;
  --mp-card: #ffffff;
  --mp-text: #1a1a1a;
  --mp-text-2: #666666;
  --mp-text-3: #999999;
  --mp-border: #ebebeb;
  --mp-radius: 12px;
  --mp-radius-sm: 8px;
  --mp-shadow: 0 2px 12px rgba(0,0,0,0.06);
  --mp-tabbar-h: 56px;
  --mp-navbar-h: 44px;
  --mp-statusbar-h: 20px;

  /* 旧页面兼容令牌 */
  --primary: var(--mp-blue);
  --primary-light: var(--mp-blue-light);
  --primary-dark: #1a4f8a;
  --success: #38a169;
  --warning: #d69e2e;
  --danger: #e53e3e;
  --info: #3182ce;
  --bg: var(--mp-bg);
  --card-bg: var(--mp-card);
  --text: var(--mp-text);
  --text-light: var(--mp-text-2);
  --text-lighter: var(--mp-text-3);
  --border: var(--mp-border);
  --shadow: var(--mp-shadow);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
  --radius: var(--mp-radius);
  --radius-sm: var(--mp-radius-sm);
  --radius-lg: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --navbar-h: var(--mp-navbar-h);
  --tabbar-h: var(--mp-tabbar-h);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

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

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.mp-body {
  width: 100%;
  max-width: 430px;
  height: 100vh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--mp-bg);
  box-shadow: 0 0 40px rgba(0,0,0,.15);
}

.mp-body > #app {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--mp-tabbar-h) + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.mp-scroll {
  overflow-x: hidden;
  padding-bottom: calc(var(--mp-tabbar-h) + 8px);
}

/* === 状态栏占位（沉浸式头部） === */
.mp-statusbar {
  height: var(--mp-statusbar-h);
  background: #fff;
  flex-shrink: 0;
}

/* === 顶部导航栏 === */
.mp-navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--mp-navbar-h);
  display: flex; align-items: center; justify-content: center;
  padding: 0 56px;
  background: #fff;
  color: var(--mp-text);
  border-bottom: 1px solid var(--mp-border);
}
.mp-navbar-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
}
.mp-navbar-action {
  position: absolute;
  right: 16px;
  font-size: 14px;
  padding: 8px 0;
  color: var(--mp-blue);
  cursor: pointer;
}
.mp-navbar-back {
  position: absolute;
  left: 16px;
  padding: 8px 0;
  color: var(--mp-blue);
  cursor: pointer;
}

/* === 用户横幅 === */
.mp-banner {
  margin: 0;
  padding: 20px 16px;
  border-radius: 0;
  background: linear-gradient(135deg, var(--mp-blue) 0%, var(--mp-blue-light) 100%);
  color: #fff;
  display: flex; align-items: center; gap: 14px;
  box-shadow: none;
}
.mp-banner-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.30);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.mp-banner-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #fff; }
.mp-banner-info { flex: 1; min-width: 0; }
.mp-banner-name { font-size: 18px; font-weight: 600; }
.mp-banner-sub { font-size: 13px; opacity: .85; margin-top: 2px; }

/* === 公告横幅 === */
.mp-notice {
  margin: 0;
  padding: 10px 16px;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--mp-border);
  border-radius: 0;
  font-size: 13px;
  color: var(--mp-text-2);
  display: flex; align-items: center; gap: 8px;
}
.mp-notice-icon { font-size: 15px; }

/* === 功能宫格 === */
.mp-grid {
  margin: 0;
  padding: 6px 16px 12px;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.mp-grid-item {
  min-height: 98px;
  padding: 16px 8px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0;
  background: #fff;
  border-radius: var(--mp-radius);
  box-shadow: var(--mp-shadow);
  transition: transform .15s cubic-bezier(.2,0,0,1), box-shadow .15s cubic-bezier(.2,0,0,1);
}
.mp-grid-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,.09); }
.mp-grid-item:active { transform: scale(.96); }
.mp-grid-item:focus-visible { outline: 3px solid rgba(43,108,176,.28); outline-offset: 2px; }
.mp-grid-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 8px;
}
.mp-grid-label { font-size: 13px; color: var(--mp-text); text-align: center; line-height: 1.35; }

/* === 卡片 === */
.mp-card {
  margin: 0 12px 12px; padding: 16px;
  background: #fff; border-radius: var(--mp-radius);
  box-shadow: var(--mp-shadow);
}
.mp-card-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.mp-card-title .more { font-size: 12px; color: var(--text-light); font-weight: 400; }

.mp-section-title {
  padding: 12px 16px 6px;
  color: var(--mp-text-3);
  font-size: 13px;
  font-weight: 500;
}

.mp-card-list {
  margin: 0 12px 12px;
  overflow: hidden;
  border-radius: var(--mp-radius);
  background: #fff;
  box-shadow: var(--mp-shadow);
}

/* === 列表项 === */
.mp-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--mp-border);
}
.mp-list-item:last-child { border-bottom: none; }
.mp-list-thumb {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
}
.mp-list-body { flex: 1; min-width: 0; }
.mp-list-info { flex: 1; min-width: 0; }
.mp-list-title { font-size: 14px; font-weight: 500; }
.mp-list-sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.mp-list-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.mp-list-arrow { color: var(--mp-text-3); font-size: 14px; }

/* === 底部 Tab === */
.mp-tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  width: min(100%, 430px);
  transform: translateX(-50%);
  height: calc(var(--mp-tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #fff;
  border-top: 1px solid var(--mp-border);
  display: flex; z-index: 200;
}
.mp-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--mp-text-3); font-size: 10px;
  transition: color .2s cubic-bezier(.2,0,0,1);
}
.mp-tab-icon { font-size: 22px; line-height: 1; }
.mp-tab.active { color: var(--mp-primary); font-weight: 500; }
.mp-tab:hover { color: var(--mp-blue); }
.mp-tab:focus-visible { outline: 3px solid rgba(43,108,176,.28); outline-offset: -3px; }

/* === 按钮 === */
.mp-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer; transition: all .2s;
  background: var(--primary); color: #fff;
}
.mp-btn-primary {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: var(--mp-radius);
  background: var(--mp-primary);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s cubic-bezier(.2,0,0,1), transform .12s cubic-bezier(.2,0,0,1);
}
.mp-btn-primary:hover { background: var(--mp-primary-dark); }
.mp-btn-primary:active { transform: translateY(1px); }
.mp-btn-sm {
  padding: 7px 14px;
  border: 0;
  border-radius: 20px;
  background: var(--mp-primary);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.mp-btn:hover { filter: brightness(.96); }
.mp-btn:active { transform: scale(.97); }
.mp-btn:focus-visible, .mp-btn-primary:focus-visible, .mp-btn-outline:focus-visible {
  outline: 3px solid rgba(43,108,176,.28);
  outline-offset: 2px;
}
.mp-btn:disabled, .mp-btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.mp-btn-block { display: flex; width: 100%; }
.mp-btn-lg { padding: 14px 24px; font-size: 16px; }
.mp-btn-success { background: var(--success); }
.mp-btn-warning { background: var(--warning); }
.mp-btn-danger { background: var(--danger); }
.mp-btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* === 表单 === */
.mp-form-group { margin-bottom: 14px; }
.mp-form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-light); }
.mp-input, .mp-textarea, .mp-select {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--mp-border); border-radius: var(--mp-radius-sm);
  font-size: 15px; background: #f9f9f9;
  -webkit-appearance: none; outline: none;
}
.mp-input:focus, .mp-textarea:focus, .mp-select:focus {
  border-color: var(--mp-blue-light);
  background: #fff;
}
.mp-textarea { min-height: 80px; resize: vertical; }

/* === 徽标 === */
.mp-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
}
.mp-badge-success { background: #c6f6d5; color: #22543d; }
.mp-badge-warning { background: #fef3c7; color: #92400e; }
.mp-badge-danger  { background: #fed7d7; color: #742a2a; }
.mp-badge-info    { background: #bee3f8; color: #1a365d; }
.mp-badge-primary { background: #ebf4ff; color: #1a4f8a; }

/* === 模态弹窗 === */
.mp-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 1000;
}
.mp-modal {
  background: #fff; width: 100%; max-width: 430px;
  border-radius: 20px 20px 0 0; max-height: 90vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.mp-modal-header {
  padding: 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.mp-modal-header span { font-size: 16px; font-weight: 600; }
.mp-modal-close { background: none; border: none; font-size: 20px; color: var(--text-light); cursor: pointer; }
.mp-modal-body { padding: 16px; }
.mp-modal-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

.mp-hidden { display: none !important; }
.hidden { display: none !important; }

.mp-empty-action {
  display: inline-flex;
  margin-top: 14px;
  padding: 8px 18px;
  border-radius: 20px;
  background: var(--mp-blue);
  color: #fff;
}

.mp-record-note {
  margin: 0 12px 12px;
  padding: 12px 14px;
  border-radius: var(--mp-radius-sm);
  background: #fff;
  color: var(--mp-text-2);
  font-size: 12px;
  box-shadow: var(--mp-shadow);
}

.mp-record-link {
  margin: 10px 12px 12px;
  padding: 11px 14px;
  border-radius: var(--mp-radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  color: var(--mp-blue);
  box-shadow: var(--mp-shadow);
}
.mp-record-link:hover { background: #f8fbff; }
.mp-record-link:focus-visible { outline: 3px solid rgba(43,108,176,.28); outline-offset: 2px; }

.mp-record-fab {
  position: fixed;
  right: max(18px, calc((100vw - 430px) / 2 + 18px));
  bottom: calc(var(--mp-tabbar-h) + 18px);
  width: 48px; height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--mp-primary);
  color: #fff;
  font-size: 24px;
  box-shadow: 0 6px 18px rgba(7,193,96,.30);
  cursor: pointer;
  z-index: 150;
}
.mp-record-fab:hover { background: var(--mp-primary-dark); }
.mp-record-fab:focus-visible { outline: 3px solid rgba(7,193,96,.28); outline-offset: 3px; }

/* === 状态卡（音乐/康复动作居家疗法） === */
.mp-state-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: var(--radius); background: #f8fafc;
  margin-bottom: 10px;
}
.mp-state-thumb {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}

/* === 量表选项 === */
.mp-scale-q { background: #f8fafc; border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; }
.mp-scale-q p { font-weight: 500; margin-bottom: 8px; }
.mp-opt { display: block; padding: 8px 12px; margin-bottom: 6px; border-radius: 6px; cursor: pointer; transition: all .15s; }
.mp-opt:hover, .mp-opt:active { background: #ebf4ff; }
.mp-opt input { margin-right: 8px; }

/* === 空状态 === */
.mp-empty { text-align: center; padding: 40px 20px; color: var(--text-light); }
.mp-empty-icon { font-size: 48px; opacity: .5; margin-bottom: 12px; }

/* === 大屏自适应 === */
@media (min-width: 600px) {
  body { background: #f7f7f7; }
}

@media (max-width: 360px) {
  .mp-navbar-title { font-size: 15px; }
  .mp-grid { padding-inline: 12px; gap: 10px; }
  .mp-grid-item { min-height: 92px; padding-inline: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
