/**
 * CSS: Category Subcategories Bar (Pre-computed Cache Layouts)
 * Package: Flatsome Lite
 * Author: Xe nâng Khuê Đăng / Antigravity
 */

/* Khung bao ngoài chung */
.category-subcategories-wrapper {
  margin: 12px 0 16px 0;
  clear: both;
}

.cat-subcat-nav {
  position: relative;
  width: 100%;
}

/* Thanh cuộn ngang mượt mà, chống tràn màn hình */
.cat-subcat-scroll-track {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding: 4px 2px 8px 2px;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.cat-subcat-scroll-track::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* ==========================================================================
   1. KIỂU: IMAGE_LEFT (HÌNH ẢNH BÊN TRÁI CHỮ - DẠNG VIÊN THUỐC PILL BADGE)
   ========================================================================== */
.cat-subcat-style-image_left .cat-subcat-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 99px;
  padding: 4px 14px 4px 5px;
  text-decoration: none;
  color: #1e293b;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  white-space: nowrap;
}

.cat-subcat-style-image_left .cat-subcat-item:hover {
  background: #f8fafc;
  border-color: var(--primary-color, #dd3333);
  color: var(--primary-color, #dd3333);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.cat-subcat-style-image_left .cat-subcat-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: #f1f5f9;
  flex-shrink: 0;
}

.cat-subcat-style-image_left .cat-subcat-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.cat-subcat-style-image_left .cat-subcat-count {
  font-size: 11px;
  color: #64748b;
  font-weight: normal;
  margin-left: 3px;
}

/* ==========================================================================
   2. KIỂU: IMAGE_TOP & IMAGE_TOP_MOBILE_LEFT (DESKTOP: HÌNH TRÊN CHỮ DƯỚI)
   ========================================================================== */
.cat-subcat-style-image_top .cat-subcat-scroll-track,
.cat-subcat-style-image_top_mobile_left .cat-subcat-scroll-track {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  overflow-x: visible;
  overflow-y: visible;
  gap: 12px;
  padding-bottom: 10px;
}

.cat-subcat-style-image_top .cat-subcat-item,
.cat-subcat-style-image_top_mobile_left .cat-subcat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex: 0 0 110px;
  width: 110px;
  max-width: 110px;
  box-sizing: border-box;
  padding: 5px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  text-decoration: none;
  text-align: center;
  color: #1e293b;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.cat-subcat-style-image_top .cat-subcat-item:hover,
.cat-subcat-style-image_top_mobile_left .cat-subcat-item:hover {
  border-color: var(--primary-color, #dd3333);
  color: var(--primary-color, #dd3333);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.cat-subcat-style-image_top .cat-subcat-img-wrap,
.cat-subcat-style-image_top_mobile_left .cat-subcat-img-wrap {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cat-subcat-style-image_top .cat-subcat-img-wrap img,
.cat-subcat-style-image_top_mobile_left .cat-subcat-img-wrap img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.cat-subcat-style-image_top .cat-subcat-item:hover .cat-subcat-img-wrap img,
.cat-subcat-style-image_top_mobile_left .cat-subcat-item:hover .cat-subcat-img-wrap img {
  transform: scale(1.06);
}

.cat-subcat-style-image_top .cat-subcat-name,
.cat-subcat-style-image_top_mobile_left .cat-subcat-name {
  font-size: 12px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.cat-subcat-style-image_top .cat-subcat-count,
.cat-subcat-style-image_top_mobile_left .cat-subcat-count {
  display: block;
  font-size: 10.5px;
  color: #64748b;
  font-weight: normal;
  margin-top: 2px;
}

/* ==========================================================================
   3. KIỂU: TEXT_ONLY (CHỈ CHỮ - DẠNG TAG NÚT BẤM GỌN GÀNG)
   ========================================================================== */
.cat-subcat-style-text_only .cat-subcat-item {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 12px;
  text-decoration: none;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cat-subcat-style-text_only .cat-subcat-item:hover {
  background: var(--primary-color, #dd3333);
  color: #ffffff;
  border-color: var(--primary-color, #dd3333);
}

.cat-subcat-style-text_only .cat-subcat-count {
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.8;
}

/* Mobile responsive */
@media (max-width: 767px) {
  .category-subcategories-wrapper {
    margin: 8px 0 12px 0;
  }
  .cat-subcat-scroll-track {
    padding-left: 0;
    padding-right: 0;
    gap: 8px;
  }
  .cat-subcat-style-image_left .cat-subcat-item {
    font-size: 12.5px;
    padding: 3px 10px 3px 4px;
  }
  .cat-subcat-style-image_left .cat-subcat-img-wrap {
    width: 28px;
    height: 28px;
  }
  .cat-subcat-style-image_top .cat-subcat-scroll-track {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    overflow-x: visible;
    gap: 8px;
  }
  .cat-subcat-style-image_top .cat-subcat-item {
    flex: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 6px;
  }
  .cat-subcat-style-image_top .cat-subcat-img-wrap {
    width: 100%;
    max-width: 88px;
    height: auto;
    aspect-ratio: 1 / 1;
  }
  .cat-subcat-style-image_top .cat-subcat-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
  .cat-subcat-style-image_top .cat-subcat-name {
    font-size: 11.5px;
    line-height: 1.3;
  }

  /* Kiểu hỗn hợp: Desktop hình trên chữ dưới -> Mobile viên thuốc (hình bên trái) */
  .cat-subcat-style-image_top_mobile_left .cat-subcat-scroll-track {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding: 4px 0 8px 0;
  }
  .cat-subcat-style-image_top_mobile_left .cat-subcat-item {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    border-radius: 99px;
    padding: 3px 11px 3px 4px;
    text-align: left;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
  }
  .cat-subcat-style-image_top_mobile_left .cat-subcat-img-wrap {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin-bottom: 0;
    background: #ffffff;
    flex-shrink: 0;
  }
  .cat-subcat-style-image_top_mobile_left .cat-subcat-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
  }
  .cat-subcat-style-image_top_mobile_left .cat-subcat-name {
    font-size: 12.5px;
    line-height: 1.2;
    display: inline;
    -webkit-line-clamp: unset;
    -webkit-box-orient: initial;
    overflow: visible;
    word-break: normal;
  }
  .cat-subcat-style-image_top_mobile_left .cat-subcat-count {
    display: inline;
    font-size: 11px;
    margin-top: 0;
    margin-left: 3px;
  }
}
