/* ==========================================================
   MEGA-MENU.CSS  —  Auto Pecas Capelini
   Menu de marcas e modelos, estilo editorial premium.
   ========================================================== */

/* ----------------------------------------------------------
   TRIGGER (dentro de .loja-nav)
   ---------------------------------------------------------- */
.loja-nav__mega-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 150ms ease,
    color 150ms ease,
    border-color 150ms ease;
}

.loja-nav__mega-trigger:hover,
.loja-nav__mega-trigger[aria-expanded="true"] {
  color: var(--color-accent);
  background: rgba(255, 107, 0, 0.06);
  border-color: rgba(255, 107, 0, 0.18);
}

.loja-nav__mega-trigger:focus-visible {
  outline: 2px solid rgba(255, 107, 0, 0.4);
  outline-offset: 2px;
}

.loja-nav__mega-caret {
  flex-shrink: 0;
  transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.loja-nav__mega-trigger[aria-expanded="true"] .loja-nav__mega-caret {
  transform: rotate(180deg);
}

/* ----------------------------------------------------------
   PANEL
   ---------------------------------------------------------- */
.mega-menu {
  position: fixed;
  top: var(--mega-menu-top, 0px);
  left: 0;
  right: 0;
  z-index: 200;
  background: #ffffff;
  border-top: 1px solid rgba(17, 17, 17, 0.06);
  box-shadow:
    0 2px 0 rgba(17, 17, 17, 0.03),
    0 24px 64px rgba(10, 12, 30, 0.14),
    0 8px 24px rgba(10, 12, 30, 0.07);
  /* Estado oculto — animação via JS */
  display: none;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 200ms ease,
    transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mega-menu.is-visible { display: flex; }
.mega-menu.is-open    { opacity: 1; transform: none; }

/* Grid interno */
.mega-menu__inner {
  display: grid;
  grid-template-columns: 220px 1fr;
  width: 100%;
  max-width: min(1280px, calc(100vw - 48px));
  margin-inline: auto;
}

/* ----------------------------------------------------------
   COLUNA ESQUERDA — Marcas
   ---------------------------------------------------------- */
.mega-menu__brands-col {
  position: relative;
  border-right: 1px solid var(--color-border);
  padding: 28px 0 32px;
}

.mega-menu__brands-label {
  margin: 0 0 8px;
  padding: 0 24px;
  font-family: var(--font-heading);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(17, 17, 17, 0.35);
}

.mega-menu__brand-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mega-menu__brand-item { display: block; }

/* Label + icon agrupados */
.mega-menu__brand-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* Logo SVG da marca */
.mega-menu__brand-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f4f4f5;
  overflow: hidden;
  transition: background 120ms ease;
}

.mega-menu__brand-icon svg {
  width: 28px;
  height: 28px;
}

.mega-menu__brand-btn.is-active .mega-menu__brand-icon {
  background: #ebebec;
}

.mega-menu__brand-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 24px;
  border: none;
  border-left: 2px solid transparent;
  background: transparent;
  color: rgba(17, 17, 17, 0.52);
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition:
    color 120ms ease,
    background 120ms ease,
    border-left-color 120ms ease;
}

.mega-menu__brand-btn:hover {
  color: var(--color-text);
  background: rgba(17, 17, 17, 0.025);
}

.mega-menu__brand-btn.is-active {
  color: var(--color-accent);
  background: rgba(255, 107, 0, 0.04);
  border-left-color: var(--color-accent);
  font-weight: 600;
}

.mega-menu__brand-arrow {
  font-size: 0.8rem;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 120ms ease, transform 120ms ease;
  flex-shrink: 0;
}

.mega-menu__brand-btn:hover .mega-menu__brand-arrow,
.mega-menu__brand-btn.is-active .mega-menu__brand-arrow {
  opacity: 1;
  transform: none;
}

/* ----------------------------------------------------------
   COLUNA DIREITA — Modelos
   ---------------------------------------------------------- */
.mega-menu__models-col {
  display: flex;
  flex-direction: column;
  padding: 32px 48px 36px;
  min-height: 400px;
  transition: opacity 120ms ease;
}

.mega-menu__models-col.is-switching { opacity: 0; }

/* ------ Brand hero (logo + nome + contagem) ------ */
.mega-menu__brand-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(17, 17, 17, 0.07);
}

.mega-menu__brand-hero-logo {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #f4f4f5;
  border: 1px solid rgba(17, 17, 17, 0.06);
  overflow: hidden;
}

.mega-menu__brand-hero-logo svg {
  width: 44px;
  height: 44px;
}

.mega-menu__brand-hero-text {
  min-width: 0;
}

.mega-menu__models-brand-name {
  margin: 0 0 3px;
  font-family: var(--font-heading);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
  line-height: 1.1;
}

.mega-menu__models-subtitle {
  margin: 0;
  color: rgba(17, 17, 17, 0.4);
  font-size: 0.78rem;
  font-family: var(--font-heading);
  font-weight: 500;
}

/* ------ Grid de cards ------ */
.mega-menu__models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  align-content: start;
  margin-bottom: auto;
}

/* Card de modelo */
.mega-menu__model-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(17, 17, 17, 0.09);
  background: #fafafa;
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease,
    transform 180ms cubic-bezier(0.34, 1.26, 0.64, 1),
    color 150ms ease;
}

