/*
 * menu-layout.css
 * Styling for the menu-layer storefront navigation (menu = parent of category).
 * Loaded after the existing stylesheets so it wins the cascade. All classes are
 * namespaced with `ml-` to avoid collisions with the legacy menu/items CSS.
 */

/* ---- shared ---- */
.ml-hidden { display: none !important; }

/* Note: the menu-section pill + category headings are styled in items_v2.php's inline
   <style> instead of here — that block is injected after this stylesheet and wins the
   cascade for those shared classes. Keep this file to the ml-* nav components. */

/* ---- top-bar menu selector (Layout A) ---- */
.ml-menu-select {
  position: relative;
  display: inline-flex;
  flex: none;
  margin-right: 10px;
}

/* Category nav row: [toggle] [menu selector] [category pills ->] on one line. */
.sticky-category-section .iteams-nav.ml-nav-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ml-nav-inline .ml-layout-toggle { flex: none; margin-left: 0; order: 0; }
.ml-nav-inline .ml-menu-select { flex: none; margin-right: 0; order: 1; }
.ml-nav-inline #ds-sub-menu { flex: 1 1 auto; min-width: 0; order: 2; }
.ml-nav-inline #ds-sub-menu2 { order: 3; }
.ml-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--primary-color, #2b6cff);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  max-width: 240px;
}
.ml-menu-btn .ml-menu-btn-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ml-menu-btn .ml-chevron {
  transition: transform 0.15s ease;
  flex: none;
}
.ml-menu-btn.ml-open .ml-chevron { transform: rotate(180deg); }

.ml-menu-popup {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 300;
  width: 500px;
  max-width: 86vw;
  max-height: 66vh;
  overflow-y: auto;
  background: #fff;
  border: 0.5px solid #f0f0f0;
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(17, 17, 26, 0.10);
  padding: 10px;
}
@media (max-width: 991px) { .ml-menu-popup { width: 340px; } }

