#navbar,
#navbar *:not(i) {
  box-sizing: border-box !important;
  font-family: "Microsoft JhengHei", Arial, sans-serif !important;
}

#navbar i {
  box-sizing: border-box !important;
}

.nav-links a {
  transition:
    color 0.3s ease,
    text-shadow 0.3s ease;
}

.nav-links a:hover {
  color: #b595cd !important;
  text-shadow: 0 0 0.3px #b595cd !important;
}

.nav-links a.active {
  color: #4a3b6c !important;
  text-shadow: 0 0 0.8px #4a3b6c !important;
}

.nav-links a i,
.nav-links a.active i {
  font-weight: 900 !important;
  text-shadow: none !important;
}

.dropdown {
  position: relative;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #ffffff;
  min-width: 180px;
  box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.1);
  z-index: 1001;
  border-radius: 8px;
  /* overflow: hidden;  <--- 【重要】這行必須刪除或註解掉，否則側邊選單會被裁切不見 */
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 15px;
  border: 1px solid #f0ebf5;
}

.dropdown::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 15px;
}

@media (min-width: 769px) {
  .dropdown:hover .dropdown-content {
    display: block;
    animation: dropdownFadeIn 0.2s ease;
  }
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.dropdown-content a {
  color: #333;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  font-size: 0.95rem;
  text-align: center;
  border-bottom: 1px solid #f0ebf5;
  transition: all 0.2s ease;
}

/* 為了彌補拿掉 overflow: hidden，我們把圓角加在第一個與最後一個 a 標籤上 */
.dropdown-content a:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.dropdown-content a:last-child {
  border-bottom: none;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.dropdown-content a:hover {
  background-color: #f8f1fd;
  color: #4a3b6c !important;
  text-shadow: 0 0 0.5px #4a3b6c;
}

/* =========================================
   新增：子選單 (多層次下拉) 樣式
========================================= */
.sub-dropdown {
  position: relative;
}

.sub-dropdown-content {
  display: none;
  position: absolute;
  left: 100%; /* 設定往右側展開 */
  top: -1px; /* 稍微對齊父選單高度 */
  background-color: #ffffff;
  min-width: 140px;
  box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.1);
  z-index: 1002;
  border-radius: 8px;
  border: 1px solid #f0ebf5;
}

/* 電腦版滑鼠懸停時顯示子選單 */
@media (min-width: 769px) {
  .sub-dropdown:hover .sub-dropdown-content {
    display: block;
    animation: fadeInSub 0.2s ease; /* 改用專屬的 fadeInSub 動畫 */
  }
}

/* 子選單專用的漸顯動畫，不帶有 -50% 的置中偏移，避免跳動 */
@keyframes fadeInSub {
  from {
    opacity: 0;
    transform: translateX(-10px); /* 稍微從左邊滑入，視覺更滑順 */
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========================================= */

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  margin-right: 15px;
}

.menu-toggle .bar {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px auto;
  background-color: #333;
  transition: all 0.3s ease-in-out;
  border-radius: 3px;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .nav-links {
    display: none !important;
    flex-direction: column;
    width: 100%;
    position: absolute;
    top: 70px;
    left: 0;
    background-color: #ffffff;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
  }

  .nav-links.active {
    display: flex !important;
  }

  .nav-links li {
    margin: 0 !important;
    width: 100%;
  }

  .nav-links > li > a {
    display: block;
    padding: 15px 0;
    border-bottom: 1px solid #f0ebf5;
  }

  .dropdown-content {
    position: static;
    box-shadow: none;
    background-color: #fafafa;
    transform: none;
    margin-top: 0;
    border: none;
    border-radius: 0;
    display: none;
  }

  .dropdown.active .dropdown-content {
    display: block;
  }

  .dropdown-content a {
    padding: 12px 0;
    font-size: 0.9rem;
    color: #66528c;
    border-bottom: 1px solid #eaeaea;
  }

  .logo a span {
    font-size: 1.2rem !important;
  }

  /* 手機版子選單：不往側邊推，改往下方展開 */
  .sub-dropdown-content {
    position: static;
    box-shadow: none;
    background-color: #f0ebf5; /* 讓背景再深一點，做出層次感 */
    border: none;
    border-radius: 0;
    display: none;
  }

  .sub-dropdown:hover .sub-dropdown-content {
    display: block;
  }
}
