/*
 * MrTehranLitePlus R1
 * Targeted navigation/header extension on top of MrTehranLite.
 * Scope: Base.ascx only via .mtlp-shell.
 */

:root {
  --mtlp-orange: #ff5a24;
  --mtlp-orange-hover: #ea4613;
  --mtlp-drawer-width: 430px;
}

body.mtlp-lock { overflow: hidden !important; }
body.mtlp-skin-active .kco-launcher { display: none !important; }

.mtlp-shell .mtlp-header-main-row { position: relative; }
.mtlp-shell .mtlp-header-actions {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  direction: rtl;
}

.mtlp-shell .mtlp-header-tool {
  position: relative;
  min-width: 62px;
  min-height: 58px;
  margin: 0;
  padding: 5px 7px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #fff !important;
  text-decoration: none !important;
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1.2;
  transition: background-color .18s ease, color .18s ease, transform .18s ease;
  box-sizing: border-box;
}
.mtlp-shell .mtlp-header-tool:hover,
.mtlp-shell .mtlp-header-tool:focus {
  background: rgba(255,255,255,.14);
  color: #fff !important;
  text-decoration: none !important;
  outline: 0;
}
.mtlp-shell .mtlp-header-tool:active { transform: translateY(1px); }
.mtlp-shell .mtlp-header-tool > i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  margin: 0;
  padding: 0;
  color: #fff !important;
  font-size: 22px;
  line-height: 1;
}
.mtlp-shell .mtlp-header-tool > span,
.mtlp-shell .mtlp-header-tool .mtlp-tool-label {
  color: #fff !important;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  text-align: center;
}

/* BasketPreview is kept native; only its trigger is restyled into the header tool. */
.mtlp-shell .mtlp-basket-host {
  min-width: 66px;
  padding: 0;
  overflow: visible;
}
.mtlp-shell .mtlp-basket-host .btn-show-basket {
  width: 66px !important;
  min-width: 66px !important;
  min-height: 58px !important;
  margin: 0 !important;
  padding: 5px 6px !important;
  border: 0 !important;
  border-radius: 9px !important;
  background: transparent !important;
  color: #fff !important;
  cursor: pointer;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 4px !important;
  box-sizing: border-box !important;
  transition: background-color .18s ease, transform .18s ease;
}
.mtlp-shell .mtlp-basket-host .btn-show-basket:hover,
.mtlp-shell .mtlp-basket-host .btn-show-basket:focus,
.mtlp-shell .mtlp-basket-host .btn-show-basket.active {
  background: rgba(255,255,255,.14) !important;
}
.mtlp-shell .mtlp-basket-host .btn-show-basket:before {
  content: "\f291" !important;
  position: static !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 26px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #fff !important;
  font-family: "Font Awesome 7 Free" !important;
  font-weight: 900 !important;
  font-size: 22px !important;
  line-height: 1 !important;
}
.mtlp-shell .mtlp-basket-host .btn-show-basket.active:before { content: "\f00d" !important; }
.mtlp-shell .mtlp-basket-host .btn-show-basket:after {
  content: "سبد خرید" !important;
  display: block !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  color: #fff !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  white-space: nowrap;
}
.mtlp-shell .mtlp-basket-count {
  position: absolute;
  z-index: 8;
  top: 1px;
  right: 1px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid var(--karen-primary);
  border-radius: 999px;
  background: var(--mtlp-orange);
  color: #fff !important;
  font: 700 11px/16px Tahoma, sans-serif;
  text-align: center;
  box-sizing: border-box;
  pointer-events: none;
}

/* Native basket box is anchored under the new header basket action on desktop. */
@media screen and (min-width: 1200px) {
  .mtlp-shell .mtlp-basket-host .basket-preview-wrap {
    position: absolute !important;
    z-index: 1095 !important;
    top: calc(100% + 8px) !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    width: 380px !important;
    max-width: min(380px, 94vw) !important;
    transform: translateY(-10px) !important;
    opacity: 0 !important;
    pointer-events: none;
  }
  .mtlp-shell .mtlp-basket-host .basket-preview-wrap.active {
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto;
  }
}

