/* ============================================================================
   Page-specific styles: cart, checkout, account, orders.
   Loaded automatically by includes/header.php when this file exists.
   Uses the design tokens defined in theme.css (--sh-*).
   ========================================================================== */

/* ---------- Cart / checkout shared layout ---------- */
.cart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--sh-space-5);
  align-items: start;
}
@media (max-width: 999px) {
  .cart-layout { grid-template-columns: 1fr; }
}

.card {
  background: #fff;
  border: 1px solid var(--sh-border-soft);
  border-radius: var(--sh-radius-lg);
  padding: var(--sh-space-5);
}

.cart-items.card { padding: var(--sh-space-4) var(--sh-space-5); }

.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th {
  text-align: left; font-size: var(--sh-font-size-xs); text-transform: uppercase;
  letter-spacing: .04em; color: var(--sh-muted); font-weight: 600;
  padding: 10px 8px; border-bottom: 1px solid var(--sh-border);
}
.cart-table td {
  padding: 16px 8px; border-bottom: 1px solid var(--sh-divider); vertical-align: middle;
}
.cart-table tr:last-child td { border-bottom: 0; }
.cart-table .th-qty, .cart-table .td-qty { width: 130px; text-align: center; }
.cart-table .td-line { font-weight: 600; white-space: nowrap; }
.cart-table .td-remove { width: 44px; text-align: center; }

.ci-media img {
  width: 72px; height: 72px; object-fit: contain; background: #fff;
  border: 1px solid var(--sh-border-soft); border-radius: var(--sh-radius-sm); padding: 4px;
}
.cart-table td[data-th="Product"] { min-width: 260px; }
.ci-name { display: block; font-weight: 600; color: var(--sh-text); }
.ci-name:hover { color: var(--sh-primary); }
.ci-brand, .ci-sku { display: block; font-size: var(--sh-font-size-xs); color: var(--sh-muted); }

.link-remove {
  background: none; border: 0; color: var(--sh-muted); font-size: 20px; cursor: pointer;
  line-height: 1; padding: 4px 8px; border-radius: var(--sh-radius-sm);
}
.link-remove:hover { color: var(--sh-danger); background: var(--sh-danger-soft); }

.qty-stepper {
  display: inline-flex; align-items: center; border: 1px solid var(--sh-border-strong);
  border-radius: var(--sh-radius); overflow: hidden; background: #fff;
}
.qty-stepper button {
  width: 32px; height: 36px; border: 0; background: none; cursor: pointer; font-size: 16px; color: var(--sh-muted);
}
.qty-stepper button:hover { background: var(--sh-bg-alt); color: var(--sh-primary); }
.qty-stepper input {
  width: 52px; height: 36px; border: 0; text-align: center; font-weight: 600;
  border-left: 1px solid var(--sh-border); border-right: 1px solid var(--sh-border);
  -moz-appearance: textfield; appearance: textfield; padding: 0;
}
.qty-stepper input::-webkit-outer-spin-button, .qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-stepper input:focus { outline: none; }

.cart-toolbar {
  display: flex; gap: var(--sh-space-3); flex-wrap: wrap; align-items: center;
  padding-top: var(--sh-space-4); margin-top: var(--sh-space-2); border-top: 1px solid var(--sh-divider);
}

/* ---------- Summary card ---------- */
.summary-card { position: sticky; top: 84px; }
.summary-card h2 { margin: 0 0 var(--sh-space-4); font-size: var(--sh-font-size-lg); }
.summary-label {
  font-size: var(--sh-font-size-xs); text-transform: uppercase; letter-spacing: .05em;
  color: var(--sh-muted); font-weight: 700; margin: 0 0 8px;
}

