/* ============================================================================
   NAVBAR COLLAPSE ANIMATION BASE
   ============================================================================ */
#mainNavbar {
    transition: transform 0.3s ease-in-out;
}

/* ============================================================================
   MOBILE NAVIGATION DRAWER
   ============================================================================ */
@media (max-width: 767.98px) {
    .navbar-collapse {
        position: fixed;
        top: var(--topbar-height);
        right: 0;
        height: calc(100vh - var(--topbar-height));
        width: 300px;
        background-color: white;
        box-shadow: -2px 0 5px rgba(0,0,0,0.1);
        padding: 20px;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        /* Enable touch scrolling */
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .navbar-collapse.show {
        transform: translateX(0);
    }

    /* Transitioning state (when opening/closing) */
    .navbar-collapse.collapsing {
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        height: calc(100vh - var(--topbar-height)) !important;
    }

    /* Overlay backdrop */
    .navbar-collapse.show::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: -1;
    }

    /* Navigation list styling */
    .navbar-nav {
        flex-direction: column;
        width: 100%;
        padding: 0;
        margin: 0;
        list-style: none;
    }

    /* Individual nav items */
    .nav-item {
        width: 100%;
        padding: 0;
        margin: 0;
    }

    /* Navigation links */
    .navbar-collapse .nav-link {
        display: block;
        padding: 12px 16px;
        color: #333;
        text-decoration: none;
        border-radius: 8px;
        transition: all 0.2s ease;
        font-size: 0.95rem;
        margin-bottom: 4px;
    }

    /* Link hover state */
    .navbar-collapse .nav-link:hover {
        background-color: #f8f9fa;
        color: #0066cc;
        padding-left: 20px;
    }

    /* Active link state */
    .navbar-collapse .nav-link.active {
        background-color: #e7f3ff;
        color: #0066cc;
        font-weight: 600;
        border-left: 3px solid #0066cc;
    }

    /* Section title styling */
    .navbar-collapse .sidebar-section-title {
        display: block;
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: #6c757d;
        margin-top: 24px;
        margin-bottom: 8px;
        padding: 8px 16px;
        background-color: #f8f9fa;
        border-radius: 6px;
        border-bottom: none;
    }

    /* First section title - no top margin */
    .navbar-collapse .sidebar-section-title:first-child {
        margin-top: 0;
    }

    /* Add visual separation before Login/Logout */
    .navbar-collapse .nav-item:last-child {
        margin-top: 24px;
        padding-top: 24px;
        border-top: 1px solid #e6eaf0;
    }

    /* Scrollbar styling (webkit browsers only) */
    .navbar-collapse::-webkit-scrollbar {
        width: 6px;
    }

    .navbar-collapse::-webkit-scrollbar-track {
        background: transparent;
    }

    .navbar-collapse::-webkit-scrollbar-thumb {
        background: #cbd5e0;
        border-radius: 10px;
    }

    .navbar-collapse::-webkit-scrollbar-thumb:hover {
        background: #a0aec0;
    }

    /* Extra padding at bottom for comfortable scrolling */
    .navbar-nav::after {
        content: '';
        display: block;
        height: 20px;
    }

    /* Show all links on mobile */
    #mainNavbar .nav-item {
        display: list-item;
    }
}

/* ============================================================================
   DESKTOP NAVIGATION
   ============================================================================ */
@media (min-width: 768px) {
    /* Hide section titles on desktop - sidebar handles these */
    .navbar-collapse .sidebar-section-title {
        display: none;
    }

    /* Hide management/clinical links on desktop - sidebar handles these */
    #mainNavbar .nav-item:not(.topbar-always-show) {
        display: none;
    }

    /* Always show these on desktop */
    #mainNavbar .nav-item.topbar-always-show {
        display: list-item;
    }
}

/* ============================================================================
   TOPBAR BASE STYLING
   ============================================================================ */
.navbar-logo-top {
    font-family: 'Actor', sans-serif;
    font-size: 1.5rem;
    line-height: 1;
}

.navbar-logo-bottom {
    font-family: 'Agbalumo', serif;
    font-size: 1.25rem;
    line-height: 1;
    margin-top: -0.1rem;
}

:root {
    --topbar-height: 5.75rem;
}

#topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e6eaf0;
}

/* ============================================================================
   MOBILE TOPBAR ADJUSTMENTS
   ============================================================================ */
@media (max-width: 767.98px) {
    :root {
        --topbar-height: 8rem;
    }

    #topbar {
        height: auto; /* Allow height to adjust */
        min-height: var(--topbar-height);
    }

    #topbar .container-fluid {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    /* Ensure logo and toggler are vertically centered */
    #topbar .navbar-brand {
        margin-bottom: 0;
    }
}
