/**
 * Module: 1688 Factory Discovery Layout (找工厂 - Find Factory)
 * Redesigned to match authentic 1688 factory channel (Image 1 & Image 2)
 */

/* Container & Global Scope */
.factory-page-wrapper {
  background-color: #f7f8fa;
  padding: 14px 0 40px;
  min-height: calc(100vh - 180px);
  width: 100%;
  max-width: 100%;
  overflow: visible;
  box-sizing: border-box;
}

.factory-container {
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}

/* 1. Breadcrumbs */
.factory-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #888888;
  margin-bottom: 12px;
}

.factory-breadcrumb a {
  color: #666666;
  text-decoration: none;
  transition: color 0.15s ease;
}

.factory-breadcrumb a:hover {
  color: #ff5000;
}

.factory-breadcrumb .sep-icon {
  display: inline-flex;
  align-items: center;
  color: #cccccc;
}

.factory-breadcrumb .curr {
  color: #333333;
  font-weight: 500;
}

.factory-breadcrumb .keyword-query {
  color: #ff5000;
  font-weight: 600;
}

/* 2. Top Category Navigation Bar & All Categories Mega Menu (Image 1 & Image 2) */
.factory-nav-wrap {
  position: -webkit-sticky;
  position: sticky;
  top: 56px;
  margin-bottom: 14px;
  z-index: 95;
  background: #f7f8fa;
  padding: 6px 0;
  transition: top 0.2s ease, box-shadow 0.2s ease;
}

.factory-cate-subnav {
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid #ebebeb;
  display: flex;
  align-items: center;
  height: 46px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  position: relative;
  box-sizing: border-box;
}

/* All categories trigger button */
.cate-all-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #222222;
  padding: 0 16px;
  border-right: 1px solid #eeeeee;
  cursor: pointer;
  user-select: none;
  height: 100%;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.cate-all-btn:hover,
.factory-nav-wrap.mega-open .cate-all-btn {
  color: #ff5000;
  background-color: #fbfbfb;
}

.cate-all-btn .icon-caret {
  transition: transform 0.2s ease;
}

.factory-nav-wrap.mega-open .cate-all-btn .icon-caret {
  transform: rotate(180deg);
}

/* Mega Dropdown Menu (Image 2) */
.factory-mega-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.09);
  z-index: 999;
  display: none;
  margin-top: 1px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.factory-nav-wrap.mega-open .factory-mega-dropdown {
  display: block;
  animation: megaFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes megaFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mega-dropdown-inner {
  padding: 16px 24px;
}

.mega-row {
  display: flex;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.mega-row:last-child {
  border-bottom: none;
}

.mega-group-title {
  width: 220px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  padding-top: 2px;
}

.mega-group-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  flex: 1;
}

.mega-link {
  font-size: 12px;
  color: #4b5563;
  text-decoration: none;
  transition: color 0.15s ease;
  line-height: 1.4;
}

.mega-link:hover {
  color: #ff5000;
  text-decoration: underline;
}

/* Horizontal Scroll Tabs */
.factory-cate-scroll-wrap {
  flex: 1;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  height: 100%;
  display: flex;
  align-items: center;
}

.factory-cate-scroll-wrap::-webkit-scrollbar {
  display: none;
}

.factory-cate-list {
  display: flex;
  align-items: center;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0 16px;
  white-space: nowrap;
  height: 100%;
}

.cate-list-item {
  display: flex;
  align-items: center;
  height: 100%;
}

.cate-item-link {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  color: #333333;
  text-decoration: none;
  padding: 0 4px;
  transition: color 0.15s ease;
  font-weight: 500;
  height: 100%;
  position: relative;
}

.cate-item-link:hover {
  color: #ff5000;
}

/* Recommended factory tab in bold orange text (Image 1) */
.cate-item-link.recommended-tab {
  color: #ff5000 !important;
  font-weight: 700;
}

.cate-item-link.active:not(.recommended-tab) {
  color: #ff5000;
  font-weight: 700;
}

/* Scroll Right Button */
.cate-scroll-right-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  background: #ffffff;
  color: #666666;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: 8px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.cate-scroll-right-btn:hover {
  color: #ff5000;
  border-color: #ff5000;
  box-shadow: 0 1px 4px rgba(255, 80, 0, 0.15);
}

/* 3. Main 2-Column Grid (Image 1) */
.factory-main-grid {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 16px;
  align-items: flex-start;
}

/* Left Column: Factory Feed */
.factory-list-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.factory-cards-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.factory-empty-state {
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #ebebeb;
  padding: 48px 24px;
  text-align: center;
}

.factory-empty-state .empty-text {
  font-size: 14px;
  color: #64748b;
  margin: 16px 0 20px;
}

.empty-reset-btn {
  display: inline-block;
  background: #ff5000;
  color: #ffffff !important;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease;
}

.empty-reset-btn:hover {
  background: #e64500;
}

/* 4. Factory Card Item (Image 1) */
.factory-card-item {
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #ebebeb;
  padding: 18px 20px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  box-sizing: border-box;
}

.factory-card-item:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  border-color: #e2e2e2;
}

