/**
 * Fire Shop — Checkout Page Styles
 *
 * Complete checkout page layout and component styling.
 * All selectors use the .fire- prefix and reference tokens from fire-tokens.css.
 *
 * Depends on: fire-tokens.css, fire-storefront.css
 * @since 1.0.0
 */

/* ============================================================
   1. Form Layout — Two-column grid
   ============================================================ */

.fire-checkout-form {
	max-width: 1120px;
	margin: 0 auto;
	padding: var(--fire-space-xl) var(--fire-space-md);
	font-family: var(--fire-font-body);
}

.fire-checkout-columns {
	display: grid;
	grid-template-columns: 1fr 400px;
	gap: var(--fire-space-xl);
}

.fire-checkout-fields {
	min-width: 0;
}

.fire-checkout-review {
	position: sticky;
	top: var(--fire-space-xl);
	align-self: start;
}

/* ============================================================
   2. Form Fields
   ============================================================ */

.fire-form-row {
	margin-bottom: var(--fire-space-sm);
}

/* Hide labels — placeholder serves as label (Shopify pattern) */
.fire-form-row > .fire-form-label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.fire-form-row input,
.fire-form-row select,
.fire-form-row textarea {
	width: 100%;
	padding: 12px var(--fire-space-md);
	border: 1px solid transparent;
	border-radius: var(--fire-radius-md);
	font-family: var(--fire-font-body);
	font-size: 14px;
	line-height: 1.5;
	color: var(--fire-text);
	transition: border-color var(--fire-duration-short) var(--fire-ease-move);
	box-sizing: border-box;
}

.fire-form-row input:focus,
.fire-form-row select:focus,
.fire-form-row textarea:focus {
	outline: none;
	border-color: var(--fire-border);
}

.fire-form-row input::placeholder,
.fire-form-row textarea::placeholder {
	color: var(--fire-text-muted);
}

.fire-required {
	color: var(--fire-error);
	text-decoration: none;
	font-weight: 400;
}

.fire-form-row--error input,
.fire-form-row--error select,
.fire-form-row--error textarea {
	border-color: var(--fire-error);
}

.fire-form-row .fire-field-error {
	display: block;
	margin-top: var(--fire-space-xs);
	font-size: 12px;
	line-height: 1.4;
	color: var(--fire-error);
}

/* Country / State selects */
.fire-form-row select {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B6B76' d='M6 8.825L1.175 4l.825-.825L6 7.175 10 3.175l.825.825z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right var(--fire-space-sm) center;
	padding-right: var(--fire-space-xl);
}

/* Checkbox rows — labels must remain visible */
.fire-form-row--checkbox > .fire-form-label {
	position: static;
	width: auto;
	height: auto;
	padding: 0;
	margin: 0;
	overflow: visible;
	clip: auto;
	white-space: normal;
}

.fire-form-row--checkbox label {
	display: inline-flex;
	align-items: center;
	gap: var(--fire-space-sm);
	cursor: pointer;
	font-size: 14px;
}

.fire-form-row--checkbox input[type="checkbox"] {
	width: auto;
	flex-shrink: 0;
}

/* Inline two-field rows (city/state, first/last name) */
.fire-form-row--half {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--fire-space-md);
}

/* Grid fieldset — 6-column grid for half and third placement */
.fire-checkout-fieldset--grid {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: var(--fire-space-sm);
}

.fire-checkout-fieldset--grid .fire-form-row {
	margin-bottom: 0;
}

.fire-form-row--half-left,
.fire-form-row--half-right {
	grid-column: span 3;
}

.fire-form-row--third {
	grid-column: span 2;
}

.fire-form-row--full,
.fire-checkout-fieldset--grid .fire-form-row:not([class*="half"]):not([class*="third"]) {
	grid-column: 1 / -1;
}

/* ============================================================
   3. Sections
   ============================================================ */

.fire-checkout-section {
	border-bottom: 1px solid var(--fire-border);
	padding-bottom: var(--fire-space-md);
	margin-bottom: var(--fire-space-md);
}

.fire-checkout-section:last-child {
	border-bottom: none;
	margin-bottom: 0;
}

.fire-checkout-section h3 {
	font-family: var(--fire-font-display);
	font-size: 18px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--fire-text);
	margin: 0 0 var(--fire-space-md) 0;
}

/* Compact section headings — Shopify-style uppercase */
.fire-checkout-heading {
	font-family: var(--fire-font-body);
	font-size: 13px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	line-height: 1.3;
	color: var(--fire-text-muted);
	margin: 0 0 var(--fire-space-sm) 0;
}

