/* =========================================================
 * components.css — 全局组件库（第 2.4 章）
 * 导航栏 / 列表行 / 按钮 / 开关 / 滑块 / 弹窗 / 操作表 /
 * 吐司 / 键盘 / Tab 栏 / 分段控件 / 滚轮选择器
 * ========================================================= */

/* ---------------------------------------------------------
 * 2.4.1 导航栏  高度 44pt（不含状态栏）
 * ------------------------------------------------------- */
.navbar {
  flex: none;
  background: var(--bg);
  position: relative;
  z-index: 5;
}
.navbar.navbar-dark { background: #1c1c1e; color: #fff; }
.navbar.navbar-clear { background: transparent; }
.navbar::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0;
  height: .5px; background: var(--sep);
}
.navbar.navbar-clear::after { display: none; }
.nav-bar {
  height: var(--nav-h);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-title {
  font-size: 17px;
  font-weight: 600;
  max-width: 200px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-sub { font-size: 11px; color: var(--text2); text-align: center; margin-top: -1px; }
.nav-left {
  position: absolute; left: 8px; bottom: 0; height: var(--nav-h);
  display: flex; align-items: center; gap: 2px;
  max-width: 130px;
}
.nav-right {
  position: absolute; right: 10px; bottom: 0; height: var(--nav-h);
  display: flex; align-items: center; gap: 16px;
}
.nav-act { color: var(--blue); display: flex; align-items: center; justify-content: center; }
.nav-act:active { opacity: .45; }
.nav-back {
  display: flex; align-items: center;
  color: var(--blue); font-size: 17px;
  margin-left: -4px;
}
.nav-back span { font-size: 17px; }
.nav-back:active { opacity: .4; }

/* ---------------------------------------------------------
 * 2.4.2 列表行
 * ------------------------------------------------------- */
.list {
  background: var(--card);
  border-radius: var(--r-card);
  margin: 0 16px 22px;
  overflow: hidden;
}
.list.plain { margin: 0; border-radius: 0; }
.list-title {
  font-size: 13px;
  color: var(--text2);
  padding: 6px 16px 7px;
  text-transform: none;
}
.row {
  display: flex;
  align-items: center;
  padding: 0 16px;
  min-height: 44px;
  position: relative;
  background: var(--card);
  transition: background 120ms linear;
}
.row.tall { min-height: 56px; }
.row.big { min-height: 72px; }
.row::after {
  content: '';
  position: absolute; left: 16px; right: 0; bottom: 0;
  height: .5px; background: var(--sep);
}
.row:last-child::after { display: none; }
.row.tap:active { background: rgba(0,0,0,.06); }
html.dark .row.tap:active { background: rgba(255,255,255,.08); }
.row-ava { margin-right: 12px; display: flex; }
.row-ico {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-right: 12px; color: #fff; flex: none;
  background: var(--blue);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 17px; display: flex; align-items: center; gap: 6px; }
.row-sub { font-size: 15px; color: var(--text2); margin-top: 2px; }
.row-right {
  display: flex; align-items: center; gap: 8px;
  color: var(--text2); flex: none; margin-left: 8px;
}
.row-value { font-size: 17px; color: var(--text2); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-arrow { color: var(--text3); display: flex; }
.row-badge {
  background: var(--red); color: #fff; font-size: 11px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}
.row-danger .row-title { color: var(--red); }

/* 头像 */
.ava {
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; letter-spacing: 0;
  overflow: hidden; flex: none; position: relative;
  text-shadow: 0 1px 2px rgba(0,0,0,.15);
}
/* 真实图片头像（img/avatars/） */
.ava-img {
  object-fit: cover; display: inline-flex; flex: none;
  -webkit-user-drag: none; user-select: none;
}

/* ---------------------------------------------------------
 * 2.4.3 按钮
 * ------------------------------------------------------- */
.btn {
  height: 44px; border-radius: var(--r-btn);
  font-size: 17px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  transition: filter 120ms linear, transform 120ms var(--ease), opacity 120ms linear;
}
.btn:active { filter: brightness(.9); transform: scale(.985); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-wx { background: var(--wx); color: #fff; }
.btn-shop { background: var(--shop); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-gray { background: var(--group); color: #000; }
html.dark .btn-gray { color: #fff; background: #2c2c2e; }
.btn-outline { background: transparent; color: var(--blue); border: 1px solid rgba(0,122,255,.4); }
.btn-outline-red { background: #fff; color: var(--red); border: 1px solid rgba(255,59,48,.5); }
.btn-dark { background: #1c1c1e; color: #fff; }
.btn[disabled], .btn.disabled { opacity: .4; pointer-events: none; }
.btn-sm { height: 34px; border-radius: 10px; font-size: 15px; padding: 0 14px; width: auto; }
.btn-round { width: 44px; height: 44px; border-radius: 22px; padding: 0; }
.btn-inline { display: inline-flex; width: auto; padding: 0 18px; }
.btn-text { background: none; color: var(--blue); font-size: 17px; font-weight: 400; height: auto; }
.btn-text.danger { color: var(--red); }
.btn-block-wrap { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }

/* ---------------------------------------------------------
 * 2.4.4 开关   51×31，滑块 27
 * ------------------------------------------------------- */
.switch {
  width: 51px; height: 31px; border-radius: 16px;
  background: #E9E9EA; position: relative; flex: none;
  transition: background 200ms var(--ease);
  display: inline-block;
}
html.dark .switch { background: #39393C; }
.switch i {
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.22);
  transition: transform 200ms var(--ease);
}
.switch.on { background: var(--green); }
.switch.on i { transform: translateX(20px); }
.switch.disabled { opacity: .5; }
.switch.blue.on { background: var(--blue); }
.switch.orange.on { background: var(--orange); }

/* ---------------------------------------------------------
 * 2.4.5 滑块   轨道 4pt，滑块 28pt
 * ------------------------------------------------------- */
.slider {
  position: relative; height: 44px; display: flex; align-items: center; gap: 10px;
  touch-action: none; cursor: pointer;
}
.slider-track {
  flex: 1; height: 6px; border-radius: 3px; background: rgba(120,120,128,.24);
  position: relative; overflow: visible;
}
.slider-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 3px; background: #fff; width: 50%;
}
.slider.light > .slider-track > .slider-fill { background: #1c1c1e; }
.slider-thumb {
  position: absolute; top: 50%; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25);
  transform: translate(-50%, -50%); left: 50%;
}
.slider-side { display: flex; align-items: center; color: var(--text2); flex: none; }

/* ---------------------------------------------------------
 * 2.4.6 弹窗 Alert  宽 270，圆角 14
 * ------------------------------------------------------- */
.alert {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: 270px; border-radius: var(--r-alert);
  background: rgba(250,250,250,.94);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  overflow: hidden; text-align: center; color: #000;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  animation: alertIn 260ms var(--ease);
}
@keyframes alertIn {
  from { transform: translate(-50%,-50%) scale(1.15); opacity: 0; }
  to { transform: translate(-50%,-50%) scale(1); opacity: 1; }
}
.alert-icon { padding: 20px 0 0; display: flex; justify-content: center; color: var(--blue); }
.alert-title { font-size: 17px; font-weight: 600; padding: 19px 16px 4px; }
.alert-msg { font-size: 13px; color: #000; opacity: .85; padding: 0 16px 20px; line-height: 1.45; }
.alert-actions { display: flex; border-top: .5px solid rgba(0,0,0,.18); }
.alert-actions.vertical { flex-direction: column; }
.alert-btn {
  flex: 1; height: 44px; font-size: 17px; color: #007AFF; background: none;
  border-right: .5px solid rgba(0,0,0,.18);
}
.alert-actions.vertical .alert-btn { border-right: none; border-bottom: .5px solid rgba(0,0,0,.18); width: 100%; }
.alert-btn:last-child { border-right: none; }
.alert-btn:active { background: rgba(0,0,0,.06); }
.alert-btn.cancel { font-weight: 600; }
.alert-btn.danger { color: var(--red); }

/* ---------------------------------------------------------
 * 2.4.7 操作表 ActionSheet
 * ------------------------------------------------------- */
.sheet-container {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 8px 8px;
  animation: sheetUp 380ms var(--ease);
}
@keyframes sheetUp { from { transform: translateY(110%); } to { transform: translateY(0); } }
.sheet { border-radius: 13px; overflow: hidden; background: rgba(250,250,250,.94); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.sheet-wrap { border-radius: 13px; overflow: hidden; }
.sheet-cancel-wrap { margin-top: 8px; }
.sheet-head { padding: 14px 16px 12px; text-align: center; border-bottom: .5px solid rgba(0,0,0,.12); }
.sheet-title { font-size: 13px; color: #000; font-weight: 600; }
.sheet-msg { font-size: 13px; color: #555; margin-top: 3px; }
.sheet-item {
  width: 100%; height: 57px; font-size: 17px; color: #007AFF;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-bottom: .5px solid rgba(0,0,0,.12);
}
.sheet-item:last-child { border-bottom: none; }
.sheet-item:active { background: rgba(0,0,0,.06); }
.sheet-item.danger { color: var(--red); }
.sheet-item.cancel { font-weight: 600; color: #007AFF; }
.sheet-ico { display: flex; align-items: center; color: #333; margin-right: 4px; }

/* ---------------------------------------------------------
 * 2.4.8 吐司 Toast
 * ------------------------------------------------------- */
.toast {
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 14px; padding: 10px 18px; border-radius: 20px;
  max-width: 260px; text-align: center; line-height: 1.4;
  animation: toastIn 220ms var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.loading-box {
  background: rgba(0,0,0,.72); border-radius: 14px;
  padding: 20px 24px; min-width: 120px; text-align: center; color: #fff;
}
.loading-text { font-size: 13px; margin-top: 10px; opacity: .9; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto;
  border: 2.5px solid rgba(255,255,255,.25);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------
 * 底部面板 Panel（模态页面）
 * ------------------------------------------------------- */
.panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--card); border-radius: 16px 16px 0 0;
  max-height: 76%; display: flex; flex-direction: column;
  animation: sheetUp 400ms var(--ease);
  color: var(--text);
  box-shadow: 0 -8px 30px rgba(0,0,0,.18);
}
html.dark .panel { background: #1c1c1e; }
.panel-head {
  height: 48px; display: flex; align-items: center; justify-content: center;
  position: relative; flex: none; border-bottom: .5px solid var(--sep);
}
.panel-title { font-size: 15px; font-weight: 600; }
.panel-close { position: absolute; right: 14px; color: var(--text2); display: flex; }
.panel-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.panel-body::-webkit-scrollbar { width: 0; }
.panel-footer { flex: none; padding: 10px 16px calc(12px + 8px); border-top: .5px solid var(--sep); }

/* ---------------------------------------------------------
 * 数字键盘
 * ------------------------------------------------------- */
.keypad {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(230,232,236,.96); backdrop-filter: blur(14px);
  animation: sheetUp 400ms var(--ease);
  padding-bottom: 6px;
}
.kp-head { position: relative; text-align: center; padding: 10px 0 12px; }
.kp-close { position: absolute; left: 16px; top: 12px; color: #333; }
.kp-title { font-size: 17px; font-weight: 600; color: #000; }
.kp-sub { font-size: 13px; color: #555; margin-top: 3px; }
.kp-sub .big { font-size: 26px; font-weight: 700; color: #000; }
.kp-dots { display: flex; justify-content: center; gap: 14px; margin: 16px 0 6px; }
.kp-dots i {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 1px solid rgba(0,0,0,.2);
  transition: background 100ms linear;
}
.kp-dots i.on { background: #333; }
.kp-dots.err { animation: shake 420ms var(--ease); }
.kp-dots.err i { background: var(--red); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}
.kp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; padding: 4px 12px 12px; }
.kp-cell {
  height: 48px; border-radius: 8px; background: #fff; color: #000;
  font-size: 24px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.kp-cell:active { background: #d4d6da; }
.kp-cell.empty { background: transparent; box-shadow: none; }
.kp-cell.func { background: rgba(255,255,255,.5); font-size: 15px; gap: 2px; }

/* ---------------------------------------------------------
 * 2.4.10 Tab 栏   49pt + 34pt 安全区
 * ------------------------------------------------------- */
.tabbar {
  flex: none;
  background: rgba(250,250,250,.94);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: .5px solid var(--sep);
  display: flex;
  padding-bottom: 0;
  position: relative;
  z-index: 4;
}
html.dark .tabbar { background: rgba(28,28,30,.94); }
.tabbar.hairless { border-top: none; }
.tab-item {
  flex: 1; height: var(--tab-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text2); font-size: 10px;
}
.tab-item.active { color: var(--blue); }
.tab-ico { position: relative; display: flex; align-items: center; justify-content: center; height: 28px; }
.tab-label { font-size: 10px; line-height: 1; }
.tab-badge {
  position: absolute; top: -3px; right: -10px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--red); color: #fff;
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.tab-badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: -1px; right: -5px; }
/* Tab 栏上方内容区 */
.tab-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* ---------------------------------------------------------
 * 2.4.11 分段控件
 * ------------------------------------------------------- */
.seg {
  display: inline-flex; background: rgba(118,118,128,.12);
  border-radius: 9px; padding: 2px; gap: 2px;
}
html.dark .seg { background: rgba(118,118,128,.24); }
.seg-item {
  padding: 0 14px; height: 30px; border-radius: 7px;
  font-size: 13px; color: var(--text); flex: 1;
  display: flex; align-items: center; justify-content: center;
  white-space: nowrap;
  transition: background 200ms var(--ease), box-shadow 200ms var(--ease);
}
.seg-item.active {
  background: var(--card); box-shadow: 0 2px 6px rgba(0,0,0,.14); font-weight: 600;
}
html.dark .seg-item.active { background: #636366; color: #fff; }
.seg.full { display: flex; width: 100%; }

/* ---------------------------------------------------------
 * 2.4.12 滚轮选择器
 * ------------------------------------------------------- */
.picker {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--card); border-radius: 14px 14px 0 0;
  animation: sheetUp 400ms var(--ease); color: var(--text);
  padding-bottom: 8px;
}
html.dark .picker { background: #1c1c1e; }
.pk-head {
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-bottom: .5px solid var(--sep);
}
.pk-title { font-size: 15px; font-weight: 600; }
.pk-btn { font-size: 16px; color: var(--blue); }
.pk-btn.done { font-weight: 600; }
.pk-mask {
  position: absolute; left: 0; right: 0;
  top: 96px; height: 40px;
  background: rgba(120,120,128,.12); border-radius: 8px;
  pointer-events: none;
}
.pk-cols { display: flex; height: 180px; padding: 0 8px; }
.pk-col { flex: 1; overflow: hidden; }
.pk-scroll { height: 100%; overflow-y: scroll; scrollbar-width: none; }
.pk-scroll::-webkit-scrollbar { width: 0; }
.pk-pad { height: 56px; }
.pk-item {
  height: 40px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--text2); transition: color 160ms linear, transform 160ms var(--ease);
}
.pk-item.sel { color: var(--text); font-weight: 600; transform: scale(1.06); }

/* ---------------------------------------------------------
 * 空态 / 搜索框 / 步进器 / 标签 / 进度
 * ------------------------------------------------------- */
.empty-state {
  padding: 90px 30px; text-align: center; color: var(--text2);
}
.empty-ico { display: flex; justify-content: center; color: var(--text3); margin-bottom: 12px; }
.empty-text { font-size: 15px; }

.search-field {
  height: 36px; border-radius: var(--r-input);
  background: rgba(118,118,128,.12);
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px; color: var(--text2); flex: 1;
}
.search-field input { flex: 1; font-size: 17px; color: var(--text); background: none; border: none; }
.search-field input::placeholder { color: var(--text2); }
html.dark .search-field input::placeholder { color: #98989f; }

.search-input-big {
  height: 40px; border-radius: var(--r-input);
  background: rgba(118,118,128,.12); border: none;
  padding: 0 12px; font-size: 17px; color: var(--text); width: 100%;
}

.stepper { display: flex; align-items: center; gap: 0; border: .5px solid var(--sep); border-radius: 8px; overflow: hidden; }
.stepper button { width: 32px; height: 28px; color: var(--text); font-size: 17px; display: flex; align-items: center; justify-content: center; }
.stepper button:active { background: rgba(0,0,0,.06); }
.stepper .sv {
  min-width: 34px; text-align: center; font-size: 15px;
  border-left: .5px solid var(--sep); border-right: .5px solid var(--sep);
  height: 28px; line-height: 28px; font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: var(--r-tag);
  font-size: 12px; background: rgba(118,118,128,.14); color: var(--text2);
}
.tag.orange { background: rgba(255,106,0,.12); color: var(--shop); }
.tag.red { background: rgba(255,59,48,.12); color: var(--red); }
.tag.green { background: rgba(7,193,96,.12); color: var(--wx); }
.tag.blue { background: rgba(0,122,255,.12); color: var(--blue); }
.tag.solid-red { background: var(--red); color: #fff; }
.tag.solid-orange { background: var(--shop); color: #fff; }
.tag.selectable.active { background: rgba(255,106,0,.1); color: var(--shop); box-shadow: inset 0 0 0 1px var(--shop); }
.tag.selectable.disabled { opacity: .35; }

.progress { height: 4px; border-radius: 2px; background: rgba(120,120,128,.2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--blue); border-radius: 2px; transition: width 200ms linear; }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--r-card);
  margin: 0 16px 12px; padding: 14px;
  box-shadow: var(--shadow-card);
}
.card.flat { box-shadow: none; background: var(--card); }

/* 缩略图 / 占位图 */
.thumb {
  display: block; position: relative; overflow: hidden;
  width: 100%; height: 100%;
  background-size: cover;
}
.thumb .thumb-glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 50% at 30% 25%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(50% 40% at 80% 85%, rgba(0,0,0,.14), transparent 60%);
}
.thumb .thumb-t {
  position: absolute; left: 0; right: 0; bottom: 6px;
  text-align: center; font-size: 11px; color: rgba(255,255,255,.85);
  text-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.img-wrap { overflow: hidden; position: relative; background: var(--group); }
.img-wrap.round8 { border-radius: 8px; }
.img-wrap.round12 { border-radius: var(--r-btn); }
.sq { position: relative; width: 100%; padding-top: 100%; }
.sq > * { position: absolute; inset: 0; }

/* 星级 */
.stars { display: inline-flex; gap: 2px; color: var(--orange); }

/* 分隔标题 */
.section-title {
  font-size: 22px; font-weight: 700; padding: 0 16px 8px; color: var(--text);
}
.section-sub { font-size: 13px; color: var(--text2); padding: 0 16px 10px; }

/* 底部安全操作条（商城等） */
.bottom-bar {
  flex: none;
  border-top: .5px solid var(--sep);
  background: rgba(250,250,250,.94);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 8px 12px calc(8px);
  display: flex; align-items: center; gap: 10px;
}
html.dark .bottom-bar { background: rgba(28,28,30,.94); }

/* 全屏滚动容器 */
.full-scroll { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.full-scroll::-webkit-scrollbar { width: 0; }
