/* ============================================================
   TokenBridge Design System
   Dark theme,延续营销站风格
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a2e;
    --bg-input: #1a1a2e;
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --text-muted: #64748b;
    --border: #1e293b;
    --border-focus: #6366f1;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --transition: all 0.2s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

a { color: var(--primary-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Typography ---- */
h1, h2, h3 { font-weight: 700; line-height: 1.3; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

/* ============================================================
   Navigation
   ============================================================ */
.nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
}
.nav-inner {
    max-width: 1400px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    height: 64px;
}
.nav-logo {
    font-size: 1.3rem; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    flex-shrink: 0; cursor: pointer;
}
.nav-links { display: flex; gap: 0.25rem; align-items: center; }
.nav-links a, .nav-links button {
    color: var(--text-dim); font-size: 0.875rem; font-weight: 500;
    padding: 0.45rem 0.85rem; border-radius: var(--radius-sm);
    transition: var(--transition); border: none; background: none; cursor: pointer;
    font-family: inherit; white-space: nowrap;
}
.nav-links a:hover, .nav-links button:hover {
    color: var(--text); background: rgba(255,255,255,0.05);
}
.nav-links a.active, .nav-links button.active {
    color: var(--primary-light); background: rgba(99,102,241,0.1);
}

/* User dropdown */
.nav-user {
    position: relative; display: flex; align-items: center;
}
.nav-user-btn {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0.8rem; border-radius: var(--radius-sm);
    background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.3);
    color: var(--text); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: var(--transition);
}
.nav-user-btn:hover { background: rgba(99,102,241,0.2); }
.nav-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.75rem; font-weight: 700;
}
.nav-dropdown {
    display: none; position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden;
    min-width: 180px; box-shadow: var(--shadow); z-index: 200;
}
.nav-dropdown.open { display: block; }
.nav-dropdown a, .nav-dropdown button {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.7rem 1rem; width: 100%; text-align: left;
    font-size: 0.875rem; color: var(--text-dim);
    border: none; background: none; cursor: pointer; transition: var(--transition);
}
.nav-dropdown a:hover, .nav-dropdown button:hover {
    background: rgba(99,102,241,0.15); color: var(--text);
}
.nav-dropdown .divider {
    height: 1px; background: var(--border); margin: 0.25rem 0;
}

/* Language Switcher (marketing) */
.lang-switcher { position: relative; display: flex; align-items: center; }
.lang-btn {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.8rem; border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    color: var(--text-dim); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.lang-btn:hover { border-color: var(--primary); color: var(--text); }
.lang-dropdown {
    display: none; position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden;
    min-width: 150px; box-shadow: var(--shadow); z-index: 200;
}
.lang-dropdown.open { display: block; }
.lang-option {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.7rem 1rem; cursor: pointer;
    font-size: 0.875rem; color: var(--text-dim); transition: var(--transition);
}
.lang-option:hover { background: rgba(99,102,241,0.15); color: var(--text); }
.lang-option.active { color: var(--primary-light); background: rgba(99,102,241,0.1); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.6rem 1.5rem; border-radius: var(--radius-sm); font-weight: 600;
    font-size: 0.9rem; border: none; cursor: pointer; transition: var(--transition);
    font-family: inherit; white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(99,102,241,0.4); }
.btn-outline {
    background: transparent; border: 1px solid var(--border); color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; transition: var(--transition);
}
.card:hover { border-color: rgba(99,102,241,0.3); }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-label {
    display: block; font-size: 0.85rem; font-weight: 500;
    color: var(--text-dim); margin-bottom: 0.4rem;
}
.form-input {
    width: 100%; padding: 0.7rem 1rem;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-size: 0.9rem; font-family: inherit; transition: var(--transition);
    outline: none;
}
.form-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.form-input::placeholder { color: var(--text-muted); }
.form-input:disabled { opacity: 0.5; cursor: not-allowed; }

textarea.form-input { resize: vertical; min-height: 100px; }
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: 0.3rem; }

/* ============================================================
   Stats / Metrics
   ============================================================ */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem;
}
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
}
.stat-card .label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.stat-card .value { font-size: 1.5rem; font-weight: 800; }
.stat-card .sub { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.3rem; }

/* ============================================================
   Table
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 0.75rem 1rem; text-align: left;
    font-size: 0.875rem; border-bottom: 1px solid var(--border);
}
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ============================================================
   Badge / Tag
   ============================================================ */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.2rem 0.6rem; border-radius: 100px;
    font-size: 0.75rem; font-weight: 600;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--info); }

/* ============================================================
   Modal / Dialog
   ============================================================ */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 500;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem;
    width: 90%; max-width: 480px; box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 1rem; }
.modal .modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ============================================================
   Toast / Notification
   ============================================================ */