.ship-form { margin-bottom: var(--sh-space-4); }
.ship-opt, .pay-opt {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--sh-border); border-radius: var(--sh-radius);
  padding: 12px 14px; margin-bottom: 10px; cursor: pointer; transition: border-color .15s, background .15s;
}
.ship-opt:hover, .pay-opt:hover { border-color: var(--sh-border-strong); }
.ship-opt.selected, .ship-opt:has(input:checked), .pay-opt:has(input:checked) {
  border-color: var(--sh-primary); background: var(--sh-primary-soft);
}
.ship-opt input, .pay-opt input { margin-top: 3px; flex: none; }
.so-body { flex: 1; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.so-name { font-weight: 600; font-size: var(--sh-font-size-sm); }
.so-name small { display: block; font-weight: 400; color: var(--sh-muted); font-size: var(--sh-font-size-xs); margin-top: 2px; }
.so-cost { font-weight: 700; white-space: nowrap; }

dl.totals { margin: 0 0 var(--sh-space-4); display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: var(--sh-font-size-sm); }
dl.totals dt { color: var(--sh-muted); margin: 0; }
dl.totals dd { margin: 0; text-align: right; font-weight: 600; }
dl.totals dt.grand, dl.totals dd.grand {
  font-size: var(--sh-font-size-lg); font-weight: 800; color: var(--sh-text);
  border-top: 2px solid var(--sh-primary); padding-top: 10px; margin-top: 4px;
}

.free-ship-nudge {
  background: var(--sh-info-soft); border-radius: var(--sh-radius); padding: 10px 12px;
  font-size: var(--sh-font-size-xs); margin: 0 0 var(--sh-space-4); display: flex; gap: 8px; align-items: center;
}
.free-ship-nudge.ok { background: var(--sh-success-soft); color: var(--sh-success); }
.free-ship-nudge svg { width: 16px; height: 16px; flex: none; }

.coupon-form { display: flex; gap: 8px; margin-bottom: var(--sh-space-4); }
.coupon-form input { flex: 1; }
.coupon-applied {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--sh-success-soft); color: var(--sh-success); font-weight: 600;
  padding: 10px 14px; border-radius: var(--sh-radius); margin-bottom: var(--sh-space-4);
}
.checkout-btn { margin-top: var(--sh-space-2); }

/* ---------- Checkout form ---------- */
.checkout-form { padding: var(--sh-space-5) var(--sh-space-6); }
.co-section { padding-bottom: var(--sh-space-5); margin-bottom: var(--sh-space-5); border-bottom: 1px solid var(--sh-divider); }
.co-section:last-of-type { border-bottom: 0; }
.co-title { display: flex; align-items: center; gap: 12px; font-size: var(--sh-font-size-lg); margin: 0 0 var(--sh-space-4); }
.co-title span {
  width: 30px; height: 30px; border-radius: 50%; background: var(--sh-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex: none;
}

.co-items { list-style: none; margin: 0 0 var(--sh-space-4); padding: 0; display: grid; gap: 12px; }
.co-items li { display: flex; gap: 12px; align-items: center; }
.co-items img {
  width: 52px; height: 52px; object-fit: contain; border: 1px solid var(--sh-border-soft);
  border-radius: var(--sh-radius-sm); padding: 3px; background: #fff; flex: none;
}
.coi-name { flex: 1; font-size: var(--sh-font-size-sm); font-weight: 600; }
.coi-name small { display: block; font-weight: 400; color: var(--sh-muted); }
.coi-total { font-weight: 700; font-size: var(--sh-font-size-sm); white-space: nowrap; }

.secure-note { display: flex; gap: 8px; align-items: center; color: var(--sh-muted); font-size: var(--sh-font-size-xs); margin: 0; }
.secure-note svg { width: 14px; height: 14px; }

/* ---------- Success ---------- */
.success-card { text-align: center; padding: var(--sh-space-6); }
.success-card .sc-icon {
  width: 64px; height: 64px; margin: 0 auto var(--sh-space-3); border-radius: 50%;
  background: var(--sh-success-soft); color: var(--sh-success);
  display: flex; align-items: center; justify-content: center;
}
.success-card .sc-icon svg { width: 30px; height: 30px; }
.sc-lead { max-width: 560px; margin: 0 auto var(--sh-space-5); color: var(--sh-muted); }
.sc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sh-space-4); text-align: left; margin-bottom: var(--sh-space-5); }
.sc-grid .sc-address { grid-column: 1 / -1; }
.sc-grid p { margin: 0; font-size: var(--sh-font-size-sm); line-height: 1.6; }
@media (max-width: 640px) { .sc-grid { grid-template-columns: 1fr; } }

