/* ==========================================================================
   TW AGRO 电商前端样式
   ========================================================================== */
:root {
  --green: #166534;
  --green-dark: #14532d;
  --green-light: #dcfce7;
  --red: #c2410c;
  --red-strong: #b91c1c;
  --ink: #1c1917;
  --ink-2: #57534e;
  --ink-3: #a8a29e;
  --line: #e7e5e4;
  --bg: #f5f5f4;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 8px 24px -12px rgba(28, 25, 23, .18);
  --max: 720px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
               "Hiragino Sans CNS", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

.wrap { max-width: var(--max); margin: 0 auto; background: var(--bg); min-height: 100vh; }

/* ------------------------------------------------------------- 顶部 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: #fff;
}
.brand { font-size: 19px; font-weight: 800; letter-spacing: .14em; }
.brand small { display: block; font-size: 11px; font-weight: 400; letter-spacing: .08em; opacity: .78; }

.topbar .admin-link {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .45);
  opacity: .9;
}

/* ------------------------------------------------------------- 轮播 */
.banner {
  position: relative;
  overflow: hidden;
  background: #e7e5e4;
}
.banner-track { display: flex; transition: transform .45s ease; }
.banner-slide { flex: 0 0 100%; }
.banner-slide img { width: 100%; height: 220px; object-fit: cover; }
.banner-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.banner-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  transition: width .25s;
}
.banner-dots i.on { width: 18px; border-radius: 4px; background: #fff; }

/* ------------------------------------------------------------- 商品网格 */
.goods-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 8px;
}
@media (min-width: 720px) {
  .goods-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.goods-card {
  display: block;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease;
}
.goods-card:active { transform: scale(.985); }
.goods-card .thumb { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #f0f0ef; }
.goods-card .body { padding: 10px 12px 14px; }
.goods-card .name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
}
.goods-card .sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.goods-card .meta {
  margin-top: 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.goods-card .price { color: var(--red-strong); font-weight: 800; font-size: 16px; }
.goods-card .sale { font-size: 11px; color: var(--ink-3); }

.list-footer {
  padding: 18px 16px 40px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}
.btn-more {
  padding: 10px 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
}

/* ------------------------------------------------------------- 详情 */
.nav-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(20, 83, 45, .96);
  color: #fff;
  backdrop-filter: blur(6px);
}
.nav-header .home {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
}
.nav-header .title { font-size: 15px; font-weight: 600; }

.swiper { position: relative; overflow: hidden; background: #f0f0ef; }
.swiper-track { display: flex; transition: transform .3s ease; }
.swiper-track img { flex: 0 0 100%; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.swiper-count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: 12px;
}
.swiper-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.swiper-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .5);
}
.swiper-dots i.on { background: #fff; width: 16px; border-radius: 3px; }

.panel {
  background: #fff;
  margin-bottom: 10px;
  padding: 16px;
}
.panel.flush { padding: 0; }

.price-section { display: flex; align-items: baseline; gap: 10px; }
.current-price { font-size: 26px; font-weight: 800; color: var(--red-strong); letter-spacing: -.02em; }
.title-section { margin-top: 8px; }
.goods-title { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.5; }
.goods-subtitle { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
.sales { margin-top: 8px; font-size: 12px; color: var(--ink-3); }

.section-title { font-size: 14px; font-weight: 700; color: var(--ink); margin: 0 0 10px; }
.spec-group + .spec-group { margin-top: 14px; }
.spec-list { display: flex; flex-wrap: wrap; gap: 10px; }
.spec-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fafaf9;
  font-size: 13px;
  transition: all .15s;
}
.spec-item img { width: 34px; height: 34px; border-radius: 7px; object-fit: cover; }
.spec-item.active {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 600;
}

.goods-num { display: flex; align-items: center; justify-content: space-between; }
.goods-num-title { font-size: 14px; font-weight: 700; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button {
  width: 38px;
  height: 34px;
  font-size: 17px;
  color: var(--ink-2);
  background: #fafaf9;
}
.stepper button:disabled { color: #d6d3d1; cursor: not-allowed; }
.stepper input {
  width: 48px;
  height: 34px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: center;
  background: #fff;
  outline: none;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.rich-content { font-size: 14px; color: var(--ink-2); line-height: 1.85; }
.rich-content h3 { font-size: 14px; color: var(--ink); margin: 18px 0 6px; }
.rich-content h3:first-child { margin-top: 0; }
.rich-content p { margin: 0 0 12px; }

/* 订单表单 */
.form-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.form-row:last-of-type { border-bottom: 0; }
.form-row > label { flex: 0 0 74px; font-size: 14px; color: var(--ink-2); }
.form-row .field { flex: 1; min-width: 0; }
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf9;
  outline: none;
  transition: border-color .15s, background .15s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: var(--green); background: #fff; }
.form-row textarea { min-height: 76px; resize: vertical; }

.delivery-tabs { display: flex; gap: 10px; padding: 4px 0 14px; }
.delivery-tabs button {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fafaf9;
  font-size: 14px;
  color: var(--ink-2);
  transition: all .15s;
}
.delivery-tabs button.active {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 700;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
  box-shadow: 0 10px 20px -12px rgba(22, 101, 52, .9);
}
.btn-primary:disabled { opacity: .6; }

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  transition: transform .25s ease;
  max-width: var(--max);
  margin: 0 auto;
}
.bottom-bar.hide { transform: translateY(120%); }
.bottom-bar .btn-primary { padding: 13px; }
.page-detail { padding-bottom: 88px; }

/* ------------------------------------------------------------- 订单完成 */
.over-page { padding: 20px 16px 60px; }
.thanks-card {
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.thanks-card .check {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  display: grid;
  place-items: center;
  font-size: 26px;
}
.thanks-card h1 { margin: 0; font-size: 18px; font-weight: 700; }
.thanks-card .order-no { margin-top: 8px; font-size: 13px; opacity: .85; letter-spacing: .04em; }

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table td { padding: 8px 0; vertical-align: top; border-bottom: 1px dashed var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table td:last-child { text-align: right; }
.table .k { color: var(--ink-2); width: 40%; }
.table .total { font-size: 17px; font-weight: 800; color: var(--red-strong); }

.order-item { display: flex; gap: 12px; padding: 2px 0 14px; border-bottom: 1px dashed var(--line); }
.order-item img { width: 68px; height: 68px; border-radius: 9px; object-fit: cover; flex: 0 0 auto; }
.order-item .info { flex: 1; min-width: 0; }
.order-item .t { font-size: 14px; font-weight: 600; line-height: 1.45; }
.order-item .s { margin-top: 4px; font-size: 12px; color: var(--ink-3); }
.order-item .p { margin-top: 6px; font-size: 13px; color: var(--red-strong); font-weight: 700; }

.status-flag {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 600;
}

.empty { padding: 80px 20px; text-align: center; color: var(--ink-3); }

/* ------------------------------------------------------------- 通用 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 10px);
  z-index: 90;
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(28, 25, 23, .88);
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.loading-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(1px);
}
.loading-mask.show { display: grid; }
.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(22, 101, 52, .18);
  border-top-color: var(--green);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.preview {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, .92);
  padding: 20px;
}
.preview.show { display: grid; }
.preview img { max-width: 100%; max-height: 88vh; object-fit: contain; }
.preview .close {
  position: absolute;
  top: 16px;
  right: 18px;
  font-size: 26px;
  color: #fff;
  opacity: .8;
}

.skeleton {
  background: linear-gradient(90deg, #f0f0ef 25%, #e7e5e4 37%, #f0f0ef 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* 取货门市信息提示（7-11 / 自有门市） */
.store-hint {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: #57534e;
  background: #f5f5f4;
  border-left: 3px solid #166534;
  border-radius: 0 6px 6px 0;
  padding: 6px 10px;
  display: none;
}
.store-hint:not(:empty) { display: block; }

/* 取货门市搜索框（门市多时显示） */
.store-search {
  width: 100%;
  margin-bottom: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf9;
  font-size: 14px;
  outline: none;
}
.store-search:focus { border-color: var(--green); background: #fff; }
.store-search::placeholder { color: #a8a29e; }


/* Line 宣传区块总容器 */
.line-promo-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0 16px 0;
  font-family: system-ui, -apple-system, "Microsoft JhengHei", sans-serif;
}

/* 左侧主体容器 */
.promo-main {
  background-color: #555555;
  color: #ffffff;
  padding: 24px 16px;
  border-radius: 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.promo-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 14px 0;
  line-height: 1.4;
  letter-spacing: 0.5px;
}

.promo-sub {
  font-size: 14px;
  color: #e2e8f0;
  margin: 0 0 20px 0;
  line-height: 1.6;
  max-width: 90%;
}

.promo-btn-wrap {
  width: 100%;
}

/* 绿色加好友按钮 */
.btn-line-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #10b981;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 20px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  transition: background-color 0.2s, transform 0.1s;
}

.btn-line-add:active {
  background-color: #059669;
  transform: scale(0.98);
}

.btn-line-add .icon-arrow {
  margin-left: 6px;
  font-style: normal;
}

/* 右侧侧边栏（二维码与承诺） */
.promo-side {
  display: flex;
  flex-direction: row;
  gap: 12px;
}

/* 二维码区域 */
.qr-box {
  background-color: #c2a894;
  color: #ffffff;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.qr-img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  background-color: #ffffff;
  padding: 4px;
  border-radius: 4px;
}

.line-id {
  font-size: 15px;
  font-weight: 600;
  margin-top: 8px;
  letter-spacing: 0.5px;
}

/* 本店承诺区域 */
.promise-box {
  background-color: #3b3b3b;
  color: #ffffff;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.promise-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.promise-box p {
  font-size: 12px;
  color: #d1d5db;
  margin: 3px 0;
  line-height: 1.4;
}

/* 电脑/平板等宽屏适配（左右双栏） */
@media (min-width: 640px) {
  .line-promo-card {
    flex-direction: row;
  }
  .promo-side {
    flex-direction: column;
    width: 220px;
  }
  .promo-title {
    font-size: 22px;
  }
}

/* 商品详情富文本（编辑器产出的内容） */
.rich-content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 12px 0;
  display: block;
}
.rich-content h2 { font-size: 18px; color: var(--ink); margin: 20px 0 8px; }
.rich-content ul, .rich-content ol { margin: 0 0 12px; padding-left: 22px; }
.rich-content li { margin-bottom: 5px; }
.rich-content blockquote {
  margin: 0 0 12px;
  padding: 8px 14px;
  border-left: 3px solid var(--green);
  background: #f5f5f4;
  border-radius: 0 8px 8px 0;
  color: var(--ink-2);
}
.rich-content a { color: var(--green); text-decoration: underline; }
.rich-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 12px;
  font-size: 13.5px;
}
.rich-content table td, .rich-content table th { border: 1px solid var(--line); padding: 6px 10px; }
.rich-content font[size="2"] { font-size: 0.85em; }
.rich-content font[size="4"] { font-size: 1.15em; }
.rich-content font[size="5"] { font-size: 1.4em; }
.rich-content font[size="6"] { font-size: 1.75em; }
.rich-content font[size="7"] { font-size: 2.1em; }
