/* ═══════════════════════════════════════
   Cat's Alley — Marketplace Styles
   Uses catsbe-common.css variables
   ═══════════════════════════════════════ */

/* ═══ LAYOUT ═══ */
.alley-wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 12px;
}

/* ═══ HEADER ═══ */
.alley-header {
  padding: 20px 0 8px;
  text-align: center;
}
.alley-header-title {
  font-family: var(--cb-font-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--cb-text);
  line-height: 1.2;
  margin: 0;
}
.alley-header-sub {
  font-family: var(--cb-font-mono);
  font-size: 10px;
  color: var(--cb-accent);
  letter-spacing: 1.5px;
  margin-top: 4px;
}

/* ═══ FILTERS ═══ */
.alley-filters {
  position: sticky;
  top: 56px;
  z-index: 100;
  background: var(--cb-bg);
  padding: 0 4px;
  border-bottom: 1px solid var(--cb-border);
}
.alley-tab-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 0;
  align-items: center;
}
.alley-tab-row::-webkit-scrollbar { display: none; }
.alley-tab-row + .alley-tab-row {
  border-top: 1px solid var(--cb-border-light);
}

.alley-tab {
  flex-shrink: 0;
  font-family: var(--cb-font-mono);
  font-size: 11px;
  letter-spacing: 0.6px;
  padding: 5px 13px;
  border-radius: var(--cb-radius-pill);
  text-decoration: none !important;
  white-space: nowrap;
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  color: var(--cb-text-sub);
  transition: all .15s;
  cursor: pointer;
}
.alley-tab:hover {
  background: var(--cb-surface-alt);
  border-color: var(--cb-border);
  color: var(--cb-text);
}
.alley-tab.active {
  background: var(--cb-text-muted);
  border-color: var(--cb-text-muted);
  color: #fff;
}
.alley-tab--label {
  font-weight: 600;
  background: var(--cb-surface-alt);
  border: 1px solid var(--cb-border);
  color: var(--cb-text);
}
.alley-tab--label.active {
  background: var(--cb-text-muted);
  border-color: var(--cb-text-muted);
  color: #fff;
}

/* ═══ TOOLBAR ═══ */
.alley-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--cb-border-light);
  flex-wrap: wrap;
}
.alley-tb {
  flex-shrink: 0;
  font-family: var(--cb-font-mono);
  font-size: 11px;
  padding: 6px 14px;
  border-radius: var(--cb-radius-sm);
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  color: var(--cb-text-sub);
  text-decoration: none !important;
  white-space: nowrap;
  transition: all .15s;
  cursor: pointer;
}
.alley-tb:hover {
  background: var(--cb-surface-alt);
  border-color: var(--cb-accent);
  color: var(--cb-text);
}
.alley-tb--primary {
  margin-left: auto;
  background: var(--cb-accent);
  border-color: var(--cb-accent);
  color: #fff;
  font-weight: 600;
}
.alley-tb--primary:hover {
  background: var(--cb-gold-dark);
  border-color: var(--cb-gold-dark);
  color: #fff;
}

/* ═══ PRODUCT GRID ═══ */
.alley-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
  padding: 16px 0;
}

/* ═══ PRODUCT CARD ═══ */
.al-card {
  display: block;
  text-decoration: none !important;
  color: inherit;
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.al-card:hover {
  color: inherit;
  border-color: var(--cb-accent);
  box-shadow: var(--cb-shadow-hover);
}

.al-card-thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--cb-surface-alt);
  overflow: hidden;
}
.al-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.al-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--cb-text-faint);
  background: var(--cb-surface-alt);
}

/* Badges */
.al-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  font-family: var(--cb-font-mono);
  font-size: 8px;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 3px;
  color: #fff;
  line-height: 1.3;
}
.al-badge--active {
  background: var(--cb-success);
}
.al-badge--sold {
  background: var(--cb-text-muted);
}
.al-badge--q {
  position: absolute;
  top: 5px;
  right: 5px;
  background: var(--cb-success);
  color: #fff;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

/* Card body */
.al-card-body {
  padding: 6px 8px 8px;
}
.al-card-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--cb-text);
  line-height: 1.3;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: keep-all;
}
.al-card-cat {
  font-family: var(--cb-font-mono);
  font-size: 9px;
  color: var(--cb-success);
  margin-bottom: 3px;
}
.al-card-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--cb-accent);
  line-height: 1.2;
}
.al-card-stock {
  font-family: var(--cb-font-mono);
  font-size: 9px;
  color: var(--cb-text-muted);
  margin-top: 2px;
}
.al-card-shipping {
  font-family: var(--cb-font-mono);
  font-size: 8px;
  color: var(--cb-text-faint);
  margin-top: 1px;
}

