/* ============================================================
   DESKTOP HEADER + MEGA MENU (min-width: 1025px only)
   Mobile/tablet keeps sidebar hamburger — unchanged.
   ============================================================ */

.desktop-nav,
.mega-menu-backdrop {
  display: none;
}

@media (min-width: 1025px) {

  /* Hide mobile hamburger on desktop when mega nav is present */
  .menu-btn {
    display: none !important;
  }

  /* Portal login page has no desktop nav — keep hamburger */
  .portal-auth-body .menu-btn {
    display: flex !important;
  }

  .navbar .max-width {
    gap: 1rem;
  }

  .navbar .logo {
    flex-shrink: 0;
    max-width: none;
  }

  /* ---------- DESKTOP NAV BAR ---------- */
  .desktop-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    min-width: 0;
    margin-left: clamp(0.5rem, 2vw, 1.75rem);
  }

  .desktop-nav-list {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .desktop-nav-item {
    position: relative;
  }

  .desktop-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    border: none;
    background: transparent;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s ease, background 0.2s ease;
    white-space: nowrap;
  }

  .desktop-nav-link:hover,
  .desktop-nav-link:focus-visible,
  .desktop-nav-item--mega.is-open .desktop-nav-trigger {
    color: #fff;
    background: rgba(255, 138, 0, 0.1);
    outline: none;
  }

  .desktop-nav-link:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 138, 0, 0.45);
  }

  .desktop-nav-chevron {
    font-size: 0.6rem;
    opacity: 0.7;
    transition: transform 0.25s ease;
  }

  .desktop-nav-item--mega.is-open .desktop-nav-chevron {
    transform: rotate(180deg);
    opacity: 1;
  }

  /* Active page hint */
  .desktop-nav-link.is-active {
    color: #ff8a00;
    background: rgba(255, 138, 0, 0.08);
  }

  /* ---------- ACTIONS (quote + portal) ---------- */
  .desktop-nav-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
    margin-left: 0.75rem;
  }

  .desktop-nav-quote {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    border-radius: 999px;
    background: linear-gradient(115deg, #ff8a00, #e52e71);
    box-shadow: 0 4px 16px rgba(255, 138, 0, 0.28);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .desktop-nav-quote:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(255, 138, 0, 0.38);
    color: #fff;
  }

  .desktop-nav-portal {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.85rem 0.4rem 0.45rem;
    border-radius: 999px;
    text-decoration: none;
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  }

  .desktop-nav-portal:hover {
    border-color: rgba(255, 138, 0, 0.4);
    background: rgba(255, 138, 0, 0.08);
    transform: translateY(-1px);
    color: #fff;
  }

  .desktop-nav-portal-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff8a00, #e52e71);
    font-size: 0.75rem;
  }

  .desktop-nav-portal-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
  }

  .desktop-nav-portal-label {
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
  }

  .desktop-nav-portal-action {
    font-size: 0.82rem;
    font-weight: 700;
  }

  /* ---------- MEGA MENU PANEL ---------- */
  .mega-menu {
    position: fixed;
    top: var(--mega-top, 72px);
    left: 50%;
    transform: translateX(-50%) translateY(-10px) scale(0.985);
    width: min(1180px, calc(100vw - 2.5rem));
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform-origin: top center;
    transition:
      opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0.32s;
  }

  .desktop-nav-item--mega.is-open .mega-menu,
  .desktop-nav-item--mega.is-closing .mega-menu {
    visibility: visible;
    pointer-events: auto;
  }

  .desktop-nav-item--mega.is-open .mega-menu {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }

  .desktop-nav-item--mega.is-closing .mega-menu {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px) scale(0.988);
    pointer-events: none;
  }

  .mega-menu-panel {
    display: grid;
    grid-template-columns: 228px 1fr;
    gap: 0;
    background: #030303;
    border: 1px solid rgba(255, 138, 0, 0.14);
    border-top: 2px solid rgba(255, 138, 0, 0.22);
    border-radius: 0 0 14px 14px;
    box-shadow:
      0 20px 50px rgba(0, 0, 0, 0.75),
      0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    overflow: hidden;
  }

  .desktop-nav-item--mega.is-open .mega-menu-panel {
    animation: megaPanelIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  @keyframes megaPanelIn {
    from {
      opacity: 0.6;
    }
    to {
      opacity: 1;
    }
  }

  .desktop-nav-item--mega.is-open .mega-menu-col {
    animation: megaColIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .desktop-nav-item--mega.is-open .mega-menu-col:nth-child(1) { animation-delay: 0.03s; }
  .desktop-nav-item--mega.is-open .mega-menu-col:nth-child(2) { animation-delay: 0.06s; }
  .desktop-nav-item--mega.is-open .mega-menu-col:nth-child(3) { animation-delay: 0.09s; }
  .desktop-nav-item--mega.is-open .mega-menu-col:nth-child(4) { animation-delay: 0.12s; }
  .desktop-nav-item--mega.is-open .mega-menu-col:nth-child(5) { animation-delay: 0.15s; }

  @keyframes megaColIn {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .mega-menu-promo {
    padding: 1.35rem 1.2rem;
    background: #050505;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
  }

  .mega-promo-badge {
    display: inline-block;
    align-self: flex-start;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #ff8a00;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 138, 0, 0.28);
    background: rgba(255, 138, 0, 0.06);
  }

  .mega-promo-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    color: #f2f2f2;
    margin: 0;
  }

  .mega-promo-text {
    font-size: 0.8rem;
    line-height: 1.55;
    color: #7a7a7a;
    margin: 0;
    flex: 1;
  }

  .mega-promo-actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.35rem;
  }

  .mega-promo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  }

  .mega-promo-btn--primary {
    background: linear-gradient(115deg, #ff8a00, #e52e71);
    color: #fff;
  }

  .mega-promo-btn--primary:hover {
    color: #fff;
    filter: brightness(1.06);
  }

  .mega-promo-btn--ghost {
    color: #b0b0b0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #0a0a0a;
  }

  .mega-promo-btn--ghost:hover {
    border-color: rgba(255, 138, 0, 0.3);
    color: #ff8a00;
    background: rgba(255, 138, 0, 0.05);
  }

  /* Services grid — 5 columns */
  .mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    padding: 0.85rem 0.35rem 0.85rem 0;
    max-height: min(68vh, 500px);
    overflow-y: auto;
    background: #030303;
  }

  .mega-menu-grid::-webkit-scrollbar {
    width: 5px;
  }

  .mega-menu-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 138, 0, 0.35);
    border-radius: 4px;
  }

  .mega-menu-col {
    padding: 0.65rem 0.7rem 0.75rem;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s ease;
  }

  .mega-menu-col:hover {
    background: rgba(255, 255, 255, 0.015);
  }

  .mega-menu-col:last-child {
    border-right: none;
  }

  .mega-col-head {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin-bottom: 0.55rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .mega-col-icon {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 7px;
    background: rgba(255, 138, 0, 0.1);
    color: #ff8a00;
    font-size: 0.7rem;
  }

  .mega-col-title-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
  }

  .mega-col-title {
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.25;
    color: #ececec;
    margin: 0;
  }

  .mega-col-count {
    font-size: 0.58rem;
    font-weight: 600;
    color: #666;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
  }

  .mega-col-desc {
    font-size: 0.64rem;
    color: #666;
    margin: 0.2rem 0 0;
    line-height: 1.35;
  }

  .mega-col-links {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .mega-col-links li {
    margin-bottom: 0.1rem;
  }

  .mega-col-links a {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.45rem;
    font-size: 0.77rem;
    line-height: 1.3;
    color: #9a9a9a;
    text-decoration: none;
    border-radius: 6px;
    border-left: 2px solid transparent;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, padding-left 0.18s ease;
  }

  .mega-col-links a i {
    width: 13px;
    flex-shrink: 0;
    font-size: 0.65rem;
    color: #ff8a00;
    opacity: 0.75;
    transition: opacity 0.18s ease;
  }

  .mega-col-links a span {
    flex: 1;
    min-width: 0;
  }

  .mega-col-links a::after {
    content: '→';
    font-size: 0.7rem;
    color: #ff8a00;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  .mega-col-links a:hover,
  .mega-col-links a:focus-visible {
    color: #fff;
    background: rgba(255, 138, 0, 0.07);
    border-left-color: #ff8a00;
    padding-left: 0.55rem;
    outline: none;
  }

  .mega-col-links a:hover i,
  .mega-col-links a:focus-visible i {
    opacity: 1;
  }

  .mega-col-links a:hover::after,
  .mega-col-links a:focus-visible::after {
    opacity: 1;
    transform: translateX(0);
  }

  /* Backdrop — below header only, NO blur (keeps header crisp) */
  .mega-menu-backdrop {
    display: block;
    position: fixed;
    top: var(--header-h, 72px);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.68);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.32s;
    pointer-events: none;
  }

  .mega-menu-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Header stays sharp when mega is open — no blur, solid bar */
  header.mega-menu-open {
    position: relative;
    z-index: 1003;
  }

  body.mega-menu-open .navbar {
    z-index: 1003;
    background: #000000;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom-color: rgba(255, 138, 0, 0.35);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  }

  body.mega-menu-open .navbar.scrolled {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  body.mega-menu-open .desktop-nav-item--mega.is-open .desktop-nav-trigger {
    color: #ff8a00;
    background: rgba(255, 138, 0, 0.12);
  }

  /* Navbar polish on desktop */
  .navbar {
    padding: 14px 0;
  }

  .navbar.scrolled {
    padding: 10px 0;
  }
}

/* Large desktop — slightly roomier mega */
@media (min-width: 1280px) {
  .mega-menu-panel {
    grid-template-columns: 260px 1fr;
  }

  .mega-col-links a {
    font-size: 0.8rem;
  }

  .mega-col-title {
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  @media (min-width: 1025px) {
    .mega-menu,
    .mega-menu-backdrop,
    .desktop-nav-link,
    .desktop-nav-chevron,
    .mega-menu-panel,
    .mega-menu-col {
      animation: none !important;
      transition: none !important;
    }
  }
}
