/* ── market.html 전용 스타일 v5 — Dark Forest Edition ── */

.sell-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent); color: white;
  font-size: 14px; font-weight: 700; height: 38px; padding: 0 18px;
  border-radius: 10px; border: none; cursor: pointer;
  font-family: 'Noto Sans KR', sans-serif; transition: all 0.15s;
}
.sell-btn:hover { background: #ea6c0e; transform: translateY(-1px); }

/* ── 페이지 히어로 오버라이드 ── */
.page-hero {
  background: linear-gradient(135deg, #150A04 0%, #2A1008 50%, #3D1A08 100%) !important;
}
.hero-stat .n { color: #FDBA74 !important; }

/* ── 카테고리 탭 바 ── */
.cat-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--green-border);
  position: sticky; top: 64px; z-index: 90;
}
.cat-bar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
  display: flex; gap: 0; overflow-x: auto; scrollbar-width: none;
}
.cat-bar-inner::-webkit-scrollbar { display: none; }

.cat-tab {
  padding: 14px 18px; min-height: 44px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); border: none; background: none; cursor: pointer;
  white-space: nowrap; border-bottom: 2px solid transparent; border-radius: 0;
  transition: all 0.15s; font-family: 'Noto Sans KR', sans-serif;
  display: inline-flex; align-items: center;
}
.cat-tab:hover { color: var(--green-bright); }
.cat-tab.active {
  color: var(--text-dark); font-weight: 700;
  border-bottom-color: var(--green-vivid); background: none;
}

/* ── 메인 레이아웃 ── */
.main { max-width: 1120px; margin: 0 auto; padding: 24px 24px 60px; display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: start; }
.main > div:first-child { min-width: 0; }

/* ── 필터 바 ── */
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-select {
  padding: 7px 12px; min-height: 44px; border: 1px solid var(--green-border);
  border-radius: 8px; font-size: 13px; color: var(--text-mid);
  background: var(--bg-elevated); cursor: pointer;
  font-family: 'Noto Sans KR', sans-serif; outline: none;
}
.filter-select option { background: var(--bg-card); }
.search-box { flex: 1; min-width: 180px; }
.view-toggle { display: flex; gap: 4px; }
.view-btn {
  width: 44px; height: 44px; border-radius: 6px;
  border: 1px solid var(--green-border);
  background: var(--bg-elevated); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.15s; color: var(--text-muted);
}
.view-btn.active { background: var(--green-vivid); border-color: var(--green-vivid); color: var(--btn-on-green); }

/* ── 상품 그리드 ── */
.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.product-grid.list-view { grid-template-columns: 1fr; }

