/* ============================================================
   NovaX — 通用组件样式
   OKX-Inspired Common Components
   ============================================================ */

/* ------------------------------------------------------------
   1. Reset — 清除浏览器默认样式
   ------------------------------------------------------------ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移动端点击高亮去掉 */
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button {
    font-family: inherit; cursor: pointer; border: none;
    background: none; color: inherit; outline: none; font-size: inherit;
}
input, select, textarea {
    font-family: inherit; font-size: inherit; outline: none;
    border: none; background: none; color: inherit;
}
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ------------------------------------------------------------
   2. 工具类 — 高频使用的快捷 class
   ------------------------------------------------------------ */
.hidden       { display: none !important; }
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-1       { flex: 1; }
.gap-sm       { gap: var(--spacing-sm); }
.gap-md       { gap: var(--spacing-md); }
.gap-lg       { gap: var(--spacing-lg); }
.text-up      { color: var(--color-up) !important; }
.text-down    { color: var(--color-down) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.w-full       { width: 100%; }

/* ------------------------------------------------------------
   3. 加载页 — App 启动时显示
   ------------------------------------------------------------ */
.loading-screen {
    position: fixed; inset: 0;
    background: var(--bg-primary);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}
.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none; /* 淡出后不可点击 */
}
.loading-logo {
    display: flex; align-items: center; gap: var(--spacing-sm);
    margin-bottom: var(--spacing-3xl);
}
.loading-logo .logo-icon {
    font-size: 40px; color: var(--color-brand);
    filter: drop-shadow(0 0 12px rgba(240, 185, 11, 0.3));
}
.loading-logo .logo-text {
    font-size: 30px; font-weight: var(--font-weight-bolder);
    letter-spacing: -0.5px;
}
.loading-spinner {
    width: 28px; height: 28px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------
   4. 顶部导航栏 Header
   ------------------------------------------------------------ */
.app-header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    z-index: 100;
}
/* Logo 区域 */
.header-left {
    display: flex; align-items: center; gap: var(--spacing-sm);
}
.header-left .logo-icon {
    font-size: 22px; color: var(--color-brand);
}
.header-left .logo-text {
    font-size: var(--font-size-xl); font-weight: var(--font-weight-bolder);
    letter-spacing: -0.3px;
}
/* 右侧操作区 */
.header-right {
    display: flex; align-items: center; gap: var(--spacing-sm);
}
.header-btn {
    padding: 6px 12px;
    border-radius: var(--border-radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: all 0.15s;
}
.header-btn:active { background: var(--bg-card-hover); }
.header-avatar {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; padding: 0; border-radius: 50%;
}

/* ------------------------------------------------------------
   5. 底部导航栏 TabBar
   ------------------------------------------------------------ */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(var(--tabbar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-tabbar);
    border-top: 1px solid var(--border-color);
    display: flex; align-items: center;
    justify-content: space-around;
    z-index: 100;
}
.tabbar-item {
    display: flex; flex-direction: column;
    align-items: center; gap: 2px;
    padding: 6px 12px;
    color: var(--text-muted);
    transition: color 0.15s;
    position: relative;
}
.tabbar-item.active    { color: var(--color-brand); }
.tabbar-item .tabbar-icon   { font-size: 22px; line-height: 1; }
.tabbar-item .tabbar-label  {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
}

/* ------------------------------------------------------------
   6. 页面容器
   ------------------------------------------------------------ */
.page {
    display: none;
    min-height: 100vh;
    padding-top: var(--header-height);
    padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + var(--spacing-sm));
}
.page.active { display: block; }
.page-content {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing-lg);
}
/* 登录/注册页 — 居中布局 */
.page.auth-page {
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    padding: var(--spacing-3xl) var(--page-padding);
}

/* ------------------------------------------------------------
   7. 区块标题 Section Header
   ------------------------------------------------------------ */
