/* ===========================================================
   METI Nav Shell — v2
   macOS-style bottom dock with hierarchical popups, favorites,
   command palette, and breadcrumbs.
   =========================================================== */

:root {
    --ns-bg: rgba(12, 12, 20, 0.86);
    --ns-bg-solid: #0d0d12;
    --ns-bg-2: #16161c;
    --ns-border: rgba(255, 255, 255, 0.08);
    --ns-border-h: rgba(255, 255, 255, 0.16);
    --ns-text: rgba(255, 255, 255, 0.82);
    --ns-text-dim: rgba(255, 255, 255, 0.46);
    --ns-text-bright: #ffffff;
    --ns-accent: #ff4646;
    --ns-accent-2: #ff8a3c;
    --ns-active-bg: rgba(255, 70, 70, 0.13);
    --ns-hover-bg: rgba(255, 255, 255, 0.06);
    --ns-radius: 13px;
    --ns-trans: all 0.22s cubic-bezier(0.2, 0, 0, 1.4);
    --ns-trans-fast: all 0.15s ease;
}

/* Hide the legacy customizer shells we're not using.
   IMPORTANT: do NOT hide .bottom-dock — that's what we render into. */
.corner-dock,
.vertical-dock,
.floating-cards,
.top-bar-nav,
.kpi-strip,
.drawer-tab,
.drawer-overlay,
.drawer-panel,
.nav-settings-trigger,
.nav-settings-overlay {
    display: none !important;
}
.cmd-overlay { display: none !important; }

/* Kill any stale elements from the failed left-sidebar attempt — these
   shouldn't be in the DOM after a refresh, but a stale tab or cached
   build could have them. Force them invisible and out of flow. */
#navShell,
.nav-shell:not(.bottom-dock),
.ns-mobile-toggle,
.ns-mobile-overlay,
.ns-settings-pop {
    display: none !important;
}
body.nav-collapsed .main-content { margin-left: 0 !important; }

/* Main content gets bottom padding so the floating dock doesn't cover it */
body.nav-shell-active .main-content,
body.nav-shell-active main.main-content {
    margin-left: 0 !important;
}

/* ===========================================================
   THE DOCK — fixed at bottom center, frosted glass, macOS style
   =========================================================== */
.bottom-dock,
#navDock {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex !important;
    align-items: flex-end;
    gap: 4px;
    padding: 10px 14px;
    background: var(--ns-bg);
    backdrop-filter: blur(30px) saturate(1.6);
    -webkit-backdrop-filter: blur(30px) saturate(1.6);
    border: 1px solid var(--ns-border);
    border-radius: 22px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.55),
        0 2px 0 rgba(255, 255, 255, 0.04) inset,
        0 -1px 0 rgba(0, 0, 0, 0.4) inset;
    z-index: 10001;
    max-width: calc(100vw - 32px);
}

/* Brand logo */
.ns-dock-logo {
    width: 50px; height: 50px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--ns-accent), var(--ns-accent-2));
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 19px; color: #fff;
    box-shadow: 0 6px 18px rgba(255, 70, 70, 0.3);
    cursor: pointer;
    transition: var(--ns-trans);
    flex-shrink: 0;
    user-select: none;
}
.ns-dock-logo:hover { transform: scale(1.06) rotate(-3deg); }

.ns-dock-sep {
    width: 1px; height: 32px;
    background: rgba(255, 255, 255, 0.07);
    margin: 0 5px;
    align-self: center;
    flex-shrink: 0;
}

/* Generic dock item (used by section icons + favorite icons) */
.ns-dock-item {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 23px;
    cursor: pointer;
    transition: var(--ns-trans);
    position: relative;
    flex-shrink: 0;
    user-select: none;
    background: transparent;
    border: none;
    color: var(--ns-text-bright);
}
.ns-dock-item:hover {
    transform: translateY(-10px) scale(1.22);
    background: rgba(255, 255, 255, 0.05);
}
.ns-dock-item.active {
    background: var(--ns-active-bg);
    box-shadow: 0 4px 16px rgba(255, 70, 70, 0.18);
}
.ns-dock-item.active::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--ns-accent);
    box-shadow: 0 0 10px rgba(255, 70, 70, 0.8);
}
.ns-dock-item.has-popup-open {
    transform: translateY(-6px) scale(1.12);
    background: var(--ns-active-bg);
}

