/* ZW Technology - 1688 Sourcing Platform */
:root {
  --primary: #0f172a;
  --primary-light: #1e293b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-bg: #eff6ff;
  --text: #333;
  --text-light: #666;
  --text-muted: #9ca3af;
  --bg: #ffffff;
  --bg-light: #f7f8fa;
  --bg-dark: #eaecef;
  --success: #067d62;
  --success-bg: #e8f5f1;
  --danger: #dc2626;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", Monaco, Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.6;
  background: var(--bg-light);
}
a { text-decoration: none; color: inherit; transition: color 0.2s; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 1040px; }
.hidden { display: none !important; }

/* ============ Header ============ */
header {
  background: var(--primary);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 72px;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 40px; height: 40px; background: var(--accent);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
}
.logo-text {
  color: #fff; font-size: 20px; font-weight: 700; letter-spacing: 0.5px;
}
.logo-text span { color: var(--accent); }
.logo-sub { color: #94a3b8; font-size: 12px; font-weight: 500; margin-left: 8px; }

nav.topnav { display: flex; align-items: center; gap: 32px; }
nav.topnav a {
  color: #cbd5e1; font-size: 14px; font-weight: 500;
  padding: 8px 0; border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
nav.topnav a:hover { color: #fff; }
nav.topnav a.active { color: #fff; border-bottom-color: var(--accent); }

.user-badge {
  display: flex; align-items: center; gap: 8px;
  color: #cbd5e1; font-size: 13px;
}
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }

/* ============ Page Header / Sub-nav ============ */
.page-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff; padding: 48px 0 56px; position: relative; overflow: hidden;
}
.page-header::after {
  content: ''; position: absolute;
  top: -50%; right: -15%; width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(37,99,235,0.15) 0%, transparent 70%);
  border-radius: 50%;
}
.page-header .container { position: relative; z-index: 1; }
.page-header h1 {
  font-size: 36px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.5px;
}
.page-header h1 span { color: var(--accent); }
.page-header p { color: #b0bec5; font-size: 15px; }

/* ============ Tab panels ============ */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.content { padding: 40px 0 80px; }

/* ============ Search forms ============ */
.search-form {
  display: grid; grid-template-columns: 1fr 140px auto; gap: 10px;
  max-width: 760px; margin: -32px auto 32px;
  background: #fff; padding: 16px; border-radius: 12px;
  box-shadow: var(--shadow-lg); position: relative; z-index: 2;
}
.search-form input, .search-form select, .image-actions select,
.addr-grid input, .opt-row select, .opt-row input, .qty {
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: #fff; color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s; font-size: 14px;
}
.search-form input:focus, .search-form select:focus,
.addr-grid input:focus, .opt-row select:focus, .opt-row input:focus, .qty:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.search-form button, .image-actions button, .btn-primary {
  padding: 12px 24px; border: none; background: var(--accent); color: #fff;
  border-radius: var(--radius); font-weight: 600; font-size: 14px;
  transition: background 0.2s, transform 0.1s;
}
.search-form button:hover, .image-actions button:hover:not(:disabled), .btn-primary:hover { background: var(--accent-dark); }
.search-form button:active { transform: translateY(1px); }
.image-actions button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ Image dropzone ============ */
.image-form { max-width: 720px; margin: -32px auto 32px; position: relative; z-index: 2; }
.dropzone {
  display: block; position: relative;
  border: 2px dashed var(--border-strong); border-radius: 12px;
  padding: 56px 24px; text-align: center; cursor: pointer;
  background: #fff; box-shadow: var(--shadow);
  transition: all 0.2s;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent); background: var(--accent-bg);
}
.dropzone-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  background: var(--accent-bg); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--accent); font-weight: 300;
}
.dropzone-text { font-size: 16px; color: var(--text); margin-bottom: 6px; font-weight: 500; }
.dropzone-hint { font-size: 13px; color: var(--text-light); }
#img-preview {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; padding: 16px; background: #fff; border-radius: 12px;
}
.image-actions {
  display: flex; gap: 12px; justify-content: center; margin-top: 20px;
}

/* ============ Status ============ */
.status {
  max-width: 760px; margin: 0 auto 24px; text-align: center;
  color: var(--text-light); font-size: 14px; min-height: 22px;
}
.status.loading::after { content: "…"; animation: dots 1.2s infinite; }
.status.error { color: var(--danger); }
.status.ok { color: var(--success); }
@keyframes dots { 0%,20%{content:""} 40%{content:"·"} 60%{content:"··"} 80%,100%{content:"···"} }

