/* ═══════════════════════════════════════════════════════════════
   GROWTHHUB v7 SHELL — Navigation & Layout (Phase 2)
   ───────────────────────────────────────────────────────────────
   A real sidebar (desktop) + bottom tab bar (mobile) replacing the
   floating chip nav. Everything is scoped under body.v7-shell,
   which js/v7-shell.js adds ONLY after it successfully builds —
   if the shell ever fails, the legacy nav comes back untouched.
   ═══════════════════════════════════════════════════════════════ */

:root {
    --v7sb-w: 250px;
    --v7sb-w-collapsed: 74px;
    --v7tab-h: 62px;
}

/* ── retire the legacy floaters (only while the shell is alive) ── */
body.v7-shell #floatingNav,
body.v7-shell #navToggleBtn,
body.v7-shell #quickLinks,
body.v7-shell #quickLinksToggleBtn {
    display: none !important;
}
body.v7-shell-booting #floatingNav,
body.v7-shell-booting #navToggleBtn,
body.v7-shell-booting #quickLinks,
body.v7-shell-booting #quickLinksToggleBtn {
    display: none !important;
}

/* ── hide floating fixed buttons that overlap with the sidebar ── */
/* During booting and after shell loads, settingsBtn sits at left:22px
   which is INSIDE the 250px sidebar. Hide it until shell repositions it. */
body.v7-shell-booting #settingsBtn,
body.v7-shell-booting #globalSoundToggle {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ── desktop-sync-btn: its ⟳ icon renders as '?' on most systems.
   When top-bar is hidden it moves to left:106px (inside the sidebar)
   but floats above it at z-index:10000, showing as a permanent white '?'. 
   The sidebar has its own sync indicator — hide this in v7-shell mode. ── */
body.v7-shell .desktop-sync-btn,
body.v7-shell-booting .desktop-sync-btn {
    display: none !important;
}

/* ── #helpGuideBtn: the ❓ emoji renders as a plain white '?' on many systems.
   The v7-shell sidebar already has a 'Guide' item that fires helpGuideBtn.click()
   so this header button is redundant when the shell is active.
   NOTE: This does NOT affect the red tour guide button (.help-btn) inside 
   #emergencyProgressSection — that is a separate element and untouched. ── */
body.v7-shell #helpGuideBtn,
body.v7-shell-booting #helpGuideBtn {
    display: none !important;
}

/* ═══ SIDEBAR (desktop ≥ 900px) ═══ */
#v7Sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--v7sb-w);
    z-index: 9000;
    display: none;
    flex-direction: column;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    transition: width 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
#v7Sidebar::-webkit-scrollbar { width: 5px; }

@media (min-width: 900px) {
    body.v7-shell #v7Sidebar { display: flex; animation: v7SbIn 0.28s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
    body.v7-shell { padding-left: var(--v7sb-w); transition: padding-left 0.22s cubic-bezier(0.2, 0.8, 0.3, 1); }
    body.v7-shell.v7-sb-collapsed { padding-left: var(--v7sb-w-collapsed); }
    body.v7-shell.v7-sb-collapsed #v7Sidebar { width: var(--v7sb-w-collapsed); }
}
@keyframes v7SbIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.v7-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 14px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 12px;
    border-radius: 10px;
    transition: background 0.15s ease;
    user-select: none;
}
.v7-brand:hover { background: var(--bg-hover); }
.v7-brand:active { background: var(--bg-tertiary); transform: scale(0.98); }
.v7-brand img { width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto; }
.v7-brand-name {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    flex: 1;
}
body.v7-sb-collapsed .v7-brand-name { display: none; }

/* mode segmented control */
.v7-modes {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    margin-bottom: 14px;
}
.v7-mode {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 8px 0;
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.v7-mode:hover { color: var(--text-primary); }
.v7-mode.on {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border-default);
}
.v7-mode.on.v7-mode-emergency { box-shadow: var(--shadow-xs), inset 0 0 0 1px color-mix(in srgb, var(--danger) 55%, transparent); }
body.v7-sb-collapsed .v7-modes { flex-direction: column; }

