/* U贝 WebApp — 暗黑主题 */

html {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0);
  overscroll-behavior: none;
}

.tab-active {
  color: #f0b90b;
  border-bottom: 2px solid #f0b90b;
}

/* 公告滚动条 */
.ticker-wrap {
  border-top: 1px solid #2b3139;
  border-bottom: 1px solid #1e2329;
}

.ticker-bar {
  display: flex;
  align-items: stretch;
  min-height: 2rem;
}

.rate-ticker-slot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.35rem 0.65rem;
  border-right: 1px solid #1e2329;
  max-width: 42%;
}

#rate-ticker {
  font-size: 11px;
  font-weight: 600;
  color: #0ecb81;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  line-height: 1.2;
}

#rate-ticker-delay-hint {
  font-size: 9px;
  color: #848e9c;
  white-space: nowrap;
  line-height: 1.15;
}

#rate-ticker-delay-hint.hidden {
  display: none;
}

.ticker-scroll-area {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.ticker-track {
  display: inline-block;
  white-space: nowrap;
  padding-left: 100%;
  animation: ticker-scroll 22s linear infinite;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* 订单卡片 */
.order-card {
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.order-sync-pending-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(234, 236, 239, 0.92);
  background: rgba(15, 18, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.order-card:active {
  transform: scale(0.99);
}

.order-card:hover {
  border-color: rgba(240, 185, 11, 0.25);
}

.deposit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.125rem 0.45rem;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  color: #0b0e11;
  background: linear-gradient(135deg, #f0b90b 0%, #d4a017 100%);
  box-shadow: 0 0 12px rgba(240, 185, 11, 0.25);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.user-deposit-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  font-size: 9px;
  font-weight: 800;
  color: #0b0e11;
  background: linear-gradient(135deg, #f0b90b 0%, #d4a017 100%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.user-v-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  border-radius: 9999px;
  font-size: 9px;
  font-weight: 800;
  color: #0b0e11;
  background: linear-gradient(135deg, #f0b90b, #d4a017);
  vertical-align: middle;
}

/* 渐变金按钮 */
.btn-primary {
  background: linear-gradient(to right, #f0b90b, #d4a017);
  color: #0b0e11;
  font-weight: 700;
  border: none;
  box-shadow:
    0 10px 15px -3px rgba(240, 185, 11, 0.3),
    0 4px 6px -4px rgba(240, 185, 11, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow:
    0 12px 20px -3px rgba(240, 185, 11, 0.35),
    0 6px 8px -4px rgba(240, 185, 11, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled,
.btn-primary.is-disabled {
  background: #2b3139 !important;
  color: #6b7280 !important;
  box-shadow: none !important;
  transform: none !important;
  cursor: not-allowed;
}

.btn-cancel {
  background: rgba(246, 70, 93, 0.12);
  color: #f6465d;
  border: 1px solid rgba(246, 70, 93, 0.35);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-cancel:hover:not(:disabled) {
  background: rgba(246, 70, 93, 0.2);
  border-color: rgba(246, 70, 93, 0.5);
}

.btn-cancel:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-delete {
  background: rgba(255, 255, 255, 0.06);
  color: #848e9c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-delete:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #b7bdc6;
}

.btn-delete:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wallet-input::placeholder {
  color: #5e6673;
}

.wallet-deposit-address-input {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  cursor: text;
  touch-action: auto;
}

.buyer-address-input-wrap {
  position: relative;
}

.buyer-address-picker {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid rgba(240, 185, 11, 0.35);
  background: rgba(24, 26, 32, 0.98);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.buyer-address-picker-head {
  padding: 6px 12px 4px;
  font-size: 11px;
  color: #848e9c;
  pointer-events: none;
}

.buyer-address-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s ease;
}

.buyer-address-picker-item:hover,
.buyer-address-picker-item:active {
  background: rgba(240, 185, 11, 0.12);
}

.buyer-address-picker-addr {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: #eaecef;
  word-break: break-all;
}

.buyer-address-picker-chain {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  color: #f0b90b;
  border: 1px solid rgba(240, 185, 11, 0.35);
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(240, 185, 11, 0.08);
}

.ubei-clipboard-sink {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.wallet-deposit-log {
  border: 1px solid rgba(43, 49, 57, 0.8);
  background: rgba(24, 26, 32, 0.6);
}

.qrcode-enlarge {
  cursor: zoom-in;
}

.qrcode-enlarge img {
  transition: transform 0.15s ease;
}

.qrcode-enlarge:active img {
  transform: scale(0.98);
}

.proof-image {
  max-width: 100%;
}

button.is-disabled,
button[aria-busy="true"] {
  pointer-events: none;
}

.btn-ghost {
  color: #f0b90b;
  transition: opacity 0.15s ease;
}

.btn-ghost:hover {
  opacity: 0.85;
}

/* 空状态 */
.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
}

.empty-state svg {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  color: #848e9c;
  opacity: 0.85;
}

.empty-state p {
  color: #848e9c;
  font-size: 0.875rem;
  line-height: 1.5;
}

.empty-state.error svg {
  color: #f6465d;
}

/* 我的订单 — 分组区块 */
.order-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.25rem 0.5rem;
  margin-top: 0.25rem;
}

.order-section-header:first-child {
  margin-top: 0;
}

.order-section-title {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #eaecef;
}

.order-section-count {
  font-size: 0.6875rem;
  color: #848e9c;
  font-variant-numeric: tabular-nums;
}

.order-section-header--active .order-section-title {
  color: #f0b90b;
}

.order-section-header--active .order-section-count {
  color: #f0b90b;
  opacity: 0.85;
}

.order-section-header--done .order-section-title,
.order-section-header--done .order-section-count {
  color: #848e9c;
}

.order-section-body:last-child {
  margin-bottom: 0 !important;
}

.orders-subnav-btn {
  border: 1px solid #2b3139;
  background: #141821;
  color: #848e9c;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.orders-subnav-btn.orders-subnav-active {
  border-color: rgba(240, 185, 11, 0.45);
  background: rgba(240, 185, 11, 0.1);
  color: #f0b90b;
}

.market-side-nav {
  width: 100%;
}

.market-side-btn {
  border: 1px solid #2b3139;
  background: #141821;
  color: #848e9c;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.market-side-btn.market-side-active {
  border-color: rgba(240, 185, 11, 0.45);
  background: rgba(240, 185, 11, 0.1);
  color: #f0b90b;
}

.market-side-btn:active {
  transform: scale(0.98);
}

/* Loading */
#loading-overlay.hidden {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

#loading-overlay.visible {
  display: flex;
  pointer-events: auto;
}

.skeleton {
  animation: pulse 1.5s ease-in-out infinite;
  border-radius: 0.75rem;
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.9; }
}

/* 状态徽章 */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}

.status-pending {
  color: #f0b90b;
  background: rgba(240, 185, 11, 0.12);
  border: 1px solid rgba(240, 185, 11, 0.35);
}

.status-matched {
  color: #1e9cf0;
  background: rgba(30, 156, 240, 0.12);
  border: 1px solid rgba(30, 156, 240, 0.35);
}

.status-completed {
  color: #0ecb81;
  background: rgba(14, 203, 129, 0.12);
  border: 1px solid rgba(14, 203, 129, 0.35);
}

.status-cancelled {
  color: #848e9c;
  background: rgba(132, 142, 156, 0.12);
  border: 1px solid rgba(132, 142, 156, 0.35);
}

/* 环境拦截遮罩 */
#env-gate {
  display: none;
}

#env-gate.active {
  display: flex;
}

#app-shell.hidden {
  display: none;
}

/* 表单控件 — 聚焦高亮；允许选中与复制粘贴 */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="search"],
input[type="url"],
input:not([type]),
select,
textarea {
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  touch-action: auto;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #f0b90b !important;
  box-shadow: 0 0 0 2px rgba(240, 185, 11, 0.35);
}

/* 输入框聚焦时 — 复制/粘贴工具栏（Telegram WebApp 等环境） */
.input-clipboard-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  z-index: 85;
  display: flex;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.5rem 1rem;
  background: #141821;
  border-top: 1px solid #2b3139;
}

.input-clipboard-bar.hidden {
  display: none;
}

.input-clipboard-btn {
  min-width: 5.5rem;
  padding: 0.45rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #2b3139;
  background: #1e2329;
  color: #f0b90b;
  font-size: 0.8125rem;
  font-weight: 600;
  touch-action: manipulation;
  cursor: pointer;
}

.input-clipboard-btn:active {
  opacity: 0.85;
}

/* 行情数字 — 等宽紧凑 */
.font-mono,
#order-amount,
#order-premium,
#wallet-deposit,
.order-card .text-right > .text-lg,
.order-card .text-right > .text-xs {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* 发布订单 Modal — 渐入渐出 */
#order-modal {
  transition: opacity 300ms ease;
  opacity: 0;
  pointer-events: none;
}

#order-modal.opacity-100 {
  opacity: 1;
  pointer-events: auto !important;
  visibility: visible !important;
  z-index: 110 !important;
}

#order-modal.opacity-0 {
  opacity: 0;
  pointer-events: none !important;
  visibility: hidden;
}

