.header {
  position: relative;
  transition: all 0.3s ease;
  --header-topbar-height: 45px;
  --header-main-height: 65px;
}

.header.header--no-topbar {
  --header-topbar-height: 0px;
}

/* sticky */
.header.sticky {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9999;
  background-color: var(--primary-background);
  --header-topbar-height: 0px;
}

/* ẩn topbar */
.header.sticky .header__topbar {
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  height: 0;
  overflow: hidden;
}

/* giữ height header main */
.header__main {
  transition: all 0.3s ease;
}

.header .header__topbar {
  background-color: #f9f9f9;
  font-size: 12px;
}

.header .header__topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 45px;
}

.header .topbar__left a {
  color: #0094ff;
  text-decoration: none;
  margin-left: 3px;
}

.topbar__right {
  display: flex;
  align-items: center;
}

.language {
  position: relative;
  cursor: pointer;
}

.language__head {
  display: flex;
  cursor: pointer;
  align-items: center;
  justify-content: space-around;
  gap: 16px;
  padding: 5px 8px;
  border-radius: 18px;
  background-color: var(--primary-background);
  font-size: 14px;
}
.language__head i {
  font-size: 10px;
  color: #222;
}

/* Dropdown */
.language__dropdown {
  position: absolute;
  right: 0;
  background: var(--primary-background);
  border-radius: 12px;
  padding: 8px 0;
  min-width: 160px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  z-index: 2;
  transform: translateY(10px);
  transition: all 0.25s ease;
}

.language__dropdown.language__dropdown--bottom {
  top: calc(100% + 5px);
}

.language__dropdown.language__dropdown--top {
  bottom: calc(100% + 5px);
}

.language:hover .language__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Item */
.language__item a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  color: var(--text-black);
}

/* Flag */
.language__dropdown img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

/* Header Main */
.header .header__main {
  background-color: var(--primary-background);
  border-bottom: 1px solid #f5f5f8;
  height: 65px;
}

.header .header__main-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header .header__logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.header .header__logo img {
  height: 40px;
}

.header .navbar-nav {
  display: flex;
  align-items: center;
  flex-flow: row wrap;
  width: 100%;
  justify-content: space-between;
}

.header .navbar-nav .nav-item {
  margin-right: 30px;
  position: relative;
  display: inline-block;
}

.header .nav-link::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;

  width: 100%;
  height: 3px;
  background: #6c3cff;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}

/* hover */
.header .nav-item:hover .nav-link::after {
  transform: scaleX(1);
}

/* active */
.header .nav-item.active .nav-link::after {
  transform: scaleX(1);
}

.header .navbar-nav .nav-item:last-child {
  margin-right: 0;
}

.header .navbar-nav .nav-item > a {
  font-weight: 500;
  font-size: 16px;
  line-height: 19px;
  padding: 23px 0;
  color: var(--text-black);
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
}

/* MEGA MENU — viewport-centered (do not override left/transform from JS; that re-anchors to the nav item). */
.header .mega-menu {
  position: fixed;
  top: calc(var(--header-topbar-height) + var(--header-main-height));
  left: 50%;
  right: auto;
  width: min(1130px, calc(100vw - 30px));
  max-width: 1130px;
  box-sizing: border-box;
  margin: 0;
  background-color: var(--primary-background);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translate3d(-50%, 10px, 0);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  padding: 0 15px;
}

/* SHOW MENU */
.header .nav-item:hover .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translate3d(-50%, 0, 0);
}

/* Inner flex block (alias .mega-data for layout hooks) */
.header .mega-menu__wrapper,
.header .mega-menu .mega-data {
  display: flex;
  width: 100%;
  padding: 12px;
}

.header .mega-menu__tabs {
  width: 100%;
  max-width: 297px;
  border-right: 1px solid #e5e7ec;
}