/* Left Thumbnail */
.factory-card-img-wrap {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #f0f0f0;
  background: #fafafa;
  display: block;
}

.factory-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.factory-card-item:hover .factory-card-img {
  transform: scale(1.03);
}

/* Right Content Body */
.factory-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* Row 1: Header (Title + Location + Actions) */
.factory-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.factory-title-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.factory-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  text-decoration: none;
  transition: color 0.15s ease;
  line-height: 1.3;
}

.factory-title:hover {
  color: #ff5000;
}

.factory-location {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
}

.factory-location .icon-pin {
  stroke: #94a3b8;
}

.factory-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.factory-resp-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  line-height: 14px;
  color: #0284c7;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 500;
  white-space: nowrap;
  box-sizing: border-box;
}

.factory-blue-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #0284c7;
  flex-shrink: 0;
}

.factory-star-btn {
  background: none;
  border: none;
  padding: 2px;
  color: #cbd5e1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease, transform 0.15s ease;
}

.factory-star-btn:hover {
  color: #f59e0b;
  transform: scale(1.15);
}

.factory-star-btn.active {
  color: #f59e0b;
  fill: #f59e0b;
}

.factory-star-btn.active svg {
  fill: #f59e0b;
}

/* Row 2: Red Bull + Products & Specs */
.factory-row-bull {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 12px;
  color: #475569;
  line-height: 1.4;
  min-width: 0;
}

.bull-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.bull-text {
  color: #334155;
  word-break: break-word;
  white-space: normal;
}

.spec-divider {
  color: #cbd5e1;
  font-size: 11px;
  flex-shrink: 0;
}

.spec-dim {
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Row 3: Heart + Metrics */
.factory-row-metrics {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
  min-width: 0;
}

.metric-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.metric-stat {
  white-space: nowrap;
}

/* Row 4: Ribbon + Ranking */
.factory-row-rank {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 11px;
  color: #d97706;
  font-weight: 500;
  line-height: 1.4;
  min-width: 0;
}

.rank-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.rank-text {
  word-break: break-word;
  white-space: normal;
}

/* Row 5: Thumbs up + Advantage */
.factory-row-advantage {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
  min-width: 0;
}

.advantage-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.advantage-text {
  word-break: break-word;
  white-space: normal;
}

/* Row 6: Badges & Tags (Compact, subtle rounded corners, strictly NOT pill) */
.factory-row-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 3px;
}

.factory-badge-pill,
.factory-badge-tag {
  font-size: 10px;
  line-height: 14px;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 2px;
  padding: 1px 6px;
  white-space: nowrap;
  font-weight: 400;
  box-sizing: border-box;
}

/* 5. Right Column: 2-Column Side Recommendations Grid (Image 1) */
.factory-side-panel {
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #ebebeb;
  padding: 12px 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  box-sizing: border-box;
  min-width: 0;
}

.side-recommend-box {
  width: 100%;
}

.side-recommend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 8px;
}

.side-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  padding: 6px 3px;
  border-radius: 4px;
  transition: background-color 0.15s ease;
  box-sizing: border-box;
  min-width: 0;
}

.side-item:hover {
  background-color: #f8fafc;
}

.side-item-img-wrap {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.side-item-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Multi-language 2-line clean clamp prevents "..." truncations on longer text */
.side-item-title {
  font-size: 11px;
  color: #334155;
  line-height: 1.35;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  white-space: normal;
  height: 2.7em;
  margin-bottom: 4px;
  text-align: center;
  padding: 0 2px;
  box-sizing: border-box;
}

.side-item-badge-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Compact rectangular badge with subtle 2px border radius, strictly NOT pill */
.side-pill {
  font-size: 10px;
  line-height: 14px;
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-sizing: border-box;
  letter-spacing: -0.2px;
}

.side-pill.badge-strength {
  background: #fffbe6;
  color: #d48806;
  border: 1px solid #ffe58f;
}

.side-pill.badge-hot {
  background: #fff1f0;
  color: #ff4d4f;
  border: 1px solid #ffa39e;
}

.side-pill.badge-service {
  background: #f9f0ff;
  color: #722ed1;
  border: 1px solid #d3adf7;
}

.side-pill.badge-new {
  background: #e6fffb;
  color: #13c2c2;
  border: 1px solid #87e8de;
}

/* 6. Comprehensive Responsive Breakdown (All devices + Mobile < 320px) */
@media (max-width: 1024px) {
  .factory-main-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .factory-side-panel {
    margin-top: 10px;
  }

  .side-recommend-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px 8px;
  }
}

@media (max-width: 768px) {
  .factory-page-wrapper {
    padding: 10px 0 28px;
  }

  .factory-container {
    padding: 0 12px;
  }

  .factory-nav-wrap {
    top: 52px;
    padding: 4px 0;
  }

  .factory-card-item {
    padding: 14px 12px;
    gap: 12px;
  }

  .factory-card-img-wrap {
    width: 100px;
    height: 100px;
  }

  .mega-row {
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
  }

  .mega-group-title {
    width: 100%;
    font-size: 12px;
  }

  .mega-group-links {
    gap: 6px 14px;
  }

  .mega-link {
    font-size: 11px;
  }

  .side-recommend-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px 6px;
  }
}