/* Ship to different address toggle */
.fire-ship-different-toggle {
	display: inline-flex;
	align-items: center;
	gap: var(--fire-space-sm);
	cursor: pointer;
	font-size: 14px;
	color: var(--fire-text);
	margin-bottom: var(--fire-space-md);
}

.fire-ship-different-toggle input[type="checkbox"] {
	width: auto;
	margin: 0;
}

/* ============================================================
   4. Payment Methods
   ============================================================ */

.fire-payment-methods {
	border: 1px solid var(--fire-border);
	border-radius: var(--fire-radius-md);
	overflow: hidden;
}

.fire-payment-method {
	display: block;
	padding: var(--fire-space-md);
	border-bottom: 1px solid var(--fire-border);
	cursor: pointer;
	transition: background-color var(--fire-duration-short) var(--fire-ease-move);
}

.fire-payment-method:last-child {
	border-bottom: none;
}

.fire-payment-method:hover {
	background-color: var(--fire-surface-alt);
}

.fire-payment-method--selected {
	background-color: var(--fire-surface-alt);
}

.fire-payment-method input[type="radio"] {
	width: auto;
	flex-shrink: 0;
}

.fire-payment-method__icon {
	width: 32px;
	height: 32px;
	object-fit: contain;
	flex-shrink: 0;
}

.fire-payment-method__label {
	display: flex;
	align-items: center;
	gap: var(--fire-space-sm);
	width: 100%;
	font-size: 14px;
	font-weight: 500;
	color: var(--fire-text);
	cursor: pointer;
}

.fire-payment-method__body {
	padding-left: 28px;
	margin-top: var(--fire-space-sm);
}

.fire-payment-method__fields {
	overflow: hidden;
	max-height: 0;
	opacity: 0;
	transition: max-height var(--fire-duration-medium) var(--fire-ease-enter),
	            opacity var(--fire-duration-medium) var(--fire-ease-enter),
	            padding var(--fire-duration-medium) var(--fire-ease-enter);
	padding: 0 var(--fire-space-md);
}

.fire-payment-method--selected .fire-payment-method__fields {
	max-height: 500px;
	opacity: 1;
	padding: var(--fire-space-md);
}

/* Fire Pay specific fields */
.fire-firepay-fields {
	display: flex;
	flex-direction: column;
	gap: var(--fire-space-sm);
	padding: var(--fire-space-sm) 0;
}

/* Stripe specific fields */
.fire-stripe-fields {
	display: flex;
	flex-direction: column;
	gap: var(--fire-space-sm);
	padding: var(--fire-space-sm) 0;
}

/* Saved payment methods */
.fire-saved-methods {
	list-style: none;
	margin: 0 0 var(--fire-space-md) 0;
	padding: 0;
}

.fire-saved-methods li {
	display: flex;
	align-items: center;
	gap: var(--fire-space-sm);
	padding: var(--fire-space-sm) 0;
	font-size: 14px;
	color: var(--fire-text);
}

.fire-saved-methods li input[type="radio"] {
	width: auto;
}

/* ============================================================
   5. Order Review (right sidebar)
   ============================================================ */

.fire-order-review {
	background-color: var(--fire-surface);
	border: 1px solid var(--fire-border);
	border-radius: var(--fire-radius-md);
	padding: var(--fire-space-md);
}

.fire-order-review h3 {
	font-family: var(--fire-font-display);
	font-size: 18px;
	font-weight: 600;
	color: var(--fire-text);
	margin: 0 0 var(--fire-space-md) 0;
}

.fire-order-review table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.fire-order-review table th,
.fire-order-review table td {
	padding: var(--fire-space-sm) 0;
	text-align: left;
}