#order-modal:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.order-modal-panel {
  transition: transform 300ms ease, opacity 300ms ease;
}

#order-modal.opacity-0 .order-modal-panel {
  transform: translateY(12px) scale(0.98);
  opacity: 0;
}

#order-modal.opacity-100 .order-modal-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.side-btn.side-active-sell {
  border-color: #f0b90b;
  background: rgba(240, 185, 11, 0.15);
  color: #f0b90b;
}

.side-btn.side-active-buy {
  border-color: #1e9cf0;
  background: rgba(30, 156, 240, 0.15);
  color: #1e9cf0;
}

#btn-submit-order.is-disabled,
#btn-submit-order:disabled {
  background: #2b3139 !important;
  color: #6b7280 !important;
  box-shadow: none !important;
  transform: none !important;
  cursor: not-allowed;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.image-upload-label:active {
  transform: scale(0.99);
}

.qrcode-preview-img,
.proof-image {
  image-rendering: -webkit-optimize-contrast;
}

.qrcode-enlarge .proof-image {
  max-height: 20rem;
}

/* 补全收款全屏页 + 付款凭证 Modal */
#proof-modal.hidden {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

#proof-modal:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.ubei-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0b0e11;
  flex-direction: column;
  overflow: hidden;
}

.ubei-fullscreen:not(.hidden) {
  display: flex;
}

