:root {
    --bg-color: #0d1117;
    --sidebar-bg: rgba(13, 17, 23, 0.95);
    --card-bg: rgba(30, 41, 59, 0.4);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-purple: #8b5cf6;
    --accent-red: #ef4444;
    --accent-blue-glow: rgba(59, 130, 246, 0.4);
    --accent-green-glow: rgba(16, 185, 129, 0.4);
    --sidebar-width: 260px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

h1, h2, h3, .brand-name {
    font-family: 'Outfit', sans-serif;
}

/* Layout Container */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto; /* Enable scrolling */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Custom Scrollbar for Chrome/Safari/Edge */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

.logo-section {
    padding-bottom: 32px;
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 20px;
    box-shadow: 0 0 15px var(--accent-blue-glow);
}

.brand-name {
    display: block;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}

.brand-sub {
    font-size: 10px;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

.nav-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 24px 0 16px;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-item i {
    width: 20px;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), transparent);
    color: var(--text-primary);
    box-shadow: inset 4px 0 0 var(--accent-blue);
    position: relative;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    left: -1px;
    height: 60%;
    width: 3px;
    background: var(--accent-blue);
    box-shadow: 0 0 15px var(--accent-blue);
}

.sidebar-promo {
    margin-top: auto;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.8));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.robot-thumb {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.promo-text h3 {
    font-size: 14px;
    margin-bottom: 4px;
}

.promo-text p {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.btn-more {
    width: 100%;
    background: var(--accent-blue);
    border: none;
    color: white;
    padding: 8px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 24px 40px;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.05), transparent 400px),
                radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.05), transparent 400px);
    width: 100%; /* Ensure full width availability */
    overflow-x: hidden; /* Prevent horizontal scroll on main container */
    overflow-y: auto;
}

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

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

.welcome-user h1 {
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.rank-badge {
    font-size: 12px;
    background: var(--accent-green);
    padding: 4px 12px;
    border-radius: 20px;
    color: #000;
    font-weight: 700;
    box-shadow: 0 0 15px var(--accent-green-glow);
}

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

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.notification-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    border: 2px solid var(--bg-color);
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    border: 1px solid var(--glass-border);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* Glass Cards */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.card {
    padding: 24px;
    width: 100%; /* Default fluid width */
    position: relative;
}

/* Summary Grid */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.summary-cards .card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.summary-cards h2 {
    font-size: 22px;
    margin: 4px 0;
}

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

.status.positive {
    color: var(--accent-green);
    font-size: 13px;
    font-weight: 600;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon.blue { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }
.card-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.card-icon.blue-light { background: rgba(14, 165, 233, 0.1); color: #0ea5e9; }
.card-icon.purple { background: rgba(139, 92, 246, 0.1); color: var(--accent-purple); }

/* Chart Container */
.chart-container {
    margin-bottom: 24px;
    position: relative;
    overflow: visible; /* Allow robot to pop out */
}

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

.robot-glow {
    position: absolute;
    right: 20px;
    top: -60px;
    width: 180px;
    z-index: 2;
}

.robot-main {
    width: 100%;
    filter: drop-shadow(0 0 20px var(--accent-green-glow));
}

.status-running {
    font-size: 10px;
    margin-left: 12px;
    color: var(--accent-green);
    letter-spacing: 1px;
    animation: pulse 2s infinite;
}

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

.chart-body {
    height: 300px;
    width: 100%;
}

.chart-footer-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding-top: 24px;
    border-top: 1px solid var(--glass-border);
    margin-top: 24px;
}

.footer-stat-item p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.footer-stat-item strong {
    font-size: 14px;
    color: var(--text-primary);
}

/* Tables */
.table-container {
    margin-bottom: 24px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.view-all {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 16px;
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* Status Colors for Table */
.win { color: var(--accent-green); background: rgba(16, 185, 129, 0.1); }
.long { color: var(--accent-green); }
.short { color: var(--accent-red); }
.no-trade { color: var(--text-secondary); }

/* Bottom Grid */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.link-box {
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    margin: 16px 0;
}

.link-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    flex: 1;
    font-size: 12px;
}

.copy-btn {
    background: var(--accent-blue);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
}

.referral-details {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.qr-code {
    width: 100px;
    height: 100px;
    background: white;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-code img {
    width: 100%;
    height: 100%;
}

.referral-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.stat-val.green { color: var(--accent-green); font-weight: 700; }

.btn-primary {
    background: linear-gradient(90deg, var(--accent-blue), #2563eb);
    border: none;
    color: white;
    padding: 14px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

/* Rank System */
.current-rank-info {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
}

.rank-mini-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-green);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 800;
}

.progress-bar-container {
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 24px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
    border-radius: 10px;
    box-shadow: 0 0 10px var(--accent-green-glow);
}

.rank-milestones {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.milestone {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.milestone span { font-size: 10px; color: var(--text-secondary); }
.milestone strong { font-size: 13px; }
.milestone .bonus { font-size: 11px; }

/* Last Grid */
.last-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.btn-action {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
    position: relative;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.deposit .btn-icon { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.withdraw .btn-icon { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }
.transfer .btn-icon { background: rgba(139, 92, 246, 0.1); color: var(--accent-purple); }

.btn-content strong { display: block; font-size: 15px; }
.btn-content span { font-size: 11px; color: var(--text-secondary); }

.btn-tag {
    position: absolute;
    right: 16px;
    font-size: 12px;
    font-weight: 600;
}

.deposit .btn-tag { color: var(--accent-green); }
.withdraw .btn-tag { color: var(--accent-blue); }
.transfer .btn-tag { color: var(--accent-purple); }

/* Footer */
.main-footer {
    padding: 40px 0;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--glass-border);
    margin-top: 40px;
    color: var(--text-secondary);
    font-size: 13px;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    text-decoration: none;
    color: var(--text-secondary);
}

.footer-links a:hover {
    color: var(--text-primary);
}

/* --- RESPONSIVE DESIGN --- */

/* Header Mobile Toggle */
.mobile-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 16px;
}

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

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Tablet & Large Mobile (max-width: 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -280px; /* Hide sidebar */
        z-index: 100;
        transition: var(--transition);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        left: 0;
    }

    .mobile-toggle {
        display: flex;
    }

    .main-content {
        padding: 20px; /* Reduced padding for tablet */
        width: 100%;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .robot-glow {
        width: 150px;
        top: -30px;
        right: 10px;
    }
}

/* Small Device (max-width: 768px) */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        background: rgba(255, 255, 255, 0.03);
        padding: 12px;
        border-radius: 12px;
        border: 1px solid var(--glass-border);
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .bottom-grid, .last-grid {
        grid-template-columns: 1fr;
    }

    .robot-glow {
        display: none; /* Hide robot overlap on small mobile to save space */
    }

    .chart-body {
        height: 250px;
    }

    .chart-footer-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .table-scroll {
        overflow-x: auto; /* Enable horizontal scroll for tables */
    }

    table {
        min-width: 600px;
    }

    .rank-milestones {
        grid-template-columns: 1fr;
    }

    .main-footer {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }
}

/* Mobile Small (max-width: 480px) */
@media (max-width: 480px) {
    .welcome-user h1 {
        font-size: 20px;
    }
    
    .card {
        padding: 16px;
    }

    .btn-action {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .btn-tag {
        position: relative;
        right: 0;
        top: 0;
        margin-top: 8px;
    }

    .referral-details {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .qr-code {
        margin-bottom: 20px;
    }

    .stat-row {
        gap: 20px;
    }
}
