/* ==========================================================================
   Navbar Styles
   ========================================================================== */

.navbar {
  position: fixed;
  width: 100%;
  height: 70px;
  box-shadow: 0 4px 4px 0 rgba(0, 0, 0, .25);
  z-index: 1000;
  background: linear-gradient(90deg, rgba(13, 123, 167, 0.85) 0, rgba(0, 168, 204, 0.85));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 0;
}

.navbar-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1000px;
  padding: 0 14px 0 0px;
  margin: 0 auto;
}

/* Logo
   ========================================================================== */

.navbar-logo {
  display: flex;
  align-items: center;
  height: 100%;
  text-decoration: none;
}

.navbar-logo img {
  height: 100%;
  width: auto;
}

/* Desktop Links
   ========================================================================== */

.navbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-links > a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  padding: 10px 14px;
  border-radius: 50px;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.desktop-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

.navbar-links > a:hover {
  text-decoration: none;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.navbar-links > a:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.98);
}

/* Hide tooltips by default */
.navbar-links .tooltip {
  display: none;
}

.navbar-links .contact-link {
  color: #fff;
  font-weight: bold;
  padding: 10px 14px;
  text-decoration: none;
  background: rgba(0, 90, 139, 0.65);  /* #005a8b with less opacity for lighter appearance */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  border-radius: 50px;
  border: 1px solid transparent;
}

.navbar-links .contact-link:hover {
  text-decoration: none;
  background: rgba(0, 68, 100, 0.7);  /* #004464 with less opacity for lighter appearance */
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border-color: rgba(255, 255, 255, 0.2);
}

.navbar-links .contact-link:active {
  background: rgba(0, 68, 100, 0.8);  /* #004464 with more opacity when pressed */
  transform: scale(0.98);
}

/* Hamburger Button
   ========================================================================== */

.navbar-hamburger {
  display: none;
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  margin: 0;
  /* margin-right: -4px; */
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.navbar-hamburger:hover {
  background: rgba(0, 0, 0, 0.2);
}

.navbar-hamburger:active {
  background: rgba(0, 0, 0, 0.3);
  transform: scale(0.98);
}

.hamburger-icon {
  width: 28px;
  height: 28px;
  display: block;
}

/* Mobile Menu
   ========================================================================== */

.navbar-mobile-menu {
  position: fixed;
  top: 70px;
  right: 0;
  bottom: 0;
  width: 75%;
  max-width: 300px;
  background: linear-gradient(90deg, rgba(58, 155, 184, 0.9) 0, rgba(77, 179, 209, 0.75));
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  /* border-radius: 25px 0 0 25px; */
  transform: translateX(100%);
  transition: transform 0.3s ease, visibility 0s 0.3s;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  box-shadow: -8px 0 16px rgba(0, 0, 0, 0.2);
  z-index: 999;
  visibility: hidden;
}

.navbar-mobile-menu.active {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.3s ease, visibility 0s 0s;
}

/* Dark overlay behind menu */
.navbar-mobile-overlay {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 998;
}

.navbar-mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

.navbar-mobile-menu > .navbar-mobile-menu-main > a,
.navbar-mobile-menu > .navbar-mobile-menu-bottom > a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  padding: 12px 16px;
  background: transparent;
  border-radius: 50px;
  margin-bottom: 6px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  position: relative;
  overflow: hidden;
}

.navbar-mobile-menu > .navbar-mobile-menu-main > a:active,
.navbar-mobile-menu > .navbar-mobile-menu-bottom > a:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.98);
}

.navbar-mobile-menu > .navbar-mobile-menu-main > a:hover,
.navbar-mobile-menu > .navbar-mobile-menu-bottom > a:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.menu-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

/* Expandable Menu Items
   ========================================================================== */

.navbar-mobile-item-expandable {
  margin-bottom: 6px;
  position: relative;
  border-radius: 24px;
  border: 1px solid transparent;
  background: transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.navbar-mobile-item-header {
  position: relative;
  display: flex;
  align-items: center;
  background: transparent;
  border-radius: 24px;
  min-height: 48px;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  overflow: hidden;
  border: 1px solid transparent;
}

/* Hover effect only when not expanded */
.navbar-mobile-item-expandable:not(.expanded) .navbar-mobile-item-header:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.navbar-mobile-item-expandable.expanded .navbar-mobile-item-header {
  border-color: transparent; /* Keep border but make it transparent to avoid jump */
  position: relative;
}

/* Add a partial-width border below the header when expanded */
.navbar-mobile-item-expandable.expanded .navbar-mobile-item-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.1) 15%, rgba(255, 255, 255, 0.1) 85%, transparent);
  transition: opacity 0.2s ease;
}

.navbar-mobile-item-expandable.expanded .navbar-mobile-item-header:hover {
  background: rgba(255, 255, 255, 0.05); /* Subtle highlight on header when expanded */
}

.navbar-mobile-item-header:active {
  background: rgba(255, 255, 255, 0.2);
}

.navbar-mobile-item-expandable.expanded {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  border-radius: 24px;
}

.navbar-mobile-item-header > a {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-right: 56px; /* Make room for the expand button */
  margin-bottom: 0;
  background: transparent !important;
  border-radius: 50px !important;
  font-weight: bold;
  color: #fff;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.navbar-mobile-item-header > a:hover {
  background: transparent !important;
}

