/* ============================================================
 * 勤小二 · 智慧养老服务平台
 * base.css — 设计系统 / 基础重置 / 通用组件
 * ============================================================ */

/* ---------- 设计变量 ---------- */
:root {
  /* 品牌主色 · 暖橙（关怀 · 活力） */
  --primary: #FF7043;
  --primary-deep: #F4511E;
  --primary-soft: #FFEDE4;
  --primary-grad: linear-gradient(135deg, #FF9A6C 0%, #FF6B35 100%);
  --primary-grad-deep: linear-gradient(135deg, #FF7A45 0%, #F4511E 100%);

  /* 品牌辅色 · 青绿（专业 · 信赖） */
  --teal: #0E9F8A;
  --teal-soft: #E3F7F2;
  --teal-grad: linear-gradient(135deg, #34C6B0 0%, #0E9F8A 100%);

  /* 补充色 */
  --blue: #3E7BFA;
  --blue-soft: #E8F0FF;
  --purple: #8B6CF0;
  --purple-soft: #F0EBFF;
  --gold: #F5A623;
  --gold-soft: #FFF3DC;

  /* 中性色 */
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --ink: #1F2937;
  --ink-2: #5A6472;
  --ink-3: #98A1AE;
  --line: #EEF0F3;
  --line-2: #E3E6EB;

  /* 功能色 */
  --success: #16B979;
  --warning: #F5A623;
  --danger: #F05252;
  --info: #3E7BFA;

  /* 圆角 */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* 阴影 */
  --sh-1: 0 2px 12px rgba(31, 41, 55, 0.05);
  --sh-2: 0 6px 22px rgba(31, 41, 55, 0.08);
  --sh-brand: 0 8px 22px rgba(255, 112, 67, 0.28);
  --sh-teal: 0 8px 22px rgba(14, 159, 138, 0.24);

  /* 尺寸 */
  --nav-h: 46px;
  --tab-h: 58px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ---------- 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: #E9ECF1;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; border: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, h5, p { margin: 0; }
svg { display: block; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ---------- 应用外壳 ---------- */
.app-shell {
  position: relative;
  width: 100%;
  max-width: 440px;
  /* 固定视口高度，让中间 view-container 成为唯一滚动容器；
     否则服务页左右分栏的 height:100% 链路失效，分类栏会随整页滚走 */
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 480px) {
  .app-shell {
    height: calc(100vh - 32px);
    min-height: 640px;
    max-height: 900px;
    margin: 16px auto;
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(31, 41, 55, 0.18);
  }
}

/* ---------- 顶部导航栏 ---------- */
.nav-bar {
  position: relative;
  z-index: 50;
  flex: 0 0 auto;
  height: calc(var(--nav-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  padding-right: 8px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.nav-bar.is-transparent {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: transparent;
  border-bottom: 0;
}
.nav-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  flex: 0 0 auto;
  transition: background .15s;
}
.nav-btn:active { background: rgba(0,0,0,.06); }
.nav-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.nav-title.sub { font-size: 15px; }
.nav-bar.is-transparent .nav-title,
.nav-bar.is-transparent .nav-btn { color: #fff; }
.nav-bar.is-light .nav-title, .nav-bar.is-light .nav-btn { color: #fff; }

/* ---------- 视图容器 ---------- */
.view-container {
  flex: 1 1 auto;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.page-view {
  min-height: 100%;
  animation: page-in .26s ease;
}
/* 固定高度页（如服务分类左右分栏），撑满视图容器以启用内部滚动 */
.page-view.is-fixed { height: 100%; display: flex; flex-direction: column; }
.page-view.is-fixed > .services-page { flex: 1 1 auto; min-height: 0; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-loading {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; color: var(--ink-3);
}
.loading-spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 底部标签栏 ---------- */
.tab-bar {
  position: relative;
  z-index: 50;
  flex: 0 0 auto;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 16px rgba(31,41,55,.04);
}
.tab-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  color: var(--ink-3);
  font-size: 10px;
  transition: color .15s;
  position: relative;
}
.tab-item .tab-ico { width: 24px; height: 24px; }
.tab-item.active { color: var(--primary); font-weight: 600; }
.tab-item.active .tab-ico { transform: translateY(-1px); }
.tab-badge {
  position: absolute; top: 4px; right: calc(50% - 20px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff;
  font-size: 10px; line-height: 16px; text-align: center;
  border-radius: var(--r-pill);
}

/* ---------- 通用布局 ---------- */
.pad { padding-left: 16px; padding-right: 16px; }
.pt16 { padding-top: 16px; }
.pb16 { padding-bottom: 16px; }
.pb-tab { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 16px); }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.center { display: flex; align-items: center; justify-content: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap12 { gap: 12px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.muted { color: var(--ink-3); }
.f12 { font-size: 12px; } .f13 { font-size: 13px; } .f16 { font-size: 16px; }
.bold { font-weight: 600; }
.ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.text-primary { color: var(--primary); }
.text-teal { color: var(--teal); }
.text-danger { color: var(--danger); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
}
.card-pad { padding: 14px; }
.section { margin: 12px 16px; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 16px 10px;
}
.section-title h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.section-title h3::before {
  content: ''; width: 4px; height: 15px; border-radius: 2px;
  background: var(--primary-grad-deep);
}
.section-more { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 2px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 20px;
  border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600;
  transition: transform .12s, opacity .12s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); opacity: .9; }
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: var(--sh-brand); }
.btn-teal { background: var(--teal-grad); color: #fff; box-shadow: var(--sh-teal); }
.btn-ghost { background: var(--primary-soft); color: var(--primary-deep); }
.btn-outline { background: #fff; color: var(--ink-2); border: 1px solid var(--line-2); }
.btn-sm { height: 32px; padding: 0 14px; font-size: 12px; }
.btn-lg { height: 48px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; box-shadow: none; cursor: not-allowed; }

/* ---------- 标签 / 徽章 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  height: 22px; padding: 0 8px;
  border-radius: var(--r-xs);
  font-size: 11px; font-weight: 500;
}
.tag-orange { background: var(--primary-soft); color: var(--primary-deep); }
.tag-teal { background: var(--teal-soft); color: var(--teal); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }
.tag-gold { background: var(--gold-soft); color: #C77C05; }
.tag-gray { background: #F1F3F5; color: var(--ink-2); }
.tag-outline { background: transparent; border: 1px solid var(--line-2); color: var(--ink-2); }

/* ---------- 头像 ---------- */
.avatar {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 50%; object-fit: cover;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.avatar-lg { width: 60px; height: 60px; }
.avatar-sm { width: 34px; height: 34px; }

/* ---------- 列表项 ---------- */
.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  position: relative;
}
.list-item + .list-item::before {
  content: ''; position: absolute; top: 0; left: 62px; right: 14px;
  height: 1px; background: var(--line);
}
.arrow-r { width: 16px; height: 16px; color: var(--ink-3); flex: 0 0 auto; }

/* ---------- 分割线 ---------- */
.divider { height: 1px; background: var(--line); margin: 12px 0; }

/* ---------- 搜索框 ---------- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px;
  background: #fff; border-radius: var(--r-pill);
  color: var(--ink-3);
}
.search-box input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 13px; color: var(--ink);
}
.search-box input::placeholder { color: var(--ink-3); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.field-label .req { color: var(--danger); margin-left: 2px; }
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line-2);
  background: #fff;
  border-radius: var(--r-sm);
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { min-height: 92px; resize: none; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2398A1AE' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.field-hint { font-size: 11px; color: var(--ink-3); margin-top: 6px; }

/* 单选 / 复选胶囊 */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px; border-radius: var(--r-pill);
  background: #fff; border: 1px solid var(--line-2);
  font-size: 13px; color: var(--ink-2);
  transition: all .15s;
}
.chip.active {
  background: var(--primary-soft); border-color: var(--primary);
  color: var(--primary-deep); font-weight: 600;
}

/* 上传框 */
.upload-box {
  width: 82px; height: 82px;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-sm);
  background: #FAFBFC;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--ink-3); font-size: 11px;
  overflow: hidden; position: relative;
}
.upload-box .uploaded-img { width: 100%; height: 100%; object-fit: cover; }
.upload-remove {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
}

/* 开关 */
.switch {
  width: 46px; height: 26px; border-radius: var(--r-pill);
  background: var(--line-2); position: relative; transition: background .2s;
  flex: 0 0 auto;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s;
}
.switch.on { background: var(--success); }
.switch.on::after { transform: translateX(20px); }

/* ---------- 步骤条 ---------- */
.steps { display: flex; align-items: center; padding: 4px 0; }
.step { display: flex; align-items: center; flex: 1; }
.step:last-child { flex: 0; }
.step-dot {
  width: 24px; height: 24px; flex: 0 0 auto;
  border-radius: 50%; background: var(--line-2); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  transition: all .2s;
}
.step.done .step-dot { background: var(--success); }
.step.active .step-dot { background: var(--primary-grad); box-shadow: var(--sh-brand); }
.step-line { flex: 1; height: 2px; background: var(--line-2); margin: 0 4px; }
.step.done .step-line { background: var(--success); }
.step-label { font-size: 10px; color: var(--ink-3); margin-top: 5px; text-align: center; }
.step.active .step-label, .step.done .step-label { color: var(--ink-2); font-weight: 600; }
.step-item { display: flex; flex-direction: column; align-items: center; min-width: 44px; }

/* ---------- Tab 切换 ---------- */
.tabs {
  display: flex; gap: 20px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: #fff;
  position: sticky; top: 0; z-index: 20;
}
.tab {
  position: relative; padding: 12px 0;
  font-size: 14px; color: var(--ink-2); white-space: nowrap;
}
.tab.active { color: var(--primary); font-weight: 700; }
.tab.active::after {
  content: ''; position: absolute; left: 50%; bottom: 5px;
  transform: translateX(-50%);
  width: 20px; height: 3px; border-radius: 2px; background: var(--primary);
}

/* ---------- 进度条 ---------- */
.progress { height: 6px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--r-pill); background: var(--primary-grad); transition: width .4s ease; }

/* ---------- 空状态 ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--ink-3); gap: 12px; }
.empty-ico { width: 72px; height: 72px; opacity: .5; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; z-index: 9999; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r-sm);
  background: rgba(31,41,55,.92); color: #fff;
  font-size: 13px; box-shadow: var(--sh-2);
  animation: toast-in .25s ease;
  max-width: 300px;
}
@keyframes toast-in { from { opacity: 0; transform: scale(.9) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.toast.out { animation: toast-out .25s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: scale(.92); } }

/* ---------- 弹窗 Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 9000; pointer-events: none; }
.modal-mask {
  position: absolute; inset: 0; background: rgba(15,23,42,.5);
  opacity: 0; transition: opacity .2s; pointer-events: auto;
  display: flex; align-items: center; justify-content: center; padding: 30px;
}
.modal-mask.show { opacity: 1; }
.modal-box {
  width: 100%; max-width: 340px; background: #fff;
  border-radius: var(--r-lg); padding: 22px 20px 18px;
  transform: scale(.92); transition: transform .22s;
  box-shadow: var(--sh-2); pointer-events: auto;
}
.modal-mask.show .modal-box { transform: scale(1); }
.modal-title { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.modal-body { font-size: 14px; color: var(--ink-2); text-align: center; line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ---------- 底部抽屉 Sheet ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 9100; pointer-events: none; }
.sheet-mask {
  position: absolute; inset: 0; background: rgba(15,23,42,.45);
  opacity: 0; transition: opacity .25s; pointer-events: auto;
}
.sheet-mask.show { opacity: 1; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #fff; border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 18px 16px calc(20px + var(--safe-b));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  pointer-events: auto; max-height: 82vh; overflow-y: auto;
}
.sheet-mask.show .sheet-panel { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 0 auto 16px; }
.sheet-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

/* ---------- 数字角标 ---------- */
.dot-badge { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); flex: 0 0 auto; }

/* ---------- 骨架屏动画 ---------- */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton {
  background: linear-gradient(90deg, #F0F2F5 25%, #E8EBEF 50%, #F0F2F5 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px;
}
