/* Common CSS for header, footer, navigation, base variables, and layout helpers */
/* 分层原则：仅放通用组件与变量、断点，不放具体页面样式 */

:root {
  /* 仅示例：可逐步迁移到此 */
  /* 自定义断点变量，供各页面CSS引用 */
  --bp-desktop: 1025px;
  --bp-tablet: 1024px;
  --bp-mobile: 768px;
}

/* 头部与底部基础布局保持页面底部不被挤压 */
.site-header,
.site-footer {
  flex-shrink: 0;
}

/* HEADER & NAVIGATION - 头部导航 */
.site-header {
  background: var(--color-bg-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 2000;
  backdrop-filter: blur(10px);
  background-color: rgba(0, 0, 0, 0.95);
  transition: all var(--transition-base);
}

.main-navigation { padding: 1.2rem 0; }
.main-navigation .container { display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-lg); }

/* Logo/品牌 */
.site-branding { flex-shrink: 0; }
.site-title { font-family: var(--font-heading); font-size: var(--font-2xl); font-weight: 900; letter-spacing: -0.5px; margin: 0; }
.site-title a { color: white; transition: opacity var(--transition-base); }
.site-title a:hover { opacity: 0.8; }

/* 主菜单 */
.primary-menu { display: flex; align-items: center; gap: var(--spacing-lg); flex: 1; justify-content: center; }
.primary-menu li { position: relative; }
.primary-menu > li > a { font-size: var(--font-sm); font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: white; padding: 0.5rem 0; position: relative; display: inline-block; }
.primary-menu > li > a::after { content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 2px; background: white; transition: width var(--transition-base); }
.primary-menu > li > a:hover::after, .primary-menu > li.current-menu-item > a::after { width: 100%; }

/* 下拉菜单 */
.primary-menu .sub-menu { position: absolute; top: 100%; left: 0; background: var(--color-bg); min-width: 220px; box-shadow: var(--shadow-lg); border-radius: var(--radius-md); padding: var(--spacing-sm); opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all var(--transition-base); margin-top: 1rem; }
.primary-menu li:hover .sub-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.primary-menu .sub-menu li a { display: block; padding: 0.75rem 1rem; color: var(--color-text); border-radius: var(--radius-sm); transition: all var(--transition-fast); }
.primary-menu .sub-menu li a:hover { background: var(--color-bg-light); color: var(--color-primary); transform: translateX(5px); }

/* 头部右侧功能区 */
.header-right { display: flex; align-items: center; gap: var(--spacing-md); flex-shrink: 1; min-width: 0; }

/* 搜索框 */
.header-search { position: relative; }
.search-form { display: flex; align-items: center; background: rgba(255, 255, 255, 0.1); border-radius: var(--radius-full); padding: 0.5rem 1rem; transition: all var(--transition-base); border: 2px solid transparent; }
.search-form:focus-within { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.3); box-shadow: var(--shadow-md); }
.search-field { border: none; background: transparent; outline: none; width: 200px; font-size: var(--font-sm); color: white; transition: width var(--transition-base); }
.search-field::placeholder { color: rgba(255, 255, 255, 0.6); }
.search-form:focus-within .search-field { width: 250px; }
.search-submit { background: transparent; border: none; color: rgba(255, 255, 255, 0.7); cursor: pointer; padding: 0; margin-left: 0.5rem; transition: color var(--transition-fast); }
.search-submit:hover { color: white; }