.section {
    padding: var(--spacing-lg) var(--page-padding);
    margin-bottom: var(--spacing-sm);
}
.section-header {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}
.section-header h3 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
}
.section-more {
    font-size: var(--font-size-sm);
    color: var(--color-brand);
    transition: opacity 0.15s;
}
.section-more:active { opacity: 0.7; }

/* ------------------------------------------------------------
   8. 表单通用样式
   ------------------------------------------------------------ */
.form-group {
    margin-bottom: var(--spacing-lg);
}
.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
    font-weight: var(--font-weight-medium);
}
/* 输入框 */
.form-input {
    width: 100%; height: 44px;
    padding: 0 var(--spacing-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--color-brand); }
.form-input::placeholder { color: var(--text-muted); }
.form-input-file {
    width: 100%; padding: var(--spacing-sm) 0;
    color: var(--text-secondary);
}
/* 下拉选择框的自定义箭头 */
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235e6673' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ------------------------------------------------------------
   9. 按钮系统
   ------------------------------------------------------------ */
/* 主按钮（金色） */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center;
    height: 44px; padding: 0 var(--spacing-3xl);
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    border-radius: var(--border-radius);
    transition: all 0.15s;
}
.btn-primary:active {
    background: var(--btn-primary-hover);
    transform: scale(0.97);
}
.btn-primary:disabled {
    opacity: 0.4; cursor: not-allowed; transform: none;
}
.btn-full { width: 100%; }

/* 次按钮（暗底） */
.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center;
    height: 44px; padding: 0 var(--spacing-3xl);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.15s;
}
.btn-secondary:active { background: var(--bg-card-hover); }

/* ------------------------------------------------------------
   10. 卡片容器
   ------------------------------------------------------------ */
.form-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--border-color);
}
.form-card h3 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--spacing-xl);
}

/* ------------------------------------------------------------
   11. Toast 轻提示
   ------------------------------------------------------------ */
.toast {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 32, 40, 0.95);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: var(--font-size-md);
    z-index: 9999;
    max-width: 80%;
    text-align: center;
    backdrop-filter: blur(12px);
    animation: toastIn 0.25s ease;
}
.toast.error   { background: rgba(246, 70, 93, 0.9); }
.toast.success { background: rgba(14, 203, 129, 0.9); }
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ------------------------------------------------------------
   12. 模态框 Modal
   ------------------------------------------------------------ */
.modal {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: flex-end; justify-content: center;
}
.modal.hidden { display: none; }
.modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.6);
}
.modal-content {
    position: relative;
    width: 100%; max-width: var(--max-width);
    max-height: 72vh;
    background: var(--bg-modal);
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
    overflow: hidden;
    display: flex; flex-direction: column;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.modal-header {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg) var(--spacing-xl);
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
}
.modal-close {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--bg-input);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    transition: background 0.15s;
}
.modal-close:active { background: var(--bg-card-hover); }

/* ------------------------------------------------------------
   13. 空状态提示
   ------------------------------------------------------------ */
.empty-state {
    text-align: center;
    padding: var(--spacing-4xl) var(--spacing-lg);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* ------------------------------------------------------------
   14. 登录/注册
   ------------------------------------------------------------ */
.auth-logo {
    display: flex; align-items: center; gap: var(--spacing-sm);
    margin-bottom: 48px;
}
.auth-logo .logo-icon { font-size: 42px; color: var(--color-brand); }
.auth-logo .logo-text {
    font-size: 34px; font-weight: var(--font-weight-bolder);
    letter-spacing: -0.5px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-2xl);
    border: 1px solid var(--border-color);
}
/* 登录/注册 Tab 切换 */
.auth-tabs {
    display: flex; gap: 0;
    margin-bottom: var(--spacing-2xl);
    background: var(--bg-input);
    border-radius: var(--border-radius);
    padding: 3px;
}
.auth-tab {
    flex: 1; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-muted);
    transition: all 0.2s;
}
.auth-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}
.auth-form { display: none; }
.auth-form.active { display: block; }

