/* Alphafusion.io — Sidebar v2.0 (hierarchical collapsible) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

/* ── Sidebar Shell ───────────────────────────────────────── */
.sidebar {
    width: 270px;
    min-width: 270px;
    background: linear-gradient(180deg, #0b111e 0%, #080e1a 100%);
    border-right: 1px solid rgba(255,255,255,0.06);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 0 80px 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}

/* Custom scrollbar */
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

/* ── Logo ────────────────────────────────────────────────── */
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.sidebar-logo a { text-decoration: none; font-size: 1.1rem; }
.sidebar-toggle-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

/* ── User Pill ───────────────────────────────────────────── */
.sidebar-user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    margin: 10px 12px;
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.sidebar-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}
.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #eef2ff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-badge {
    font-size: 0.68rem;
    font-weight: 600;
    color: rgba(238,242,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-user-badge.badge-premium { color: #f59e0b; }
.sidebar-user-badge.badge-pro     { color: #22c55e; }

/* ── Section Container ───────────────────────────────────── */
.sidebar-section { margin-bottom: 1px; }

/* ── Shared item style ───────────────────────────────────── */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(238,242,255,0.65);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
}
.sidebar-item i { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
.sidebar-item:hover {
    background: rgba(255,255,255,0.05);
    color: #eef2ff;
    border-left-color: rgba(59,130,246,0.5);
    text-decoration: none;
}
.sidebar-item.active {
    background: rgba(37,99,235,0.15);
    color: #60a5fa;
    border-left-color: #3b82f6;
    font-weight: 600;
}

/* ── Section Header (collapsible trigger) ────────────────── */
.sidebar-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(238,242,255,0.65);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border-left: 2px solid transparent;
    user-select: none;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}
.sidebar-section-header i:first-child { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
.sidebar-section-header:hover {
    background: rgba(255,255,255,0.04);
    color: #eef2ff;
    border-left-color: rgba(59,130,246,0.3);
}
.sidebar-section-header.open {
    color: #93c5fd;
    border-left-color: #3b82f6;
}

/* Arrow rotation */
.sidebar-arrow {
    font-size: 0.7rem;
    transition: transform 0.25s ease;
    opacity: 0.5;
    margin-left: auto;
}
.sidebar-section-header.open .sidebar-arrow { transform: rotate(180deg); opacity: 1; }

/* ── Section Body (collapsible panel) ───────────────────── */
.sidebar-section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    background: rgba(0,0,0,0.15);
}
.sidebar-section-body.open { max-height: 800px; }

/* ── Sub-section label ───────────────────────────────────── */
.sidebar-subsection-label {
    padding: 6px 20px 4px 36px;
    font-size: 0.68rem;
    font-weight: 700;
    color: rgba(238,242,255,0.28);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-family: 'Inter', sans-serif;
}
.sidebar-subsection-label.mt-2 { margin-top: 6px; }

/* ── Sub-items (deeper indent) ───────────────────────────── */
.sidebar-subitem {
    padding: 7px 20px 7px 36px;
    font-size: 0.82rem;
    color: rgba(238,242,255,0.55);
    border-left: 2px solid transparent;
}
.sidebar-subitem:hover {
    color: #eef2ff;
    background: rgba(255,255,255,0.04);
    border-left-color: rgba(59,130,246,0.4);
}

/* ── Coming Soon items ───────────────────────────────────── */
.sidebar-soon { opacity: 0.55; cursor: default; pointer-events: none; }
.sidebar-soon:hover { background: none; border-left-color: transparent; }
.soon-badge {
    display: inline-block;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: rgba(99,102,241,0.3);
    color: #a5b4fc;
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Logout item ─────────────────────────────────────────── */
.sidebar-logout-item {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 270px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: linear-gradient(180deg, transparent, #080e1a 40%);
}
.sidebar-logout-item .sidebar-item {
    padding: 14px 20px;
    color: rgba(239,68,68,0.7);
}
.sidebar-logout-item .sidebar-item:hover {
    background: rgba(239,68,68,0.08);
    color: #ef4444;
    border-left-color: #ef4444;
}

/* ── Mobile overlay ──────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1039;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 270px;
    padding: 0;
    background: #070c13;
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
}

/* ── Top Bar ─────────────────────────────────────────────── */
.dashboard-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    background: rgba(11,17,30,0.95);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}
.dashboard-topbar-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #eef2ff;
    margin: 0;
}
.dashboard-topbar-title p {
    font-size: 0.8rem;
    color: rgba(238,242,255,0.5);
    margin: 0;
}
.dashboard-topbar-actions { margin-left: auto; }

/* ── Padding wrapper inside main ────────────────────────── */
.main-content > *:not(.dashboard-topbar) { padding: 0 24px; }
.main-content > .row { padding: 0 24px; margin-top: 20px; }
.main-content > .dash-section-header { padding: 0 24px; }
.main-content > .market-tabs { padding: 0 24px; }
.main-content > .market-content { padding: 0 24px; }
.main-content > .insights-grid { padding: 0 24px 32px; }

/* ── Stat Cards ──────────────────────────────────────────── */
.dash-stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: rgba(10,17,32,0.93);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    backdrop-filter: blur(20px);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dash-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}
.dash-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(var(--icon-color, 59,130,246), 0.12);
    color: var(--icon-color, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
/* icon color via CSS var string trick */
.dash-stat-icon { background: color-mix(in srgb, var(--icon-color) 15%, transparent); color: var(--icon-color); }
.dash-stat-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dash-stat-label { font-size: 0.72rem; font-weight: 600; color: rgba(238,242,255,0.45); text-transform: uppercase; letter-spacing: 0.4px; }
.dash-stat-value { font-size: 1.1rem; font-weight: 700; color: #eef2ff; }

/* ── Section Headers ─────────────────────────────────────── */
.dash-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(238,242,255,0.45);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 20px 0 12px;
}
.dash-section-header i { color: #3b82f6; }

/* ── Quick Widget Cards ──────────────────────────────────── */
.dash-widget-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: rgba(10,17,32,0.93);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    backdrop-filter: blur(20px);
    color: #eef2ff;
    transition: all 0.2s ease;
}
.dash-widget-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.35);
    border-color: rgba(59,130,246,0.3);
    color: #eef2ff;
}
.dash-widget-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--w-color) 15%, transparent);
    color: var(--w-color);
}
.dash-widget-title { font-size: 0.85rem; font-weight: 600; color: #eef2ff; }
.dash-widget-sub   { font-size: 0.72rem; color: rgba(238,242,255,0.45); margin-top: 1px; }
.dash-widget-arrow { font-size: 0.7rem; color: rgba(238,242,255,0.3); }

/* ── Market tabs overrides (keep existing functionality) ─── */
.market-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.market-tab {
    padding: 8px 22px;
    background: rgba(30,35,50,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: rgba(238,242,255,0.6);
    transition: all 0.2s ease;
}
.market-tab.active {
    background: rgba(37,99,235,0.2);
    border-color: rgba(59,130,246,0.4);
    color: #60a5fa;
}
.market-content { display: none; }
.market-content.active { display: block; animation: fadeIn 0.4s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Insight grid & boxes (keep existing) ────────────────── */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 8px;
}
.insight-box {
    background: rgba(10,17,32,0.93);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    backdrop-filter: blur(20px);
    padding: 18px;
    max-height: 380px;
    overflow-y: auto;
    transition: transform 0.2s ease;
}
.insight-box:hover { transform: translateY(-3px); }
.insight-box::-webkit-scrollbar { width: 4px; }
.insight-box::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.insight-box h3 { font-size: 1rem; margin-bottom: 12px; color: #fff; font-weight: 600; }
.insight-box.gainers h3 { color: #22c55e; }
.insight-box.losers  h3 { color: #ef4444; }
.insight-box.buy     h3 { color: #3b82f6; }
.insight-box.sell    h3 { color: #f97316; }
.insight-item {
    display: flex;
    justify-content: space-between;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.82rem;
}
.insight-item:last-child { border-bottom: none; }
.insight-symbol { font-weight: 600; color: #eef2ff; }
.insight-value.positive { color: #22c55e; }
.insight-value.negative { color: #ef4444; }

/* ── Loading spinners ────────────────────────────────────── */
.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 140px;
}
.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.08);
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Body overrides ──────────────────────────────────────── */
body { padding-top: 0 !important; background: #070c13 !important; }
nav.navbar { display: none !important; }
footer { margin-left: 270px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: 270px;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    footer { margin-left: 0; }
    .sidebar-logout-item { width: 270px; }
    .insights-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 576px) {
    .dashboard-topbar { padding: 12px 16px; }
    .main-content > *:not(.dashboard-topbar),
    .main-content > .row,
    .main-content > .dash-section-header,
    .main-content > .market-tabs,
    .main-content > .market-content,
    .main-content > .insights-grid { padding-left: 12px; padding-right: 12px; }
    .insights-grid { grid-template-columns: 1fr; }
}