/* 购物车 */
.header-cart { position: relative; }
.cart-contents { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: var(--radius-full); background: rgba(255, 255, 255, 0.1); color: white; transition: all var(--transition-base); font-size: var(--font-sm); font-weight: 600; }
.cart-contents:hover { background: white; color: var(--color-primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.cart-icon-wrapper { position: relative; display: flex; align-items: center; }
.cart-count-badge { position: absolute; top: -8px; right: -8px; background: var(--color-accent); color: white; font-size: var(--font-xs); min-width: 18px; height: 18px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; font-weight: 700; padding: 0 4px; box-shadow: var(--shadow-sm); }

/* 登录按钮 */
.login-button { padding: 0.6rem 1.5rem; background: white; color: var(--color-primary); border-radius: var(--radius-full); font-size: var(--font-sm); font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; transition: all var(--transition-base); }
.login-button:hover { background: rgba(255, 255, 255, 0.9); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* 用户菜单 */
.user-menu { position: relative; }
.user-menu-toggle { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; background: rgba(255, 255, 255, 0.1); color: white; border-radius: var(--radius-full); font-size: var(--font-sm); transition: all var(--transition-base); }
.user-menu-toggle:hover { background: white; color: var(--color-primary); }
.user-dropdown { position: absolute; top: calc(100% + 0.5rem); right: 0; background: var(--color-bg); min-width: 200px; box-shadow: var(--shadow-xl); border-radius: var(--radius-md); padding: var(--spacing-sm); opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all var(--transition-base); }
.user-menu:hover .user-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; color: var(--color-text); border-radius: var(--radius-sm); transition: all var(--transition-fast); }
.dropdown-item:hover { background: var(--color-bg-light); transform: translateX(5px); }

/* 汉堡菜单按钮 */
.mobile-menu-toggle { display: none; flex-direction: column; justify-content: space-around; width: 36px; height: 36px; background: transparent; border: none; cursor: pointer; padding: 6px; z-index: 1002; transition: all var(--transition-base); }
.hamburger-line { width: 100%; height: 3px; background: white; border-radius: 2px; transition: all var(--transition-base); }
.mobile-menu-toggle.active .hamburger-line:nth-child(1) { transform: rotate(45deg) translateY(10px); }
.mobile-menu-toggle.active .hamburger-line:nth-child(2) { opacity: 0; }
.mobile-menu-toggle.active .hamburger-line:nth-child(3) { transform: rotate(-45deg) translateY(-10px); }

/* 防止菜单打开时页面滚动 */
body.menu-open { overflow: hidden; }

/* FOOTER - 页脚 */
.site-footer { background: var(--color-bg-dark) !important; color: rgba(255, 255, 255, 0.8); padding: var(--spacing-3xl) var(--spacing-xl) var(--spacing-xl) !important; flex-shrink: 0 !important; position: relative; z-index: 10; margin: 0 !important; width: 100% !important; max-width: none !important; }
.site-footer .container { max-width: none !important; padding: 0 !important; margin: 0 !important; width: 100% !important; }
.footer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--spacing-xl); padding-bottom: var(--spacing-xl); border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.footer-col { display: flex; flex-direction: column; gap: var(--spacing-md); }
.footer-title { font-family: var(--font-heading); font-size: var(--font-lg); font-weight: 700; color: white; margin-bottom: var(--spacing-sm); letter-spacing: 0.5px; text-transform: uppercase; }
.footer-description { line-height: 1.8; color: rgba(255, 255, 255, 0.7); }
.footer-links { display: flex; flex-direction: column; gap: var(--spacing-sm); }
.footer-links a { color: rgba(255, 255, 255, 0.7); font-size: var(--font-sm); transition: all var(--transition-fast); display: inline-block; }
.footer-links a:hover { color: white; transform: translateX(5px); }
.footer-contact { display: flex; flex-direction: column; gap: var(--spacing-sm); }
.footer-contact li a { color: rgba(255, 255, 255, 0.7); transition: color var(--transition-fast); }
.footer-contact li a:hover { color: white; }
.footer-social { display: flex; gap: var(--spacing-sm); }
.social-link { width: 40px; height: 40px; background: rgba(255, 255, 255, 0.1); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: var(--font-lg); transition: all var(--transition-base); }
.social-link:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-3px); }

