/* Aniyab UI — Header / Main menu (desktop + mobile)
 * From Figma: Footer and menu / main menu + mobile header
 */

.ay-header {
  --ay-header-pad-x: 72px;
  --ay-header-pad-y: 20px;
  --ay-header-height: 84px;

  position: sticky;
  top: 0;
  z-index: 1040;
  box-sizing: border-box;
  font-family: var(--ay-font-family, dana, DanaFaNum, IRANSansfanum, Tahoma, sans-serif);
  color: var(--ay-text-main, #404040);
}

.ay-header *,
.ay-header *::before,
.ay-header *::after {
  box-sizing: border-box;
}

.ay-header__bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: var(--ay-header-height);
  padding: var(--ay-header-pad-y) var(--ay-header-pad-x);
  background: var(--ay-bg-white, #FFFFFF);
  border-radius: 0 0 16px 16px;
}

.ay-header__start {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 40px;
  min-width: 0;
  order: 0; /* RTL main-start = right */
}

.ay-header__end {
  order: 1; /* RTL = left actions */
}

.ay-header__brand {
  order: 0;
}

.ay-header__nav {
  order: 1;
}

.ay-header__mobile-toggle {
  order: 2;
}

.ay-header__lang {
  order: 1;
}

.ay-header__agents {
  order: 2;
}

.ay-header__desktop-auth,
.ay-header__account,
.ay-header__mobile-auth {
  order: 3;
}

.ay-header__brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  text-decoration: none;
}

.ay-header__brand img {
  display: block;
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.ay-header__nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ay-header__nav-item {
  position: relative;
  display: flex;
  align-items: center;
}

.ay-header__end {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  flex: none;
}

/* ensure end order rule from above isn't duplicated — kept for clarity */

/* Language */
.ay-header__lang {
  position: relative;
}

.ay-header__lang-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 8px;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--ay-text-main, #404040);
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  line-height: 28px;
  cursor: pointer;
}

