/* =========================================================
   TOPBAR.CSS — CLEAN FINAL VERSION
   Desktop + Tablet/Mobile + RTL + Overflow-safe
   Hamburger starts at 1050px
   Brand stays left in all languages
   ========================================================= */


/* =========================================================
   BASE HEADER LAYOUT
   ========================================================= */

   .headerbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 36px;
  
    padding: 16px 0;
  
    min-width: 0;
    max-width: 100%;
    overflow: visible;
  
    /* Keep header structure left-to-right, even on RTL pages */
    direction: ltr;
  }
  
  .brand {
    order: 1;
  
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 70px);
  
    font-size: 24px;
    font-weight: 700;
    line-height: 1.18;
  
    text-align: left;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
  }
  
  .navwrap {
    order: 2;
  
    display: flex;
    align-items: center;
    gap: 8px;
  
    flex: 0 0 auto;
    flex-shrink: 0;
  
    min-width: 0;
    max-width: 100%;
  
    position: relative;
  
    /* Keep button/dropdown geometry predictable */
    direction: ltr;
  }
  
  
  /* =========================================================
     DESKTOP NAVIGATION
     ========================================================= */
  
  .navlinks {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 8px;
  
    min-width: 0;
    max-width: 100%;
  }
  
  .navlinks a {
    display: inline-block;
  
    color: #111;
    text-decoration: none;
  
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
  
    padding: 7px 8px;
    border-radius: 10px;
  
    white-space: nowrap;
  }
  
  .navlinks a:hover {
    background: #f1f1f1;
  }
  
  .navlinks a.cta {
    background: #0f7c73;
    color: #fff;
  
    padding: 9px 14px;
    border-radius: 999px;
  
    font-weight: 700;
  }
  
  .navlinks a.cta:hover {
    background: #0c655e;
  }
  
  
  /* =========================================================
     LANGUAGE DROPDOWN
     ========================================================= */
  
  .lang-dd {
    position: relative;
  
    flex: 0 0 auto;
    max-width: 100%;
  
    direction: ltr;
  }
  
  .lang-dd-btn {
    border: 0;
  
    background: #eee;
    color: #111;
  
    font-family: Georgia, "Times New Roman", "Noto Naskh Arabic", "Noto Sans Arabic", serif;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
  
    padding: 8px 12px;
    border-radius: 10px;
  
    cursor: pointer;
    white-space: nowrap;
  }
  
  .lang-dd-btn:hover {
    background: #e6e6e6;
  }
  
  .lang-dd-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
  
    display: none;
  
    min-width: 170px;
    max-width: min(240px, calc(100vw - 32px));
  
    padding: 10px;
  
    background: #fff;
    border: 1px solid #e7e7e7;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .2);
  
    z-index: 2001;
    overflow-wrap: break-word;
  
    /* Keep dropdown box positioning stable */
    direction: ltr;
    text-align: left;
  }
  
  .lang-dd.open .lang-dd-menu {
    display: block;
  }
  
  .lang-menu {
    list-style: none;
  
    display: flex;
    flex-direction: column;
    gap: 8px;
  
    margin: 0;
    padding: 0;
  
    direction: ltr;
  }
  
  .lang-menu a {
    display: block;
  
    background: #f3f3f3;
    color: #111;
  
    font-family: Georgia, "Times New Roman", "Noto Naskh Arabic", "Noto Sans Arabic", serif;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
  
    padding: 8px 12px;
    border-radius: 10px;
  
    text-decoration: none;
    white-space: nowrap;
  
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
  }
  
  .lang-menu a:hover {
    background: #e9e9e9;
  }
  
  /* Arabic/Persian language names */
  .lang-menu a[lang="ar"],
  .lang-menu a[lang="fa"],
  .lang-menu a[hreflang="ar"],
  .lang-menu a[hreflang="fa"] {
    direction: rtl !important;
    text-align: right !important;
  }
  
  /* English language name */
  .lang-menu a[lang="en"],
  .lang-menu a[hreflang="en"] {
    direction: ltr !important;
    text-align: left !important;
  }
  
  
  /* =========================================================
     HAMBURGER BUTTON
     ========================================================= */
  
  .menu-btn {
    display: none;
  
    width: 46px;
    height: 42px;
    padding: 0;
  
    border: 0;
    border-radius: 10px;
  
    background: #eee;
    color: #111;
  
    font-family: inherit;
    font-size: 25px;
    font-weight: 800;
    line-height: 1;
  
    cursor: pointer;
  
    align-items: center;
    justify-content: center;
  }
  
  .menu-btn:hover {
    background: #e6e6e6;
  }
  
  
  /* =========================================================
     RTL DESKTOP
     Brand stays left, nav stays right
     ========================================================= */
  
  html[dir="rtl"] .headerbar,
  html:lang(ar) .headerbar,
  html:lang(fa) .headerbar {
    flex-direction: row;
    direction: ltr;
  }
  
  html[dir="rtl"] .brand,
  html:lang(ar) .brand,
  html:lang(fa) .brand {
    order: 1;
    text-align: left;
    direction: rtl;
  }
  
  html[dir="rtl"] .navwrap,
  html:lang(ar) .navwrap,
  html:lang(fa) .navwrap {
    order: 2;
  
    /* Keep the dropdown attached to the same side as in LTR */
    direction: ltr;
  }
  
  html[dir="rtl"] .navlinks,
  html:lang(ar) .navlinks,
  html:lang(fa) .navlinks {
    direction: rtl;
    justify-content: flex-end;
  }
  
  html[dir="rtl"] .navlinks a,
  html:lang(ar) .navlinks a,
  html:lang(fa) .navlinks a {
    text-align: right;
  }
  
  html[dir="rtl"] .navlinks a.cta,
  html:lang(ar) .navlinks a.cta,
  html:lang(fa) .navlinks a.cta {
    text-align: center;
  }
  
  /* RTL pages: dropdown still opens from the right edge */
  html[dir="rtl"] .lang-dd,
  html:lang(ar) .lang-dd,
  html:lang(fa) .lang-dd {
    direction: ltr;
  }
  
  html[dir="rtl"] .lang-dd-menu,
  html:lang(ar) .lang-dd-menu,
  html:lang(fa) .lang-dd-menu {
    right: 0;
    left: auto;
  
    direction: ltr;
    text-align: left;
  }
  
  /* Keep Arabic/Persian correct even inside RTL pages */
  html[dir="rtl"] .lang-menu a[lang="ar"],
  html[dir="rtl"] .lang-menu a[hreflang="ar"],
  html[dir="rtl"] .lang-menu a[lang="fa"],
  html[dir="rtl"] .lang-menu a[hreflang="fa"],
  html:lang(ar) .lang-menu a[lang="ar"],
  html:lang(ar) .lang-menu a[hreflang="ar"],
  html:lang(ar) .lang-menu a[lang="fa"],
  html:lang(ar) .lang-menu a[hreflang="fa"],
  html:lang(fa) .lang-menu a[lang="ar"],
  html:lang(fa) .lang-menu a[hreflang="ar"],
  html:lang(fa) .lang-menu a[lang="fa"],
  html:lang(fa) .lang-menu a[hreflang="fa"] {
    direction: rtl !important;
    text-align: right !important;
  }
  
  /* Keep English correct even inside RTL pages */
  html[dir="rtl"] .lang-menu a[lang="en"],
  html[dir="rtl"] .lang-menu a[hreflang="en"],
  html:lang(ar) .lang-menu a[lang="en"],
  html:lang(ar) .lang-menu a[hreflang="en"],
  html:lang(fa) .lang-menu a[lang="en"],
  html:lang(fa) .lang-menu a[hreflang="en"] {
    direction: ltr !important;
    text-align: left !important;
  }
  
  
  /* =========================================================
     TABLET / MOBILE
     Hamburger from 1050px downward
     ========================================================= */
  
  @media (max-width: 1050px) {
    .headerbar {
      flex-direction: row;
      align-items: center;
      gap: 20px;
  
      position: relative;
  
      max-width: 100%;
      overflow: visible;
  
      direction: ltr;
    }
  
    .brand {
      max-width: calc(100% - 62px);
    }
  
    .navwrap {
      margin-left: auto;
      margin-right: 0;
  
      flex: 0 0 auto;
  
      position: relative;
      direction: ltr;
    }
  
    .menu-btn {
      display: inline-flex !important;
    }
  
    .navlinks {
      position: absolute;
      top: calc(100% + 10px);
      right: 0;
      left: auto;
  
      display: none !important;
      flex-direction: column !important;
      align-items: stretch;
      justify-content: flex-start;
      gap: 8px;
  
      width: max-content;
      min-width: 220px;
      max-width: min(260px, calc(100vw - 32px));
  
      padding: 10px;
  
      background: #fff;
      border: 1px solid #e7e7e7;
      border-radius: 14px;
      box-shadow: 0 12px 30px rgba(0, 0, 0, .15);
  
      z-index: 2000;
    }
  
    .navlinks.open {
      display: flex !important;
    }
  
    .navlinks a {
      display: block;
  
      width: 100%;
  
      padding: 9px 10px;
  
      font-size: 15px;
      text-align: left;
    }
  
    .navlinks a.cta {
      padding: 10px 14px;
      text-align: center;
    }
  
    /* RTL mobile: brand left, hamburger/dropdown right */
    html[dir="rtl"] .headerbar,
    html:lang(ar) .headerbar,
    html:lang(fa) .headerbar {
      flex-direction: row;
      direction: ltr;
    }
  
    html[dir="rtl"] .brand,
    html:lang(ar) .brand,
    html:lang(fa) .brand {
      order: 1;
      text-align: left;
      direction: rtl;
    }
  
    html[dir="rtl"] .navwrap,
    html:lang(ar) .navwrap,
    html:lang(fa) .navwrap {
      order: 2;
  
      margin-left: auto;
      margin-right: 0;
  
      direction: ltr;
    }
  
    html[dir="rtl"] .navlinks,
    html:lang(ar) .navlinks,
    html:lang(fa) .navlinks {
      right: 0 !important;
      left: auto !important;
  
      direction: rtl;
      text-align: right;
    }
  
    html[dir="rtl"] .navlinks a,
    html:lang(ar) .navlinks a,
    html:lang(fa) .navlinks a {
      text-align: right;
    }
  
    html[dir="rtl"] .navlinks a.cta,
    html:lang(ar) .navlinks a.cta,
    html:lang(fa) .navlinks a.cta {
      text-align: center;
    }
  
    html[dir="rtl"] .lang-dd-menu,
    html:lang(ar) .lang-dd-menu,
    html:lang(fa) .lang-dd-menu {
      right: 0 !important;
      left: auto !important;
  
      max-width: calc(100vw - 32px);
  
      direction: ltr;
      text-align: left;
    }
  }
  
  
  /* =========================================================
     PHONE POLISH
     ========================================================= */
  
  @media (max-width: 600px) {
    .headerbar {
      align-items: flex-start;
      gap: 12px;
  
      padding: 10px 0 18px;
    }
  
    .brand {
      max-width: calc(100% - 58px);
  
      font-size: 21px;
      line-height: 1.15;
    }
  
    .navwrap {
      flex: 0 0 auto;
  
      margin-left: auto;
      margin-right: 0;
  
      padding-right: 0;
    }
  
    .menu-btn {
      width: 46px;
      height: 42px;
  
      font-size: 25px;
      border-radius: 10px;
    }
  
    .navlinks {
      top: calc(100% + 8px);
      min-width: 210px;
    }
  }
  
  
  /* =========================================================
     VERY SMALL PHONES
     ========================================================= */
  
  @media (max-width: 420px) {
    .headerbar {
      gap: 10px;
    }
  
    .brand {
      max-width: calc(100% - 52px);
  
      font-size: 19px;
    }
  
    .menu-btn {
      width: 44px;
      height: 40px;
  
      font-size: 24px;
    }
  
    .navlinks {
      min-width: 200px;
      max-width: calc(100vw - 24px);
    }
  
    .lang-dd-menu {
      max-width: calc(100vw - 24px);
    }
  }
  
  
  /* =========================================================
     DESKTOP SAFETY
     ========================================================= */
  
  @media (min-width: 1051px) {
    .navlinks {
      position: static;
  
      display: flex !important;
      flex-direction: row !important;
      align-items: center;
  
      min-width: 0;
      max-width: 100%;
  
      padding: 0;
  
      background: transparent;
      border: 0;
      box-shadow: none;
    }
  
    .menu-btn {
      display: none !important;
    }
  }

