/* 布局样式 - Header, Footer, Main structure */

header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.header-top {
  height: 40px;
  background-color: var(--color-primary);
  color: #ffffff;
  font-size: 14px;
  display: flex;
  align-items: center;
}

.header-top .container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
}

.header-top-inner {
  position: relative;
}

.header-top-title {
  display: block;
  text-align: center;
  width: 100%;
  flex: 1;
}

.header-top-lang {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.header-main {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap; /* 強制不換行 */
}

/* Header Responsive */
@media (max-width: 1200px) {
  nav ul {
    gap: 15px; /* 縮小導航間距以騰出空間 */
  }
}

@media (max-width: 992px) {
  .header-main {
    height: auto;
    padding: 15px 20px;
    flex-wrap: wrap; /* 平板及手機端允許換行 */
    gap: 15px;
  }
  
}

@media (max-width: 576px) {
  .header-actions {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  
  .search-bar {
    width: 100%;
  }
  
  .search-bar input {
    width: 100% !important;
  }
  
  .header-top .container {
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .header-top #lang-switcher {
    margin-left: auto;
  }
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  flex-shrink: 0; /* 防止 Logo 被壓縮 */
}

.logo img {
  height: 45px;
  margin-right: 12px;
}

nav {
  margin: 0 20px;
  flex: 1; /* 讓導航占據剩餘空間 */
  display: flex;
  justify-content: center; /* 導航居中 */
  min-width: 0; /* 允許 nav 內部的 ul 收縮 */
}

nav ul {
  display: flex;
  gap: 30px;
  flex-wrap: nowrap;
}

nav ul li a {
  font-weight: 500;
  color: var(--color-text-main);
  white-space: nowrap; /* 文字不換行 */
}

nav ul li a:hover,
nav ul li a.active {
  color: var(--color-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0; /* 防止操作區被壓縮 */
}


.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar input {
  padding: 8px 15px;
  padding-right: 35px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  width: 180px; /* 默認寬度稍作縮小 */
  transition: var(--transition-base);
}

.search-bar input:focus {
  width: 220px; /* 縮小聚焦時的擴展寬度，避免擠壓 */
  border-color: var(--color-primary);
}

.search-bar .icon {
  position: absolute;
  right: 12px;
  color: var(--color-text-helper);
}

/* Footer */
footer {
  background-color: #ffffff;
  border-top: 1px solid var(--color-border);
  padding: 60px 0 30px;
  margin-top: 80px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr;
  gap: 40px;
  margin-bottom: 40px;
}

@media (max-width: 992px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 576px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}

.footer-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--color-primary);
}

.footer-links li {
  margin-bottom: 12px;
}

.footer-links a:hover {
  color: var(--color-primary);
}

.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding-top: 30px;
  text-align: center;
  color: var(--color-text-helper);
  font-size: 14px;
}

/* 移動端漢堡菜單按鈕 */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  gap: 5px;
  z-index: 1001;
}

.hamburger-line {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--color-primary);
  transition: all 0.3s ease;
  border-radius: 2px;
}

/* 移動端抽屜菜單 */
.mobile-drawer {
  position: fixed;
  top: 0;
  right: -280px;
  width: 280px;
  height: 100vh;
  background: #ffffff;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1002;
  transition: right 0.3s ease;
}

.mobile-drawer.active {
  right: 0;
}

.mobile-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  background: var(--color-primary);
  color: #ffffff;
}

.mobile-drawer-title {
  font-size: 18px;
  font-weight: 600;
}

.mobile-drawer-close {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  width: 32px;
  height: 32px;
}

.mobile-drawer-nav {
  height: calc(100vh - 140px);
  overflow-y: auto;
  background: #ffffff;
}

.mobile-drawer-nav ul,
.mobile-menu-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
}

.mobile-drawer-nav li,
.mobile-menu-item {
  border-bottom: 1px solid #e0e0e0 !important;
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

.mobile-drawer-nav ul {
  list-style: none;
}

.mobile-drawer-nav li {
  border-bottom: 1px solid #e0e0e0;
}

.mobile-drawer-nav a,
.mobile-menu-item a {
  display: block !important;
  padding: 16px 20px !important;
  color: #333 !important;
  font-size: 16px !important;
  text-decoration: none !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.mobile-drawer-nav a:hover {
  background: #f5f5f5;
}

.mobile-drawer-nav i {
  margin-right: 12px;
  color: var(--color-secondary);
}

.mobile-drawer-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
}

.mobile-drawer-actions .btn-block {
  width: 100%;
  text-align: center;
  justify-content: center;
}

/* 遮罩層 */
.mobile-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 移動端響應式樣式 */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
  
  .main-nav {
    display: none;
  }
  
  .header-actions {
    display: none;
  }
  
  .header-main {
    position: relative;
  }
  
  .logo {
    flex: 1;
  }
  
  .logo span {
    font-size: 16px !important;
  }
  
  .logo span:last-child {
    font-size: 8px !important;
  }
}

@media (max-width: 576px) {
  .mobile-drawer {
    width: 260px;
    right: -260px;
  }
  
  .header-top-title {
    font-size: 12px;
  }
}