.navbar-mobile-item-header > a:active {
  transform: scale(0.98);
}

.navbar-mobile-expand {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border-radius: 50%;
}

/* Show border and background on expand button when hovering anywhere on the header */
.navbar-mobile-item-header:hover .navbar-mobile-expand {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.navbar-mobile-expand:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25) !important;
  transform: translateY(-50%);
}

.navbar-mobile-expand:active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(0.95);
}

.navbar-mobile-item-expandable.expanded .navbar-mobile-expand {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15); /* Show border when expanded */
}

/* Show border and background on expand button when hovering anywhere on expanded header */
.navbar-mobile-item-expandable.expanded .navbar-mobile-item-header:hover .navbar-mobile-expand {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.navbar-mobile-item-expandable.expanded .navbar-mobile-expand:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3) !important;
}

.navbar-mobile-item-expandable.expanded .navbar-mobile-expand:active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(0.95);
}

.navbar-mobile-expand span {
  display: block;
  width: 16px;
  height: 16px;
  position: relative;
  transition: transform 0.3s;
}

.navbar-mobile-expand span::before,
.navbar-mobile-expand span::after {
  content: '';
  position: absolute;
  background: #fff;
  border-radius: 2px;
}

.navbar-mobile-expand span::before {
  width: 16px;
  height: 2px;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.navbar-mobile-expand span::after {
  width: 2px;
  height: 16px;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.navbar-mobile-item-expandable.expanded .navbar-mobile-expand span {
  transform: rotate(45deg);
}

/* Submenu Container - Pocket Style
   ========================================================================== */

.navbar-mobile-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0 8px; /* Consistent horizontal padding */
}

.navbar-mobile-item-expandable.expanded .navbar-mobile-submenu {
  max-height: 400px; /* Specific height for Tools submenu (8 items) */
}

/* Submenu Links
   ========================================================================== */

.navbar-mobile-submenu a {
  display: flex;
  align-items: center;
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  font-size: 13px;
  padding: 8px 12px;
  padding-left: 36px; /* Indented within pocket */
  border-radius: 50px; /* Fully rounded pills */
  margin-bottom: 6px; /* Increased gap between items */
  background: transparent; /* No special background */
  transition: all 0.2s ease;
  position: relative;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  overflow: hidden;
}

.navbar-mobile-submenu a:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.98);
}

.navbar-mobile-submenu a:first-child {
  margin-top: 8px; /* Top spacing */
}

.navbar-mobile-submenu a:last-child {
  margin-bottom: 10px; /* More bottom spacing to balance with rounded corners */
}

/* Small dot indicator for submenu items */
.navbar-mobile-submenu a::before {
  content: '';
  position: absolute;
  left: 18px; /* Position within pocket */
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
}

.navbar-mobile-submenu a:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile Menu Layout
   ========================================================================== */

.navbar-mobile-menu-main {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.navbar-mobile-menu-bottom {
  margin-top: auto;
  padding: 12px;
}

.navbar-mobile-contact {
  background-color: #005a8b !important;
  justify-content: center;
  padding: 12px 16px !important;
  border-radius: 50px !important;
  margin-bottom: 0 !important;
  transition: all 0.2s ease;
  border: 1px solid transparent !important;
  min-height: 48px !important;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  overflow: hidden;
  position: relative;
}

.navbar-mobile-contact:active {
  background-color: #004464 !important;
  transform: scale(0.98);
}

.navbar-mobile-contact:hover {
  background-color: #004464 !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Mobile navbar - 580px and below */
@media (max-width: 580px) {
  .navbar-links {
    display: none;
  }

  .navbar-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .navbar-mobile-menu {
    display: flex;
  }
}

/* Hide mobile overlay on larger screens to prevent blocking */
@media (min-width: 581px) {
  .navbar-mobile-overlay,
  .navbar-mobile-overlay.active {
    display: none !important;
  }

  .navbar-mobile-menu,
  .navbar-mobile-menu.active {
    display: none !important;
  }

  /* Force body overflow to be visible on larger screens */
  body {
    overflow: visible !important;
  }
}

/* Icon-only mode - middle step between desktop and mobile (581px to 700px) */
@media (min-width: 581px) and (max-width: 700px) {
  .navbar-links > a {
    padding: 14px;
    min-width: auto;
    width: auto;
    height: auto;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible !important;
    aspect-ratio: 1;
  }

  .navbar-links > a > span:not(.tooltip) {
    display: none;
  }

  .navbar-links .desktop-icon {
    width: 20px;
    height: 20px;
  }

  /* Tooltip element */
  .navbar-links > a .tooltip {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 10000;
    display: block !important;
  }

  .navbar-links > a:hover .tooltip {
    opacity: 1;
    visibility: visible;
  }

  /* Contact button adjustments */
  .navbar-links .contact-link {
    padding: 12px;
  }
}

@media (max-width: 300px) {
  .navbar-mobile-menu {
    width: 100%;
    max-width: 100%;
  }
}

/* Hide logo text on very small screens */
@media (max-width: 260px) {
  .navbar-logo img[src="/assets/images/main-logo-text.svg"] {
    display: none;
  }
}

/* Old navbar classes for backwards compatibility (can be removed later) */
.nav-links,
.nav-links-left,
.nav-links-right,
.first-link {
  display: none;
}