/*
 * ERG Mega Menu — Vertical "Browse Categories" Layout
 * Best Of Indian Products — Harkanwal Singh
 *
 * Architecture:
 *  .erg-mm-v-nav             — <nav> wrapper
 *  .erg-mm-v-trigger         — "Browse Categories" bar that opens/closes the whole thing
 *  .erg-mm-v-menu-wrap       — dropdown shell (sidebar + panel), absolutely positioned under the trigger
 *  .erg-mm-v-menu            — <ul> sidebar list of top-level categories
 *  .erg-mm-v-row             — one sidebar row (top-level category)
 *  .erg-mm-v-row--active     — the row whose panel is currently showing
 *  .erg-mm-v-panel           — right-hand content panel for one top-level category
 *  .erg-mm-v-panel--active   — the panel currently visible (only one at a time on desktop)
 *  .erg-mm-v-panel-groups    — multi-column flow of heading+list blocks inside a panel
 *  .erg-mm-v-group           — one "HEADING + links" block
 *  .erg-mm-v-group-title     — bold, uppercase subcategory heading
 *  .erg-mm-v-group-list      — plain link list under a heading
 *
 * Colours come from the same CSS custom properties as the horizontal
 * layout (ERG_MM_Settings::output_css_vars()) — no hardcoded colours.
 */

.erg-mm-v-nav * ,
.erg-mm-v-nav *::before,
.erg-mm-v-nav *::after {
  box-sizing: border-box;
}

.erg-mm-v-nav {
  position: relative;
  z-index: 1000;
  display: inline-block;
}

