/* ===================================================================
   AUDITTECH360 — GLOBAL NAVBAR DROPDOWN STYLES
   Orange + White Corporate Editorial Theme
   =================================================================== */

/* Ensure header container does not clip floating dropdowns */
.editorial-header,
.editorial-header .container,
.editorial-header .navbar-collapse {
  overflow: visible !important;
}

/* Nav Item Container */
.editorial-nav-list .nav-dropdown-item {
  position: relative;
}

@media (min-width: 992px) {
  /* On desktop, make item static so dropdown positions relative to full editorial-header */
  .editorial-nav-list .nav-dropdown-item {
    position: static;
  }
}

/* Overview Link + Chevron Trigger Group */
.nav-link-group {
  display: inline-flex;
  align-items: center;
  position: relative;
  gap: 2px;
}

.nav-link-group .nav-link-overview {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-main-heading, #172033) !important;
  padding: 6px 0 !important;
  display: inline-flex !important;
  align-items: center;
  position: relative !important;
  text-decoration: none !important;
  line-height: 1.3 !important;
  height: auto !important;
  transition: color 0.2s ease;
}

.nav-link-group .nav-link-overview::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background-color: #1677FF;
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 2px;
  pointer-events: none;
}

.nav-link-group .nav-link-overview:hover,
.nav-link-group .nav-link-overview.active,
.nav-dropdown-item.is-active .nav-link-overview {
  color: #1677FF !important;
}

.nav-link-group .nav-link-overview:hover::after,
.nav-link-group .nav-link-overview.active::after,
.nav-dropdown-item.is-active .nav-link-overview::after {
  width: 100% !important;
}

/* Accessible Chevron Toggle Button */
.nav-dropdown-toggle {
  background: transparent;
  border: none;
  padding: 6px;
  margin-left: 2px;
  cursor: pointer;
  color: var(--text-primary, #171717);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-dropdown-toggle:hover,
.nav-dropdown-toggle:focus-visible {
  color: var(--color-orange-primary, #1677FF);
  background-color: rgba(22, 119, 255, 0.08);
  outline: none;
}

.nav-chevron {
  font-size: 0.72rem;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-dropdown-item.is-open .nav-chevron,
.nav-dropdown-toggle[aria-expanded="true"] .nav-chevron {
  transform: rotate(180deg);
  color: var(--color-orange-primary, #1677FF);
}

/* ===================================================================
   DESKTOP DROPDOWN PANEL (>= 992px)
   =================================================================== */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .editorial-nav-list {
    gap: 16px !important;
  }
}

@media (min-width: 992px) {
  .nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    width: 640px;
    max-width: calc(100vw - 32px);
    /* Responsive maximum height: maintains clean spacing above viewport bottom across all screen heights */
    max-height: calc(100vh - 116px);
    max-height: calc(100dvh - 116px);
    display: flex;
    flex-direction: column;
    background: #FFFFFF !important;
    border: 1px solid rgba(23, 23, 23, 0.08);
    border-radius: 16px;
    box-shadow: 0 20px 48px -12px rgba(23, 23, 23, 0.14), 0 4px 16px rgba(22, 119, 255, 0.06);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s ease;
    z-index: 1050;
    overflow: hidden;
  }

  /* Reveal on hover or when opened via toggle/keyboard */
  .nav-dropdown-item:hover > .nav-dropdown-menu,
  .nav-dropdown-item:focus-within > .nav-dropdown-menu,
  .nav-dropdown-item.is-open > .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
  }

  /* 2-Column Grid with internal scrolling */
  .nav-dropdown-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 12px 14px;
    flex: 1 1 auto;
    min-height: 0; /* Critical for flex child vertical scrolling */
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #D4CEBF #FAF8F5;
  }

  /* Custom subtle scrollbar */
  .nav-dropdown-grid::-webkit-scrollbar {
    width: 6px;
  }
  .nav-dropdown-grid::-webkit-scrollbar-track {
    background: #FAF8F5;
    border-radius: 4px;
  }
  .nav-dropdown-grid::-webkit-scrollbar-thumb {
    background: #D4CEBF;
    border-radius: 4px;
  }
  .nav-dropdown-grid::-webkit-scrollbar-thumb:hover {
    background: #1677FF;
  }
}

/* ===================================================================
   DROPDOWN ITEM LINKS & CONTENT
   =================================================================== */
.nav-dropdown-link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  transition: background-color 0.18s ease, transform 0.18s ease;
  background: transparent;
}

