/* =======================================================
   HEADER — Cấu trúc, scroll, mega menu, hamburger
======================================================== */

#site-header {
  position: fixed !important;
  top: 0; left: 0; width: 100%;
  z-index: 3000;
  background-color: transparent !important;
  border-bottom: none !important;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              background-color 0.3s ease,
              box-shadow 0.3s ease,
              border 0.3s ease;
}

.header-container {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 80px;
}

/* ----- Trạng thái scroll ----- */
#site-header.is-at-top {
  background-color: transparent !important;
  border-bottom: none !important;
  box-shadow: none !important;
}
#site-header.is-scrolled-up,
#site-header.is-scrolled-down,
#site-header.is-active {
  background-color: rgba(255, 255, 255, 0.98) !important;
}
#site-header.is-scrolled-up {
  box-shadow: 0 4px 15px rgba(0,0,0,0.05) !important;
  transform: translateY(0);
}
#site-header.is-scrolled-down {
  transform: translateY(-100%);
  box-shadow: none !important;
}

/* Khi mở menu mobile: ép trắng 100% */
#site-header.is-active,
#site-header.is-at-top.is-active {
  background-color: #fff !important;
  border-bottom: 1px solid #eee !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05) !important;
}
#site-header.is-active .header-logo h2,
#site-header.is-active .main-menu-list > li > a,
#site-header.is-active .h-icon svg,
#site-header.is-active .hamburger-btn svg,
#site-header.is-at-top.is-active .header-logo h2,
#site-header.is-at-top.is-active .h-icon svg,
#site-header.is-at-top.is-active .hamburger-btn svg {
  color: #000 !important;
  stroke: #000 !important;
  fill: none !important;
}

/* ----- Các trang không phải index: Header luôn trắng ----- */
body:not(.tpl-index) #site-header,
body:not(.tpl-index) #site-header.is-at-top {
  background-color: #fff !important;
  border-bottom: 1px solid #eee !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05) !important;
}
body:not(.tpl-index) #site-header .header-logo h2,
body:not(.tpl-index) #site-header.is-at-top .header-logo h2,
body:not(.tpl-index) #site-header .main-menu-list > li > a,
body:not(.tpl-index) #site-header.is-at-top .main-menu-list > li > a,
body:not(.tpl-index) #site-header .h-icon svg,
body:not(.tpl-index) #site-header.is-at-top .h-icon svg,
body:not(.tpl-index) #site-header .hamburger-btn svg,
body:not(.tpl-index) #site-header.is-at-top .hamburger-btn svg {
  color: #000 !important;
  stroke: #000 !important;
  fill: none !important;
}
body:not(.tpl-index) #main-content {
  padding-top: 80px !important;
}
@media (max-width: 768px) {
  body:not(.tpl-index) #main-content {
    padding-top: 60px !important;
  }
}

/* ----- Logo ----- */
.header-logo h2 {
  font-size: 28px;
  font-weight: 900;
  color: #000;
  letter-spacing: 2px;
  margin: 0;
}

/* ----- Menu chính ----- */
.header-nav { display: block; }
.main-menu-list {
  display: flex !important;
  flex-direction: row;
  gap: 30px;
}
.main-menu-list > li > a {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 10px 0;
  color: #000;
  display: block;
}
.main-menu-list > li > a:hover,
.menu-link-active { color: #000 !important; opacity: 0.6; }

/* ----- Mega menu ----- */
.has-mega-menu { position: static; }
.mega-menu-dropdown {
  position: absolute;
  top: 80px; left: 0;
  width: 100%;
  background-color: #fff;
  border-top: 1px solid #eaeaea;
  box-shadow: 0 10px 20px rgba(0,0,0,0.05);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 100;
}
.has-mega-menu:hover .mega-menu-dropdown { opacity: 1; visibility: visible; }

.mega-menu-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 20px;
  display: flex;
  gap: 50px;
}
.mega-menu-columns {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 30px;
}
.col-title, .col-title a {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 20px;
  text-transform: uppercase;
}
.mega-menu-columns .menu-col h4.col-title a {
  color: #1768b2 !important;
  transition: color 0.3s ease;
}
.mega-menu-columns .menu-col h4.col-title a:hover {
  color: #2596be !important;
}
.menu-col ul li a { font-size: 13px; color: #000; opacity: 0.8; }
.menu-col ul li a:hover { opacity: 1; text-decoration: underline; }
.mega-menu-image { width: 250px; flex-shrink: 0; }
.mega-menu-image img { width: 100%; border-radius: 4px; }

/* ----- Level 3 & 4 mega menu ----- */
.level-3-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
}
.level-3-link { font-weight: bold; }