/* ------------------------------------------------------------
   15. 语言选择列表
   ------------------------------------------------------------ */
.lang-list {
    overflow-y: auto;
    padding: var(--spacing-sm) 0;
}
.lang-item {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-xl);
    transition: background 0.15s;
}
.lang-item:active { background: var(--bg-card-hover); }
.lang-item .lang-name { font-size: var(--font-size-md); }
.lang-item .lang-check {
    color: var(--color-brand);
    font-size: var(--font-size-lg);
}
.lang-item .lang-check.hidden { visibility: hidden; }

/* ------------------------------------------------------------
   16. 用户下拉菜单
   ------------------------------------------------------------ */
.user-dropdown {
    position: fixed;
    top: calc(var(--header-height) + 4px);
    right: 12px;
    min-width: 200px;
    background: var(--bg-dropdown);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 500;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}
.user-dropdown-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}
.user-dropdown-name {
    display: block;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
}
.user-dropdown-account {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}
.user-dropdown-body { padding: 4px 0; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 16px;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s;
}
.dropdown-item:active { background: var(--bg-card-hover); }
.dropdown-item-danger { color: var(--color-down); }
.dropdown-icon {
    font-size: 16px; width: 20px; text-align: center;
}
.dropdown-value {
    margin-left: auto;
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}
.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ------------------------------------------------------------
   17. 页脚
   ------------------------------------------------------------ */
.footer {
    text-align: center;
    padding: var(--spacing-3xl) var(--spacing-lg);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

/* ------------------------------------------------------------
   18. 状态 Badge
   ------------------------------------------------------------ */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
}
.status-badge.pending   { background: rgba(240, 185, 11, 0.12); color: var(--color-brand); }
.status-badge.approved  { background: var(--color-up-bg); color: var(--color-up); }
.status-badge.completed { background: var(--color-up-bg); color: var(--color-up); }
.status-badge.rejected  { background: var(--color-down-bg); color: var(--color-down); }

/* ------------------------------------------------------------
   19. 各页面初始入场动画
   ------------------------------------------------------------ */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.fade-in { animation: fadeIn 0.25s ease; }

/* ------------------------------------------------------------
   20. 滚动条隐藏（移动端）
   ------------------------------------------------------------ */
::-webkit-scrollbar { width: 0; height: 0; }

/* ------------------------------------------------------------
   21. 安全区适配（iPhone X 以上）
   ------------------------------------------------------------ */
@supports (padding-top: env(safe-area-inset-top)) {
    .app-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }
    .page {
        padding-top: calc(var(--header-height) + env(safe-area-inset-top));
    }
}

/* ------------------------------------------------------------
   22. 下拉刷新 Pull-to-Refresh

/* ------------------------------------------------------------
   22. 小屏幕适配（< 375px）
   ------------------------------------------------------------ */
@media (max-width: 374px) {
    .auth-card { padding: var(--spacing-lg); }
    .page-content { padding: var(--spacing-md); }
    .section { padding: var(--spacing-md) var(--spacing-md); }
    .trade-form { padding: var(--spacing-md); }
    .form-card { padding: var(--spacing-md); }
}

/* --- SVG Icons --- */
.nav-icon-svg, .tabbar-icon svg, .action-icon svg, .header-icon-svg {
    display: block;
    transition: all 0.25s ease;
}
.tabbar-item.active svg {
    filter: drop-shadow(0 0 6px rgba(240, 185, 11, 0.4));
    transform: translateY(-1px);
}
.tabbar-item:active svg {
    transform: scale(0.9);
}
.action-icon svg {
    width: 24px; height: 24px;
}
.home-action-btn:active svg {
    transform: scale(0.85);
    opacity: 0.7;
}
.header-btn svg {
    display: block;
}
.header-btn:active svg {
    transform: scale(0.85);
}
