/* ============================================================
   錢包連接 UI
   ============================================================ */

/* ---------- 頂部的連接按鈕 ---------- */

.wallet-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--gold-200);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.22s;
  white-space: nowrap;
  justify-content: center;
  /*
   * 提高層級，確保點擊一定有效。
   *
   * 為什麼需要：
   *   地球語言鈕是 position: fixed、z-index 9998 的浮動元素，
   *   它的透明外框可能延伸到這顆按鈕上方，
   *   導致點「連接錢包」時實際點到的是地球按鈕。
   *
   *   這裡把錢包按鈕拉到 9999（高於地球），
   *   並建立自己的堆疊脈絡，點擊一定有效。
   *   地球可以維持高 z-index 而不會被導覽列蓋住。
   */
  position: relative;
  z-index: 9999;
}

/*
 * 已連接：只留綠燈圓點。
 *
 * 文字會被 JS 清空，這裡把按鈕縮成小圓形，
 * 不再佔用 92px 的寬度，右邊的選單圖示就有空間。
 */
.wallet-btn.connected {
  min-width: 0;
  width: 36px;
  padding: 0;
  gap: 0;
  border-radius: 50%;
}

.wallet-btn.connected .dot {
  width: 10px;
  height: 10px;
}

.wallet-btn .label-text {
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 沒有文字時不佔空間 */
.wallet-btn .label-text:empty {
  display: none;
}

.wallet-btn:hover {
  background: rgba(212, 175, 55, 0.14);
  border-color: rgba(168, 134, 28, 0.3);
}

.wallet-btn.connected {
  color: #1f8a4c;
  border-color: rgba(31, 138, 76, 0.32);
  background: rgba(74, 222, 128, 0.14);
}

.wallet-btn .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.wallet-btn.connected .dot {
  animation: wallet-pulse 2s ease-in-out infinite;
}

@keyframes wallet-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- 連接提示彈窗 ---------- */

.wallet-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(3, 6, 14, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.28s;
}

.wallet-overlay.show {
  opacity: 1;
  visibility: visible;
}

.wallet-modal {
  width: 100%;
  max-width: 380px;
  background: var(--navy-700);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 26px 22px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(12px);
  transition: transform 0.28s;
}

.wallet-overlay.show .wallet-modal {
  transform: translateY(0);
}

.wallet-modal h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--gold-300);
  margin: 0 0 10px;
}

.wallet-modal .wm-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 20px;
}

.wallet-option {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--navy-800);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.22s;
}

.wallet-option:hover {
  border-color: var(--gold-400);
  background: rgba(212, 175, 55, 0.08);
}

.wallet-option .wo-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, #f0d98a, #d4af37);
  color: #1a1200;
}

.wallet-option .wo-name {
  font-weight: 600;
}

.wallet-option .wo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.wallet-modal .wm-close {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.wallet-modal .wm-close:hover {
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

/* ---------- 交易進度 ---------- */

.tx-progress {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 14px;
  background: rgba(77, 163, 255, 0.1);
  border: 1px solid rgba(77, 163, 255, 0.32);
  color: #7cb9ff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tx-progress.done {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.35);
  color: #4ade80;
}

.tx-progress.fail {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.35);
  color: #f87171;
}

.tx-spinner {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border: 2px solid rgba(124, 185, 255, 0.3);
  border-top-color: #7cb9ff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* ---------- 入金流程步驟清單 ---------- */

.tx-progress.steps {
  display: block;
  padding: 16px 18px;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(168, 134, 28, 0.28);
  color: #4a3f18;
}

.tx-progress.steps.done {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(31, 138, 76, 0.32);
  color: #1f5f34;
}

.tx-progress.steps.fail {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(200, 60, 60, 0.35);
  color: #7a2222;
}

.steps-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
  color: #8a6d10;
  -webkit-text-fill-color: #8a6d10;
}

.tx-progress.steps.done .steps-title {
  color: #1f8a4c;
  -webkit-text-fill-color: #1f8a4c;
}

.tx-progress.steps.fail .steps-title {
  color: #b33a3a;
  -webkit-text-fill-color: #b33a3a;
}

.step-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 12.5px;
  line-height: 1.5;
}

