/* =====================================================================
   E-commerce module — storefront, account and admin additions.
   Uses the design tokens from app.css (loaded first).
   ===================================================================== */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.btn-sm { padding: 7px 14px; font-size: 0.86rem; }
.btn[disabled], .btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--ink-muted); padding: 8px; border-radius: 50%; display: inline-flex; }
.icon-btn:hover { background: var(--parchment); color: var(--error-ink); }
hr.soft { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
[hidden] { display: none !important; }

/* ---- Header widgets ---- */
.top-icon-link { position: relative; display: inline-flex; align-items: center; }
.top-icon-link .icon { width: 22px; height: 22px; }
.count-pill {
  position: absolute; top: -8px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--brand); color: #fff; font-size: 0.7rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}

/* ---- Shared bits ---- */
.stars { display: inline-flex; align-items: center; gap: 1px; color: var(--border-strong); }
.stars .icon { width: 15px; height: 15px; }
.stars .icon.is-on { fill: var(--gold); color: var(--gold); stroke: var(--gold); }
.stars-count { margin-left: 6px; font-size: 0.8rem; color: var(--ink-muted); }

.price-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.price { font-size: 1.15rem; font-weight: 800; color: var(--brand-dark); }
.price-old { color: var(--ink-muted); text-decoration: line-through; font-size: 0.9rem; }
.price-off { color: var(--success-ink); font-weight: 800; font-size: 0.9rem; }
.price-row-lg .price { font-size: 1.9rem; }

.fav-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: 1.5px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.92); color: var(--ink-muted); border-radius: 999px; padding: 7px; line-height: 0;
  transition: color 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.fav-btn:hover { color: var(--rose); border-color: var(--rose); transform: scale(1.06); }
.fav-btn .icon { width: 20px; height: 20px; }
.fav-btn.is-fav { color: var(--rose); border-color: var(--rose); }
.fav-btn.is-fav .icon { fill: var(--rose); }
.fav-btn-label { padding: 9px 16px; line-height: 1.2; font-weight: 700; background: var(--surface); }

.shop-tag { position: absolute; top: 10px; left: 10px; padding: 3px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 800; color: #fff; }
.shop-tag-sale { background: var(--teal); }
.shop-tag-out { background: var(--ink-muted); }

.stock-line { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; margin: 4px 0 12px; }
.stock-line.is-in { color: var(--success-ink); }
.stock-line.is-low { color: var(--saffron); }
.stock-line.is-out { color: var(--error-ink); }

.qty-input { width: 76px !important; text-align: center; padding: 9px 8px !important; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit; background: var(--surface); }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-row-3 { grid-template-columns: repeat(3, 1fr); }

.totals { margin: 14px 0 6px; }
.totals > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.totals dt { color: var(--ink-muted); }
.totals dd { margin: 0; font-weight: 700; }
.totals .is-discount dd { color: var(--success-ink); }
.totals .grand { border-top: 2px solid var(--border-strong); margin-top: 8px; padding-top: 12px; font-size: 1.2rem; }
.totals .grand dt { color: var(--ink); font-weight: 800; }
.totals .grand dd { color: var(--brand-dark); font-weight: 800; }

/* ---- Listing ---- */
.shop-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.shop-head h1 { margin: 0; display: flex; align-items: center; gap: 10px; }
.shop-search { display: flex; gap: 8px; }
.shop-search input { padding: 10px 16px; border: 1.5px solid var(--border-strong); border-radius: 999px; min-width: 260px; font: inherit; background: var(--surface); }
.shop-layout { display: grid; grid-template-columns: 250px 1fr; gap: 28px; align-items: start; }
.shop-filters { display: grid; gap: 18px; position: sticky; top: 16px; }
.shop-filters .card { padding: 20px; }
.shop-filters h3 { margin: 0 0 12px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.shop-cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.shop-cats a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink); font-weight: 600; }
.shop-cats a:hover { background: var(--parchment); }
.shop-cats a.active { background: linear-gradient(155deg, var(--brand-light), var(--brand)); color: #fff; }
.shop-cats .count { font-size: 0.76rem; background: var(--parchment); color: var(--ink); border-radius: 999px; padding: 1px 8px; }
.shop-cats a.active .count { background: rgba(255, 255, 255, 0.25); color: #fff; }
.price-range { display: flex; align-items: center; gap: 8px; }
.price-range input { width: 100%; min-width: 0; }
.shop-price-form .form-group { margin-bottom: 14px; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.shop-grid-featured { margin-bottom: 36px; }
.shop-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; transition: transform 200ms ease, box-shadow 200ms ease; }
.shop-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.shop-card.is-soldout .shop-card-media img { filter: grayscale(0.8); opacity: 0.7; }
.shop-card-media { position: relative; display: block; aspect-ratio: 1 / 1; background: var(--parchment); overflow: hidden; }
.shop-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-card-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.shop-card-ph img { width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--gold-light); object-fit: cover; }
.shop-card-fav { position: absolute; top: 10px; right: 10px; z-index: 2; }
.shop-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.shop-card-body h3 { margin: 0; font-size: 1rem; font-family: var(--font-content); line-height: 1.45; }
.shop-card-body h3 a { color: var(--ink); }
.shop-card-body h3 a:hover { color: var(--brand); }
.shop-card-cat { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); font-weight: 700; }
.shop-card-body form { margin-top: auto; }

