/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --success-color: #10b981;
    --error-color: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶部导航 */
.top-nav {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo h1 {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.5rem;
}

/* 功能页签 */
.tabs {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.tab {
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    text-decoration: none;
}

.tab:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}

.tab.active {
    background: var(--primary-color);
    color: white;
}

.tab .icon {
    font-size: 1.2rem;
}

/* 语言切换 */
.language-switcher {
    margin-left: auto;
    margin-right: 1rem;
}

.btn-language {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-language:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

#languageIcon {
    font-size: 1.1rem;
}

#languageText {
    font-weight: 500;
}

/* 用户区域 */
.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-login,
.btn-register {
    padding: 0.5rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-login {
    background: var(--primary-color);
    color: white;
}

.btn-login:hover {
    background: var(--primary-dark);
}

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

.btn-register:hover {
    background: var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-logout:hover {
    border-color: var(--error-color);
    color: var(--error-color);
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

.page {
    display: none;
    animation: fadeIn 0.3s;
}

.page.active {
    display: block;
}

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

.page-content h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* 功能卡片 */
.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.feature-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

.feature-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.feature-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* 统计部分 */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.stat-item {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface-color);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* 操作栏 */
.action-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-input,
.form-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.search-input:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 按钮 */
.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    text-decoration: none;
}

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

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
}

.btn-wallet {
    background: var(--secondary-color);
}

.btn-wallet:hover {
    background: #7c3aed;
}

/* OR 分隔线 */
.divider {
    text-align: center;
    margin: 1rem 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: var(--border-color);
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.divider span {
    background: var(--surface-color);
    padding: 0 1rem;
    color: var(--text-secondary);
    position: relative;
}

/* 结果容器 */
.results-container {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    min-height: 300px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
}

/* 提交表单 */
.submit-section {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--surface-color);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.submit-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.login-prompt {
    color: var(--error-color);
    text-align: center;
    padding: 1rem;
}

/* 表单组 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
}

.form-group small {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border-color);
    animation: slideUp 0.3s;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s;
}

.modal-close:hover {
    color: var(--error-color);
}

.exp-content {
    padding: 3rem;
    text-align: center;
}

.coming-soon {
    margin-top: 3rem;
}

.coming-soon .emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 1rem;
}

/* 推广区域 */
.promo-section {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    text-align: center;
}

.promo-title {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.author-link {
    display: inline-block;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    margin-bottom: 0.5rem;
}

.author-link:hover {
    text-decoration: underline;
}

.promo-description {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* 必填标记 */
.required {
    color: var(--error-color);
}

/* textarea */
textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

/* X402 购买页面 */
.token-purchase-section {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    max-width: 600px;
    margin: 0 auto;
}

.token-purchase-section h3 {
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.token-input-group {
    margin-bottom: 1.5rem;
}

.token-input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.token-amount-display {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
    border: 2px dashed var(--border-color);
    user-select: none;
}

.token-info {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
}

.estimated-cost {
    color: var(--text-secondary);
    margin: 0;
}

.estimated-cost span {
    color: var(--primary-color);
    font-weight: 700;
}

/* 风险确认复选框 */
.risk-acknowledgment {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(251, 191, 36, 0.05);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.risk-acknowledgment:hover {
    background: rgba(251, 191, 36, 0.08);
    border-color: rgba(251, 191, 36, 0.5);
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-left: 0;
}

.checkbox-container input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: relative;
    flex-shrink: 0;
    height: 20px;
    width: 20px;
    background-color: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.3s ease;
    margin-top: 2px;
}

.checkbox-container:hover .checkmark {
    border-color: rgba(251, 191, 36, 0.6);
    background-color: rgba(251, 191, 36, 0.05);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: rgba(251, 191, 36, 0.2);
    border-color: rgb(251, 191, 36);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 5px;
    top: 1px;
    width: 6px;
    height: 11px;
    border: solid rgb(251, 191, 36);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-text {
    color: rgb(251, 191, 36);
    font-size: 0.9rem;
    line-height: 1.5;
    font-weight: 500;
}

.warning-info {
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 0.5rem;
    border: 1px solid var(--error-color);
}

.warning-info p {
    margin: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 顶部导航优化 */
    .nav-content {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    
    .logo h1 {
        font-size: 1.2rem;
    }
    
    /* 导航标签优化 */
    .tabs {
        width: 100%;
        justify-content: space-around;
        order: 3;
        gap: 0.5rem;
    }
    
    .tab {
        flex: 1;
        justify-content: center;
        padding: 0.5rem;
        min-width: 0;
    }
    
    .tab .icon {
        font-size: 1.1rem;
    }
    
    .tab .text {
        display: none;
    }
    
    /* 语言切换按钮优化 */
    .language-switcher {
        margin-left: 0;
        margin-right: auto;
        order: 2;
    }
    
    .btn-language {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }
    
    #languageIcon {
        font-size: 1rem;
    }
    
    /* 用户区域优化 */
    .user-section {
        order: 2;
        gap: 0.5rem;
    }
    
    .btn-login,
    .btn-register {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }
    
    .btn-logout {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .username {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* 主内容区域优化 */
    .main-content {
        padding: 0.75rem;
    }
    
    .page-content {
        padding: 1rem;
    }
    
    .page-content h2 {
        font-size: 1.5rem;
    }
    
    .page-content .subtitle {
        font-size: 0.9rem;
    }
    
    /* 功能卡片优化 */
    .feature-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    .feature-icon {
        font-size: 2rem;
        width: 3rem;
        height: 3rem;
    }
    
    .feature-card h3 {
        font-size: 1.2rem;
    }
    
    /* 表单优化 */
    .modal-content {
        width: 95%;
        max-width: 95vw;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header h3 {
        font-size: 1.2rem;
    }
    
    .form-input,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="url"],
    input[type="number"],
    textarea {
        font-size: 16px; /* 防止iOS自动放大 */
    }
    
    /* 按钮优化 */
    .btn-primary,
    .btn-block {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    /* X402支付区域优化 */
    .token-purchase-section {
        padding: 1.5rem;
    }
    
    .token-purchase-section h3 {
        font-size: 1.3rem;
    }
    
    .token-input-group {
        gap: 0.5rem;
    }
    
    .token-input-group label {
        font-size: 0.9rem;
    }
    
    .token-amount-display {
        font-size: 2rem;
        padding: 0.75rem;
    }
    
    /* 风险提示复选框优化 */
    .risk-acknowledgment {
        padding: 0.75rem;
        margin: 1rem 0;
    }
    
    .checkbox-text {
        font-size: 0.85rem;
        line-height: 1.4;
    }
    
    .checkmark {
        width: 18px;
        height: 18px;
    }
    
    .checkbox-container .checkmark:after {
        left: 4px;
        top: 1px;
        width: 5px;
        height: 10px;
    }
    
    /* 警告信息优化 */
    .warning-info {
        padding: 0.75rem;
        margin-top: 1.5rem;
    }
    
    .warning-info p {
        font-size: 0.85rem;
        line-height: 1.4;
    }
    
    /* 推特搜索区域优化 */
    .action-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .search-input {
        width: 100%;
    }
    
    .action-bar .btn-primary {
        width: 100%;
    }
    
    /* 提交区域优化 */
    .submit-section {
        padding: 1.5rem;
        margin-top: 1.5rem;
    }
    
    .submit-section h3 {
        font-size: 1.2rem;
    }
    
    /* Toast 优化 */
    .toast {
        min-width: 240px;
        max-width: 95%;
        font-size: 0.9rem;
    }
}

/* 超小屏幕优化（iPhone SE等） */
@media (max-width: 375px) {
    .nav-content {
        padding: 0.5rem 0.75rem;
    }
    
    .logo h1 {
        font-size: 1.1rem;
    }
    
    .tab {
        padding: 0.4rem 0.3rem;
    }
    
    .tab .icon {
        font-size: 1rem;
    }
    
    .btn-login,
    .btn-register {
        padding: 0.35rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .btn-language {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
    }
    
    #languageText {
        display: none;
    }
    
    .page-content h2 {
        font-size: 1.3rem;
    }
    
    .feature-card {
        padding: 1.25rem;
    }
    
    .token-purchase-section {
        padding: 1.25rem;
    }
    
    .checkbox-text {
        font-size: 0.8rem;
    }
    
    .warning-info p {
        font-size: 0.8rem;
    }
}

/* 横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .nav-content {
        flex-wrap: nowrap;
    }
    
    .tabs {
        order: 2;
        width: auto;
        flex: 1;
    }
    
    .language-switcher {
        order: 3;
    }
    
    .user-section {
        order: 4;
    }
    
    .modal-content {
        max-height: 85vh;
    }
}

/* ================= Toast ================= */
#toastContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px;
    z-index: 2000;
    pointer-events: none; /* 点击穿透 */
}

.toast {
    pointer-events: auto;
    min-width: 260px;
    max-width: 90%;
    background: rgba(30, 41, 59, 0.95);
    color: #fff;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    transform: translateY(-20px);
    opacity: 0;
    transition: transform .2s ease, opacity .2s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success { border-left-color: var(--success-color); }
.toast-error   { border-left-color: var(--error-color); }
.toast-info    { border-left-color: var(--primary-color); }