/* Tooltip on hover */
.ns-dock-tip {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: rgba(8, 8, 14, 0.96);
    border: 1px solid var(--ns-border-h);
    padding: 7px 14px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--ns-text-bright);
    opacity: 0;
    pointer-events: none;
    transition: var(--ns-trans-fast);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 10002;
}
.ns-dock-item:hover .ns-dock-tip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.ns-dock-item.has-popup-open .ns-dock-tip { opacity: 0; }

/* Badge */
.ns-dock-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 18px; height: 18px;
    background: var(--ns-accent);
    border-radius: 9px;
    font-size: 9px;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px;
    border: 2px solid var(--ns-bg-solid);
    color: #fff;
}

/* Group wrapper (favorites) */
.ns-dock-group {
    display: flex;
    gap: 3px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.025);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    position: relative;
}
.ns-dock-group::before {
    content: attr(data-label);
    position: absolute;
    top: -14px; left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.42);
    text-transform: uppercase;
    letter-spacing: 1.4px;
    white-space: nowrap;
    padding: 0 2px;
}
.ns-dock-group .ns-dock-item { width: 42px; height: 42px; font-size: 19px; }
.ns-dock-group .ns-dock-item:hover { transform: translateY(-7px) scale(1.18); }

/* Profile circle on the right end */
.ns-dock-profile {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: var(--ns-trans);
    flex-shrink: 0;
    user-select: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.ns-dock-profile:hover { transform: translateY(-6px) scale(1.1); }

/* ===========================================================
   POPUP MENU — appears above a section icon when clicked
   =========================================================== */
.ns-popup {
    position: fixed;
    z-index: 10010;
    background: rgba(8, 8, 14, 0.96);
    backdrop-filter: blur(30px) saturate(1.5);
    -webkit-backdrop-filter: blur(30px) saturate(1.5);
    border: 1px solid var(--ns-border-h);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    min-width: 240px;
    max-width: 320px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 8px;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 0, 0, 1.4);
    pointer-events: none;
}
.ns-popup.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ns-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--ns-border);
    margin-bottom: 6px;
}
.ns-popup-icon {
    width: 32px; height: 32px;
    border-radius: 9px;
    background: var(--ns-active-bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}
.ns-popup-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ns-text-bright);
    flex: 1;
}
.ns-popup-search {
    background: var(--ns-bg-2);
    border: 1px solid var(--ns-border);
    border-radius: 8px;
    padding: 7px 10px;
    color: var(--ns-text-bright);
    font-size: 12px;
    width: 100%;
    margin-bottom: 6px;
    outline: none;
}
.ns-popup-search:focus { border-color: rgba(255, 70, 70, 0.4); }

