/**
 * 商户开户申请弹窗
 *
 * 官网 index.html 已有全局的 *、body 重置与 .page / .btn / .panel / .chip 等通用类名，
 * 因此这里所有类名与自定义属性统一加 moa- 前缀，且不写任何元素级选择器，避免双向污染。
 */
:root {
  --moa-panel: #0a0a0c;
  --moa-field: #22262e;
  --moa-popup: #474b55;
  --moa-line: #2a2f39;
  --moa-text: #eaecef;
  --moa-text-2: #a2a9b6;
  --moa-text-3: #6d7482;
  --moa-primary: #2f7cf6;
  --moa-primary-soft: rgba(47, 124, 246, 0.14);
  /* 步骤条未完成态：描边与连线同色，圆点填充为同色 0.2 */
  --moa-step-idle: rgba(91, 157, 255, 0.45);
  --moa-step-idle-fill: rgba(91, 157, 255, 0.2);
  --moa-danger: #f05a5a;
  --moa-success: #35c46a;
  --moa-r-sm: 8px;
  --moa-r-lg: 18px;
}

.moa-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- 弹窗骨架 ---------- */
.moa-mask {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  overflow-x: hidden;
  background: rgba(4, 6, 10, 0.68);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.moa-mask[hidden] {
  display: none;
}

html.moa-open,
html.moa-open body {
  overflow: hidden;
  overscroll-behavior: none;
}

@media (max-width: 640px) {
  html.moa-open,
  html.moa-open body,
  html.moa-open .page {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
  }
}

.moa-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: min(880px, 100%);
  box-sizing: border-box;
  /* 固定高度，内容多少都不改变弹窗尺寸；视口不够时退回视口高度 */
  height: 840px;
  max-height: 100%;
  overflow: hidden;
  border-radius: var(--moa-r-lg);
  /* 底色 + 5% 白叠加；光束图用 screen 混合，暗部不遮挡底色，只叠加亮部 */
  background:
    url("../images/dialog-bg.jpg") no-repeat right top / cover,
    linear-gradient(0deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05)),
    var(--moa-panel);
  background-blend-mode: screen, normal, normal;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  color: var(--moa-text);
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  animation: moa-dialog-in 0.22s ease-out;
}

@keyframes moa-dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
}

.moa-dialog__head {
  position: relative;
  padding: 26px 32px 0;
}

.moa-dialog__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 1px;
}

.moa-dialog__desc {
  margin: 10px 0 0;
  color: var(--moa-text-2);
  font-size: 13px;
  text-align: center;
}

