.top-bar-section {
  /* 将 padding 从外层容器移到内部，避免内容为空时仍有间距 */
  padding-top: 24px;
  --top-bar-height: 80px;
  --top-bar-height-mobile: 56px;
  --top-bar-gap: 24px;
  --top-bar-gap-mobile: 12px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--top-bar-height);
  background-color: rgb(var(--color-background));
  margin: 0 auto;
  width: 100%;
  max-width: var(--page-width, 1200px);
}

/* 吸顶效果样式 */
.top-bar-section.top-bar-section--sticky {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-width: none;
  z-index: var(--z-index-sticky, 100);
  animation: animation-top-bar-sticky 0.26s ease-out forwards;
  padding-top: 24px;
}

/* 吸顶动画 */
@keyframes animation-top-bar-sticky {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(0);
  }
}

/* 覆盖 color-scheme-1 的背景色 */
.top-bar-section.color-scheme-1 {
  background-color: #f5f5f5;
}

/* 当页面类型是产品详情页时，将 data-settings-id="shopline-section-top-bar" 元素背景色改为 f5f5f5 */
body.page-type-product [data-settings-id="shopline-section-top-bar"],
body[data-page-type="product"] [data-settings-id="shopline-section-top-bar"] {
  background-color: #f5f5f5;
}

@media (max-width: 959px) {
  .top-bar-section {
    height: var(--top-bar-height-mobile);
  }
}

.top-bar__container {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 600px) 1fr;
  gap: var(--top-bar-gap);
  align-items: center;
  width: 100%;
  max-width: var(--page-width);
  height: 100%;
  padding-inline: var(--page-width-spacing);
  margin: 0 auto;
}

@media (max-width: 959px) {
  .top-bar__container {
    grid-template-columns: auto 1fr auto;
    gap: var(--top-bar-gap-mobile);
  }
}

/* Logo */
.top-bar__logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-bar__logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: rgb(var(--color-text)) !important;
}

.top-bar__logo-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.top-bar__logo-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.top-bar__logo-text {
  font-size: var(--title4-font-size);
  font-weight: 600;
  white-space: nowrap;
}

.top-bar__logo-image {
  width: var(--desktop-logo-width, 150px);
  height: auto;
}

@media (max-width: 959px) {
  .top-bar__logo-image {
    width: var(--mobile-logo-width, 100px);
  }

  .top-bar__logo-text {
    font-size: var(--body2-font-size);
  }
}

/* Search Bar - 根据 Figma 设计 */
.top-bar__search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 700px; /* Figma: 700px */
  margin: 0 auto;
}

.top-bar__search-form {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 52px; /* Figma: 52px */
  background-color: rgb(var(--color-background));
  border: 1px solid #c68635; /* Figma: 金色边框 */
  border-radius: 50px; /* Figma: 完全圆角 */
  overflow: hidden;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  z-index: 1;
}

.top-bar__search-form:focus-within {
  border-color: #c68635;
  box-shadow: 0 0 0 1px #c68635;
}

.top-bar__search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px; /* 调整以适应 31px 图标 */
  height: 100%;
  flex-shrink: 0;
  color: #666; /* Figma: 灰色图标 */
}

.top-bar__search-icon svg {
  width: 31px; /* Figma: 31px */
  height: 31px;
}

.top-bar__search-input {
  flex: 1;
  height: 100%;
  padding: 0;
  padding-inline-end: 20px;
  font-size: 14px; /* Figma: 14px */
  color: rgb(var(--color-text));
  background: transparent;
  border: none;
  outline: none;
  position: relative;
  z-index: 2;
  pointer-events: auto;
  cursor: text;
}

.top-bar__search-input::placeholder {
  color: #666; /* Figma: 灰色占位符 */
}

@media (max-width: 959px) {
  .top-bar__search-form {
    height: 44px;
  }

  .top-bar__search-icon {
    width: 44px;
  }

  .top-bar__search-icon svg {
    width: 24px;
    height: 24px;
  }

  .top-bar__search-input {
    font-size: 13px;
  }
}

/* Actions */
.top-bar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

@media (max-width: 959px) {
  .top-bar__actions {
    gap: 12px;
  }
}

.top-bar__action-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: rgb(var(--color-primary-button-background));
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: opacity 0.2s ease;
}

.top-bar__action-item:hover {
  opacity: 0.7;
}

.top-bar__action-item svg {
  width: 24px;
  height: 24px;
}

.top-bar__action-badge {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background-color: #e53935;
  border-radius: 9px;
}

.top-bar__action-badge:empty {
  display: none;
}

@media (max-width: 959px) {
  .top-bar__action-item {
    width: 36px;
    height: 36px;
  }

  .top-bar__action-item svg {
    width: 20px;
    height: 20px;
  }
}

/* Hide on mobile */
.top-bar__desktop-only {
  display: flex;
}

@media (max-width: 959px) {
  .top-bar__desktop-only {
    display: none;
  }
}

/* 移动端隐藏整个 top-bar */
@media (max-width: 959px) {
  .top-bar-section {
    display: none !important;
  }
}

/* ========================================
   Search Dropdown Menu Styles
   ======================================== */

/* 搜索下拉菜单容器 */
.top-bar__search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% + 200px);
  max-width: 900px;
  padding: 24px 32px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease,
    transform 0.25s ease;
  z-index: 99999;
}

/* 下拉菜单显示状态 */
.top-bar__search.is-dropdown-open .top-bar__search-dropdown {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* 下拉菜单区块 */
.search-dropdown__section {
  margin-bottom: 20px;
}

.search-dropdown__section:last-child {
  margin-bottom: 0;
}

/* 下拉菜单标题 */
.search-dropdown__title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: #c68635; /* 金色标题 */
  line-height: 1.4;
}