.header .mega-menu__tab a {
  align-items: center;
  display: flex;
  font-weight: 500;
  font-size: 16px;
  color: #404963;
  padding: 12px 25px;
  transition: all 0.3s ease;
}

.header .mega-menu__tab:hover a {
  color: var(--primary-color);
}

.header .mega-menu__tab--active a {
  border-left: 2px solid var(--primary-color);
  color: var(--primary-color);
  position: relative;
}

.header .mega-menu__content {
  flex: 1;
  padding: 45px 30px 30px;
}

.header .mega-menu__list {
  display: flex;
}

.header .mega-menu__column {
  flex: 0 0 calc(100% / 4);
}

.header .mega-menu__column li {
  margin-bottom: 20px;
}

.mega-menu__column a {
  color: #0c1941;
  transition: all 0.3s ease;
}

.mega-menu__column a:hover {
  color: var(--primary-color);
}

.header .mega-menu__button {
  display: block;
  text-align: center;
  padding: 16px;
  background: var(--primary-color);
  color: #ffffff;
  font-weight: bolder;
  border-radius: 50px;
  transition: all 0.3s ease;
}

.header .mega-menu__button:hover {
  opacity: 0.9;
}

.header .navbar-nav .nav-item .nav-link i {
  margin-left: 7px;
  opacity: 1;
  font-size: 14px;
  color: #666;
  font-weight: 600;
}

/* SUB MENU LIÊN HỆ */
.header .sub-menu {
  position: absolute;
  top: 100%;
  left: -50%;
  transform: translateX(50%);

  min-width: 225px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 1px 4px 16px rgba(0, 0, 0, 0.05);
  padding: 0 15px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 999;
}

.header .sub-menu__item a {
  font-size: 14px;
  font-weight: 400;
  line-height: 24px;
  display: block;
  padding: 6px 0;
  color: var(--text-black);
  transition: all 0.3s ease;
}

.header .sub-menu__item a:hover {
  color: var(--primary-color);
}

/* HOVER HIỆN MENU */
.nav-item:hover > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.header .search {
  display: flex;
  align-items: center;
  position: relative;
  width: 42px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.header .search.active {
  width: 365px;
}

/* ICON */
.header .search__icon {
  position: absolute;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ICON CHUI VÀO */
.header .search.active .search__icon {
  left: 15px;
  transform: scale(0.9);
  opacity: 0.6;
}

.header .search__icon i {
  font-size: 20px;
}

/* BOX */
.header .search.active .search__box {
  border: 2px solid #f5f5f8;
  background: #fff;
  height: 50px;
}

.header .search__box {
  display: flex;
  align-items: center;
  flex: 1;
  border-radius: 16px;
  overflow: hidden;
  padding-left: 35px;
}

.header .search__left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header .search__flag {
  width: 20px;
  height: 20px;
  object-fit: cover;
  display: block;
}

.header .search__input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0 10px;
  font-size: 14px;
  opacity: 0;
  transition: 0.2s;
}

.header .search.active .search__input {
  opacity: 1;
}

.header .search__clear {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
}

.header .search.active .search__clear {
  opacity: 1;
}

/* DROPDOWN */
.header .search__dropdown {
  position: absolute;
  top: 110%;
  left: 0;
  width: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: 0.3s;
}

.header .search.active.show-dropdown .search__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.header .search__item {
  display: flex;
  justify-content: space-between;
  padding: 12px 15px;
  cursor: pointer;
}

.header .search__item:hover {
  background: #f5f5f5;
}

.search__price {
  color: var(--primary-color);
}

.header .cart-header i {
  color: #0094ff;
}

.header .cart-header {
  position: relative;
}

.header .cart-header > a,
.header .mobile-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header .cart-header .cart-badge {
  position: absolute;
  top: 8px;
  right: -13px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #45aaf7;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.header .mobile-cart .cart-badge {
  top: -4px;
  right: -5px;
}

.header .header-mobile-right {
  display: none;
}

.header .mobi-iconbox {
  position: relative;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header .mobi-iconbox .menu-icon {
  display: block;
  width: 25px;
  cursor: pointer;
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  margin: 0 auto;
  transform: translate(0, -50%);
  transition: all 0.4s ease 0s;
}

.header .mobi-iconbox .menu-icon .icon-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-black);
  transition: all 0.4s ease 0s;
}

