:root {
  --header-height: 72px;
  --header-z: 1000;
  --secondary: #E8E6DF;
  --companies-bg: #887755;
  --primary-dark: #522B3A;
}

.header {
  position: sticky;
  top: 0;
  z-index: var(--header-z);
  background: var(--secondary);
  font-family: 'DM Sans', system-ui, sans-serif;
}

.header__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 4rem;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.header__logo-img {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
}

.header__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--header-text);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s;
}

.header__toggle:hover {
  background: rgba(89, 74, 63, 0.08);
}

.header__toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.25s, opacity 0.25s;
}

.header__toggle[aria-expanded="true"] .header__toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.header__toggle[aria-expanded="true"] .header__toggle-bar:nth-child(2) {
  opacity: 0;
}

.header__toggle[aria-expanded="true"] .header__toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.header__overlay {
  display: none;
}

@media (max-width: 900px) {
  .header__overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(89, 74, 63, 0.2);
    z-index: calc(var(--header-z) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
  }

  .header__overlay.is-open {
    opacity: 1;
    visibility: visible;
  }
}

/* Nav container */
.header__nav {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: center;
  gap: 2rem;
}

.header__menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
}

.header__link {
  color: var(--primary-dark);
  text-decoration: none;
  font-size: small;
  font-weight: 500;
  padding: 0.5rem 0;
  position: relative;
  white-space: nowrap;
  transition: color 0.2s;
  font-weight: bold;
}

.header__link:hover {
  color: var(--header-text-hover);
}

/* Hover + active underline */
.header__link::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--companies-bg); 
  border-radius: 1px;
  opacity: 0;
  color: var(--companies-bg); ;
  transition: opacity 0.2s ease;
}

.header__link:hover::after,
.header__link--active::after {
  opacity: 1;
}

.header__arrow {
  font-size: 0.6em;
  opacity: 0.8;
  margin-left: 0.2em;
}

/* Dropdowns */
.header__dropdown {
  position: relative;
}

.header__dropdown:hover .header__submenu,
.header__dropdown:focus-within .header__submenu {
  opacity: 1;
  visibility: visible;
}

.header__submenu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  padding: 0.5rem 0;
  margin: 0;
  list-style: none;
  background: var(--secondary);
  box-shadow: var(--header-shadow);
  border-radius: 6px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 10;
}

.header__submenu a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--header-text);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.header__submenu a:hover {
  background: rgba(89, 74, 63, 0.08);
  color: var(--header-text-hover);
}

/* Right utils: language + search */
.header__utils {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}

.header__util {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--companies-bg );
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color 0.2s;
}

.header__util:hover {
  color: var(--header-text-hover);
}

.header__util-icon {
  flex-shrink: 0;
  opacity: 0.9;
}

/* Search: dropdown under trigger */
.header__search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.header__search-trigger {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
  transition: color 0.2s;
}

.header__search-trigger:hover {
  color: var(--primary-dark);
}

.header__search-wrap.is-open .header__search-trigger {
  color: var(--companies-bg);
}

.header__search-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  min-width: 280px;
  padding: 0.75rem;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(82, 43, 58, 0.12), 0 2px 8px rgba(82, 43, 58, 0.06);
  border: 1px solid rgba(82, 43, 58, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.header__search-wrap.is-open .header__search-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.header__search-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header__search-input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.85rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--primary-dark);
  background: var(--secondary);
  border: 1px solid rgba(82, 43, 58, 0.12);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.header__search-input::placeholder {
  color: rgba(82, 43, 58, 0.45);
}

.header__search-input:focus {
  border-color: var(--companies-bg);
  box-shadow: 0 0 0 3px rgba(136, 119, 85, 0.15);
}

.header__search-submit {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--companies-bg);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.header__search-submit:hover {
  opacity: 0.92;
}

.header__search-submit:active {
  transform: scale(0.97);
}

[dir="rtl"] .header__search-dropdown {
  right: auto;
  left: 0;
}

/* ----- Responsive: tablet ----- */
@media (max-width: 1024px) {
  .header__menu {
    gap: 0.25rem 1rem;
  }

  .header__link {
    font-size: small;
  }

  .header__nav {
    gap: 1rem;
  }
}

@media (max-width: 900px) {
  .header__toggle {
    display: flex;
    order: 2;
  }

  .header__logo {
    order: 1;
  }

  .header__nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 85vw);
    background: var(--secondary);
    box-shadow: -4px 0 20px rgba(89, 74, 63, 0.15);
    z-index: var(--header-z);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: calc(var(--header-height) + 1rem) 1.5rem 1.5rem;
    gap: 0;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.3s, visibility 0.3s;
    overflow-y: auto;
  }

  .header__nav.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  .header__menu {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(89, 74, 63, 0.12);
  }

  .header__menu li {
    border-bottom: 1px solid rgba(89, 74, 63, 0.06);
  }

  .header__menu li:last-child {
    border-bottom: none;
  }

  .header__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0;
    font-size: small;
  }

  .header__link--active::after {
    left: 0;
    right: auto;
    width: 4px;
    height: 100%;
    top: 0;
    bottom: 0;
  }

  .header__dropdown .header__submenu {
    position: static;
    opacity: 1;
    visibility: visible;
    box-shadow: none;
    background: rgba(89, 74, 63, 0.04);
    border-radius: 6px;
    margin: 0.25rem 0 0.5rem;
    padding: 0.25rem 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s;
  }

  .header__dropdown.is-open .header__submenu {
    max-height: 200px;
  }

  .header__dropdown .header__arrow {
    transition: transform 0.2s;
  }

  .header__dropdown.is-open .header__arrow {
    transform: rotate(180deg);
  }

  .header__utils {
    flex-direction: column;
    align-items: stretch;
    padding-top: 1rem;
    gap: 0.5rem;
  }

  .header__util {
    padding: 0.6rem 0;
  }
}

/* Small mobile: compact header height */
@media (max-width: 480px) {
  :root {
    --header-height: 60px;
  }

  .header__logo-img {
    height: 34px;
  }

  .header__inner {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
