/* ============================================
   MOBILE-FIRST NAVIGATION STYLES
   ============================================ */

/* Base Mobile Styles (Default) */
.navbar {
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 999;
}

.navbar-brand img {
    height: 32px;
    transition: transform 0.2s;
}

.navbar-toggler {
    border: none;
    padding: 0.5rem;
    border-radius: 8px;
}

.navbar-toggler:focus {
    box-shadow: none;
    background-color: #f8f9fa;
}

/* Mobile Menu Collapse */
.navbar-collapse {
    margin-top: 1rem;
    padding: 0;
}

/* Navigation Links - Mobile First */
.navbar-nav {
    width: 100%;
}

.nav-item {
    width: 100%;
    margin-bottom: 0.25rem;
}

.nav-link {
    color: #2c3e50;
    font-weight: 500;
    font-size: 1rem;
    padding: 0.875rem 1rem !important;
    border-radius: 8px;
    /* transition: none; - Removed to prevent double-effect/ghosting */
    display: flex;
    align-items: center;
}

.nav-link i {
    width: 24px;
    font-size: 1.1rem;
}

.nav-link:hover,
.nav-link:active,
.nav-link:focus,
.nav-link.show,
.dropdown:hover > .nav-link {
    color: #0d6efd;
    box-shadow: none;
    transform: none;
}

/* Dropdown Toggle */
.nav-link.dropdown-toggle::after {
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Dropdown Menus - Mobile First */
.dropdown-menu {
    width: 100%;
    border: none;
    border-radius: 0;
    background-color: #f8f9fa;
    padding: 0.25rem 0;
    margin-top: 0.25rem;
    box-shadow: none;
    z-index: 1040 !important;
}

.dropdown-item {
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    font-size: 0.95rem;
    color: #495057;
    border-radius: 6px;
    margin: 0.125rem 0.5rem;
    transition: all 0.15s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: #e9ecef;
    color: #0d6efd;
}

.dropdown-item:active {
    background-color: #0d6efd;
    color: white;
}

.dropdown-item.active {
    background-color: #f8f9fa;
    color: #2c3e50;
    font-weight: 600;
    position: relative;
}

.dropdown-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #0d6efd;
}

.dropdown-divider {
    margin: 0.5rem 1rem;
    opacity: 0.5;
}

/* Nested Dropdowns - Mobile First */
.dropend {
    width: 100%;
}

.dropend .dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 1rem;
}

.dropend .dropdown-toggle::after {
    border: none;
    content: "\F282";
    font-family: "bootstrap-icons";
    font-size: 0.875rem;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.dropend .dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(90deg);
}

.dropend>.dropdown-menu {
    position: static !important;
    transform: none !important;
    width: calc(100% - 1rem);
    margin-left: 1rem;
    margin-top: 0.25rem;
    background-color: #ffffff;
    border-left: 3px solid #0d6efd;
    box-shadow: none;
}

.dropend .dropdown-item {
    padding-left: 2rem;
    font-size: 0.9rem;
}

/* User Actions Section - Mobile First */
.navbar-user-actions {
    width: 100%;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid #e9ecef;
}

/* Icon Links (Chat, Reminders) */
.nav-icon-links {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    margin-bottom: 1rem;
}

.nav-icon-link {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem !important;
    font-size: 1.25rem;
    color: #6c757d;
    border-radius: 8px;
    background-color: #f8f9fa;
    transition: all 0.2s ease;
}

.nav-icon-link:hover {
    color: #0d6efd;
    background-color: #e7f1ff;
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.625rem;
    padding: 0.25em 0.5em;
    border: 2px solid #fff;
    min-width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Role Selector - Mobile First */
.role-selector-mobile {
    width: 100%;
    margin-bottom: 0.75rem;
}

.role-badge {
    width: 100%;
    font-size: 0.9rem !important;
    background-color: #f8f9fa !important;
    color: #495057 !important;
    border: 1px solid rgba(222, 226, 230, 0.5) !important;
    border-radius: 50px !important;
    padding: 0.5rem 0.875rem !important;
    font-weight: 600 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    transition: all 0.2s ease !important;
}

.role-badge:hover {
    background-color: #e9ecef !important;
    border-color: #adb5bd !important;
}

.role-badge .text-muted {
    color: #6c757d !important;
    font-weight: 400;
}

/* User Profile - Mobile First */
.user-profile-mobile {
    width: 100%;
}

.user-profile-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.user-profile-toggle:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: #0d6efd;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    text-align: left;
}

.user-name {
    color: #2c3e50;
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.2;
}

.user-role {
    color: #6c757d;
    font-size: 0.8rem;
    margin: 0;
    line-height: 1.2;
}

.user-dropdown-icon {
    color: #6c757d;
    font-size: 1rem;
}

/* User Dropdown Menu */
.user-dropdown-menu {
    width: 100%;
    margin-top: 0.5rem;
}

.user-dropdown-menu .dropdown-item {
    padding: 0.75rem 1rem;
}

.user-dropdown-menu .text-danger {
    color: #dc3545 !important;
}

.user-dropdown-menu .text-danger:hover {
    background-color: #fee;
}

/* Hide desktop-only elements on mobile */
.vr {
    display: none;
}

/* ============================================
   DESKTOP STYLES (min-width: 1200px)
   ============================================ */