/* ---- menu groups + category chips (shared by popup and rail) ---- */
.ml-menu-group { margin-bottom: 12px; }
.ml-menu-group:last-child { margin-bottom: 0; }
.ml-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  padding: 6px 4px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.ml-menu-group.ml-active > .ml-menu-head { color: var(--primary-color, #2b6cff); }
.ml-menu-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px;
}
.ml-cat-item {
  border: 1px solid transparent;
  background: #f4f4f6;
  color: #374151;
  border-radius: 999px;
  padding: 8px 15px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.ml-cat-item:hover { background: #ececee; }
.ml-cat-item.ml-active {
  background: var(--primary-color, #2b6cff);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}

/* ---- menu dropdown popup: modern group treatment ---- */
.ml-menu-head-name { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.ml-menu-dot {
  width: 7px; height: 7px; min-width: 7px; border-radius: 50%;
  background: #d6d3db; display: inline-block;
}
.ml-menu-group.ml-active .ml-menu-dot { background: var(--primary-color, #2b6cff); }
.ml-menu-count {
  font-size: 12px; font-weight: 600; color: #9ca3af;
  background: #f4f4f6; border-radius: 999px; padding: 2px 9px; min-width: 24px; text-align: center;
}
.ml-menu-popup .ml-menu-group { border-radius: 14px; padding: 8px 10px 12px; margin-bottom: 2px; }
.ml-menu-popup .ml-menu-group.ml-active {
  background: #f5f4f7;
  background: color-mix(in srgb, var(--primary-color, #3a0a5c) 7%, #fff);
}
.ml-menu-popup .ml-menu-group.ml-active .ml-cat-item:not(.ml-active) { background: #fff; }
.ml-menu-popup .ml-menu-group.ml-active .ml-menu-count { background: #fff; }

/* ---- layout toggle (bar <-> rail), desktop only ---- */
.ml-layout-toggle {
  display: inline-flex;
  border: 1px solid #e2e0e0;
  border-radius: 999px;
  overflow: hidden;
  flex: none;
  margin-left: 8px;
}
.ml-layout-toggle [data-layout] {
  border: none;
  background: transparent;
  padding: 6px 10px;
  cursor: pointer;
  color: #777;
  display: inline-flex;
  align-items: center;
}
.ml-layout-toggle [data-layout].ml-active {
  background: #f2f2f2;
  color: var(--primary-color, #2b6cff);
}
@media (max-width: 991px) {
  .ml-layout-toggle { display: none; }
  /* Mobile: menu selector becomes an icon-only launcher pinned left of the pills.
     The grey section pill already names the current menu, so the button label + chevron
     are dropped. Still opens the same menu-jump popup. */
  .ml-menu-btn { max-width: none; gap: 0; padding: 0; width: 38px; height: 38px; justify-content: center; border-radius: 12px; }
  .ml-menu-btn .ml-menu-btn-label,
  .ml-menu-btn .ml-chevron { display: none; }
}

/* ---- side rail (Layout B) ---- */
.ml-rail {
  display: none;
  width: 280px;
  flex: none;
  border-right: 1px solid #f0f0f0;
  padding: 16px 14px 16px 4px;
  position: sticky;
  top: 90px;
  align-self: flex-start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.ml-rail-title {
  margin: 0 0 0px; padding: 0 10px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.7px;
  text-transform: uppercase; color: #9ca3af;
}
.ml-rail .ml-menu-group { padding: 10px 0 4px; margin-bottom: 0; }
.ml-rail .ml-menu-group + .ml-menu-group { border-top: 0.5px solid #f0f0f0; }
.ml-rail .ml-menu-head { font-size: 16px; font-weight: 600; padding: 4px 10px 8px; }
.ml-rail-head-right { display: inline-flex; align-items: center; gap: 8px; color: #9ca3af; }
.ml-rail .ml-menu-head .ml-rail-caret { transition: transform 0.15s ease; }
.ml-rail .ml-menu-group.ml-collapsed .ml-menu-cats { display: none; }
.ml-rail .ml-menu-group.ml-collapsed .ml-rail-caret { transform: rotate(-90deg); }
.ml-rail .ml-menu-cats { flex-direction: column; flex-wrap: nowrap; gap: 2px; padding: 0 4px 6px; }
.ml-rail .ml-cat-item {
  border: none;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #555;
}
.ml-rail .ml-cat-item:hover { background: #f4f4f6; }
.ml-rail .ml-cat-item.ml-active {
  background: #f0ebf7;
  background: color-mix(in srgb, var(--primary-color, #3a0a5c) 8%, #fff);
  color: var(--primary-color, #2b6cff);
  font-weight: 600;
}

/* Rail layout mode: sticky search bar spans the top, then rail (left) + items (right).
   Uses flex on .top_menu_btn so the rail can stay position:sticky (a floated element
   would ignore sticky). Bar mode = default (no restructuring). */
#items.ml-mode-rail .top_menu_btn { display: flex; flex-wrap: wrap; align-items: flex-start; }
#items.ml-mode-rail .iteamsSarch { flex: 0 0 100%; }
#items.ml-mode-rail .ml-rail { display: block; flex: 0 0 280px; }
#items.ml-mode-rail .categorys.all_items_home_page { flex: 1 1 0%; min-width: 0; margin-left: 16px; }
/* Rail mode: hide the category pills AND the menu selector (the rail replaces both). */
#items.ml-mode-rail #ds-sub-menu,
#items.ml-mode-rail #ds-sub-menu2 { display: none; }
#items.ml-mode-bar .ml-rail { display: none; }

#items.ml-mode-rail .menu-section { margin-left: 20px; }

/* Rail mode, desktop only: drop the top menu selector, pull Filters/Sort up next to the
   layout switch, show 2 item cards per row, and remove the inter-card gap. Wrapped in a
   desktop media query so the mobile fallback (which reverts to bar layout) is untouched. */
@media (min-width: 992px) {
  #items.ml-mode-rail .ml-menu-select { display: none; }
  /* Rail mode (desktop only): reduce the category-title band's vertical padding
     (22px -> 12px) and drop the top margin above the dashed border. Bar mode keeps 22px. */
  #items.ml-mode-rail .sticky-category-section .iteam_menu_title1 {
    padding-top: 12px;
    padding-bottom: 12px;
    margin-top: 0;
  }
  #items.ml-mode-rail .iteam_menu_title1 { display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; }
  #items.ml-mode-rail .menuHead { flex: 0 0 100%; }
  #items.ml-mode-rail .ml-nav-inline { flex: 0 0 auto; width: auto; }
  #items.ml-mode-rail .ml-toolbar { flex: 0 0 auto; padding-top: 0; padding-bottom: 0; }
  #items.ml-mode-rail .category-items { gap: 12px; }
  #items.ml-mode-rail .all_items_home_page .category-items .iteam_menu { width: calc(50% - 6px); }
}
@media (max-width: 991px) {
  /* Side rail is desktop only; mobile always uses the bar. */
  #items.ml-mode-rail .top_menu_btn { display: block; }
  #items.ml-mode-rail .ml-rail { display: none; }
  #items.ml-mode-rail .categorys.all_items_home_page { margin-left: 0; }
  #items.ml-mode-rail #ds-sub-menu,
  #items.ml-mode-rail #ds-sub-menu2 { display: block; }
}

/* ---- Sort and filter toolbar (client-side) — clean, minimal ---- */
.ml-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 0 2px; }
.ml-fs { position: relative; }

/* Trigger pills: borderless soft fill, muted icons, soft hover */
.ml-fs-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #f4f4f6; color: #1a1a1a; border: 1px solid transparent; border-radius: 999px;
  padding: 10px 18px; font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background 0.15s ease;
}
.ml-fs-btn:hover { background: #ececee; }
.ml-fs-btn.ml-open { background: #ececee; }
.ml-fs-btn svg:not(.ml-fs-caret) { color: #6b7280; }
.ml-fs-caret { color: #9ca3af; transition: transform 0.15s ease; }
.ml-fs-btn.ml-open .ml-fs-caret { transform: rotate(180deg); }

/* Active-filters indicator: a small accent dot (not a number) */
.ml-filter-badge {
  width: 7px; height: 7px; min-width: 7px; padding: 0; font-size: 0;
  border-radius: 50%; background: var(--primary-color, #3a0a5c); display: inline-block;
}

/* Dropdown panel: airy, soft shadow */
.ml-fs-panel {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 300;
  background: #fff; border: 0.5px solid #f0f0f0; border-radius: 18px;
  box-shadow: 0 14px 40px rgba(17, 17, 26, 0.08); padding: 20px;
  min-width: 340px; max-width: 92vw;
  /* Long allergen lists overflowed off-screen; cap the height and scroll inside. */
  max-height: min(70vh, 520px); overflow-y: auto;
}
.ml-fs-group-label {
  margin: 0 0 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.7px;
  text-transform: uppercase; color: #9ca3af;
}
.ml-fs-pills { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 20px; }

/* Option pills: borderless soft fill */
.ml-fs-pill {
  border: 1px solid transparent; background: #f4f4f6; color: #374151; border-radius: 999px;
  padding: 8px 16px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.ml-fs-pill:hover { background: #ececee; }
.ml-fs-pill.ml-active { background: var(--primary-color, #3a0a5c); color: #fff; font-weight: 600; }
/* Allergen (multi-select) selected = soft tint + check, softer than a solid fill */
.ml-fs-pills[data-filter="allergens"] .ml-fs-pill.ml-active {
  background: #f0ebf7; color: var(--primary-color, #3a0a5c);
}
.ml-fs-pills[data-filter="allergens"] .ml-fs-pill.ml-active::before {
  content: "\2713"; margin-right: 6px; font-weight: 600;
}

.ml-fs-footer { display: flex; align-items: center; border-top: 0.5px solid #f0f0f0; padding-top: 16px; }
.ml-fs-clear {
  background: none; border: none; color: #0d6efd;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 0;
  transition: color 0.15s ease;
}
.ml-fs-clear:hover { color: #0b5ed7; }

/* Sort panel: refined selectable list */
.ml-sort-panel { min-width: 240px; padding: 8px; }
.ml-fs-opt {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: none; text-align: left; font-family: inherit; font-size: 15px; font-weight: 600; color: #374151;
  border-radius: 11px; padding: 11px 14px; cursor: pointer; transition: background 0.15s ease;
}
.ml-fs-opt:hover { background: #f7f7f7; }
.ml-fs-opt.ml-active { background: #f0ebf7; color: var(--primary-color, #3a0a5c); font-weight: 600; }
.ml-fs-opt.ml-active::after { content: "\2713"; font-size: 15px; }

.ml-fs-empty { display: none; padding: 44px 16px; text-align: center; color: #9ca3af; font-size: 16px; }
.ml-fs-empty .ml-fs-clear { margin-left: 8px; font-size: 16px; }
/* Nav entries emptied by the active filters: dimmed but still hoverable so the native
   "Hidden by your filters" tooltip shows; clicks are blocked in JS (capture phase). */
.ml-nav-hidden { opacity: 0.35; cursor: not-allowed; }
.ml-nav-hidden * { cursor: not-allowed; }

/* ---- Sticky search slot: holds the header search when scrolled (desktop, both layouts) ---- */
.ml-search-slot:empty { display: none; }
.ml-search-slot {
  flex: 1 1 auto; min-width: 0; max-width: 560px; margin-left: 0;
  display: flex; align-items: center;
}
/* Container must fill the slot so the icon (anchored to the container's right edge) lands at
   the input's right edge, not mid-field. The header's `margin-right:22px !important` is reset. */
.ml-search-slot .searchContainer {
  flex: 1 1 auto; width: auto; min-width: 0; margin: 0 !important;
}
.ml-search-slot .searchInput {
  width: 100%; min-width: 0; box-sizing: border-box;
  padding: 9px 40px 9px 16px; font-size: 14px; border-radius: 999px;
}
/* Vertically centre the magnifier at the right edge regardless of input height. */
.ml-search-slot .searchIcon { top: 50%; right: 16px; transform: translateY(-50%); }
@media (max-width: 991px) { .ml-search-slot { display: none; } }

@media (max-width: 550px) {
  .sticky-category-section .iteams-nav.ml-nav-inline {
    gap: 0;
  }
  .ml-fs-btn {
    padding: 8px 18px;
  }
  .ml-fs-panel {
    z-index: 300 !important;
  }
}