/* =========================================================
   LEGAL PAGE HEADER
   Only language dropdown, no hamburger, no section nav
   ========================================================= */

   .legal-navwrap {
    margin-left: auto !important;
  }
  
  .legal-navlinks {
    position: static !important;
  
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
  
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  
    padding: 0 !important;
    margin: 0 !important;
  
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  
  .legal-navlinks .nav-lang {
    display: block !important;
  }
  
  .legal-navwrap .menu-btn {
    display: none !important;
  }
  
  /* Make sure mobile CSS does not hide the language dropdown */
  @media (max-width: 1050px) {
    .legal-navlinks {
      position: static !important;
  
      display: flex !important;
      flex-direction: row !important;
      align-items: center !important;
  
      width: auto !important;
      min-width: 0 !important;
      max-width: none !important;
  
      padding: 0 !important;
      background: transparent !important;
      border: 0 !important;
      box-shadow: none !important;
    }
  
    .legal-navwrap {
      margin-left: auto !important;
      margin-right: 0 !important;
    }
  }
  
  /* RTL legal header */
  html[dir="rtl"] .legal-navwrap {
    margin-left: auto !important;
    margin-right: 0 !important;
    direction: rtl;
  }
  
  html[dir="rtl"] .legal-navlinks {
    direction: rtl;
  }