/* Digikala-style mobile bottom navigation — moboniaz2026 */

@media (max-width: 991.98px) {
  /* Header: logo (right) + search field (left) */
  #header .header-wrapper {
    container-type: inline-size;
    container-name: mn2026-header;
  }

  #header .header-wrapper .container-fluid .row {
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 10px;
  }

  #header .header-wrapper .container-fluid .row #logo-container-wrapper {
    order: 1 !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    display: block !important;
  }

  #header .header-wrapper .container-fluid .row #logo-container-wrapper #logo-container a img {
    width: 12% !important;
    height: auto !important;
    max-width: none !important;
    display: block;
  }

  /* 12% of header bar (wrapper is shrink-wrapped, so % alone is unreliable) */
  @supports (width: 1cqw) {
    #header .header-wrapper .container-fluid .row #logo-container-wrapper #logo-container a img {
      width: 12cqw !important;
    }
  }

  #header .header-wrapper .container-fluid .row #search-box-wrapper {
    order: 2 !important;
    flex: 1 1 auto !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    white-space: normal !important;
  }

  /* Keep FiboSearch as an inline field (not icon-only) beside the logo */
  #header #search-box-wrapper .dgwt-wcas-search-wrapp.dgwt-wcas-icon-mobile {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
  }

  #header #search-box-wrapper .dgwt-wcas-search-wrapp.dgwt-wcas-icon-mobile .dgwt-wcas-search-form {
    display: block !important;
  }

  #header #search-box-wrapper .dgwt-wcas-enable-mobile-form,
  #header #search-box-wrapper .dgwt-wcas-icon-handler {
    display: none !important;
  }

  #header .header-wrapper .container-fluid .row #search-box-wrapper #search-box,
  #header .header-wrapper .container-fluid .row #search-box-wrapper #search-box > div,
  #header .header-wrapper .container-fluid .row #search-box-wrapper .dgwt-wcas-search-wrapp,
  #header .header-wrapper .container-fluid .row #search-box-wrapper .dgwt-wcas-search-form {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  #header .header-wrapper .container-fluid .row #search-box-wrapper .dgwt-wcas-sf-wrapp input[type='search'].dgwt-wcas-search-input {
    width: 100% !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 12px !important;
    line-height: 32px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
    background: #f0f0f1 !important;
    border: 0 !important;
    box-sizing: border-box !important;
  }

  #header #account-container {
    display: none !important;
  }

  /*
   * Mega menu lives inside #header (before #main-content in DOM).
   * Without elevating #header, later siblings (slider, cards) paint on top.
   */
  body.mn2026-menu-open #header,
  body.mn2026-menu-closing #header {
    position: relative;
    z-index: 100000100 !important;
    contain: none !important;
  }

  body.mn2026-menu-open #main-content,
  body.mn2026-menu-closing #main-content {
    z-index: 0;
  }

  body.mn2026-menu-open #main-content .product-item,
  body.mn2026-menu-open #home-slider,
  body.mn2026-menu-open #home-offer,
  body.mn2026-menu-open #home-category,
  body.mn2026-menu-closing #main-content .product-item,
  body.mn2026-menu-closing #home-slider,
  body.mn2026-menu-closing #home-offer,
  body.mn2026-menu-closing #home-category {
    z-index: auto !important;
  }

  .mn2026-menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000090;
    background: rgba(0, 0, 0, 0.45);
    opacity: 1;
    transition: opacity 200ms ease;
  }

  body.mn2026-menu-open .mn2026-menu-backdrop,
  body.mn2026-menu-closing .mn2026-menu-backdrop {
    display: block;
    z-index: 100000090;
  }

  body.mn2026-menu-closing .mn2026-menu-backdrop {
    opacity: 0;
    pointer-events: none;
  }

  /* Hide hamburger chrome when closed */
  #header #menu-container .mega-menu-toggle:not(.mega-menu-open),
  #mega-menu-wrap-main_menu > .mega-menu-toggle:not(.mega-menu-open) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /*
   * Max Mega Menu off-canvas styles are only defined ≤768px.
   * Force the open panel for our full mobile range (≤991.98px).
   */
  #mega-menu-wrap-main_menu > .mega-menu-toggle.mega-menu-open {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    opacity: 1 !important;
    background: transparent !important;
    pointer-events: none !important;
    z-index: 100000101 !important;
  }

  #mega-menu-wrap-main_menu > .mega-menu-toggle.mega-menu-open .mega-toggle-blocks-left,
  #mega-menu-wrap-main_menu > .mega-menu-toggle.mega-menu-open .mega-toggle-blocks-center,
  #mega-menu-wrap-main_menu > .mega-menu-toggle.mega-menu-open .mega-toggle-blocks-right {
    display: none !important;
  }

  #mega-menu-wrap-main_menu > .mega-menu-toggle.mega-menu-open + #mega-menu-main_menu,
  body.mn2026-menu-open #mega-menu-wrap-main_menu #mega-menu-main_menu {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    width: min(300px, 100vw) !important;
    max-width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    background-color: #222 !important;
    box-sizing: border-box !important;
    z-index: 100000102 !important;
    overscroll-behavior: contain;
  }

  #mega-menu-wrap-main_menu > .mega-menu-toggle.mega-menu-open ~ button.mega-close,
  body.mn2026-menu-open #mega-menu-wrap-main_menu > button.mega-close {
    display: flex !important;
    align-items: center;
    justify-content: center;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    top: 0 !important;
    right: min(100vw - 40px, 300px) !important;
    left: auto !important;
    width: 40px !important;
    height: 40px !important;
    z-index: 100000103 !important;
    cursor: pointer;
    pointer-events: auto !important;
  }

  body.mn2026-menu-closing #mega-menu-wrap-main_menu #mega-menu-main_menu,
  body.mn2026-menu-closing #mega-menu-wrap-main_menu > button.mega-close {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  body.mn2026-menu-open .mn2026-bottom-nav,
  body.mn2026-menu-closing .mn2026-bottom-nav {
    z-index: 100000104 !important;
  }

  /* Class is set in PHP body_class (not only JS) to avoid late padding CLS */
  body.mn2026-has-bottom-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mn2026-bottom-nav {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    z-index: 100050;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    direction: rtl;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid #e0e0e2;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
  }

  .mn2026-bottom-nav__item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    margin: 0;
    padding: 6px 4px;
    border: 0;
    background: transparent;
    color: #62666d;
    text-decoration: none;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }

  .mn2026-bottom-nav__item:hover,
  .mn2026-bottom-nav__item:focus,
  .mn2026-bottom-nav__item:active {
    color: #ef4056;
    text-decoration: none;
    outline: none;
  }

  .mn2026-bottom-nav__item.is-active {
    color: #ef4056;
  }

  .mn2026-bottom-nav__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 20px;
    line-height: 1;
    position: relative;
  }

  .mn2026-bottom-nav__icon i {
    font-size: 20px;
    line-height: 1;
  }

  .mn2026-bottom-nav__label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
  }

  .mn2026-bottom-nav__badge {
    position: absolute;
    top: -4px;
    left: -8px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4056;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-sizing: border-box;
  }

  .mn2026-bottom-nav__badge:empty,
  .mn2026-bottom-nav__badge[data-count="0"] {
    display: none;
  }
}