.step-row.active {
  font-weight: 600;
}

.step-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  border-radius: 50%;
}

.step-icon.pending {
  color: rgba(120, 100, 40, 0.4);
  -webkit-text-fill-color: rgba(120, 100, 40, 0.4);
}

.step-icon.running {
  color: #a8861c;
}

.step-icon.done {
  color: #1f8a4c;
  -webkit-text-fill-color: #1f8a4c;
}

.step-icon.fail {
  color: #c83c3c;
  -webkit-text-fill-color: #c83c3c;
}

.step-icon.skip {
  color: rgba(120, 100, 40, 0.55);
  -webkit-text-fill-color: rgba(120, 100, 40, 0.55);
}

.step-icon .tx-spinner {
  width: 12px;
  height: 12px;
  border-width: 2px;
  border-color: rgba(168, 134, 28, 0.25);
  border-top-color: #a8861c;
}

.step-num {
  font-size: 11px;
  color: rgba(120, 100, 40, 0.55);
  -webkit-text-fill-color: rgba(120, 100, 40, 0.55);
  min-width: 14px;
}

.step-label {
  flex: 0 0 auto;
}

.step-note {
  font-size: 11.5px;
  font-weight: 400;
  color: rgba(110, 90, 30, 0.8);
  -webkit-text-fill-color: rgba(110, 90, 30, 0.8);
  margin-left: auto;
  text-align: right;
  word-break: break-all;
}

/* ---------- 未連接時的提示（取代查詢框） ---------- */

.connect-prompt {
  text-align: center;
  padding: 34px 20px;
  background: var(--navy-800);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.connect-prompt .cp-icon {
  font-size: 34px;
  margin-bottom: 12px;
  opacity: 0.85;
}

.connect-prompt .cp-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gold-300);
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}

.connect-prompt .cp-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 18px;
}

.connect-prompt .cp-btn {
  padding: 12px 32px;
  border: 0;
  border-radius: 30px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  background: linear-gradient(135deg, #f0d98a, #d4af37 55%, #b8942a);
  color: #1a1200;
  box-shadow: 0 5px 20px rgba(212, 175, 55, 0.3);
  transition: all 0.25s;
}

.connect-prompt .cp-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(212, 175, 55, 0.45);
}

/* ---------- 手動輸入的折疊區 ---------- */

.manual-toggle {
  display: block;
  margin: 14px auto 0;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 8px;
}

.manual-toggle:hover {
  color: var(--gold-300);
}

/* ---------- 餘額顯示 ---------- */

.wallet-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(212, 175, 55, 0.07);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  flex-wrap: wrap;
}

.wallet-balance .wb-label {
  color: var(--text-muted);
  font-size: 12px;
}

.wallet-balance .wb-value {
  font-weight: 700;
  color: var(--gold-300);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

/* ---------- 首頁專用：header 疊在照片上，需要更強的對比 ---------- */

.site-header .wallet-btn {
  background: transparent;
  backdrop-filter: blur(5px);
  border-color: rgba(168, 134, 28, 0.35);
  height: 40px;
  font-size: 13px;
  padding: 0 16px;
}

.site-header .wallet-btn:hover {
  background: rgba(212, 175, 55, 0.22);
  border-color: var(--gold-400);
}

.site-header .wallet-btn.connected {
  background: rgba(10, 40, 22, 0.72);
  border-color: rgba(74, 222, 128, 0.55);
}

@media (max-width: 640px) {
  .site-header .wallet-btn {
    height: 34px;
    padding: 0 11px;
    font-size: 11.5px;
  }
}

/* ---------- RWD ---------- */

@media (max-width: 640px) {
  .wallet-btn {
    height: 34px;
    padding: 0 11px;
    font-size: 11.5px;
  }

  .wallet-btn .label-full {
    display: none;
  }

  .connect-prompt {
    padding: 26px 16px;
  }

  .wallet-modal {
    padding: 22px 18px 18px;
  }
}
