/* =============================================
   SITE HEADER — fixed wrapper, topbar + nav
   ============================================= */

#site-header-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
}

#site-header-wrapper:not(.site-header--inner) {
  background-color: rgba(33, 33, 33, 0.41);
}

/* --- Topbar --- */
.site-topbar {
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  padding: 7px 0;
  max-height: 44px;
  overflow: hidden;
  opacity: 1;
  transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.35s ease;
}

.site-topbar-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.site-topbar-item i {
  color: var(--color-primary);
  font-size: 15px;
}

.site-topbar-divider {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.25);
  display: inline-block;
}

.site-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: color 0.2s;
}

.site-lang-btn:hover,
.site-lang-btn.active {
  color: #ffffff;
}

/* Topbar ẩn khi scroll */
#site-header-wrapper.is-scrolled .site-topbar {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* --- Desktop Nav --- */
.site-nav {
  min-height: 82px;
  display: flex;
  align-items: center;
  transition: min-height 0.28s ease, box-shadow 0.28s ease;
}

#site-header-wrapper.is-scrolled .site-nav {
  min-height: 60px;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 18px rgba(1, 27, 62, 0.1);
}

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

.site-brand img {
  height: 60px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  transition: height 0.28s ease;
}

#site-header-wrapper.is-scrolled .site-brand img {
  height: 44px;
}

.site-menu {
  flex: 1;
  justify-content: center;
  gap: 0;
  padding: 0;
}

.site-menu-item {
  position: relative;
}

.site-nav-link {
  display: block;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0 14px;
  line-height: 82px;
  transition: color 0.2s ease, line-height 0.28s ease;
  white-space: nowrap;
}

.site-nav-link:hover,
.site-nav-link.active {
  color: var(--color-primary-light);
}

#site-header-wrapper.is-scrolled .site-nav-link {
  line-height: 60px;
}

/* Dropdown */
.site-menu-item.has-children:hover .site-dropdown {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.site-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(1, 27, 62, 0.12);
  border-top: 2px solid var(--color-primary);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
  padding: 6px 0;
}

.site-dropdown-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  color: var(--color-secondary);
  font-size: 13.5px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.site-dropdown-item:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.site-dropdown-item i {
  font-size: 12px;
  color: var(--color-primary);
}

/* Nested dropdown (level 2) */
.site-dropdown li.has-sub {
  position: relative;
}

.site-dropdown li.has-sub > .site-dropdown-item {
  justify-content: space-between;
}