/* ═══ DETAIL PAGE ═══ */
.ald-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 12px;
}
.ald-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding-top: 16px;
}

/* ── Gallery (swipe) ── */
.ald-gallery {
  position: relative;
  background: #0f0e0c;
  border-radius: var(--cb-radius);
  overflow: hidden;
}
.ald-gallery-inner {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.ald-gallery-inner::-webkit-scrollbar { display: none; }
.ald-gallery-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  aspect-ratio: 1 / 1;
  max-height: 480px;
}
.ald-gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ald-gallery-empty {
  flex: 0 0 100%;
  aspect-ratio: 1 / 1;
  max-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cb-text-faint);
  font-size: 36px;
  background: var(--cb-surface-alt);
}
.ald-gallery-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}
.ald-gallery-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: background .2s, width .2s;
}
.ald-gallery-dot.active {
  background: #fff;
  width: 18px;
  border-radius: 3px;
}
.ald-gallery-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: var(--cb-font-mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  color: #fff;
}
.ald-gallery-badge--live { background: var(--cb-success); }
.ald-gallery-badge--sold { background: rgba(0,0,0,0.5); }

/* ── Info ── */
.ald-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ald-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--cb-text);
  margin: 0;
  line-height: 1.3;
}
.ald-cat {
  font-family: var(--cb-font-mono);
  font-size: 11px;
  color: var(--cb-success);
}
.ald-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--cb-accent);
}
.ald-stock {
  font-size: 14px;
  color: var(--cb-text-sub);
}
.ald-stock strong {
  color: var(--cb-text);
}
.ald-shipping {
  font-size: 13px;
  color: var(--cb-text-muted);
  padding: 8px 12px;
  background: var(--cb-surface-alt);
  border-radius: var(--cb-radius-sm);
  border: 1px solid var(--cb-border-light);
}
.ald-buy-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--cb-radius);
  background: var(--cb-accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background .15s;
  text-decoration: none !important;
}
.ald-buy-btn:hover {
  background: var(--cb-gold-dark);
  color: #fff;
}
.ald-buy-btn:disabled,
.ald-buy-btn--sold {
  background: var(--cb-text-faint) !important;
  cursor: not-allowed;
  color: #fff;
}
.ald-seller {
  font-size: 12px;
  color: var(--cb-text-muted);
}
.ald-views {
  font-family: var(--cb-font-mono);
  font-size: 10px;
  color: var(--cb-text-faint);
}

