/* components.css —— 卡片、徽章、按钮、表单、空状态与骨架屏
   负责人：102401228 林彦翔
   这一版先给出骨架需要的通用类，页面实现时按需补充，不要另起一套命名。 */

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-2);
}

.card.is-closed { opacity: .62; }

.item-card {
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow .18s ease, transform .18s ease;
}
.item-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

.item-thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-2);
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* 没有图片的条目：占位符图标，避免空白卡片看起来像坏掉了 */
.item-thumb:empty::after {
  content: '\1F4F7';
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 20px;
  color: var(--muted-2);
  opacity: .55;
}

.item-main { flex: 1 1 auto; min-width: 0; }
.item-title-row { display: flex; align-items: center; gap: 6px; }
.item-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.item-desc { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block;
  flex: 0 0 auto;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
}

.badge-lost   { background: #EAF0FF; color: var(--brand); }
.badge-found  { background: #E8F7EE; color: var(--ok); }
.badge-active { background: var(--brand-light); color: var(--brand-dark); }
.badge-closed { background: var(--bg-2); color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
}

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: var(--card); color: var(--brand); border-color: var(--brand-line); }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: not-allowed; }

/* ---------- 分段控件 / 筛选条 ---------- */
.seg {
  display: flex;
  gap: 6px;
  padding: 3px;
  background: var(--bg-2);
  border-radius: 999px;
}
.seg > * {
  flex: 1 1 0;
  text-align: center;
  padding: 6px 0;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
}
.seg > .on { background: var(--card); color: var(--brand); font-weight: 600; box-shadow: var(--shadow); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; }
.chip {
  flex: 0 0 auto;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
}
.chip.on { background: var(--brand-light); border-color: var(--brand-line); color: var(--brand-dark); font-weight: 600; }

/* ---------- 搜索框 ---------- */
.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 13px;
  cursor: text;
}
.searchbox input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > .lab {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
}
.field > .lab .req { color: var(--danger); margin-left: 2px; }

.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  outline: 0;
}
.input:focus { border-color: var(--brand-mid); box-shadow: 0 0 0 3px var(--brand-light); }
.input.err { border-color: var(--danger); background: #FFFBFB; }
textarea.input { min-height: 88px; resize: vertical; }
.err-tip { margin-top: 6px; font-size: 12px; color: var(--danger); }

/* ---------- 空状态 / 骨架屏 ---------- */
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .empty-i { font-size: 32px; }
.empty .empty-t { margin-top: 10px; font-size: 14px; color: var(--ink-3); }
.empty .empty-s { margin-top: 4px; font-size: 12px; }
.empty .btn { margin-top: 16px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 25%, #F7F9FC 37%, var(--bg-2) 63%);
  background-size: 400% 100%;
  border-radius: 6px;
  animation: sk 1.2s ease-in-out infinite;
}
.sk-line { height: 12px; margin-bottom: 8px; }
.sk-thumb { width: 72px; height: 72px; flex: 0 0 72px; border-radius: var(--radius-sm); }

@keyframes sk {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* 用户在系统里开了「减弱动态效果」时，停掉骨架屏的流动动画，
   避免对光敏感或容易晕动的人不舒服。 */
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--bg-2); }
  .item-card, .btn { transition: none; }
}

