/*
 * مگامنوی دسکتاپ (.nmm) و منوی دسته‌بندی موبایل (.nmob)
 * ویوها: resources/views/shop/main/partials/header/_megamenu-*.blade.php
 * رنگ‌ها و فونت از توکن‌های باندل اصلی سایت می‌آیند؛ مقدار دوم هر var همان مقدار سایت است.
 */

:root {
  --nm-primary: var(--color-primary-500, #1c74bd);
  --nm-text: var(--color-primary-text, #3f4064);
  --nm-muted: #74768c;
  --nm-faint: #a2a4b5;
  --nm-line: var(--color-gray-50, #f2f2f2);
  --nm-active-bg: #f0f6fc;
  --nm-soft: #f8f9fb;
}

/* ------------------------------------------------------------------ */
/* آیکن‌ها (مشترک)                                                     */
/* ------------------------------------------------------------------ */

.nm-ico {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nm-icobox {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid #ebedf2;
  border-radius: 9px;
  background: #fff;
  color: var(--nm-muted);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nm-icobox img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.nm-icobox i {
  font-size: 16px;
  line-height: 1;
}

/* ------------------------------------------------------------------ */
/* دسکتاپ                                                              */
/* ------------------------------------------------------------------ */

#header-bottom > .header-wrapper {
  position: relative;
}

/* پنل باید به عرض کامل هدر بچسبد، نه به ردیف لینک‌ها */
@media (min-width: 48rem) {
  #header-bottom .header-menu {
    position: static;
  }
}

.nmm-trigger {
  display: none;
}

@media (min-width: 48rem) {
  .nmm-trigger {
    align-self: stretch;
    display: flex;
    align-items: center;
  }
}

.nmm-trigger > .noornegar-btn {
  transition: background-color 0.15s ease;
}

.nmm-trigger > .noornegar-btn[aria-expanded="true"] {
  background-color: var(--nm-primary);
}

.nmm {
  position: absolute;
  top: 100%;
  right: calc(var(--spacing, 0.25rem) * 4);
  left: calc(var(--spacing, 0.25rem) * 4);
  z-index: 9;
  display: flex;
  height: var(--nmm-h, 540px);
  background: #fff;
  border-top: 1px solid var(--nm-line);
  border-radius: 0 0 1rem 1rem;
  box-shadow: 0 16px 32px -12px rgb(37 38 66 / 0.18);
  overflow: hidden;
}

/* ستون دسته‌ها */
.nmm__rail {
  width: 236px;
  flex-shrink: 0;
  padding-block: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-inline-end: 1px solid var(--nm-line);
  scrollbar-width: thin;
  scrollbar-color: #dcdde3 transparent;
}

.nmm__cat {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 50px;
  margin-inline: 8px;
  padding-inline: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--nm-text);
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nmm__cat:hover .nm-icobox {
  color: var(--nm-primary);
  border-color: #d6e6f5;
}

.nmm__cat.is-active {
  background: var(--nm-active-bg);
  color: var(--nm-primary);
  font-weight: 700;
}

.nmm__cat.is-active .nm-icobox {
  background: var(--nm-primary);
  border-color: var(--nm-primary);
  color: #fff;
  box-shadow: 0 4px 10px -4px rgb(28 116 189 / 0.6);
}

.nmm__cat:focus-visible {
  outline: 2px solid var(--nm-primary);
  outline-offset: -2px;
}

.nmm__cat-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nmm__cat-arrow {
  width: 6px;
  height: 11px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.nmm__cat.is-active .nmm__cat-arrow {
  opacity: 1;
}

/* محتوای دسته */
.nmm__panes {
  position: relative;
  flex: 1;
  min-width: 0;
}

.nmm__pane {
  position: absolute;
  inset: 0;
  padding: 20px 32px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #dcdde3 transparent;
}

.nmm__all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--nm-primary);
}

.nmm__all svg {
  width: 6px;
  height: 11px;
  transition: transform 0.15s ease;
}

.nmm__all:hover svg {
  transform: translateX(-3px);
}

/* بخش‌ها کنار هم می‌نشینند و اگر جا نبود به ردیف بعد می‌روند */
.nmm__sections {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 56px;
}

.nmm__section {
  flex: 0 1 calc(var(--cols, 1) * 196px + (var(--cols, 1) - 1) * 36px);
  min-width: 0;
  max-width: 100%;
}

.nmm__section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 800;
  line-height: 24px;
  color: var(--nm-text);
}

.nmm__section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--nm-line);
}

.nmm__section-title svg {
  width: 6px;
  height: 11px;
  color: var(--nm-faint);
}

a.nmm__section-title:hover,
a.nmm__section-title:hover svg {
  color: var(--nm-primary);
}

/* حداکثر --cols ستون، هر ستون دست‌کم ۱۷۰ پیکسل */
.nmm__cols {
  columns: var(--cols, 1) 170px;
  column-gap: 36px;
}

.nmm__group {
  break-inside: avoid;
  padding-bottom: 18px;
}

.nmm__head {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding-inline-start: 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 24px;
  color: var(--nm-text);
}

.nmm__head::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 5px;
  bottom: 5px;
  width: 2px;
  border-radius: 2px;
  background: var(--nm-primary);
}

.nmm__head svg {
  width: 5px;
  height: 9px;
  color: var(--nm-faint);
  transition: color 0.12s ease, transform 0.12s ease;
}