@media (max-width: 576px) {
  .factory-container {
    padding: 0 10px;
  }

  .factory-cate-subnav {
    height: 42px;
  }

  .cate-all-btn {
    padding: 0 10px;
    font-size: 12px;
    gap: 5px;
  }

  .factory-cate-list {
    padding: 0 10px;
    gap: 14px;
  }

  .cate-item-link {
    font-size: 12px;
  }

  .cate-scroll-right-btn {
    width: 24px;
    height: 24px;
  }

  .factory-card-item {
    padding: 12px 10px;
    gap: 10px;
  }

  .factory-card-img-wrap {
    width: 84px;
    height: 84px;
  }

  .factory-title {
    font-size: 14px;
  }

  .factory-row-bull,
  .factory-row-metrics {
    font-size: 11px;
  }

  .side-recommend-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 6px;
  }

  .side-item-img-wrap {
    width: 68px;
    height: 68px;
  }
}

@media (max-width: 360px) {
  .factory-container {
    padding: 0 6px;
  }

  .factory-cate-subnav {
    height: 40px;
  }

  .cate-all-btn {
    padding: 0 8px;
    font-size: 11.5px;
    gap: 4px;
  }

  .factory-cate-list {
    padding: 0 8px;
    gap: 12px;
  }

  .factory-card-item {
    padding: 10px 8px;
    gap: 8px;
  }

  .factory-card-img-wrap {
    width: 72px;
    height: 72px;
  }

  .factory-title {
    font-size: 13px;
  }

  .factory-resp-badge {
    font-size: 9px;
    padding: 1px 4px;
  }

  .factory-resp-badge .factory-blue-dot {
    width: 4px;
    height: 4px;
  }

  .side-item-img-wrap {
    width: 58px;
    height: 58px;
  }

  .side-item-title {
    font-size: 10px;
    height: 2.5em;
  }

  .side-pill {
    font-size: 9px;
    padding: 1px 4px;
  }
}

/* Mobile < 320px (Ultra-compact: 280px - 319px) */
@media (max-width: 320px) {
  .factory-page-wrapper {
    padding: 6px 0 18px;
  }

  .factory-container {
    padding: 0 4px;
  }

  .factory-nav-wrap {
    top: 52px;
    padding: 3px 0;
  }

  .factory-breadcrumb {
    font-size: 11px;
    gap: 3px;
    margin-bottom: 8px;
  }

  .factory-cate-subnav {
    height: 38px;
  }

  .cate-all-btn {
    padding: 0 6px;
    font-size: 11px;
    gap: 3px;
  }

  .cate-all-btn svg {
    width: 12px;
    height: 12px;
  }

  .factory-cate-list {
    padding: 0 6px;
    gap: 10px;
  }

  .cate-item-link {
    font-size: 11px;
    padding: 0 2px;
  }

  .cate-scroll-right-btn {
    width: 22px;
    height: 22px;
    margin-right: 3px;
  }

  .factory-card-item {
    padding: 8px 6px;
    gap: 6px;
  }

  .factory-card-img-wrap {
    width: 64px;
    height: 64px;
  }

  .factory-title {
    font-size: 12px;
    line-height: 1.3;
  }

  .factory-location {
    font-size: 10px;
  }

  .factory-resp-badge {
    font-size: 8.5px;
    padding: 1px 3px;
    gap: 2px;
  }

  .factory-star-btn svg {
    width: 13px;
    height: 13px;
  }

  .factory-row-bull {
    font-size: 10px;
    gap: 2px 4px;
  }

  .bull-icon svg {
    width: 11px;
    height: 11px;
  }

  .factory-row-metrics {
    font-size: 10px;
    gap: 2px 4px;
  }

  .metric-icon svg {
    width: 11px;
    height: 11px;
  }

  .factory-row-rank {
    font-size: 10px;
  }

  .rank-icon svg {
    width: 11px;
    height: 11px;
  }

  .factory-row-advantage {
    font-size: 10px;
  }

  .advantage-icon svg {
    width: 11px;
    height: 11px;
  }

  .factory-badge-pill,
  .factory-badge-tag {
    font-size: 8.5px;
    padding: 1px 3px;
  }

  .factory-side-panel {
    padding: 8px 4px;
  }

  .side-recommend-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 4px;
  }

  .side-item {
    padding: 4px 2px;
  }

  .side-item-img-wrap {
    width: 50px;
    height: 50px;
  }

  .side-item-title {
    font-size: 9.5px;
    line-height: 1.25;
    height: 2.5em;
  }

  .side-pill {
    font-size: 8.5px;
    padding: 1px 3px;
    border-radius: 2px;
  }

  .factory-empty-state {
    padding: 24px 12px;
  }

  .factory-empty-state .empty-text {
    font-size: 12px;
    margin: 10px 0 14px;
  }

  .empty-reset-btn {
    padding: 6px 14px;
    font-size: 11px;
  }
}