/* ── 상품 카드 ── */
.product-card {
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--green-border); box-shadow: var(--shadow-sm);
  overflow: hidden; cursor: pointer; transition: all 0.2s;
  display: flex; flex-direction: column;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md), 0 0 20px rgba(34,197,94,0.05);
  border-color: var(--green-border-bright);
}
.product-card.sold { opacity: 0.5; }
.product-card.sold .product-img::after {
  content: '거래완료'; position: absolute; inset: 0;
  background: rgba(0,0,0,0.6); color: var(--text-dark);
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.product-img {
  width: 100%; aspect-ratio: 1/1; background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  font-size: 50px; position: relative; overflow: hidden; flex-shrink: 0;
  border-bottom: 1px solid var(--green-border);
}
.product-badge { position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.badge-free { background: var(--green-vivid); color: var(--btn-on-green); }
.badge-hot  { background: var(--accent); color: white; }
.badge-new  { background: #3B82F6; color: white; }

.product-body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.product-cat { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; width: fit-content; }
.cat-share  { background: rgba(34,197,94,0.1); color: var(--green-bright); }

.product-title {
  font-size: 14px; font-weight: 500; color: var(--text-dark);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; line-height: 1.45; flex: 1;
}
.product-price { font-size: 17px; font-weight: 700; color: var(--accent); }
.product-price.free { color: var(--green-vivid); }
.product-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
}
.product-location { display: flex; align-items: center; gap: 3px; }
.product-stats { display: flex; gap: 8px; }

/* 리스트뷰 */
.product-grid.list-view .product-card { flex-direction: row; }
.product-grid.list-view .product-img { width: 110px; height: 110px; aspect-ratio: unset; flex-shrink: 0; font-size: 38px; }
.product-grid.list-view .product-body { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.product-grid.list-view .product-title { flex-basis: 100%; -webkit-line-clamp: 1; }
.product-grid.list-view .product-price { margin-right: auto; }

/* 빈 상태 */
.empty-state { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; margin-bottom: 8px; }
.empty-state small { font-size: 13px; }
.pagination { margin-top: 24px; }

/* ── 사이드바 ── */
.sidebar { align-self: flex-start; max-height: none; overflow-y: visible; }
.safety-card {
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  border-radius: var(--radius); padding: 20px;
}
[data-theme="dark"] .safety-card {
  background: linear-gradient(135deg, #080F0A, #0C1C10);
  border: 1px solid var(--green-border);
}
.safety-card h4 { font-family: 'Playfair Display', serif; font-size: 15px; color: var(--text-dark); margin-bottom: 12px; }
.safety-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.safety-list li { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.safety-list li span { flex-shrink: 0; font-size: 14px; }

.club-cat-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; transition: background 0.13s; }
.club-cat-item:hover { background: var(--bg-hover); }
.club-cat-emoji { font-size: 18px; }
.club-cat-name { font-size: 13px; font-weight: 500; color: var(--text-dark); flex: 1; }
.club-cat-cnt  { font-size: 11px; color: var(--text-muted); }

.recent-item { display: flex; gap: 10px; padding: 10px 16px; cursor: pointer; transition: background 0.13s; }
.recent-item:hover { background: var(--bg-hover); }
.recent-thumb { width: 46px; height: 46px; border-radius: 8px; background: var(--bg-elevated); border: 1px solid var(--green-border); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.recent-info { flex: 1; }
.recent-title { font-size: 12px; font-weight: 500; color: var(--text-dark); margin-bottom: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 160px; }
.recent-price { font-size: 13px; font-weight: 700; color: var(--accent); }

/* ── 장터 모달 다크모드 override ── */
#item-detail-modal > div {
  background: var(--bg-card) !important;
  color: var(--text-dark) !important;
}

@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .hero-stats { display: none; }
}
@media (max-width: 768px) {
  .page-hero { padding: 16px 16px 14px !important; }
  .page-hero h1 { font-size: 20px !important; }
  .cat-bar { margin-top: 8px !important; }
  .cat-bar-inner {
    display: flex !important; flex-wrap: wrap !important;
    gap: 4px !important; padding: 6px 12px !important;
    overflow-x: hidden !important;
  }
  .cat-bar-inner #club-cat-select {
    border-radius: 8px !important; font-size: 11px !important; padding: 4px 8px !important;
    background: var(--bg-elevated) !important; color: var(--text-dark) !important;
    border: 1px solid var(--green-border) !important; min-height: 32px !important;
  }
  .cat-tab {
    padding: 5px 4px !important; font-size: 11px !important; min-height: 26px !important;
    border-bottom: none !important; border: 1px solid var(--green-border) !important;
    border-radius: 8px !important; text-align: center; justify-content: center;
    background: var(--bg-elevated) !important;
  }
  .cat-tab.active { background: var(--green-vivid) !important; color: var(--btn-on-green) !important; border-color: var(--green-vivid) !important; }
  .main { padding: 8px 12px 40px !important; }
  .filter-bar { flex-wrap: nowrap; gap: 4px; margin-bottom: 8px; overflow-x: auto; scrollbar-width: none; }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-select { height: 32px !important; min-height: 32px !important; padding: 0 4px; font-size: 11px; max-width: 80px; }
  .search-box { flex: 1; min-width: 0; height: 32px; overflow: hidden; }
  .search-box input { flex: 1; width: auto; min-width: 0; font-size: 12px; padding: 0 8px; }
  .search-box button { padding: 0 8px; flex-shrink: 0; }
  .view-toggle { display: none; }
  .product-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
  .product-body { padding: 6px; gap: 2px; }
  .product-cat, .product-meta, .product-author { display: none; }
  .product-title { font-size: 11px; -webkit-line-clamp: 1; }
  .product-price { font-size: 13px; }
}
@media (max-width: 480px) {
  .product-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
}