/* ---------- 提示条 / 对话框 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(17, 24, 39, .88);
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  animation: toast-in .18s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, .35);
}
.dlg {
  width: 280px;
  padding: 20px 18px 12px;
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
}
.dlg .dlg-t { font-size: 15px; font-weight: 600; }
.dlg .dlg-s { margin-top: 8px; font-size: 13px; color: var(--ink-3); }
.dlg .acts { display: flex; gap: 10px; margin-top: 18px; }
.dlg .acts > * {
  flex: 1 1 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dlg-cancel { background: var(--bg-2); color: var(--ink-3); }
.dlg-ok { background: var(--brand); color: #fff; font-weight: 600; }

/* ---------- 状态横幅（详情页用） ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 10px;
}
.banner-closed { background: var(--bg-2); color: var(--ink-3); }

/* ---------- 骨架阶段的占位说明（各页面实现后删掉） ---------- */
.stage-note { background: #FFFDF3; border: 1px dashed #E8D48A; }
.stage-note .n-t { font-size: 13px; font-weight: 600; color: #8A6D1F; }
.stage-note .n-s { margin-top: 6px; font-size: 12px; color: #8A6D1F; opacity: .9; }

/* ---------- 详情页 ---------- */
.detail-hero {
  width: 100%;
  height: 190px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
  margin-bottom: 12px;
}
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: var(--muted-2);
}

.detail-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-title { font-size: 19px; font-weight: 600; color: var(--ink); }

.detail-rows { margin-top: 6px; }
.d-row {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.d-row:last-child { border-bottom: 0; }
.d-row .d-k { flex: 0 0 64px; color: var(--muted); }
.d-row .d-v { flex: 1 1 auto; color: var(--ink-2); word-break: break-word; }

.desc-block { margin-top: 6px; font-size: 13px; line-height: 1.75; color: var(--ink-2); word-break: break-word; }

.contact-box { display: flex; align-items: center; gap: 10px; }
.contact-val { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 600; color: var(--ink); word-break: break-all; }
.contact-off { font-size: 13px; color: var(--muted); }

.section-title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

/* 详情页底部主按钮：浮在底部导航之上 */
.action-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--tabbar-h);
  width: 100%;
  max-width: var(--app-w);
  z-index: 25;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line-2);
  backdrop-filter: blur(8px);
  /* 刘海屏 / 底部手势条：给按钮多留一点空间，别被 Home 指示条挡住 */
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.app-body.pb-action { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }

/* ---------- 发布 / 编辑页 ---------- */
.img-pick { display: flex; align-items: center; gap: 12px; }
.img-preview {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-2);
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--muted-2);
  cursor: pointer;
  flex: 0 0 auto;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-hint { font-size: 12px; color: var(--muted); }

.counter { margin-top: 4px; text-align: right; font-size: 12px; color: var(--muted); }
.counter.over { color: var(--danger); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ---------- 我的发布 ---------- */
.mine-actions { display: flex; gap: 8px; margin-top: 10px; }
.mine-actions .btn { flex: 1 1 0; min-height: 36px; padding: 0 10px; font-size: 13px; }
.btn-quiet { background: var(--card); color: var(--ink-3); border-color: var(--line); }
.btn-danger { color: var(--danger); border-color: #F3C7C7; background: #FFFBFB; }
.btn-danger:hover { background: var(--danger-bg); }

/* ---------- 相关推荐 ---------- */
.rel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
  cursor: pointer;
}
.rel-row:last-child { border-bottom: 0; padding-bottom: 0; }
.rel-row:hover .rel-title { color: var(--brand); }
.rel-row .rel-title { flex: 0 1 auto; font-weight: 600; color: var(--ink); }
.rel-row .rel-meta { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 12px; }
.rel-row .rel-arrow { flex: 0 0 auto; color: var(--muted-2); }

/* ---------- 触摸 / 点击反馈 ----------
   移动端没有 hover，按下时给一点下沉反馈，让点击更「有手感」；
   同时去掉默认的蓝色点击高亮，避免点一下闪蓝。 */
.card, .btn, .tab, .chip, .seg > *, .nav-back, .rel-row {
  -webkit-tap-highlight-color: transparent;
}
.item-card:active { transform: translateY(0) scale(.985); }
.btn:active:not(:disabled) { transform: scale(.97); }
.tab:active { opacity: .65; }
.chip:active { opacity: .65; }
.seg > *:active { opacity: .7; }
.nav-back:active { background: var(--bg-2); }
.rel-row:active { background: var(--bg-2); }

/* 键盘导航时给可点元素一个清晰的焦点圈，方便不用鼠标的用户 */
.btn:focus-visible, .tab:focus-visible, .nav-back:focus-visible {
  outline: 2px solid var(--brand-mid);
  outline-offset: 2px;
}
