body.no-scroll {
  overflow: hidden;
}

:root {
  --da-header-height: 56px;
}

/* Fixed header — stays visible while scrolling */
#site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  width: 100%;
}

/* Offset page content so it isn't hidden under the fixed header */
body {
  padding-top: var(--da-header-height);
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--da-header-height);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  gap: 12px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 8px;
  direction: ltr;
  flex-shrink: 0;
}

.logo-area a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

/* English: logo on the left, site name on the right */
html[dir="ltr"] .logo-area a {
  flex-direction: row-reverse;
}

.logo-area img {
  width: 50%;
  height: 50px;
  object-fit: contain;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
}

/* Grow between logo and actions so links sit in the visual center */
.header > nav {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  flex: 0 1 auto;
  justify-content: center;
  margin: 0;
  padding: 0;
}

.nav a {
  display: block;
  padding: 6px 10px;
  font-size: 14px;
  color: #111;
  text-decoration: none;
  font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: "Cairo", sans-serif;
}

.nav a:hover {
  background: #f3f4f6;
}

.actions {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
  direction: ltr;
}

/* Sequence: menu → user → lang → theme */
.menu-toggle {
  order: 1;
}

.header-auth {
  order: 2;
  display: flex;
  align-items: center;
}

.lang-toggle {
  order: 3;
}

.theme-toggle {
  order: 4;
}

/* English: start from the right */
html[dir="ltr"] .actions {
  flex-direction: row-reverse;
}

/* Arabic: logo on the right, action icons on the left */
html[dir="rtl"] .header {
  direction: ltr;
  flex-direction: row-reverse;
}

html[dir="rtl"] .actions {
  flex-direction: row;
  margin-left: 0;
  margin-right: 0;
}

html[dir="rtl"] .header > nav {
  direction: rtl;
}

.login-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid #d1d5db;
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  color: #111;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: "Cairo", sans-serif;
}

.login-btn:hover {
  background: #f3f4f6;
}

.user-profile {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px 0 6px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: transparent;
  color: #111;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  font-family: "Cairo", sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.user-profile:hover {
  background: #f3f4f6;
}

.user-profile img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-profile-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu {
  position: relative;
}

.user-menu-caret {
  font-size: 11px;
  color: #6b7280;
  margin-inline-start: 2px;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 190px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 1200;
  direction: rtl;
}

html[dir="ltr"] .user-dropdown {
  left: auto;
  right: 0;
  direction: ltr;
}

.user-dropdown.open {
  display: block;
}

.user-dropdown-item {
  display: block;
  width: 100%;
  text-align: right;
  border: 0;
  background: transparent;
  color: #111827;
  font-family: "Cairo", sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

html[dir="ltr"] .user-dropdown-item {
  text-align: left;
}

.user-dropdown-item:hover {
  background: #f3f4f6;
}

.user-dropdown-item.danger {
  color: #dc2626;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid #d1d5db;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #111;
  transition: background 0.15s;
  font-size: 16px;
}

.icon-btn:hover {
  background: #f3f4f6;
}

.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: #374151;
  font-size: 26px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.menu-toggle svg {
  width: 26px;
  height: 26px;
  display: block;
}

.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}

.mobile-menu-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.mobile-menu {
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: min(70vw, 584px);
  padding: 14px 20px;
  background: #fff;
  transition: transform 0.25s ease;
}

/* Dock to inline-start: RTL = right edge, LTR = left edge.
   translateX is physical, so closed offset must match the dock side. */
html[dir="rtl"] .mobile-menu {
  transform: translateX(100%); /* hide off to the right → opens right-to-left */
}

html[dir="ltr"] .mobile-menu {
  transform: translateX(-100%); /* hide off to the left → opens left-to-right */
}

.mobile-menu-overlay.is-open .mobile-menu {
  transform: translateX(0);
}

.mobile-menu-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  border-bottom: 1px solid #e5e7eb;
  direction: ltr;
}

.mobile-menu-logo {
  width: 58px;
  height: 50px;
  object-fit: contain;
}

.mobile-menu-close {
  border: 0;
  background: transparent;
  color: #4b5563;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.mobile-nav {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-nav a {
  display: block;
  padding: 7px 16px;
  color: #374151;
  font-family: "Cairo", sans-serif;
  font-size: 17px;
  font-weight: 700;
  text-align: start;
  text-decoration: none;
}

.theme-icon {
  display: none;
}

.theme-icon.is-visible {
  display: block;
}

@media (max-width: 1158px) {
  :root {
    --da-header-height: 64px;
  }

  .header {
    padding: 0 16px;
    gap: 8px;
  }

  .header nav {
    display: none;
  }

  .logo-area {
    min-width: 0;
    flex-shrink: 1;
  }

  .logo-area img {
    width: 56px;
    height: 50px;
  }

  .actions {
    min-width: 0;
    flex-shrink: 0;
  }

  /* Keep menu + login near the logo so they are not clipped off-screen in RTL. */
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Compact profile: icon only on small/tablet screens */
  .user-profile {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  .user-profile-name,
  .user-menu-caret {
    display: none;
  }

  .user-profile img {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 600px) {
  :root {
    --da-header-height: 72px;
  }

  .header {
    padding: 0 14px;
  }

  .logo-text {
    display: none;
  }

  .logo-area img {
    width: 56px;
    height: 56px;
  }

  .actions {
    gap: 5px;
  }

  .login-btn {
    display: block;
    height: 44px;
    padding: 0 12px;
    font-size: 16px;
  }

  .icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    font-size: 20px;
  }

  .menu-toggle {
    width: 34px;
    height: 42px;
    margin-inline-start: 0;
    font-size: 28px;
  }

  .mobile-menu {
    width: min(86vw, 584px);
  }
}

/* Dark mode — header & shared pages */
body.dark-mode {
  background: #000;
  color: #fff;
}

body.dark-mode .header,
body.dark-mode .mobile-menu {
  background: #000;
}

body.dark-mode .logo-text,
body.dark-mode .nav a,
body.dark-mode .login-btn,
body.dark-mode .user-profile,
body.dark-mode .icon-btn,
body.dark-mode .mobile-nav a {
  color: #fff;
}

body.dark-mode .mobile-menu-overlay {
  background: rgba(255, 255, 255, 0.58);
}