/* ---- Product page ---- */
.crumbs { font-size: 0.9rem; color: var(--ink-muted); margin-bottom: 18px; }
.crumbs a { font-weight: 600; }
.pdp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 40px; margin-bottom: 30px; }
.pdp-main { position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius); background: var(--parchment); border: 1px solid var(--border); overflow: hidden; }
.pdp-main img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.pdp-thumbs { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pdp-thumb { width: 70px; height: 70px; padding: 0; border: 2px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; cursor: pointer; }
.pdp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pdp-thumb.active, .pdp-thumb:hover { border-color: var(--brand); }
.pdp-info h1 { margin: 0 0 6px; font-family: var(--font-content); }
.pdp-rating { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tax-note { margin: -4px 0 12px; }
.pdp-short { color: var(--ink); font-family: var(--font-content); line-height: 1.7; }
.pdp-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 18px; }
.pdp-buy { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.qty-label { font-weight: 700; }
.pdp-meta { list-style: none; margin: 0; padding: 14px 0 0; border-top: 1px solid var(--border); display: grid; gap: 8px; font-size: 0.92rem; }
.pdp-meta span { display: inline-block; min-width: 76px; color: var(--ink-muted); font-weight: 700; }
.pdp-desc, .pdp-reviews { margin-bottom: 26px; }
.prose { font-family: var(--font-content); line-height: 1.85; }
.prose p { margin: 0 0 1em; }
.reviews-grid { display: grid; grid-template-columns: 280px 1fr; gap: 36px; }
.reviews-score { font-size: 3rem; font-weight: 800; color: var(--brand-dark); line-height: 1; }
.reviews-bars { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; font-size: 0.85rem; }
.reviews-bars li { display: grid; grid-template-columns: 30px 1fr 26px; gap: 8px; align-items: center; }
.reviews-bars .bar { height: 8px; background: var(--parchment); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.reviews-bars .bar i { display: block; height: 100%; background: var(--gold); }
.rating-input { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.rating-input input { position: absolute; opacity: 0; pointer-events: none; }
.rating-input label { cursor: pointer; margin: 0 !important; color: var(--border-strong); }
.rating-input label .icon { width: 30px; height: 30px; }
.rating-input input:checked ~ label, .rating-input label:hover, .rating-input label:hover ~ label { color: var(--gold); }
.rating-input input:checked ~ label .icon, .rating-input label:hover .icon, .rating-input label:hover ~ label .icon { fill: var(--gold); }
.rating-input input:focus-visible + label { outline: 3px solid rgba(224, 123, 31, 0.55); border-radius: 4px; }
.review-list { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 18px; }
.review { padding-top: 18px; border-top: 1px solid var(--border); }
.review-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.review-date { color: var(--ink-muted); font-size: 0.82rem; }
.review h4 { margin: 6px 0 2px; }
.review p { margin: 4px 0 0; font-family: var(--font-content); }

/* ---- Cart / checkout ---- */
.cart-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 26px; align-items: start; }
.cart-lines { padding: 8px 24px; }
.cart-line { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto 100px 40px; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--border); }
.cart-line.is-unavailable { opacity: 0.65; }
.cart-line-img img { width: 84px; height: 84px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--parchment); display: block; }
.cart-line-img img.is-placeholder { object-fit: contain; padding: 14px; }
.cart-line-name { font-weight: 700; color: var(--ink); font-family: var(--font-content); }
.cart-line-total { text-align: right; font-weight: 800; color: var(--brand-dark); }
.cart-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 0 10px; }
.cart-summary { position: sticky; top: 16px; }
.cart-summary h2 { margin-top: 0; }
.coupon-form { display: flex; gap: 8px; margin-bottom: 8px; }
.coupon-form input { flex: 1; min-width: 0; padding: 10px 14px; border: 1.5px dashed var(--border-strong); border-radius: 999px; font: inherit; text-transform: uppercase; background: var(--surface); }
.coupon-applied { display: flex; justify-content: space-between; align-items: center; background: var(--success-bg); color: var(--success-ink); padding: 10px 14px; border-radius: var(--radius-sm); }
.free-ship-hint { display: flex; align-items: center; gap: 6px; color: var(--teal); font-weight: 700; }
.checkout-main { display: grid; gap: 20px; }
.checkout-main h2 { margin-top: 0; display: flex; align-items: center; gap: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; cursor: pointer; background: var(--surface); }
.choice:hover { border-color: var(--gold); }
.choice:has(input:checked) { border-color: var(--brand); background: #fff8f2; box-shadow: 0 0 0 3px rgba(122, 31, 46, 0.08); }
.choice input { width: auto; margin-top: 4px; accent-color: var(--brand); }
.address-fields { margin-top: 10px; padding: 18px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); transition: opacity 150ms ease; }
.address-fields.is-inactive { opacity: 0.45; }
.mini-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.92rem; }
.mini-lines li { display: flex; justify-content: space-between; gap: 12px; }
.mini-name small { color: var(--ink-muted); }
.pay-card { text-align: center; }
.pay-card h1 { font-size: 1.5rem; display: flex; justify-content: center; align-items: center; gap: 8px; }
.pay-amount { font-size: 2.6rem; font-weight: 800; color: var(--brand-dark); margin: 12px 0 20px; }

