/* ── Base ── */
#navbar,
#navbar *:not(i) {
  box-sizing: border-box !important;
  font-family: "Microsoft JhengHei", Arial, sans-serif !important;
}
#navbar i { box-sizing: border-box !important; }

#navbar {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 68px;
  background: #ffffff;
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, #4a3b6c, #b595cd, #7ec8e3) 1;
  box-shadow: 0 2px 16px rgba(74,59,108,0.08);
  z-index: 1000;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1140px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Brand ── */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  height: 50px;
  display: block;
}

/* ── Nav links ── */
.nav-links {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 4px;
}

.nav-link {
  display: inline-block;
  padding: 6px 14px;
  text-decoration: none;
  color: #444;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: 6px;
  position: relative;
  transition: color 0.2s;
  white-space: nowrap;
}

/* animated underline */
.nav-link::after {
  content: "";
  position: absolute;
  bottom: 0; left: 14px;
  width: calc(100% - 28px);
  height: 2px;
  background: linear-gradient(90deg, #4a3b6c, #b595cd);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.nav-link:hover {
  color: #4a3b6c !important;
}

.nav-link:hover::after {
  transform: scaleX(1);
}

.nav-link.active {
  color: #4a3b6c !important;
  font-weight: 600;
}

.nav-link.active::after {
  transform: scaleX(1);
}

/* chevron icon */
.nav-chevron {
  font-size: 0.72em;
  margin-left: 5px;
  color: #aaa;
  transition: transform 0.2s;
}

.dropdown:hover .nav-chevron {
  transform: rotate(180deg);
  color: #4a3b6c;
}

/* ── Dropdown ── */
.dropdown {
  position: relative;
}

.dropdown::after {
  content: "";
  position: absolute;
  top: 100%; left: 0;
  width: 100%; height: 16px;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  min-width: 180px;
  border-radius: 10px;
  border: 1px solid #ede8f5;
  box-shadow: 0 8px 28px rgba(74,59,108,0.13);
  z-index: 1001;
}

/* tiny arrow */
.dropdown-content::before {
  content: "";
  position: absolute;
  top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 12px; height: 12px;
  background: #fff;
  border-left: 1px solid #ede8f5;
  border-top: 1px solid #ede8f5;
  transform: translateX(-50%) rotate(45deg);
}

@media (min-width: 769px) {
  .dropdown:hover .dropdown-content {
    display: block;
    animation: dropFadeIn 0.18s ease;
  }
}

@keyframes dropFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.dropdown-content a {
  display: block;
  padding: 11px 18px;
  color: #444;
  font-size: 0.93rem;
  text-decoration: none;
  text-align: center;
  border-bottom: 1px solid #f3eefb;
  transition: background 0.15s, color 0.15s;
}

.dropdown-content a:last-child { border-bottom: none; }

.dropdown-content a:hover {
  background: #f7f2fd;
  color: #4a3b6c !important;
}

/* ── Sub-dropdown ── */
.sub-dropdown { position: relative; }

.sub-dropbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}

.sub-chevron {
  font-size: 0.72em;
  color: #aaa;
  position: absolute;
  right: 18px;
}

.sub-dropdown-content {
  display: none;
  position: absolute;
  left: 100%; top: -1px;
  background: #ffffff;
  min-width: 130px;
  border-radius: 10px;
  border: 1px solid #ede8f5;
  box-shadow: 0 8px 28px rgba(74,59,108,0.13);
  overflow: hidden;
  z-index: 1002;
}

@media (min-width: 769px) {
  .sub-dropdown:hover .sub-dropdown-content {
    display: block;
    animation: subFadeIn 0.18s ease;
  }
}

@keyframes subFadeIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Mobile toggle ── */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}

.menu-toggle .bar {
  display: block;
  width: 24px; height: 2px;
  margin: 5px 0;
  background: #4a3b6c;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* ── Mobile layout ── */
@media (max-width: 768px) {
  .menu-toggle { display: block; }

  .nav-links {
    display: none !important;
    flex-direction: column;
    align-items: stretch;
    position: absolute;
    top: 68px; left: 0;
    width: 100%;
    background: #fff;
    border-top: 1px solid #ede8f5;
    box-shadow: 0 8px 20px rgba(74,59,108,0.1);
    gap: 0;
    max-height: calc(100vh - 68px);
    overflow-y: auto;
  }

  .nav-links.active { display: flex !important; }

  .nav-links li { width: 100%; }

  .nav-link {
    display: block;
    padding: 14px 24px;
    border-bottom: 1px solid #f3eefb;
    border-radius: 0;
  }

  .nav-link::after { display: none; }

  .dropdown-content {
    position: static;
    transform: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: #faf7ff;
    display: none;
    overflow: visible;
  }

  .dropdown-content::before { display: none; }

  .dropdown.active .dropdown-content { display: block; }

  .dropdown-content a {
    padding: 12px 36px;
    text-align: left;
    color: #66528c;
    border-bottom: 1px solid #ede8f5;
  }

  .sub-dropdown-content {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: #f0ebf9;
    display: none;
    overflow: visible;
  }

  .sub-dropdown.active .sub-dropdown-content { display: block; }

  .sub-dropdown-content a {
    padding: 11px 48px;
    text-align: left;
  }
}