.order-table { width: 100%; border-collapse: collapse; text-align: left; margin-bottom: var(--sh-space-4); }
.order-table th {
  font-size: var(--sh-font-size-xs); text-transform: uppercase; color: var(--sh-muted);
  padding: 8px; border-bottom: 2px solid var(--sh-border);
}
.order-table td { padding: 10px 8px; border-bottom: 1px solid var(--sh-divider); font-size: var(--sh-font-size-sm); }
.order-table tfoot td { border-bottom: 0; padding: 6px 8px; color: var(--sh-muted); }
.order-table tfoot tr.grand td { font-weight: 800; font-size: var(--sh-font-size-lg); color: var(--sh-text); border-top: 2px solid var(--sh-primary); }

/* ---------- Account ---------- */
.account-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: var(--sh-space-5); align-items: start; }
@media (max-width: 899px) { .account-layout { grid-template-columns: 1fr; } }

.account-nav {
  background: #fff; border: 1px solid var(--sh-border-soft); border-radius: var(--sh-radius-lg);
  overflow: hidden; position: sticky; top: 84px;
}
.account-nav .an-head { padding: var(--sh-space-4); background: var(--sh-primary); color: #fff; }
.account-nav .an-head strong { display: block; font-size: var(--sh-font-size-lg); }
.account-nav .an-head span { font-size: var(--sh-font-size-xs); opacity: .8; }
.account-nav ul { list-style: none; margin: 0; padding: 0; }
.account-nav a {
  display: flex; gap: 10px; align-items: center; padding: 12px 16px;
  color: var(--sh-text); border-bottom: 1px solid var(--sh-divider);
}
.account-nav a:hover { background: var(--sh-bg-alt); color: var(--sh-primary); }
.account-nav a.active { background: var(--sh-primary-soft); color: var(--sh-primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--sh-primary); }
.account-nav svg { width: 16px; height: 16px; flex: none; }
@media (max-width: 899px) {
  .account-nav { position: static; }
  .account-nav ul { display: flex; overflow-x: auto; }
  .account-nav li { flex: none; }
  .account-nav a { border-bottom: 0; white-space: nowrap; }
}

.account-body > .card { margin-bottom: var(--sh-space-4); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sh-space-4); }
.dash-stat { background: #fff; border: 1px solid var(--sh-border-soft); border-radius: var(--sh-radius-lg); padding: var(--sh-space-4); }
.dash-stat .ds-label { font-size: var(--sh-font-size-xs); text-transform: uppercase; color: var(--sh-muted); letter-spacing: .05em; font-weight: 700; }
.dash-stat .ds-value { font-size: var(--sh-font-size-xl); font-weight: 800; margin-top: 6px; }
.dash-stat .ds-link { font-size: var(--sh-font-size-xs); }

.auth-card { max-width: 460px; margin: 0 auto; }
.auth-card .card-title { text-align: center; margin: 0 0 var(--sh-space-3); font-size: var(--sh-font-size-xl); }
.auth-card .card-sub { text-align: center; color: var(--sh-muted); font-size: var(--sh-font-size-sm); margin: 0 0 var(--sh-space-5); }
.auth-switch { text-align: center; margin-top: var(--sh-space-4); font-size: var(--sh-font-size-sm); color: var(--sh-muted); }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--sh-muted); font-size: var(--sh-font-size-xs); margin: var(--sh-space-4) 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--sh-border); }