.moa-dialog__close {
  position: absolute;
  top: 22px;
  right: 24px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.moa-dialog__close img {
  display: block;
  width: 24px;
  height: 24px;
}

/* ---------- 步骤条 ---------- */
.moa-steps {
  display: flex;
  margin: 34px 0 0;
  padding: 0;
  list-style: none;
}

.moa-steps__item {
  position: relative;
  flex: 1;
  text-align: center;
}

/* 两端各让出一个圆点半径，避免半透明圆点透出连线 */
.moa-steps__item + .moa-steps__item::before {
  content: "";
  position: absolute;
  top: 16px;
  right: calc(50% + 16px);
  left: calc(-50% + 16px);
  height: 1px;
  background: var(--moa-step-idle);
}

.moa-steps__item.is-active::before,
.moa-steps__item.is-done::before {
  background: var(--moa-primary);
}

/* 未完成步骤：半透明蓝底 + 1px 半透明蓝描边 */
.moa-steps__dot {
  position: relative;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--moa-step-idle);
  border-radius: 50%;
  background: var(--moa-step-idle-fill);
  color: #5b9dff;
  font-size: 16px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.moa-steps__item.is-active .moa-steps__dot,
.moa-steps__item.is-done .moa-steps__dot {
  border-color: var(--moa-primary);
  background: var(--moa-primary);
  color: #fff;
}

.moa-steps__text {
  display: block;
  margin-top: 10px;
  color: var(--moa-text-3);
  font-size: 13px;
}

.moa-steps__item.is-active .moa-steps__text {
  color: #fff;
  font-weight: 600;
}

/* ---------- 表单区 ---------- */
.moa-dialog__form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.moa-dialog__body {
  flex: 1;
  min-height: 320px;
  overflow-y: auto;
  padding: 26px 32px 30px;
  scrollbar-width: thin;
  scrollbar-color: #3a4252 transparent;
}

.moa-dialog__body::-webkit-scrollbar {
  width: 6px;
}

.moa-dialog__body--captcha {
  overflow: visible;
}

.moa-panel {
  display: none;
}

.moa-panel.is-active {
  display: block;
}

.moa-field + .moa-field {
  margin-top: 18px;
}

.moa-field__label {
  display: block;
  margin-bottom: 9px;
  color: var(--moa-text);
  font-size: 13px;
  font-weight: 500;
}

.moa-field__tip {
  margin-left: 8px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  font-style: normal;
  font-weight: 330;
  line-height: 1.3;
}

.moa-field__note {
  margin: 8px 0 0;
  color: var(--moa-text-3);
  font-size: 12px;
}

.moa-field__error {
  margin: 6px 0 0;
  color: var(--moa-danger);
  font-size: 12px;
  min-height: 0;
}

.moa-field__error:empty {
  display: none;
}

.moa-req {
  margin-right: 4px;
  color: var(--moa-danger);
  font-style: normal;
}

.moa-row {
  display: flex;
  gap: 10px;
}

.moa-input,
.moa-select__trigger {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--moa-r-sm);
  background: rgba(255, 255, 255, 0.1);
  color: var(--moa-text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.moa-input::placeholder {
  color: rgba(255, 255, 255, 0.75);
}

.moa-input:focus,
.moa-select__trigger:focus-visible {
  border-color: var(--moa-primary);
  box-shadow: 0 0 0 3px var(--moa-primary-soft);
}

.moa-input.is-invalid {
  border-color: var(--moa-danger);
}

.moa-select {
  position: relative;
  flex: 0 0 130px;
}

.moa-select__trigger {
  padding-right: 32px;
  text-align: left;
  cursor: pointer;
}

.moa-select__trigger.is-invalid {
  border-color: var(--moa-danger);
}

.moa-select__label.is-placeholder {
  color: rgba(255, 255, 255, 0.75);
}

.moa-select__arrow {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--moa-text-2);
  transform: translateY(-50%);
  pointer-events: none;
}

/* ---------- 选项弹层 ---------- */
.moa-picker {
  position: fixed;
  inset: 0;
  z-index: 560;
}

.moa-picker[hidden] {
  display: none;
}

/* 位置由 JS 按触发按钮实时计算，空间不足时向上展开 */
.moa-picker__panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 12px;
  overflow-y: auto;
  list-style: none;
  box-sizing: border-box;
  border: 1px solid var(--line-hi, rgba(255, 255, 255, 0.2));
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.moa-picker__option {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--moa-r-sm);
  background: transparent;
  color: var(--moa-text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.moa-picker__option:hover {
  border-color: transparent;
  background: rgba(10, 132, 255, 0.1);
  color: rgba(10, 132, 255, 1);
}

.moa-picker__option.is-selected {
  border-color: rgba(10, 132, 255, 1);
  background: rgba(10, 132, 255, 0.1);
  color: rgba(10, 132, 255, 1);
}

/* 默认语种在没勾选接入语种前无可选项 */
.moa-picker__empty {
  padding: 10px 12px;
  color: var(--moa-text-2);
  font-size: 13px;
  text-align: center;
}

/* ---------- 标签选择 ---------- */
.moa-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.moa-chip {
  box-sizing: border-box;
  width: auto;
  max-width: 100%;
  min-height: 36px;
  height: auto;
  padding: 8px 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
  font-family: inherit;
  font-size: 14px;
  font-weight: 330;
  line-height: 140%;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  cursor: pointer;
  transition: all 0.25s;
}

.moa-chip:hover {
  background: rgba(10, 132, 255, 0.1);
  color: #0a84ff;
  border-color: transparent;
}

.moa-chip.is-selected {
  background: rgba(10, 132, 255, 0.1);
  color: #0a84ff;
  border-color: #0a84ff;
}

.moa-chips.is-invalid .moa-chip {
  border-color: rgba(240, 90, 90, 0.5);
}

/* ---------- 上传 ---------- */
.moa-upload {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.moa-upload__preview {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--moa-line);
  border-radius: var(--moa-r-sm);
  object-fit: cover;
}

.moa-upload__name {
  flex: 1;
  min-width: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 人机验证 ---------- */
/* 跟在投注额度后面；第三步内容短，滚动层改为 overflow:visible，避免 H5 吞掉 iframe 点击 */
.moa-captcha-slot {
  position: relative;
  z-index: 3;
}

.moa-captcha-slot[hidden] {
  display: none;
}

.moa-captcha__widget {
  position: relative;
  z-index: 2;
  width: max-content;
  max-width: 100%;
  min-height: 65px;
  overflow: visible;
}

.moa-captcha__widget iframe {
  pointer-events: auto;
  touch-action: manipulation;
}

/* 交互态直接露出 Turnstile 组件原生外观，不再包一层容器样式 */
.moa-captcha__row {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.moa-captcha {
  position: relative;
}

.moa-captcha[data-state="error"] {
  padding: 13px 14px;
  border: 1px solid var(--moa-line);
  border-radius: var(--moa-r-sm);
  background: var(--moa-field);
}

.moa-captcha[data-state="loading"] {
  padding: 13px 14px;
  border: 1px solid var(--moa-line);
  border-radius: var(--moa-r-sm);
  background: var(--moa-field);
  min-height: 46px;
}

.moa-captcha[data-state="loading"] .moa-captcha__row--loading {
  position: relative;
  z-index: 1;
  display: flex;
  color: var(--moa-text-2);
}

.moa-captcha__spinner {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--moa-primary);
  border-radius: 50%;
  animation: moa-spin 0.7s linear infinite;
}

@keyframes moa-spin {
  to {
    transform: rotate(360deg);
  }
}

.moa-captcha[data-state="error"] .moa-captcha__row--error {
  position: relative;
  z-index: 1;
  display: flex;
  color: var(--moa-danger);
}

/* 失败/通过都盖住组件，但不要 display:none：H5 上藏 iframe 会再打 error，getResponse 也读不到 token */
.moa-captcha[data-state="error"] .moa-captcha__widget,
.moa-captcha[data-state="passed"] .moa-captcha__widget,
.moa-captcha[data-state="loading"] .moa-captcha__widget {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  opacity: 0.01;
  pointer-events: none;
}

.moa-captcha[data-state="passed"] {
  padding: 13px 14px;
  border: 1px solid rgba(53, 196, 106, 0.35);
  border-radius: var(--moa-r-sm);
  background: rgba(53, 196, 106, 0.12);
}

.moa-captcha[data-state="passed"] .moa-captcha__row--ok {
  position: relative;
  z-index: 1;
  display: flex;
  color: var(--moa-success);
}

.moa-captcha__row--error .moa-link {
  margin: 0 0 0 4px;
}

.moa-link {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: #5b9bff;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

/* ---------- 完成态 ---------- */
.moa-done {
  display: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 48px 24px;
  text-align: center;
}

.moa-done[hidden] {
  display: none;
}

.moa-dialog.is-done {
  height: 400px;
  max-height: 400px;
}

.moa-dialog.is-done .moa-steps,
.moa-dialog.is-done .moa-dialog__form,
.moa-dialog.is-done .moa-dialog__foot {
  display: none;
}

.moa-dialog.is-done .moa-done {
  display: flex;
}

.moa-done__icon {
  display: block;
  width: 48px;
  height: 48px;
  margin: 40px 0 12px;
  object-fit: contain;
}

.moa-done__title {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

.moa-done__desc {
  margin: 0;
  max-width: 100%;
  color: var(--moa-text-2);
  font-size: 14px;
  line-height: 1.6;
}

.moa-done__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  margin-top: 32px;
}

/* ---------- 底部 ---------- */
.moa-dialog__foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 32px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.moa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 450;
  line-height: 1.4;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}

.moa-btn[hidden] {
  display: none;
}

a.moa-btn {
  text-decoration: none;
  box-sizing: border-box;
}

.moa-btn[disabled] {
  cursor: not-allowed;
  filter: grayscale(0.4);
  opacity: 0.7;
}

.moa-btn--primary {
  background: linear-gradient(90deg, rgba(43, 127, 255, 1) 0%, rgba(91, 157, 255, 1) 100%);
  color: #fff;
}

.moa-btn--primary:hover {
  filter: brightness(1.08);
}

/* 上一步 / 下一步：默认半透明蓝无描边，hover 才填充为主按钮的渐变 */
.moa-btn--ghost {
  background: rgba(43, 127, 255, 0.2);
  color: #5b9dff;
}

.moa-btn--ghost:hover {
  background: linear-gradient(90deg, rgba(43, 127, 255, 1) 0%, rgba(91, 157, 255, 1) 100%);
  color: #fff;
}

.moa-btn--outline {
  min-width: 88px;
  height: 52px;
  padding: 12px 24px;
  box-sizing: border-box;
  background: transparent;
  border: 1px solid #fff;
  color: #fff;
}

.moa-btn--outline:hover {
  background: rgba(255, 255, 255, 0.08);
}

.moa-btn--upload {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  height: 44px;
  padding: 0 16px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  white-space: nowrap;
}

.moa-btn--upload svg {
  color: #fff;
  flex-shrink: 0;
}

/* iOS 拍照确认后，1px + clip 的 file input 经常拿不到文件，盖在按钮上才能收到 */
.moa-upload__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
}

.moa-dialog__foot-tip {
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  font-weight: 330;
}

.moa-dialog__foot-tip[hidden] {
  display: none;
}

/* ---------- 轻提示 ---------- */
.moa-toast {
  position: fixed;
  top: 88px;
  left: 50%;
  z-index: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 40px;
  box-sizing: border-box;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.moa-toast[data-type="success"] {
  background: rgba(19, 246, 95, 0.1);
  border: 1px solid rgba(19, 246, 95, 0.1);
  color: #13f65f;
}

.moa-toast[data-type="error"] {
  background: rgba(240, 90, 90, 0.1);
  border: 1px solid rgba(240, 90, 90, 0.1);
  color: #f05a5a;
}

.moa-toast__icon {
  display: none;
  flex-shrink: 0;
}

.moa-toast[data-type="success"] .moa-toast__icon--ok,
.moa-toast[data-type="error"] .moa-toast__icon--err {
  display: block;
}

.moa-toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 适配 ---------- */

@media (max-width: 640px) {
  /* H5：底部半屏浮层，顶部留出一段遮罩 */
  .moa-mask {
    padding: 0;
    left: 0;
    top: 0;
    right: auto;
    bottom: auto;
    width: 100%;
    max-width: 100%;
    height: 100%;
    overflow-x: hidden;
    align-items: flex-end;
    /* backdrop-filter 会让内部跨域 iframe 点不中 */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* iOS 聚焦小于 16px 的输入框会整页放大，键盘收起后缩放不回正 */
  .moa-input,
  .moa-select__trigger {
    font-size: 16px;
  }

  .moa-dialog {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: calc(100% - 78px);
    max-height: calc(100% - 78px);
    border: 0;
    border-radius: 16px 16px 0 0;
    animation: moa-sheet-in 0.26s ease-out;
    /* 窄屏不要把 PC 光束图钉在右侧，否则右侧会发白看起来像裁切 */
    background-position: center top;
  }

  /* 滑入动画结束后去掉 transform，否则 Turnstile iframe 点击坐标会偏移 */
  .moa-dialog.is-settled {
    animation: none;
    transform: none;
  }

  .moa-dialog__head {
    padding: 22px 20px 0;
  }

  .moa-dialog__title {
    font-size: 17px;
  }

  .moa-dialog__desc {
    margin-top: 8px;
  }

  .moa-dialog__close {
    top: 18px;
    right: max(12px, env(safe-area-inset-right, 0px));
    width: 24px;
    height: 24px;
  }

  .moa-dialog__close img {
    width: 24px;
    height: 24px;
  }

  .moa-steps {
    margin-top: 28px;
  }

  .moa-steps__text {
    margin-top: 8px;
  }

  .moa-toast {
    top: 20px;
    padding: 12px 24px;
    white-space: normal;
  }

  .moa-dialog__body {
    min-height: 0;
    padding: 20px 20px 24px;
  }

  .moa-captcha-slot {
    z-index: 8;
  }

  .moa-dialog__foot {
    position: relative;
    z-index: 1;
  }

  .moa-field + .moa-field {
    margin-top: 16px;
  }

  .moa-input,
  .moa-select__trigger {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.1);
  }

  .moa-captcha[data-state="error"],
  .moa-captcha[data-state="loading"] {
    background: linear-gradient(90deg, #23272e 0%, #3a3f49 100%);
  }

  .moa-row {
    flex-wrap: nowrap;
  }

  .moa-select {
    flex: 0 0 104px;
  }

  .moa-row .moa-input {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .moa-dialog__foot {
    gap: 10px;
    padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  }

  /* H5 底部三个元素同行，按钮沿用小尺寸，不套用 PC 的 128×52 规格 */
  .moa-dialog__foot .moa-btn {
    flex: 0 0 auto;
    min-width: 78px;
    height: 36px;
    padding: 0 16px;
    border-radius: var(--moa-r-sm);
    font-weight: 400;
    font-size: 14px;
  }

  .moa-dialog__foot-tip {
    flex: 1;
    text-align: left;
  }

  .moa-dialog.is-done {
    width: 100%;
    max-width: 100%;
    height: 400px;
    max-height: min(400px, calc(100% - 78px));
    border-radius: 16px 16px 0 0;
  }

  .moa-done {
    padding: 0 20px 20px;
  }

  .moa-done__icon {
    width: 48px;
    height: 48px;
    margin: 40px 0 12px;
  }

  .moa-done__title {
    font-size: 17px;
  }

  .moa-done__actions .moa-btn {
    flex: 1 1 0;
    min-width: 0;
    height: 44px;
    padding: 0 12px;
    font-size: 14px;
  }
}

@keyframes moa-sheet-in {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
