/**
 * header-topbar.css — نوار بالا موبایل/دسکتاپ + انتخاب شهر
 * نسخه 1
 */

/* —— موبایل: سه ستون منظم —— */
.header-mobile.asy-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--card, #fff);
  border-bottom: 1px solid var(--border, #e2e8f0);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  box-sizing: border-box;
}

@media (max-width: 899px) {
  .header-mobile.asy-topbar {
    display: flex;
  }
  .header-desktop-only {
    display: none !important;
  }
}

/* دکمه شهر — مثل دیوار، خوانا */
.hm-loc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 1 auto;
  max-width: 38%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--bg-2, #f8fafc);
  color: var(--text, #0f172a);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hm-loc-btn .icon {
  flex-shrink: 0;
  opacity: 0.9;
  color: var(--primary, #0d9488);
}
.hm-loc-btn .hm-loc-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  line-height: 1.2;
}
.hm-loc-btn:active {
  transform: scale(0.98);
  background: var(--primary-soft, rgba(13, 148, 136, 0.12));
}

/* جستجو وسط */
.hm-search-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.hm-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--bg-2, #f8fafc);
}
.hm-search .icon {
  flex-shrink: 0;
  opacity: 0.55;
}
.hm-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text, #0f172a);
  outline: none;
  padding: 8px 0;
}
.hm-search-input::placeholder {
  color: var(--muted, #94a3b8);
}

/* همبرگر */
.hm-menu-btn.nav-toggle {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--bg-2, #f8fafc);
  cursor: pointer;
  padding: 0;
}
.hm-menu-icon {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 18px;
}
.hm-menu-icon span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--text, #0f172a);
}

/* —— شیت انتخاب شهر —— */
.loc-sheet {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.loc-sheet[hidden] {
  display: none !important;
}
.loc-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(2px);
}
.loc-sheet-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: min(88vh, 640px);
  background: var(--card, #fff);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--border, #e2e8f0);
  display: flex;
  flex-direction: column;
  animation: locSheetUp 0.22s ease;
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.12);
}
@keyframes locSheetUp {
  from { transform: translateY(40px); opacity: 0.5; }
  to { transform: none; opacity: 1; }
}
.loc-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.loc-sheet-head strong {
  font-size: 0.95rem;
  font-weight: 800;
}
.loc-sheet-search {
  padding: 10px 14px;
}
.loc-sheet-search .form-control {
  min-height: 42px;
  border-radius: 12px;
}
.loc-sheet-list {
  overflow: auto;
  flex: 1;
  padding: 0 4px 8px;
  -webkit-overflow-scrolling: touch;
}
.loc-sheet-foot {
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border, #e2e8f0);
}
.loc-sheet-foot .btn-block {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  font-weight: 700;
}

@media (min-width: 700px) {
  .loc-sheet {
    align-items: center;
  }
  .loc-sheet-panel {
    border-radius: 18px;
    max-height: 80vh;
    margin: 16px;
  }
}

/* —— دسکتاپ: دکمه شهر —— */
.desk-loc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--bg-2, #f8fafc);
  color: var(--text, #0f172a);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  max-width: 160px;
}
.desk-loc-btn .hm-loc-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.desk-loc-btn .icon {
  color: var(--primary, #0d9488);
  flex-shrink: 0;
}
.desk-loc-btn:hover {
  border-color: var(--primary, #0d9488);
  background: var(--primary-soft, rgba(13, 148, 136, 0.1));
}

@media (min-width: 900px) {
  .header-mobile.asy-topbar {
    display: none !important;
  }
}

/* منوی کشویی مرتب‌تر */
.asy-drawer-panel {
  max-width: 320px;
}
.asy-drawer-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 12px;
  color: var(--text, #0f172a);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.asy-drawer-nav a:hover,
.asy-drawer-nav a:active {
  background: var(--bg-2, #f1f5f9);
}
.asy-drawer-nav .asy-di {
  display: inline-flex;
  width: 28px;
  justify-content: center;
  opacity: 0.85;
}


/* v3 polish */
@media (max-width: 360px) {
  .hm-loc-btn { max-width: 34%; padding: 8px 8px; font-size: 0.72rem; }
  .hm-search-input { font-size: 0.85rem; }
}


/* ===== Header logo + layout (global, all pages) v4 ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--card, #fff);
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.site-header .header-inner {
  max-width: var(--container, 1120px);
  margin: 0 auto;
  padding: 8px 14px;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  box-sizing: border-box;
}
.site-header .logo,
.site-header .site-logo-link {
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(200px, 28vw);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text, #0f172a);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.site-header .site-logo-img,
.site-logo-img,
a.logo img,
a.site-logo-link img {
  display: block;
  height: 36px !important;
  width: auto !important;
  max-height: 36px !important;
  max-width: 160px !important;
  object-fit: contain !important;
  vertical-align: middle;
}
.site-header .nav-desktop {
  flex: 1 1 auto;
  min-width: 0;
  display: none;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.site-header .nav-desktop::-webkit-scrollbar { display: none; }
.site-header .header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: auto; /* RTL: push actions to end visually with flex */
}
/* در RTL با direction، order را ساده نگه می‌داریم */
html[dir="rtl"] .site-header .header-inner {
  flex-direction: row;
}
.site-header .desk-loc-btn {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 140px;
}
.site-header .user-menu {
  flex: 0 0 auto;
}

@media (min-width: 900px) {
  .site-header .nav-desktop {
    display: flex;
  }
  .site-header .header-actions .nav-toggle {
    display: none;
  }
  .site-header .desk-loc-btn {
    display: inline-flex !important;
  }
  .site-header .logo,
  .site-header .site-logo-link {
    max-width: 180px;
  }
  .site-header .site-logo-img,
  .site-logo-img {
    height: 40px !important;
    max-height: 40px !important;
    max-width: 180px !important;
  }
}

@media (max-width: 899px) {
  .header-desktop-only.site-header {
    display: none !important;
  }
}

/* جلوگیری از شکست کل هدر با لوگوی خیلی عریض */
.site-header .logo span {
  color: var(--primary, #0d9488);
}


/* فلکس پایدار منوها */
.site-header .nav-desktop a {
  flex: 0 0 auto;
}
.site-header .nav-desktop .user-menu {
  flex: 0 0 auto;
}
.header-mobile.asy-topbar > * {
  min-width: 0;
}
.hm-search-wrap {
  flex: 1 1 0;
}
.hm-loc-btn {
  flex: 0 1 auto;
}
.hm-menu-btn {
  flex: 0 0 auto;
}
