/* ============================================================
   草履虫投资 — 书籍商城 (shop.bytalk.cn)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --fg: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }

/* ---- Navbar ---- */
.navbar {
  position: sticky; top: 0; z-index: 50; height: 56px;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1280px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
}
.nav-left { display: flex; align-items: center; gap: 10px; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-brand {
  display: flex; align-items: center; gap: 6px;
  text-decoration: none; color: var(--fg); font-weight: 700; font-size: 14px;
}
.nav-logo { font-size: 20px; }
.nav-title { display: none; }
@media (min-width: 640px) { .nav-title { display: inline; } }
.nav-sep { color: var(--muted); font-size: 14px; }
.nav-current { font-size: 14px; font-weight: 600; color: var(--primary); }
.nav-link { font-size: 13px; color: var(--muted); text-decoration: none; }
.nav-link:hover { color: var(--fg); }

/* Auth area — styled by bytalk-auth.js (shared component) */

/* ---- Page Header ---- */
.page-header { padding: 2.5rem 0 1.5rem; }
.page-title { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.25rem; }
.page-subtitle { font-size: 0.875rem; color: var(--muted); }

/* ---- Toolbar ---- */
.toolbar { margin-bottom: 1rem; }
.search-box { position: relative; max-width: 320px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: #9ca3af;
}
.search-input {
  width: 100%; height: 40px; padding: 0 12px 0 36px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: var(--font); color: var(--fg);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.search-input::placeholder { color: #9ca3af; }

/* ---- Category Tabs ---- */
.category-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 2rem; }
.cat-btn {
  padding: 6px 14px; border: none; border-radius: var(--radius);
  font-size: 12px; font-weight: 500; font-family: var(--font); cursor: pointer;
  background: #f3f4f6; color: var(--muted); transition: all 0.15s;
}
.cat-btn:hover { background: #e5e7eb; color: var(--fg); }
.cat-btn.active { background: var(--primary); color: #fff; }

/* ---- Product Grid ---- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 3rem;
}
@media (min-width: 768px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }

.product-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.product-card:hover { box-shadow: var(--shadow-hover); border-color: var(--primary); }

.card-cover {
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; position: relative; overflow: hidden;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; }

.card-badge-discount {
  position: absolute; top: 8px; right: 8px; padding: 2px 8px;
  border-radius: 4px; font-size: 10px; font-weight: 700;
  background: var(--danger); color: #fff; z-index: 1;
}

.card-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; }
.card-name {
  font-size: 14px; font-weight: 700; line-height: 1.4; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-author { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.card-price-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-price { font-size: 1.1rem; font-weight: 700; color: var(--danger); }
.card-original { font-size: 12px; color: var(--muted); text-decoration: line-through; }

.card-actions { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }

.btn-detail {
  width: 100%; padding: 8px 0; border: none; border-radius: 6px;
  font-size: 12px; font-weight: 600; font-family: var(--font); cursor: pointer;
  background: var(--primary); color: #fff; transition: background 0.15s;
}
.btn-detail:hover { background: var(--primary-hover); }

.btn-buy {
  display: block; width: 100%; padding: 8px 0; border: 1px solid #f97316;
  border-radius: 6px; font-size: 12px; font-weight: 600; font-family: var(--font);
  color: #ea580c; text-decoration: none; text-align: center; transition: background 0.15s;
}
.btn-buy:hover { background: #fff7ed; }

.btn-dl {
  display: block; width: 100%; padding: 8px 0; border: 1px solid var(--primary);
  border-radius: 6px; font-size: 12px; font-weight: 600; font-family: var(--font);
  color: var(--primary); text-decoration: none; text-align: center; transition: background 0.15s;
}
.btn-dl:hover { background: #eff6ff; }

/* ---- Empty & Loading ---- */
.empty-state, .loading-state { text-align: center; padding: 4rem 0; }
.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-title { font-size: 1.1rem; color: var(--muted); margin-bottom: 0.25rem; }
.empty-hint { font-size: 0.875rem; color: var(--muted); }
.loading-state { color: var(--muted); font-size: 0.95rem; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: 80; display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 1rem 1rem;
}
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
}
.modal-content {
  position: relative; background: #fff; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15); overflow: hidden;
  width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto;
  z-index: 1;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-title {
  font-size: 15px; font-weight: 700; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; flex: 1; margin-right: 12px;
}
.modal-close {
  background: none; border: none; font-size: 24px; color: #9ca3af;
  cursor: pointer; padding: 0 4px; flex-shrink: 0;
}
.modal-close:hover { color: var(--fg); }

.detail-body { padding: 20px; }

.detail-cover {
  aspect-ratio: 4/3; border-radius: var(--radius);
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem; overflow: hidden; margin-bottom: 16px;
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }

.detail-info-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 14px; }
.detail-info-row .label { color: var(--muted); }
.detail-info-row .value { color: var(--fg); }

.detail-tag { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.detail-tag.hot { background: #fef2f2; color: var(--danger); }
.detail-tag.rec { background: #eff6ff; color: var(--primary); }
.detail-tag.new { background: #ecfdf5; color: var(--success); }

.detail-price-row {
  display: flex; align-items: baseline; gap: 10px; margin: 16px 0;
}
.detail-price { font-size: 1.5rem; font-weight: 700; color: var(--danger); }
.detail-original { font-size: 14px; color: var(--muted); text-decoration: line-through; }
.detail-discount-badge {
  font-size: 12px; font-weight: 700; color: var(--danger);
  background: #fef2f2; padding: 2px 8px; border-radius: 4px;
}

.detail-actions { display: flex; flex-direction: column; gap: 8px; }
.btn-detail-buy {
  padding: 10px 0; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; font-family: var(--font);
  background: #f97316; color: #fff; text-decoration: none; text-align: center;
  transition: background 0.15s;
}
.btn-detail-buy:hover { background: #ea580c; }
.btn-detail-dl {
  padding: 10px 0; border: 1px solid var(--primary);
  border-radius: 8px; font-size: 14px; font-weight: 600; font-family: var(--font);
  color: var(--primary); text-decoration: none; text-align: center;
  transition: background 0.15s;
}
.btn-detail-dl:hover { background: #eff6ff; }
.detail-no-link { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 0; }

@media (max-width: 480px) {
  .page-title { font-size: 1.35rem; }
  .product-grid { grid-template-columns: 1fr; }
}
