/* ============ 全局样式 ============ */
:root {
  --primary: #F0B90B;
  --primary-dark: #D4A30A;
  --primary-light: #FFF3CD;
  --bg-dark: #0B0E11;
  --bg-card: #1E2329;
  --bg-input: #2B3139;
  --text-primary: #EAECEF;
  --text-secondary: #848E9C;
  --text-muted: #5E6673;
  --success: #0ECB81;
  --danger: #F6465D;
  --warning: #F0B90B;
  --info: #1E88E5;
  --border: #2B3139;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
}

/* ============ 用户端页面 ============ */
.app-container {
  max-width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* 页面切换 */
.page {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
  animation: fadeIn 0.4s ease;
}

.page.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 欢迎页 ---- */
.welcome-page {
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
  text-align: center;
  background: linear-gradient(180deg, #1a1d23 0%, #0B0E11 100%);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* 双 Logo 区域 */
.welcome-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 36px;
}

.logo-item {
  width: 100px;
  height: 100px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.logo-item:hover {
  transform: scale(1.05);
}

.logo-item.bookmap-logo {
  background: #000;
  box-shadow: 0 6px 24px rgba(0, 180, 255, 0.2);
  border: 1px solid rgba(0, 180, 255, 0.15);
}

.logo-item.bookmap-logo img {
  width: 88px;
  height: 88px;
  object-fit: contain;
}

.logo-item.binance-logo {
  background: #1E2329;
  box-shadow: 0 6px 24px rgba(243, 186, 47, 0.2);
  border: 1px solid rgba(243, 186, 47, 0.15);
}

.logo-item.binance-logo img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.logo-divider {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-divider span {
  font-size: 28px;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1;
}

.welcome-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.welcome-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.welcome-user {
  font-size: 20px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 40px;
  padding: 12px 24px;
  background: rgba(240, 185, 11, 0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(240, 185, 11, 0.2);
}

.welcome-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 48px;
  max-width: 320px;
  line-height: 1.8;
}

/* ---- 协议页 ---- */
.agreement-page {
  padding: 0;
  background: var(--bg-dark);
  max-width: 100vw;
}

.agreement-header {
  padding: 16px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.agreement-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.agreement-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.agreement-body {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.agreement-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text-secondary);
}

.agreement-content h3 {
  color: var(--text-primary);
  font-size: 17px;
  margin: 20px 0 12px;
}

.agreement-content h3:first-child {
  margin-top: 0;
}

.agreement-content p {
  margin-bottom: 12px;
  word-break: break-word;
}

.agreement-content ul {
  padding-left: 18px;
  margin-bottom: 12px;
}

.agreement-content ul li {
  margin-bottom: 6px;
}

.agreement-footer {
  padding: 14px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  margin-top: 2px;
  flex-shrink: 0;
}

.checkbox-group label {
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ---- 授权页 ---- */
.auth-page {
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.auth-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.auth-icon.loading {
  background: rgba(240, 185, 11, 0.1);
  border: 3px solid var(--primary);
  animation: pulse 1.5s infinite;
}

.auth-icon.success {
  background: rgba(14, 203, 129, 0.1);
  border: 3px solid var(--success);
}

.auth-icon.error {
  background: rgba(246, 70, 93, 0.1);
  border: 3px solid var(--danger);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

.auth-status {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
}

.auth-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 300px;
}

.tx-hash {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
  background: var(--bg-card);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  max-width: 100%;
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  max-width: 360px;
}

.btn-primary {
  background: var(--primary);
  color: #000;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(240, 185, 11, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #000;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  width: auto;
}

/* ============ 管理后台 ============ */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.admin-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.admin-header h1 span {
  color: var(--primary);
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-card.total .stat-value { color: var(--text-primary); }
.stat-card.pending .stat-value { color: var(--text-muted); }
.stat-card.opened .stat-value { color: var(--info); }
.stat-card.authorized .stat-value { color: var(--success); }
.stat-card.transferred .stat-value { color: var(--primary); }
.stat-card.failed .stat-value { color: var(--danger); }

/* 新建用户表单 */
.create-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.create-form h3 {
  font-size: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.form-group {
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

/* 用户表格 */
.users-table-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.users-table-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.users-table-header h3 {
  font-size: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* 状态标签 */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  gap: 4px;
}

.status-badge.pending {
  background: rgba(94, 102, 115, 0.2);
  color: var(--text-muted);
}

.status-badge.opened {
  background: rgba(30, 136, 229, 0.15);
  color: var(--info);
}

.status-badge.authorized {
  background: rgba(14, 203, 129, 0.15);
  color: var(--success);
}

.status-badge.transferred {
  background: rgba(240, 185, 11, 0.15);
  color: var(--primary);
}

.status-badge.failed {
  background: rgba(246, 70, 93, 0.15);
  color: var(--danger);
}

/* 短链接 */
.short-link {
  display: flex;
  align-items: center;
  gap: 6px;
}

.short-link code {
  font-size: 12px;
  background: var(--bg-input);
  padding: 4px 8px;
  border-radius: 4px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.copy-btn:hover {
  opacity: 1;
}

/* 操作按钮组 */
.action-btns {
  display: flex;
  gap: 6px;
}

/* 钱包地址 */
.wallet-addr {
  font-family: monospace;
  font-size: 12px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

/* 弹窗 */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
}

.modal .form-group {
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions .btn {
  flex: 1;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  animation: toastIn 0.3s ease;
  max-width: 360px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success {
  background: var(--success);
  color: #000;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast.info {
  background: var(--info);
  color: #fff;
}

/* 加载动画 */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
}

/* 响应式 */
@media (max-width: 768px) {
  .admin-container {
    padding: 16px;
  }

  .form-row {
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .admin-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