.ns-popup-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--ns-text);
    font-size: 13px;
    cursor: pointer;
    transition: var(--ns-trans-fast);
    text-decoration: none;
    position: relative;
    user-select: none;
}
.ns-popup-row:hover {
    background: var(--ns-hover-bg);
    color: var(--ns-text-bright);
}
.ns-popup-row.active {
    background: var(--ns-active-bg);
    color: var(--ns-text-bright);
    font-weight: 600;
}
.ns-popup-row-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}
.ns-popup-row-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ns-popup-row-badge {
    background: var(--ns-accent);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 10px;
    flex-shrink: 0;
}
.ns-popup-row-fav {
    background: transparent;
    border: none;
    color: var(--ns-text-dim);
    cursor: pointer;
    font-size: 13px;
    padding: 0 4px;
    opacity: 0;
    transition: var(--ns-trans-fast);
    flex-shrink: 0;
}
.ns-popup-row:hover .ns-popup-row-fav { opacity: 1; }
.ns-popup-row-fav.starred { color: #fbbf24; opacity: 1; }
.ns-popup-row-fav:hover { transform: scale(1.2); color: #fbbf24; }

/* Submenu chevron + nested popup */
.ns-popup-row.has-children .ns-popup-row-chev {
    color: var(--ns-text-dim);
    font-size: 12px;
    flex-shrink: 0;
}
.ns-popup-empty {
    padding: 24px 14px;
    text-align: center;
    color: var(--ns-text-dim);
    font-size: 12px;
}

/* Backdrop that closes popups when clicked */
.ns-popup-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10005;
    background: transparent;
    display: none;
}
.ns-popup-backdrop.show { display: block; }

/* ===========================================================
   PROFILE MENU (small popup off the avatar)
   =========================================================== */
.ns-profile-menu {
    position: fixed;
    z-index: 10010;
    background: rgba(8, 8, 14, 0.96);
    backdrop-filter: blur(30px) saturate(1.5);
    border: 1px solid var(--ns-border-h);
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
    min-width: 220px;
    padding: 10px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}
.ns-profile-menu.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.ns-profile-info {
    padding: 10px 12px;
    border-bottom: 1px solid var(--ns-border);
    margin-bottom: 6px;
}
.ns-profile-name { font-weight: 700; color: var(--ns-text-bright); font-size: 13px; }
.ns-profile-role { font-size: 11px; color: var(--ns-text-dim); margin-top: 2px; }
.ns-profile-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    cursor: pointer; color: var(--ns-text); font-size: 13px;
    transition: var(--ns-trans-fast);
}
.ns-profile-row:hover { background: var(--ns-hover-bg); color: var(--ns-text-bright); }

/* ===========================================================
   BREADCRUMBS (above page title)
   =========================================================== */
.nav-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ns-text-dim);
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.nb-crumb {
    color: var(--ns-text-dim);
    text-decoration: none;
    padding: 3px 8px;
    border-radius: 6px;
    transition: var(--ns-trans-fast);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.nb-crumb:hover { color: var(--ns-text-bright); background: var(--ns-hover-bg); }
.nb-crumb.current { color: var(--ns-text); font-weight: 600; cursor: default; }
.nb-crumb.current:hover { background: transparent; }
.nb-sep { color: var(--ns-text-dim); font-size: 11px; opacity: 0.5; }
.page-title-stack { display: flex; flex-direction: column; gap: 2px; }
/* Hide the legacy h1 — the breadcrumb shows current page already */
body.nav-shell-active .page-title-stack h1.page-title { display: none; }

/* ===========================================================
   COMMAND PALETTE (Ctrl+K)
   =========================================================== */
.ns-cmd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    z-index: 11000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 14vh;
}
.ns-cmd-overlay.show { display: flex; }
.ns-cmd-box {
    width: min(640px, 92vw);
    max-height: 70vh;
    background: rgba(12, 12, 20, 0.98);
    border: 1px solid var(--ns-border-h);
    border-radius: 16px;
    box-shadow: 0 28px 72px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: nsCmdFadeIn 0.18s cubic-bezier(0.2, 0, 0, 1.4);
}
@keyframes nsCmdFadeIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to { opacity: 1; transform: none; }
}
.ns-cmd-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ns-border);
}
.ns-cmd-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--ns-text-bright);
    font-size: 16px;
    outline: none;
}
.ns-cmd-input::placeholder { color: var(--ns-text-dim); }
.ns-cmd-list {
    overflow-y: auto;
    padding: 6px 8px 8px;
    flex: 1;
}
.ns-cmd-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ns-text-dim);
    padding: 10px 12px 4px;
    font-weight: 800;
}
.ns-cmd-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    cursor: pointer;
    color: var(--ns-text);
    font-size: 13px;
    transition: var(--ns-trans-fast);
}
.ns-cmd-row:hover,
.ns-cmd-row.selected {
    background: var(--ns-hover-bg);
    color: var(--ns-text-bright);
}
.ns-cmd-row.selected { background: var(--ns-active-bg); }
.ns-cmd-icon { font-size: 16px; width: 22px; flex-shrink: 0; text-align: center; }
.ns-cmd-name { flex: 1; }
.ns-cmd-sec { font-size: 11px; color: var(--ns-text-dim); }
.ns-cmd-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-top: 1px solid var(--ns-border);
    font-size: 11px;
    color: var(--ns-text-dim);
}
.ns-cmd-footer kbd {
    background: var(--ns-bg-2);
    border: 1px solid var(--ns-border);
    padding: 2px 7px;
    border-radius: 5px;
    font-family: -apple-system, monospace;
    font-size: 10px;
    color: var(--ns-text);
}