.toast-container {
    position: fixed; top: 80px; right: 1.5rem; z-index: 1000;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    padding: 0.8rem 1.2rem; border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 500;
    animation: slideIn 0.3s ease-out;
    box-shadow: var(--shadow);
}
.toast-success { background: #065f46; color: #6ee7b7; border: 1px solid #047857; }
.toast-error { background: #7f1d1d; color: #fca5a5; border: 1px solid #991b1b; }
.toast-info { background: #1e3a5f; color: #93c5fd; border: 1px solid #1e40af; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================================
   Layout
   ============================================================ */
.page { padding-top: 64px; min-height: 100vh; }
.page-inner { max-width: 1000px; margin: 0 auto; padding: 2rem; }
.page-header { margin-bottom: 2rem; }
.page-header h1 { margin-bottom: 0.5rem; }
.page-header p { color: var(--text-dim); font-size: 1rem; }

/* Auth pages */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 2rem;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2.5rem;
}
.auth-card h1 { text-align: center; margin-bottom: 0.5rem; font-size: 1.5rem; }
.auth-card .subtitle { text-align: center; color: var(--text-dim); margin-bottom: 2rem; font-size: 0.9rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.85rem; color: var(--text-dim); }
.auth-logo {
    text-align: center; margin-bottom: 1.5rem; font-size: 1.5rem; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

/* ============================================================
   Chat Page Specific
   ============================================================ */
.chat-layout { display: flex; height: calc(100vh - 64px); }
.chat-sidebar {
    width: 280px; background: var(--bg-card); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; flex-shrink: 0;
}
.chat-sidebar-header { padding: 1rem; border-bottom: 1px solid var(--border); }
.chat-list { flex: 1; overflow-y: auto; padding: 0.5rem; }
.chat-item {
    padding: 0.7rem 1rem; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 0.875rem; color: var(--text-dim);
    transition: var(--transition); margin-bottom: 0.2rem;
    display: flex; align-items: center; justify-content: space-between;
}
.chat-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.chat-item.active { background: rgba(99,102,241,0.1); color: var(--primary-light); }
.chat-item .delete-btn {
    opacity: 0; background: none; border: none; color: var(--danger);
    cursor: pointer; font-size: 0.8rem; padding: 0.2rem;
}
.chat-item:hover .delete-btn { opacity: 1; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-messages {
    flex: 1; overflow-y: auto; padding: 2rem;
    display: flex; flex-direction: column; gap: 1.5rem;
}
.chat-msg { display: flex; gap: 0.75rem; max-width: 80%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
}
.chat-msg.user .chat-msg-avatar { background: linear-gradient(135deg, var(--primary), #a855f7); color: white; }
.chat-msg.assistant .chat-msg-avatar { background: var(--bg-input); color: var(--text-dim); }
.chat-msg-content {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0.8rem 1rem;
    font-size: 0.9rem; line-height: 1.7;
}
.chat-msg.user .chat-msg-content {
    background: rgba(99,102,241,0.15); border-color: rgba(99,102,241,0.3);
}
.chat-msg-content pre {
    background: #0d1117; border: 1px solid var(--border);
    border-radius: var(--radius-xs); padding: 0.8rem; margin: 0.5rem 0;
    overflow-x: auto; font-size: 0.85rem;
}
.chat-msg-content code {
    background: rgba(255,255,255,0.1); padding: 0.15rem 0.4rem;
    border-radius: 4px; font-size: 0.85rem;
}
.chat-msg-content pre code { background: none; padding: 0; }

.chat-input-area {
    padding: 1rem 2rem; border-top: 1px solid var(--border);
    display: flex; gap: 0.75rem; align-items: flex-end;
}
.chat-input-area textarea {
    flex: 1; resize: none; min-height: 44px; max-height: 200px;
    padding: 0.7rem 1rem;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-size: 0.9rem; font-family: inherit; outline: none;
    transition: var(--transition);
}
.chat-input-area textarea:focus { border-color: var(--border-focus); }
.chat-input-area select {
    padding: 0.7rem; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-size: 0.85rem; font-family: inherit; outline: none;
}

/* ============================================================
   Pricing Cards (topup page)
   ============================================================ */
.pricing-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem;
}
.pricing-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem; position: relative;
    transition: var(--transition); cursor: pointer;
}
.pricing-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 20px rgba(99,102,241,0.1); }
.pricing-card.selected { border-color: var(--primary); box-shadow: 0 0 30px rgba(99,102,241,0.2); }
.pricing-card.popular { border-color: var(--primary); }
.pricing-card.popular::before {
    content: attr(data-label); position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white; font-size: 0.7rem; font-weight: 700;
    padding: 0.2rem 0.8rem; border-radius: 100px; white-space: nowrap;
}
/* Trial 套餐卡样式 */
.pricing-card.trial {
    border-color: rgba(34,197,94,0.4);
    background: linear-gradient(135deg, rgba(34,197,94,0.04), rgba(99,102,241,0.04));
    position: relative;
}
.pricing-card.trial::before {
    content: attr(data-badge);
    position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white; font-size: 0.7rem; font-weight: 700;
    padding: 0.25rem 0.8rem; border-radius: 100px;
    white-space: nowrap;
}
.pricing-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }
.pricing-desc { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 1rem; }
.pricing-amount { display: flex; align-items: baseline; gap: 0.3rem; margin-bottom: 0.3rem; }
.pricing-currency { font-size: 1.1rem; font-weight: 600; color: var(--text-dim); }
.pricing-value { font-size: 2.5rem; font-weight: 800; }
.pricing-period { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.pricing-features { list-style: none; margin-bottom: 1.5rem; }
.pricing-features li { padding: 0.3rem 0; font-size: 0.85rem; color: var(--text-dim); display: flex; align-items: center; gap: 0.5rem; }
.pricing-features li::before { content: '\2713'; color: var(--success); font-weight: 700; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .nav-links { gap: 0; }
    .nav-links a span.hide-mobile, .nav-links button span.hide-mobile { display: none; }
    .chat-sidebar { display: none; }
    .chat-msg { max-width: 95%; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .pricing-grid { grid-template-columns: 1fr; }
    .page-inner { padding: 1rem; }
    .chat-input-area { padding: 0.75rem 1rem; }
}
