/**
 * AxesKit Global Navigation Stylesheet
 * Strict requirements:
 * - ZERO ICONS in navbar (pure typography, high density)
 * - Pure white background (#ffffff), crisp 1px borders (#e5e7eb)
 * - Zero glassmorphism, zero noisy blur below hero
 * - LottieFiles-inspired multi-level category navigation
 */

/* ==========================================================================
   1. Nav Trigger & Dropdown Containers
   ========================================================================== */
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.nav-dropdown-trigger {
  position: relative;
  display: inline-block;
}

/* Invisible pointer bridge so mouse moving from button to dropdown never loses focus */
.nav-dropdown-trigger::after {
  content: '';
  position: absolute;
  top: 100%;
  left: -8px;
  right: -8px;
  height: 16px;
  z-index: 240;
}

/* Nav Trigger Button */
.nav-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  line-height: 1;
}

.nav-trigger-btn:hover,
.nav-dropdown-trigger.is-open .nav-trigger-btn {
  color: #111827;
  background: #f9fafb;
  border-color: #e5e7eb;
}

.nav-trigger-btn:focus-visible {
  outline: 2px solid #111827;
  outline-offset: 2px;
}

.nav-chevron {
  font-size: 11px;
  color: #6b7280;
  transition: transform 0.18s ease;
  display: inline-block;
  line-height: 1;
}

.nav-dropdown-trigger.is-open .nav-chevron {
  transform: rotate(180deg);
}

/* ==========================================================================
   2. Mega Menu Panels (Solid Pure White, Crisp Gray Border, No Cards)
   ========================================================================== */
.mega-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.03);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
  z-index: 250;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.nav-dropdown-trigger.is-open .mega-menu-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* ==========================================================================
   3. Categories Mega Menu (2-Panel Master-Detail Layout)
   ========================================================================== */
.mega-menu-categories {
  width: 960px;
  padding: 0;
}

.mega-cat-container {
  display: flex;
  min-height: 480px;
}

/* Left Master Categories List */
.mega-cat-master-col {
  width: 270px;
  flex-shrink: 0;
  background: #fafafa;
  border-right: 1px solid #e5e7eb;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: 520px;
}

.mega-cat-master-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: #374151;
  background: transparent;
  border: none;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
}

.mega-cat-master-item:hover {
  background: #f3f4f6;
  color: #111827;
}

.mega-cat-master-item.is-active {
  background: #ffffff;
  color: #111827;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.mega-cat-master-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: #111827;
  border-radius: 2px;
}

.mega-cat-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mega-cat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}

.mega-cat-count {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
  background: #e5e7eb;
  padding: 1px 6px;
  border-radius: 10px;
  line-height: 1.3;
}

.mega-cat-caret {
  font-size: 14px;
  color: #9ca3af;
  line-height: 1;
}

/* Right Subcategories Panel */
.mega-cat-sub-col {
  flex: 1;
  padding: 24px 28px;
  background: #ffffff;
  overflow-y: auto;
  max-height: 520px;
}

.mega-sub-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid #f3f4f6;
}

.mega-sub-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #9ca3af;
  display: block;
  margin-bottom: 4px;
}

.mega-sub-title {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  margin: 0;
  letter-spacing: -0.015em;
}

.mega-view-all-link {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f3f4f6;
  transition: background 0.15s ease, color 0.15s ease;
}

.mega-view-all-link:hover {
  background: #111827;
  color: #ffffff;
}

.mega-subcat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
}

.mega-subcat-link {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.mega-subcat-link:hover {
  background: #f9fafb;
  border-color: #e5e7eb;
}

.mega-subcat-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.25;
}

.mega-subcat-desc {
  font-size: 11.5px;
  color: #6b7280;
  margin-top: 3px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   4. Free Tools Mega Menu (Compact 4-Column Layout, Zero Icons)
   ========================================================================== */
.mega-menu-tools {
  width: 980px;
  padding: 24px 28px;
}

.mega-tools-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
}

.mega-tools-title {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.015em;
}

.mega-tools-all-link {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f3f4f6;
  transition: background 0.15s ease, color 0.15s ease;
}

.mega-tools-all-link:hover {
  background: #111827;
  color: #ffffff;
}

.mega-tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.mega-tools-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.mega-tool-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mega-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #6b7280;
  padding-bottom: 4px;
  border-bottom: 1px solid #f3f4f6;
}

.mega-tool-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mega-tool-link {
  display: flex;
  flex-direction: column;
  padding: 5px 8px;
  border-radius: 5px;
  text-decoration: none;
  transition: background 0.12s ease;
}

.mega-tool-link:hover {
  background: #f3f4f6;
}

.mega-tool-name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  line-height: 1.25;
}

.mega-tool-desc {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   5. Mobile Hamburger & Responsive Navigation
   ========================================================================== */
.nav-mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}

.nav-mobile-toggle span {
  width: 18px;
  height: 2px;
  background: #111827;
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

@media (max-width: 1040px) {
  .mega-menu-categories,
  .mega-menu-tools {
    width: calc(100vw - 32px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
  }

  .nav-dropdown-trigger.is-open .mega-menu-panel {
    transform: translateX(-50%) translateY(0);
  }

  .mega-tools-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 840px) {
  .nav-mobile-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 16px 20px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  }

  .nav-links.mobile-open {
    display: flex;
  }

  .nav-dropdown-trigger {
    width: 100%;
  }

  .nav-trigger-btn {
    width: 100%;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f9fafb;
    border-color: #e5e7eb;
  }

  .mega-menu-panel {
    position: static;
    width: 100%;
    transform: none;
    box-shadow: none;
    border-radius: 6px;
    margin-top: 8px;
  }

  .mega-cat-container {
    flex-direction: column;
  }

  .mega-cat-master-col {
    width: 100%;
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }

  .mega-cat-sub-col {
    padding: 16px;
  }

  .mega-subcat-grid {
    grid-template-columns: 1fr;
  }

  .mega-tools-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .mega-menu-panel,
  .nav-chevron,
  .nav-trigger-btn,
  .mega-cat-master-item,
  .mega-subcat-link,
  .mega-tool-link {
    transition: none !important;
    transform: none !important;
  }
}

/* ==========================================================================
   4. Universal Navbar Search (Single Universal Icon, Zero Glitches)
   ========================================================================== */
.search-container {
  flex: 0 1 420px;
  min-width: 240px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 8px 16px 8px 38px;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #111827;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.08);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #9ca3af;
  flex-shrink: 0;
}

.nav-search-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  min-width: 340px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.12);
  z-index: 350;
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nav-search-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
  border-top: 1px solid #f3f4f6;
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-search-group-header:first-child {
  border-top: none;
}

.nav-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  text-decoration: none;
  color: #111827;
  transition: background 0.12s ease;
}

.nav-search-item:hover,
.nav-search-item.is-selected {
  background: #f3f4f6;
}

.nav-search-item-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e0f2fe;
  color: #0284c7;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.nav-search-item-badge.badge-cat {
  background: #fef3c7;
  color: #b45309;
}

.nav-search-item-preview {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.nav-search-item-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.nav-search-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-search-item-title {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-search-item-sub {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-search-view-all {
  padding: 11px 14px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: #0284c7;
  cursor: pointer;
  text-decoration: none;
  display: block;
}

.nav-search-view-all:hover {
  background: #f3f4f6;
  color: #0369a1;
}
