/* 现代化 AFC DApp 样式 */

/* 全局变量 */
:root {
    --primary: #ffd700;
    --primary-dark: #e6c200;
    --secondary: #ffb347;
    --accent: #10b981;
    --background: #0f0f0f;
    --surface: #1a1a1a;
    --surface-light: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #a0a0a0;
    --border: #333333;
    --border-light: #444444;
    --success: #10b981;
    --warning: #ff8c00;
    --error: #ff4444;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(255, 215, 0, 0.2), 0 2px 4px -1px rgba(255, 215, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(255, 215, 0, 0.3), 0 4px 6px -2px rgba(255, 215, 0, 0.15);
}

/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 加载动画 */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loader-overlay p {
    color: var(--text-secondary);
    font-size: 14px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 主应用容器 */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 导航栏 */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-brand i {
    font-size: 24px;
    color: var(--primary);
}

.brand-text {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

/* 用户信息 */
.user-info {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
}

.user-address {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-family: 'Monaco', 'Menlo', monospace;
}

.user-address i {
    color: var(--primary);
}

/* 连接提示 */
.connect-prompt {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 16px 24px;
    text-align: center;
    display: none;
}

.prompt-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: white;
}

.prompt-content i {
    font-size: 18px;
    animation: pulse 2s infinite;
}

.prompt-content p {
    margin: 0;
    font-weight: 500;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

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

/* 标签切换器 */
.tab-switcher {
    display: flex;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--surface-light);
}

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

.tab-btn i {
    font-size: 16px;
}

/* 标签内容 */


/* Final Tab Visibility Logic */
.tab-content {
    padding: 20px;
    background-color: #1c1c1c;
    border-radius: 8px;
    margin-top: 10px;
    animation: fadeIn 0.5s ease-in-out;
    display: block; /* Utility classes */
    opacity: 1; /* Ensure it's not transparent by default */
}

.tab-content.hidden {
    display: none !important; /* Use !important to ensure this rule always applies */
}

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

/* 区块样式 */
.section {
    margin-bottom: 32px;
}

.section-header {
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header i {
    color: var(--primary);
    font-size: 18px;
}

/* 信息网格 - 2x2 网格布局 */
.info-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto auto !important;
    gap: 20px !important;
    width: 100% !important;
    margin-bottom: 24px;
    box-sizing: border-box !important;
}

/* 确保父容器不限制宽度 */
.section {
    width: 100% !important;
    max-width: none !important;
}

.tab-content {
    width: 100% !important;
    max-width: none !important;
}

/* 确保每个 info-item 都在正确的位置和等宽 */
.info-item:nth-child(1) { 
    grid-column: 1; 
    grid-row: 1; 
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
}
.info-item:nth-child(2) { 
    grid-column: 2; 
    grid-row: 1; 
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
}
.info-item:nth-child(3) { 
    grid-column: 1; 
    grid-row: 2; 
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
}
.info-item:nth-child(4) { 
    grid-column: 2; 
    grid-row: 2; 
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
}

.info-item {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: all 0.2s ease;
    min-height: 100px;
    position: relative;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    flex: 1 1 0 !important;
}

.info-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.info-item .label {
    display: block;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.info-item .value {
    display: block;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

/* 移动端响应式设计 - 所有屏幕都保持 2x2 网格 */
@media (max-width: 480px) {
    .info-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto !important;
        gap: 12px !important;
    }
    
    .info-item {
        padding: 12px !important;
        min-height: 80px !important;
    }
    
    .info-item .label {
        font-size: 12px !important;
        margin-bottom: 6px !important;
    }
    
    .info-item .value {
        font-size: 14px !important;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto !important;
        gap: 16px !important;
    }
    
    .info-item {
        padding: 16px !important;
        min-height: 90px !important;
    }
    
    .info-item .label {
        font-size: 13px !important;
    }
    
    .info-item .value {
        font-size: 16px !important;
    }
}

@media (min-width: 769px) {
    .info-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto !important;
        gap: 20px !important;
    }
}

/* 标签切换样式 */
.tab-content {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tab-content.active {
    display: block;
    opacity: 1;
}

/* The !important visibility override has been removed as part of the refactor. */

/* 确保全网内容区域有最小高度，避免看起来像空白 */
#global-content {
    min-height: 200px;
}

/* 收益明细按钮 */
.income-details-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    border: none;
    cursor: pointer;
}

