/* --- Navbar Wrapper --- */
.custom-navbar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1030;
    padding: 15px 0;
    transition: all 0.3s ease;
}

/* Sticky/Scrolled state (to be toggled via JS) */
.custom-navbar.scrolled {
    position: fixed;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 10px 0;
}

/* Base Body Locking */
body.navbar-open {
    overflow: hidden !important;
}

/* --- Container --- */
.custom-navbar .container {
    padding-left: 15px;
    padding-right: 15px;
}

/* --- Logo --- */
.navbar-logo {
    width: 90px;
    height: auto;
    transition: transform 0.3s ease;
}

.navbar-brand:hover .navbar-logo {
    transform: scale(1.05);
}

/* --- Nav Links --- */
.navbar-nav {
    gap: 1.5rem;
}

.nav-link {
    color: #444444 !important;
    font-family: 'Quicksand', sans-serif;
    font-size: 16px;
    font-weight: 600;
    padding: 8px 0 !important;
    position: relative;
    transition: color 0.3s ease;
}

.custom-navbar.scrolled .nav-link {
    color: #333333 !important;
}

.custom-navbar .nav-link:hover,
.custom-navbar .nav-link.active,
.custom-navbar.scrolled .nav-link:hover,
.custom-navbar.scrolled .nav-link.active {
    color: #1965c0 !important;
}

/* Animated Underline (Premium Centered Style) */
.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0px;
    left: 50%;
    width: 0;
    height: 3px;
    background-color: #1965c0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-50%);
    border-radius: 2px;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 25px; /* Consistent fixed width for premium look */
}

/* --- Dropdowns --- */
.dropdown-menu {
    border: none;
    border-radius: 12px;
    padding: 1rem 0;
    margin-top: 0;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    display: block; /* Required for transition */
}

/* Dropdown toggle arrow removal */
.dropdown-toggle::after {
    display: none !important;
}

/* Desktop Submenu Logic */
@media (min-width: 992px) {
    .nav-item.dropdown:hover > .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .dropdown-submenu {
        position: relative;
    }

    .dropdown-submenu > .dropdown-menu {
        top: 0;
        left: 100%;
        margin-top: -10px; /* Aligns with parent item padding */
        margin-left: -1px;
        border-radius: 0 12px 12px 12px;
        opacity: 0;
        visibility: hidden;
        transform: translateX(10px);
    }

    .dropdown-submenu:hover > .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
    }

    /* Submenu Arrow/Icon */
    .dropdown-submenu > .dropdown-item::after {
        content: "\f054";
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        float: right;
        font-size: 10px;
        margin-top: 5px;
        margin-left: 10px;
        opacity: 0.5;
        /* Reset animated underline properties for this specific font-icon ::after */
        position: static;
        width: auto;
        height: auto;
        background-color: transparent;
        transition: none;
        transform: none;
    }
}

.dropdown-item {
    font-family: 'Quicksand', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: #555555;
    padding: 10px 20px;
    transition: all 0.2s ease;
    position: relative;
}

/* Premium Underline for Dropdown Items */
.dropdown-item::before {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: #1965c0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-50%);
    border-radius: 2px;
}

.dropdown-item:hover::before {
    width: 20px;
}

.dropdown-item:hover {
    background-color: #f8faff;
    color: #1965c0;
}

.dropdown-item.active,
.dropdown-item:active {
    background-color: #1965c0;
    color: #fff;
}

/* --- Icon Buttons --- */
.navbar-icons {
    margin-left: 2rem;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-decoration: none;
}

.icon-btn img {
    width: 20px;
    height: 20px;
}

.icon-btn.outline {
    border: 1.5px solid #1965c0;
    background: transparent;
}

.icon-btn.outline:hover {
    background: #1965c0;
}

.icon-btn.outline:hover img {
    filter: brightness(0) invert(1);
}

.icon-btn.filled {
    background: #1965c0;
}

.icon-btn.filled:hover {
    background: #1452a1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(25, 101, 192, 0.3);
}

