/**
 * 2025 Navbar Modernization
 * Glassmorphism + micro-interactions
 */

/* ========== GLASSMORPHISM NAVBAR ========== */

/* Floating frosted glass navbar - iOS-style with darkest hero blue */
#header.u-header {
  background: rgba(33, 50, 91, 0.7) !important;
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999 !important; /* Ensure navbar is above everything */
  position: fixed !important;
  top: 0 !important;
  width: 100% !important;
  visibility: visible !important;
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* Push down hero CONTENT (not hero background) to account for fixed navbar */
/* This lets the blue gradient extend to top while keeping text below navbar */
.bg-gradient-hero .container,
#banner .wrapper > .inner,
.wrapper.style1 > .inner,
section:first-of-type > .container,
section:first-of-type > .inner {
  padding-top: 10rem !important;
}

/* Mobile spacing adjustments - more space needed on mobile */
@media (max-width: 767.98px) {
  .bg-gradient-hero .container,
  #banner .wrapper > .inner,
  .wrapper.style1 > .inner,
  section:first-of-type > .container,
  section:first-of-type > .inner {
    padding-top: 9rem !important;
  }
}

/* Logo swap logic - show white by default, black when scrolled */
.navbar-logo-white {
  display: block;
  transition: opacity 0.3s ease;
}

.navbar-logo-black {
  display: none;
  transition: opacity 0.3s ease;
}

/* When scrolled, swap to black logo */
#header.u-header.u-header--moved-up .navbar-logo-white {
  display: none;
}

#header.u-header.u-header--moved-up .navbar-logo-black {
  display: block;
}

/* Desktop navbar layout: logo left, nav center, button right */
@media (min-width: 768px) {
  /* Use CSS Grid for three-column layout */
  #header.u-header .navbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: flex-end; /* Bottom-align all items */
    gap: 1rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  /* Logo stays in first column - make it larger */
  #header.u-header .navbar-brand {
    grid-column: 1;
    padding: 0;
    margin: 0;
  }

  #header.u-header .navbar-brand img {
    height: 60px !important; /* Increased from 50px */
  }

  /* Toggler hidden on desktop anyway but keep it in flow */
  #header.u-header .navbar-toggler {
    display: none;
  }

  /* Navbar collapse spans middle column */
  #header.u-header .navbar-collapse {
    grid-column: 2;
    display: flex !important;
    justify-content: center;
    align-items: flex-end; /* Bottom-align nav items */
  }

  /* Nav items bottom-aligned within their container */
  #header.u-header .navbar-nav {
    display: flex;
    align-items: flex-end; /* Bottom-align with logo */
    gap: 0.5rem;
    margin: 0;
    padding-bottom: 0.25rem; /* Fine-tune alignment with logo baseline */
  }

  /* Move the last item (Client Login) to third column */
  #header.u-header .navbar-nav .nav-item:last-child {
    position: fixed;
    right: 2rem;
    bottom: 0.75rem; /* Align with bottom of navbar */
  }
}

/* When scrolled, change to off-white with dark text */
#header.u-header.u-header--moved-up {
  background: rgba(255, 255, 255, 0.9) !important;
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow:
    0 2px 16px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  visibility: visible !important;
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* Change nav link colors to dark when scrolled */
#header.u-header.u-header--moved-up .nav-link {
  color: #2d2d2d !important;
}

#header.u-header.u-header--moved-up .nav-link:hover {
  color: #21325b !important;
}

/* Change dropdown toggle color when scrolled */
#header.u-header.u-header--moved-up .dropdown-toggle {
  color: #2d2d2d !important;
}

#header.u-header.u-header--moved-up .dropdown-toggle:hover {
  color: #21325b !important;
}

/* Adjust button styling when scrolled */
#header.u-header.u-header--moved-up .btn-light {
  background: rgba(33, 50, 91, 0.95) !important;
  color: white !important;
  border: 1px solid rgba(33, 50, 91, 1) !important;
}

#header.u-header.u-header--moved-up .btn-light:hover {
  background: rgba(33, 50, 91, 1) !important;
  transform: translateY(-2px);
}


/* ========== SMOOTH UNDERLINE ANIMATIONS ========== */