/* nav sections */
.v7-label {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 8px 10px 6px;
    white-space: nowrap;
}
body.v7-sb-collapsed .v7-label { visibility: hidden; height: 8px; padding: 0; }

.v7-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 9px 10px;
    border-radius: 11px;
    cursor: pointer;
    text-align: left;
    transition: background 0.13s ease, color 0.13s ease, border-color 0.13s ease;
    position: relative;
    white-space: nowrap;
}
.v7-item .ic { font-size: 1rem; width: 22px; text-align: center; flex: 0 0 auto; }
.v7-item .lb { overflow: hidden; text-overflow: ellipsis; }
.v7-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.v7-item.on {
    background: var(--primary-light);
    color: var(--text-primary);
    border-color: color-mix(in srgb, var(--primary) 28%, transparent);
}
.v7-item.on::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: 3px;
    background: var(--gradient-brand);
}
body.v7-sb-collapsed .v7-item { justify-content: center; padding: 10px 0; }
body.v7-sb-collapsed .v7-item .lb { display: none; }
body.v7-sb-collapsed .v7-item.on::before { left: -8px; }

.v7-sep { height: 1px; background: var(--border-subtle); margin: 10px 6px; }
.v7-flex { flex: 1 1 auto; }

/* footer / account */
.v7-foot {
    border-top: 1px solid var(--border-subtle);
    padding-top: 10px;
    margin-top: 10px;
}
.v7-ver {
    text-align: center;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    padding-top: 8px;
    white-space: nowrap;
}
body.v7-sb-collapsed .v7-ver { display: none; }

/* ═══ BOTTOM TAB BAR (mobile < 900px) ═══ */
#v7Tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 9000;
    display: none;
    height: calc(var(--v7tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--glass-bg);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
}
@media (max-width: 899.98px) {
    body.v7-shell #v7Tabbar { display: flex; }
    body.v7-shell { padding-bottom: calc(var(--v7tab-h) + env(safe-area-inset-bottom) + 10px); }
    /* keep floating widgets above the bar */
    body.v7-shell #miniTimer { bottom: calc(var(--v7tab-h) + env(safe-area-inset-bottom) + 12px) !important; }
}
.v7-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.1s ease;
}
.v7-tab .ic { font-size: 1.25rem; line-height: 1; }
.v7-tab:active { transform: scale(0.94); }
.v7-tab.on { color: var(--primary); }

/* ═══ "MORE" SHEET (mobile) ═══ */
#v7SheetBackdrop {
    position: fixed;
    inset: 0;
    z-index: 9400;
    background: rgba(8, 10, 16, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
}
#v7Sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 9401;
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-bottom: none;
    border-radius: 22px 22px 0 0;
    box-shadow: var(--shadow-lg);
    padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
    max-height: 72dvh;
    overflow-y: auto;
}
body.v7-sheet-open #v7SheetBackdrop { display: block; animation: v7Fade 0.18s ease-out; }
body.v7-sheet-open #v7Sheet { display: block; animation: v7Up 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
@keyframes v7Fade { from { opacity: 0; } }
@keyframes v7Up { from { transform: translateY(24px); opacity: 0; } }
.v7-sheet-grip {
    width: 40px; height: 4px;
    border-radius: 99px;
    background: var(--border-strong);
    margin: 2px auto 12px;
}
.v7-sheet-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.v7-sheet-item {
    border: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 14px;
    padding: 12px 4px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.62rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.13s ease, transform 0.1s ease;
}
.v7-sheet-item .ic { font-size: 1.35rem; line-height: 1; }
.v7-sheet-item:active { transform: scale(0.95); }
.v7-sheet-item.on { border-color: color-mix(in srgb, var(--primary) 45%, transparent); background: var(--primary-light); }

@media (prefers-reduced-motion: reduce) {
    #v7Sidebar, body.v7-shell, #v7Sheet, #v7SheetBackdrop { transition: none !important; animation: none !important; }
}
