/*
 * Best Before · My account (Concept B §4.8). Loaded only on is_account_page()
 * (login/register view included) - see inc/pages/account.php.
 * Buttons, inputs, selects and textareas already pick up the bb- look from
 * main.css (.bb-btn/.button, .bb-input/.input-text); this file covers the
 * account-specific layout and the native Woo endpoints that are styled by
 * CSS alone (orders list, view order, addresses, edit account, lost
 * password) rather than template overrides.
 */

/* ---------- Logged-out: login / register ---------- */
.bb-authgate { display: grid; gap: 20px; max-width: 900px; margin: 0 auto; }
.bb-authgate--split { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.bb-authgate__panel h2 { margin-bottom: 18px; }
.bb-authgate__form .bb-field:last-of-type { margin-bottom: 12px; }
.bb-authgate__row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin: 4px 0 10px; }
.bb-authgate__remember { display: flex; align-items: center; gap: 8px; font-size: .875rem; color: var(--bb-muted); }
.bb-authgate .lost_password { margin: 0; font-size: .875rem; }
.bb-authgate .lost_password a { font-weight: 600; }

/* ---------- Logged-in shell: 240px nav + content ---------- */
.bb-account { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; align-items: start; }
.bb-account__nav { position: sticky; top: 16px; }
.bb-account__navlist { background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-r-panel); padding: 8px; }
.bb-account__navul { display: grid; gap: 2px; }
.bb-account__navlink { display: flex; align-items: center; min-height: var(--bb-touch); padding: 0 16px; border-radius: var(--bb-r-control); color: var(--bb-ink); font-weight: 500; text-decoration: none; }
.bb-account__navlink:hover { background: var(--bb-ground); text-decoration: none; }
.bb-account__navlink.is-active { background: var(--bb-ink); color: var(--bb-yellow); font-weight: 700; }
.bb-account__navlink.is-active:hover { background: #000; }
.bb-account__navlink--muted { color: var(--bb-muted); }
.bb-account__content { display: grid; gap: 24px; min-width: 0; }
.bb-account__heading, .bb-account__greeting { margin: 0; }
.bb-account__bottomrow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.bb-account__branchnote { margin: 10px 0 0; font-size: .875rem; }

/* ---------- Rewards (dashboard + full Rewards tab) ---------- */
.bb-rewards { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; }
.bb-rewards__balance { display: flex; flex-direction: column; gap: 10px; }
.bb-rewards__label { font-size: .875rem; text-transform: uppercase; letter-spacing: .03em; margin: 0; }
.bb-rewards__figurerow { display: flex; align-items: baseline; gap: 12px; }
.bb-rewards__figure { font-family: var(--bb-font-display); font-size: clamp(2.75rem, 2rem + 3vw, 5rem); font-weight: 800; color: #fff; line-height: 1; }
.bb-rewards__unit { font-size: 1.125rem; font-weight: 700; color: #fff; }
.bb-rewards__value { margin: 0; font-size: 1.0625rem; color: #fff; }
.bb-rewards__value strong { color: var(--bb-yellow); }
.bb-rewards__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.bb-earn__list { display: grid; gap: 12px; margin: 0 0 12px; }
.bb-earn__list li { display: flex; align-items: center; gap: 12px; font-size: .9375rem; }
.bb-earn__tag { display: inline-flex; flex: none; align-items: center; justify-content: center; min-width: 48px; height: 32px; padding: 0 8px; border-radius: var(--bb-r-small); background: var(--bb-yellow); color: var(--bb-ink); font-weight: 800; font-size: .875rem; }

/* ---------- Recent orders ---------- */
.bb-orders__head, .bb-saved .bb-orders__head, .bb-addresses .bb-orders__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.bb-orders__head h2 { margin: 0; }
.bb-orders__list { display: grid; }
.bb-orders__row { display: grid; grid-template-columns: minmax(0, 1.4fr) auto auto auto; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--bb-border); }
.bb-orders__list .bb-orders__row:first-child { border-top: 0; padding-top: 0; }
.bb-orders__id { display: grid; gap: 2px; min-width: 0; }
.bb-orders__total { text-align: right; white-space: nowrap; }
.bb-orders__actions { display: flex; gap: 8px; flex: none; }

.bb-status { display: inline-flex; align-items: center; height: 26px; padding: 0 12px; border-radius: var(--bb-r-pill); font-size: .8125rem; font-weight: 700; white-space: nowrap; justify-self: start; }
.bb-status--success { background: var(--bb-success-bg); color: var(--bb-success); }
.bb-status--warn { background: var(--bb-soft-yellow); color: var(--bb-ink); }
.bb-status--muted { background: var(--bb-ground); color: var(--bb-muted); }
.bb-status--neutral { background: var(--bb-ground); color: var(--bb-ink-2); }

/* ---------- Points history ---------- */
.bb-ptable { display: grid; font-size: .9375rem; }
.bb-ptable__row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 90px 90px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--bb-border); }
.bb-ptable__row:first-child { border-top: 0; }
.bb-ptable__row--head { padding-top: 0; font-size: .8125rem; font-weight: 600; color: var(--bb-muted); }
.bb-ptable__pts { font-weight: 700; }
.bb-ptable__pts.is-negative { color: var(--bb-urgency); }
.bb-ptable__pts.is-positive { color: var(--bb-success); }

/* ---------- Addresses + saved items (bottom row) ---------- */
.bb-addresses__item { padding: 14px 0; border-top: 1px solid var(--bb-border); font-size: .9375rem; }
.bb-addresses__item:first-of-type { border-top: 0; padding-top: 0; }
.bb-addresses__item strong { display: block; margin-bottom: 4px; }
/* A8: a bordered card with a truck icon, not a plain multi-line block. */
.bb-addresses__item--card { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--bb-border); border-radius: var(--bb-r-tile); padding: 14px 16px; }
.bb-addresses__item--card:first-of-type { border-top: 1px solid var(--bb-border); padding-top: 14px; }
.bb-addresses__icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--bb-r-small); background: var(--bb-ground); color: var(--bb-ink); margin-top: 1px; }
.bb-addresses__body { min-width: 0; }
.bb-addresses__branchline { margin: 10px 0 0; }
.bb-saved__list { display: grid; gap: 12px; }
.bb-saved__row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 72px 64px; align-items: center; gap: 12px; }
.bb-saved__thumb { display: block; width: 56px; height: 56px; flex: none; border-radius: var(--bb-r-small); overflow: hidden; background: var(--bb-ground); }
.bb-saved__thumb img { width: 100%; height: 100%; object-fit: contain; }
.bb-saved__info { min-width: 0; display: grid; gap: 2px; }
.bb-saved__name { font-size: .875rem; font-weight: 600; color: var(--bb-ink); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bb-saved__price { font-size: 1.0625rem; text-align: right; white-space: nowrap; }

/* ---------- Native Woo endpoints: orders list, view order, addresses, account details, lost password ---------- */
.woocommerce-MyAccount-content .shop_table,
.woocommerce-orders-table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.woocommerce-orders-table thead th { text-align: left; padding: 0 0 10px; font-size: .8125rem; font-weight: 600; color: var(--bb-muted); border-bottom: 1px solid var(--bb-border); }
.woocommerce-orders-table tbody td, .woocommerce-orders-table tbody th { padding: 14px 10px 14px 0; border-top: 1px solid var(--bb-border); vertical-align: middle; }
.woocommerce-orders-table .woocommerce-orders-table__cell-order-actions { text-align: right; white-space: nowrap; }
.woocommerce-orders-table .woocommerce-orders-table__cell-order-actions a { margin-left: 6px; }
/* A10: a real status pill, matching the dashboard's .bb-status look, not plain coloured text. */
.woocommerce-orders-table__cell-order-status { display: inline-flex; align-items: center; height: 26px; padding: 0 12px !important; border-radius: var(--bb-r-pill); font-weight: 700; font-size: .8125rem; white-space: nowrap; }
tr.woocommerce-orders-table__row--status-completed .woocommerce-orders-table__cell-order-status,
tr.woocommerce-orders-table__row--status-shipped .woocommerce-orders-table__cell-order-status { color: var(--bb-success); background: var(--bb-success-bg); }
tr.woocommerce-orders-table__row--status-processing .woocommerce-orders-table__cell-order-status,
tr.woocommerce-orders-table__row--status-on-hold .woocommerce-orders-table__cell-order-status,
tr.woocommerce-orders-table__row--status-partially-shipped .woocommerce-orders-table__cell-order-status { color: #946200; background: var(--bb-soft-yellow); }
tr.woocommerce-orders-table__row--status-cancelled .woocommerce-orders-table__cell-order-status,
tr.woocommerce-orders-table__row--status-failed .woocommerce-orders-table__cell-order-status,
tr.woocommerce-orders-table__row--status-refunded .woocommerce-orders-table__cell-order-status { color: var(--bb-muted); background: var(--bb-ground); }

.woocommerce-order-details mark.order-status, .woocommerce-MyAccount-content mark { background: none; color: var(--bb-ink); font-weight: 700; padding: 0; }
.woocommerce-order-details .woocommerce-order-details__title { margin-bottom: 16px; }

.woocommerce-order-details, .woocommerce-customer-details, .woocommerce-order-downloads {
	background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-r-panel); padding: clamp(18px, 2.4vw, 28px); margin: 0 0 20px;
}
.woocommerce-order-details .shop_table, .woocommerce-table--order-details { border-collapse: collapse; width: 100%; }
.woocommerce-table--order-details th, .woocommerce-table--order-details td { padding: 10px 8px; border-top: 1px solid var(--bb-border); text-align: left; }
.woocommerce-table--order-details tfoot th, .woocommerce-table--order-details tfoot td { font-weight: 700; }
.woocommerce-customer-details address { font-style: normal; }
.woocommerce-column--billing-address, .woocommerce-column--shipping-address { margin-top: 16px; }

.woocommerce-Addresses.addresses, .u-columns.col2-set { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.woocommerce-Address { background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-r-panel); padding: clamp(18px, 2.4vw, 24px); }
.woocommerce-Address-title.title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.woocommerce-Address-title.title h2 { margin: 0; font-size: 1.25rem; }
.woocommerce-Address-title.title .edit { font-weight: 700; text-decoration: none; }
.woocommerce-Address address { font-style: normal; font-size: .9375rem; }

.woocommerce-EditAccountForm, .woocommerce-address-fields, .woocommerce-ResetPassword {
	display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; max-width: 760px;
}
.woocommerce-EditAccountForm .form-row-wide, .woocommerce-address-fields .form-row-wide,
.woocommerce-EditAccountForm fieldset, .woocommerce-EditAccountForm p:not(.form-row),
.woocommerce-EditAccountForm > p:last-child { grid-column: 1 / -1; }
.woocommerce-EditAccountForm fieldset { border: 0; padding: 0; margin: 10px 0 0; }
.woocommerce-EditAccountForm legend { font-weight: 700; margin-bottom: 10px; padding: 0; }
.woocommerce-EditAccountForm .clear { display: none; }
.woocommerce-ResetPassword.lost_reset_password { max-width: 420px; }
.woocommerce-ResetPassword .form-row-wide { grid-column: 1 / -1; }

/* ---------- Mobile (<768): nav becomes a horizontal chip scroller ---------- */
@media (max-width: 767px) {
	.bb-account, .bb-rewards, .bb-account__bottomrow,
	.woocommerce-Addresses.addresses, .u-columns.col2-set,
	.woocommerce-EditAccountForm, .woocommerce-address-fields { grid-template-columns: 1fr; }
	.bb-authgate--split { grid-template-columns: 1fr; }
	.bb-account__nav { position: static; min-width: 0; }
	/* A13: fade the right edge so the horizontal pill row reads as scrollable (same cue as the chip bar). */
	.bb-account__navlist { background: transparent; border: 0; padding: 0; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
	.bb-account__navlist::-webkit-scrollbar { display: none; }
	.bb-account__navul { display: flex; gap: 8px; padding-bottom: 4px; }
	.bb-account__navul > li { flex: none; }
	.bb-account__navlink { border: 1px solid var(--bb-border); border-radius: var(--bb-r-pill); white-space: nowrap; }
	.bb-account__navlink.is-active { border-color: var(--bb-ink); }
	.bb-orders__row { grid-template-columns: 1fr; gap: 8px; }
	.bb-orders__total, .bb-orders__actions { justify-self: start; text-align: left; }
	.bb-ptable__row { grid-template-columns: 1fr 1fr; grid-template-areas: "date pts" "desc desc" "bal bal"; row-gap: 4px; }
	.bb-ptable__row--head { display: none; }
	.bb-saved__row { grid-template-columns: 48px minmax(0, 1fr) auto; }
	.bb-saved__price { display: none; }

	/* A11: the native WooCommerce "Orders" table overflowed to ~422px at 390 -
	   stack it into cards instead of letting it scroll horizontally. The
	   core template already prints a data-title attribute on every cell
	   (woocommerce/templates/myaccount/orders.php), so this needs no markup
	   override, just the responsive-table pattern. */
	.woocommerce-orders-table thead { position: absolute; left: -9999px; top: -9999px; }
	.woocommerce-orders-table, .woocommerce-orders-table tbody, .woocommerce-orders-table tr { display: block; width: 100%; }
	.woocommerce-orders-table tr { margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--bb-border); border-radius: var(--bb-r-tile); }
	.woocommerce-orders-table tbody td, .woocommerce-orders-table tbody th { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 6px 0; border-top: 0; text-align: right; }
	.woocommerce-orders-table tbody td::before, .woocommerce-orders-table tbody th::before { content: attr(data-title); flex: none; font-size: .8125rem; font-weight: 600; color: var(--bb-muted); text-align: left; }
	.woocommerce-orders-table .woocommerce-orders-table__cell-order-actions { justify-content: flex-end; }
	.woocommerce-orders-table .woocommerce-orders-table__cell-order-actions::before { display: none; }
	.woocommerce-orders-table .woocommerce-orders-table__cell-order-actions a { margin: 0 0 0 8px; }
}