/* Desktop nav links with animated underline */
@media (min-width: 768px) {
  .navbar-nav .nav-link {
    position: relative;
    transition: color 0.3s ease;
  }

  /* Only apply underline to non-dropdown nav links */
  .navbar-nav .nav-link:not(.dropdown-toggle)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #4A90E2, #357ABD);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-50%);
  }

  .navbar-nav .nav-link:not(.dropdown-toggle):hover::after,
  .navbar-nav .nav-link:not(.dropdown-toggle).active::after {
    width: 80%;
  }

  /* Dropdown toggle chevron rotation */
  .dropdown-toggle::after {
    transition: transform 0.3s ease;
    display: inline-block;
  }

  .dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
  }
}

/* ========== ENHANCED DROPDOWN MENUS ========== */

/* Dropdown menu glassmorphism */
.navbar-nav .dropdown-menu {
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(255, 255, 255, 0.95) 100%
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 0.5rem;
  animation: dropdownFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000 !important; /* Ensure dropdowns appear above navbar and hero */
  position: absolute;
}

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

/* Dropdown items with hover effect */
.navbar-nav .dropdown-item {
  border-radius: 8px;
  margin: 0.125rem 0;
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.navbar-nav .dropdown-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(74, 144, 226, 0.1), rgba(53, 122, 189, 0.05));
  transition: width 0.3s ease;
  z-index: -1;
}

.navbar-nav .dropdown-item:hover::before {
  width: 100%;
}

.navbar-nav .dropdown-item:hover {
  background-color: rgba(74, 144, 226, 0.08);
  transform: translateX(4px);
  color: #21325b !important;
}

/* Dropdown headers styling */
.navbar-nav .dropdown-header {
  color: #6c757d;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem 0.5rem;
  margin-top: 0.5rem;
}

.navbar-nav .dropdown-header:first-child {
  margin-top: 0;
}

/* ========== MEGA MENU ENHANCEMENTS ========== */

/* Mega menu with glassmorphism */
.hs-mega-menu.dropdown-menu {
  min-width: 35rem !important;
  padding: 1.5rem;
  z-index: 10000 !important; /* Ensure mega menu appears above navbar and hero */
  position: absolute;
}

/* Banner section glassmorphism */
.navbar-dropdown-menu-banner {
  background: linear-gradient(135deg,
    rgba(33, 50, 91, 0.95) 0%,
    rgba(47, 73, 121, 0.9) 100%
  ) !important;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.navbar-dropdown-menu-banner-content h2 {
  color: #fff;
  margin-bottom: 1rem;
}

.navbar-dropdown-menu-banner-content p {
  color: rgba(255, 255, 255, 0.9);
}

/* CTA button in banner */
.navbar-dropdown-menu-banner .btn-primary {
  background: linear-gradient(135deg, #4A90E2, #357ABD);
  border: none;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
  transition: all 0.3s ease;
}

.navbar-dropdown-menu-banner .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

/* ========== VISUAL SERVICE ICONS ========== */

/* Icon containers for menu items */
.dropdown-item-with-icon {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dropdown-item-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.1), rgba(74, 144, 226, 0.05));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 1px solid rgba(74, 144, 226, 0.2);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.dropdown-item:hover .dropdown-item-icon {
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.2), rgba(74, 144, 226, 0.1));
  border-color: rgba(74, 144, 226, 0.3);
  transform: scale(1.05);
}

/* ========== MOBILE ENHANCEMENTS ========== */