/* ============ Results grid ============ */
.results-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px; margin-top: 8px;
}
.item {
  background: #fff; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex; flex-direction: column;
}
.item:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.item-img {
  aspect-ratio: 1; background: var(--bg-dark); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.item-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.item:hover .item-img img { transform: scale(1.04); }
.item-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.item-title {
  font-size: 13px; line-height: 1.4; color: var(--text); min-height: 36px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item-price {
  color: var(--accent); font-size: 22px; font-weight: 700;
}
.item-meta {
  font-size: 12px; color: var(--text-light);
  display: flex; justify-content: space-between;
}
.item-tags { display: flex; flex-wrap: wrap; gap: 4px; min-height: 22px; }
.tag {
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  background: var(--bg-dark); color: var(--text-light); font-weight: 500;
}
.tag.jxhy { background: var(--accent-bg); color: var(--accent); }
.tag.onepsale { background: #ecfdf5; color: var(--success); }
.tag.years { background: #fff7ed; color: #c2410c; }
.item-actions {
  display: flex; gap: 8px; margin-top: auto; padding-top: 10px;
  border-top: 1px solid var(--border); align-items: center;
}
.item-actions a {
  font-size: 12px; color: var(--text-light);
}
.item-actions a:hover { color: var(--accent); }
.item-actions .spacer { flex: 1; }
.item-actions .add-cart {
  font-size: 12px; color: var(--accent); font-weight: 600;
  background: none; border: none; padding: 4px 8px; border-radius: 4px;
}
.item-actions .add-cart:hover { background: var(--accent-bg); }
.item-actions .add-cart[data-in="true"] { color: var(--success); }

/* ============ Selection panel ============ */
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 40px; }
.sidebar {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); height: fit-content; font-size: 14px;
}
.side-section { margin-bottom: 24px; }
.side-section:last-child { margin-bottom: 0; }
.side-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); margin-bottom: 10px; font-weight: 600;
}
.side-list { list-style: none; }
.side-list li { margin-bottom: 2px; }
.side-list a {
  display: block; padding: 8px 12px; border-radius: 6px;
  color: var(--text); font-size: 14px; transition: background 0.15s;
}
.side-list a:hover { background: var(--bg-light); }
.side-list a.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

.main { min-width: 0; }
.page-head { margin-bottom: 24px; }
.page-head h2 {
  font-size: 24px; font-weight: 700; margin-bottom: 6px; color: var(--primary);
}
.page-meta { color: var(--text-light); font-size: 13px; }
.page-meta .count { color: var(--accent); font-weight: 600; }

.products { display: flex; flex-direction: column; gap: 20px; }
.product {
  display: grid; grid-template-columns: 140px 1fr; gap: 24px;
  padding: 24px; background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); transition: box-shadow 0.2s;
}
.product:hover { box-shadow: var(--shadow-lg); }
.product.decided { border-left: 4px solid var(--success); }
.product-main { min-width: 0; }
.product-img {
  width: 140px; height: 140px; border-radius: var(--radius);
  overflow: hidden; background: var(--bg-dark);
}
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-code {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);
  background: var(--bg-light); padding: 2px 8px; border-radius: 4px;
}
.product-title-cn { font-size: 17px; font-weight: 600; margin: 8px 0 4px; color: var(--primary); }
.product-title-en { color: var(--text-light); font-size: 13px; margin-bottom: 14px; }
.decided-badge {
  display: inline-block; color: var(--success); background: var(--success-bg);
  padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; margin-left: 8px;
}

