/**
 * SaleHub Checkout — front-end styles.
 * All theming goes through CSS custom properties (see class-sh-checkout-assets.php)
 * so a store's brand color can be changed from Settings without editing this file.
 */

.sh-checkout {
	--sh-primary: #000000;
	--sh-primary-hover: #2b2b2b;
	--sh-primary-text: #ffffff;
	--sh-radius: 10px;
	--sh-border: #e2e5e9;
	--sh-bg: #ffffff;
	--sh-bg-muted: #f7f8fa;
	--sh-text: #1f2328;
	--sh-text-muted: #6b7280;
	--sh-danger: #d64545;
	--sh-success: #1a9c6b;

	max-width: 1240px;
	margin: 80px auto;
	color: var(--sh-text);
	font-size: 15px;
	line-height: 1.5;
	position: relative;
	box-sizing: border-box;
}
.sh-checkout *,
.sh-checkout *::before,
.sh-checkout *::after {
	box-sizing: border-box;
}

/*
 * Hard reset for interactive elements inside the module. Store themes
 * frequently apply their own brand color (often pink/magenta) to bare
 * <button> / input[type=submit] elements with fairly high specificity.
 * Stripping all inherited styling here and re-applying everything
 * explicitly through our own classes below guarantees the checkout looks
 * the same regardless of which theme it's dropped into.
 */
.sh-checkout :where(button),
.sh-checkout :where(input[type="submit"]),
.sh-checkout :where(input[type="button"]) {
	all: unset;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-family: inherit;
	cursor: pointer;
}
.sh-checkout :where(select) {
	all: unset;
	box-sizing: border-box;
	display: block;
	width: 100%;
	cursor: pointer;
	font-family: inherit;
}
/*
 * Several elements here (the loading overlay, step panels, invoice fields,
 * coupon body, notice) are shown/hidden purely via the native `hidden`
 * attribute in JS, relying on the browser's built-in `[hidden]{display:none}`
 * rule. But author CSS always wins over that user-agent default regardless
 * of specificity — so any of our own rules below that set `display` on the
 * SAME element unconditionally (e.g. `.sh-loading-overlay{display:flex}`)
 * silently cancels the hidden attribute's effect on host themes that don't
 * happen to also ship their own `[hidden]{display:none!important}` reset.
 * This single !important rule guarantees `hidden` always actually hides,
 * regardless of what the host theme does or doesn't define.
 */
.sh-checkout [hidden] {
	display: none !important;
}

/* Steps indicator */
.sh-checkout__steps {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--sh-bg-muted);
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	padding: 16px 24px;
	margin-bottom: 24px;
	flex-wrap: wrap;
}
.sh-step {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--sh-text-muted);
	font-weight: 500;
}
.sh-step__icon {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 1px solid var(--sh-border);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	background: var(--sh-bg);
}
.sh-step--done .sh-step__icon {
	background: var(--sh-primary);
	border-color: var(--sh-primary);
	color: var(--sh-primary-text);
}
.sh-step--active {
	color: var(--sh-text);
}
.sh-step--active .sh-step__icon {
	border-color: var(--sh-primary);
	color: var(--sh-primary);
}
.sh-step:not(:last-child)::after {
	content: '›';
	margin-left: 8px;
	color: var(--sh-border);
}

/* Layout */
.sh-checkout__layout {
	display: grid;
	grid-template-columns: 1fr 380px;
	gap: 32px;
	align-items: start;
}
@media (max-width: 900px) {
	.sh-checkout__layout {
		grid-template-columns: 1fr;
	}
	.sh-checkout__sidebar {
		order: -1;
	}
}

.sh-panel__title {
	font-size: 20px;
	font-weight: 600;
	margin: 0 0 16px;
}
.sh-panel__title--spaced {
	margin-top: 32px;
}
.sh-panel__subtitle {
	font-size: 16px;
	font-weight: 600;
	margin: 24px 0 12px;
}

.sh-field,
.sh-field-group {
	margin-bottom: 16px;
}
.sh-field-group--2col {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
}
@media (max-width: 560px) {
	.sh-field-group--2col {
		grid-template-columns: 1fr;
	}
}
.sh-field label,
.sh-field__label {
	display: block;
	font-weight: 500;
	margin-bottom: 6px;
	font-size: 14px;
}
.sh-field input[type="text"],
.sh-field input[type="email"],
.sh-field input[type="tel"],
.sh-field select,
.sh-field textarea {
	width: 100%;
	padding: 11px 14px;
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	font-size: 14px;
	line-height: 1.4;
	background: var(--sh-bg);
	color: var(--sh-text);
	transition: border-color .15s ease;
}
/*
 * Selects get extra, !important-guarded rules on top of the shared field
 * style above. Some store themes force a fixed, shorter height on native
 * <select> elements (often via a high-specificity/!important rule), which
 * clips our padded label text at the top. Overriding height/line-height
 * explicitly here — after the :where(select) reset near the top of this
 * file already stripped the theme's own appearance — guarantees the
 * option text is always fully visible regardless of the host theme.
 */