.header .mobi-iconbox .menu-icon .icon-bar + .icon-bar {
  margin-top: 5px;
}

/* ===== MOBILE MENU ===== */
.header .mobi-iconbox.is-active .top-icon-bar {
  transform: translateY(7px) rotate(45deg);
}

.header .mobi-iconbox.is-active .middle-icon-bar {
  opacity: 0;
}

.header .mobi-iconbox.is-active .bottom-icon-bar {
  transform: translateY(-7px) rotate(-45deg);
}

/* .mobile-menu {
  display: none;
} */

/* ===== MOBILE MENU ===== */
.mobile-menu {
  position: fixed;
  top: 65px;
  left: -100%;
  width: 100%;
  height: 100vh;
  overflow-y: auto;
  padding: 20px;

  background-color: var(--primary-background);
  z-index: 9999;

  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

/* active */
.mobile-menu.active {
  opacity: 1;
  visibility: visible;
  left: 0;
  pointer-events: auto;
}

/* SEARCH */
.mobile-menu__search {
  display: flex;
  margin-bottom: 10px;
}

.mobile-menu__search input {
  font-weight: 400;
  font-size: 18px;
  line-height: 24px;
  border-radius: 16px;
  height: 50px;
  margin: 0;
  color: var(--text-black);
  background-color: var(--primary-background);
  min-width: 290px;
  flex: 1;
  padding: 15px 10px 15px 45px;
  border: 2px solid #f5f5f8;
}

.mobile-menu__search input::placeholder {
  color: var(--text-black);
  font-size: 14px;
}

/* LIST */
.mobile-menu__list {
  position: relative;
  font-size: 20px;
  font-weight: 500;
  color: #404963;
  line-height: 1.5;
}

/* ITEM */
.mobile-menu__item {
  border-bottom: 1px solid #f5f5f8;
  padding: 15px 0;
  position: relative;
  width: 100%;
}

.menu-mobile .hitarea {
  position: absolute;
  width: 60px;
  height: 60px;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-mobile .hitarea i {
  font-size: 18px;
  transition: transform 0.25s ease;
}

/* SUB MENU */
.mobile-menu__sub {
  display: none;
  background: var(--primary-background);
  margin: 16px 0 0 16px;
  z-index: 1;
}

.mobile-menu__sub li {
  margin-bottom: 18px;
  position: relative;
}

/* SUB ITEM */
.mobile-menu__sub li a {
  display: block;
  color: #404963;
  font-size: 18px;
  font-weight: 400;
}

.mobile-menu__item i {
  transition: 0.3s;
}

.mobile-menu__item.open i {
  transform: rotate(90deg);
}

.mobile-search-wrapper {
  position: relative;
  z-index: 999;
}
/* SEARCH DROPDOWN */
.mobile-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 12px;
  margin-top: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  /* display: none; */
  transform: translateY(10px);
  transition: all 0.25s ease;
}

.mobile-search-dropdown.active {
  opacity: 1;
  visibility: visible;
  /* display: block; */
  transform: translateY(0);
}

.mobile-search-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 15px;
}

.mobile-search-item:hover {
  background: #f5f5f5;
}

.mobile-search-dropdown {
  max-height: 300px;
  overflow-y: auto;
}

@media (max-width: 991px) {
  .header .header__topbar {
    display: none;
  }

  .header .header-right {
    display: none;
  }

  .header .header-mobile-right {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: space-between;
  }

  .header .mobi-iconbox {
    display: block;
  }
  .header .mobile-cart .cart-badge {
    top: -12px;
    right: -10px;
  }
}