@media (max-width: 767.98px) {
  /* Mobile navbar keeps glassmorphism but more opaque for readability */
  #header.u-header .navbar-collapse {
    background: rgba(33, 50, 91, 0.92) !important;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Mobile menu items - larger touch targets */
  #header.u-header .navbar-collapse .nav-link,
  #header.u-header .navbar-collapse .dropdown-toggle {
    padding: 1rem 1.25rem !important;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  #header.u-header .navbar-collapse .nav-link:last-child {
    border-bottom: none;
  }

  /* Ensure container allows proper positioning */
  #header.u-header .navbar-collapse .navbar-nav {
    width: 100% !important;
  }

  /* Mobile dropdown menu glassmorphism - FIT TO SCREEN */
  #header.u-header .navbar-collapse .dropdown-menu {
    background: linear-gradient(135deg,
      rgba(255, 255, 255, 0.95) 0%,
      rgba(255, 255, 255, 0.92) 100%
    );
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    width: calc(100vw - 3rem) !important;
    max-width: calc(100vw - 3rem) !important;
    min-width: auto !important;
    position: relative !important;
    left: 0 !important;
    right: auto !important;
    margin: 0.5rem 1rem !important;
    padding: 0.75rem !important;
    box-sizing: border-box !important;
  }

  /* Mobile mega menu - override desktop min-width */
  #header.u-header .navbar-collapse .hs-mega-menu.dropdown-menu {
    min-width: auto !important;
    width: calc(100vw - 3rem) !important;
    max-width: calc(100vw - 3rem) !important;
    padding: 1rem !important;
    margin: 0.5rem 1rem !important;
  }

  /* Force correct positioning when dropdown is shown/expanded */
  #header.u-header .navbar-collapse .dropdown-menu.show {
    position: relative !important;
    left: 0 !important;
    right: auto !important;
    transform: none !important;
    inset: auto !important;
    width: calc(100vw - 3rem) !important;
    max-width: calc(100vw - 3rem) !important;
    margin: 0.5rem 1rem !important;
  }

  /* Mega menu when shown */
  #header.u-header .navbar-collapse .hs-mega-menu.dropdown-menu.show {
    position: relative !important;
    left: 0 !important;
    right: auto !important;
    transform: none !important;
    inset: auto !important;
  }

  /* Mobile dropdown items */
  #header.u-header .navbar-collapse .dropdown-item {
    padding: 0.65rem 0.75rem !important;
    font-size: 0.9rem !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow: hidden !important;
    max-width: 100% !important;
  }

  /* Mobile dropdown items with icons - adjust layout */
  #header.u-header .navbar-collapse .dropdown-item-with-icon {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Mobile dropdown item icons - smaller on mobile */
  #header.u-header .navbar-collapse .dropdown-item-icon {
    width: 24px !important;
    height: 24px !important;
    font-size: 12px !important;
    flex-shrink: 0 !important;
    min-width: 24px !important;
  }

  /* Text wrapper for dropdown items on mobile */
  #header.u-header .navbar-collapse .dropdown-item-with-icon span:not(.dropdown-item-icon) {
    flex: 1 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.3 !important;
  }

  /* Mobile dropdown headers - smaller */
  #header.u-header .navbar-collapse .dropdown-header {
    font-size: 0.7rem !important;
    padding: 0.5rem 0.75rem 0.25rem !important;
  }

  /* ===== MOBILE INVERTED STATE (when scrolled) ===== */

  /* Hamburger icon turns black when scrolled */
  #header.u-header.u-header--moved-up .navbar-toggler .bi-list,
  #header.u-header.u-header--moved-up .navbar-toggler .bi-x {
    color: #2d2d2d !important;
  }

  /* Mobile menu container changes from blue to white when scrolled */
  #header.u-header.u-header--moved-up .navbar-collapse {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(25px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(180%) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.9) !important;
  }

  /* Mobile menu items text changes to dark when scrolled */
  #header.u-header.u-header--moved-up .navbar-collapse .nav-link,
  #header.u-header.u-header--moved-up .navbar-collapse .dropdown-toggle {
    color: #2d2d2d !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
  }
}

/* ========== BUTTON ENHANCEMENTS ========== */

/* Client Login button with modern styling */
.navbar-nav .btn-light {
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.9) 100%
  ) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
}

.navbar-nav .btn-light:hover {
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.95) 100%
  ) !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* ========== ACCESSIBILITY IMPROVEMENTS ========== */

/* Focus states for keyboard navigation */
.navbar-nav .nav-link:focus,
.navbar-nav .dropdown-item:focus {
  outline: 2px solid #4A90E2;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip to content link styling */
.skip-link {
  background: linear-gradient(135deg, #4A90E2, #357ABD) !important;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
  border-radius: 8px !important;
  font-weight: 500;
}

.skip-link:focus {
  outline: 3px solid white !important;
  outline-offset: 4px !important;
}
