/* ============================================================
   咖啡豆袋展示平台 · 用户端样式
   低饱和大地色 + 衬线标题，整体克制、温润、有质感
   ============================================================ */
:root {
  --bg:        #f5efe6;
  --bg-soft:   #efe7da;
  --surface:   #ffffff;
  --ink:       #2f241b;
  --ink-soft:  #6b5a4b;
  --ink-faint: #9c8a78;
  --brand:     #4a3527;      /* 咖啡深棕 */
  --brand-2:   #7a5a3e;
  --accent:    #b9804a;      /* 焦糖琥珀 */
  --accent-2:  #d9a86c;
  --line:      #e6dccd;
  --danger:    #b0493c;
  --ok:        #3f7d4e;
  --shadow:    0 10px 30px rgba(74, 53, 39, .10);
  --shadow-sm: 0 4px 14px rgba(74, 53, 39, .08);
  --radius:    16px;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --sans:  "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.container { width: min(1200px, 92%); margin: 0 auto; }

/* ---------------- 顶部导航 ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(245, 239, 230, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex; align-items: center; gap: 24px;
  height: 72px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff;
  font-size: 20px; box-shadow: var(--shadow-sm);
}
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--ink-faint); letter-spacing: 1.5px; }

.nav-search { flex: 1; max-width: 460px; margin-left: auto; }
.search-form {
  display: flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.search-form input {
  flex: 1; border: 0; outline: 0; padding: 10px 18px;
  font-size: 14px; background: transparent; color: var(--ink);
}
.search-form button {
  border: 0; background: var(--brand); color: #fff; cursor: pointer;
  padding: 0 20px; font-size: 14px; transition: background .2s;
}
.search-form button:hover { background: var(--brand-2); }

.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-admin {
  font-size: 13px; color: var(--ink-soft); padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 999px; transition: .2s;
}
.nav-admin:hover { border-color: var(--brand-2); color: var(--brand); }

/* 购物车按钮（抛物线动画落点） */
.cart-btn {
  position: relative; display: flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff; border: 0;
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
  font-size: 14px; transition: transform .15s, background .2s;
  box-shadow: var(--shadow-sm);
}
.cart-btn:hover { background: var(--brand-2); transform: translateY(-1px); }
.cart-btn .cart-count {
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
  transition: transform .2s;
}
.cart-btn .cart-count.bump { animation: bump .35s ease; }
@keyframes bump { 0%{transform:scale(1)} 40%{transform:scale(1.5)} 100%{transform:scale(1)} }

/* ---------------- 主视觉横幅 ---------------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(217,168,108,.28), transparent 60%),
    linear-gradient(135deg, var(--brand) 0%, #5a412c 60%, #6e5138 100%);
  color: #fbf6ee;
  padding: 74px 0 84px;
}
.hero::after {
  content: ""; position: absolute; right: -120px; top: -60px;
  width: 420px; height: 420px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 0 0 70px rgba(255,255,255,.04), 0 0 0 140px rgba(255,255,255,.03);
}
.hero-inner { position: relative; z-index: 2; max-width: 640px; }
.hero .eyebrow {
  font-size: 12px; letter-spacing: 3px; color: var(--accent-2);
  text-transform: uppercase; margin-bottom: 14px;
}
.hero h1 {
  font-family: var(--serif); font-size: clamp(32px, 5vw, 52px);
  font-weight: 700; line-height: 1.2; margin-bottom: 16px;
}
.hero p { color: rgba(251,246,238,.82); font-size: 16px; max-width: 520px; }
.hero .hero-stats { display: flex; gap: 36px; margin-top: 34px; }
.hero .stat b { display: block; font-family: var(--serif); font-size: 26px; color: var(--accent-2); }
.hero .stat span { font-size: 13px; color: rgba(251,246,238,.7); }

/* ---------------- 筛选栏 ---------------- */
.filter-bar {
  position: sticky; top: 72px; z-index: 60;
  background: rgba(245,239,230,.95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 14px 0;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
/* 类目筛选标签 */
.cat-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.cat-tab {
  padding: 7px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .18s; text-decoration: none;
}
.cat-tab:hover { border-color: var(--accent); color: var(--accent); }
.cat-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-label { font-size: 12px; color: var(--ink-faint); margin-right: 2px; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-soft); font-size: 13px;
  cursor: pointer; transition: .18s; white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--brand); }
.chip.active {
  background: var(--brand); color: #fff; border-color: var(--brand);
}
.chip.reset { color: var(--ink-faint); }
.filter-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.sort-select {
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
  background: var(--surface); color: var(--ink); font-size: 13px; outline: 0;
  cursor: pointer;
}
.result-count { font-size: 13px; color: var(--ink-faint); }

/* ---------------- 商品网格 ---------------- */
.section { padding: 44px 0 80px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 24px; margin-top: 28px;
}
.product-card {
  position: relative; background: var(--surface); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); transition: transform .25s, box-shadow .25s;
}
.product-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); }
.card-media { position: relative; aspect-ratio: 1 / 1; overflow: hidden; cursor: pointer; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.product-card:hover .card-media img { transform: scale(1.05); }
.stock-tag {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.92); color: var(--ink-soft);
  backdrop-filter: blur(4px);
}
.stock-tag.low { color: var(--danger); }
/* 库存为 0 时的待盘点遮罩 */
.soldout-mask {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
}
.soldout-box {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.soldout-txt {
  color: #fff; font-size: 15px; font-weight: 700; letter-spacing: 2px;
  padding: 8px 16px; border: 1.5px solid rgba(255,255,255,.85); border-radius: 999px;
  background: rgba(0,0,0,.35);
}
.want-btn {
  cursor: pointer; border: 0; border-radius: 999px;
  padding: 9px 30px; font-size: 14px; font-weight: 700; letter-spacing: 2px;
  color: var(--brand); background: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
  transition: transform .15s;
}
.want-btn:hover:not(:disabled) { transform: translateY(-2px); }
.want-btn.fed, .want-btn:disabled {
  cursor: not-allowed; color: #c9c9c9; background: #e8e8e8;
  box-shadow: none;
}
.product-card .add-btn:disabled { opacity: .45; cursor: not-allowed; }
.price-tag {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--brand); color: #fff;
}
.card-body { padding: 14px 16px 16px; }
.card-title { font-family: var(--serif); font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.card-subtitle { font-size: 12px; color: var(--ink-faint); margin-bottom: 10px; min-height: 18px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag-pill {
  font-size: 11px; color: var(--brand-2); background: var(--bg-soft);
  padding: 2px 8px; border-radius: 6px;
}
.card-foot { display: flex; align-items: center; justify-content: space-between; }
.card-stocktime { font-size: 11px; color: var(--ink-faint); }
.card-stocktime b { color: var(--ink-soft); font-weight: 600; }
.add-btn {
  border: 0; background: var(--accent); color: #fff; cursor: pointer;
  padding: 9px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; transition: .2s; box-shadow: var(--shadow-sm);
}
.add-btn:hover { background: var(--brand-2); transform: translateY(-1px); }
.add-btn:disabled { background: var(--ink-faint); cursor: not-allowed; }

/* 空态 */
.empty {
  text-align: center; padding: 80px 20px; color: var(--ink-faint);
  grid-column: 1 / -1;
}
.empty .empty-icon { font-size: 48px; margin-bottom: 14px; }

/* ---------------- 分页 ---------------- */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 44px; }
.pagination a, .pagination span {
  min-width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink-soft); font-size: 14px; transition: .18s;
}
.pagination a:hover { border-color: var(--accent); color: var(--brand); }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------------- 页脚 ---------------- */
.site-footer {
  border-top: 1px solid var(--line); padding: 34px 0;
  color: var(--ink-faint); font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
}
.site-footer b { color: var(--ink-soft); }

