/* ==========================================================================
   Modern Navbar Styling: sw_asset/css/topnav_style.css
   ========================================================================== */

.topnav {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 0;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: visible;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    z-index: 9999;
    margin: 20px auto;
    max-width: calc(100% - 40px);
    width: fit-content;
}

.topnav a {
    color: #ffffff;
    text-decoration: none;
    padding: 16px 20px;
    display: block;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    border-radius: 8px;
    margin: 4px;
    position: relative;
    float: left;
}

.topnav a:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: #ffffff;
}

.topnav a.active {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

/* ==========================================================================
   Modern Dropdown Styling
   ========================================================================== */

.dropdownNB {
    float: left;
    overflow: visible;
    position: relative;
}

.dropdownNB .dropbtn {
    background: none;
    border: none;
    color: #ffffff !important;
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    margin: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdownNB .dropbtn:hover,
.dropdownNB:hover .dropbtn {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: #ffffff !important;
}

.dropdownNB .dropbtn .fa-caret-down {
    transition: transform 0.3s ease;
    color: #ffffff;
}

.dropdownNB:hover .dropbtn .fa-caret-down {
    transform: rotate(180deg);
}

/* Modern Dropdown Content */
.dropdownNB-content {
    display: none;
    position: absolute;
    top: calc(100% - 4px);
    left: 0;
    background: #ffffff;
    min-width: 220px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 5000;
    padding: 8px;
    margin-top: 0;
    border: 1px solid rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    animation: dropdownSlide 0.3s ease;
    text-align: left;
}

/* Add invisible bridge to prevent dropdown from disappearing */
.dropdownNB::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 8px;
    background: transparent;
    z-index: 4999;
}

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

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

.dropdownNB-content a {
    color: #333333 !important;
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 8px;
    margin: 2px 0;
    transition: all 0.2s ease;
    font-weight: 400;
    float: none;
    text-align: left;
}

.dropdownNB-content a:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff !important;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.dropdownNB-content a span {
    width: 20px;
    text-align: center;
    color: inherit;
}

/* Enhanced hover detection - DESKTOP ONLY */
@media (hover: hover) and (pointer: fine) {

    .dropdownNB:hover .dropdownNB-content,
    .dropdownNB-content:hover {
        display: block;
    }

    .dropdownNB:hover::after {
        display: block;
    }
}

/* Flyout Sub-menu (Nested Dropdown) */
.dropdownNB-sub {
    position: relative;
}

.dropdownNB-sub-link {
    color: #333333 !important;
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    margin: 2px 0;
    transition: all 0.2s ease;
    font-weight: 400;
}

.dropdownNB-sub-link span {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dropdownNB-sub-link span i {
    width: 20px;
    text-align: center;
}

.dropdownNB-sub-link:hover,
.dropdownNB-sub:hover > .dropdownNB-sub-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #ffffff !important;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.dropdownNB-sub-link:hover *,
.dropdownNB-sub:hover > .dropdownNB-sub-link * {
    color: #ffffff !important;
}

.dropdownNB-sub-content {
    display: none;
    position: absolute;
    top: -8px;
    left: calc(100% + 4px);
    background: #ffffff;
    min-width: 240px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 5001;
    padding: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    animation: dropdownSlide 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
    .dropdownNB-sub:hover > .dropdownNB-sub-content {
        display: block;
    }
}

@media screen and (max-width: 950px) {
    .dropdownNB-sub-content {
        position: relative;
        left: 0;
        top: 0;
        box-shadow: none;
        background: rgba(0, 0, 0, 0.03);
        margin-left: 12px;
        display: block !important;
    }
    .dropdownNB-sub-caret {
        transform: rotate(90deg);
    }
}

/* ==========================================================================
   Logo & Special Navigation Actions
   ========================================================================== */

/* Logo/Home Icon Styling */
.topnav>a:first-child {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px;
    padding: 0;
}

.topnav>a:first-child img {
    filter: brightness(0) invert(1);
    transition: all 0.3s ease;
}

.topnav>a:first-child:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Reset first-child styling for dropdown content */
.dropdownNB-content a:first-child {
    background: none !important;
    border-radius: 8px !important;
    width: auto !important;
    height: auto !important;
    display: flex !important;
    padding: 12px 16px !important;
    margin: 2px 0 !important;
}

.dropdownNB-content a:first-child img {
    filter: none !important;
}

.dropdownNB-content a:first-child:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    transform: translateX(4px) !important;
    border-radius: 8px !important;
}

/* Logout Button Styling */
.topnav a[href*="log=out"] {
    background: rgba(220, 53, 69, 0.8);
    margin-left: auto;
    border-radius: 20px;
    font-weight: 600;
    color: #ffffff !important;
}

.topnav a[href*="log=out"]:hover {
    background: rgba(220, 53, 69, 1);
    transform: translateY(-2px);
    color: #ffffff !important;
}

/* Mobile Menu Hamburger Icon */
.topnav .icon {
    display: none;
    font-size: 20px;
    color: #ffffff !important;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 0;
    /* remove rounded box */
    transition: all 0.3s ease;
    float: right;
    background: transparent;
    /* remove background shade */
    margin: 8px;
    cursor: pointer;
    border: 0px;
}

.topnav .icon:hover {
    background: transparent;
    /* remove hover shade */
    transform: rotate(90deg);
    color: #ffffff !important;
}

/* Color Scheme --default */
.bluishtopnav {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ==========================================================================
   Responsive Design - MOBILE FIRST APPROACH
   ========================================================================== */

@media screen and (max-width: 950px) {
    .topnav {
        border-radius: 20px;
        display: block;
        overflow: hidden;
    }

    /* Hide all navigation items except home and hamburger */
    .topnav a:not(:first-child):not(.icon),
    .dropdownNB {
        display: none;
    }

    /* Show hamburger icon */
    .topnav .icon {
        display: flex !important;
        align-items: center;
        justify-content: center;
        float: right;
        position: relative;
    }

    /* Home icon adjustments for mobile */
    .topnav>a:first-child {
        float: left;
        width: 40px;
        height: 40px;
        margin: 8px;
        border-radius: 50% !important;
        /* Force rounded on mobile */
        background: rgba(255, 255, 255, 0.1) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
    }

    /* When responsive class is active - SHOW ALL ITEMS */
    /* Add padding to the responsive container to create space after logout */
    .topnav.responsive {
        position: relative;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        display: block;
        overflow: visible;
        padding-bottom: 10px;
        /* Add 10px space at bottom */
    }

    /* Position hamburger icon in responsive mode */
    .topnav.responsive .icon {
        position: absolute;
        right: 8px;
        top: 8px;
        float: none;
    }

    /* Show all navigation items in responsive mode */
    .topnav.responsive a:not(.icon) {
        float: none;
        display: block !important;
        text-align: left;
        margin: 2px 8px;
        color: #000000 !important;
        /* Legacy fallback style for readability */
        width: auto;
        height: auto;
        border-radius: 8px;
        padding: 12px 16px;
    }

    /* Show dropdown containers in responsive mode */
    .topnav.responsive .dropdownNB {
        float: none;
        width: auto;
        display: block !important;
        margin: 8px 8px 16px 8px;
        /* Increased bottom margin for gap */
    }

    /* Add extra spacing between dropdown sections */
    .topnav.responsive .dropdownNB:not(:last-of-type) {
        margin-bottom: 20px;
        /* More space between dropdown menus */
    }

    /* Style dropdown buttons in responsive mode */
    .topnav.responsive .dropdownNB .dropbtn {
        display: block !important;
        width: 100%;
        text-align: left;
        padding: 12px 16px;
        color: #ffffff !important;
        margin: 0;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.05);
        margin-bottom: 4px;
        /* Small gap between button and content */
    }

    /* Show dropdown content in responsive mode - ALWAYS VISIBLE */
    .topnav.responsive .dropdownNB-content {
        position: relative;
        display: block !important;
        width: 100%;
        margin: 0;
        box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
        background: rgba(255, 255, 255, 0.95);
        border-radius: 8px;
        margin-top: 4px;
        animation: none;
    }

    /* Reset home icon styling in responsive mode */
    .topnav.responsive>a:first-child {
        background: rgba(255, 255, 255, 0.1) !important;
        border-radius: 50% !important;
        /* Force rounded in responsive mode */
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        margin: 8px !important;
        float: left;
    }

    /* Logout button in responsive mode */
    .topnav.responsive a[href*="log=out"] {
        background: rgba(220, 53, 69, 0.8);
        margin: 2px 8px 10px 8px !important;
        border-radius: 8px;
        display: block !important;
        color: #ffffff !important;
    }

    /* Disable hover effects on mobile */
    .topnav.responsive .dropdownNB:hover .dropdownNB-content {
        display: block !important;
    }

    /* Remove invisible bridge on mobile */
    .topnav.responsive .dropdownNB::after {
        display: none;
    }
}

/* Additional Modern Enhancements */
.dropdownNB-content::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #ffffff;
}

/* Hide dropdown arrow and caretaker icons in mobile */
@media screen and (max-width: 950px) {
    .dropdownNB-content::before {
        display: none;
    }

    /* Hide caret-down arrows on mobile for first level menu */
    .topnav.responsive .dropdownNB .dropbtn .fa-caret-down {
        display: none;
    }
}

/* Subtle animation for better UX - DESKTOP ONLY */
@media (hover: hover) and (pointer: fine) {

    .topnav a,
    .dropdownNB .dropbtn {
        position: relative;
        overflow: hidden;
    }

    .topnav a::before,
    .dropdownNB .dropbtn::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.5s;
    }

    .topnav a:hover::before,
    .dropdownNB .dropbtn:hover::before {
        left: 100%;
    }
}
