/* ==========================================================================
   Navigation Rail & Layout System — 72px Dark Rail with Gradient Accents
   ========================================================================== */

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-app);
}

/* --------------------------------------------------------------------------
   Left Navigation Rail (72px desktop)
   -------------------------------------------------------------------------- */
.nav-rail {
    width: 72px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-16) 0;
    z-index: var(--z-sidebar);
    flex-shrink: 0;
    transition: background var(--ease-normal), border-color var(--ease-normal);
}

.nav-rail-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: var(--space-16);
}

/* Brand / Logo Tile: 48px square, 12px radius, gradient with glow */
.nav-brand {
    width: 48px;
    height: 48px;
    background: var(--grad-brand);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 20px;
    font-weight: 700;
    box-shadow: var(--shadow-glow);
    cursor: pointer;
    user-select: none;
    transition: transform var(--ease-normal), box-shadow var(--ease-normal);
}
.nav-brand:hover {
    transform: scale(1.04);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.5);
}
.nav-brand svg {
    width: 24px;
    height: 24px;
    stroke: #ffffff;
    fill: none;
}

/* Nav Item Stack */
.nav-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    width: 100%;
    align-items: center;
}

.nav-item {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--ease-normal);
    border: none;
    outline: none;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.75;
    stroke: currentColor;
    fill: none;
    transition: stroke var(--ease-normal), transform var(--ease-normal);
}

.nav-item:hover {
    background: rgba(26, 36, 56, 0.6);
    color: var(--text-primary);
}
[data-theme="light"] .nav-item:hover {
    background: rgba(238, 242, 248, 0.8);
}

.nav-item.active {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

/* 3px gradient vertical bar along the left edge */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    background: var(--grad-brand);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}

/* Dynamic Sidebar & Mobile Nav Badges */
.nav-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--grad-brand);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4.5px;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 2;
    transition: transform 150ms cubic-bezier(0.16, 1, 0.3, 1), opacity 150ms ease;
    animation: badgePop 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-badge.chats-badge-pill {
    background: linear-gradient(135deg, #3B82F6, #6366F1);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.55);
}

.nav-badge.stories-badge-pill {
    background: linear-gradient(135deg, #EC4899, #F43F5E);
    box-shadow: 0 2px 8px rgba(236, 72, 153, 0.55);
}

.nav-badge.discover-badge-pill {
    background: linear-gradient(135deg, #10B981, #06B6D4);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.55);
}

.nav-badge.notif-badge-pill {
    background: linear-gradient(135deg, #EF4444, #F97316);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.55);
}

@keyframes badgePop {
    0% { transform: scale(0.6); opacity: 0; }
    80% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Bottom Pinned Profile & Settings */
.nav-bottom-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    align-items: center;
}

#nav-user-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
    border: 2px solid transparent;
    transition: border-color var(--ease-normal);
}
.nav-item:hover #nav-user-avatar,
.nav-item.active #nav-user-avatar {
    border-color: var(--accent);
}

/* Clean Nav Tooltips */
.nav-item[data-tooltip] {
    position: relative;
}
.nav-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) scale(0.95);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    box-shadow: var(--shadow-elevated);
    transition: opacity var(--ease-normal), transform var(--ease-normal);
    z-index: var(--z-dropdown);
}
.nav-item[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* --------------------------------------------------------------------------
   Main Content Viewport
   -------------------------------------------------------------------------- */
.main-viewport {
    flex: 1;
    display: flex;
    height: 100%;
    overflow: hidden;
    position: relative;
    background: var(--bg-app);
}

.view-pane {
    flex: 1;
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Mobile Bottom Navigation (Under 768px)
   -------------------------------------------------------------------------- */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(14, 21, 36, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    align-items: center;
    z-index: var(--z-header);
    padding-bottom: env(safe-area-inset-bottom);
}
[data-theme="light"] .mobile-bottom-nav {
    background: rgba(255, 255, 255, 0.96);
}

.mobile-bottom-nav .nav-item {
    width: 44px;
    height: 44px;
}
.mobile-bottom-nav .nav-item.active::before {
    display: none;
}
.mobile-bottom-nav .nav-item.active {
    background: var(--bg-surface-2);
    color: var(--accent);
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .nav-rail {
        display: none;
    }
    .mobile-bottom-nav {
        display: flex;
    }
    #app {
        flex-direction: column;
        padding-bottom: 64px;
    }
}
