

/* 主選單容器 */
.navbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  /*padding: 10px 20px;
  height: 64px;
  background: #fff;*/
  background: var(--navbar-bg);
  height: var(--navbar-h);
  padding: var(--navbar-pad);

  color: #333;
  border-bottom: 1px solid #ccc;

  /* ✅ 新增固定設定 
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
*/
  margin-top: -2px;
}

body {
  margin: 0;
  padding: 0;
}
#navMenu.sticky {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: var(--navbar-bg);
  height: var(--navbar-h);
  padding: var(--navbar-pad);  
}

/* 漢堡選單 */
.hamburger {
  margin-left: auto;
  /* ✅ 漢堡推到最右邊 */
  font-size: 28px;
  cursor: pointer;
  color: #333;
  display: none;
}

/* 主選單 */
/* 主選單列表 */
#navMenu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0px;
  flex-grow: 1;
  flex-wrap: wrap;
}

/* 導航右側區塊 */
.navbar-right {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-left: auto;
}

/* 購物車樣式 */
.navbar-cart {
  position: relative;
}

.cart-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  transition: all 0.3s ease;
  text-decoration: none;
  color: var(--navbar-fc);
}

.cart-link:hover {
  background: rgba(255, 102, 0, 0.1);
  color: #ff6600;
}

.cart-icon {
  width: 24px;
  height: 24px;
  filter: brightness(0) saturate(100%);
  transition: filter 0.3s ease;
}

.cart-link:hover .cart-icon {
  filter: brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(1352%) hue-rotate(13deg) brightness(102%) contrast(107%);
}

/* 購物車數量徽章 */
.cart-count {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ff4444;
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
  animation: cartBounce 0.3s ease;
}