/* ---------- Orders (account + admin) ---------- */
.orders-table, .data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: var(--sh-font-size-xs); text-transform: uppercase; letter-spacing: .04em;
  color: var(--sh-muted); padding: 10px 12px; border-bottom: 2px solid var(--sh-border); white-space: nowrap;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--sh-divider); font-size: var(--sh-font-size-sm); vertical-align: middle; }
.data-table tr:hover td { background: var(--sh-bg-alt); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .strong { font-weight: 700; }
.order-thumb { width: 40px; height: 40px; object-fit: contain; border: 1px solid var(--sh-border-soft); border-radius: 6px; padding: 2px; background: #fff; }

.order-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sh-space-4); margin-bottom: var(--sh-space-5); }
.od-card { background: var(--sh-bg-alt); border-radius: var(--sh-radius); padding: var(--sh-space-4); font-size: var(--sh-font-size-sm); line-height: 1.6; }
.od-card h3 { margin: 0 0 8px; font-size: var(--sh-font-size-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--sh-muted); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 var(--sh-space-4) var(--sh-space-5); border-left: 2px solid var(--sh-border); }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--sh-primary); border: 2px solid #fff;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline .tl-status { font-weight: 700; }
.timeline .tl-meta { color: var(--sh-muted); font-size: var(--sh-font-size-xs); }

/* Address book */
.address-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sh-space-4); }
.address-card { border: 1px solid var(--sh-border-soft); border-radius: var(--sh-radius-lg); padding: var(--sh-space-4); position: relative; }
.address-card.default { border-color: var(--sh-primary); box-shadow: 0 0 0 1px var(--sh-primary); }
.address-card h3 { margin: 0 0 6px; font-size: var(--sh-font-size-sm); }
.address-card p { margin: 0 0 var(--sh-space-3); font-size: var(--sh-font-size-sm); color: var(--sh-muted); line-height: 1.6; }
.addr-tags { display: flex; gap: 6px; margin-bottom: 8px; }
.addr-actions { display: flex; gap: 10px; }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; background: var(--sh-primary-soft); color: var(--sh-primary); padding: 3px 8px; border-radius: 999px; }

/* Empty state + page head */
.empty-state { text-align: center; padding: var(--sh-space-8) var(--sh-space-4); }
.empty-state .es-icon {
  width: 72px; height: 72px; margin: 0 auto var(--sh-space-3); border-radius: 50%;
  background: var(--sh-bg-alt); color: var(--sh-muted); display: flex; align-items: center; justify-content: center;
}
.empty-state .es-icon svg { width: 32px; height: 32px; }
.empty-state p { color: var(--sh-muted); max-width: 420px; margin: 0 auto var(--sh-space-4); }

.page-head { background: var(--sh-bg-alt); border-bottom: 1px solid var(--sh-border); padding: var(--sh-space-5) 0; }
.page-head h1 { margin: 4px 0 2px; font-size: var(--sh-font-size-xl); }
.page-head p { margin: 0; color: var(--sh-muted); font-size: var(--sh-font-size-sm); }

/* Toolbar/filter bar used by order lists + account tables */
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--sh-space-4); flex-wrap: wrap; margin-bottom: var(--sh-space-4); }
.tabs-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs-row .pill { text-decoration: none; }

/* Small screens: turn the cart table into stacked rows */
@media (max-width: 767px) {
  .cart-table thead { display: none; }
  .cart-table, .cart-table tbody, .cart-table tr, .cart-table td { display: block; width: 100%; }
  .cart-table tr { border-bottom: 1px solid var(--sh-border); padding: 12px 0; }
  .cart-table td { border: 0; padding: 6px 0; }
  .cart-table td[data-th]::before {
    content: attr(data-th); display: block; font-size: 11px; text-transform: uppercase; color: var(--sh-muted); font-weight: 700;
  }
  .cart-table td[data-th="Product"]::before { display: none; }
  .cart-table td[data-th="Product"] { display: flex; gap: 12px; align-items: center; }
  .cart-table .td-qty, .cart-table .td-remove { display: inline-block; width: auto; }
  .summary-card { position: static; }
}
