/* ============================
   DigiStreet Market 专属样式
   ============================ */

/* 主体结构 */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0rem 1rem;
  min-height: calc(100vh - 140px); /* 留出导航与页脚空间 */
}

/* 顶部标题与发布按钮 */
.market-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.market-hero h2 {
  font-size: 2rem;
  color: var(--text);
  margin-bottom: 1rem;
}

/* ============================
   市场卡片布局（替代表格）
   ============================ */

.market-grid-section {
  width: 100%;
  max-width: 1100px;
  display: flex;
  justify-content: center;
}

.market-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
  width: 100%;
  padding: 1rem;
  justify-items: stretch;
}

.market-card {
  background: rgba(255,255,255,0.10);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.market-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.market-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.market-card-body {
  padding: 0.8rem 1rem;
}

.market-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.market-card-price {
  font-size: 1.1rem;
  font-weight: bold;
  color: #7cd9ff;
  margin-bottom: 0.4rem;
}

.market-card-meta {
  font-size: 0.85rem;
  color: #ccc;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.market-card-tags {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tag {
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

/* 商品表格部分 */
.market-table-section {
  width: 100%;
  max-width: 900px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.market-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
}

.market-table thead {
  background: rgba(255, 255, 255, 0.15);
}

.market-table th,
.market-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.market-table th {
  font-weight: 600;
  font-size: 1rem;
}

.market-table tr:hover {
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.img-cell {
  text-align: center;
  width: 80px;
}

/* 使用全局 modal 基线，这里只加淡入动画 */
.modal {
  animation: fadeIn 0.3s ease;
}

/* 列表三大模块的详情 / 发布弹窗：在全局基线之上把宽度调大 */
#itemModal .modal-content,
#roomModal .modal-content,
#vehicleModal .modal-content,
#postModal .modal-content,
#postLifeModal .modal-content,
#postRoomModal .modal-content,
#postVehicleModal .modal-content {
  max-width: 600px;         /* 比基线 480px 更宽 */
  text-align: center;       /* 如果你需要所有这些弹窗居中排版 */
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);  /* 可选：稍微比基线更重一点 */
}

/* Second-hand: constrain Post Item modal height so it doesn't overflow viewport */
#postModal .modal-content {
  max-height: 90vh;      /* 最高占视口高度的 90% */
  overflow-y: auto;      /* 内容太多时在弹窗内部滚动 */
  margin: 4vh auto;      /* 上下留一点空间 */
}

/* Life sharing: constrain Post Life modal height so it doesn't overflow viewport */
#postLifeModal .modal-content {
  max-height: 90vh;
  overflow-y: auto;
  margin: 4vh auto;
}

@media (max-width: 600px) {
  #postModal .modal-content,
  #postLifeModal .modal-content {
    max-height: 88vh;
    padding: 1.4rem 1.1rem;
  }
}

/* 商品详情弹窗内容 */
.modal-content img {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.modal-meta p {
  margin: 0.4rem 0;
  font-size: 0.95rem;
  color: #ddd;
}

/* ==========================
   Detail Contact (LINE) UI
   ========================== */

/* Wrapper inserted in market.html inside the shared detail modal */
.detail-contact {
  margin: 0.8rem 0;
  text-align: left;
}

#dsDetailContactHint {
  display: none;
  font-size: 0.95rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

#dsDetailMessageDraft {
  display: none;
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.35;
  resize: vertical;
}

/* Button row (works with existing .btn-global baseline) */
.detail-contact > div:last-child {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center; /* center buttons on desktop/TV */
  align-items: center;
}

/* Make the two buttons a bit more compact so they can sit side-by-side more often */
#dsDetailCopyMessage.btn-global,
#dsDetailContactLink.btn-global {
  padding: 0.55rem 1.05rem;
  font-size: 0.95rem;
  min-width: 160px;
}

/* Prevent buttons from stretching full width when wrapped */
#dsDetailCopyMessage,
#dsDetailContactLink {
  flex: 0 1 190px;
}

#dsDetailCopyMessage {
  display: none;
}

#dsDetailContactLink {
  display: none;
}

/* Ensure the <a> looks and behaves like a button when shown */
#dsDetailContactLink.btn-global {
  display: none;
  align-items: center;
  justify-content: center;
}

@media (max-width: 600px) {
  #dsDetailMessageDraft {
    font-size: 0.9rem;
  }
  #dsDetailCopyMessage.btn-global,
  #dsDetailContactLink.btn-global {
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    min-width: 140px;
  }

  #dsDetailCopyMessage,
  #dsDetailContactLink {
    flex: 0 1 170px;
  }
}

