/* =========================================================
   頂部導覽列 (Navbar & Main-A)
   ========================================================= */
.Main-A {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 64px;
  padding: 0 24px;
  background-color: #1e293b;
  border-bottom: 3px solid #b5a67c;
  position: relative;
  z-index: 100000;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: #ffffff;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  object-fit: cover;
}

.nav-title {
  color: #ffffff;
  font-size: 18px;
  font-weight: bold;
  white-space: nowrap;
}

.nav-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  margin-left: 40px;
}

.nav-list {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-active-pill {
  position: absolute;
  top: 0;
  left: 0;
  height: 0;
  width: 0;
  background-color: #ffffff;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  z-index: 1;
  transition:
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s ease;
  opacity: 0;
}

.nav-list .nav-item > a {
  position: relative;
  z-index: 2;
  display: inline-block;
  padding: 8px 16px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.3s ease;
}

.nav-list .nav-item > a.is-pill-active {
  color: #0f172a !important;
}

.nav-item.has-dropdown {
  position: relative;
}

/* 桌面版 Hover 展開下拉選單 */
@media (min-width: 1205px) {
  .nav-item.has-dropdown:hover .dropdown-menu {
    display: flex;
    flex-direction: column;
  }
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #1e293b;
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.2);
  padding: 8px 0;
  border-radius: 8px;
  min-width: 160px;
  z-index: 100;
  list-style: none;
}

.dropdown-menu li a {
  display: block;
  padding: 10px 16px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.dropdown-menu li a:hover {
  background-color: #334155;
  color: #ffffff;
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: #ffffff;
  font-size: 28px;
  cursor: pointer;
  padding: 4px 8px;
}

/* =========================================================
   📱 RWD 手機與平板響應式選單 
   ========================================================= */
@media (max-width: 1204px) {
  .nav-active-pill {
    display: none !important;
  }

  .hamburger-btn {
    display: block !important;
    position: relative;
    z-index: 100001;
  }

  .hamburger-btn i {
    pointer-events: none;
  }

  .nav-wrapper {
    margin-left: 0;
  }

  /* 💡 右側暗色半透明遮罩 */
  .nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.3s ease,
      visibility 0.3s ease;
    z-index: 99998;
  }

  .nav-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  /* 💡 左側滑出抽屜式選單面板 */
  .nav-list {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 280px !important;
    max-width: 80vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 80px 16px 32px 16px !important;
    background-color: #1e293b !important;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.5);
    z-index: 100000 !important;
    text-align: left !important;
    gap: 6px !important;
    overflow-y: auto !important;

    /* 💡【新增這兩行】：阻止 Safari 頂部回彈與滑動傳遞  */
    touch-action: pan-y !important;
    overscroll-behavior-y: contain !important;
    -webkit-overflow-scrolling: touch !important;

    /* 平滑預設隱藏至左側 */
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  .nav-list.active {
    transform: translateX(0) !important;
  }

  .nav-list .nav-item {
    width: 100%;
  }

  /* 💡 修正 1：保留左右 16px Padding，讓主選單文字不貼邊 */
  .nav-list .nav-item > a {
    display: block;
    padding: 12px 16px !important;
    width: 100%;
    box-sizing: border-box;
  }

  /* 💡 核心修復：子選單預設隱藏，展開時隨文件流向下推開其他選項 */
  .dropdown-menu {
    display: none; /* 預設隱藏 */
    position: static !important; /* 關鍵：隨文件流順向排列，不懸浮 */
    box-shadow: none !important;
    background-color: #0f172a !important;
    width: 100% !important;
    padding: 6px 0 6px 12px !important; /* 💡 修正 2：保留左側 12px 內縮層級感 */
    margin-top: 6px !important;
    border-radius: 6px !important;
    box-sizing: border-box;
  }

  /* 觸發 Hover 或 Focus 時才展開子選單 */
  .nav-item.has-dropdown.is-open .dropdown-menu {
    display: flex !important;
    flex-direction: column !important;
  }

  .dropdown-menu li a {
    padding: 10px 16px !important;
    font-size: 14px !important;
    color: #94a3b8 !important;
    text-align: left;
  }

  /* 💡 選單開啟時，鎖定背景主頁面的滾動，避免與選單觸控衝突 */
  body.nav-open {
    overflow: hidden !important;
  }
}
