/* ═══════════════════════════════════════════════════════════════
   PPN v3 — Hub Layout (Layout B)
   2-column: Profile sidebar (left) + Content (right)
   Desktop sticky sidebar, Mobile collapses to top + bottom-nav
   ═══════════════════════════════════════════════════════════════ */

/* ── TopNav — minimal, logo only ── */
.topnav-hub {
    position: sticky; top: 0; z-index: 120;
    height: 56px;
    background: rgba(255,255,255,.8);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(147,51,234,.05);
}
.topnav-hub-inner {
    max-width: 1280px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    height: 100%; padding: 0 20px;
}
.topnav-hub-logo {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: inherit;
}
.topnav-hub-logo img {
    width: 32px; height: 32px; border-radius: 10px;
    box-shadow: 0 2px 12px rgba(147,51,234,.18);
}
.topnav-hub-logo span {
    font-family: var(--font-display);
    font-weight: 800; font-size: .95rem;
    color: var(--amethyst-800);
}
.mobile-menu-btn {
    display: none; background: none; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); padding: 6px 12px;
    font-size: 1.2rem; cursor: pointer; color: var(--amethyst-600);
    transition: all .2s;
}
.mobile-menu-btn:hover { background: var(--amethyst-50); }

/* ── Hub Grid ── */
.hub {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: calc(100vh - 56px);
    max-width: 1280px; margin: 0 auto;
}

/* ─────────────────────────────────
   Panel Left — Profile + PV + Nav
   ───────────────────────────────── */
.panel-left {
    background: var(--surface);
    border-right: 1px solid rgba(147,51,234,.05);
    padding: 24px 20px;
    display: flex; flex-direction: column; gap: 20px;
    position: sticky; top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--amethyst-100) transparent;
}
.panel-left::-webkit-scrollbar { width: 4px; }
.panel-left::-webkit-scrollbar-thumb { background: var(--amethyst-100); border-radius: 4px; }

/* Profile card */
.panel-profile { text-align: center; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.panel-avatar {
    width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 10px;
    background: var(--gradient-hero);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.75rem; font-weight: 800; color: #fff;
    box-shadow: 0 4px 20px rgba(147,51,234,.25);
    border: 3px solid var(--surface);
}
.panel-name {
    font-family: var(--font-display);
    font-size: 1.05rem; font-weight: 700; color: var(--text);
}
.panel-username {
    font-size: .75rem; color: var(--text-muted); margin-top: 1px;
}
.panel-star {
    display: inline-block; margin-top: 8px;
    background: linear-gradient(135deg, #fde68a, #fbbf24);
    color: #78350f; padding: 4px 16px; border-radius: var(--radius-pill);
    font-size: .7rem; font-weight: 700;
    box-shadow: 0 2px 8px rgba(245,158,11,.15);
}

/* PV Progress */
.panel-pv {
    padding: 16px; background: var(--amethyst-50);
    border-radius: var(--radius-md); border: 1px solid var(--amethyst-100);
}
.panel-pv-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 8px;
}
.panel-pv-label { font-size: .68rem; color: var(--amethyst-700); font-weight: 600; }
.panel-pv-value {
    font-family: var(--font-display);
    font-size: 1.15rem; font-weight: 800; color: var(--amethyst-700);
}
.panel-pv-bar {
    height: 7px; background: var(--amethyst-100);
    border-radius: var(--radius-pill); overflow: hidden;
}
.panel-pv-fill {
    height: 100%; border-radius: var(--radius-pill);
    background: var(--gradient-hero);
    transition: width .8s var(--ease-out);
}
.panel-pv-targets {
    display: flex; justify-content: space-between;
    font-size: .58rem; color: var(--text-muted); margin-top: 4px;
}

/* Navigation */
.panel-nav {
    display: flex; flex-direction: column; gap: 2px;
}
.panel-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: .82rem; font-weight: 500; color: var(--text-secondary);
    text-decoration: none; transition: all .2s;
}
.panel-nav a span:first-child {
    font-size: 1.05rem; width: 24px; text-align: center;
}
.panel-nav a:hover {
    background: var(--amethyst-50); color: var(--amethyst-700);
}
.panel-nav a.active {
    background: var(--amethyst-50); color: var(--amethyst-700);
    font-weight: 600;
}

/* Referral */
.panel-ref {
    padding: 16px; background: var(--bg);
    border-radius: var(--radius-md); margin-top: auto;
}
.panel-ref-label {
    font-size: .7rem; font-weight: 700; color: var(--amethyst-700); margin-bottom: 8px;
}
.panel-ref-input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: .65rem; color: var(--amethyst-600);
    background: var(--surface); font-family: var(--font-mono);
}
.panel-ref-btn {
    width: 100%; margin-top: 8px; padding: 10px;
    background: var(--gradient-hero); color: #fff; border: none;
    border-radius: var(--radius-sm); font-size: .75rem; font-weight: 600;
    cursor: pointer; box-shadow: var(--shadow-glow);
    transition: all .2s; font-family: var(--font-body);
}
.panel-ref-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* Logout */
.panel-logout {
    padding: 10px; width: 100%;
    background: none; border: 1px solid rgba(239,68,68,.15);
    border-radius: var(--radius-sm); color: var(--scarlet);
    font-size: .78rem; font-weight: 500; cursor: pointer;
    transition: all .2s; font-family: var(--font-body);
}
.panel-logout:hover { background: var(--scarlet-50); }

/* ─────────────────────────────────
   Panel Main — Content area
   ───────────────────────────────── */