@keyframes cartBounce {
  0% {
    transform: scale(0.8);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* 社群區塊 */
.navbar-social {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-social a img {
  width: 24px;
  height: 24px;
  opacity: 0.8;
  transition: opacity 0.3s, filter 0.3s;
  filter: grayscale(70%);
}

.navbar-social a:hover img {
  opacity: 1;
  filter: none;
}

/* 品牌 hover 效果 */
.navbar-social a[href*="facebook"]:hover img {
  filter: brightness(1) saturate(1.5) drop-shadow(0 0 3px #3b5998);
}

.navbar-social a[href*="lin"]:hover img {
  filter: brightness(1) saturate(1.5) drop-shadow(0 0 3px #06C755);
}

.navbar-social a[href*="youtube"]:hover img {
  filter: brightness(1) saturate(1.5) drop-shadow(0 0 3px #FF0000);
}

/* 項目外框 */
.navbar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 20px;
  align-items: center;
}

/* 單一選項 */
.navbar li {
  position: relative;
  padding-bottom: 10px;
}

/* 項目連結 */
.navbar a {
  color: var(--navbar-fc);
  /* 主選單連結顏色 */
  text-decoration: none;
  padding: 10px 10px;
  display: block;
  transition: color 0.2s ease;
  font-size: var(--navbar-fs);
  /* ← 新增這行，調整主選單文字大小 NAVBAR_FONTSIZE*/
}

/* 滑入效果 */
.navbar a:hover,
.navbar .active {
  color: #ff6600;
}

/* 子選單樣式 */
.navbar li ul {
  display: none;
  position: absolute;
  top: 100%;
  /* 子選單對齊主選單下緣 */
  margin-top: 0px;
  /* 可再靠近些 */
  left: 0;


  min-width: 160px;
  flex-direction: column;
  background: #f9f9f9;
  /* 子選單偏淺灰底 */
  border-top: 4px solid #ff9800;
  /* 醒目的粗上邊框 */
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: opacity 0.3s ease;
  z-index: 1050;
  gap: 0;
  /* ✅ 移除 Flex 預設間距 */

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

.navbar li ul li {
  margin: 3px;
  /* ✅ 移除 li 預設間隔 */
  padding: 3px;
}

.navbar li ul a {
  color: #333;
  white-space: nowrap;
  padding: 8px 16px;
  /* ✅ 調整內距更緊湊 */
  line-height: 1.4;
  /* ✅ 壓縮高度 */

  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.navbar li ul a:hover {
  background: #eee;
  color: #ff6600;
}

.navbar li:hover>ul {
  display: flex;
  animation: fadeIn 0.3s ease;
  opacity: 1;
  pointer-events: auto;
}

/* 給有子選單的主選單加上箭頭 */
.navbar li.has-submenu>a::after {
  content: " ▾";
  /* 你也可以用 " ▼"、" ⯆"、SVG */
  font-size: 0.75em;
  margin-left: 6px;
  color: #ccc;
  transition: transform 0.3s ease;
}

/* hover 時旋轉圖示（可選） */
.navbar li.has-submenu:hover>a::after {
  transform: rotate(180deg);
}

.navbar li:has(ul)>a::after {
  content: " ▾";
  font-size: 0.75em;
  margin-left: 6px;
  color: #ffa500;
  transition: transform 0.3s;
}

/* 當滑入展開時旋轉箭頭 */
.navbar li:hover>a::after {
  transform: rotate(180deg);
}

.navbar-product-overview {
  display: none !important;
  font-weight: bold;
  background: #1976d2;
  color: #fff;
  border-radius: 10px;
  padding: 2px 9px;
  margin: 2px 0 2px 2px;
  text-align: center;
  text-decoration: none;
  font-size: 0.8em;
}

/* 手機版按鈕區塊 */
.navbar-mobile-controls {
  display: none;
  gap: 8px;
  align-items: center;
}

.navbar-mobile-controls a {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: bold;
  border-radius: 8px;
  padding: 6px 10px;
  text-decoration: none;
  font-size: 0.8em;
  transition: all 0.3s ease;
  min-width: 60px;
  justify-content: center;
}

.navbar-product-overview {
  background: #1976d2;
  color: #fff;
}

.navbar-product-overview:hover {
  background: #1565c0;
  transform: translateY(-1px);
}

.navbar-logout-btn {
  background: #f44336;
  color: #fff;
}

.navbar-logout-btn:hover {
  background: #d32f2f;
  transform: translateY(-1px);
}

.navbar-login-btn {
  background: #4caf50;
  color: #fff;
}

.navbar-login-btn:hover {
  background: #388e3c;
  transform: translateY(-1px);
}

/* 圖標樣式 */
.icon-grid::before { 
  content: "⊞"; 
  font-size: 1.1em;
  margin-right: 2px;
}

.icon-logout::before { 
  content: "⏻"; 
  font-size: 1em;
  margin-right: 2px;
}

.icon-login::before { 
  content: "�"; 
  font-size: 0.9em;
  margin-right: 2px;
}

/* 子選單動畫 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 小螢幕 RWD */

@media screen and (max-width: 768px) {
  .navbar-mobile-controls {
    display: flex !important; 
  }
  
  .navbar-product-overview {
    display: flex !important; 
  }
  
  body {
    padding-top: 54px;
  }

  .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: #fff;
    padding: 3px 5px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-top: 0px;
    flex-wrap: wrap; /* 允許換行 */
  }

  .navbar-logo img {
    height: 45px;
  }

  .hamburger {
    display: block;
    font-size: 24px;
    margin-left: auto;
    color: #333;
    background: none;
    border: none;
    order: 999; /* 確保漢堡選單在最右邊 */
    z-index: 1001; /* 確保漢堡選單在選單上方 */
    position: relative;
  }

  .navbar-right {
    display: none; /* 手機版完全隱藏 */
  }

  /* 手機版隱藏桌機版購物車 */
  .navbar-cart {
    display: none;
  }

  #navMenu {
    display: none;
    flex-direction: column;
    width: 100%;
    background: #fff;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  }

  #navMenu.show {
    display: flex;
  }

  #navMenu>li>a {
    position: relative;
    font-weight: bold;
    padding: 16px 40px 16px 16px;
    /* 預留右側空間 */
    font-size: 1.05em;
    color: #222;
    border-bottom: 1px solid #eee;
    background: #fff;
  }

  #navMenu>li.has-submenu>a::after {
    content: "▶";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1em;
    color: #222;
  }

  #navMenu>li.expanded>a::after {
    content: "▼";
  }

  #navMenu li ul {
    max-height: 0;
    overflow: hidden;
    flex-direction: column;
    background: #fff;
    transition: max-height 0.3s ease;
  }

  #navMenu li.expanded>ul {
    max-height: 500px;
  }

  #navMenu li ul li a {
    font-size: 0.95em;
    color: #666;
    padding: 14px 24px;
    border-bottom: 1px solid #eee;
    background: #fff;
  }
}