.ubei-fullscreen.hidden {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.ubei-fullscreen-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.75rem;
  border-bottom: 1px solid #2b3139;
  background: #141821;
  flex-shrink: 0;
}

.ubei-fullscreen-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 1.25rem 2rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.ubei-back-btn {
  color: #f0b90b;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  touch-action: manipulation;
}

.ubei-back-btn:active {
  opacity: 0.85;
}

.ubei-global-file-input {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  z-index: 2147483646;
}

.seller-pick-wrap {
  position: relative;
}

.seller-pick-input-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
  z-index: 1;
  pointer-events: none;
}

#btn-seller-info-pick {
  position: relative;
  z-index: 2;
  touch-action: manipulation;
}

#btn-release-proof-pick {
  position: relative;
  z-index: 2;
  touch-action: manipulation;
}

#btn-seller-info-pick:disabled,
#btn-seller-info-pick.pick-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

#seller-info-qrcode-file:disabled {
  pointer-events: none;
}

body.seller-info-open {
  overflow: hidden;
}

body.app-modal-open {
  overflow: hidden;
}

#ubei-confirm-modal:not(.hidden) {
  display: flex !important;
  z-index: 10050 !important;
  pointer-events: auto !important;
  visibility: visible !important;
}

#match-modal:not(.hidden) {
  display: flex !important;
  pointer-events: auto !important;
  z-index: 200 !important;
}

#btn-match-submit:disabled {
  pointer-events: none;
}

.system-notification-root {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.system-notification-toast {
  pointer-events: auto;
  max-width: 20rem;
  width: calc(100% - 2rem);
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid #2b3139;
  background: rgba(24, 26, 32, 0.96);
  color: #eaecef;
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.45;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.system-notification-success {
  border-color: rgba(46, 189, 133, 0.45);
}

.payment-urgent-banner {
  box-shadow: 0 0 0 1px rgba(246, 70, 93, 0.35), 0 8px 24px rgba(246, 70, 93, 0.15);
}

.system-notification-error {
  border-color: rgba(246, 70, 93, 0.45);
}

.system-notification-info,
.system-notification-loading {
  border-color: rgba(240, 185, 11, 0.45);
}

.ui-state-lock {
  position: fixed;
  inset: 0;
  z-index: 2147482000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ui-state-lock.hidden {
  display: none !important;
  pointer-events: none !important;
}

.ui-state-lock-panel {
  min-width: 12rem;
  padding: 1.25rem 1.5rem;
  border-radius: 0.875rem;
  border: 1px solid #2b3139;
  background: #181a20;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

body.ui-state-locked {
  overflow: hidden;
}

.order-card.status-expired {
  opacity: 0.55;
  filter: grayscale(0.35);
}

.order-card.status-expired .status-expired-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  background: rgba(156, 163, 175, 0.15);
  border: 1px solid rgba(156, 163, 175, 0.25);
}

.proof-upload-success .proof-upload-badge {
  line-height: 1.4;
}

.sync-refresh-banner {
  background: rgba(240, 185, 11, 0.12);
  border: 1px solid rgba(240, 185, 11, 0.35);
  color: #f0b90b;
}

.sync-refresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #f6465d;
  box-shadow: 0 0 0 0 rgba(246, 70, 93, 0.6);
  animation: sync-dot-pulse 1.4s ease-in-out infinite;
}

@keyframes sync-dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(246, 70, 93, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(246, 70, 93, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(246, 70, 93, 0);
  }
}