/* ---------------- 购物车 ---------------- */
.cart-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; }
.page-title { font-family: var(--serif); font-size: 28px; margin: 34px 0 6px; }
.page-sub { color: var(--ink-faint); margin-bottom: 26px; }
.cart-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.cart-item {
  display: flex; gap: 16px; padding: 16px; border-bottom: 1px solid var(--line);
  align-items: center;
}
.cart-item:last-child { border-bottom: 0; }
.cart-thumb { width: 84px; height: 84px; border-radius: 12px; overflow: hidden; flex-shrink: 0; }
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-info { flex: 1; min-width: 0; }
.cart-info .name { font-family: var(--serif); font-weight: 700; font-size: 15px; }
.cart-info .meta { font-size: 12px; color: var(--ink-faint); margin-top: 3px; }
.qty-ctl { display: flex; align-items: center; gap: 10px; }
.qty-ctl button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; font-size: 16px; color: var(--brand); transition: .15s;
}
.qty-ctl button:hover { background: var(--brand); color: #fff; }
.qty-ctl input { width: 44px; text-align: center; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.cart-price { text-align: right; min-width: 90px; }
.cart-price .sub { font-weight: 700; font-size: 15px; }
.cart-price .unit { font-size: 12px; color: var(--ink-faint); }
.cart-remove { background: none; border: 0; color: var(--ink-faint); cursor: pointer; font-size: 13px; }
.cart-remove:hover { color: var(--danger); }

.cart-summary {
  position: sticky; top: 88px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm);
}
.summary-title { font-family: var(--serif); font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.sum-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; color: var(--ink-soft); }
.sum-row.total { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 14px; font-size: 16px; color: var(--ink); font-weight: 700; }
.sum-row.total b { color: var(--accent); font-size: 24px; }
.checkout-btn {
  width: 100%; margin-top: 18px; padding: 14px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; transition: .2s;
}
.checkout-btn:hover { background: var(--brand-2); }
.empty-cart { text-align: center; padding: 70px 20px; color: var(--ink-faint); }
.empty-cart .big { font-size: 52px; margin-bottom: 14px; }
.empty-cart a { color: var(--accent); font-weight: 600; }

/* ---------------- 结算表单 ---------------- */
.checkout-wrap { max-width: 820px; margin: 0 auto; }
.form-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; margin-bottom: 24px; box-shadow: var(--shadow-sm);
}
.form-card h3 { font-family: var(--serif); font-size: 18px; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 13px; color: var(--ink-soft); }
.form-item input, .form-item textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  font-size: 14px; outline: 0; background: #fdfbf7; transition: border .2s;
}
.form-item input:focus, .form-item textarea:focus { border-color: var(--accent); }
.form-item textarea { resize: vertical; min-height: 74px; }
.submit-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow-sm);
}
.submit-bar .total-tip b { color: var(--accent); font-size: 22px; }
.btn-primary {
  background: var(--accent); color: #fff; border: 0; padding: 14px 34px;
  border-radius: 999px; font-size: 16px; font-weight: 700; cursor: pointer; transition: .2s;
}
.btn-primary:hover { background: var(--brand-2); }
.msg { margin-top: 14px; font-size: 14px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* ---------------- 下单成功 ---------------- */
.success-wrap { max-width: 640px; margin: 60px auto; text-align: center; }
.success-icon {
  width: 84px; height: 84px; margin: 0 auto 22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff; font-size: 40px; box-shadow: var(--shadow);
}
.order-no {
  font-family: var(--serif); font-size: 44px; font-weight: 700; letter-spacing: 6px;
  color: var(--brand); margin: 18px 0 6px;
}
.order-hint { color: var(--ink-faint); margin-bottom: 30px; }
.order-detail {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 24px; text-align: left; box-shadow: var(--shadow-sm); margin-bottom: 30px;
}
.order-detail .row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; }
.order-detail .row span { color: var(--ink-soft); }
.order-detail .row b { color: var(--ink); }
.success-actions { display: flex; gap: 14px; justify-content: center; }
.btn-ghost {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  padding: 12px 26px; border-radius: 999px; font-size: 14px; cursor: pointer; transition: .2s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--brand); }