.toggle-arrow {
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 5px;
  user-select: none;
  display: inline-flex;
  transition: transform 0.3s ease;
}
.toggle-arrow.is-open { transform: rotate(90deg); }

.level-4-list {
  display: none !important;
  list-style: none;
  padding-left: 15px !important;
  margin-top: 8px !important;
}
.level-4-list.is-open { display: block !important; }
.has-level-4:hover .level-4-list { display: block !important; }
.has-level-4:hover .toggle-arrow { transform: rotate(90deg); }

/* ----- Icons (search, wishlist, cart, account) ----- */
.header-icons {
  display: flex;
  align-items: center;
  gap: 20px;
}
.h-icon {
  display: inline-flex;
  align-items: center;
  color: #000 !important;
  position: relative !important;
}
.sobie-wishlist-header-icon {
  position: relative !important;
  display: inline-flex !important;
  align-items: center;
}

.cart-icon { position: relative; }
.cart-count {
  position: absolute;
  top: -8px; right: -10px;
  background-color: #000;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}
#wishlist-count-header {
  position: absolute !important;
  top: -6px !important; right: -8px !important;
  background: #000 !important;
  color: #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99 !important;
  line-height: 1;
}
.sobie-wishlist-btn.is-active svg,
.sobie-wishlist-btn.is-active svg path {
  fill: #ff4d4f !important;
  stroke: #ff4d4f !important;
  transition: all 0.3s ease;
}

/* =======================================================
   DESKTOP: Mega menu no-gap fix (>= 769px)
======================================================== */
@media (min-width: 769px) {
  .main-menu-list > li {
    display: flex;
    align-items: center;
    height: 80px !important;
  }
  .mega-menu-dropdown {
    top: 80px !important;
    border-top: 1px solid #eaeaea !important;
  }
  #site-header:hover,
  #site-header.is-at-top:hover,
  #site-header:has(.has-mega-menu:hover) {
    background-color: #fff !important;
  }
  #site-header:has(.has-mega-menu:hover) .header-logo h2,
  #site-header:has(.has-mega-menu:hover) .main-menu-list > li > a,
  #site-header:has(.has-mega-menu:hover) .h-icon svg {
    color: #000 !important;
    stroke: #000 !important;
  }
}

/* =======================================================
   MOBILE DRAWER (menu trượt xuống từ trên)
======================================================== */
.mobile-header-left,
.mobile-drawer,
.mobile-drawer-overlay { display: none; }