@media (min-width: 992px) {
  .mn2026-bottom-nav,
  .mn2026-menu-backdrop {
    display: none !important;
  }

  /* Reset any mobile off-canvas state that may leak to desktop */
  html.mega-menu-main_menu-off-canvas-open,
  body.mega-menu-main_menu-mobile-open {
    overflow: visible !important;
    height: auto !important;
  }

  #mega-menu-wrap-main_menu .mega-menu-toggle {
    display: none !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    clip: auto !important;
    opacity: 1 !important;
    pointer-events: none !important;
    overflow: visible !important;
  }

  #mega-menu-wrap-main_menu #mega-menu-main_menu,
  body.mn2026-menu-open #mega-menu-wrap-main_menu #mega-menu-main_menu,
  #mega-menu-wrap-main_menu > .mega-menu-toggle.mega-menu-open + #mega-menu-main_menu {
    display: block !important;
    position: static !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: transparent !important;
    box-sizing: border-box !important;
    z-index: auto !important;
  }

  #mega-menu-wrap-main_menu #mega-menu-main_menu > li.mega-menu-item {
    display: inline-block !important;
    vertical-align: middle !important;
    float: none !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    height: auto !important;
  }

  #mega-menu-wrap-main_menu #mega-menu-main_menu > li.mega-menu-item > a.mega-menu-link {
    display: block !important;
    line-height: 40px !important;
  }

  #mega-menu-wrap-main_menu > button.mega-close {
    display: none !important;
  }
}
