/* Marketplace Styles */
.marketplace-hero {
    background-color: #1a1a1a;
    padding: 60px 0;
    text-align: center;
    border-radius: 12px;
    margin: 20px auto;
    max-width: 1200px;
}

.marketplace-title {
    color: #b0b0b0;
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.marketplace-subtitle {
    color: #888888;
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto;
}

.products-section {
    padding: 40px 0;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    margin-bottom: 40px;
    color: #333;
    font-size: 2rem;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.product-card {
    background-color: #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.marketplace-hero-image {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
}
.product-image {
    height: 200px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2a2a2a;
}

.product-image img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}
.marketplace-hero-image img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
}
.product-info {
    padding: 20px;
}

.product-title {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #b0b0b0;
}

.product-description {
    color: #888888;
    font-size: 0.9rem;
    margin-bottom: 15px;
    line-height: 1.5;
}

.product-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.price-usd {
    font-size: 1.2rem;
    font-weight: bold;
    color: #4CAF50;
}

.price-token {
    font-size: 0.9rem;
    color: #888888;
}

.buy-button {
    width: 100%;
    padding: 12px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.buy-button:hover {
    background-color: #45a049;
}

/* Make redeem buttons visually consistent with buy buttons */
.redeem-button {
    width: 100%;
    padding: 12px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.redeem-button:hover {
    background-color: #45a049;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #1a1a1a;
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #888888;
    cursor: pointer;
}

.modal-title {
    text-align: center;
    margin-bottom: 30px;
    color: #b0b0b0;
}

.order-summary, .email-form, .payment-info {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #2a2a2a;
    border-radius: 8px;
}

.order-details p {
    margin: 10px 0;
    color: #b0b0b0;
}

.email-form p {
    margin-bottom: 15px;
    color: #888888;
}

#customer-email {
    width: 100%;
    padding: 12px;
    border: 1px solid #444;
    border-radius: 6px;
    background-color: #333;
    color: #b0b0b0;
    font-size: 1rem;
}

.qr-code-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#payment-qr-code {
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    width: 200px;
    height: 200px;
}

.payment-address {
    margin: 20px 0;
}

.address-copy {
    display: flex;
    margin-top: 10px;
}

#wallet-address {
    flex: 1;
    padding: 12px;
    border: 1px solid #444;
    border-radius: 6px 0 0 6px;
    background-color: #333;
    color: #b0b0b0;
    font-size: 0.9rem;
}

#copy-address {
    padding: 12px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
}