@media (max-width: 1024px) {
  .header-nav { display: none !important; }
  .mobile-header-left { display: flex; align-items: center; gap: 15px; }
  .m-hide-mobile { display: none !important; }
  .m-hide-desktop { display: flex !important; }

  .hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #000 !important;
    padding: 0;
    z-index: 3001;
    width: 44px; height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
  }
  .hamburger-btn svg {
    width: 24px; height: 18px;
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  }
  .hamburger-btn svg line {
    stroke: currentColor;
    stroke-width: 2px;
    stroke-linecap: butt;
    transform-origin: center;
    transition: transform 0.4s ease, opacity 0.3s ease;
  }
  .hamburger-btn.is-active svg { transform: rotate(180deg); }
  .hamburger-btn.is-active .hl-1 { transform: translateY(6px) rotate(45deg); }
  .hamburger-btn.is-active .hl-2 { opacity: 0; }
  .hamburger-btn.is-active .hl-3 { transform: translateY(-6px) rotate(-45deg); }

  /* Overlay nền mờ */
  .mobile-drawer-overlay {
    display: block;
    position: fixed;
    top: 80px; left: 0;
    width: 100vw;
    bottom: var(--sobie-bnav-h, 60px);
    height: auto;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    opacity: 0; visibility: hidden;
    transition: 0.3s;
  }
  .mobile-drawer-overlay.is-open { opacity: 1; visibility: visible; }

  /* Ngăn kéo */
  .mobile-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 80px; left: 0;
    width: 100%;
    bottom: var(--sobie-bnav-h, 60px); /* Dính ngay top của bottom-nav */
    height: auto;
    background: #fff;
    z-index: 2001;
    transform: translateY(-150%);
    transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  }
  .mobile-drawer.is-open { transform: translateY(0); }

  /* Tabs top */
  .drawer-tabs {
    display: flex;
    overflow-x: auto;
    background: #fff;
    border-bottom: none !important;
    scrollbar-width: none;
  }
  .drawer-tabs::-webkit-scrollbar { display: none; }
  .drawer-tab-btn {
    padding: 20px 15px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-weight: 700;
    color: #999;
    white-space: nowrap;
    cursor: pointer;
  }
  .drawer-tab-btn.active {
    color: #000;
    border-bottom-color: #000;
  }

  /* Nội dung & accordion */
  .drawer-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fff;
  }
  .drawer-tab-content { display: none; animation: fadeIn 0.3s; }
  .drawer-tab-content.active { display: block; }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

  .m-accordion {
    margin-bottom: 20px;
    list-style: none !important;
    padding-left: 0 !important;
  }
  .m-accordion > li {
    border-bottom: 1px solid #f9f9f9 !important;
    padding: 15px 0;
    list-style: none !important;
  }
  .m-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .m-link-lv2 {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
  }
  .m-plus-icon {
    font-size: 20px;
    font-weight: 300;
    cursor: pointer;
    width: 30px;
    text-align: right;
  }
  .m-accordion-body { display: none; padding-top: 10px; padding-left: 10px; }
  .m-accordion-body li { margin-bottom: 10px; }
  .m-accordion-body a { font-size: 13px; color: #666; }

  /* Sản phẩm gợi ý trong ngăn kéo */
  .m-drawer-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
  }
  .m-product-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fff !important;
    padding: 8px 0 !important;
    border: none !important;
    box-shadow: none !important;
  }
  .m-product-card img {
    width: 60px; height: 60px;
    object-fit: cover;
    border-radius: 4px;
  }
  .m-product-info h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #000;
  }
  .m-product-info p { font-size: 12px; color: #666; }

  .m-sub-links-list { margin-bottom: 15px; }
  .m-drawer-products.has-border-top {
    margin-top: 15px;
    border-top: 1px dashed #e0e0e0;
    padding-top: 15px;
  }

  /* View all & Footer drawer */
  .m-view-all-btn {
    display: block;
    width: 100%;
    padding: 12px;
    text-align: center;
    border: 1px solid #000;
    border-radius: 25px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 20px;
  }
  .drawer-footer {
    background: #fff !important;
    padding: 20px;
    border-top: none !important;
  }
  .drawer-footer a {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 15px;
  }

  /* Ép toàn bộ mobile drawer ul/li không có dấu chấm */
  .mobile-drawer ul,
  .mobile-drawer li {
    list-style: none !important;
    list-style-type: none !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
  }
  .mobile-drawer li::before,
  .mobile-drawer li::after {
    display: none !important;
    content: none !important;
  }
}

/* =======================================================
   MOBILE RESPONSIVE (<=768px): Thu gọn header
======================================================== */
@media (max-width: 768px) {
  .header-container {
    height: 60px !important;
    padding: 0 15px !important;
  }
  .header-logo img { max-height: 25px !important; }

  .header-icons {
    gap: 16px !important;
    padding-right: 0 !important;
  }
  .mobile-header-left { gap: 16px !important; }
  .header-icons .account-icon,
  .header-icons .sobie-wishlist-header-icon,
  .header-icons .cart-icon {
    display: none !important;
  }

  .header-icons .h-icon {
    width: 44px !important;
    height: 44px !important;
    justify-content: center !important;
  }

  .header-icons .h-icon svg,
  .mobile-header-left .h-icon svg,
  .hamburger-btn svg {
    width: 18px !important;
    height: 18px !important;
  }

  .cart-count,
  #wishlist-count-header {
    width: 14px !important;
    height: 14px !important;
    font-size: 9px !important;
    top: -6px !important;
    right: -8px !important;
  }

  /* Vá gap mobile drawer ở mobile nhỏ (header thu gọn xuống 60px) */
  .mobile-drawer,
  .mobile-drawer-overlay { top: 60px !important; }
  .mobile-drawer {
    bottom: var(--sobie-bnav-h, 60px) !important; /* Dính top của bottom-nav */
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .mobile-drawer-overlay {
    bottom: var(--sobie-bnav-h, 60px) !important;
    height: auto !important;
  }
  .drawer-content-area {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .drawer-footer {
    flex-shrink: 0 !important;
    padding-bottom: 20px !important; /* Bỏ env đáy vì menu không chạm đáy nữa */
  }

  /* Header không bị giấu khi menu đang mở */
  #site-header.is-scrolled-down {
    transform: translateY(-100%) !important;
    background-color: rgba(255, 255, 255, 0.98) !important;
  }
  #site-header.is-scrolled-down.is-active {
    transform: translateY(0) !important;
  }
}

/* =======================================================
   HIỆU ỨNG BAY TIM WISHLIST
======================================================== */
.wishlist-float-anim {
  position: fixed;
  z-index: 99999;
  display: flex;
  align-items: center;
  color: #ff4d4f;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: floatUpWishlist 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes floatUpWishlist {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1.2);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -150%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -200%) scale(0.8);
  }
}