.panel-main {
    padding: 28px 32px;
    background:
        radial-gradient(ellipse at 25% 20%, rgba(168,85,247,.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(196,181,253,.03) 0%, transparent 50%),
        var(--bg);
    min-height: calc(100vh - 56px);
    overflow-y: auto;
}

/* Greeting */
.hub-greeting { margin-bottom: 24px; }
.hub-greeting h1 {
    font-family: var(--font-display);
    font-size: 1.5rem; font-weight: 800; color: var(--text);
}
.hub-greeting p {
    font-size: .82rem; color: var(--text-muted); margin-top: 2px;
}

/* Stats */
.hub-stats {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
}
.hub-stat {
    display: flex; align-items: center; gap: 16px;
    background: var(--gradient-card);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px;
    transition: all .25s var(--ease-out);
}
.hub-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md); border-color: var(--amethyst-200);
}
.hub-stat-icon {
    width: 46px; height: 46px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.hub-stat-icon.green  { background: var(--emerald-50); }
.hub-stat-icon.purple { background: var(--amethyst-50); }
.hub-stat-icon.blue   { background: var(--sky-50); }
.hub-stat-icon.amber  { background: var(--gold-50); }
.hub-stat-label { font-size: .68rem; color: var(--text-muted); font-weight: 500; }
.hub-stat-value {
    font-family: var(--font-display);
    font-size: 1.2rem; font-weight: 700; margin-top: 2px;
}
.hub-stat-value.accent { color: var(--amethyst-600); }

/* Section title */
.hub-section-title {
    font-family: var(--font-display);
    font-size: .85rem; font-weight: 700; color: var(--text-secondary);
    margin: 28px 0 14px; letter-spacing: .01em;
}

/* Quick actions */
.hub-actions {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.hub-action {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px;
    background: var(--gradient-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    text-decoration: none; color: inherit;
    transition: all .25s var(--ease-out);
}
.hub-action:hover {
    border-color: var(--amethyst-200);
    box-shadow: var(--shadow-md); transform: translateY(-2px);
}
.hub-action-icon {
    width: 44px; height: 44px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.hub-action-text { font-size: .82rem; font-weight: 600; color: var(--text); }
.hub-action-sub { font-size: .65rem; color: var(--text-muted); margin-top: 1px; }

/* Total income */
.hub-income {
    margin-top: 28px;
    background: var(--gradient-hero);
    border-radius: var(--radius-xl); padding: 28px 32px;
    color: #fff; position: relative; overflow: hidden;
    box-shadow: var(--shadow-glow);
}
.hub-income::before {
    content: ''; position: absolute; top: -40%; right: -15%;
    width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(255,255,255,.08), transparent 70%);
    border-radius: 50%; pointer-events: none;
}
.hub-income-label {
    font-size: .78rem; color: rgba(255,255,255,.5); font-weight: 500;
    position: relative; z-index: 1;
}
.hub-income-value {
    font-family: var(--font-display);
    font-size: 2.4rem; font-weight: 800; margin-top: 4px;
    position: relative; z-index: 1;
}
.hub-income-unit { font-size: .95rem; color: rgba(255,255,255,.5); font-weight: 400; }

/* ─────────────────────────────────
   Mobile Responsive
   ───────────────────────────────── */
@media (max-width: 1024px) {
    .mobile-menu-btn { display: block; }

    .hub { grid-template-columns: 1fr; }

    .panel-left {
        position: fixed; top: 56px; left: 0; bottom: 0; width: 300px;
        z-index: 110; transform: translateX(-100%);
        transition: transform .35s var(--ease-out);
        box-shadow: 4px 0 24px rgba(88,28,135,.08);
        height: calc(100vh - 56px);
    }
    .panel-left.open { transform: translateX(0); }

    .panel-overlay {
        display: none; position: fixed; inset: 0; top: 56px;
        background: rgba(59,7,100,.18); backdrop-filter: blur(3px);
        z-index: 109;
    }
    .panel-overlay.active { display: block; }

    .panel-main {
        padding: 20px 16px;
        padding-bottom: calc(var(--nav-height) + 24px);
        min-height: calc(100vh - 56px);
    }

    .hub-stats { grid-template-columns: repeat(2, 1fr); }
    .hub-actions { grid-template-columns: repeat(2, 1fr); }
    .hub-income-value { font-size: 1.8rem; }
}

@media (max-width: 480px) {
    .hub-stats { grid-template-columns: 1fr; }
    .hub-actions { grid-template-columns: 1fr; }
    .hub-stat { padding: 16px; }
    .hub-income { padding: 24px; }
    .hub-income-value { font-size: 1.5rem; }
}

/* Desktop: ซ่อน bottom-nav */
@media (min-width: 1025px) {
    .bottom-nav { display: none; }
    .mobile-menu-btn { display: none; }
}

/* ── TopNav right area ── */
.topnav-hub-right {
    display: flex; align-items: center; gap: 10px;
}
.topnav-logout {
    padding: 7px 16px; border-radius: var(--radius-pill);
    font-size: .78rem; font-weight: 600; cursor: pointer;
    background: none; border: 1px solid rgba(239,68,68,.18);
    color: var(--scarlet); font-family: var(--font-body);
    transition: all .2s;
}
.topnav-logout:hover {
    background: var(--scarlet-50); border-color: rgba(239,68,68,.3);
}

/* ── Desktop: ซ่อนปุ่ม logout บน topnav (ใช้ในแถบซ้ายแทน) ── */
@media (min-width: 1025px) {
    .topnav-logout { display: none; }
}