/* 联系我们图标样式 */
.footer-contact-icons { display: flex !important; flex-direction: column !important; gap: var(--spacing-lg) !important; width: 100% !important; }
.contact-icon-link { display: flex !important; align-items: center !important; gap: var(--spacing-md) !important; color: rgba(255, 255, 255, 0.7) !important; text-decoration: none !important; font-size: var(--font-base) !important; transition: all var(--transition-base) !important; padding: var(--spacing-md) var(--spacing-lg) !important; border-radius: var(--radius-sm) !important; width: 100% !important; }
.contact-icon-link i { font-size: 3rem !important; width: 60px !important; height: 60px !important; display: flex !important; align-items: center !important; justify-content: center !important; flex-shrink: 0 !important; }
.contact-icon-link:hover { color: white !important; background: rgba(255, 255, 255, 0.1) !important; transform: translateX(8px) !important; }

/* 固定客服按钮栏 */
.fixed-contact-buttons { position: fixed; right: 20px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 15px; z-index: 9999; }
.fixed-contact-btn { width: 60px; height: 60px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 28px; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); text-decoration: none; }
.fixed-contact-btn:hover { transform: scale(1.15) rotate(10deg); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); }
.fixed-contact-btn.whatsapp-btn { background: linear-gradient(135deg, #25d366 0%, #128c7e 100%); }
.fixed-contact-btn.telegram-btn { background: linear-gradient(135deg, #0088cc 0%, #0066aa 100%); }
.fixed-contact-btn.instagram-btn { background: linear-gradient(135deg, #f09433 0%, #e6683c 50%, #dc2743 100%); }
.fixed-contact-btn.facebook-btn { background: linear-gradient(135deg, #1877f2 0%, #0a66c2 100%); }

/* 响应式：移动设备 (768px及以下) */
@media (max-width: 768px) {
  .site-header { backdrop-filter: blur(8px); background-color: rgba(0, 0, 0, 0.98); }
  .main-navigation { padding: 1rem 0; }
  .site-title { font-size: var(--font-xl); }
  .primary-menu { display: none; }
  /* 移动设备上调整固定按钮 */
  .fixed-contact-buttons { right: 10px; gap: 10px; }
  .fixed-contact-btn { width: 50px; height: 50px; font-size: 24px; }
}

/* 更小屏幕：小型移动设备 (480px及以下) */
@media (max-width: 480px) {
  body { padding-top: 55px; }
  .main-navigation { padding: 0.6rem 0; }
  .site-title { font-size: var(--font-base); }
  .mobile-menu-toggle { width: 32px; height: 32px; padding: 4px; }
  .hamburger-line { height: 2.5px; }
  .primary-menu { padding: 0.75rem; }
  .primary-menu.active { padding: 0.75rem; }
  .primary-menu > li > a { padding: 0.85rem 0.75rem; font-size: var(--font-sm); }
}
/* 响应式：平板 */
@media (max-width: 1024px) {
  /* 使用三列：品牌(auto) / 汉堡(自适应) / 右侧(auto) */
  .main-navigation .container { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; align-items: center; gap: 0.75rem; }
  /* 品牌区域过长时截断，允许收缩 */
  .site-branding { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; grid-column: 1; grid-row: 1; min-width: 0; }
  /* 汉堡居中列，右侧功能靠右 */
  .mobile-menu-toggle { display: flex; grid-column: 2; grid-row: 1; }
  .header-right { grid-column: 3; grid-row: 1; justify-self: end; }
  /* 平板断点：右侧区改为网格，确保登录不被挤压 */
  .header-right { display: grid; grid-template-columns: minmax(140px, 1fr) auto auto; align-items: center; column-gap: 0.5rem; }
  .header-search { display: flex; grid-column: 1; }
  .header-cart { grid-column: 2; }
  .login-button { grid-column: 3; flex-shrink: 0; white-space: nowrap; }
  .cart-contents { flex-shrink: 0; }
  /* 主菜单默认隐藏，但激活时必须显示 */
  .primary-menu { display: none; }
  .primary-menu.active { display: flex !important; }
  /* 收紧搜索框宽度，避免占满空间 */
  .search-form { padding: 0.4rem 0.75rem; }
  .search-field { width: 140px !important; }
  .search-form:focus-within .search-field { width: 180px !important; }
  .cart-contents .cart-text { display: none; }
  .cart-contents { padding: 0.5rem 0.75rem; font-size: 0.8125rem; }
  .login-button { padding: 0.5rem 1rem; font-size: 0.8125rem; }

  /* 点击汉堡按钮后展开主菜单（平板断点） */
  .primary-menu.active { 
    display: flex; 
    grid-column: 1 / -1; 
    grid-row: 2; 
    width: 100%; 
    flex-direction: column; 
    gap: 0; 
    background: rgba(0, 0, 0, 0.98); 
    padding: 1rem; 
    border-radius: var(--radius-md); 
    margin-top: 0.5rem; 
    max-height: 600px; 
    overflow: hidden; 
    opacity: 1; 
    visibility: visible; 
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 2005;
  }
}

/* 响应式：手机 */
@media (max-width: 768px) {
  .site-header { position: fixed; width: 100%; top: 0; z-index: 2001; }
  body { padding-top: 60px; }
  .main-navigation { padding: 0.75rem 0; }
  .main-navigation .container { display: grid; grid-template-columns: 1fr auto auto; grid-template-rows: auto auto; align-items: center; gap: 1rem; }
  .site-branding { grid-column: 1; grid-row: 1; }
  .site-title { font-size: var(--font-lg); }
  .mobile-menu-toggle { display: flex; grid-column: 2; grid-row: 1; margin-right: 0.5rem; }
  .header-right { grid-column: 3; grid-row: 1; }
  .primary-menu { grid-column: 1 / -1; grid-row: 2; width: 100%; flex-direction: column; gap: 0; background: rgba(0, 0, 0, 0.98); padding: 0; border-radius: var(--radius-md); margin-top: 0.5rem; max-height: 0; overflow: hidden; opacity: 0; visibility: hidden; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); position: relative; z-index: 2004; }
  .primary-menu.active { max-height: 600px; opacity: 1; visibility: visible; padding: 1rem; position: relative; z-index: 2005; }
  .primary-menu li { width: 100%; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
  .primary-menu li:last-child { border-bottom: none; }
  .primary-menu > li > a { display: block; padding: 1rem; font-size: var(--font-base); text-align: left; color: white; }
  .primary-menu > li > a::after { display: none; }
  .primary-menu > li > a:hover, .primary-menu > li > a:focus { background: rgba(255, 255, 255, 0.1); padding-left: 1.5rem; }
  .primary-menu.active li { animation: menuItemSlideIn 0.3s ease-out forwards; }
  .primary-menu.active li:nth-child(1) { animation-delay: 0.05s; }
  .primary-menu.active li:nth-child(2) { animation-delay: 0.1s; }
  .primary-menu.active li:nth-child(3) { animation-delay: 0.15s; }
  .primary-menu.active li:nth-child(4) { animation-delay: 0.2s; }
  .primary-menu.active li:nth-child(5) { animation-delay: 0.25s; }
  @keyframes menuItemSlideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
  .header-right { gap: 0.5rem; }
  .header-search { display: none; }
  .search-field { width: 0; }
  .cart-contents { padding: 0.5rem 0.75rem; font-size: 0.75rem; }
  .login-button { padding: 0.5rem 1rem; font-size: 0.75rem; }
  .user-menu-toggle { padding: 0.5rem 0.75rem; font-size: 0.75rem; }
  /* 页脚在移动端显示为单列 */
  .footer-grid { grid-template-columns: 1fr; gap: var(--spacing-xl); }
  .footer-title { font-size: var(--font-base); }
}

/* Admin Bar Compatibility: prevent overlap with fixed/sticky header */
@media (min-width: 783px) {
  body.admin-bar .site-header { top: 32px; }
}
@media (max-width: 782px) {
  body.admin-bar .site-header { top: 46px; }
}