.mega-menu__model-chip::after {
  content: '\203A';
  flex-shrink: 0;
  margin-left: 6px;
  font-size: 1.05rem;
  color: rgba(17, 17, 17, 0.22);
  transition: color 150ms ease, transform 150ms ease;
}

.mega-menu__model-chip:hover {
  border-color: var(--color-accent);
  background: rgba(255, 107, 0, 0.04);
  color: var(--color-accent);
  box-shadow: 0 2px 16px rgba(255, 107, 0, 0.12);
  transform: translateY(-1px);
}

.mega-menu__model-chip:hover::after {
  color: var(--color-accent);
  transform: translateX(3px);
}

.mega-menu__model-chip:active {
  transform: scale(0.97);
}

.mega-menu__model-chip:focus-visible {
  outline: 2px solid rgba(255, 107, 0, 0.45);
  outline-offset: 2px;
}

/* ------ Footer CTA ------ */
.mega-menu__footer {
  margin-top: 28px;
  padding-top: 0;
}

.mega-menu__all-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: opacity 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 2px 12px rgba(255, 107, 0, 0.22);
}

.mega-menu__all-link:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 107, 0, 0.28);
}

/* ----------------------------------------------------------
   SLIDE TRACK (desktop: transparente; mobile: trilho animado)
   ---------------------------------------------------------- */
.mega-menu__slide-track {
  display: contents;
}

/* ----------------------------------------------------------
   BOTÃO VOLTAR (mobile — hidden no desktop)
   ---------------------------------------------------------- */
.mega-menu__back {
  display: none;
  align-items: center;
  gap: 6px;
  margin: 0 0 24px;
  padding: 7px 12px 7px 8px;
  border: 1px solid rgba(17, 17, 17, 0.09);
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.04);
  color: rgba(17, 17, 17, 0.55);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 130ms ease, background 130ms ease, border-color 130ms ease;
}

.mega-menu__back:hover {
  color: var(--color-text);
  background: rgba(17, 17, 17, 0.07);
  border-color: rgba(17, 17, 17, 0.16);
}

.mega-menu__back:focus-visible {
  outline: 2px solid rgba(255, 107, 0, 0.4);
  outline-offset: 2px;
}

/* ----------------------------------------------------------
   BOTÃO FECHAR (mobile — hidden no desktop)
   ---------------------------------------------------------- */
.mega-menu__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: transparent;
  color: var(--color-body);
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease;
}

.mega-menu__close:hover {
  background: var(--color-surface-soft);
  color: var(--color-text);
}

.mega-menu__close:focus-visible {
  outline: 2px solid rgba(255, 107, 0, 0.4);
  outline-offset: 2px;
}

/* ----------------------------------------------------------
   BACKDROP
   ---------------------------------------------------------- */
.mega-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(8, 10, 22, 0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  opacity: 0;
  transition: opacity 200ms ease;
  cursor: pointer;
}

.mega-menu-backdrop.is-visible { display: block; }
.mega-menu-backdrop.is-open    { opacity: 1; }

/* ----------------------------------------------------------
   MOBILE  (≤ 840px)
   ---------------------------------------------------------- */
@media (max-width: 840px) {
  /* Painel vira sheet fullscreen — desliza da direita */
  .mega-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    overflow: hidden;   /* clip — scroll é por coluna */
    opacity: 1;
    transform: translateX(100%);
    transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
  }

  .mega-menu.is-open {
    transform: translateX(0);
  }

  .mega-menu__inner {
    display: block;
    height: 100%;
    overflow: hidden;
    position: relative;
  }

  /* Trilho deslizante — contém brands + models lado a lado */
  .mega-menu__slide-track {
    display: flex;
    width: 200%;
    height: 100%;
    transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }

  .mega-menu__slide-track.is-models {
    transform: translateX(-50%);
  }

  /* Cada painel = 100vw, scroll independente */
  .mega-menu__brands-col,
  .mega-menu__models-col {
    width: 50%;
    flex-shrink: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 100%;
    box-sizing: border-box;
  }

  .mega-menu__brands-col {
    border-right: none;
    padding: 64px 0 32px;
  }

  .mega-menu__models-col {
    padding: 20px 20px 48px;
    min-height: unset;
  }

  /* Hero menor no mobile */
  .mega-menu__brand-hero {
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  .mega-menu__brand-hero-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }

  .mega-menu__brand-hero-logo svg {
    width: 36px;
    height: 36px;
  }

  .mega-menu__models-brand-name {
    font-size: 1.25rem;
    margin-top: 0;
  }

  /* 2 colunas no mobile */
  .mega-menu__models-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mega-menu__model-chip {
    padding: 14px 12px;
    font-size: 0.82rem;
    border-radius: 14px;
  }

  /* CTA full-width no mobile */
  .mega-menu__footer {
    margin-top: 24px;
  }

  .mega-menu__all-link {
    width: 100%;
    justify-content: center;
    padding: 13px 20px;
    font-size: 0.85rem;
  }

  .mega-menu__close {
    display: flex;
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
  }

  .mega-menu__back {
    display: inline-flex;
  }

  /* Backdrop desnecessário em fullscreen */
  .mega-menu-backdrop {
    display: none !important;
  }

  .loja-nav__mega-trigger {
    font-size: 0.82rem;
    padding: 6px 12px;
  }
}