/* --- Mobile Specifics --- */
@media (max-width: 991.98px) {
    .custom-navbar {
        background: #ffffff;
        position: fixed;
        width: 100%;
        left: 0;
        top: 0;
        padding: 5px 0;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }

    .navbar-logo {
        width: 70px; /* Improved visibility on mobile */
    }
    
    .navbar-collapse {
        background: #ffffff;
        padding: 10px 20px 30px; /* Added more bottom padding for better scroll room */
        border-radius: 0 0 15px 15px;
        margin-top: 5px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
        max-height: 90vh; /* Increased from 85vh */
        overflow-y: auto;
        border-top: 1px solid #f0f0f0;
    }

    .navbar-nav {
        gap: 0.25rem; /* Tighter vertical spacing for mobile */
    }

    .nav-link {
        padding: 10px 0 !important; /* Slightly more compact */
        border-bottom: 1px solid #f8f8f8;
        font-size: 15px;
    }

    .nav-link::after {
        display: none;
    }

    .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: none;
        display: none; /* Reset for mobile click */
        position: static;
        box-shadow: none;
        padding-left: 1.5rem;
        background: #fcfcfc;
        border-left: 2px solid #1965c0;
        border-radius: 0;
    }

    .dropdown-menu.show {
        display: block;
    }

    /* Mobile Submenu Styling */
    .dropdown-submenu .dropdown-menu {
        display: none;
        padding-left: 1.5rem;
        border-left: 1px dashed #1965c0;
        background-color: #f9f9f9;
        box-shadow: none;
        border-radius: 0;
        margin-top: 0;
    }

    .dropdown-item {
        padding: 8px 15px; /* More compact items for mobile */
    }

    .dropdown-submenu.open > .dropdown-menu {
        display: block;
    }

    .dropdown-submenu > .dropdown-item::after {
        content: "\f054"; /* Right arrow */
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        float: right;
        font-size: 12px;
        transition: transform 0.3s ease;
    }

    .dropdown-submenu.open > .dropdown-item::after {
        transform: rotate(90deg);
    }

    .navbar-icons {
        margin: 20px 0 0;
        justify-content: center;
    }

    /* --- Mobile Split Menu Enhancements --- */
    .nav-item.dropdown, .dropdown-submenu {
        position: relative;
    }

    .nav-link-container, .dropdown-item-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        border-bottom: 1px solid #f8f8f8;
    }

    .nav-link-container .nav-link, 
    .dropdown-item-container .dropdown-item {
        flex: 1;
        border-bottom: none !important;
        padding-right: 10px !important;
    }

    .dropdown-toggle-split {
        width: 45px;
        height: 45px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: #1965c0;
        transition: all 0.3s ease;
        border-left: 1px solid #f0f0f0;
    }

    .dropdown-toggle-split i {
        font-size: 12px;
        transition: transform 0.3s ease;
    }

    .dropdown-toggle-split.active i,
    .dropdown-submenu.open > .dropdown-item-container .dropdown-toggle-split i {
        transform: rotate(180deg);
    }

    .dropdown-menu {
        margin-top: 0 !important;
    }

    /* Standard Bootstrap Toggler Icon Color */
    .navbar-toggler-icon {
        filter: brightness(0) saturate(100%) invert(32%) sepia(87%) saturate(1022%) hue-rotate(188deg) brightness(92%) contrast(92%);
    }
}

/* --- Mega Menu Enhancements --- */
@media (min-width: 992px) {
    .mega-menu {
        min-width: 520px;
        left: 50% !important;
        transform: translate(-50%, 10px) !important;
        padding: 20px !important;
        border-radius: 16px !important;
    }

    .nav-item.dropdown:hover > .mega-menu {
        transform: translate(-50%, 0) !important;
        opacity: 1;
        visibility: visible;
    }

    .mega-menu .row {
        margin: 0;
    }

    .mega-menu .col-divider {
        border-right: 1px solid rgba(0, 0, 0, 0.05);
    }
}

.mega-menu .dropdown-item {
    display: flex !important;
    align-items: center;
    border-radius: 8px;
    margin-bottom: 2px;
}

/* Mobile Mega Menu Reset */
@media (max-width: 991.98px) {
    .mega-menu {
        min-width: 100%;
        left: 0 !important;
        transform: none !important;
    }
    
    .mega-menu .col-divider {
        border-right: none;
        border-bottom: 1px dashed #eee;
        margin-bottom: 10px;
        padding-bottom: 10px;
    }
}