.income-details-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    filter: brightness(1.1);
}

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

.income-details-btn i:first-child {
    font-size: 18px;
}

.income-details-btn i:last-child {
    font-size: 14px;
    opacity: 0.8;
}

.income-details-btn span {
    flex: 1;
    text-align: center;
    margin: 0 16px;
}

@media (max-width: 640px) {
    .income-details-btn {
        padding: 14px 16px;
        font-size: 15px;
    }
    
    .income-details-btn i:first-child {
        font-size: 16px;
    }
}

/* 直推列表样式 */
.referral-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.referral-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.referral-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.referral-item.placeholder {
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
}

.wallet-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.wallet-address {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.wallet-level {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.referral-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    text-align: right;
}

.detail-item {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.4;
}

.detail-item.node-yes {
    color: var(--success);
    font-weight: 600;
}

.detail-item.node-no {
    color: var(--text-muted);
    font-weight: 500;
}

@media (max-width: 640px) {
    .referral-item {
        padding: 14px 16px;
        /* 保持水平布局，不改为垂直 */
        flex-direction: row;
        align-items: flex-start;
        gap: 10px;
    }
    
    .wallet-info {
        flex: 1;
    }
    
    .wallet-address {
        font-size: 14px;
        font-weight: 600;
    }
    
    .wallet-level {
        font-size: 11px;
    }
    
    .referral-details {
        /* 保持右对齐 */
        align-items: flex-end;
        text-align: right;
        gap: 4px;
        flex-shrink: 0;
    }
    
    .detail-item {
        font-size: 11px;
    }
}

/* 余额卡片 */
.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.balance-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.balance-card.highlight::before {
    background: linear-gradient(90deg, var(--accent), var(--warning));
}

.balance-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.balance-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.balance-card.highlight .balance-icon {
    background: var(--accent);
}

.balance-info {
    flex: 1;
}

.balance-label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.balance-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-accent:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn:disabled:hover {
    background: var(--primary);
    transform: none;
    box-shadow: none;
}

.btn-secondary:disabled:hover {
    background: var(--secondary);
}

.btn-accent:disabled:hover {
    background: var(--accent);
}

/* 操作按钮组 */
.action-buttons {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* 信息列表 */
.info-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.info-row:last-child {
    border-bottom: none;
}

.info-row:hover {
    background: var(--surface-light);
}

.info-row .label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.info-row .value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
}

.value-with-link {
    display: flex;
    align-items: center;
    gap: 12px;
}

.link {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s ease;
}

.link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* 统计网格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
}

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

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.stat-icon.bnb {
    background: #f0b90b;
}

.stat-icon.afc {
    background: var(--primary);
}

.stat-icon.burn {
    background: var(--error);
}

.stat-info {
    flex: 1;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* 底部 */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 24px;
    text-align: center;
    margin-top: auto;
}

.footer p {
    color: var(--text-muted);
    font-size: 14px;
}

/* 收益明细分页按钮尺寸优化 */
.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pagination-controls .btn {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 8px;
    min-width: auto;
}

.pagination-controls #page-info {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .balance-grid,
    .info-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        justify-content: center;
    }
    
    .info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .value-with-link {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .brand-text {
        font-size: 20px;
    }
    
    .balance-card {
        flex-direction: column;
        text-align: center;
    }
    
    .balance-icon {
        margin: 0 auto;
    }
}