/* Desktop category trigger before the existing main menu. */
.mtlp-shell .mtlp-nav-row { min-height: 56px; }
.mtlp-shell .mtlp-nav-inner {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  direction: rtl;
}
.mtlp-shell .mtlp-category-trigger {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 17px;
  border: 0;
  border-radius: 12px;
  background: var(--mtlp-orange);
  color: #fff !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background-color .18s ease, transform .18s ease;
}
.mtlp-shell .mtlp-category-trigger:hover,
.mtlp-shell .mtlp-category-trigger:focus {
  background: var(--mtlp-orange-hover);
  color: #fff !important;
  outline: 0;
}
.mtlp-shell .mtlp-category-trigger:active { transform: translateY(1px); }
.mtlp-shell .mtlp-category-trigger i,
.mtlp-shell .mtlp-category-trigger span { color: #fff !important; }
.mtlp-shell .mtlp-category-trigger i { font-size: 18px; }
.mtlp-shell .mtlp-desktop-menu-slot { flex: 1 1 auto; min-width: 0; }
.mtlp-shell .mtlp-main-nav { width: 100%; }
.mtlp-shell .mtlp-main-menu { margin-top: 0 !important; }

/* R1.1: Base is intentionally single-column. Category HTML is kept only inside the shared drawer. */
.mtlp-shell .mtlp-page-body .mtlp-content-full {
  float: none !important;
  width: 100% !important;
  max-width: none !important;
  border-right: 0 !important;
}
.mtlp-shell .mtlp-category-server-pane {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Shared drawer. Desktop category button opens categories; mobile menu exposes both tabs. */
.mtlp-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147480500;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(0,0,0,.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.mtlp-navigation-drawer {
  position: fixed !important;
  z-index: 2147480600 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: min(var(--mtlp-drawer-width), 94vw) !important;
  height: 100vh !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-left: 1px solid var(--karen-border) !important;
  background: var(--karen-surface) !important;
  color: var(--karen-text) !important;
  box-shadow: -12px 0 38px rgba(0,0,0,.20);
  transform: translate3d(104%,0,0);
  transition: transform .25s ease;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}
body.mtlp-drawer-open .mtlp-drawer-overlay { opacity: 1; pointer-events: auto; }
body.mtlp-drawer-open .mtlp-navigation-drawer { transform: translate3d(0,0,0); }
.mtlp-drawer-head {
  flex: 0 0 auto;
  min-height: 78px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--karen-border);
  background: var(--karen-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mtlp-drawer-heading { display: flex; flex-direction: column; min-width: 0; }
.mtlp-drawer-heading strong { color: var(--karen-text) !important; font-size: 17px; line-height: 1.6; }
.mtlp-drawer-heading span { color: var(--karen-text-muted) !important; font-size: 13px; line-height: 1.6; }
.mtlp-drawer-close {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--karen-border);
  border-radius: 12px;
  background: var(--karen-surface-muted);
  color: var(--karen-text) !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.mtlp-drawer-close i { color: var(--karen-text) !important; font-size: 20px; }
.mtlp-drawer-tabs {
  flex: 0 0 auto;
  min-height: 58px;
  display: none;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--karen-border);
  background: var(--karen-surface-muted);
}
.mtlp-drawer-tab {
  position: relative;
  min-height: 58px;
  border: 0;
  background: transparent;
  color: var(--karen-text-muted) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.mtlp-drawer-tab i,
.mtlp-drawer-tab span { color: inherit !important; }
.mtlp-drawer-tab:after {
  content: "";
  position: absolute;
  right: 16px;
  left: 16px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: transparent;
}
.mtlp-drawer-tab.is-active { color: var(--karen-primary) !important; background: rgba(var(--karen-primary-rgb),.05); }
.mtlp-drawer-tab.is-active:after { background: var(--karen-primary); }
.mtlp-drawer-body { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.mtlp-drawer-panel {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px;
  background: var(--karen-surface);
}
.mtlp-drawer-panel[hidden] { display: none !important; }

/* Category menu keeps its original server-rendered HTML; only drawer sizing is normalized. */
.mtlp-category-drawer-slot,
.mtlp-category-drawer-slot #RightPane,
.mtlp-category-drawer-slot .fsh-category-menu-wrap,
.mtlp-category-drawer-slot .wi-menu { width: 100% !important; max-width: 100% !important; }
.mtlp-category-drawer-slot .fsh-category-menu-wrap { margin: 0 !important; }

/* Main menu inside mobile drawer: same BootstrapMenu HTML, no Ajax/duplicate menu. */
.mtlp-mobile-menu-slot .mtlp-main-nav {
  position: static !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}
.mtlp-mobile-menu-slot .mtlp-main-menu {
  float: none !important;
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}
.mtlp-mobile-menu-slot .mtlp-main-menu > li {
  float: none !important;
  display: block !important;
  width: 100% !important;
  height: auto !important;
  margin: 0 !important;
  visibility: visible !important;
  opacity: 1 !important;
  overflow: visible !important;
}
.mtlp-mobile-menu-slot .mtlp-main-menu > li > a {
  width: 100% !important;
  min-height: 50px;
  padding: 12px 10px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--karen-border) !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--karen-text) !important;
  display: flex !important;
  align-items: center;
  white-space: normal !important;
  font-size: 14px;
}
.mtlp-mobile-menu-slot .mtlp-main-menu > li > a:hover,
.mtlp-mobile-menu-slot .mtlp-main-menu > li > a:focus,
.mtlp-mobile-menu-slot .mtlp-main-menu > li > a:visited { color: var(--karen-text) !important; }
.mtlp-mobile-menu-slot .mtlp-main-menu > li.active > a { color: var(--karen-primary) !important; background: rgba(var(--karen-primary-rgb),.06) !important; }
.mtlp-mobile-menu-slot .mtlp-main-menu .dropdown-menu {
  position: static !important;
  float: none !important;
  display: block;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-right: 2px solid rgba(var(--karen-primary-rgb),.18) !important;
  border-radius: 0 !important;
  background: var(--karen-surface-muted) !important;
  box-shadow: none !important;
}
.mtlp-mobile-menu-slot .mtlp-main-menu .dropdown-menu > li > a {
  min-height: 44px;
  padding: 9px 16px !important;
  color: var(--karen-text) !important;
  white-space: normal !important;
}
.mtlp-mobile-menu-slot .mtlp-main-menu > li.mtlp-mobile-overflow > a { display: none !important; }
.mtlp-mobile-menu-slot .mtlp-main-menu > li.mtlp-mobile-overflow > .dropdown-menu {
  display: block !important;
  border-right: 0 !important;
  background: transparent !important;
}
.mtlp-mobile-menu-slot .mtlp-main-menu > li.mtlp-mobile-overflow > .dropdown-menu > li > a {
  min-height: 50px;
  padding: 12px 10px !important;
  border-bottom: 1px solid var(--karen-border) !important;
  background: transparent !important;
}

@media screen and (max-width: 1199px) {
  .mtlp-shell > header { padding-top: 12px; }
  .mtlp-shell .mtlp-header-main-row {
    margin: 0 -8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    direction: rtl;
  }
  .mtlp-shell .mtlp-header-logo {
    order: 1;
    float: none !important;
    flex: 0 0 100%;
    width: 100%;
    padding: 0 8px;
    text-align: center;
  }
  .mtlp-shell .mtlp-header-logo a { margin-bottom: 9px; }
  .mtlp-shell .mtlp-menu-trigger {
    order: 2;
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px;
    min-height: 54px;
    padding: 4px 3px;
    display: inline-flex !important;
  }
  .mtlp-shell .mtlp-header-search {
    order: 3;
    float: none !important;
    flex: 1 1 110px;
    width: auto !important;
    min-width: 90px;
    padding: 0 4px;
    text-align: center;
  }
  .mtlp-shell .mtlp-header-actions {
    order: 4;
    float: none !important;
    flex: 0 0 auto;
    width: auto !important;
    min-height: 54px;
    padding: 0 4px;
    gap: 1px;
    display: flex !important;
    align-items: center;
  }
  .mtlp-shell .mtlp-header-actions .mtlp-header-tool,
  .mtlp-shell .mtlp-menu-trigger {
    min-height: 54px;
    border-radius: 8px;
  }
  .mtlp-shell .mtlp-header-actions .mtlp-header-tool { min-width: 47px; padding: 3px 2px; }
  .mtlp-shell .mtlp-custom-order-action { width: 60px; min-width: 60px !important; }
  .mtlp-shell .mtlp-header-tool > i { width: 25px; height: 24px; font-size: 20px; }
  .mtlp-shell .mtlp-header-tool > span { font-size: 10.5px; line-height: 1.25; }
  .mtlp-shell .mtlp-custom-order-action > span { max-width: 58px; white-space: normal; }
  .mtlp-shell .mtlp-basket-host { min-width: 48px !important; width: 48px; }
  .mtlp-shell .mtlp-basket-host .btn-show-basket {
    width: 48px !important;
    min-width: 48px !important;
    min-height: 54px !important;
    padding: 3px 2px !important;
  }
  .mtlp-shell .mtlp-basket-host .btn-show-basket:before { width: 25px !important; height: 24px !important; font-size: 20px !important; }
  .mtlp-shell .mtlp-basket-host .btn-show-basket:after { font-size: 10.5px !important; }
  .mtlp-shell .mtlp-basket-count {
    top: -1px;
    right: -1px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-width: 2px;
    font-size: 10px;
    line-height: 14px;
  }

  /* Search internals are deliberately not restyled; only its available width changes. */
  .mtlp-shell .mtlp-header-search > div.js__header-search-box { width: 100%; }

  /* Original desktop category trigger is intentionally absent on mobile/tablet. */
  .mtlp-shell .mtlp-nav-row { display: none !important; }

  .mtlp-drawer-tabs { display: grid; }
  .mtlp-navigation-drawer { width: min(var(--mtlp-drawer-width), 94vw) !important; }
  .mtlp-drawer-head { min-height: 70px; padding: 11px 13px; }
  .mtlp-drawer-panel { padding: 10px; }

  /* Native basket preview becomes a header-associated floating card on small screens. */
  .mtlp-shell .mtlp-basket-host .basket-preview-wrap {
    position: fixed !important;
    z-index: 2147480700 !important;
    top: 136px !important;
    left: 10px !important;
    right: 10px !important;
    bottom: auto !important;
    width: auto !important;
    max-width: none !important;
    transform: translateY(-10px) !important;
    opacity: 0 !important;
    pointer-events: none;
  }
  .mtlp-shell .mtlp-basket-host .basket-preview-wrap.active {
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto;
  }
}

@media screen and (max-width: 480px) {
  .mtlp-shell > header { padding-right: 8px; padding-left: 8px; }
  .mtlp-shell .mtlp-header-main-row { margin-right: 0; margin-left: 0; }
  .mtlp-shell .mtlp-header-logo { padding-right: 0; padding-left: 0; }
  .mtlp-shell .mtlp-menu-trigger { flex-basis: 43px; width: 43px; min-width: 43px; }
  .mtlp-shell .mtlp-header-search { flex-basis: 82px; min-width: 76px; padding-right: 2px; padding-left: 2px; }
  .mtlp-shell .mtlp-header-actions { padding-right: 1px; padding-left: 0; }
  .mtlp-shell .mtlp-header-actions .mtlp-header-tool { min-width: 43px; width: 43px; }
  .mtlp-shell .mtlp-custom-order-action { min-width: 56px !important; width: 56px !important; }
  .mtlp-shell .mtlp-basket-host { min-width: 43px !important; width: 43px !important; }
  .mtlp-shell .mtlp-basket-host .btn-show-basket { width: 43px !important; min-width: 43px !important; }
  .mtlp-shell .mtlp-header-tool > span,
  .mtlp-shell .mtlp-basket-host .btn-show-basket:after { font-size: 10px !important; }
  .mtlp-navigation-drawer { width: min(420px, 96vw) !important; }
}

/* ================================================================
 * R1.2 — Mobile header hierarchy refinement
 * - Description moves to a slim darker strip at the top of header.
 * - Row 1: Menu + right-aligned brand title | Login + Basket on left.
 * - Row 2: Existing search box + Custom Order; search internals unchanged.
 * Desktop is intentionally untouched.
 * ================================================================ */
@media screen and (max-width: 1199px) {
  .mtlp-shell > header {
    padding-top: 0 !important;
  }

  .mtlp-shell .mtlp-header-main-row {
    position: relative;
    margin-right: -8px;
    margin-left: -8px;
    padding: 34px 8px 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    direction: rtl;
  }

  /* Keep one source of truth for the portal description, but present it as
     a dedicated slim strip. The darker tone is derived from the current
     brand header instead of hard-coding a site color. */
  .mtlp-shell .mtlp-header-logo {
    position: static !important;
    order: 2;
    float: none !important;
    flex: 0 0 calc(100% - 144px);
    width: calc(100% - 144px) !important;
    min-width: 0;
    margin: 0;
    padding: 0 8px;
    text-align: right;
  }
  .mtlp-shell .mtlp-header-logo a {
    display: block;
    width: 100%;
    margin: 0 !important;
    padding: 0;
    text-align: right;
  }
  .mtlp-shell .mtlp-header-logo a strong {
    display: block;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: #fff;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mtlp-shell .mtlp-header-logo a span {
    position: absolute;
    z-index: 2;
    top: 0;
    right: 0;
    left: 0;
    height: 28px;
    margin: 0;
    padding: 0 12px;
    background: rgba(0, 0, 0, .12);
    color: rgba(255, 255, 255, .72);
    opacity: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 11.5px;
    line-height: 28px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
  }

  /* The wrapper no longer owns a row on mobile; its children become direct
     flex items so Login/Basket can share the brand row while Custom Order
     stays beside Search on the row below. */
  .mtlp-shell .mtlp-header-actions {
    display: contents !important;
  }

  .mtlp-shell .mtlp-menu-trigger {
    order: 1;
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px;
    min-height: 54px;
    margin: 0;
    padding: 4px 3px;
    display: inline-flex !important;
  }
  .mtlp-shell .mtlp-login-action {
    order: 3;
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px !important;
  }
  .mtlp-shell .mtlp-basket-host {
    order: 4;
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px !important;
  }

  /* Second mobile row: keep original search component styling; only the
     available width/placement changes. */
  .mtlp-shell .mtlp-header-search {
    order: 5;
    float: none !important;
    flex: 0 0 calc(100% - 64px);
    width: calc(100% - 64px) !important;
    min-width: 0;
    margin-top: 6px;
    padding: 0 4px 0 0;
    text-align: center;
  }
  .mtlp-shell .mtlp-custom-order-action {
    order: 6;
    flex: 0 0 64px;
    width: 64px !important;
    min-width: 64px !important;
    margin-top: 6px;
  }
  .mtlp-shell .mtlp-header-search > div.js__header-search-box {
    width: 100%;
  }

  /* Basket preview follows the new two-row header height. */
  .mtlp-shell .mtlp-basket-host .basket-preview-wrap {
    top: 150px !important;
  }
}

@media screen and (max-width: 480px) {
  .mtlp-shell .mtlp-header-main-row {
    margin-right: 0;
    margin-left: 0;
    padding-right: 0;
    padding-left: 0;
  }
  .mtlp-shell .mtlp-menu-trigger {
    flex-basis: 43px;
    width: 43px;
    min-width: 43px;
  }
  .mtlp-shell .mtlp-header-logo {
    flex-basis: calc(100% - 129px);
    width: calc(100% - 129px) !important;
    padding-right: 7px;
    padding-left: 7px;
  }
  .mtlp-shell .mtlp-login-action {
    flex-basis: 43px;
    width: 43px;
    min-width: 43px !important;
  }
  .mtlp-shell .mtlp-basket-host {
    flex-basis: 43px;
    width: 43px;
    min-width: 43px !important;
  }
  .mtlp-shell .mtlp-header-search {
    flex-basis: calc(100% - 58px);
    width: calc(100% - 58px) !important;
    padding-right: 0;
    padding-left: 3px;
  }
  .mtlp-shell .mtlp-custom-order-action {
    flex-basis: 58px;
    width: 58px !important;
    min-width: 58px !important;
  }
}
