/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(31, 41, 55, 0.8);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-hover: rgba(255, 255, 255, 0.08);

    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a78bfa 100%);

    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.1);
    --green-glow: rgba(16, 185, 129, 0.3);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --yellow: #f59e0b;
    --yellow-bg: rgba(245, 158, 11, 0.1);

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    --header-h: 64px;
    --filter-h: 56px;
    --leaderboard-w: 420px;
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== Header ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    font-size: 22px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--accent-glow);
    color: var(--accent-secondary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.header-center {
    flex: 1;
    max-width: 500px;
    margin: 0 32px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 0 16px;
    transition: all var(--transition-normal);
}

.search-box:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.search-box i {
    color: var(--text-muted);
    font-size: 14px;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 10px 12px;
}

.search-box input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-sans);
}

.search-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.search-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.auto-refresh {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-label {
    position: relative;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.toggle-label input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--text-muted);
    border-radius: 20px;
    transition: var(--transition-normal);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-normal);
}

.toggle-label input:checked + .toggle-slider {
    background: var(--accent-primary);
}

.toggle-label input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

.toggle-text {
    font-size: 12px;
    color: var(--text-secondary);
}

.last-update {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.last-update i { font-size: 12px; }

/* ===== Filter Bar ===== */
.filter-bar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 24px;
    background: rgba(10, 14, 26, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 99;
    overflow-x: auto;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.filter-buttons {
    display: flex;
    gap: 4px;
}

.filter-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-btn:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    box-shadow: 0 0 12px var(--accent-glow);
}

.smart-money-shortcuts {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.shortcut-chips {
    display: flex;
    gap: 6px;
}

.chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.chip:hover {
    background: var(--accent-glow);
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
}

.chip .chip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

/* ===== Main Layout ===== */
.main-content {
    display: flex;
    margin-top: calc(var(--header-h) + var(--filter-h));
    height: calc(100vh - var(--header-h) - var(--filter-h));
}

/* ===== Leaderboard Panel ===== */
.leaderboard-panel {
    width: var(--leaderboard-w);
    min-width: var(--leaderboard-w);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    background: rgba(10, 14, 26, 0.4);
}

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

.panel-header h2 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h2 i {
    color: var(--yellow);
    font-size: 14px;
}

.refresh-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.refresh-btn:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

.refresh-btn.spinning i {
    animation: spin 0.8s linear infinite;
}

.leaderboard-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Leaderboard Item */
.lb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    margin-bottom: 4px;
}

.lb-item:hover {
    background: var(--glass-hover);
    border-color: var(--glass-border);
}

.lb-item.active {
    background: var(--accent-glow);
    border-color: rgba(99, 102, 241, 0.3);
}

.lb-rank {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.lb-rank.top-1 {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a1a;
}

.lb-rank.top-2 {
    background: linear-gradient(135deg, #d1d5db, #9ca3af);
    color: #1a1a1a;
}

.lb-rank.top-3 {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.lb-rank.normal {
    background: var(--glass);
    color: var(--text-muted);
}

.lb-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--glass);
    border: 2px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.lb-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lb-avatar i {
    font-size: 14px;
    color: var(--text-muted);
}

.lb-info {
    flex: 1;
    min-width: 0;
}

.lb-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-address-short {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-top: 2px;
}

.lb-stats {
    text-align: right;
    flex-shrink: 0;
}

.lb-pnl {
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.lb-pnl.positive { color: var(--green); }
.lb-pnl.negative { color: var(--red); }

.lb-vol {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Detail Panel ===== */
.detail-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Welcome State */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    animation: pulse-glow 3s ease-in-out infinite;
}

.welcome-icon i {
    font-size: 32px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-state h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-state p {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 400px;
    line-height: 1.6;
}

.welcome-stats {
    display: flex;
    gap: 24px;
    margin-top: 32px;
}

.welcome-stat {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 16px 24px;
    text-align: center;
}

.welcome-stat .stat-value {
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-secondary);
}

.welcome-stat .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* User Detail */
.hidden { display: none !important; }

.user-summary-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    backdrop-filter: blur(10px);
    margin-bottom: 20px;
}

.user-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar i {
    font-size: 24px;
    color: white;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info h2 {
    font-size: 20px;
    font-weight: 700;
}

.user-address {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.user-address code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.copy-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition-fast);
}

.copy-btn:hover { color: var(--accent-secondary); }

.user-metrics {
    display: flex;
    gap: 24px;
    flex-shrink: 0;
}

.metric {
    text-align: center;
    padding: 0 16px;
    border-left: 1px solid var(--glass-border);
}

.metric:first-child { border-left: none; }

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

.metric-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.metric-value.positive { color: var(--green); }
.metric-value.negative { color: var(--red); }

/* Tabs */
.detail-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--glass);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Positions Grid */
.positions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

.position-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all var(--transition-fast);
}

.position-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.position-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.position-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    flex: 1;
    margin-right: 12px;
}

.position-side {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.position-side.yes {
    background: var(--green-bg);
    color: var(--green);
}

.position-side.no {
    background: var(--red-bg);
    color: var(--red);
}

.position-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.pos-detail {
    text-align: center;
}

.pos-detail-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.pos-detail-value {
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-mono);
    margin-top: 2px;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.activity-item:hover {
    background: var(--bg-card-hover);
    border-color: rgba(99, 102, 241, 0.15);
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.activity-icon.buy {
    background: var(--green-bg);
    color: var(--green);
}

.activity-icon.sell {
    background: var(--red-bg);
    color: var(--red);
}

.activity-icon.other {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.activity-info {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.activity-amount {
    text-align: right;
    flex-shrink: 0;
}

.activity-value {
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.activity-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Loading Skeleton ===== */
.loading-skeleton {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}

.skeleton-row {
    height: 56px;
    background: linear-gradient(90deg, var(--glass) 25%, var(--glass-hover) 50%, var(--glass) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-md);
    animation: shimmer 1.5s ease-in-out infinite;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 12px;
}

.loading-spinner i {
    font-size: 24px;
    color: var(--accent-secondary);
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.4;
}

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

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    font-size: 13px;
    animation: toast-in 0.3s ease forwards;
    max-width: 400px;
}

.toast.error { border-left: 3px solid var(--red); }
.toast.success { border-left: 3px solid var(--green); }
.toast.info { border-left: 3px solid var(--accent-primary); }

.toast.fade-out {
    animation: toast-out 0.3s ease forwards;
}

/* ===== Animations ===== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
    50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(99, 102, 241, 0.1); }
}

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

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

.fade-in {
    animation: fade-in 0.3s ease forwards;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    :root {
        --leaderboard-w: 320px;
    }
    .header-center { margin: 0 16px; }
    .smart-money-shortcuts { display: none; }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        height: auto;
    }

    .leaderboard-panel {
        width: 100%;
        min-width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .header-right { display: none; }
    .header-center { max-width: none; margin: 0 12px; }
    .user-summary-card { flex-direction: column; text-align: center; }
    .user-metrics { justify-content: center; }
    .positions-grid { grid-template-columns: 1fr; }
}