/* ---- Account ---- */
.account-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin: 22px 0 34px; }
.account-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 12px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); color: var(--ink); transition: transform 180ms ease, box-shadow 180ms ease; }
.account-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); color: var(--ink); }
.account-tile .icon { width: 28px; height: 28px; color: var(--brand); }
.account-tile strong { font-size: 1.5rem; line-height: 1.1; }
.account-tile span { color: var(--ink-muted); font-weight: 600; font-size: 0.9rem; }
.order-list { display: grid; gap: 12px; margin-bottom: 24px; }
.order-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 1.4fr auto; gap: 16px; align-items: center; padding: 16px 20px; color: var(--ink); }
.order-row:hover { border-color: var(--gold-light); box-shadow: var(--shadow-md); color: var(--ink); }
.order-row-total { font-weight: 800; color: var(--brand-dark); font-size: 1.1rem; }
.order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.order-head h1 { margin: 0; }
.order-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tracker { list-style: none; display: flex; margin: 0 0 24px; padding: 0; counter-reset: step; }
.tracker li { flex: 1; text-align: center; position: relative; color: var(--ink-muted); font-weight: 700; font-size: 0.85rem; }
.tracker li::before { counter-increment: step; content: counter(step); display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin: 0 auto 6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); position: relative; z-index: 1; }
.tracker li::after { content: ''; position: absolute; top: 15px; left: -50%; width: 100%; height: 2px; background: var(--border-strong); }
.tracker li:first-child::after { display: none; }
.tracker li.is-done { color: var(--brand-dark); }
.tracker li.is-done::before { background: var(--brand); border-color: var(--brand); color: #fff; }
.tracker li.is-done::after { background: var(--brand); }
.tracker li.is-current::before { box-shadow: 0 0 0 4px rgba(122, 31, 46, 0.18); }
.tracking-card { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; padding: 16px 20px; }
.order-items { list-style: none; margin: 0 0 24px; padding: 0; }
.order-items li { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.order-items img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.order-items img.is-placeholder { object-fit: contain; padding: 10px; background: var(--parchment); }
.oi-info strong { display: block; font-family: var(--font-content); }
.oi-total { font-weight: 800; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border-strong); display: grid; gap: 14px; }
.timeline li { position: relative; }
.timeline li::before { content: ''; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline .hint { margin: 0 0 0 8px; }
.addr { font-style: normal; line-height: 1.7; }
.address-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.address-card { padding: 20px; display: grid; gap: 10px; align-content: start; }
.address-card.is-default { border-color: var(--gold); box-shadow: var(--shadow-gold); }
.address-edit summary { cursor: pointer; font-weight: 700; color: var(--brand); display: inline-flex; align-items: center; gap: 6px; }
.address-edit[open] summary { margin-bottom: 14px; }

/* ---- Status badges ---- */
.badge-order-pending { background: #FBEBCB; color: #8A5A0B; }
.badge-order-confirmed { background: #DCE9F8; color: #1F4E8C; }
.badge-order-processing { background: #E6E1F6; color: #4B3C99; }
.badge-order-shipped { background: #D8EFEC; color: #17625C; }
.badge-order-delivered { background: var(--success-bg); color: var(--success-ink); }
.badge-order-cancelled { background: var(--error-bg); color: var(--error-ink); }
.badge-pay-pending { background: #F0E6CE; color: #7A5A1E; }
.badge-pay-paid { background: var(--success-bg); color: var(--success-ink); }
.badge-pay-failed { background: var(--error-bg); color: var(--error-ink); }
.badge-pay-refunded { background: #E6E1F6; color: #4B3C99; }

/* ---- Admin additions ---- */
.admin-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.admin-thumb-ph { background: var(--parchment); }
.admin-gallery { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }
.admin-gallery-item { display: grid; gap: 6px; justify-items: start; }
.admin-gallery-item img { width: 110px; height: 110px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.admin-order-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.settings-stack { display: grid; gap: 22px; max-width: 820px; }
.settings-stack h2 { margin-top: 0; display: flex; align-items: center; gap: 8px; }
.settings-stack code, .hint code { background: var(--parchment); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; word-break: break-all; }
.review-admin-list { display: grid; gap: 14px; }
.review-admin { padding: 20px; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .shop-layout { grid-template-columns: 1fr; }
  .shop-filters { position: static; grid-template-columns: 1fr 1fr; }
  .pdp { grid-template-columns: 1fr; gap: 24px; }
  .reviews-grid { grid-template-columns: 1fr; gap: 24px; }
  .cart-layout, .admin-order-layout { grid-template-columns: 1fr; }
  .cart-summary { position: static; }
}
@media (max-width: 640px) {
  .shop-filters { grid-template-columns: 1fr; }
  .shop-search input { min-width: 0; width: 100%; }
  .shop-search { width: 100%; }
  .shop-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .shop-card-body { padding: 10px 12px 12px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0; }
  .cart-line { grid-template-columns: 64px minmax(0, 1fr) auto; grid-template-areas: "img info rm" "img qty total"; gap: 8px 12px; }
  .cart-line-img { grid-area: img; }
  .cart-line-img img { width: 64px; height: 64px; }
  .cart-line-info { grid-area: info; }
  .cart-line .icon-btn { grid-area: rm; }
  .cart-line-qty { grid-area: qty; }
  .cart-line-total { grid-area: total; }
  .order-row { grid-template-columns: 1fr auto; }
  .order-row > div:nth-child(2) { grid-column: 1 / -1; order: 3; }
  .tracker li { font-size: 0.7rem; }
  .pay-amount { font-size: 2.1rem; }
}
