/* 新太五金網站共用樣式 */

:root {
  --brand: #2b4fd6;
  --brand-dark: #1f3aa6;
  --brand-soft: #eef2fd;
  --ink: #1f2533;
  --ink-2: #4a5263;
  --ink-3: #7a8292;
  --line: #e2e6ee;
  --bg: #f6f7fa;
  --card: #ffffff;
  --accent: #f2a007;
  --danger: #d0342c;
  --danger-soft: #fdeceb;
  --ok: #1e8e4e;
  --ok-soft: #e7f6ee;
  --warn-soft: #fff5e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.06), 0 4px 16px rgba(20, 30, 60, 0.06);
  --maxw: 1160px;
  --font: 'Microsoft JhengHei', '微軟正黑體', 'PingFang TC', 'Noto Sans TC', 'Heiti TC', -apple-system,
    BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 0.6em; }
h1 { font-size: clamp(24px, 3.2vw, 32px); }
h2 { font-size: clamp(20px, 2.6vw, 26px); }
h3 { font-size: 18px; }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.section { padding: 48px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.center { text-align: center; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- 頂部列 ---------- */
.test-banner {
  background: var(--warn-soft);
  color: #7a5200;
  text-align: center;
  font-size: 14px;
  padding: 6px 12px;
  border-bottom: 1px solid #f3dca6;
}
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .bar { height: 4px; background: var(--brand); }
.header-inner { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--brand); flex-shrink: 0; }
.logo-mark {
  width: 36px; height: 36px; border-radius: 8px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.logo-text { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.main-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a {
  color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-weight: 600;
}
.main-nav a:hover { background: var(--brand-soft); color: var(--brand); }
.main-nav a.active { color: var(--brand); background: var(--brand-soft); }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-link {
  position: relative; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2);
  text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 600; white-space: nowrap;
}
.icon-link:hover { background: var(--brand-soft); color: var(--brand); }
.icon-link svg { width: 22px; height: 22px; }
.cart-count {
  position: absolute; top: 2px; left: 22px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 12px; line-height: 18px; text-align: center; font-weight: 700;
}
@media (max-width: 760px) {
  .header-inner { flex-wrap: wrap; gap: 8px 12px; padding: 8px 0; }
  .main-nav { order: 3; flex-basis: 100%; }
  .logo-text { font-size: 20px; }
  .icon-link .label { display: none; }
}

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none; line-height: 1.4; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn-outline:hover { background: var(--brand-soft); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: #fff; color: var(--ink); }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #d98f00; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f0b8b4; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-lg { padding: 14px 28px; font-size: 18px; }
.btn-block { width: 100%; }

/* ---------- 卡片與區塊 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 20px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--brand-soft); color: var(--brand); white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: #9a6400; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-gray { background: #eef0f4; color: var(--ink-3); }
.alert { padding: 12px 16px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-dark); }
.alert-warn { background: var(--warn-soft); color: #7a5200; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- 首頁 ---------- */
.hero {
  background: linear-gradient(120deg, #1a2f8a 0%, var(--brand) 55%, #4a6cf0 100%);
  color: #fff; position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; right: -80px; top: -80px; width: 420px; height: 420px; border-radius: 50%;
  border: 60px solid rgba(255, 255, 255, 0.06);
}
.hero-inner { padding: 64px 0 72px; position: relative; z-index: 1; max-width: 720px; }
.hero .eyebrow { display: inline-block; font-size: 14px; letter-spacing: 2px; opacity: 0.85; margin-bottom: 12px; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); margin-bottom: 16px; }
.hero p { font-size: clamp(16px, 2vw, 19px); opacity: 0.92; }
.hero .btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.7); }
.hero .btn-outline:hover { background: rgba(255, 255, 255, 0.12); }
.hero-facts { display: flex; gap: 32px; margin-top: 32px; flex-wrap: wrap; }
.hero-facts div { font-size: 14px; opacity: 0.9; }
.hero-facts strong { display: block; font-size: 24px; }

.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.category-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none;
  color: var(--ink); font-weight: 700; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.category-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #c9d3f3; }
.category-card img { width: 44px; height: 44px; }
.category-card .count { font-size: 13px; color: var(--ink-3); font-weight: 400; }

.about-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: start; }
@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; } }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 4px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-list li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.contact-list li:last-child { border-bottom: 0; }
.contact-list .k { color: var(--ink-3); width: 56px; flex-shrink: 0; }
.map-frame { width: 100%; height: 320px; border: 0; border-radius: var(--radius); display: block; }