/* 平台角色说明（平台仅为信息桥梁）弱化一点 */

.modal-meta p.platform-note {
  font-size: 0.85rem;
  color: #e32828;
}

/* ==========================
   Item detail modal tweaks
   ========================== */

/* 给商品详情弹窗顶部多一点空间，避免关闭按钮压在图片上 */
#itemModal .modal-content {
  padding-top: 2.4rem;
}

/* 让图片轮播略微离顶部远一点（特别是手机端） */
#itemModal .carousel-container {
  margin-top: 0.6rem;
  margin-bottom: 1rem;
}

/* 商品名与价格之间增加一点垂直间距，阅读更舒适 */
#itemModal h3,
#itemModal .modal-title {
  margin-top: 1rem;
  margin-bottom: 0.2rem;
}

#itemModal #modalItemPrice,
#itemModal .modal-item-price,
#itemModal .modal-price {
  margin-top: 0.2rem;
  margin-bottom: 0.2rem;
}

/* 发布商品弹窗表单 */
#postForm {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 1rem;
}

#postForm input,
#postForm textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: inherit;
}

/* Transparent Selects */
select.filter-select,
#postForm select {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: inherit;
  appearance: none;
}

/* 自定义文件上传按钮 */
.file-label {
  display: inline-block;
  align-self: center;
  padding: 0.6rem 1.4rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  color: var(--text);
  cursor: pointer;
  transition: all 0.25s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.file-label:hover {
  background: var(--secondary);
  transform: translateY(-2px);
}

/* 居中发布按钮 */
#postForm button {
  align-self: center;
  margin-top: 1rem;
}

/* 动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* 页脚位置固定到底部 */
footer {
  position: relative;
  bottom: 0;
  width: 100%;
  margin-top: 2rem;
}

/* ==========================
   Carousel Styles
   ========================== */
.carousel-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.carousel {
  display: flex;
  transition: transform 0.4s ease;
}

.carousel-img {
  width: 100%;
  height: 260px;
  object-fit: contain;
  flex-shrink: 0;
  display: none;
  background: rgba(0,0,0,0.5);
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.4);
  border: none;
  color: var(--text);
  font-size: 2rem;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  z-index: 10;
  border-radius: 6px;
}

.carousel-btn.prev { left: 6px; }
.carousel-btn.next { right: 6px; }

.load-more-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 2rem 0;
}

/* Upload Preview */
.preview-wrap {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.4rem;
  justify-content: center;
}

.preview-thumb {
  width: 70px;
  height: 70px;
  border-radius: 6px;
  object-fit: cover;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
}

.preview-delete {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: #ff6b6b;
  cursor: pointer;
}
.market-card.sold {
  opacity: 0.45;
  filter: grayscale(60%);
  position: relative;
  pointer-events: none;
}

.market-card.sold::after {
  content: "SOLD";
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255,0,0,0.75);
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--text);
  font-weight: bold;
  font-size: 0.9rem;
  letter-spacing: 1px;
  z-index: 5;
}

/* Prevent hover effects on SOLD items */
.market-card.sold:hover {
  transform: none !important;
  box-shadow: none !important;
  cursor: default !important;
}

/* Rent Room: constrain Post Room modal height so it doesn't overflow viewport */
#postRoomModal .modal-content {
  max-height: 90vh;      /* 最多占视口高度的 90% */
  overflow-y: auto;      /* 内容太多时在弹窗内部滚动 */
  margin: 4vh auto;      /* 上下留一点空间 */
}

@media (max-width: 600px) {
  #postRoomModal .modal-content {
    max-height: 88vh;
    padding: 1.4rem 1.1rem; /* 手机上稍微收紧内边距 */
  }
}

/* Rent scooter: constrain Post Vehicle modal height so it doesn't overflow viewport */
#postVehicleModal .modal-content {
  max-height: 90vh;      /* 最多占视口高度的 90% */
  overflow-y: auto;      /* 内容太多时在弹窗内部滚动 */
  margin: 4vh auto;      /* 上下留一点空间 */
}

@media (max-width: 600px) {
  #postVehicleModal .modal-content {
    max-height: 88vh;
    padding: 1.4rem 1.1rem; /* 手机上稍微收紧内边距 */
  }
}

@media (min-width: 1024px) {
  .market-card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}