/* ============================================
   FLAIR LAYOUT SYSTEM
   Desktop: Fixed Sidebar + Main Content
   Mobile: Full Width + Sticky Bottom Nav
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: var(--bg-surface-0);
    --sidebar-border: var(--border-subtle);
    --mobile-nav-height: 64px;
}

/* ============================================
   BASE LAYOUT
   ============================================ */
body {
    background-color: var(--bg-app);
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Main Content Area */
.main-content {
    flex: 1;
    min-width: 0;
    /* Prevent flex overflow */
    padding: var(--spacing-xl);
    padding-bottom: calc(var(--spacing-xl) + 20px);
}

@media (min-width: 769px) {
    .main-content {
        margin-left: var(--sidebar-width);
        padding-top: var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        padding-bottom: calc(var(--mobile-nav-height) + var(--spacing-lg));
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
    }
}

/* ============================================
   DESKTOP SIDEBAR
   ============================================ */
.sidebar-desktop {
    display: none;
    /* Hidden by default on mobile */
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    z-index: 50;
    padding: var(--spacing-lg);
    flex-direction: column;
}

@media (min-width: 769px) {
    .sidebar-desktop {
        display: flex;
        /* Visible flex on desktop */
    }
}

/* Sidebar Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    margin-bottom: 32px;
    padding-left: 12px;
}

.sidebar-brand .logo-container {
    width: 32px;
    height: 32px;
}

.sidebar-brand .logo-container img {
    width: 100%;
    height: auto;
}

.sidebar-brand .brand-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 20px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* Sidebar Navigation */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

.sidebar-nav .nav-item i {
    font-size: 18px;
    color: var(--text-tertiary);
}

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

.sidebar-nav .nav-item:hover i {
    color: var(--text-primary);
}

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

.sidebar-nav .nav-item.active i {
    color: var(--primary-color);
}

.sidebar-nav .badge-count {
    margin-left: auto;
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Sidebar Footer (User Profile) */
.sidebar-footer {
    position: relative;
    border-top: 1px solid var(--border-subtle);
    padding-top: var(--spacing-md);
    margin-top: auto;
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-profile-btn:hover,
.sidebar-footer.active .user-profile-btn {
    background: var(--bg-surface-2);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-email {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Sidebar Popover Menu */
.sidebar-popover-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    /* Slightly wider */
    margin-bottom: 12px;
    background: var(--bg-surface-0);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    /* Richer shadow */
    border-radius: var(--radius-lg);
    padding: 8px;
    display: none;
    z-index: 100;
    animation: slideUpFade 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-footer.active .sidebar-popover-menu {
    display: block;
}

.menu-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 4px;
}

.menu-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.menu-item:hover {
    background: var(--bg-surface-1);
    color: var(--text-primary);
    transform: translateX(2px);
    /* Subtle nudge */
}

.menu-item i {
    font-size: 16px;
    color: var(--text-tertiary);
    transition: color 0.2s;
}

.menu-item:hover i {
    color: var(--primary-color);
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   MOBILE BOTTOM NAV
   ============================================ */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border-subtle);
    /* Glass panel styles are inherited from .glass-panel utility */
    background: rgba(255, 255, 255, 0.9);
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    width: 60px;
    text-decoration: none;
    color: var(--text-tertiary);
    transition: all 0.2s ease;
}

.mobile-bottom-nav .nav-item i {
    font-size: 20px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-bottom-nav .nav-item span {
    font-size: 10px;
    font-weight: 500;
}

.mobile-bottom-nav .nav-item.active {
    color: var(--primary-color);
}

.mobile-bottom-nav .nav-item.active i {
    transform: translateY(-2px);
    color: var(--primary-color);
}

.nav-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
}

.nav-item.active .nav-avatar {
    border-color: var(--primary-color);
}

.icon-wrapper {
    position: relative;
}

.badge-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--danger-color);
    border-radius: 50%;
    border: 1px solid white;
}

/* --- Global Mobile Menu Styles --- */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-menu-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface-0);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 1.5rem;
    z-index: 1050;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-height: 80vh;
    overflow-y: auto;
}

.mobile-menu-overlay.show {
    display: block;
    opacity: 1;
}

.mobile-menu-sheet.show {
    transform: translateY(0);
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 1rem;
    font-weight: 500;
}

.mobile-menu-item:last-child {
    border-bottom: none;
}

.mobile-menu-item i {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}