/* ===== 玖參選物 — 溫暖質感選物風 =====
   米白底 · 赤陶紅點綴 · 圓角卡片 · 大量留白 */
:root{
  --brand:#C1663F;        /* 赤陶紅 */
  --brand-dark:#A9542F;
  --brand-soft:#F3E7DE;
  --accent:#D98E5A;
  --bg:#FAF5EF;           /* 米白 */
  --surface:#FFFFFF;
  --ink:#33302C;
  --muted:#8C8178;
  --line:#EBE3D9;
  --line-green:#06C755;
  --ok:#2E9E6B;
  --warn:#C9803B;
  --danger:#C4483C;
  --radius:16px;
  --shadow:0 6px 20px rgba(120,86,60,.08);
  --shadow-hover:0 12px 30px rgba(120,86,60,.15);
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0; color:var(--ink); background:var(--bg);
  font-family:-apple-system,BlinkMacSystemFont,"Noto Sans TC","PingFang TC","Microsoft JhengHei",Segoe UI,Roboto,sans-serif;
  line-height:1.6; -webkit-font-smoothing:antialiased;
}
a{color:var(--brand); text-decoration:none}
a:hover{color:var(--brand-dark)}
img{max-width:100%; display:block}
.wrap{max-width:1120px; margin:0 auto; padding:0 20px}

