/**
 * 档案列表 + 详情页样式（设计稿 D1/D2/D3）
 * 米色调与 relationships-report.css / me.css 一致
 */

/* ============ 公共布局：archive-list-view + archive-detail-view ============ */
#archive-list-view,
#archive-detail-view {
  background: #faf3e3;
  min-height: 100vh;
  min-height: 100dvh;
  color: #3a2e1f;
  font-family: var(--onboard-font-sans, -apple-system, "PingFang SC", sans-serif);
}

/* ============ 顶部 nav (返回 + 标题 + 右侧 action) ============ */
.archive-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px;
  background: #faf3e3;
  position: sticky;
  top: 0;
  z-index: 5;
}
.archive-nav__back {
  background: none;
  border: none;
  color: #a07a32;
  font-size: 18px;
  padding: 4px 8px;
  cursor: pointer;
  justify-self: start;
}
.archive-nav__title {
  font-size: 16px;
  font-weight: 600;
  color: #3a2e1f;
  text-align: center;
}
.archive-nav__action {
  background: none;
  border: none;
  color: #a07a32;
  font-size: 14px;
  cursor: pointer;
  justify-self: end;
  padding: 4px 8px;
}

/* ============ 列表页 ============ */
.archive-list {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 100px;
}
.archive-list__search {
  position: relative;
  margin-bottom: 12px;
}
.archive-list__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #8a7860;
  font-size: 14px;
  pointer-events: none;
}
.archive-list__search input {
  width: 100%;
  padding: 10px 12px 10px 34px;
  border-radius: 999px;
  border: 1px solid #e3d4ae;
  background: #fff;
  color: #3a2e1f;
  font-size: 13px;
  -webkit-appearance: none;
}
.archive-list__search input::placeholder { color: #c1995a; }

.archive-list__count {
  font-size: 12px;
  color: #8a7860;
  margin: 8px 4px;
}
.archive-list__group { margin-bottom: 12px; }
.archive-list__group-heading {
  font-size: 12px;
  color: #8a7860;
  margin: 12px 4px 6px;
}

/* ============ 列表行（archive-row） ============ */
.archive-row {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #e3d4ae;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  gap: 10px;
  transition: transform 0.1s;
}
.archive-row:active { transform: scale(0.99); }
.archive-row--self {
  background: #faead2;
  border-color: #e3c89a;
}
.archive-row__check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #c1995a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  background: transparent;
  flex: 0 0 auto;
}
.archive-row__check.is-checked {
  background: #a07a32;
  border-color: #a07a32;
}
.archive-row__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  /* 兜底色：JS 通过 inline style 传 avatarFallbackStyle() 覆盖 */
  background: linear-gradient(135deg, #23244F 0%, #5B4FB3 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex: 0 0 auto;
}
.archive-row__avatar--female { background: linear-gradient(135deg, #331461 0%, #6B3FB8 100%); }
.archive-row__avatar--self { background: linear-gradient(135deg, #143461 0%, #3F7AC8 100%); }
.archive-row__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.archive-row__name {
  font-size: 14px;
  font-weight: 600;
  color: #3a2e1f;
}
.archive-row__sub {
  font-size: 12px;
  color: #8a7860;
}
.archive-row__tag {
  background: #c1995a;
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  flex: 0 0 auto;
}
.archive-row__chevron {
  color: #c1995a;
  font-size: 16px;
  flex: 0 0 auto;
}

/* ============ 编辑模式底部操作栏 ============ */
.archive-list__action-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid #e3d4ae;
  z-index: 10;
}
.archive-list__select-all {
  background: none;
  border: none;
  color: #a07a32;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
}
.archive-list__delete-btn {
  flex: 1;
  background: #b6534f;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.archive-list__delete-btn.is-disabled,
.archive-list__delete-btn[disabled] {
  background: #d9b3b1;
  cursor: not-allowed;
}

/* ============ 详情页 ============ */
.archive-detail {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 32px;
}
.archive-detail__head {
  text-align: center;
  padding: 16px 0 8px;
}
.archive-detail__avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto 12px;
  /* 兜底色：JS inline style 接管，gender 未知时显示中性紫蓝渐变 */
  background: linear-gradient(135deg, #23244F 0%, #5B4FB3 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 600;
}
.archive-detail__avatar--female { background: linear-gradient(135deg, #331461 0%, #6B3FB8 100%); }
.archive-detail__name {
  font-size: 22px;
  font-weight: 700;
  color: #3a2e1f;
}
.archive-detail__sub {
  font-size: 13px;
  color: #8a7860;
  margin-top: 4px;
}
.archive-detail__chat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #b08842;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 32px;
  margin-top: 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-width: 240px;
  box-shadow: 0 4px 12px rgba(176, 136, 66, 0.3);
}
.archive-detail__chat-hint {
  font-size: 11px;
  color: #8a7860;
  margin-top: 8px;
}

.archive-detail__chart-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #fff;
  color: #b08842;
  border: 1px solid #b08842;
  border-radius: 999px;
  padding: 10px 28px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-width: 200px;
}
.archive-detail__chart-wrap {
  margin-top: 12px;
}
.archive-detail__chart-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
}
.archive-detail__chart-loading,
.archive-detail__chart-error {
  text-align: center;
  font-size: 13px;
  color: #8a7860;
  padding: 24px 12px;
  background: #fff;
  border: 1px dashed #e3d4ae;
  border-radius: 12px;
}
.archive-detail__chart-error {
  color: #c0392b;
  border-color: #e8c4be;
}

.archive-detail__section-heading {
  font-size: 12px;
  color: #8a7860;
  margin: 18px 4px 8px;
}
.archive-detail__rels-empty {
  text-align: center;
  font-size: 12px;
  color: #8a7860;
  padding: 16px;
  background: #fff;
  border: 1px dashed #e3d4ae;
  border-radius: 12px;
}
.archive-detail__rels-hint {
  font-size: 11px;
  color: #c1995a;
  margin-bottom: 6px;
  padding-left: 4px;
}

.archive-rel {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #e3d4ae;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
}
.archive-rel__avatars {
  display: flex;
  flex: 0 0 auto;
}
.archive-rel__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  /* 兜底色：JS inline style 接管 */
  background: linear-gradient(135deg, #23244F 0%, #5B4FB3 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  margin-right: -6px;
  border: 2px solid #fff;
}
.archive-rel__avatar--female { background: linear-gradient(135deg, #331461 0%, #6B3FB8 100%); }
.archive-rel__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 6px;
}
.archive-rel__title {
  font-size: 14px;
  font-weight: 600;
  color: #3a2e1f;
}
.archive-rel__sub {
  font-size: 12px;
  color: #8a7860;
}
.archive-rel__chevron {
  color: #c1995a;
  font-size: 16px;
}

.archive-detail__manage-row {
  display: flex;
  align-items: center;
  width: 100%;
  background: #fff;
  border: 1px solid #e3d4ae;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 8px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: #3a2e1f;
  gap: 10px;
}
.archive-detail__manage-row--danger { color: #b6534f; }
.archive-detail__manage-icon {
  font-size: 18px;
  flex: 0 0 auto;
}
.archive-detail__manage-label { flex: 1; }
.archive-detail__manage-chevron {
  color: #c1995a;
  font-size: 14px;
}

/* 「+」新建档案 FAB（需求#3，按小程序流程：点击先 can-create 预检） */
.archive-list__fab {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #c1995a;
  color: #fff;
  font-size: 30px;
  line-height: 52px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(193, 153, 90, 0.45);
  cursor: pointer;
  z-index: 20;
}
.archive-list__fab:active { transform: scale(0.96); }
