/* 分类页面专用样式 */

/* Tailwind 工具类扩展 */
@layer utilities {
  .content-auto {
    content-visibility: auto;
  }
  .scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .scrollbar-hide::-webkit-scrollbar {
    display: none;
  }
  .category-item-hover {
    transition: all 0.2s ease-in-out;
  }
  .category-item-hover:active {
    background-color: rgba(76, 175, 80, 0.1);
  }
  .product-card-hover {
    transition: all 0.2s ease-in-out;
  }
  .product-card-hover:active {
    transform: scale(0.98);
  }
  div.btn-add-to-cart {
    transition: all 0.2s ease-in-out;
    background-color: white;
    border: 1px solid #e5e7eb !important;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .bg-lightGreen {
    background-color: white !important;
  }
  .btn-add-to-cart:active {
    transform: scale(1.1);
    background-color: #E8F5E9;
  }
}

/* 地区选择器样式 */
.bg-white.py-2.px-4 > .flex > div.text-primary {
  position: relative;
}

.bg-white.py-2.px-4 > .flex > div.text-primary::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 2px;
  background-color: #4CAF50;
}

/* 分类页面主体样式 */
.category-page body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #F5F5F5;
  touch-action: manipulation;
}

/* 自定义滚动条样式 */
.category-page ::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}
.category-page ::-webkit-scrollbar-track {
  background: transparent;
}
.category-page ::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3); /* 淡灰色 */
    border-radius: 1.5px;
    transition: opacity 0.2s ease;
  }

/* 地区选择器滚动条特殊样式 - 更细且在不滚动时隐藏 */
.bg-white.py-2.px-4.overflow-x-auto {
  scrollbar-width: thin;
  transition: scrollbar-width 0.2s ease;
}

/* 鼠标悬停或滚动时显示滚动条 */
.bg-white.py-2.px-4.overflow-x-auto:hover {
  scrollbar-width: thin;
}

/* 自定义细滚动条样式 */
.bg-white.py-2.px-4.overflow-x-auto::-webkit-scrollbar {
  height: 2px;
  transition: height 0.2s ease;
}

.bg-white.py-2.px-4.overflow-x-auto:hover::-webkit-scrollbar {
  height: 2px;
}

.bg-white.py-2.px-4.overflow-x-auto::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3); /* 淡灰色 */
    border-radius: 1px;
  }

/* 通过JS实现滚动停止后隐藏滚动条的效果 */
@keyframes hideScrollbar {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* 分类项样式增强 */
.category-item {
  position: relative;
  transition: all 0.2s ease;
}
.category-item::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  opacity: 0;
  transition: all 0.2s ease;
}
.category-item.active::after {
  opacity: 1;
}

/* 增强选中分类的背景对比度 */
.category-item.active {
  background-color: #f0fdf4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* 商品卡片动画 */
#categoryProductGrid > div {
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 底部导航栏增强 */
.fixed.bottom-0 {
  box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.05);
}

/* 搜索框焦点样式 */
.category-page input:focus {
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* 分类页搜索框样式 */
#categorySearchInput {
  transition: all 0.2s ease;
}

#categorySearchInput:focus {
  background-color: white !important;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2) !important;
}

/* 主要内容区域高度调整 */
.flex.h-\[calc\(100vh-18rem\)\] {
  height: calc(100vh - 18rem) !important;
  min-height: calc(100vh - 100px) !important;
}

/* 响应式调整 */
@media screen and (max-width: 375px) {
  .h-[calc(100vh-14rem)] {
    height: calc(100vh - 13rem);
  }
}

@media screen and (max-width: 320px) {
  .h-[calc(100vh-14rem)] {
    height: calc(100vh - 12rem);
  }
  
  h4.text-xs.line-clamp-2.h-10 {
    height: 9px;
    font-size: 11px;
  }
}

/* 骨架屏占位效果 */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 购物车动画样式 */
.cart-animation {
  position: fixed;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  background-color: rgba(76, 175, 80, 0.9);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  z-index: 9999;
  pointer-events: none;
  animation: cartAddAnimation 0.8s ease-out forwards;
}

@keyframes cartAddAnimation {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(0);
  }
  20% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-50px);
  }
}