.suppliers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.supplier {
  position: relative; padding: 14px; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; transition: all 0.15s;
  background: #fff;
}
.supplier:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.supplier.selected { border-color: var(--accent); border-width: 2px; background: var(--accent-bg); padding: 13px; }
.supplier .rank {
  position: absolute; top: -8px; left: 12px; background: #fff;
  padding: 0 8px; font-size: 11px; color: var(--text-muted); font-family: var(--font-mono);
  border: 1px solid var(--border); border-radius: 4px;
}
.supplier-top { display: flex; gap: 10px; margin-bottom: 8px; }
.supplier-img { width: 56px; height: 56px; border-radius: 6px; overflow: hidden; background: var(--bg-dark); flex-shrink: 0; }
.supplier-img img { width: 100%; height: 100%; object-fit: cover; }
.supplier-info { min-width: 0; flex: 1; }
.supplier-title {
  font-size: 13px; line-height: 1.4; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 4px;
}
.supplier-price { color: var(--accent); font-size: 16px; font-weight: 700; }
.supplier-meta { font-size: 12px; color: var(--text-light); display: flex; flex-wrap: wrap; gap: 4px 10px; }

.empty {
  text-align: center; color: var(--text-muted); padding: 80px 20px;
  font-size: 15px; background: #fff; border-radius: var(--radius);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }

/* ============ Cart / Checkout ============ */
.checkout-layout {
  display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start;
}
.section-card {
  background: #fff; border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); margin-bottom: 20px;
}
.section-title {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 16px; font-weight: 700; color: var(--primary);
  margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.link-btn { background: none; border: none; color: var(--accent); font-size: 13px; font-weight: 500; }
.link-btn:hover { color: var(--accent-dark); }

.cart-list { display: flex; flex-direction: column; gap: 10px; }
.cart-item {
  display: grid; grid-template-columns: 24px 60px 1fr 80px 80px 28px; gap: 12px;
  padding: 12px; border: 1px solid var(--border); border-radius: 6px; align-items: center;
  transition: border-color 0.15s;
}
.cart-item:hover { border-color: var(--border-strong); }
.cart-item.unchecked { opacity: 0.4; }
.cart-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; background: var(--bg-dark); }
.cart-item .cart-title {
  font-size: 13px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cart-item .cart-offer { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cart-item input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.cart-item .qty {
  width: 100%; padding: 6px 8px; text-align: center; font-size: 13px;
}
.cart-item .cart-price { color: var(--accent); font-weight: 700; font-size: 15px; text-align: right; }
.cart-item .remove {
  color: var(--text-muted); background: none; border: none;
  font-size: 18px; width: 28px; height: 28px; border-radius: 4px;
}
.cart-item .remove:hover { color: var(--danger); background: #fef2f2; }

.addr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.addr-grid .span-2 { grid-column: span 2; }
.opt-row { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.opt-row label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-light); font-weight: 500; }

.summary { position: sticky; top: 96px; }
.summary-list {
  display: flex; flex-direction: column; gap: 8px;
  font-size: 13px; margin-bottom: 16px; max-height: 240px; overflow-y: auto;
}
.summary-list .row { display: flex; justify-content: space-between; gap: 12px; }
.summary-list .row .name {
  color: var(--text-light); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.summary-list .row .val { color: var(--text); font-weight: 500; white-space: nowrap; }
.summary-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 0; border-top: 2px solid var(--border); margin-top: 12px;
}
.summary-total > span:first-child { color: var(--text-light); font-size: 14px; }
.summary-amount {
  color: var(--accent); font-weight: 700; font-size: 28px;
}
.btn-accent {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; margin-top: 10px;
  background: var(--accent); color: #fff; transition: background 0.15s;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); }
.btn-accent:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary {
  width: 100%; padding: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: 14px; font-weight: 600; margin-top: 10px;
  background: #fff; color: var(--text); transition: background 0.15s;
}
.btn-secondary:hover { background: var(--bg-light); }
.order-result {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-light); padding: 12px; border-radius: 6px;
  max-height: 280px; overflow: auto; margin-top: 12px;
  white-space: pre-wrap; word-break: break-all; color: var(--text);
}

/* ============ Footer ============ */
footer {
  background: var(--primary); color: #94a3b8;
  padding: 32px 0; margin-top: 64px; font-size: 13px;
}
footer .container { display: flex; justify-content: space-between; align-items: center; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .search-form { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .product { grid-template-columns: 1fr; }
  .product-img { width: 100%; height: 200px; }
  .suppliers { grid-template-columns: 1fr; }
  .checkout-layout { grid-template-columns: 1fr; }
  .addr-grid { grid-template-columns: 1fr 1fr; }
  .addr-grid .span-2 { grid-column: span 2; }
  .page-header h1 { font-size: 28px; }
  nav.topnav { gap: 16px; font-size: 13px; }
  .logo-sub { display: none; }
}
