/**
 * WooCommerce My Account — card layout + sidebar nav (matches CBS site tokens).
 */

.cbs-account-wrap .entry-header {
	margin-bottom: var(--cbs-entry-header-spacing, 24px);
}

.cbs-account-wrap .entry-title {
	margin: 0;
	font-size: var(--cbs-font-size-entry-title, 32px);
	font-weight: var(--cbs-font-weight-entry-title, 700);
	line-height: 1.25;
	color: var(--cbs-heading-color, #1a1a1a);
}

/* Logged-in dashboard: sidebar nav + content (not login/register). */
.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) {
	display: grid;
	grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
	gap: 0 28px;
	align-items: start;
}

/* WooCommerce prepends an (often empty) notices wrapper as the first child;
   force it to span both columns so it doesn't consume the nav's grid cell. */
.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) > .woocommerce-notices-wrapper {
	grid-column: 1 / -1;
	margin: 0;
}

.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) .woocommerce-MyAccount-navigation {
	float: none;
	width: auto;
	grid-column: 1;
}

.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) .woocommerce-MyAccount-content {
	float: none;
	width: auto;
	grid-column: 2;
}

.woocommerce-MyAccount-navigation ul {
	list-style: none;
	margin: 0;
	padding: 0;
	background: #f6f7f7;
	border: 1px solid var(--cbs-border, #d5dbe3);
	border-radius: 8px;
	overflow: hidden;
}

.woocommerce-MyAccount-navigation li {
	margin: 0;
	border-bottom: 1px solid var(--cbs-border, #d5dbe3);
}

.woocommerce-MyAccount-navigation li:last-child {
	border-bottom: none;
}

.woocommerce-MyAccount-navigation a {
	display: block;
	padding: 12px 16px;
	color: var(--cbs-text, #3a3a3a);
	font-size: var(--cbs-font-size-body, 16px);
	font-weight: var(--cbs-font-weight-nav, 500);
	line-height: 1.4;
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.woocommerce-MyAccount-navigation a:hover,
.woocommerce-MyAccount-navigation a:focus {
	background: #fff;
	color: var(--cbs-brand, #195a5b);
}

.woocommerce-MyAccount-navigation-link.is-active a {
	background: #fff;
	color: var(--cbs-brand, #195a5b);
	box-shadow: inset 3px 0 0 var(--cbs-brand, #195a5b);
}

.woocommerce-MyAccount-navigation-link--customer-logout a:hover,
.woocommerce-MyAccount-navigation-link--customer-logout a:focus {
	color: #8a0000;
}

.woocommerce-MyAccount-content {
	float: none;
	width: auto;
	background: #fff;
	border: 1px solid var(--cbs-border, #d5dbe3);
	border-radius: 8px;
	padding: 24px 28px;
	color: var(--cbs-text, #3a3a3a);
	font-size: var(--cbs-font-size-body, 16px);
	font-weight: var(--cbs-font-weight-body, 400);
	line-height: var(--cbs-line-height-body, 1.65);
}

.woocommerce-MyAccount-content > p:first-child {
	margin-top: 0;
}

/*
 * Content card padding is the bottom inset — drop trailing margin on the last
 * direct child only (dashboard last paragraph, orders/downloads table, etc.).
 * Spacing between earlier siblings is unchanged.
 */
.woocommerce-account .woocommerce-MyAccount-content > *:last-child {
	margin-bottom: 0;
}

/* shop_table sets margin-bottom 1.5rem (0,3,1) — beats > *:last-child (0,3,0); zero when it closes the card. */
.woocommerce-account .woocommerce-MyAccount-content > table.shop_table:last-child,
.woocommerce-account .woocommerce-MyAccount-content > .woocommerce-order-downloads:last-child table.shop_table {
	margin-bottom: 0;
}

/* Licences / Subscriptions wrap table + notice in a div (not direct card children). */
.woocommerce-account .woocommerce-MyAccount-content .cbsl-my-account-licences > *:last-child,
.woocommerce-account .woocommerce-MyAccount-content .cbss-my-account-subscriptions > *:last-child {
	margin-bottom: 0;
}

/* Account details: form rows are <p>; .entry-content p adds paragraph spacing below fields. */
.woocommerce-account .woocommerce-MyAccount-content .woocommerce-EditAccountForm p {
	margin-bottom: 0;
}

/*
 * My Account notices: always keep 20px below the banner so it does not sit flush
 * on Dashboard / Licences / Subscriptions / etc. Woo often wraps the notice in
 * .woocommerce-notices-wrapper as the only child, so :not(:last-child) on the
 * notice itself never matched and margin stayed 0.
 */
.woocommerce-account .woocommerce-MyAccount-content > .woocommerce-notices-wrapper:not(:empty),
.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) > .woocommerce-notices-wrapper:not(:empty) {
	margin-bottom: 20px;
}

.woocommerce-account .woocommerce-MyAccount-content > .woocommerce-message,
.woocommerce-account .woocommerce-MyAccount-content > .woocommerce-info,
.woocommerce-account .woocommerce-MyAccount-content > .woocommerce-error {
	margin-bottom: 20px;
}

.woocommerce-account .woocommerce-MyAccount-content .woocommerce-notices-wrapper .woocommerce-message,
.woocommerce-account .woocommerce-MyAccount-content .woocommerce-notices-wrapper .woocommerce-info,
.woocommerce-account .woocommerce-MyAccount-content .woocommerce-notices-wrapper .woocommerce-error,
.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) > .woocommerce-notices-wrapper .woocommerce-message,
.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) > .woocommerce-notices-wrapper .woocommerce-info,
.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) > .woocommerce-notices-wrapper .woocommerce-error {
	margin-bottom: 0;
}

.woocommerce-MyAccount-content a {
	color: var(--cbs-brand, #195a5b);
	text-decoration: var(--cbs-link-text-decoration, underline);
	text-underline-offset: 0.12em;
}

.woocommerce-MyAccount-content a:hover,
.woocommerce-MyAccount-content a:focus {
	color: var(--cbs-brand-hover, #134a4b);
	text-decoration: var(--cbs-link-text-decoration-hover, underline);
}

.woocommerce-account .woocommerce table.shop_table {
	width: 100%;
	border: 1px solid var(--cbs-border, #d5dbe3);
	border-radius: 8px;
	border-collapse: separate;
	border-spacing: 0;
	overflow: hidden;
	margin: 0 0 1.5rem;
}

/* WooCommerce adds border-top on td; we use border-bottom dividers only (avoids double lines). */
.woocommerce-account .woocommerce table.shop_table th,
.woocommerce-account .woocommerce table.shop_table td {
	padding: 12px 16px;
	border-top: 0;
	border-left: 0;
	border-right: 0;
	border-bottom: 1px solid var(--cbs-border, #d5dbe3);
	text-align: left;
	vertical-align: middle;
	font-size: var(--cbs-font-size-body, 16px);
	font-weight: var(--cbs-font-weight-body, 400);
}

.woocommerce-account .woocommerce table.shop_table thead th {
	background: #f6f7f7;
	color: var(--cbs-heading-color, #1a1a1a);
	font-size: var(--cbs-font-size-meta, 14px);
	font-weight: var(--cbs-font-weight-h4, 700);
}

.woocommerce-account .woocommerce table.shop_table tbody th,
.woocommerce-account .woocommerce table.shop_table tfoot th {
	font-size: var(--cbs-font-size-body, 16px);
	font-weight: var(--cbs-font-weight-h4, 700);
}

.woocommerce-account .woocommerce table.shop_table tfoot td {
	font-size: var(--cbs-font-size-body, 16px);
	font-weight: var(--cbs-font-weight-body, 400);
}

.woocommerce-account .woocommerce table.shop_table tbody tr:last-child td,
.woocommerce-account .woocommerce table.shop_table tbody tr:last-child th {
	border-bottom: none;
}

.woocommerce-account .woocommerce table.shop_table .button {
	margin-right: 0.35rem;
}

/*
 * My Account action columns — narrow width, right-aligned buttons (Orders, Downloads,
 * Payment methods, CBS Licences order link).
 */
.woocommerce-account table.shop_table th.order-actions,
.woocommerce-account table.shop_table td.order-actions,
.woocommerce-account table.shop_table th.woocommerce-orders-table__header-order-actions,
.woocommerce-account table.shop_table td.woocommerce-orders-table__cell-order-actions,
.woocommerce-account table.shop_table th.download-actions,
.woocommerce-account table.shop_table td.download-actions,
.woocommerce-account table.shop_table th.download-file,
.woocommerce-account table.shop_table td.download-file,
.woocommerce-account table.shop_table th.payment-method-actions,
.woocommerce-account table.shop_table td.payment-method-actions,
.woocommerce-account table.shop_table th.woocommerce-PaymentMethod--actions,
.woocommerce-account table.shop_table td.woocommerce-PaymentMethod--actions,
.woocommerce-account .cbsl-licences-table th.cbsl-licences-table__order,
.woocommerce-account .cbsl-licences-table td.cbsl-licences-table__order {
	width: 1%;
	white-space: nowrap;
	text-align: right;
}

.woocommerce-account table.shop_table td.order-actions .button,
.woocommerce-account table.shop_table td.woocommerce-orders-table__cell-order-actions .button,
.woocommerce-account table.shop_table td.download-actions .button,
.woocommerce-account table.shop_table td.download-file .button,
.woocommerce-account table.shop_table td.payment-method-actions .button,
.woocommerce-account table.shop_table td.woocommerce-PaymentMethod--actions .button {
	margin-right: 0;
}

.woocommerce-account table.shop_table td.order-actions .button + .button,
.woocommerce-account table.shop_table td.woocommerce-orders-table__cell-order-actions .button + .button,
.woocommerce-account table.shop_table td.download-actions .button + .button,
.woocommerce-account table.shop_table td.download-file .button + .button,
.woocommerce-account table.shop_table td.payment-method-actions .button + .button,
.woocommerce-account table.shop_table td.woocommerce-PaymentMethod--actions .button + .button {
	margin-left: 0.35rem;
}

.woocommerce-account .woocommerce-pagination {
	margin-top: 1rem;
}

.woocommerce-account fieldset {
	margin: 1.5rem 0;
	padding: 1.25rem 1.5rem;
	border: 1px solid var(--cbs-border, #d5dbe3);
	border-radius: 8px;
}

.woocommerce-account fieldset legend {
	padding: 0 0.35rem;
	font-weight: 600;
	color: var(--cbs-heading-color, #1a1a1a);
}

.woocommerce-account .woocommerce-Addresses .title {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem 0;
	margin-bottom: 0.75rem;
	flex-direction: column;
}

.woocommerce-account .woocommerce-Addresses .title h3 {
	margin: 0;
	font-size: 1.1rem;
}

.woocommerce-account address {
	margin: 0;
	padding: 0;
	border: none;
	font-style: normal;
	line-height: 1.6;
}

@media (max-width: 781px) {
	.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) {
		grid-template-columns: 1fr;
		gap: 20px;
	}

	.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) .woocommerce-MyAccount-navigation,
	.woocommerce-account .woocommerce:has(.woocommerce-MyAccount-navigation) .woocommerce-MyAccount-content {
		grid-column: 1;
	}

	.woocommerce-MyAccount-content {
		padding: 20px;
	}

	/* Non-responsive tables only — horizontal scroll. Responsive tables use Woo's stacked layout. */
	.woocommerce-account table.shop_table:not(.shop_table_responsive) {
		display: block;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.woocommerce-account table.shop_table_responsive,
	.woocommerce-account table.shop_table_responsive tbody,
	.woocommerce-account table.shop_table_responsive tr {
		width: 100%;
	}

	.woocommerce-account table.shop_table_responsive tr td {
		width: 100%;
		box-sizing: border-box;
	}

	/* Reset desktop action-column shrink rules when cells stack on small screens. */
	.woocommerce-account table.shop_table_responsive th.order-actions,
	.woocommerce-account table.shop_table_responsive td.order-actions,
	.woocommerce-account table.shop_table_responsive th.woocommerce-orders-table__header-order-actions,
	.woocommerce-account table.shop_table_responsive td.woocommerce-orders-table__cell-order-actions,
	.woocommerce-account table.shop_table_responsive th.download-actions,
	.woocommerce-account table.shop_table_responsive td.download-actions,
	.woocommerce-account table.shop_table_responsive th.download-file,
	.woocommerce-account table.shop_table_responsive td.download-file {
		width: 100%;
		white-space: normal;
		text-align: left !important;
	}

	.woocommerce-account table.shop_table_responsive th.payment-method-actions,
	.woocommerce-account table.shop_table_responsive td.payment-method-actions,
	.woocommerce-account table.shop_table_responsive th.woocommerce-PaymentMethod--actions,
	.woocommerce-account table.shop_table_responsive td.woocommerce-PaymentMethod--actions {
		width: 100%;
		white-space: normal;
		text-align: left !important;
		/* Woo appends &nbsp; after each action link; collapse it when buttons stack. */
		font-size: 0;
		line-height: 0;
	}

	/*
	 * Payment methods actions: Woo uses &nbsp; as the column title, so the responsive
	 * data-title pseudo-label renders as a lone ":". Hide it; full-width action buttons.
	 */
	.woocommerce-account table.shop_table_responsive td.payment-method-actions::before,
	.woocommerce-account table.shop_table_responsive td.woocommerce-PaymentMethod--actions::before {
		display: none;
	}

	.woocommerce-account table.shop_table_responsive td.payment-method-actions .button,
	.woocommerce-account table.shop_table_responsive td.woocommerce-PaymentMethod--actions .button {
		display: block;
		width: 100%;
		margin: 3px 0;
		font-size: var(--cbs-font-size-body, 16px);
		line-height: 1.4;
		text-align: center;
		box-sizing: border-box;
	}

	.woocommerce-account table.shop_table_responsive td.payment-method-actions .button + .button,
	.woocommerce-account table.shop_table_responsive td.woocommerce-PaymentMethod--actions .button + .button {
		margin-left: 0;
	}
}