/* ── 前台 Header ── */
.shop-header{
  background:linear-gradient(180deg,#FFFDFA 0%,var(--bg) 100%);
  border-bottom:1px solid var(--line); position:sticky; top:0; z-index:20;
  backdrop-filter:saturate(1.2) blur(6px);
}
.header-row{display:flex; align-items:center; justify-content:space-between; padding:16px 0; gap:16px}
.brand-block{display:flex; align-items:baseline; gap:12px; min-width:0}
.brand-mark{
  font-size:26px; font-weight:800; letter-spacing:2px; color:var(--brand);
}
.tagline{margin:0; color:var(--muted); font-size:13px; white-space:nowrap}

/* ── 精緻 LINE 登入按鈕（指示②）── */
.login-area{display:flex; align-items:center; gap:10px}
.line-login{
  display:inline-flex; align-items:center; gap:9px;
  background:var(--line-green); color:#fff; border:0; cursor:pointer;
  padding:10px 18px; border-radius:999px; font-size:14px; font-weight:700;
  box-shadow:0 4px 12px rgba(6,199,85,.32); transition:transform .12s ease, box-shadow .12s ease;
}
.line-login:hover{transform:translateY(-1px); box-shadow:0 8px 18px rgba(6,199,85,.42)}
.line-login:active{transform:translateY(0)}
.line-login .line-logo{width:20px; height:20px; flex:0 0 auto}
.member-box{display:inline-flex; align-items:center; gap:10px}
.member-pic{width:36px; height:36px; border-radius:50%; object-fit:cover; border:2px solid var(--brand-soft)}
.member-name{font-size:14px; font-weight:600; color:var(--ink); max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.logout-link{font-size:12px; color:var(--muted)}

/* ── header 右側動作區：購物車 icon + 登入區 ── */
.header-actions{display:flex; align-items:center; gap:10px; flex:0 0 auto}
.cart-btn{
  position:relative; display:inline-flex; align-items:center; justify-content:center;
  min-width:44px; min-height:44px; flex:0 0 auto;
  background:var(--surface); border:1px solid var(--line); border-radius:14px;
  color:var(--brand-dark); box-shadow:0 1px 3px rgba(51,48,44,.06);
  transition:transform .12s ease, box-shadow .12s ease, border-color .12s ease, color .12s ease;
}
.cart-btn:hover{
  color:var(--brand); border-color:var(--brand);
  transform:translateY(-1px); box-shadow:0 8px 18px rgba(193,102,63,.20);
}
.cart-btn:active{transform:translateY(0); background:var(--brand-soft); box-shadow:none}
.cart-btn:focus-visible{outline:3px solid rgba(193,102,63,.45); outline-offset:2px}
.cart-icon{width:23px; height:23px; display:block; flex:0 0 auto}
.cart-badge{
  position:absolute; top:1px; right:1px;
  display:inline-flex; align-items:center; justify-content:center;
  min-width:12px; height:12px; padding:3px 5px;
  background:var(--brand); color:#fff; border:2px solid var(--surface);
  border-radius:999px; font-size:11px; font-weight:700; line-height:1;
  letter-spacing:0; box-shadow:0 2px 5px rgba(193,102,63,.35);
}
.cart-badge[hidden]{display:none}   /* [hidden] 需覆蓋上面的 display:inline-flex */
.logout-link:hover{color:var(--danger)}

/* ── Hero ── */
.hero{padding:40px 0 8px}
.hero h2{font-size:22px; margin:0 0 6px; font-weight:700}
.hero p{margin:0; color:var(--muted)}

/* ── 商品格 ── */
.product-grid{
  display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr));
  gap:22px; padding:26px 0 60px;
}
.product-card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  overflow:hidden; box-shadow:var(--shadow); transition:transform .16s ease, box-shadow .16s ease;
  display:flex; flex-direction:column;
}
.product-card:hover{transform:translateY(-4px); box-shadow:var(--shadow-hover)}
.product-card .thumb{aspect-ratio:1/1; background:var(--brand-soft); overflow:hidden}
.product-card .thumb img{width:100%; height:100%; object-fit:cover; transition:transform .3s ease}
.product-card:hover .thumb img{transform:scale(1.04)}
.product-card .thumb.empty{display:flex; align-items:center; justify-content:center; color:var(--accent); font-size:34px}
.product-card .info{padding:14px 16px 18px; display:flex; flex-direction:column; gap:6px; flex:1}
.product-card .name{font-weight:700; font-size:15px; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.product-card .price{color:var(--brand); font-weight:800; font-size:17px}
.product-card .price small{font-weight:600; font-size:12px; opacity:.8}
.product-card .card-actions{margin-top:auto; display:flex; gap:8px; padding-top:10px}
.btn-buy{
  flex:1; text-align:center; background:var(--brand); color:#fff; border:0; cursor:pointer;
  padding:9px 12px; border-radius:10px; font-size:14px; font-weight:700; transition:background .12s ease;
}
.btn-buy:hover{background:var(--brand-dark); color:#fff}
.btn-view{
  text-align:center; background:var(--brand-soft); color:var(--brand-dark);
  padding:9px 14px; border-radius:10px; font-size:14px; font-weight:700;
}
.empty-state{padding:80px 0; text-align:center; color:var(--muted)}

/* ── 商品明細頁（指示③）── */
.detail{display:grid; grid-template-columns:1fr 1fr; gap:40px; padding:34px 0 60px}
.gallery .main-img{
  aspect-ratio:1/1; background:var(--brand-soft); border-radius:var(--radius);
  overflow:hidden; border:1px solid var(--line);
}
.gallery .main-img img{width:100%; height:100%; object-fit:cover}
.gallery .main-img.empty{display:flex; align-items:center; justify-content:center; color:var(--accent); font-size:60px}
.thumbs{display:flex; gap:10px; margin-top:12px; flex-wrap:wrap}
.thumbs img{
  width:68px; height:68px; object-fit:cover; border-radius:10px; cursor:pointer;
  border:2px solid transparent; transition:border-color .12s ease;
}
.thumbs img.active,.thumbs img:hover{border-color:var(--brand)}
.detail-info h1{font-size:26px; margin:0 0 4px}
.detail-info .code{color:var(--muted); font-size:13px; margin-bottom:16px}
.detail-info .detail-price{font-size:30px; font-weight:800; color:var(--brand); margin:10px 0}
.detail-info .stock{font-size:13px; color:var(--muted); margin-bottom:18px}
.detail-info .stock.out{color:var(--danger); font-weight:700}
.detail-info .desc{white-space:pre-wrap; color:#54504A; border-top:1px solid var(--line); padding-top:18px; margin-top:8px}
.detail-actions{display:flex; gap:12px; margin:22px 0}
.detail-actions .btn-buy{flex:0 0 auto; padding:13px 30px; border-radius:12px; font-size:16px}
.back-link{color:var(--muted); font-size:14px}

/* ── Footer ── */
.shop-footer{border-top:1px solid var(--line); background:#FFFDFA; padding:30px 0; color:var(--muted); font-size:13px; text-align:center}
.shop-footer a{color:var(--muted)}
.shop-footer a:hover{color:var(--brand)}

/* ===== 通用按鈕 / 表單 ===== */
.btn{display:inline-block; padding:9px 16px; border-radius:10px; border:1px solid var(--line);
  background:var(--surface); color:var(--ink); cursor:pointer; font-size:14px; text-decoration:none}
.btn:hover{border-color:var(--brand); color:var(--brand)}
.btn.primary{background:var(--brand); color:#fff; border-color:var(--brand)}
.btn.primary:hover{background:var(--brand-dark); color:#fff}
.btn.danger{color:var(--danger); border-color:#E7C4C0}
.btn.danger:hover{background:var(--danger); color:#fff}

/* ===== 後台 ===== */
body.admin{background:var(--bg)}
.admin-shell{display:flex; min-height:100vh}
.sidebar{
  width:220px; flex:0 0 220px; background:#3C332C; color:#EFE7DD; padding:20px 0;
  position:sticky; top:0; height:100vh; overflow-y:auto;
}
.sidebar .brand{font-size:18px; font-weight:800; letter-spacing:2px; padding:6px 22px 18px; color:#fff}
.sidebar a{display:block; color:#D8CDBF; padding:11px 22px; font-size:14px; border-left:3px solid transparent}
.sidebar a:hover{background:#4A3F36; color:#fff}
.sidebar a.active{background:#4A3F36; color:#fff; border-left-color:var(--brand)}
.sidebar a.logout{margin-top:14px; color:#C79A8C}
.admin-main{flex:1; padding:30px 34px; min-width:0}
.page-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; gap:12px}
h1{font-size:22px; margin:0 0 18px}
h3{font-size:16px; margin:22px 0 10px}
.hint{color:var(--muted); font-size:13px; margin:4px 0 16px}

.stat-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:16px}
.stat{background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:20px; box-shadow:var(--shadow); text-align:center}
.stat .num{display:block; font-size:30px; font-weight:800; color:var(--brand)}
.stat .lbl{color:var(--muted); font-size:13px}
.stat.warn .num{color:var(--warn)}

.filter{display:flex; gap:10px; margin-bottom:16px; flex-wrap:wrap}
.filter input,.filter select{padding:9px 12px; border:1px solid var(--line); border-radius:10px; background:#fff}

table.data{width:100%; border-collapse:collapse; background:var(--surface); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow)}
table.data th,table.data td{padding:12px 14px; text-align:left; border-bottom:1px solid var(--line); font-size:14px}
table.data th{background:#FBF6F0; color:var(--muted); font-weight:700; font-size:13px}
table.data tr:last-child td{border-bottom:0}
table.data tr:hover td{background:#FCF9F5}

.tag{display:inline-block; padding:2px 10px; border-radius:999px; font-size:12px; font-weight:700}
.tag.public{background:#E4F1E8; color:var(--ok)}
.tag.hidden{background:#F1E7E4; color:var(--brand-dark)}
.status-pending{background:#FBEEDD; color:var(--warn)}
.status-paid{background:#E4F1E8; color:var(--ok)}
.status-shipped{background:#E2ECF6; color:#3B76B0}
.status-completed{background:#E9E6F2; color:#6B5FA0}
.status-cancelled{background:#F1E4E2; color:var(--danger)}

.form{max-width:640px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:24px; box-shadow:var(--shadow)}
.form label{display:block; font-size:13px; color:var(--muted); margin:14px 0 5px; font-weight:600}
.form input,.form select,.form textarea{
  width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:10px;
  font-size:14px; line-height:1.4; background:#fff; font-family:inherit; color:var(--ink);
}
/* 讓 <select> 外觀與文字框一致（移除瀏覽器原生樣式，改用自訂箭頭）*/
.form select{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  padding-right:36px; cursor:pointer;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%238C8178' d='M0 0h12L6 8z'/></svg>");
  background-repeat:no-repeat; background-position:right 13px center; background-size:11px 7px;
}
.form input:focus,.form select:focus,.form textarea:focus{outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(193,102,63,.12)}
.form input:disabled{background:#F5F1EB; color:var(--muted)}
.form textarea{min-height:96px; resize:vertical}
.form .row{display:flex; gap:14px}
.form .row>div{flex:1}
.form .checkbox{display:flex; align-items:center; gap:9px; margin-top:16px; font-size:14px; color:var(--ink)}
.form .checkbox input{width:18px; height:18px; accent-color:var(--brand)}
.form-actions{margin-top:24px; display:flex; gap:10px}

.notice{background:#FBF6F0; border:1px solid var(--line); border-radius:12px; padding:12px 14px; margin-bottom:16px; font-size:14px}
.notice.ok{background:#E9F5EE; border-color:#CDE8D7; color:var(--ok)}
.notice.warn{background:#FBEFDD; border-color:#F0DCBD; color:var(--warn)}

/* ── 圖片上傳即時預覽（指示①）── */
.upload-zone{
  border:2px dashed var(--line); border-radius:12px; padding:22px; text-align:center;
  color:var(--muted); background:#FCFAF7; cursor:pointer; transition:border-color .12s ease, background .12s ease;
}
.upload-zone:hover,.upload-zone.drag{border-color:var(--brand); background:#FBF3EC; color:var(--brand-dark)}
.upload-zone input[type=file]{display:none}
.img-list{display:flex; flex-wrap:wrap; gap:10px; margin-top:12px}
.img-thumb{position:relative; width:92px; height:92px; border:1px solid var(--line); border-radius:10px; overflow:hidden; background:#fff}
.img-thumb img{width:100%; height:100%; object-fit:cover}
.cover-badge{position:absolute; left:0; top:0; background:var(--brand); color:#fff; font-size:11px; padding:1px 7px; border-bottom-right-radius:8px}
.new-badge{position:absolute; left:0; top:0; background:var(--accent); color:#fff; font-size:11px; padding:1px 7px; border-bottom-right-radius:8px}
.del-img{position:absolute; right:3px; top:3px; background:rgba(0,0,0,.55); color:#fff; border:0; border-radius:50%; width:22px; height:22px; cursor:pointer; line-height:1; font-size:13px}
.del-img:hover{background:var(--danger)}

/* ── 分類樹 ── */
.cat-tree,.cat-tree ul{list-style:none; padding-left:18px; margin:0}
.cat-tree>li{margin-top:6px}
.cat-tree li{padding:5px 0}
.cat-badge{display:inline-block; font-size:11px; color:var(--muted); border:1px solid var(--line); border-radius:6px; padding:0 6px; margin-right:6px}
.inline-form{display:inline}

/* ── 登入頁 ── */
.login-page{display:flex; align-items:center; justify-content:center; min-height:100vh; background:linear-gradient(135deg,#F3E7DE,#FAF5EF)}
.login-box{background:#fff; border-radius:20px; padding:36px 32px; width:340px; box-shadow:var(--shadow-hover)}
.login-box h1{text-align:center; color:var(--brand); letter-spacing:2px}
.login-box input{width:100%; padding:12px; border:1px solid var(--line); border-radius:10px; margin-bottom:12px; font-size:15px}
.login-box button{width:100%; padding:12px; background:var(--brand); color:#fff; border:0; border-radius:10px; font-size:15px; font-weight:700; cursor:pointer}
.login-box button:hover{background:var(--brand-dark)}
.login-err{color:var(--danger); font-size:13px; text-align:center; margin-bottom:10px}

/* ===== LIFF 顧客頁 ===== */
body.liff{background:#fff}
.liff-wrap{max-width:480px; margin:0 auto; padding:20px}
.liff-wrap h1{font-size:20px}
.liff-status{color:var(--muted); padding:34px 0; text-align:center}
.liff-item{display:flex; justify-content:space-between; align-items:center; gap:12px; padding:14px 0; border-bottom:1px solid var(--line)}
.liff-item .qty{display:flex; align-items:center; gap:8px}
.liff-summary{display:flex; justify-content:space-between; align-items:center; padding:16px 0; font-size:18px; font-weight:700}
.liff-btn{width:100%; padding:14px; border:0; border-radius:12px; background:var(--brand); color:#fff; font-size:16px; font-weight:700; cursor:pointer; margin-top:12px}
.liff-btn:hover{background:var(--brand-dark)}
.liff-link{display:block; text-align:center; margin-top:18px; color:var(--muted)}
body.liff label{display:block; font-size:13px; color:var(--muted); margin:14px 0 5px}
body.liff input,body.liff select{width:100%; padding:11px; border:1px solid var(--line); border-radius:10px; font-size:15px}

/* ── 會員中心 ── */
.member-wrap{max-width:640px; margin:0 auto; padding:24px 20px 60px}
.member-title{font-size:22px; margin:8px 0 18px}
.member-link{color:#fff; font-size:13px; text-decoration:underline}
.member-link:hover{color:#fff; opacity:.85}
.member-tabs{display:flex; gap:4px; margin-bottom:16px; border-bottom:1px solid var(--line)}
.mtab{background:none; border:0; padding:10px 14px; font-size:14px; color:var(--muted); cursor:pointer; border-bottom:3px solid transparent; font-family:inherit}
.mtab.active{color:var(--brand); border-bottom-color:var(--brand); font-weight:700}
.member-card{background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:22px; box-shadow:var(--shadow)}
.member-card label{display:block; font-size:13px; color:var(--muted); margin:14px 0 5px; font-weight:600}
.member-card input,.member-card select{width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:10px; font-size:15px; background:#fff; font-family:inherit; color:var(--ink)}
.member-card select{appearance:none;-webkit-appearance:none; padding-right:36px; cursor:pointer;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%238C8178' d='M0 0h12L6 8z'/></svg>");
  background-repeat:no-repeat; background-position:right 13px center; background-size:11px 7px}
.me-head{display:flex; align-items:center; gap:12px; margin-bottom:6px}
.me-head .member-pic{width:48px; height:48px}
.ship-toggle{display:flex; gap:16px; margin:6px 0 8px; flex-wrap:wrap}
.ship-toggle label{display:flex; align-items:center; gap:6px; font-size:15px; color:var(--ink); cursor:pointer}
.ship-toggle input{width:auto}
.save-msg{color:var(--ok); font-size:14px; margin-top:10px; min-height:18px; text-align:center}
.order-row{display:flex; justify-content:space-between; align-items:center; gap:10px; padding:14px 0; border-bottom:1px solid var(--line); cursor:pointer}
.order-row:last-child{border-bottom:0}
.order-row:hover{background:#FCF9F5}

/* ── RWD ── */
@media(max-width:820px){
  /* 後台：側欄改為「頂部橫向導覽」，內容緊接其下、滿版，確保一定看得到 */
  .admin-shell{flex-direction:column; min-height:100vh}
  .sidebar{
    width:auto; flex:none; height:auto; position:sticky; top:0; z-index:30;
    display:flex; flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch;
    padding:0; box-shadow:0 2px 10px rgba(0,0,0,.18);
  }
  .sidebar::-webkit-scrollbar{height:0}
  .sidebar .brand{display:none}
  .sidebar a{
    flex:0 0 auto; white-space:nowrap; border-left:0; border-bottom:0;
    padding:14px 16px; font-size:14px;
  }
  .sidebar a.active{border-left:0; border-bottom:3px solid var(--brand)}
  .sidebar a.logout{margin-top:0; color:#C79A8C}
  .admin-main{padding:20px 16px; width:100%; min-width:0}
  .form{max-width:100%}
  table.data{display:block; overflow-x:auto; white-space:nowrap}
}
@media(max-width:720px){
  .detail{grid-template-columns:1fr; gap:22px}
  .brand-mark{font-size:20px}
  .tagline{display:none}
  .header-row{gap:10px}                 /* 品牌與登入鈕維持同一列，不換行 */
  .brand-block{min-width:0}
  .hero{padding:24px 0 2px}
  .hero h2{font-size:19px}
}
@media(max-width:560px){
  .wrap{padding:0 14px}
  .header-row{padding:12px 0}
  .line-login{padding:8px 12px; font-size:13px}
  .line-login .line-logo{width:18px; height:18px}
  .member-name{max-width:80px}
  /* 窄螢幕：壓縮間距讓 44px 購物車鈕塞得下（320px 亦不重疊）*/
  .header-actions{gap:6px}
  .login-area{gap:6px; min-width:0}
  .member-box{gap:7px}
  .cart-btn{border-radius:12px}
  /* 手機商品改兩欄，卡片按鈕上下排 */
  .product-grid{grid-template-columns:repeat(2,1fr); gap:13px; padding:18px 0 44px}
  .product-card .info{padding:10px 11px 13px; gap:4px}
  .product-card .name{font-size:13.5px}
  .product-card .price{font-size:15px}
  .product-card .card-actions{flex-direction:column; gap:6px}
  .btn-buy,.btn-view{padding:9px 6px; font-size:13px}
  .detail-info h1{font-size:21px}
  .detail-info .detail-price{font-size:24px}
  .detail-actions .btn-buy{width:100%; padding:13px}
}