/* ── TRIGGER BAR ─────────────────────────────────────────────── */
.erg-mm-v-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--erg-mm-nav-bg, #1B3F6B);
  color: var(--erg-mm-nav-text, #fff);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 0 18px;
  height: 48px;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.15s;
}
.erg-mm-v-trigger:hover,
.erg-mm-v-trigger[aria-expanded="true"] {
  background: var(--erg-mm-nav-bg-hover, #16335A);
}

.erg-mm-v-trigger-burger {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 16px;
  flex-shrink: 0;
}
.erg-mm-v-trigger-burger span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.erg-mm-v-trigger-chevron {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.erg-mm-v-trigger[aria-expanded="true"] .erg-mm-v-trigger-chevron {
  transform: rotate(180deg);
}

/* ── DROPDOWN SHELL ──────────────────────────────────────────── */
.erg-mm-v-menu-wrap {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: flex;
  align-items: stretch;
  background: var(--erg-mm-drop-bg, #fff);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
  overflow: hidden;
  z-index: 1001;
  min-width: 780px;
  max-width: min(1100px, calc(100vw - 32px));

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.erg-mm-v-nav.erg-mm-v-nav--open .erg-mm-v-menu-wrap {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* ── SIDEBAR (top-level categories) ─────────────────────────── */
.erg-mm-v-menu {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  width: 240px;
  flex-shrink: 0;
  background: var(--erg-mm-v-sidebar-bg, #fff);
  border-right: 1px solid var(--erg-mm-v-border, #ececec);
  overflow-y: auto;
}

.erg-mm-v-row {
  border-bottom: 1px solid var(--erg-mm-v-border, #f2f2f2);
}
.erg-mm-v-row:last-child {
  border-bottom: none;
}

.erg-mm-v-row-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  color: var(--erg-mm-drop-text, #1E1E1E);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}

.erg-mm-v-row:hover .erg-mm-v-row-link,
.erg-mm-v-row--active .erg-mm-v-row-link {
  background: var(--erg-mm-drop-hover, #F9F5EE);
  color: var(--erg-mm-accent, #D4500A);
}

.erg-mm-v-row-icon--emoji {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}
.erg-mm-v-row-icon--img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

.erg-mm-v-row-label {
  flex: 1;
  min-width: 0;
  white-space: normal;
}

.erg-mm-v-row-badge {
  font-size: 9px;
  flex-shrink: 0;
}

.erg-mm-v-row-chevron {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.12s, transform 0.12s;
}
.erg-mm-v-row:hover .erg-mm-v-row-chevron,
.erg-mm-v-row--active .erg-mm-v-row-chevron {
  opacity: 1;
  transform: translateX(2px);
}

/* ── RIGHT PANEL ─────────────────────────────────────────────── */
.erg-mm-v-panel {
  display: none;
  flex: 1;
  min-width: 0;
  padding: 28px 32px;
  max-height: min(560px, calc(100vh - 160px));
  overflow-y: auto;
}
.erg-mm-v-panel--active {
  display: block;
}

.erg-mm-v-panel-groups {
  column-count: 3;
  column-gap: 36px;
}

.erg-mm-v-group {
  break-inside: avoid;
  margin-bottom: 26px;
}

.erg-mm-v-group-title {
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--erg-mm-nav-bg, #1B3F6B);
  margin-bottom: 10px;
}
.erg-mm-v-group-title a {
  color: inherit;
  text-decoration: none;
}
.erg-mm-v-group-title a:hover {
  color: var(--erg-mm-accent, #D4500A);
}

.erg-mm-v-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.erg-mm-v-group-item {
  margin-bottom: 8px;
}

.erg-mm-v-group-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--erg-mm-drop-text, #4B4B4B);
  font-size: 13px;
  text-decoration: none;
  line-height: 1.4;
  transition: color 0.12s;
}
.erg-mm-v-group-link:hover {
  color: var(--erg-mm-accent, #D4500A);
}

.erg-mm-v-group-link .erg-mm-child-img-wrap {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: #f4f4f4;
}
.erg-mm-v-group-link .erg-mm-child-img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  display: block;
}

.erg-mm-v-group-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.erg-mm-v-group-item-text .erg-mm-child-count {
  font-size: 11px;
  color: #999;
}

/* Sparse deep nesting fallback (rare 4th+ level) */
.erg-mm-v-sub-list {
  list-style: none;
  margin: 4px 0 0 14px;
  padding: 0;
}

/* ── CLOSE ON CLICK-OUTSIDE HELPER OVERLAY (mobile only) ──────── */
.erg-mm-v-overlay {
  display: none;
}

/* ── TABLET: 2 columns ───────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1100px) {
  .erg-mm-v-menu-wrap {
    min-width: 620px;
  }
  .erg-mm-v-panel-groups {
    column-count: 2;
  }
}

/* ── MOBILE: full-width accordion drawer ──────────────────────── */
@media (max-width: 767px) {
  .erg-mm-v-nav {
    display: block;
    width: 100%;
  }
  .erg-mm-v-trigger {
    width: 100%;
    justify-content: flex-start;
    border-radius: 4px;
  }

  .erg-mm-v-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }
  .erg-mm-v-nav--open .erg-mm-v-overlay {
    display: block;
  }

  .erg-mm-v-menu-wrap {
    position: fixed;
    top: 0;
    left: -100%;
    right: auto;
    width: min(340px, 88vw);
    height: 100vh;
    max-width: none;
    min-width: 0;
    border-radius: 0;
    flex-direction: column;
    z-index: 999;
    transform: none;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .erg-mm-v-nav--open .erg-mm-v-menu-wrap {
    left: 0;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .erg-mm-v-menu {
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--erg-mm-v-border, #ececec);
    flex-shrink: 0;
  }

  /* Each row becomes an accordion trigger; its panel drops in place
     directly beneath it instead of showing in a separate pane. */
  .erg-mm-v-row {
    display: flex;
    flex-direction: column;
  }
  .erg-mm-v-panel {
    order: 1;
    max-height: none;
    padding: 8px 18px 18px 44px;
    background: var(--erg-mm-drop-hover, #F9F5EE);
  }
  .erg-mm-v-row--active .erg-mm-v-panel {
    display: block;
  }
  .erg-mm-v-row:not(.erg-mm-v-row--active) .erg-mm-v-panel {
    display: none;
  }
  .erg-mm-v-panel-groups {
    column-count: 1;
  }
}

/* ── FOCUS STYLES ────────────────────────────────────────────── */
.erg-mm-v-trigger:focus-visible,
.erg-mm-v-row-link:focus-visible,
.erg-mm-v-group-link:focus-visible {
  outline: 2px solid var(--erg-mm-accent, #D4500A);
  outline-offset: -2px;
}