.payment-details p {
    margin: 10px 0;
    color: #b0b0b0;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.modal-actions button {
    width: 100%;
}
#confirm-payment-btn {
    background-color: #2196F3;
}
#confirm-payment-btn:hover {
    background-color: #1e88e5;
}
.modal-actions button {
    padding: 12px 30px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.modal-actions button:hover {
    background-color: #45a049;
}

.hidden {
    display: none;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
    
    .modal-content {
        width: 90%;
        margin: 10% auto;
    }
}

/* Wallet connect modal styles (ported from lottery.html inline styles) */
.connect-modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 1000; }
.connect-modal-open { overflow: hidden; }
.connect-modal .connect-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.connect-modal .connect-modal-content { position: relative; background: #141414; color: #fff; border-radius: 12px; width: 360px; max-width: 90vw; box-shadow: 0 12px 32px rgba(0,0,0,0.4); border: 1px solid #2a2a2a; }
.connect-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #2a2a2a; font-weight: 600; }
.connect-modal-close { background: transparent; border: none; color: #bbb; font-size: 18px; cursor: pointer; }
.connect-modal-close:hover { color: #fff; }
.connect-modal-body { padding: 16px; }
.connect-modal-tips { margin-top: 8px; font-size: 12px; color: #8a8a8a; text-align: center; }

/* Wallet status and cards styles */
.wallet-connection { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 8px; }
.wallet-status { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.wallet-status.connected { background: #103b28; color: #10b981; }
.wallet-status.not-connected { background: #3a1a1a; color: #f87171; }
.wallet-status .status-text { display: inline-block; }
.wallet-status .wallet-address { color: #9ca3af; }
.wallet-status-cards { display: flex; align-items: center; gap: 12px; }
.wallet-card { display: flex; align-items: center; gap: 10px; background: #1f2937; border: 1px solid #374151; border-radius: 10px; padding: 10px 12px; }
.wallet-connect-button { display: inline-flex; align-items: center; gap: 8px; background: #374151; color: #fff; border: none; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.wallet-connect-button.connected { background: #6b7280; }
.wallet-balance { color: #e5e7eb; }
.wallet-points-card .wallet-points { color: #c4b5fd; }
.connect-option { width: 100%; padding: 12px 14px; margin: 8px 0; border-radius: 10px; border: 1px solid #2a2a2a; background: #1b1b1b; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.connect-option:hover { background: #222; border-color: #3a3a3a; }
.connect-section-title { font-size: 14px; color: #9ca3af; margin: 6px 0 4px; }
.connect-list { display: flex; flex-direction: column; gap: 6px; }
/* Toast 样式 */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none; /* 允许点击穿透 */
}
.toast {
  min-width: 240px;
  max-width: 90vw;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  border-radius: 8px;
  padding: 12px 16px;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: auto; /* 单条 toast 可点击关闭 */
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast--success { background: #2fb344; }
.toast--info { background: #228be6; }
.toast--warning { background: #f59f00; }
.toast--error { background: #d9480f; }
.toast__close {
  margin-left: 12px;
  cursor: pointer;
  opacity: 0.9;
}
/* 在较小屏幕上更紧凑 */
@media (max-width: 480px) {
  .toast { font-size: 13px; padding: 10px 12px; }
}

/* Purchase History Styles - 现代化设计，参考edu模块风格 */
:root {
  --purchase-card: #12161c;
  --purchase-border: #1f2732;
  --purchase-text: #e7edf3;
  --purchase-muted: #8a9099;
  --purchase-primary: #4cd964;
  --purchase-primary-hover: #3db851;
}

.purchase-history-section { 
  padding: 40px 0; 
  max-width: 1200px; 
  margin: 0 auto; 
}

.purchase-history-section .container { 
  max-width: 960px; 
  margin: 0 auto; 
}

.purchase-history-section h2 { 
  text-align: center; 
  font-size: 2.4rem; 
  color: var(--purchase-text); 
  margin-bottom: 20px; 
  font-weight: 700;
  letter-spacing: -0.5px;
}

.purchase-history-list { 
  display: flex; 
  flex-direction: column; 
  gap: 14px; 
}

.purchase-item { 
  background: var(--purchase-card); 
  border: 1px solid var(--purchase-border); 
  border-radius: 14px; 
  padding: 18px 20px; 
  display: flex; 
  flex-direction: column; 
  gap: 14px; 
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.purchase-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(76, 217, 100, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.purchase-item .purchase-main { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 16px; 
  align-items: center; 
  margin-bottom: 4px;
}

.purchase-item .purchase-name { 
  color: var(--purchase-text); 
  font-weight: 700; 
  font-size: 16px;
  flex: 1;
  min-width: 200px;
}

.purchase-item .purchase-amount { 
  color: var(--purchase-primary); 
  font-weight: 700; 
  font-size: 16px;
  letter-spacing: 0.3px;
}

.purchase-item .purchase-time { 
  color: var(--purchase-muted); 
  font-size: 13px; 
  flex: 1;
  text-align: right;
}

.purchase-item .purchase-sub { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 16px; 
  align-items: center; 
  padding-top: 12px;
  border-top: 1px solid var(--purchase-border);
}

.purchase-status, .purchase-email, .purchase-tx { 
  color: var(--purchase-text); 
  font-size: 14px; 
  display: flex;
  align-items: center;
  gap: 6px;
}

.purchase-status {
  font-weight: 500;
}

.purchase-email {
  color: var(--purchase-muted);
}

.purchase-tx a {
  color: var(--purchase-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.purchase-tx a:hover {
  color: var(--purchase-primary-hover);
  text-decoration: underline;
}

.purchase-detail-btn, .update-info-btn { 
  padding: 8px 16px; 
  border-radius: 20px; 
  border: 1px solid var(--purchase-border); 
  background: transparent; 
  color: var(--purchase-text); 
  cursor: pointer; 
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.purchase-detail-btn:hover, .update-info-btn:hover { 
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--purchase-primary);
  color: var(--purchase-primary);
  transform: translateY(-1px);
}

.purchase-detail-btn {
  background: var(--purchase-primary);
  border-color: var(--purchase-primary);
  color: white;
}

.purchase-detail-btn:hover {
  background: var(--purchase-primary-hover);
  border-color: var(--purchase-primary-hover);
  color: white;
}

/* 加载更多按钮样式 */
#purchase-history-load-more {
  margin-top: 24px;
  padding: 20px 0;
  text-align: center;
  display: none;
}

#load-more-purchase-btn {
  padding: 12px 28px;
  border-radius: 24px;
  border: 1px solid var(--purchase-primary);
  background: transparent;
  color: var(--purchase-primary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  min-width: 140px;
  font-family: inherit;
}

#load-more-purchase-btn:hover {
  background: var(--purchase-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 217, 100, 0.3);
}

#load-more-purchase-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#load-more-purchase-btn:disabled:hover {
  background: transparent;
  color: var(--purchase-primary);
  box-shadow: none;
}

/* 全部加载完成提示 */
#purchase-history-all-loaded {
  padding: 16px 20px;
  margin-top: 8px;
  text-align: center;
  display: none;
}

#purchase-history-all-loaded div {
  color: var(--purchase-muted);
  font-size: 14px;
  font-weight: 500;
}

/* Detail Modal Overlay Styles (for showPurchaseDetail) */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none; align-items: center; justify-content: center; z-index: 1100; }
.modal-overlay.show { display: flex; }
.modal-overlay .modal { display: block !important; position: relative !important; width: 560px; max-width: 92vw; border-radius: 12px; background: #141414; color: #fff; box-shadow: 0 12px 32px rgba(0,0,0,0.4); border: 1px solid #2a2a2a; }
.modal__header { padding: 12px 16px; border-bottom: 1px solid #2a2a2a; font-weight: 600; }
.modal__content { padding: 16px; }
.modal__row { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: #e5e7eb; }
.modal__tip { margin-top: 8px; font-size: 13px; color: #9ca3af; }
.modal__footer { padding: 12px 16px; border-top: 1px solid #2a2a2a; display: flex; justify-content: flex-end; }
.modal__close { padding: 8px 12px; background: #374151; border: 1px solid #4b5563; border-radius: 8px; color: #fff; cursor: pointer; }
.modal__close:hover { background: #4b5563; }

@media (max-width: 768px) {
  .purchase-item {
    padding: 16px;
  }
  
  .purchase-item .purchase-main { 
    flex-direction: column; 
    align-items: flex-start;
    gap: 10px;
  }
  
  .purchase-item .purchase-name,
  .purchase-item .purchase-amount,
  .purchase-item .purchase-time {
    width: 100%;
    flex: none;
  }
  
  .purchase-item .purchase-time {
    text-align: left;
  }
  
  .purchase-item .purchase-sub { 
    flex-direction: column; 
    align-items: flex-start;
    gap: 10px;
  }
  
  .purchase-status, 
  .purchase-email, 
  .purchase-tx {
    width: 100%;
  }
  
  .purchase-detail-btn, 
  .update-info-btn {
    width: 100%;
    text-align: center;
  }
  
  #load-more-purchase-btn {
    width: 100%;
    max-width: 300px;
  }
}

/* Purchase History Empty Hint Card */
#purchase-history-hint {
  display: block;
  max-width: 960px;
  margin: 0 auto 20px;
  background: var(--purchase-card);
  border: 1px solid var(--purchase-border);
  border-radius: 14px;
  padding: 20px 24px;
  color: var(--purchase-muted);
  text-align: center;
  font-size: 14px;
  font-weight: 500;
}

@media (max-width: 768px) {
  #purchase-history-hint { 
    font-size: 13px; 
    padding: 16px 20px; 
    margin-bottom: 16px;
  }
}