/* ST Sidebar — هدر موبایل به شکل اپلیکیشن سلام بابا (v1.0)
 * چیدمان: راست: منو ← لوگو (چسبیده به منو) … چپ: ابزارها به‌صورت دکمه‌های سفید گرد با سایه‌ی نرم؛ زیرش جستجوی پُر.
 * فقط وقتی <html> کلاس sbah دارد (از تنظیمات ماژول) و فقط موبایل/تبلت (≤۹۹۱). هیچ عنصری در DOM جابه‌جا نمی‌شود؛
 * فقط wrapperهای داخلی ردیف بالا display:contents می‌گیرند و ترتیب نمایش با order تعیین می‌شود.
 * اندازه‌ها از تنظیمات ادمین: --sbah-row (ارتفاع ردیف)، --sbah-chip (دکمه‌ها)، --sbah-logo (لوگو)، --sbah-sh (جستجو)
 * هدر فشرده (sb-hdr-compact) اگر روشن باشد، این لایه اعمال نمی‌شود تا دو چیدمان با هم قاطی نشوند.
 */
@media (max-width:991px){
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar{background:#fff!important;border-bottom:1px solid #e9edf2!important;box-shadow:none!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar>.container{padding-left:0!important;padding-right:0!important;max-width:none!important;width:auto!important;border:0!important;box-shadow:none!important}
  /* هیچ خط جداکننده‌ای بین ردیف لوگو و جستجو نباشد (مثل اپ)؛ فقط یک خط نازک زیر کل هدر */
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar :is(#mobile_bar_top,#mobile_bar_bottom,.sb-mobile-search-row,.search_widget_block,.search_widget,.search_widget_form){border:0!important;box-shadow:none!important;outline:0!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar :is(#mobile_bar_top,#mobile_bar_bottom)::before,
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar :is(#mobile_bar_top,#mobile_bar_bottom)::after{display:none!important}

  /* ---------- ردیف بالا ---------- */
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar #mobile_bar_top{
    display:flex!important;flex-direction:row!important;flex-wrap:nowrap!important;align-items:center!important;direction:rtl!important;
    gap:8px!important;height:var(--sbhd-top,var(--sbah-row,52px))!important;min-height:0!important;margin:0!important;
    padding:0 max(12px,env(safe-area-inset-right,0px)) 0 max(12px,env(safe-area-inset-left,0px))!important;box-sizing:border-box!important;
  }
  /* wrapperها (چپ/وسط/راست و flex_containerهای داخلشان) فقط ظرف‌اند؛ محتوایشان مستقیم در ردیف چیده می‌شود */
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar #mobile_bar_top>:is(#mobile_bar_left,#mobile_bar_center,#mobile_bar_right),
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar #mobile_bar_top>:is(#mobile_bar_left,#mobile_bar_center,#mobile_bar_right)>.flex_container,
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar #mobile_bar_top .sbah-dc{display:contents!important}

  /* ترتیب: منو (راست‌ترین) ← لوگو ← فاصله‌ی آزاد ← ابزارها */
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top :is(.menu_mobile_bar_tri,[data-name="side_stmobilemenu"],[data-name="side_steasymenu"]):not(.rightbar_tels){order:1!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top a.mobile_logo{order:2!important;margin:0 0 0 auto!important;margin-inline:0 auto!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top>*,
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top .sbah-dc>*{order:3}

  /* منو: آیکن ساده، بدون کادر */
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top :is(.menu_mobile_bar_tri,[data-name="side_stmobilemenu"],[data-name="side_steasymenu"]):not(.rightbar_tels){
    display:inline-flex!important;align-items:center!important;justify-content:center!important;flex:0 0 auto!important;
    width:36px!important;min-width:36px!important;height:36px!important;margin:0!important;padding:0!important;
    background:transparent!important;border:0!important;box-shadow:none!important;color:#1f2937!important;
  }

  /* لوگو: کنار منو، راست‌چین */
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top a.mobile_logo{
    display:flex!important;align-items:center!important;justify-content:flex-start!important;flex:0 1 auto!important;min-width:0!important;
    height:var(--sbah-logo,30px)!important;max-height:var(--sbah-logo,30px)!important;
    max-width:min(200px,46vw)!important;width:auto!important;padding:0!important;
    background-position:right center!important;
  }
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top a.mobile_logo img{height:var(--sbah-logo,30px)!important;max-height:var(--sbah-logo,30px)!important;width:auto!important;max-width:100%!important;object-fit:contain;object-position:right center}
  /* لوگوی موبایل ماژول (پس‌زمینه): عرض ثابت لازم دارد تا تصویر دیده شود */
  html.sbah.sbah-bglogo:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top a.mobile_logo{width:min(200px,46vw)!important;background-size:contain!important;background-repeat:no-repeat!important}

  /* ابزارها (سبد و هر آیتمی که در «Mobile bar left/right» گذاشته شود): کنار هم، سمت چپ.
   * ظاهر از ادمین: ساده (پیش‌فرض، فقط آیکن) | دایره‌ی سفید | مربع سفید ۷ پیکسل */
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top :is(.mobile_bar_item:not(.menu_mobile_bar_tri):not([data-name="side_stmobilemenu"]):not([data-name="side_steasymenu"]),.sbah-tool){
    position:relative!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;flex:0 0 auto!important;
    width:var(--sbah-chip,40px)!important;min-width:var(--sbah-chip,40px)!important;height:var(--sbah-chip,40px)!important;
    margin:0!important;padding:0!important;box-sizing:border-box!important;color:#1f2937!important;
    background:transparent!important;border:0!important;border-radius:7px!important;box-shadow:none!important;
  }
  html.sbah.sbah-chip:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top :is(.mobile_bar_item:not(.menu_mobile_bar_tri):not([data-name="side_stmobilemenu"]):not([data-name="side_steasymenu"]),.sbah-tool){
    background:#fff!important;border:1px solid #edf0f4!important;box-shadow:0 2px 8px rgba(15,23,42,.10),0 1px 2px rgba(15,23,42,.06)!important;
  }
  html.sbah.sbah-chip.sbah-round:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top :is(.mobile_bar_item:not(.menu_mobile_bar_tri):not([data-name="side_stmobilemenu"]):not([data-name="side_steasymenu"]),.sbah-tool){border-radius:50%!important}
  /* حالت ساده: فاصله‌ی کمتر بین آیکن‌ها */
  html.sbah:not(.sbah-chip):not(.sb-hdr-compact) body:not(#_) #mobile_bar #mobile_bar_top{gap:2px!important}
  html.sbah:not(.sbah-chip):not(.sb-hdr-compact) body:not(#_) #mobile_bar_top a.mobile_logo{margin-right:6px!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top .mobile_bar_item:active{transform:scale(.94)}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top .mobile_bar_item .mobile_bar_tri_text{display:none!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top .mobile_bar_item :is(i,.icon_btn){margin:0!important;font-size:20px!important;line-height:1!important;color:inherit!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top .mobile_bar_item img{max-width:22px!important;max-height:22px!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top .mobile_bar_item .ajax_cart_bag{position:relative!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;margin:0!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top .mobile_bar_item .amount_circle{position:absolute!important;top:-9px!important;inset-inline-end:-11px!important;z-index:2!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top .mobile_bar_item:after{display:none!important}

  /* ---------- جستجو: پُر، بدون حاشیه‌ی پررنگ، ذره‌بین سمت راست ---------- */
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar #mobile_bar_bottom{min-height:0!important;margin:0!important;padding:6px max(13px,env(safe-area-inset-right,0px)) 6px max(13px,env(safe-area-inset-left,0px))!important;border:0!important;border-top:var(--sbhd-line,1px) solid #e6e8ec!important;background:#fff!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar .sb-mobile-search-row{margin:0!important;padding:0!important;flex:0 1 70vw!important;width:70vw!important;min-width:45%!important;max-width:70vw!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar .sb-mobile-search-row .search_widget_form_inner{
    display:flex!important;flex-direction:row!important;align-items:center!important;direction:rtl!important;
    height:var(--sbhd-bot,var(--sbah-sh,42px))!important;min-height:0!important;padding:0 4px!important;box-sizing:border-box!important;
    background:#f0f2f5!important;border:1px solid #e8ebf0!important;border-radius:7px!important;box-shadow:none!important;
    transition:background-color .18s,border-color .18s!important;
  }
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar .sb-mobile-search-row .search_widget_form_inner:focus-within{background:#fff!important;border-color:#1877f2!important}
  /* متن سمت راست، ذره‌بین سمت چپ */
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar .sb-mobile-search-row .input-group-btn{order:2!important;display:flex!important;width:auto!important;flex:0 0 auto!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar .sb-mobile-search-row .search_widget_btn{
    width:36px!important;min-width:36px!important;height:36px!important;padding:0!important;margin:0!important;
    background:transparent!important;border:0!important;box-shadow:none!important;color:#6b7280!important;opacity:1!important;
  }
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar .sb-mobile-search-row .search_widget_btn i{color:#6b7280!important;font-size:18px!important;line-height:1!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar .sb-mobile-search-row :is(.search_widget_block,.search_widget,.search_widget_form){width:100%!important;max-width:none!important;margin:0!important;padding:0!important;background:transparent!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar .sb-mobile-search-row .search_widget_text{
    flex:1 1 auto!important;min-width:0!important;height:100%!important;padding:0 12px 0 4px!important;margin:0!important;order:1!important;
    background:transparent!important;border:0!important;border-radius:0!important;box-shadow:none!important;outline:0!important;
    direction:rtl!important;text-align:right!important;font-size:14px!important;color:#1f2937!important;
  }
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar .sb-mobile-search-row .search_widget_text::placeholder{color:#8a93a3!important;opacity:1!important}
}
/* گوشی‌های خیلی کم‌عرض */
@media (max-width:359px){
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar #mobile_bar_top{gap:6px!important;padding-left:8px!important;padding-right:8px!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top .mobile_bar_item:not(.menu_mobile_bar_tri){width:calc(var(--sbah-chip,40px) - 4px)!important;min-width:calc(var(--sbah-chip,40px) - 4px)!important;height:calc(var(--sbah-chip,40px) - 4px)!important}
  html.sbah:not(.sb-hdr-compact) body:not(#_) #mobile_bar_top a.mobile_logo{max-width:40vw!important}
}
