/* === Navbar 基礎樣式 === */
#navbar {
  position: fixed;
  top: 0;
  width: 100%;
  height: 65px;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  justify-content: center;
  transition: background-color 0.3s ease;
}

#navbar.scrolled {
  background-color: white;
}

/* === 內容區域配置 === */
.nav-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-left, .nav-middle, .nav-right {
  flex: 1;
  display: flex;
  align-items: center;
}

.nav-left {
  height: auto;
  justify-content: center;
}

.logo img {
  height: auto;
  transition: filter 0.3s ease;
}

.nav-right {
  justify-content: flex-start;
}

/* === 主選單 === */
.nav-right ul {
  display: flex;
  gap: 30px;
  list-style: none;
  padding: 0;
  margin: 0;
  align-items: center;
}

.nav-right ul li {
  position: relative;
}

.nav-right ul li a {
  color: white;
  text-decoration: none;
  font-weight: bold;
  font-size: 16px;
  white-space: nowrap;
  transition: color 0.3s ease;
}

#navbar.scrolled .nav-right ul li a {
  color: #333;
}

.nav-right ul li a:hover {
  color: #90caf9;
}

#navbar.scrolled .nav-right ul li a:hover {
  color: #007BFF;
}

/* === 箭頭動畫 === */
.dropdown-arrow {
  margin-left: 6px;
  transition: transform 0.3s ease;
}

.nav-right ul li:hover > a .dropdown-arrow {
  transform: rotate(180deg);
}

/* === 子選單樣式（預設）=== */
.nav-right ul li ul {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  top: calc(100% + 16px);
  left: 50%;
  transform: translate(-50%, -10px);
  background: rgba(0, 0, 0, 0.8);
  border-radius: 0 0 10px 10px;
  min-width: 140px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  padding: 4px 0;
  transition: all 0.25s ease;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.nav-right ul li:hover ul {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.nav-right ul li ul li a {
  color: #ffffff;
  display: block;
  padding: 6px 20px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.nav-right ul li ul li a:hover {
  background: rgba(255, 255, 255, 0.08);
  padding-left: 28px;
  color: #90caf9;
}

/* === 子選單樣式（滾動白色背景）=== */
#navbar.scrolled .nav-right ul li ul {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

#navbar.scrolled .nav-right ul li ul li a {
  color: #333;
}

#navbar.scrolled .nav-right ul li ul li a:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #007BFF;
}
/* 預設隱藏漢堡按鈕 */
.menu-toggle {
  display: none;
  font-size: 24px;
  cursor: pointer;
  color: white;
}


/* === Navbar RWD 響應式樣式 === */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 24px;
    color: white;
    cursor: pointer;
  }

  .nav-right {
    display: none;
    position: absolute;
    top: 65px;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.95);
    flex-direction: column;
    z-index: 999;
  }
  .nav-right ul{
    gap: 0;
  }
  .nav-right.active {
    display: flex;
  }

  .nav-right ul.nav-menu {
    flex-direction: column;
    padding: 10px 0;
    width: 100%;
  }
  #navbar.scrolled .nav-right ul li ul {
    background: transparent !important;
    box-shadow: none !important;
  }
  .nav-right ul.nav-menu > li {
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .nav-right ul.nav-menu > li > a {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 14px 20px;
    font-size: 18px;
    color: white;
    font-size: 26px;            /* 主選單字體放大 */
  }

  /* 子選單樣式 */
  .nav-right ul.nav-menu li ul {
    gap: 0;
    display: none;
    flex-direction: column;
    background-color: rgba(255, 255, 255, 0.05);
    padding: 0;
    position: static;          /* ⭐ 讓子選單佔據空間 */
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
  }

  .nav-right ul.nav-menu li.open ul {
    display: flex;
    margin-top: -4px; 
    background: transparent;
  }

  .nav-right ul.nav-menu li ul li a {
    padding: 12px 28px;
    font-size: 24px;
    color: #ccc;
    background: transparent;
  }

  .nav-right ul.nav-menu li ul li a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #90caf9;
  }

  .dropdown-arrow {
    margin-left: 8px;
    transition: transform 0.3s ease;
  }

  .has-submenu.open .dropdown-arrow {
    transform: rotate(180deg);
  }
/* === 滾動時背景變白 & 文字變黑 === */
#navbar.scrolled {
  background-color: white;
}

#navbar.scrolled .menu-toggle {
  color: #000;
}

#navbar.scrolled .nav-right {
  background-color: rgba(255, 255, 255, 0.95);
}

#navbar.scrolled .nav-right ul.nav-menu > li > a {
  color: #000;
}

#navbar.scrolled .nav-right ul.nav-menu li ul li a {
  color: #333;
}

#navbar.scrolled .dropdown-arrow {
  color: #000;
}

#navbar.scrolled .nav-right ul.nav-menu li ul li a:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #007BFF;
}

}