.nav-dropdown-link:hover,
.nav-dropdown-link:focus-visible {
  background: rgba(22, 119, 255, 0.06);
  outline: none;
}

.nav-dropdown-link.active-item {
  background: rgba(22, 119, 255, 0.08);
}

/* Icon Box */
.nav-dropdown-icon,
.dropdown-link-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(22, 119, 255, 0.1);
  color: var(--color-orange-primary, #1677FF);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-dropdown-link:hover .nav-dropdown-icon,
.nav-dropdown-link:hover .dropdown-link-icon,
.nav-dropdown-link:focus-visible .nav-dropdown-icon,
.nav-dropdown-link:focus-visible .dropdown-link-icon,
.nav-dropdown-link.active-item .nav-dropdown-icon,
.nav-dropdown-link.active-item .dropdown-link-icon {
  background: var(--color-orange-primary, #1677FF);
  color: #FFFFFF;
  transform: scale(1.05);
}

/* Text Block */
.nav-dropdown-text,
.dropdown-link-content {
  display: flex;
  flex-direction: column;
}

.nav-dropdown-title,
.dropdown-link-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
  color: #172033;
  line-height: 1.3;
  transition: color 0.18s ease;
}

.nav-dropdown-link:hover .nav-dropdown-title,
.nav-dropdown-link:hover .dropdown-link-title,
.nav-dropdown-link:focus-visible .nav-dropdown-title,
.nav-dropdown-link:focus-visible .dropdown-link-title,
.nav-dropdown-link.active-item .nav-dropdown-title,
.nav-dropdown-link.active-item .dropdown-link-title {
  color: var(--color-orange-primary, #1677FF);
}

.nav-dropdown-desc,
.dropdown-link-desc {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  color: #5B6472;
  line-height: 1.35;
  margin-top: 2px;
}

/* Dropdown Footer Strip */
.nav-dropdown-footer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 3;
  border-top: 1px solid rgba(23, 23, 23, 0.08);
  padding: 12px 18px;
  background: #FAF8F5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 15px;
}

.nav-dropdown-all-link,
.dropdown-footer-link {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-orange-primary, #1677FF);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.18s ease, color 0.18s ease;
}

.nav-dropdown-all-link i,
.dropdown-footer-link i {
  transition: transform 0.18s ease;
}

.nav-dropdown-all-link:hover,
.dropdown-footer-link:hover {
  color: #0D47A1;
}

.nav-dropdown-all-link:hover i,
.dropdown-footer-link:hover i {
  transform: translateX(3px);
}

/* ===================================================================
   MOBILE ACCORDION DROPDOWN (< 992px)
   =================================================================== */
@media (max-width: 991.98px) {
  /* Prevent mobile navigation menu from overflowing viewport */
  .editorial-header .navbar-collapse {
    max-height: calc(100vh - 85px);
    max-height: calc(100dvh - 85px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-link-group {
    width: 100%;
    justify-content: space-between;
  }

  .nav-dropdown-toggle {
    width: 44px;
    height: 44px;
    margin-left: auto;
  }

  .nav-dropdown-menu {
    position: static;
    transform: none;
    width: 100%;
    background: #FDFCFB;
    border: 1px solid rgba(23, 23, 23, 0.08);
    border-radius: 12px;
    margin-top: 6px;
    box-shadow: none;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.25s ease;
  }

  .nav-dropdown-item.is-open > .nav-dropdown-menu {
    max-height: min(460px, calc(100vh - 200px));
    max-height: min(460px, calc(100dvh - 200px));
    opacity: 1;
    visibility: visible;
  }

  .nav-dropdown-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #D4CEBF #FAF8F5;
  }

  .nav-dropdown-link {
    padding: 8px 10px;
  }

  .nav-dropdown-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .nav-dropdown-title {
    font-size: 0.84rem;
  }

  .nav-dropdown-desc {
    font-size: 0.7rem;
  }

  .nav-dropdown-footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding: 9px 14px;
    background: #F5F1EB;
    border-top: 1px solid rgba(23, 23, 23, 0.08);
    border-bottom-left-radius: 11px;
    border-bottom-right-radius: 11px;
  }
}