@media (min-width: 1200px) {
    .navbar {
        padding: 0.875rem 1.5rem;
    }

    .navbar-brand img {
        height: 42px;
    }

    .navbar-collapse {
        margin-top: 0;
    }

    /* Horizontal Navigation */
    .navbar-nav {
        width: auto;
        flex-direction: row;
        align-items: center;
        gap: 0.25rem;
    }

    .nav-item {
        width: auto;
        margin-bottom: 0;
    }

    .nav-link {
        padding: 0.5rem 1rem !important;
        font-size: 0.95rem;
    }

    /* Desktop Dropdowns */
    .dropdown-menu {
        width: auto;
        min-width: 220px;
        background-color: #ffffff;
        border: 1px solid rgba(0, 0, 0, 0.08);
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        margin-top: 0.5rem;
        padding: 0.5rem;
        position: absolute;
        top: 100%;
        left: 0;
        z-index: 1040 !important;
    }

    /* Invisible bridge to prevent menu closing when crossing the gap */
    .dropdown-menu::before {
        content: '';
        position: absolute;
        top: -0.5rem;
        left: 0;
        width: 100%;
        height: 0.5rem;
    }

    .dropdown-item {
        padding: 0.5rem 1rem;
        margin: 0.125rem 0;
        border-radius: 6px;
    }

    /* Nested Dropdowns - Desktop Hover */
    .dropend {
        position: relative;
    }

    .dropend>.dropdown-menu {
        position: absolute !important;
        left: 100%;
        top: -0.5rem;
        margin-left: 0.75rem;
        margin-top: 0;
        width: auto;
        min-width: 200px;
        border: 1px solid rgba(0, 0, 0, 0.08);
        border-radius: 8px;
        background-color: #ffffff;
    }

    /* Create an invisible hover bridge between parent and submenu */
    .dropend>.dropdown-menu::before {
        content: '';
        position: absolute;
        right: 100%;
        top: 0;
        width: 1rem;
        height: 100%;
        background: transparent;
    }

    .dropend .dropdown-toggle::after {
        content: "\F285";
        transform: none;
    }

    /* Only show submenu when hovering over parent dropdown */
    .dropdown:hover>.dropdown-menu {
        display: block;
    }

    /* User Actions - Desktop Horizontal Layout */
    .navbar-user-actions {
        width: auto;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .nav-icon-links {
        width: auto;
        margin-bottom: 0;
        gap: 0.5rem;
    }

    .nav-icon-link {
        flex: none;
        width: 40px;
        height: 40px;
        padding: 0 !important;
        font-size: 1.1rem;
        background-color: transparent;
    }

    .nav-icon-link:hover {
        background-color: #e7f1ff;
    }

    .vr {
        display: block !important;
        height: 32px;
        opacity: 0.3;
    }

    .role-selector-mobile {
        width: auto;
        margin-bottom: 0;
    }

    .role-badge {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.875rem !important;
    }


    /* Ensure dropdown-menu-end stays within viewport on hover */
    .dropdown:hover>.dropdown-menu.dropdown-menu-end {
        position: absolute;
        right: 0;
        left: auto;
        transform: none;
    }
}

/* Mobile responsive adjustments */
@media (max-width: 1199px) {
    .navbar {
        padding: 0.6rem 0.5rem;
    }

    .navbar-brand img {
        height: 35px;
    }

    /* Fix navbar collapse alignment */
    .navbar-collapse {
        margin-top: 1rem;
    }

    /* Remove center alignment on mobile */
    .navbar-nav.align-items-center {
        align-items: flex-start !important;
    }

    /* Better spacing for nav items on mobile */
    .nav-item {
        width: 100%;
    }

    .nav-link {
        padding: 0.75rem 1rem !important;
        font-size: 1rem;
    }

    /* Nested dropdown styling for mobile */
    .dropend>.dropdown-menu {
        position: static !important;
        transform: none !important;
        margin-left: 1rem;
        margin-top: 0.25rem;
        box-shadow: none;
        border-left: 3px solid #0d6efd;
        border-radius: 0;
        background-color: #f8f9fa;
    }

    .dropend .dropdown-toggle::after {
        transform: rotate(90deg);
    }

    /* Icon links section on mobile */
    .d-flex.align-items-center.gap-3 {
        flex-direction: column;
        align-items: flex-start !important;
        width: 100%;
        gap: 1rem !important;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid #dee2e6;
    }

    /* Icon links wrapper */
    .d-flex.align-items-center.gap-3>.d-flex {
        width: 100%;
        justify-content: flex-start;
        gap: 1rem;
    }

    .nav-icon-link {
        margin-left: 0 !important;
        padding: 0.75rem 1rem !important;
        font-size: 1.3rem;
    }

    /* Role and user dropdowns on mobile */
    .d-flex.align-items-center.gap-3>.dropdown {
        width: 100%;
    }

    .role-badge {
        width: 100% !important;
        justify-content: space-between !important;
        padding: 0.6rem 1rem !important;
        font-size: 0.9rem !important;
    }

    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    /* Dropdown menus on mobile */
    .dropdown-menu {
        width: 100%;
        box-shadow: none;
        border: 1px solid #dee2e6;
    }

    /* Remove vr divider on mobile */
    .vr {
        display: none !important;
    }

    /* Container padding on mobile */
    .navbar>.container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Extra small devices */
@media (max-width: 576px) {
    .navbar {
        padding: 0.5rem 0.25rem;
    }

    .navbar-brand img {
        height: 30px;
    }

    .navbar>.container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .nav-link {
        padding: 0.6rem 0.75rem !important;
        font-size: 0.95rem;
    }

    .dropdown-item {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .role-badge {
        font-size: 0.85rem;
        padding: 0.6rem 0.75rem;
    }
}

/* Scrollable dropdown for many items */
.scrollable-menu {
    max-height: 500px;
    overflow-y: auto;
}