/* ===========================================================
   MOBILE — dock becomes scrollable + icon-only
   =========================================================== */
@media (max-width: 768px) {
    #navDock {
        bottom: 12px;
        padding: 8px 10px;
        gap: 2px;
        max-width: calc(100vw - 24px);
        overflow-x: auto;
        overflow-y: visible;
        scrollbar-width: none;
    }
    #navDock::-webkit-scrollbar { display: none; }
    .ns-dock-item { width: 44px; height: 44px; font-size: 20px; }
    .ns-dock-logo { width: 44px; height: 44px; font-size: 17px; }
    .ns-dock-sep { height: 26px; }
    .ns-dock-group .ns-dock-item { width: 38px; height: 38px; font-size: 17px; }
    .ns-popup { min-width: 220px; max-width: calc(100vw - 24px); }
}

/* ===========================================================
   VIEW-AS banner — fixed top bar shown while impersonating
   =========================================================== */
.ns-view-as-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 42px;
    z-index: 11500;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    color: #1a0f00;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: nsVabSlide 0.3s cubic-bezier(0.2, 0, 0, 1.4);
}
@keyframes nsVabSlide { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.ns-vab-left {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}
.ns-vab-icon { font-size: 18px; }
.ns-vab-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-vab-role {
    background: rgba(0, 0, 0, 0.15);
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 10px;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.ns-vab-exit {
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--ns-trans-fast);
}
.ns-vab-exit:hover { background: #000; transform: scale(1.04); }

/* When the bar is active, push the whole app down so nothing overlaps */
body.view-as-active { padding-top: 42px; }

/* ===========================================================
   Wrapper page modes — hide Project Timer chrome when shown
   as standalone Finance / Time Off / Projects.
   =========================================================== */
.project-timer-page.pt-as-finance .pt-admin-tabs,
.project-timer-page.pt-as-timeoff .pt-admin-tabs,
.project-timer-page.pt-as-projects .pt-admin-tabs,
.project-timer-page.pt-as-payroll .pt-admin-tabs {
    display: none !important;
}
.project-timer-page.pt-as-projects .fin-tabs,
.project-timer-page.pt-as-payroll .fin-tabs {
    display: none !important;
}

/* Hide Payroll from the regular Project Timer Finance pane — it now lives
   as its own top-level page in the sidebar. The wrapper mode still shows it. */
.project-timer-page:not(.pt-as-payroll) .fin-tab[data-fin="payroll"] {
    display: none !important;
}
/* Hide the Finance tab itself from regular Project Timer (you said remove
   Finance from Project Tracking — Finance lives as its own top-level page now). */
.project-timer-page:not(.pt-as-finance):not(.pt-as-projects):not(.pt-as-payroll) #ptTabFinance {
    display: none !important;
}

/* When Project Timer is shown as itself (not a wrapper), hide the
   Finance and Time Off top-tabs since those now live as their own
   top-level pages in the sidebar. */
.project-timer-page:not(.pt-as-finance):not(.pt-as-timeoff):not(.pt-as-projects) #ptTabFinance,
.project-timer-page:not(.pt-as-finance):not(.pt-as-timeoff):not(.pt-as-projects) #ptTabTimeoff {
    display: none !important;
}

/* Wrapper-mode body marker — set BEFORE the project timer renders so
   the chrome is hidden from frame 1 (no flash of wrong UI). */
body[data-pt-wrapper] .pt-admin-tabs { display: none !important; }
body[data-pt-wrapper="projects"] .fin-tabs,
body[data-pt-wrapper="payroll"] .fin-tabs { display: none !important; }
