/* ==========================================================================
   省市多选组件（AreaPicker）
   用于：合作信息发布 / 编辑页的「合作地区」、合作列表页的地区筛选
   设计口径：品牌青 #087e78、正文 #1d2939、描边 #e9eef3、卡片圆角 14、控件圆角 9
   ========================================================================== */

.ap {
  position: relative;
  display: block;
  width: 100%;
  max-width: 560px;
  --ap-brand: #087e78;
  --ap-brand-700: #066a65;
  --ap-brand-100: #e9f7f5;
  --ap-line: #e9eef3;
  --ap-line-2: #dce4ea;
  --ap-ink: #1d2939;
  --ap-text-2: #475467;
  --ap-muted: #667085;
  --ap-radius: 14px;
}
.ap *,
.ap *::before,
.ap *::after { box-sizing: border-box; }

/* ---------- 触发器 ---------- */
.ap-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--ap-line-2);
  border-radius: 9px;
  background: #fff;
  color: var(--ap-ink);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.ap-trigger:hover { border-color: #b9ded9; background: #fcfefe; }
.ap-trigger:focus-visible {
  outline: 2px solid var(--ap-brand);
  outline-offset: 2px;
}
.ap.is-open .ap-trigger,
.ap-trigger[aria-expanded="true"] {
  border-color: var(--ap-brand);
  box-shadow: 0 0 0 3px rgba(8, 126, 120, .10);
}
.ap-trigger-icon {
  flex: none;
  color: var(--ap-brand);
  font-size: 13px;
  line-height: 1;
}
.ap-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-trigger.is-empty .ap-trigger-text { color: #667085; }
.ap-trigger-tags {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}
.ap-trigger-tag {
  padding: 1px 8px;
  border-radius: 100px;
  background: var(--ap-brand-100);
  color: var(--ap-brand-700);
  font-size: 12px;
  line-height: 18px;
}
.ap-trigger-count {
  flex: none;
  padding: 1px 8px;
  border-radius: 100px;
  background: var(--ap-brand);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
}
.ap-caret {
  flex: none;
  color: #98a2b3;
  font-size: 10px;
  transition: transform .18s ease;
}
.ap.is-open .ap-caret { transform: rotate(180deg); }

/* ---------- 浮层 ---------- */
.ap-pop {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  left: 0;
  display: none;
  width: min(660px, calc(100vw - 32px));
  border: 1px solid var(--ap-line);
  border-radius: var(--ap-radius);
  background: #fff;
  box-shadow: 0 18px 44px rgba(16, 24, 40, .16), 0 2px 8px rgba(16, 24, 40, .06);
  overflow: auto;
  overscroll-behavior: contain;
}
.ap.is-open .ap-pop { display: block; animation: ap-pop-in .16s ease-out; }
@keyframes ap-pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .ap.is-open .ap-pop { animation: none; }
  .ap-caret { transition: none; }
}

.ap-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid #f1f4f7;
}
.ap-search {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #e3e9ef;
  border-radius: 8px;
  background: #fbfcfd;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.ap-search:focus-within {
  border-color: var(--ap-brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(8, 126, 120, .09);
}
.ap-search i { color: #a7b2bd; font-size: 11.5px; }
.ap-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ap-ink);
  font-family: inherit;
  font-size: 12.5px;
}
.ap-search input::placeholder { color: #b3bcc7; }
.ap-close {
  flex: none;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #f5f7f9;
  color: #7b8794;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.ap-close:hover { background: #eef2f5; color: #1d2939; }

.ap-body {
  display: grid;
  grid-template-columns: 146px minmax(0, 1fr);
  height: 316px;
}

/* 省份列 */
.ap-provinces {
  overflow-y: auto;
  padding: 6px;
  border-right: 1px solid #f1f4f7;
  background: #fcfdfe;
  scrollbar-width: thin;
}
.ap-prov {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ap-text-2);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color .14s ease, color .14s ease;
}
.ap-prov:hover { background: #f1f7f6; color: var(--ap-brand); }
.ap-prov:focus-visible { outline: 2px solid var(--ap-brand); outline-offset: -2px; }
.ap-prov.is-active { background: var(--ap-brand-100); color: var(--ap-brand-700); font-weight: 600; }
.ap-prov-mark {
  flex: none;
  width: 13px;
  height: 13px;
  border: 1.5px solid #cfd8e0;
  border-radius: 3px;
  background: #fff;
  transition: background-color .14s ease, border-color .14s ease;
}
.ap-prov.is-on .ap-prov-mark {
  border-color: var(--ap-brand);
  background: var(--ap-brand);
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.4 6.2l2.2 2.2 4.8-4.8' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 11px 11px;
  background-repeat: no-repeat;
  background-position: center;
}
.ap-prov.is-part .ap-prov-mark { border-color: var(--ap-brand); background: #fff; box-shadow: inset 0 0 0 3px var(--ap-brand-100); }
.ap-prov-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-prov-num {
  flex: none;
  color: var(--ap-brand);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ap-prov-empty { padding: 14px 10px; color: var(--ap-muted); font-size: 12.5px; text-align: center; }

/* 「全国」项 */
.ap-prov-all { position: relative; margin-bottom: 6px; }
.ap-prov-all::after {
  position: absolute;
  right: 8px;
  bottom: -4px;
  left: 8px;
  height: 1px;
  background: #eef2f5;
  content: '';
}
.ap-prov-all.is-on { background: var(--ap-brand); color: #fff; font-weight: 600; }
.ap-prov-all.is-on .ap-prov-mark {
  border-color: #fff;
  background-color: #fff;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.4 6.2l2.2 2.2 4.8-4.8' fill='none' stroke='%23087e78' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* 城市面板 */
.ap-cities {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.ap-cities-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px 8px;
}
.ap-cities-title { color: var(--ap-ink); font-size: 13px; font-weight: 600; }
.ap-cities-title small { margin-left: 6px; color: var(--ap-muted); font-size: 11.5px; font-weight: 400; }
.ap-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid #dbe5e3;
  border-radius: 100px;
  background: #fff;
  color: var(--ap-text-2);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s ease;
}
.ap-all:hover { border-color: #a9dcd5; color: var(--ap-brand); }
.ap-all:focus-visible { outline: 2px solid var(--ap-brand); outline-offset: 2px; }
.ap-all.is-on {
  border-color: var(--ap-brand);
  background: var(--ap-brand);
  color: #fff;
  font-weight: 600;
}
.ap-city-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 7px;
  overflow-y: auto;
  padding: 4px 13px 14px;
  scrollbar-width: thin;
}
.ap-city {
  height: 30px;
  padding: 0 8px;
  border: 1px solid #e6ebf0;
  border-radius: 7px;
  background: #fff;
  color: var(--ap-text-2);
  font-family: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: all .14s ease;
}
.ap-city:hover { border-color: #a9dcd5; color: var(--ap-brand); background: #f7fdfc; }
.ap-city:focus-visible { outline: 2px solid var(--ap-brand); outline-offset: 1px; }
.ap-city.is-on {
  border-color: var(--ap-brand);
  background: var(--ap-brand-100);
  color: var(--ap-brand-700);
  font-weight: 600;
}
.ap-city.is-on::after { content: ' ✓'; font-size: 10px; }
.ap-city-empty {
  grid-column: 1 / -1;
  padding: 26px 8px;
  color: var(--ap-muted);
  font-size: 12.5px;
  text-align: center;
}

/* 底部 */
.ap-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border-top: 1px solid #f1f4f7;
  background: #fcfdfe;
}
.ap-foot-info { color: var(--ap-muted); font-size: 12px; }
.ap-foot-info b { color: var(--ap-brand); font-weight: 700; font-variant-numeric: tabular-nums; }
.ap-foot-actions { display: flex; align-items: center; gap: 8px; }
.ap-btn {
  height: 32px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .15s ease;
}
.ap-btn:focus-visible { outline: 2px solid var(--ap-brand); outline-offset: 2px; }
.ap-btn.ghost { border-color: #e3e9ef; background: #fff; color: var(--ap-text-2); }
.ap-btn.ghost:hover { border-color: #cfd8e0; color: var(--ap-ink); }
.ap-btn.primary {
  /* 纯品牌青保证小字号白字对比度 ≥ 4.5:1（渐变浅端仅 4.0） */
  background: #087e78;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(8, 126, 120, .22);
}
.ap-btn.primary:hover { background: #066a65; }

/* ---------- 已选标签（表单页展示） ---------- */
.ap-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.ap-chips:empty { display: none; }
.ap-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 10px;
  border: 1px solid #cfe9e5;
  border-radius: 100px;
  background: #fff;
  color: var(--ap-brand-700);
  font-size: 12px;
  line-height: 18px;
}
.ap-chip.is-province { border-style: dashed; }
.ap-chip em { color: #8a9a97; font-style: normal; font-size: 11px; }
.ap-chip button {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #eef6f5;
  color: #7b918e;
  font-size: 9px;
  line-height: 15px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.ap-chip button:hover { background: #fdeceb; color: #d9534f; }
.ap-chip button:focus-visible { outline: 2px solid var(--ap-brand); outline-offset: 1px; }

/* ---------- 筛选模式（列表页） ---------- */
.ap[data-ap-mode="filter"] {
  display: inline-block;
  width: auto;
  max-width: none;
  vertical-align: middle;
}
.ap[data-ap-mode="filter"] .ap-trigger {
  width: auto;
  min-height: 30px;
  max-width: min(420px, calc(100vw - 120px));
  padding: 3px 11px;
  border-radius: 8px;
  border-color: var(--ap-line-2);
  font-size: 13px;
  color: var(--ap-text-2);
}
.ap[data-ap-mode="filter"] .ap-trigger:hover { background: var(--ap-brand-100); border-color: #cfe9e5; color: var(--ap-brand); }
.ap[data-ap-mode="filter"] .ap-trigger.is-empty .ap-trigger-text { color: var(--ap-text-2); }
.ap[data-ap-mode="filter"] .ap-trigger.is-filled {
  border-color: var(--ap-brand);
  background: var(--ap-brand-100);
  color: var(--ap-brand-700);
  font-weight: 600;
}
.ap[data-ap-mode="filter"] .ap-trigger-count { background: var(--ap-brand); }

/* ---------- 提示文案 ---------- */
.ap-hint {
  margin-top: 6px;
  color: #667085;
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- 行内模式（列表页：省份常驻 + 城市展开） ---------- */
.ap[data-ap-mode="inline"] {
  display: block;
  flex: 1 1 100%;
  width: 100%;
  max-width: none;
  min-width: 0;
}
.ap-inline-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-width: 0;
}
.ap-inline-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 4px;
  min-width: 0;
}
.ap-inline-city-row {
  margin-top: 2px;
  padding-top: 7px;
  border-top: 1px dashed #eef2f6;
}
.ap-inline-city-row[hidden] { display: none !important; }
.ap-inline-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.ap-inline-title {
  color: var(--ap-brand-700);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2px;
}
.ap-inline-title::before {
  display: inline-block;
  width: 3px;
  height: 11px;
  margin-right: 6px;
  border-radius: 3px;
  background: linear-gradient(180deg, #0a8f88, #067069);
  content: '';
  vertical-align: -1px;
}
.ap-inline-hint { color: var(--ap-muted); font-size: 11.5px; }

/* 行内标签：与其它筛选 pill 同尺寸 */
.ap-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 29px;
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ap-text-2);
  font-family: inherit;
  font-size: 13px;
  line-height: 19px;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.ap-tag:hover { background: var(--ap-brand-100); color: var(--ap-brand); }
.ap-tag:focus-visible { outline: 2px solid var(--ap-brand); outline-offset: 1px; }
.ap-tag.is-on {
  background: var(--ap-brand);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(8, 126, 120, .22);
}
.ap-tag.is-on:hover { background: var(--ap-brand-700); color: #fff; }
.ap-tag.is-focus:not(.is-on) {
  border-color: var(--ap-brand);
  background: #f2fbf9;
  color: var(--ap-brand-700);
}
.ap-tag.is-focus.is-on {
  outline: 2px solid rgba(8, 126, 120, .28);
  outline-offset: 1px;
}
.ap-tag-num {
  padding: 0 5px;
  border-radius: 100px;
  /* 选中态下压暗底，保证 10.5px 白字仍达 AA */
  background: rgba(0, 0, 0, .18);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 600;
  line-height: 15px;
  font-variant-numeric: tabular-nums;
}
.ap-tag:not(.is-on) .ap-tag-num { background: var(--ap-brand-100); color: var(--ap-brand-700); }
.ap-tag-all { font-weight: 600; }
.ap-tag-all::before {
  width: 12px;
  height: 12px;
  margin-right: 1px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.0 3.4h8M2.0 6h8M2.0 8.6h8' fill='none' stroke='%23667085' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  content: '';
}
.ap-tag-all.is-on::before {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.0 3.4h8M2.0 6h8M2.0 8.6h8' fill='none' stroke='%23ffffff' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
}

@media (min-width: 721px) and (max-width: 1024px) {
  /* 中等宽度：标签略紧凑，避免省份换行过多 */
  .ap-tag { padding: 3px 9px; font-size: 12.5px; min-height: 27px; }
}

@media (max-width: 720px) {
  .ap-tag { min-height: 32px; padding: 5px 11px; font-size: 12.5px; }
  /* 移动端：省份一行横滑，城市换行铺开 */
  .ap-inline-prov-row,
  .ap-inline-prov-row .ap-inline-items {
    width: 100%;
    max-width: 100%;
  }
  .ap-inline-prov-row .ap-inline-items {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .ap-inline-prov-row .ap-inline-items::-webkit-scrollbar { display: none; }
  .ap-inline-prov-row .ap-tag { flex: 0 0 auto; }
  .ap-inline-city-row .ap-inline-items { max-height: 168px; overflow-y: auto; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .ap-pop {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 82vh;
    display: none;
    flex-direction: column;
  }
  .ap.is-open .ap-pop { display: flex; }
  .ap-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: auto;
    max-height: 60vh;
  }
  .ap-provinces {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid #f1f4f7;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .ap-prov {
    width: auto;
    height: 30px;
    padding: 0 10px;
    border: 1px solid #e6ebf0;
    border-radius: 100px;
    white-space: nowrap;
  }
  .ap-prov.is-active { border-color: var(--ap-brand); }
  .ap-prov-mark { display: none; }
  .ap-cities { min-height: 0; }
  .ap-city-grid { max-height: 40vh; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .ap-city { height: 34px; }
}