.fire-order-review table th {
	font-weight: 500;
	color: var(--fire-text-muted);
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.fire-order-review table th:last-child {
	text-align: right;
}

.fire-order-review table td:last-child {
	text-align: right;
	font-family: var(--fire-font-data);
	font-variant-numeric: tabular-nums;
}

.fire-order-review .fire-order-total td {
	font-size: 16px;
	font-weight: 700;
	color: var(--fire-text);
	border-bottom: none;
	padding-top: var(--fire-space-md);
}

/* Coupon toggle + form in order summary */
.fire-coupon-toggle {
	font-size: 13px;
	padding: 4px 0;
	border: none;
	background: none;
	color: var(--fire-text-muted);
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.fire-coupon-toggle:hover {
	color: var(--fire-text);
}

.fire-coupon-section {
	margin-top: var(--fire-space-md);
	padding-top: var(--fire-space-sm);
	border-top: 1px solid var(--fire-border);
}

.fire-coupon-form {
	display: flex;
	align-items: stretch;
	gap: var(--fire-space-sm);
	margin-top: var(--fire-space-sm);
}

.fire-coupon-form__input {
	flex: 1;
	min-width: 0;
	height: 42px;
	padding: 0 12px;
	font-size: 14px;
	border: 1px solid var(--fire-border);
	border-radius: 4px;
	box-sizing: border-box;
}

.fire-coupon-form__btn {
	flex-shrink: 0;
	white-space: nowrap;
	height: 42px;
	background-color: var(--fire-text);
	color: var(--fire-surface);
	border-color: var(--fire-text);
	border-radius: 4px;
	box-sizing: border-box;
}

.fire-coupon-form__btn:hover {
	background-color: var(--fire-text-muted);
	border-color: var(--fire-text-muted);
}

.fire-coupon-message {
	font-size: 13px;
	margin-top: var(--fire-space-xs);
}

.fire-coupon-message--error {
	color: var(--fire-error);
}

.fire-coupon-message--success {
	color: var(--fire-success);
}

.fire-coupon-applied {
	display: flex;
	align-items: center;
	gap: var(--fire-space-sm);
	margin-top: var(--fire-space-sm);
	font-size: 13px;
	color: var(--fire-success);
}

.fire-coupon-applied__remove {
	color: var(--fire-text-muted);
	cursor: pointer;
	font-size: 12px;
	text-decoration: underline;
}

.fire-coupon-applied__remove:hover {
	color: var(--fire-error);
}

.fire-coupon-remove-x {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	margin-left: 4px;
	padding: 0;
	border: none;
	background: none;
	color: var(--fire-text-muted);
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	vertical-align: middle;
}

.fire-coupon-remove-x:hover {
	color: var(--fire-error);
}

.fire-shipping-options {
	display: flex;
	flex-direction: column;
	gap: var(--fire-space-xs);
}

.fire-shipping-option {
	display: flex;
	align-items: center;
	gap: var(--fire-space-xs);
	font-size: 13px;
	cursor: pointer;
}

.fire-shipping-option__radio {
	width: auto;
	margin: 0;
}

/* ============================================================
   6. Place Order
   ============================================================ */

.fire-place-order-btn {
	display: block;
	width: 100%;
	padding: 14px var(--fire-space-lg);
	background-color: var(--fire-primary);
	color: #ffffff;
	border: none;
	border-radius: var(--fire-radius-sm);
	font-family: var(--fire-font-body);
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	text-align: center;
	transition: background-color var(--fire-duration-short) var(--fire-ease-move),
	            opacity var(--fire-duration-short) var(--fire-ease-move);
	margin-top: var(--fire-space-md);
}

.fire-place-order-btn:hover {
	background-color: #333;
}

.fire-place-order-btn:disabled {
	background-color: var(--fire-border);
	color: var(--fire-text-muted);
	cursor: not-allowed;
}

.fire-place-order-btn.fire-btn-success {
	background-color: var(--fire-success);
	color: #ffffff;
}

.fire-wallet-status {
	margin-top: var(--fire-space-sm);
	font-size: 14px;
	text-align: center;
}

.fire-wallet-status--success {
	color: var(--fire-success);
}

/*
 * "Not known yet" is not the same as failed, and a payment in this state may
 * still complete. Muted rather than alarming, so nobody reads it as a reason to
 * pay again.
 */
.fire-wallet-status--notice {
	color: var(--fire-text-muted);
}

.fire-wallet-status--error {
	color: var(--fire-error);
}

.fire-terms-row {
	display: flex;
	align-items: flex-start;
	gap: var(--fire-space-sm);
	margin-top: var(--fire-space-md);
	font-size: 13px;
	color: var(--fire-text-muted);
}

.fire-terms-row input[type="checkbox"] {
	width: auto;
	margin-top: 2px;
	flex-shrink: 0;
}

.fire-terms-row a {
	color: var(--fire-primary);
	text-decoration: underline;
}

/* Order notes toggle */
.fire-checkout-notes-toggle {
	background: none;
	border: none;
	color: var(--fire-primary);
	font-family: var(--fire-font-body);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	padding: 0;
	text-decoration: underline;
}

.fire-checkout-notes-body {
	margin-top: var(--fire-space-sm);
}

/* ============================================================
   7. Loading / Processing States
   ============================================================ */

.fire-checkout--processing {
	position: relative;
	pointer-events: none;
}

.fire-checkout--processing::after {
	content: '';
	position: absolute;
	inset: 0;
	background-color: rgba(255, 255, 255, 0.7);
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
}

.fire-checkout-loading {
	position: absolute;
	inset: 0;
	background-color: rgba(255, 255, 255, 0.6);
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
}

.fire-checkout-loading::after {
	content: '';
	width: 32px;
	height: 32px;
	border: 3px solid var(--fire-border);
	border-top-color: var(--fire-primary);
	border-radius: 50%;
	animation: fire-spin 0.6s linear infinite;
}

@keyframes fire-spin {
	to { transform: rotate(360deg); }
}

/* ============================================================
   8. Checkout Login Prompt & Modal
   ============================================================ */

.fire-checkout-login-prompt {
	font-family: var(--fire-font-body);
	font-size: 13px;
	color: var(--fire-text-muted);
	margin: var(--fire-space-sm) 0 0 0;
}

.fire-checkout-login-prompt a {
	color: var(--fire-text);
	font-weight: 500;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

.fire-checkout-login-prompt a:hover {
	color: var(--fire-primary);
}

/* Modal overlay */
.fire-login-modal {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.fire-login-modal__backdrop {
	position: absolute;
	inset: 0;
	background-color: rgba(0, 0, 0, 0.4);
}

.fire-login-modal__dialog {
	position: relative;
	width: 100%;
	max-width: 380px;
	margin: var(--fire-space-md);
	padding: var(--fire-space-xl, 32px);
	background-color: var(--fire-surface, #fff);
	border-radius: var(--fire-radius-md, 8px);
	box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12);
	z-index: 1;
}

.fire-login-modal__close {
	position: absolute;
	top: var(--fire-space-sm, 8px);
	right: var(--fire-space-sm, 8px);
	background: none;
	border: none;
	font-size: 24px;
	line-height: 1;
	color: var(--fire-text-muted);
	cursor: pointer;
	padding: 4px 8px;
	transition: color 0.15s ease;
}

.fire-login-modal__close:hover {
	color: var(--fire-text);
}

.fire-login-modal__dialog h2 {
	margin-bottom: var(--fire-space-lg, 24px);
}

.fire-login-modal__field {
	margin-bottom: var(--fire-space-md, 16px);
}

.fire-login-modal__field label {
	display: block;
	font-family: var(--fire-font-body);
	font-size: 12px;
	font-weight: 500;
	color: var(--fire-text-muted);
	margin-bottom: 6px;
}

.fire-login-modal__field input {
	width: 100%;
	padding: 12px var(--fire-space-md, 16px);
	font-family: var(--fire-font-body);
	font-size: 14px;
	border: 1px solid transparent;
	background-color: var(--fire-surface-alt, #f5f5f5);
	border-radius: var(--fire-radius-sm, 4px);
	box-sizing: border-box;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.fire-login-modal__field input:focus {
	outline: none;
	border-color: var(--fire-border);
	background-color: var(--fire-surface, #fff);
}

.fire-login-modal__remember {
	margin-bottom: var(--fire-space-md, 16px);
}

.fire-login-modal__remember label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-family: var(--fire-font-body);
	font-size: 13px;
	color: var(--fire-text-muted);
	cursor: pointer;
}

.fire-login-modal__remember input[type="checkbox"] {
	width: auto;
}

.fire-login-modal__error {
	font-family: var(--fire-font-body);
	font-size: 13px;
	color: var(--fire-error, #d32f2f);
	margin-bottom: var(--fire-space-md, 16px);
	padding: 10px var(--fire-space-md, 16px);
	background-color: rgba(211, 47, 47, 0.06);
	border-radius: var(--fire-radius-sm, 4px);
}

.fire-login-modal__submit {
	margin-top: 0;
}

/* ============================================================
   9. Responsive
   ============================================================ */

/* Tablet */
@media (max-width: 960px) {
	.fire-checkout-form {
		grid-template-columns: 1fr 320px;
		gap: var(--fire-space-lg);
	}
}

/* Mobile */
@media (max-width: 680px) {
	.fire-checkout-form {
		padding: var(--fire-space-md);
	}

	.fire-checkout-columns {
		grid-template-columns: 1fr;
	}

	.fire-checkout-review {
		position: static;
		order: -1;
	}

	.fire-form-row--half {
		grid-template-columns: 1fr;
	}

	.fire-checkout-fieldset--grid {
		grid-template-columns: 1fr;
	}

	.fire-form-row--half-left,
	.fire-form-row--half-right,
	.fire-form-row--third {
		grid-column: 1 / -1;
	}

	.fire-place-order-btn {
		font-size: 15px;
		padding: var(--fire-space-md);
	}
}
