/* ─── Sidebar Navigation ─── */

/* Sidebar Container */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 224px;
    background: #09090f;
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.1rem 1.25rem 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}
.sidebar-logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #f0f0f5;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}
.sidebar-logo span {
    background: linear-gradient(135deg, #6c5ce7, #00cec9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.sidebar-logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #6c5ce7, #00cec9);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Nav Section */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.75rem;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.25);
    padding: 0.5rem 0.6rem 0.35rem;
    margin-top: 0.4rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.52rem 0.7rem;
    border-radius: 9px;
    text-decoration: none;
    color: rgba(240,240,245,0.55);
    font-size: 0.875rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
    position: relative;
    margin-bottom: 1px;
}
.sidebar-item:hover {
    color: rgba(240,240,245,0.9);
    background: rgba(255,255,255,0.04);
}
.sidebar-item.active {
    color: #a29bfe;
    background: rgba(108,92,231,0.12);
}
.sidebar-item.active .sidebar-icon {
    color: #a29bfe;
}
.sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(240,240,245,0.4);
    transition: color 0.15s;
}
.sidebar-item:hover .sidebar-icon {
    color: rgba(240,240,245,0.7);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}

/* ─── Project Switcher ─── */
.sidebar-project-switcher {
    padding: 0.5rem 0.75rem 0.4rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    position: relative;
}
.sps-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 8px;
    cursor: pointer;
    color: rgba(240,240,245,0.75);
    font-size: 0.8rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    transition: all 0.15s ease;
    text-align: left;
    min-width: 0;
}
.sps-trigger:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.12);
    color: rgba(240,240,245,0.95);
}
.sps-trigger.open {
    background: rgba(108,92,231,0.1);
    border-color: rgba(108,92,231,0.35);
    color: #a29bfe;
}
.sps-emoji {
    font-size: 0.9rem;
    line-height: 1;
    flex-shrink: 0;
}
.sps-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.sps-chevron {
    flex-shrink: 0;
    color: rgba(240,240,245,0.3);
    transition: transform 0.2s ease;
}
.sps-trigger.open .sps-chevron {
    transform: rotate(180deg);
    color: #a29bfe;
}

.sps-dropdown {
    display: none;
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    top: calc(100% - 0.1rem);
    z-index: 300;
    padding-top: 0.25rem;
}
.sps-dropdown.open {
    display: block;
}
.sps-dropdown-inner {
    background: #16161f;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 0.35rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
    backdrop-filter: blur(12px);
}
.sps-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    background: none;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    color: rgba(240,240,245,0.65);
    font-size: 0.8rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    transition: all 0.12s;
    text-align: left;
    min-width: 0;
}
.sps-option:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(240,240,245,0.9);
}
.sps-option-active {
    color: #a29bfe;
}
.sps-option-emoji {
    font-size: 0.85rem;
    flex-shrink: 0;
}
.sps-option-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.sps-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 0.3rem 0;
}
.sps-manage {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 7px;
    text-decoration: none;
    color: rgba(240,240,245,0.4);
    font-size: 0.75rem;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.12s;
}
.sps-manage:hover {
    background: rgba(255,255,255,0.04);
    color: rgba(240,240,245,0.7);
}

/* ─── Global Page Entrance Animation ─── */
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.app, .app-with-sidebar {
    animation: pageEnter 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* ─── Shared Skeleton Shimmer ─── */
@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-global {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

/* App layout shift */
.app-with-sidebar {
    margin-left: 224px;
}

/* Hide topnav nav-links and logo when sidebar is active */
.app-with-sidebar .nav-links {
    display: none !important;
}
.app-with-sidebar .topnav > .topnav-left > .logo,
.app-with-sidebar nav > .topnav > .topnav-left > .logo,
.app-with-sidebar .topnav-left > a.logo:first-child {
    display: none !important;
}

/* Hamburger button (mobile) */
.sidebar-hamburger {
    display: none;
    position: fixed;
    top: 0.8rem;
    left: 0.8rem;
    z-index: 300;
    width: 36px;
    height: 36px;
    background: #111119;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 9px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: rgba(240,240,245,0.7);
    transition: all 0.15s;
}
.sidebar-hamburger:hover {
    background: #16161f;
    border-color: rgba(255,255,255,0.14);
    color: #f0f0f5;
}

/* Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ─── Accessibility: Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    .app, .app-with-sidebar {
        animation: none !important;
    }
    .skeleton-global,
    .sidebar {
        animation: none !important;
        transition: none !important;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 248px;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .app-with-sidebar {
        margin-left: 0;
    }
    .sidebar-hamburger {
        display: flex;
    }
    .app-with-sidebar .topnav {
        padding-left: 3.5rem !important;
    }
}