.ay-header__lang-btn:hover {
  color: var(--ay-brand-secondary, #FF6F1C);
}

.ay-header__lang-flag {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.ay-header__chevron {
  display: inline-flex;
  width: 20px;
  height: 20px;
  color: inherit;
  transition: transform 0.15s ease;
}

.ay-header__nav-item.is-open > .ay-menu-item .ay-header__chevron,
.ay-header__lang.is-open .ay-header__chevron,
.ay-header__account.is-open .ay-header__chevron {
  transform: rotate(180deg);
}

/* Agents link */
.ay-header__agents {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 8px;
  border-radius: 8px;
  color: var(--ay-brand-primary, #002D71);
  font-weight: 500;
  font-size: 14px;
  line-height: 28px;
  text-decoration: none;
  white-space: nowrap;
}

.ay-header__agents:hover {
  color: var(--ay-brand-primary-light, #0545A6);
  text-decoration: none;
}

.ay-header__agents-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  color: inherit;
}

/* Auth / account outline button */
.ay-header__auth {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 8px;
  border: 1px solid var(--ay-text-tertiary, #A3A3A3);
  border-radius: 8px;
  background: transparent;
  color: var(--ay-text-main, #404040);
  font-weight: 500;
  font-size: 14px;
  line-height: 28px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.ay-header__auth:hover {
  border-color: var(--ay-text-main, #404040);
  color: var(--ay-text-title, #302E2E);
  text-decoration: none;
}

.ay-header__auth-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  color: inherit;
}

.ay-header__auth-label {
  padding: 0 8px;
}

/* Dropdown panels */
.ay-header__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  z-index: 1060;
  display: none;
  min-width: 220px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: var(--ay-surface-white, #FFFFFF);
  border-radius: 16px;
  box-shadow: var(--ay-elevation-md, 0px 4px 12px rgba(163, 163, 163, 0.25));
}

.ay-header__lang .ay-header__dropdown {
  inset-inline-start: auto;
  inset-inline-end: 0;
  min-width: 160px;
}

.ay-header__account {
  position: relative;
}

.ay-header__account .ay-header__dropdown {
  inset-inline-start: auto;
  inset-inline-end: 0;
  min-width: 200px;
}

.ay-header__nav-item.is-open > .ay-header__dropdown,
.ay-header__lang.is-open > .ay-header__dropdown,
.ay-header__account.is-open > .ay-header__dropdown {
  display: block;
}

/* Thin orange underline when submenu is open (Figma menu-item selected) */
.ay-header__nav-item.is-open > .ay-menu-item {
  --ay-menu-item-color: var(--ay-brand-secondary-dark, #ED5904);
  border-bottom-color: var(--ay-brand-secondary-dark, #ED5904);
}

.ay-header__drawer-item.is-open > .ay-menu-item {
  --ay-menu-item-color: var(--ay-brand-secondary-dark, #ED5904);
  border-bottom-color: var(--ay-brand-secondary-dark, #ED5904);
}

.ay-header__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-inline-start: 4px;
  border-radius: 9px;
  background: var(--ay-brand-secondary, #FF6F1C);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.ay-header__dropdown .ay-list-item {
  width: 100%;
  border-radius: 8px;
  justify-content: flex-start;
}

/* Mobile-only controls (hidden on desktop) */
.ay-header__mobile-toggle,
.ay-header__mobile-auth {
  display: none;
}

.ay-header__backdrop {
  display: none;
}

/* ── Mobile drawer ── */
.ay-header__drawer {
  display: none;
}

/* ── Responsive ── */
@media (max-width: 1199.98px) {
  .ay-header {
    --ay-header-pad-x: 32px;
  }

  .ay-header__start {
    gap: 20px;
  }

  .ay-header__nav {
    gap: 8px;
  }
}

@media (max-width: 991.98px) {
  .ay-header {
    --ay-header-pad-x: 12px;
    --ay-header-pad-y: 8px;
    --ay-header-height: 52px;
  }

  .ay-header__bar {
    gap: 12px;
    padding: 8px 8px 8px 12px;
    border-radius: 0;
    box-shadow: var(--ay-elevation-md, 0px 4px 12px rgba(163, 163, 163, 0.25));
  }

  .ay-header__start {
    gap: 4px;
  }

  .ay-header__mobile-toggle {
    order: 0; /* far right in RTL */
  }

  .ay-header__brand {
    order: 1;
  }

  .ay-header__end {
    gap: 0;
  }

  /* فقط نوار بالا؛ اکشن‌های داخل دراور نباید مخفی شوند */
  .ay-header__nav,
  .ay-header__end .ay-header__lang,
  .ay-header__end .ay-header__agents,
  .ay-header__desktop-auth {
    display: none !important;
  }

  .ay-header__mobile-toggle,
  .ay-header__mobile-auth {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 34px;
    padding: 8px 6px;
    margin: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ay-text-main, #404040);
    text-decoration: none;
    cursor: pointer;
  }

  .ay-header__mobile-auth {
    border: 1px solid var(--ay-text-tertiary, #A3A3A3);
  }

  .ay-header__mobile-toggle {
    border: 0;
  }

  .ay-header__mobile-toggle svg,
  .ay-header__mobile-auth svg {
    display: block;
    width: 18px;
    height: 18px;
  }

  /* Drawer */
  .ay-header__backdrop {
    position: fixed;
    inset: 0;
    z-index: 1045;
    display: block;
    background: var(--ay-scrim, rgba(48, 46, 46, 0.3));
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }

  .ay-header.is-drawer-open .ay-header__backdrop {
    opacity: 1;
    visibility: visible;
  }

  .ay-header__drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-end: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    width: min(320px, 88vw);
    padding: 16px;
    background: var(--ay-surface-white, #FFFFFF);
    box-shadow: var(--ay-elevation-lg, 0px 4px 24px rgba(163, 163, 163, 0.25));
    transform: translateX(110%);
    transition: transform 0.25s ease;
    overflow-y: auto;
  }

  html[dir="rtl"] .ay-header__drawer,
  body.rtl .ay-header__drawer {
    transform: translateX(-110%);
  }

  .ay-header.is-drawer-open .ay-header__drawer {
    transform: translateX(0);
  }

  .ay-header__drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .ay-header__drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ay-text-main, #404040);
    cursor: pointer;
  }

  .ay-header__drawer-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0 0 16px;
    border-bottom: 1px solid var(--ay-border-light, #E7E5E4);
  }

  .ay-header__drawer-actions .ay-header__drawer-login,
  .ay-header__drawer-actions .ay-header__drawer-agents {
    display: inline-flex;
    width: 100%;
    justify-content: center;
  }

  .ay-header__drawer-actions .ay-header__lang--drawer {
    display: block;
    width: 100%;
  }

  .ay-header__drawer-actions .ay-header__lang-btn {
    width: 100%;
    justify-content: space-between;
  }

  .ay-header__drawer-actions .ay-header__dropdown--inline {
    position: static;
    inset: auto;
    display: none;
    min-width: 0;
    box-shadow: none;
    padding: 0;
  }

  .ay-header__drawer-actions .ay-header__lang.is-open > .ay-header__dropdown--inline {
    display: block;
  }

  .ay-header__drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .ay-header__drawer-nav--account {
    margin-top: 4px;
  }

  .ay-header__drawer-nav .ay-menu-item,
  .ay-header__drawer-nav .ay-list-item {
    width: 100%;
    justify-content: flex-start;
  }

  .ay-header__drawer-sub {
    display: none;
    margin: 0;
    padding: 0 0 0 8px;
    list-style: none;
  }

  html[dir="rtl"] .ay-header__drawer-sub,
  body.rtl .ay-header__drawer-sub {
    padding: 0 8px 0 0;
  }

  .ay-header__drawer-item.is-open > .ay-header__drawer-sub {
    display: block;
  }

  body.ay-header-lock {
    overflow: hidden;
  }
}

@media (max-width: 575.98px) {
  .ay-header {
    --ay-header-pad-x: 8px;
  }
}