a.nmm__head:hover {
  color: var(--nm-primary);
}

a.nmm__head:hover svg {
  color: var(--nm-primary);
  transform: translateX(-2px);
}

.nmm__list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.nmm__list a,
.nmm__list span {
  display: block;
  padding-inline-start: 10px;
  font-size: 12.5px;
  line-height: 32px;
  color: var(--nm-muted);
  transition: color 0.12s ease;
}

.nmm__list a:hover {
  color: var(--nm-primary);
}

.nmm__empty {
  margin: 0;
  font-size: 13px;
  color: var(--nm-muted);
}

/* ------------------------------------------------------------------ */
/* موبایل                                                              */
/* ------------------------------------------------------------------ */

.nmob {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.nmob__panel {
  position: absolute;
  inset-inline: 0;
  top: var(--mm-top, 0px);
  bottom: 3.75rem;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-top: 1px solid var(--nm-line);
  overflow: hidden;
}

.nmob__body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* تب‌های دسته */
.nmob__rail {
  width: 88px;
  flex-shrink: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f7f7f9;
  scrollbar-width: none;
}

.nmob__rail::-webkit-scrollbar {
  display: none;
}

.nmob__tab {
  position: relative;
  width: 100%;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 6px;
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
  color: var(--nm-muted);
  border-bottom: 1px solid #ececf0;
  cursor: pointer;
}

.nmob__tab.is-active {
  background: #fff;
  color: var(--nm-primary);
  font-weight: 700;
}

.nmob__tab .nm-icobox {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.nmob__tab .nm-ico {
  width: 21px;
  height: 21px;
}

.nmob__tab.is-active .nm-icobox {
  background: var(--nm-primary);
  border-color: var(--nm-primary);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgb(28 116 189 / 0.7);
}

/* محتوای تب */
.nmob__content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px 24px;
  scrollbar-width: none;
}

.nmob__content::-webkit-scrollbar {
  display: none;
}

.nmob__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  border-bottom: 1px solid var(--nm-line);
}

.nmob__all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--nm-primary);
}

.nmob__all svg {
  width: 6px;
  height: 11px;
}

.nmob__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--nm-text);
}

.nmob__close {
  width: 36px;
  height: 36px;
  margin-inline-end: -8px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--nm-muted);
}

.nmob__close svg {
  width: 20px;
  height: 20px;
}

.nmob__section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 20px 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--nm-faint);
}

.nmob__section a {
  color: var(--nm-primary);
  font-weight: 700;
}

.nmob__row {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  text-align: start;
  color: var(--nm-text);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--nm-line);
  cursor: pointer;
}

.nmob__row svg {
  flex-shrink: 0;
  color: var(--nm-faint);
}

.nmob__row .nmob__chev-down {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.nmob__row .nmob__chev-left {
  width: 6px;
  height: 11px;
}

.nmob__acc.is-open > .nmob__row {
  color: var(--nm-primary);
  border-bottom-color: transparent;
}

.nmob__acc.is-open > .nmob__row .nmob__chev-down {
  transform: rotate(180deg);
  color: var(--nm-primary);
}

.nmob__acc-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}

.nmob__acc.is-open > .nmob__acc-body {
  grid-template-rows: 1fr;
}

.nmob__acc-inner {
  min-height: 0;
  overflow: hidden;
}

.nmob__items {
  margin: 0 0 12px;
  padding: 2px 14px;
  background: var(--nm-soft);
  border-radius: 12px;
}

.nmob__items a,
.nmob__items span {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: 13px;
  color: #5d6079;
  border-bottom: 1px solid #eef0f4;
}

.nmob__items > :last-child {
  border-bottom: 0;
}

.nmob__items .nmob__see-all {
  gap: 8px;
  font-weight: 700;
  color: var(--nm-primary);
}

.nmob__items .nmob__see-all svg {
  width: 6px;
  height: 11px;
}

.nmob__empty {
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.9;
  color: var(--nm-muted);
}

/* تب دسترسی سریع: کارت‌های افقی دوستونه، هر میانبر با رنگ خودش */
.nmob__tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 16px;
}

.nmob__tile {
  --tone: var(--nm-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px;
  background: #fff;
  border: 1px solid #edf0f4;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgb(37 38 66 / 0.04);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.nmob__tile:active {
  background: var(--nm-soft);
  border-color: #e2e6ec;
}

.nmob__tile .nm-icobox {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 11px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 11%, #fff);
}

.nmob__tile .nm-ico {
  width: 20px;
  height: 20px;
  stroke-width: 1.7;
}

.nmob__tile-title {
  min-width: 0;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.65;
  color: var(--nm-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* رنگ هر میانبر (از روی آیکنی که برای عنوانش انتخاب شده) */
.nm-tone-cap { --tone: #6d5bd0; }
.nm-tone-cycle { --tone: #1f9d6b; }
.nm-tone-card { --tone: #0e8f9e; }
.nm-tone-tag { --tone: #c47f00; }
.nm-tone-store { --tone: #1c74bd; }
.nm-tone-wrench { --tone: #5b6478; }
.nm-tone-headset { --tone: #e0663a; }
.nm-tone-book { --tone: #d6457a; }

@media (prefers-reduced-motion: reduce) {
  .nmm *,
  .nmob * {
    transition: none !important;
  }
}
