* {
  box-sizing: border-box;
}

.navber {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff;
  box-shadow: 0 2px 14px rgba(17, 26, 51, 0.06);
}

.navber-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  height: 78px;
  margin: 0 auto;
  padding: 12px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

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

.whatsapp-link img {
  width: auto;
  height: 48px;
  object-fit: contain;
}

.cart-link img {
  width: auto;
  height: 28px;
  object-fit: contain;
}

.cart-link {
  position: relative;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 42px;
  margin-left: auto;
  margin-right: auto;
}

.main-nav > a,
.nav-products {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  color: #111a33;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.main-nav > a.is-active::after,
.nav-products.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -14px;
  height: 4px;
  border-radius: 999px;
  background: #2d5bdb;
}

.nav-item {
  position: relative;
}

.nav-caret {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s ease;
}

.nav-item-products:hover .nav-caret,
.nav-item-products:focus-within .nav-caret,
.nav-item-products.open .nav-caret {
  transform: rotate(225deg) translateY(-1px);
}

/* 下拉外層貼住頂欄，靠自身透明 padding 作「hover 橋」，避免中途甩掉造成閃爍 */
.product-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  z-index: 120;
  width: max-content;
  max-width: 86vw;
  padding-top: 14px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  pointer-events: none;
}

.dropdown-panel {
  position: relative;
  display: grid;
  gap: 2px;
  min-width: 190px;
  padding: 10px;
  border: 1px solid #e2e9fb;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(17, 26, 51, 0.16);
}

.dropdown-panel::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  width: 12px;
  height: 12px;
  border-top: 1px solid #e2e9fb;
  border-left: 1px solid #e2e9fb;
  background: #ffffff;
  transform: translateX(-50%) rotate(45deg);
}

.dropdown-panel a {
  position: relative;
  z-index: 1;
  display: block;
  padding: 11px 14px;
  border-radius: 10px;
  color: #111a33;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.dropdown-panel a:hover,
.dropdown-panel a:focus-visible {
  background: #eef3ff;
  color: #255de0;
}

.nav-item-products:hover .product-dropdown,
.nav-item-products:focus-within .product-dropdown,
.nav-item-products.open .product-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.whatsapp-link,
.cart-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #111a33;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.cart-count {
  display: inline-grid;
  place-items: center;
  position: absolute;
  top: -8px;
  right: -10px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #2d5bdb;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* 加購入購物車時，藍點數字跳一下 */
.cart-count.bump {
  animation: cart-badge-bump 0.45s ease;
}

@keyframes cart-badge-bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.55); }
  100% { transform: scale(1); }
}

/* 商品縮圖飛向購物車圖示嘅動畫元素 */
.cart-fly {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(8, 16, 44, 0.32);
  pointer-events: none;
  transition: transform 0.8s cubic-bezier(0.4, 0.05, 0.35, 0.95), opacity 0.8s ease;
}

@media (max-width: 900px) {
  .navber-inner {
    width: calc(100% - 20px);
    height: auto;
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px 0 16px;
  }

  .main-nav {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 22px;
    flex-wrap: wrap;
  }

  .main-nav > a.is-active::after,
  .nav-products.is-active::after {
    bottom: -8px;
  }

  .product-dropdown {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(-6px);
  }

  .dropdown-panel::before {
    left: auto;
    right: 22px;
    transform: rotate(45deg);
  }

  .nav-item-products:hover .product-dropdown,
  .nav-item-products:focus-within .product-dropdown,
  .nav-item-products.open .product-dropdown {
    transform: translateX(0) translateY(0);
  }

  .nav-actions {
    gap: 12px;
  }
}