/* 最近搜索区块头部 */
.search-dropdown__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.search-dropdown__header .search-dropdown__title {
  margin-bottom: 0;
}

/* 清除按钮 */
.search-dropdown__clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #999;
  transition: color 0.2s ease;
}

.search-dropdown__clear-btn:hover {
  color: #666;
}

.search-dropdown__clear-btn svg {
  width: 18px;
  height: 18px;
}

/* 最近搜索隐藏状态 */
.search-dropdown__recent.is-hidden {
  display: none;
}

/* 空状态提示 */
.search-dropdown__empty-tip {
  font-size: 14px;
  color: #999;
}

/* 搜索标签容器 */
.search-dropdown__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* 搜索标签 */
.search-dropdown__tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  font-size: 14px;
  color: #333;
  text-decoration: none;
  background-color: #f5f5f5;
  border-radius: 4px;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.search-dropdown__tag:hover {
  background-color: #c68635;
  color: #fff !important;
}

.search-dropdown__tag:hover .search-dropdown__tag-icon {
  color: #fff !important;
}

/* 火焰图标 */
.search-dropdown__tag-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c68635;
}

.search-dropdown__tag-icon svg {
  width: 14px;
  height: 14px;
}

/* 热门搜索标签区域 - 多行显示 */
.search-dropdown__popular-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* 近期访问商品 - 空状态提示 */
.search-dropdown__empty-viewed {
  font-size: 14px;
  color: #999;
  text-align: center;
  padding: 24px 0;
}

/* 图片占位（无图片时） */
.search-dropdown__product-img--placeholder {
  width: 100%;
  height: 100%;
  background-color: #f0f0f0;
}

/* ========================================
   Recently Viewed Products Carousel
   ======================================== */

.search-dropdown__carousel {
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden; /* 防止内容溢出到弹窗外 */
  width: 100%;
}

/* 轮播箭头 - 绝对定位叠在产品两侧 */
.search-dropdown__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  cursor: pointer;
  color: #333;
  flex-shrink: 0;
  z-index: 2;
  transition: color 0.2s ease;
}

.search-dropdown__arrow--prev {
  left: 0;
}

.search-dropdown__arrow--next {
  right: 0;
}

.search-dropdown__arrow:hover {
  color: #c68635;
}

.search-dropdown__arrow:disabled {
  color: #ccc;
  cursor: not-allowed;
}

.search-dropdown__arrow svg {
  width: 20px;
  height: 20px;
}

/* 产品轨道 */
.search-dropdown__products-track {
  display: flex;
  gap: 16px;
  overflow: visible; /* 允许内容可见，由父容器控制溢出 */
  flex: 1;
  transition: transform 0.3s ease;
  will-change: transform; /* 优化动画性能 */
}

/* 产品卡片 */
.search-dropdown__product-card {
  flex: 0 0 calc((100% - 48px) / 4); /* 4个产品 */
  min-width: 120px; /* 参考移动端大小 */
  max-width: 150px; /* 限制最大宽度 */
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease;
}

.search-dropdown__product-card:hover {
  transform: translateY(-2px);
}

/* 产品图片容器 */
.search-dropdown__product-image {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 4px;
  background-color: #f5f5f5;
}

.search-dropdown__product-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 产品标题 */
.search-dropdown__product-title {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  color: #333;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 产品价格 - 使用 block-product-card__price-row 样式 */
.search-dropdown__product-card .block-product-card__price-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-block: 4px;
}

.search-dropdown__product-card .block-product-card__price-current {
  font-family: "Open Sans", sans-serif;
  font-weight: 700;
  color: #c68635; /* 默认金色 */
}

.search-dropdown__product-card .block-product-card__price-current.has-discount {
  color: #fa3e3e; /* 有折扣时红色 */
}

.search-dropdown__product-card .block-product-card__price-current .price-symbol {
  font-size: 14px;
}

.search-dropdown__product-card .block-product-card__price-current .price-value {
  font-size: 18px;
}

.search-dropdown__product-card .block-product-card__price-original {
  font-size: 12px;
  color: #999;
  text-decoration: line-through;
}

.search-dropdown__product-card .block-product-card__discount-tag {
  padding: 2px 10px;
  font-size: 12px;
  height: 22px;
  line-height: 16px;
  color: #fa3e3e;
  background-color: transparent;
  border: 1px solid #fa3e3e;
  border-radius: 2px;
}

@media (max-width: 959px) {
  .search-dropdown__product-card .block-product-card__price-current .price-symbol {
    font-size: 12px;
  }
  
  .search-dropdown__product-card .block-product-card__price-current .price-value {
    font-size: 16px;
  }
  
  .search-dropdown__product-card .block-product-card__discount-tag {
    padding: 1px 6px;
    font-size: 12px;
  }
}

/* ========================================
   Mobile Responsive Styles
   ======================================== */

@media (max-width: 959px) {
  .top-bar__search-dropdown {
    width: calc(100vw - 24px);
    max-width: none;
    left: 50%;
    transform: translateX(-50%);
    padding: 20px;
  }

  .search-dropdown__title {
    font-size: 14px;
  }

  .search-dropdown__popular-tags {
    grid-template-columns: repeat(3, auto);
  }

  .search-dropdown__tag {
    padding: 6px 12px;
    font-size: 13px;
  }

  .search-dropdown__product-card {
    flex: 0 0 calc((100% - 32px) / 3); /* 3个产品 */
  }

  .search-dropdown__product-title {
    font-size: 12px;
  }

  .search-dropdown__product-price {
    font-size: 13px;
  }
}
