/*
 * Woo notices (site-wide on Woo pages), shared Woo tables and forms, and my account.
 * Spec: docs/migration/woocommerce.md §4. Notice colours are Bricks' defaults darkened to pass AA.
 */

:root {
	--woo-info: #0069a1;
	--woo-info-bg: #e5f3ff;
	--woo-success: #0b7a45;
	--woo-success-bg: #e6f6ed;
	--woo-error: #c4122f;
	--woo-error-bg: #ffe6ec;
}

:is(.woocommerce-message, .woocommerce-info, .woocommerce-error) {
	--notice: var(--woo-info);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px 20px;
	margin: 0 0 30px;
	padding: 15px;
	background: var(--woo-info-bg);
	color: var(--notice);
	font-size: 15px;
	line-height: 1.7;
	list-style: none;
}

.woocommerce-message {
	--notice: var(--woo-success);
	background: var(--woo-success-bg);
}

.woocommerce-error {
	--notice: var(--woo-error);
	flex-direction: column;
	align-items: stretch;
	background: var(--woo-error-bg);
}

:is(.woocommerce-message, .woocommerce-info, .woocommerce-error) a {
	color: inherit;
	font-weight: 700;
	text-decoration: underline;
}

:is(.woocommerce-message, .woocommerce-info, .woocommerce-error) :is(a.button, .button) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	order: 2;
	min-height: 40px;
	padding: 7px 15px;
	border: 0;
	background: var(--notice);
	color: var(--wp--preset--color--white);
	font-weight: 700;
	text-decoration: none;
}

.woocommerce-notices-wrapper:empty {
	display: none;
}

/* Woo focuses a fresh notice (tabindex=-1) so screen readers announce it; it is not a control. */
:is(.woocommerce-message, .woocommerce-info, .woocommerce-error)[tabindex="-1"]:focus {
	outline: none;
}

.woocommerce table.shop_table {
	width: 100%;
	border-collapse: collapse;
	font-size: 15px;
	text-align: left;
}

.woocommerce table.shop_table :is(th, td) {
	padding: 15px 10px;
	border-bottom: 1px solid var(--wp--preset--color--mid-grey);
	vertical-align: middle;
}

.woocommerce table.shop_table th {
	font-weight: 700;
}

.woocommerce table.shop_table thead th {
	padding-block: 19px;
}

.woocommerce table.shop_table a {
	color: inherit;
}

/* Zero-ish specificity so notice and .btn-primary buttons keep their own look. */
:where(.woocommerce-account .woocommerce) :is(.button, button[type="submit"]):where(:not(.btn-primary)) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 7px 15px;
	border: 0;
	background: var(--wp--preset--color--black);
	color: var(--wp--preset--color--white);
	font-weight: 500;
	letter-spacing: 0.5px;
	line-height: 1.15;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.2s;
}

:where(.woocommerce-account .woocommerce) :is(.button, button[type="submit"]):where(:not(.btn-primary)):where(:hover:not(:disabled)) {
	background: var(--wp--preset--color--grey);
}

:where(.woocommerce-account .woocommerce) :is(.button, button):disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

.woocommerce form .form-row {
	display: flex;
	flex-direction: column;
	gap: 5px;
	margin: 0 0 15px;
}

.woocommerce form .form-row label:has(> input[type="checkbox"]) {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.woocommerce form .required {
	color: inherit;
	text-decoration: none;
}

.woocommerce :is(.woocommerce-address-fields__field-wrapper, .woocommerce-EditAccountForm) {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: 20px;
}

.woocommerce :is(.woocommerce-address-fields__field-wrapper, .woocommerce-EditAccountForm) > :not(.form-row-first, .form-row-last) {
	grid-column: 1 / -1;
}

.woocommerce fieldset {
	margin: 15px 0;
	padding: 20px;
	border: 1px solid var(--wp--preset--color--mid-grey);
}

.woocommerce legend {
	padding-inline: 5px;
	font-weight: 700;
}

.woocommerce .password-input {
	position: relative;
	display: block;
}

.woocommerce .password-input input {
	padding-right: 44px;
}

.woocommerce .show-password-input {
	position: absolute;
	top: 0;
	right: 0;
	width: 42px;
	height: 100%;
	border: 0;
	background: var(--wp--preset--color--black);
	cursor: pointer;
	mask: url("../icons/eye.svg") center / 20px no-repeat;
}

.woocommerce .show-password-input.display-password {
	mask-image: url("../icons/eye-off.svg");
}

/* Woo's `col-1`/`col-2` are also Tailwind grid-column utilities (docs/styling.md); unlayered CSS wins. */
.woocommerce :is(.col2-set, .woocommerce-Addresses) {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 30px;
}

.woocommerce :is(.col2-set, .woocommerce-Addresses) > :is(.col-1, .col-2) {
	grid-column: auto;
}

.woocommerce select {
	height: 42px;
}

.woocommerce mark {
	background: none;
	color: inherit;
	font-weight: 700;
}

.woocommerce-MyAccount-content section {
	margin-top: 30px;
}

.woocommerce address {
	font-style: normal;
	line-height: 1.7;
}

.woocommerce-account .woocommerce:has(> .woocommerce-MyAccount-navigation) {
	display: flex;
	align-items: flex-start;
	gap: 40px;
}

.woocommerce-MyAccount-navigation {
	flex: 0 0 213px;
	background: #f5f6f7;
}

.woocommerce-MyAccount-navigation ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.woocommerce-MyAccount-navigation a {
	display: flex;
	align-items: center;
	min-height: 60px;
	padding: 0 30px;
	color: var(--wp--preset--color--black);
	text-decoration: none;
}

.woocommerce-MyAccount-navigation a:hover {
	text-decoration: underline;
}

.woocommerce-MyAccount-navigation .is-active a {
	font-weight: 700;
}

.woocommerce-MyAccount-content {
	flex: 1;
	min-width: 0;
	padding-top: 15px;
}

.woocommerce-MyAccount-content :is(h2, h3) {
	margin-bottom: 15px;
	font-size: 28px;
	font-weight: 700;
	text-transform: none;
	line-height: 1.4;
}

.woocommerce-MyAccount-content .woocommerce-Address-title a {
	font-weight: 700;
}

.woocommerce-account .woocommerce > h2 {
	text-align: center;
}

.nomon-account-dash__greeting {
	margin-bottom: 5px;
	font-weight: 700;
}

.nomon-account-cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 15px;
	margin: 30px 0 45px;
}

