/* products/products.css */

/* 搜索与侧边栏布局 */
/* 页面淡入动画 */
/* body {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

body.loaded {
  opacity: 1;
  transform: translateY(0);
} */

.products-page .container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    padding: 80px 0;
}

.hamburger {
  display: none; /* 桌面隐藏汉堡按钮 */
}

nav {
  display: flex;
  gap: 20px;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
}

.search-box {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 25px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-list li {
    margin-bottom: 12px;
}

.category-list a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: #555;
    border-radius: 5px;
    transition: all 0.2s;
}

.category-list a:hover,
.category-list a.active {
    background: #d63031;
    color: white;
}

.main-content {
    flex: 1;
    min-width: 300px;
}

/* 响应式 */
@media (max-width: 768px) {
    .products-page .container {
        flex-direction: column;
    }
    .hamburger {
        display: block;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        margin-left: auto; /* 靠右对齐 */
        color: #333;
  }

    nav {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: white;
        flex-direction: column;
        padding: 16px 0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        display: none; /* 默认隐藏 */
        z-index: 1000;
    }

    nav.show {
        display: flex;
    }

    nav a {
        padding: 12px 20px;
        text-align: left;
    }
    .sidebar {
        width: 100%;
        padding-top: 20px;
    }
    .search-box {
        margin-bottom: 20px;
    }
}

/* 所有商品页卡片动画 */
.product-card {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.product-card.animate-in {
  opacity: 1;
  transform: translateY(0);
}

/* ===== 产品卡片整体布局 ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.product-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
}

.product-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  /* box-shadow: 0 2px 6px rgba(0,0,0,0.05); */
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.product-card.animate-in {
  opacity: 1;
  transform: translateY(0);
}

/* ===== 关键：适配 550x550 正方形图 ===== */
.product-card img {
  width: 100%;
  height: auto;
  max-height: 240px;        /* 限制最大高度，避免过大 */
  object-fit: contain;      /* 完整显示，不裁剪 */
  object-position: center;
  display: block;
  margin-bottom: 14px;
  border-radius: 4px;
  background-color: #ffffff;
}

.product-card h3 {
  margin: 0 0 10px;
  font-size: 1.1em;
  line-height: 1.4;
  /* color: #333; */
}

.product-card p {
  margin: 0;
  font-size: 0.95em;
  /* color: #666; */
  line-height: 1.5;
}

/* 消除灰色背景透出 */
body,
.main-content {
  background-color: #ffffff !important;
}


/* 调整标题与卡片的对齐 */
.main-content > h2 {
  margin: 0 0 40px;       /* 移除默认 margin-top，控制下方间距 */
  padding: 0;
  font-size: 1.8em;
  line-height: 1.2;
}

/* 确保 .main-content 无额外上边距 */
.main-content {
  padding: 0; /* 或只保留左右 padding，如 padding: 0 24px; */
}


/* ===== 粘性页脚：防止内容少时页脚上浮 ===== */
html, body {
  height: 100%;
  margin: 0;
}

#mainContent {
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* 关键：至少占满整个视口高度 */
}

main.products-page {
  flex: 1 0 auto; /* 自动撑开，填充剩余空间 */
}

footer {
  flex-shrink: 0; /* 防止页脚被压缩 */
}

/* ===== 固定侧边栏（仅桌面端） ===== */
@media (min-width: 769px) {
  .products-page {
    display: block; /* 退出 flex 布局，避免干扰 sticky */
    position: relative;
  }

  .sidebar {
    position: sticky;
    top: 15%; /* 与 header 高度对齐（header ≈80px） */
    height: fit-content;
    max-height: calc(100vh - 120px); /* 防止过高溢出 */
    overflow-y: auto; /* 内容多时侧边栏可滚动 */
    align-self: flex-start;
  }
}

.products-header {
  padding: 22px 18px 10px; /* 上 → 28px（比之前多 8~12px），下 → 16px */
}


.products-page .container {
  display: flex;
  gap: 30px;
  padding: 0 0 40px; /* 只保留底部 padding，顶部交给 .products-header */
}




.pagination-btn {
    margin: 0 4px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.pagination-btn:hover {
    background: #f0f0f0;
}

.pagination-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== 防止无商品时布局塌陷 ===== */
.products-scroll-area {
  min-height: 400px; /* 关键：确保区域始终有足够高度 */
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* 商品顶部对齐，空状态居中可选 */
}

/* 空状态提示优化（覆盖内联样式） */
.products-scroll-area .product-grid > p {
  margin: auto 0; /* 如果希望空提示垂直居中，用 margin: auto; */
  padding: 20px;
  font-size: 1.1em;
  color: #777;
}