/* ---------- 商品 ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.product-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; text-decoration: none; color: inherit; transition: box-shadow 0.15s, transform 0.15s;
}
.product-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.product-card .thumb { aspect-ratio: 1; background: #eef1f7; }
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .info { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card .cat { font-size: 13px; color: var(--ink-3); }
.product-card .name { font-weight: 700; line-height: 1.45; }
.product-card .price { margin-top: auto; color: var(--brand); font-weight: 700; font-size: 18px; }

.shop-layout { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.cat-nav { position: sticky; top: 90px; }
.cat-nav a {
  display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 8px; color: var(--ink-2);
  text-decoration: none; font-weight: 600;
}
.cat-nav a:hover { background: #fff; }
.cat-nav a.active { background: var(--brand); color: #fff; }
.cat-nav a .n { font-weight: 400; opacity: 0.7; }
@media (max-width: 860px) {
  .shop-layout { grid-template-columns: 1fr; }
  .cat-nav { position: static; display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .cat-nav a { white-space: nowrap; background: #fff; border: 1px solid var(--line); }
  .cat-nav a .n { display: none; }
  .cat-nav h3 { display: none; }
}
.search-box { display: flex; gap: 8px; margin-bottom: 20px; }
.search-box input { flex: 1; }

.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
@media (max-width: 860px) { .product-detail { grid-template-columns: 1fr; gap: 24px; } }
.product-detail .gallery { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.product-detail .gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.product-detail .price { font-size: 30px; font-weight: 700; color: var(--brand); margin: 8px 0 20px; }
.product-detail .desc { white-space: pre-line; color: var(--ink-2); }
.breadcrumb { font-size: 14px; color: var(--ink-3); margin-bottom: 16px; }
.breadcrumb a { color: var(--ink-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand); }
.qty { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.qty button { width: 38px; border: 0; background: #f3f5f9; font-size: 18px; cursor: pointer; color: var(--ink-2); }
.qty button:hover { background: var(--brand-soft); color: var(--brand); }
.qty input { width: 56px; text-align: center; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; padding: 8px 0; }

/* ---------- 留言 ---------- */
.comments { margin-top: 40px; }
.comment { padding: 16px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment .meta { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--ink-3); margin-bottom: 4px; }
.comment .author { font-weight: 700; color: var(--ink); }
.comment .body { white-space: pre-wrap; word-break: break-word; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}

/* ---------- 表單 ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); font-size: 15px; }
input[type='text'], input[type='email'], input[type='password'], input[type='tel'], input[type='number'],
input[type='search'], input[type='url'], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cfd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(43, 79, 214, 0.25); border-color: var(--brand); }
textarea { resize: vertical; min-height: 96px; }
.field { margin-bottom: 16px; }
.field .hint { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.auth-card { max-width: 440px; margin: 48px auto; }
.choice-group { display: grid; gap: 10px; }
.choice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; cursor: pointer; font-weight: 400; margin: 0;
}
.choice:hover { border-color: #b9c5ee; }
.choice input { margin-top: 5px; accent-color: var(--brand); }
.choice.selected { border-color: var(--brand); background: var(--brand-soft); }
.choice .title { font-weight: 700; color: var(--ink); }
.choice .sub { font-size: 14px; color: var(--ink-3); }
.store-pickers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.selected-store { margin-top: 12px; padding: 12px 14px; background: var(--ok-soft); border-radius: 8px; }

/* ---------- 購物車與結帳 ---------- */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; }
@media (max-width: 900px) { .cart-layout { grid-template-columns: 1fr; } }
.cart-item { display: grid; grid-template-columns: 88px 1fr auto; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); align-items: center; }
.cart-item:last-child { border-bottom: 0; }
.cart-item img { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; background: #eef1f7; }
.cart-item .name { font-weight: 700; text-decoration: none; color: var(--ink); }
.cart-item .line-total { font-weight: 700; text-align: right; }
@media (max-width: 600px) {
  .cart-item { grid-template-columns: 64px 1fr; }
  .cart-item img { width: 64px; height: 64px; }
  .cart-item .line-actions { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
}
.summary { position: sticky; top: 90px; }
.summary dl { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 0 0 16px; }
.summary dt { color: var(--ink-2); }
.summary dd { margin: 0; text-align: right; font-weight: 600; }
.summary .total { font-size: 22px; color: var(--brand); font-weight: 700; }
.empty-state { text-align: center; padding: 56px 20px; color: var(--ink-3); }
.empty-state .btn { margin-top: 16px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #f7f8fb; color: var(--ink-3); font-weight: 600; white-space: nowrap; font-size: 14px; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f7f9ff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #eef1f7; }

/* ---------- 頁尾 ---------- */
.site-footer { background: #1b2233; color: #b9c0cf; margin-top: 48px; font-size: 15px; }
.footer-inner { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; padding: 40px 20px; }
.site-footer h4 { color: #fff; margin: 0 0 12px; font-size: 16px; }
.site-footer a { color: #d7dcea; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }
.footer-bottom { border-top: 1px solid #2c3549; padding: 16px 20px; font-size: 13px; color: #8a93a8; }
@media (max-width: 760px) { .footer-inner { grid-template-columns: 1fr; gap: 20px; } }

/* ---------- 提示訊息 ---------- */
.toast-box { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; }
.toast {
  background: #1f2533; color: #fff; padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow);
  font-weight: 600; animation: toast-in 0.2s ease-out;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.loading { color: var(--ink-3); padding: 32px 0; text-align: center; }
.page-title { padding: 32px 0 8px; }
.prose h2 { margin-top: 1.6em; }
.prose li { margin-bottom: 6px; }

/* ---------- 對話框 ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(15, 20, 35, 0.45); }
dialog .dialog-head { padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
dialog .dialog-head h3 { margin: 0; flex: 1; }
dialog .dialog-body { padding: 20px 24px; max-height: 70vh; overflow-y: auto; }
dialog .dialog-foot { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.close-x { border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--ink-3); line-height: 1; }