.sh-field select {
	height: auto !important;
	min-height: 44px !important;
	line-height: 1.4 !important;
	padding: 11px 36px 11px 14px !important;
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 10px 6px;
}
.sh-field input:focus,
.sh-field select:focus,
.sh-field textarea:focus {
	outline: none;
	border-color: var(--sh-primary);
}
.sh-field.has-error input,
.sh-field.has-error select {
	border-color: var(--sh-danger);
}
.sh-field__error {
	color: var(--sh-danger);
	font-size: 12px;
	margin-top: 4px;
}

.sh-field--radio-group {
	display: flex;
	align-items: center;
	gap: 24px;
}
.sh-radio {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-weight: 500;
	cursor: pointer;
}

.sh-checkbox {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin: 14px 0;
	font-size: 14px;
	cursor: pointer;
}
.sh-checkbox input {
	margin-top: 3px;
	width: 16px;
	height: 16px;
	accent-color: var(--sh-primary);
	flex: none;
}
.sh-checkbox a {
	color: var(--sh-primary);
}
/*
 * Secondary/optional consent (newsletter): visually lighter than the
 * required terms checkbox so it doesn't compete for attention, but never
 * hidden, tiny-to-the-point-of-unreadable, or pre-checked — an opt-in
 * checkbox has to still be genuinely noticeable and unticked by default.
 */
.sh-checkbox--muted {
	font-size: 12px;
	color: var(--sh-text-muted);
}
.sh-checkbox--muted input {
	accent-color: var(--sh-text-muted);
}

/* Buttons */
.sh-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 13px 22px;
	border-radius: var(--sh-radius);
	font-size: 15px;
	font-weight: 600;
	border: 1px solid transparent;
	cursor: pointer;
	transition: background-color .15s ease, opacity .15s ease;
}
.sh-btn--block {
	width: 100%;
}
.sh-btn--primary {
	background: var(--sh-primary);
	color: var(--sh-primary-text);
}
.sh-btn--primary:hover:not(:disabled) {
	background: var(--sh-primary-hover);
}
.sh-btn--primary:disabled {
	opacity: .5;
	cursor: not-allowed;
}
.sh-btn--secondary {
	background: var(--sh-bg-muted);
	color: var(--sh-text);
	border-color: var(--sh-border);
}
.sh-btn--ghost {
	background: transparent;
	color: var(--sh-text);
	border-color: var(--sh-border);
}
.sh-panel__actions {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-top: 24px;
}
.sh-panel__actions .sh-btn--primary {
	flex: 1;
}