/* Description */
.ald-desc {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--cb-border);
}
.ald-desc h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--cb-text);
  margin-bottom: 12px;
}
.ald-desc-body {
  font-size: 15px;
  line-height: 1.85;
  color: var(--cb-text-sub);
  word-break: keep-all;
  overflow-wrap: break-word;
}
.ald-desc-body p {
  margin: 0 0 0.8em;
}
.ald-desc-body p:last-child {
  margin-bottom: 0;
}
.ald-desc-body h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--cb-text);
  margin: 1.4em 0 0.5em;
  line-height: 1.4;
}
.ald-desc-body h2:first-child {
  margin-top: 0;
}
.ald-desc-body strong, .ald-desc-body b {
  font-weight: 600;
  color: var(--cb-text);
}
.ald-desc-body ul, .ald-desc-body ol {
  padding-left: 1.4em;
  margin: 0.6em 0;
}
.ald-desc-body li {
  margin-bottom: 0.3em;
}
.ald-desc-body img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1em auto;
}
.ald-desc-body hr {
  border: none;
  border-top: 1px solid var(--cb-border-light);
  margin: 1.2em 0;
}
.ald-desc-body a {
  color: var(--cb-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ald-desc-body a:hover {
  color: var(--cb-gold-dark);
}
.ald-desc-body mark {
  background: #FFF3CD;
  padding: 1px 3px;
  border-radius: 2px;
}

/* ═══ ALLEY EDITOR (등록/수정 폼) ═══ */
.alley-editor-wrap {
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius, 10px);
  background: #fff;
  overflow: hidden;
}
.alley-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--cb-surface-alt, #f8f5f0);
  border-bottom: 1px solid var(--cb-border);
}
.alley-editor-toolbar button {
  min-width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--cb-text-sub);
  transition: background .15s;
}
.alley-editor-toolbar button:hover,
.alley-editor-toolbar button.active {
  background: var(--cb-border-light, #ede8e0);
}
.alley-editor-toolbar .tb-sep {
  width: 1px;
  height: 20px;
  background: var(--cb-border);
  margin: 0 4px;
}
.alley-editor-toolbar .tb-photo {
  font-size: 16px;
}
.alley-editor-wrap #tiptap-editor {
  min-height: 200px;
}
.alley-editor-wrap #tiptap-editor .ProseMirror {
  min-height: 180px;
  padding: 14px 12px;
  outline: none;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: break-word;
  font-size: 15px;
  line-height: 1.8;
  color: var(--cb-text-sub);
}
.alley-editor-wrap #tiptap-editor .ProseMirror p.is-editor-empty:first-child::before {
  content: "상품 상태, 구성품, 특이사항 등을 적어주세요.";
  color: #bbb;
  float: left;
  height: 0;
  pointer-events: none;
}
.alley-editor-wrap #tiptap-editor .ProseMirror img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.8em auto;
}
.alley-editor-wrap #tiptap-editor .ProseMirror h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 1em 0 0.4em;
}
@media (max-width: 767px) {
  .alley-editor-wrap #tiptap-editor {
    min-height: 160px;
  }
  .alley-editor-wrap #tiptap-editor .ProseMirror {
    min-height: 140px;
    padding: 12px 10px;
    font-size: 14px;
  }
  .alley-editor-toolbar button {
    min-width: 30px;
    height: 30px;
    font-size: 13px;
  }
}

/* SearchPost card */
.ald-sp-card {
  margin-top: 16px;
  padding: 16px;
  background: var(--cb-surface-alt);
  border-radius: var(--cb-radius);
  border: 1px solid var(--cb-border);
}
.ald-sp-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--cb-success);
  margin-bottom: 8px;
}
.ald-sp-card p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--cb-text-sub);
  margin: 0;
}

/* ═══ FORM PAGES ═══ */
.alley-form-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 12px;
}
.alley-form-wrap h1 {
  font-family: var(--cb-font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--cb-text);
  margin-bottom: 20px;
}

/* ═══ MY SALES ═══ */
.alley-sales-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* ═══ EMPTY STATE ═══ */
.alley-empty {
  padding: 48px 0;
  text-align: center;
  color: var(--cb-text-faint);
  font-size: 14px;
}

/* ═══ RESPONSIVE ═══ */

/* Tablet (5 columns) */
@media (max-width: 1024px) {
  .alley-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Mobile (4 columns) */
@media (max-width: 767px) {
  .alley-header-title { font-size: 22px; }
  .alley-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .al-card-body { padding: 4px 6px 6px; }
  .al-card-title { font-size: 10px; }
  .al-card-price { font-size: 11px; }
  .al-card-cat { font-size: 8px; }
  .al-badge { font-size: 7px; padding: 1px 4px; }
  .al-badge--q { width: 14px; height: 14px; font-size: 8px; }

  .ald-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .ald-gallery { border-radius: 0; margin: 0 -12px; }
  .ald-title { font-size: 18px; }
  .ald-price { font-size: 26px; }
  .ald-stock { font-size: 14px; }
  .ald-shipping { font-size: 13px; }
  .ald-seller { font-size: 13px; }
  .ald-views { font-size: 11px; }
  .ald-desc-body {
    font-size: 15px;
    line-height: 1.8;
  }
  .ald-desc-body h2 {
    font-size: 16px;
  }
  .ald-desc-body img {
    border-radius: 6px;
    margin: 0.8em auto;
  }
}

/* Small mobile (4 columns tighter) */
@media (max-width: 400px) {
  .alley-grid {
    gap: 4px;
  }
  .al-card-body { padding: 3px 5px 5px; }
  .al-card-title { font-size: 9px; }
  .al-card-price { font-size: 10px; }
}

/* ═══ 4D PORTAL STRIP ═══ */
.alley-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 0;
}
.alley-strip::-webkit-scrollbar { display: none; }
.alley-strip .al-card {
  flex-shrink: 0;
  width: 140px;
}