.woocommerce-MyAccount-content .nomon-account-card {
	display: flex;
	flex-direction: column;
	gap: 5px;
	padding: 20px;
	border: 1px solid var(--wp--preset--color--mid-grey);
	color: var(--wp--preset--color--black);
	text-decoration: none;
}

.nomon-account-card:hover {
	border-color: var(--wp--preset--color--black);
}

.nomon-account-card__title {
	font-weight: 700;
}

.nomon-account-card__desc,
.nomon-account-recent__date,
.nomon-account-recent__total {
	color: var(--wp--preset--color--text);
	font-size: 15px;
}

.nomon-account-recent__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 15px;
}

.woocommerce-MyAccount-content .nomon-account-recent__title {
	font-size: 20px;
}

.nomon-account-recent__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.nomon-account-recent__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 5px 15px;
	padding: 15px 0;
	border-bottom: 1px solid var(--wp--preset--color--mid-grey);
}

.nomon-account-recent__row:first-child {
	border-top: 1px solid var(--wp--preset--color--mid-grey);
}

.nomon-account-recent__num {
	font-weight: 700;
}

.nomon-order-status {
	display: inline-flex;
	padding: 2px 10px;
	background: var(--pill, var(--wp--preset--color--grey));
	color: var(--wp--preset--color--white);
	font-size: 14px;
	font-weight: 500;
	line-height: 1.5;
	white-space: nowrap;
}

.nomon-order-status--green { --pill: var(--woo-success); }
.nomon-order-status--blue { --pill: var(--woo-info); }
.nomon-order-status--orange { --pill: #8a4b00; }
.nomon-order-status--red { --pill: var(--woo-error); }

.woocommerce :is(form.woocommerce-form-login, form.woocommerce-ResetPassword) {
	max-width: 425px;
	margin: 30px auto 0;
	padding: 30px;
	border: 1px solid var(--wp--preset--color--mid-grey);
	text-align: center;
}

.woocommerce :is(form.woocommerce-form-login, form.woocommerce-ResetPassword) .form-row {
	align-items: center;
}

.woocommerce :is(form.woocommerce-form-login, form.woocommerce-ResetPassword) .form-row :is(input:not([type="checkbox"]), .password-input) {
	width: 100%;
}

.woocommerce :is(form.woocommerce-form-login, form.woocommerce-ResetPassword) input:not([type="checkbox"]) {
	text-align: center;
}

.woocommerce :is(form.woocommerce-form-login, form.woocommerce-ResetPassword) p:last-child {
	margin-bottom: 0;
}

/* Klarna's own CSS lays out #kco-wrapper as a 6fr/4fr grid; it needs the full content width. */
.woocommerce-checkout .entry-content {
	max-width: none;
}

#kco-order-review table.shop_table {
	border: 1px solid var(--wp--preset--color--mid-grey);
	font-size: 13.5px;
}

#kco-order-review table.shop_table :is(th, td) {
	padding: 20px;
	vertical-align: top;
}

#kco-order-review dl.variation {
	display: flex;
	flex-wrap: wrap;
	gap: 0 4px;
	margin: 4px 0 0;
}

#kco-order-review dl.variation :is(dt, dd, p) {
	margin: 0;
}

#kco-order-review #shipping_method {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

#kco-order-review #shipping_method li {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px;
}

#kco-order-review #shipping_method input {
	margin: 0;
	accent-color: var(--wp--preset--color--black);
}

#kco-order-review .woocommerce-additional-fields {
	margin-top: 20px;
}

#kco-order-review textarea {
	width: 100%;
	min-height: 90px;
	padding: 10px 12px;
	border: 1px solid var(--wp--preset--color--mid-grey);
	font-size: 13.5px;
}

@media (max-width: 767px) {
	.woocommerce table.shop_table_responsive thead {
		display: none;
	}

	.woocommerce table.shop_table_responsive :is(tbody, tr) {
		display: block;
	}

	.woocommerce table.shop_table_responsive tr {
		border-bottom: 1px solid var(--wp--preset--color--mid-grey);
	}

	.woocommerce table.shop_table_responsive :is(tbody th, td) {
		display: block;
		width: auto;
		padding: 10px 0;
		border-bottom: 0;
		text-align: right;
	}

	.woocommerce table.shop_table_responsive :is(tbody th, td)[data-title]::before {
		content: attr(data-title) ": ";
		float: left;
		margin-right: 15px;
		font-weight: 700;
	}

	#kco-wrapper {
		display: flex;
		flex-direction: column;
	}

	#kco-iframe {
		order: -1;
	}

	.woocommerce-account .woocommerce:has(> .woocommerce-MyAccount-navigation) {
		flex-direction: column;
		align-items: stretch;
	}

	.woocommerce-MyAccount-navigation {
		flex-basis: auto;
	}

	.woocommerce :is(.col2-set, .woocommerce-Addresses, .woocommerce-address-fields__field-wrapper, .woocommerce-EditAccountForm) {
		grid-template-columns: minmax(0, 1fr);
	}
}