/* Option cards (shipping / payment) */
.sh-options {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.sh-option {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease;
}
.sh-option:hover {
	border-color: var(--sh-primary);
}
.sh-option input {
	accent-color: var(--sh-primary);
	width: 16px;
	height: 16px;
	flex: none;
}
.sh-option.is-selected {
	border-color: var(--sh-primary);
	background: color-mix(in srgb, var(--sh-primary) 6%, white);
}
.sh-option__label {
	flex: 1;
	font-weight: 500;
}
.sh-option__desc {
	display: block;
	font-weight: 400;
	color: var(--sh-text-muted);
	font-size: 13px;
	margin-top: 2px;
}
.sh-option__price {
	font-weight: 600;
}

/* Sidebar / order summary */
.sh-checkout__sidebar {
	background: var(--sh-bg);
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	padding: 20px;
}
.sh-sidebar__title {
	font-size: 16px;
	font-weight: 600;
	margin: 8px 0 14px;
}
.sh-coupon {
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	padding: 12px 14px;
	margin-bottom: 20px;
}
.sh-coupon__toggle {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	text-align: left;
	color: var(--sh-primary);
	font-size: 13px;
	font-weight: 600;
}
.sh-coupon__chevron {
	margin-left: auto;
	color: var(--sh-text-muted);
	font-size: 12px;
	transition: transform .15s ease;
}
.sh-coupon.is-open .sh-coupon__chevron {
	transform: rotate(180deg);
}
.sh-coupon__body {
	display: flex;
	gap: 8px;
	margin-top: 10px;
}
.sh-coupon__body input {
	flex: 1;
	padding: 9px 12px;
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	font-size: 13px;
}
.sh-coupon__body .sh-btn {
	padding: 9px 16px;
	font-size: 13px;
}

.sh-cart-item {
	display: flex;
	gap: 12px;
	padding: 14px 0;
	border-bottom: 1px solid var(--sh-border);
}
.sh-cart-item img {
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: calc(var(--sh-radius) - 4px);
	border: 1px solid var(--sh-border);
	flex: none;
}
.sh-cart-item__info {
	flex: 1;
	min-width: 0;
}
.sh-cart-item__top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
}
.sh-cart-item__name {
	font-size: 13.5px;
	font-weight: 500;
	margin: 0;
	line-height: 1.35;
}
.sh-cart-item__remove {
	flex: none;
	width: 24px;
	height: 24px;
	color: var(--sh-text-muted);
	font-size: 14px;
	border-radius: 6px;
}
.sh-cart-item__remove:hover {
	color: var(--sh-danger);
	background: var(--sh-bg-muted);
}
.sh-cart-item__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 10px;
}
/*
 * Layout-critical dimensions are !important-guarded: this widget sits
 * inside a narrow sidebar next to the price, so it must stay compact no
 * matter what a host theme's generic input/button rules try to impose.
 */
.sh-qty {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	white-space: nowrap;
	border: 1px solid var(--sh-border);
	border-radius: 8px;
	height: 28px !important;
	overflow: hidden;
}
.sh-qty button {
	width: 24px !important;
	min-width: 0 !important;
	height: 100% !important;
	padding: 0 !important;
	margin: 0 !important;
	background: var(--sh-bg-muted);
	font-size: 14px;
	line-height: 1;
	color: var(--sh-text);
}
.sh-qty button:hover {
	background: var(--sh-border);
}
.sh-qty input {
	width: 26px !important;
	min-width: 0 !important;
	max-width: 26px !important;
	height: 100% !important;
	padding: 0 !important;
	margin: 0 !important;
	text-align: center;
	border: none;
	border-left: 1px solid var(--sh-border);
	border-right: 1px solid var(--sh-border);
	font-size: 12px;
	background: transparent;
	font-variant-numeric: tabular-nums;
}
.sh-cart-item__price {
	flex: 0 0 auto;
	font-weight: 600;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	text-align: right;
	white-space: nowrap;
}

.sh-totals {
	margin-top: 8px;
}
.sh-totals__row {
	display: flex;
	justify-content: space-between;
	padding: 10px 0;
	font-size: 14px;
	border-bottom: 1px solid var(--sh-border);
}
.sh-totals__row--total {
	border-bottom: none;
	padding-top: 16px;
	font-size: 18px;
	font-weight: 700;
}
.sh-totals__note {
	color: var(--sh-primary);
	font-size: 13px;
}

.sh-review .sh-cart-item img {
	width: 48px;
	height: 48px;
}
.sh-review__block {
	padding: 14px 0;
	border-bottom: 1px solid var(--sh-border);
}
.sh-review__block:last-child {
	border-bottom: none;
}
.sh-review__label {
	color: var(--sh-text-muted);
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .03em;
	margin: 0 0 4px;
}
.sh-review__value {
	font-weight: 500;
}

.sh-notice {
	padding: 12px 16px;
	border-radius: var(--sh-radius);
	margin-bottom: 16px;
	font-size: 14px;
}
.sh-notice--error {
	background: #fdecec;
	color: var(--sh-danger);
	border: 1px solid #f5c6c6;
}
.sh-notice--success {
	background: #e9f9f1;
	color: var(--sh-success);
	border: 1px solid #b9ecd3;
}

.sh-muted {
	color: var(--sh-text-muted);
	font-size: 14px;
}

.sh-checkout--empty {
	text-align: center;
	padding: 60px 20px;
}
.sh-checkout--empty .sh-btn {
	margin-top: 16px;
}

.sh-loading-overlay {
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, .7);
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--sh-radius);
	z-index: 10;
}
.sh-spinner {
	width: 36px;
	height: 36px;
	border: 3px solid var(--sh-border);
	border-top-color: var(--sh-primary);
	border-radius: 50%;
	animation: sh-spin .8s linear infinite;
}
@keyframes sh-spin {
	to { transform: rotate(360deg); }
}