/* ---------------- 飞入购物车飞行动画 ---------------- */
.flying-img {
  position: fixed; z-index: 9999; pointer-events: none;
  width: 70px; height: 70px; border-radius: 14px; object-fit: cover;
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
}

/* ---------------- Toast ---------------- */
#toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: var(--brand); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .3s; z-index: 1000;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .nav { flex-wrap: wrap; height: auto; padding: 12px 0; gap: 12px; }
  .nav-search { order: 3; flex-basis: 100%; max-width: none; }
  .filter-bar { position: static; }
  .cart-wrap { grid-template-columns: 1fr; }
  .cart-summary { position: static; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ==================== 手机端购物车优化 ==================== */
@media (max-width: 640px) {
  .page-title { font-size: 22px; margin-top: 22px; }
  .page-sub { margin-bottom: 16px; }

  /* 条目改为两行网格：缩略图+信息 / 数量+小计 */
  .cart-item {
    position: relative;
    display: grid;
    grid-template-columns: 72px 1fr;
    grid-template-areas:
      "thumb info"
      "qty   price";
    column-gap: 14px;
    row-gap: 12px;
    align-items: center;
    padding: 14px 14px 14px;
    padding-right: 48px; /* 给右上移除按钮留空间 */
  }
  .cart-thumb { grid-area: thumb; width: 72px; height: 72px; }
  .cart-info { grid-area: info; }
  .cart-info .name { font-size: 14px; line-height: 1.35; }
  .qty-ctl { grid-area: qty; gap: 8px; }
  .qty-ctl button { width: 34px; height: 34px; font-size: 18px; }
  .qty-ctl input { width: 46px; height: 34px; font-size: 14px; }
  .cart-price { grid-area: price; text-align: right; min-width: 0; }
  .cart-price .sub { font-size: 15px; }
  .cart-price .unit { font-size: 11px; margin-top: 2px; }

  /* 移除按钮：右上角 × 图标 */
  .cart-remove {
    position: absolute; top: 14px; right: 14px;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--bg); font-size: 0; color: var(--ink-faint);
  }
  .cart-remove::after { content: '×'; font-size: 18px; line-height: 1; }

  /* 结算栏吸底，简化间距、按钮加大 */
  .cart-summary {
    position: sticky; bottom: 10px; z-index: 6;
    padding: 14px 16px; border-radius: 16px;
    box-shadow: 0 -8px 24px rgba(0,0,0,.10);
  }
  .summary-title { font-size: 15px; margin-bottom: 6px; }
  .sum-row { padding: 6px 0; font-size: 13px; }
  .sum-row.total { margin-top: 6px; padding-top: 10px; }
  .sum-row.total b { font-size: 22px; }
  .checkout-btn { margin-top: 12px; padding: 13px; font-size: 16px; border-radius: 12px; }
}