.site-dropdown-sub {
  position: absolute;
  top: 0;
  left: 100%;
  min-width: 200px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(1, 27, 62, 0.12);
  border-top: 2px solid var(--color-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 11;
  padding: 6px 0;
}

.site-dropdown li.has-sub:hover > .site-dropdown-sub {
  opacity: 1;
  pointer-events: auto;
}

/* Search */
.site-search-form {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.site-search-input {
  border: 1px solid var(--border-color);
  border-right: none;
  border-radius: 0;
  height: 40px;
  padding: 0 14px;
  font-size: 13px;
  width: 200px;
  outline: none;
  transition: border-color 0.2s;
}

.site-search-input:focus {
  border-color: var(--color-primary);
}

.site-search-btn {
  height: 40px;
  width: 42px;
  background: var(--color-primary);
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.site-search-btn:hover {
  background: var(--color-primary-hover);
}

/* --- Mobile Nav --- */
.site-mobile-nav {
  padding: 10px 0;
  box-shadow: 0 2px 10px rgba(1, 27, 62, 0.08);
  background: #ffffff6b;
  transition: background 0.35s ease, box-shadow 0.35s ease, padding 0.38s ease;
}

.site-mobile-nav .site-brand img {
  height: 46px;
}

.site-mobile-nav .mobile-nav-toggler {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  text-align: center;
  background: var(--tg-secondary-color);
  color: var(--tg-white);
  border-radius: 50%;
  font-size: 25px;
  cursor: pointer;
}

/* === Mobile Topbar === */
.site-mobile-topbar {
  height: 38px;
  max-height: 38px;
  overflow: hidden;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.88);
  background: var(--color-primary);
  opacity: 1;
  transition: max-height 0.35s ease, opacity 0.28s ease, padding 0.35s ease;
}

.site-mobile-topbar-phone {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-size: 12px;
  font-weight: 200;
  white-space: nowrap;
}

.site-mobile-topbar-phone i {
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
}

/* Ẩn khi scroll (giống desktop topbar) */
#site-header-wrapper.is-scrolled .site-mobile-topbar {
  max-height: 0;
  opacity: 0;
}

/* === Mobile inner pages: nav overlays cont-top === */
.site-mobile-nav--inner {
  background: transparent !important;
  box-shadow: none !important;
  transition: padding 0.38s ease;
  margin-bottom: 12px;
}

/* Logo: animate collapse (no display:none — dùng max-width + opacity) */
.site-mobile-nav--inner .site-brand {
  max-width: 200px;
  overflow: hidden;
  flex-shrink: 0;
  transition: max-width 0.38s ease, opacity 0.28s ease;
}

/* Toggler: chuẩn bị transition cho shadow và scale */
.site-mobile-nav--inner .mobile-nav-toggler {
  transition: box-shadow 0.3s ease, transform 0.38s ease;
  flex-shrink: 0;
}

/* ---- Scrolled: toggler ghim góc phải top ---- */

/* Wrapper: pointer-events off (transparent vùng rỗng không chặn click) */
.site-header--inner.is-scrolled {
  pointer-events: none;
}

/* Desktop nav vẫn clickable */
.site-header--inner.is-scrolled .site-nav {
  pointer-events: auto;
}

/* Nav bar thu nhỏ padding */
.site-header--inner.is-scrolled .site-mobile-nav--inner {
  padding: 0;
  pointer-events: none;
}

/* Logo thu lại (max-width → 0 tạo hiệu ứng slide collapse về bên trái) */
.site-header--inner.is-scrolled .site-mobile-nav--inner .site-brand {
  max-width: 0;
  opacity: 0;
  pointer-events: none;
}

/* Toggler: ghim cứng góc phải top bằng position fixed */
.site-header--inner.is-scrolled .site-mobile-nav--inner .mobile-nav-toggler {
  position: fixed;
  top: 10px;
  right: 12px;
  pointer-events: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.32);
  transform: scale(0.88);
  z-index: 1200;
}

/* === Mobile homepage: scroll → logo ẩn, toggler ghim góc phải (giống inner) === */

/* Transitions cho homepage mobile nav */
.site-mobile-nav:not(.site-mobile-nav--inner) .site-brand {
  max-width: 200px;
  overflow: hidden;
  flex-shrink: 0;
  transition: max-width 0.38s ease, opacity 0.28s ease;
}

.site-mobile-nav:not(.site-mobile-nav--inner) .mobile-nav-toggler {
  transition: box-shadow 0.3s ease, transform 0.38s ease, opacity 0.3s ease;
  flex-shrink: 0;
}

/* Wrapper: pointer-events off khi scrolled */
#site-header-wrapper.is-scrolled:not(.site-header--inner) {
  pointer-events: none;
}

#site-header-wrapper.is-scrolled:not(.site-header--inner) .site-nav {
  pointer-events: auto;
}

/* Mobile nav: fade out background + shadow, padding về 0 */
#site-header-wrapper.is-scrolled:not(.site-header--inner) .site-mobile-nav {
  padding: 0;
  pointer-events: none;
  background: transparent;
  box-shadow: none;
}

/* Logo slide collapse */
#site-header-wrapper.is-scrolled:not(.site-header--inner) .site-mobile-nav .site-brand {
  max-width: 0;
  opacity: 0;
  pointer-events: none;
}

/* Toggler ghim cứng góc phải */
#site-header-wrapper.is-scrolled:not(.site-header--inner) .site-mobile-nav .mobile-nav-toggler {
  position: fixed;
  top: 10px;
  right: 12px;
  pointer-events: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.32);
  transform: scale(0.88);
  z-index: 1200;
}

/* === Mobile inner pages: cont-top chỉ shift lên đúng chiều cao mobile nav
   → topbar (solid) nằm trên hero, nav (transparent) overlay hero          === */
@media (max-width: 991.98px) {
  body.is-inner-page .cont-top {
    margin-top: calc(var(--mobile-nav-h, 64px) * -1);
    padding-top: calc(var(--mobile-nav-h, 64px) + 1rem);
  }
}
