// Shared styling for GiftWrapFields.jsx — used identically by both the
// classic checkout box and the Checkout block, so the two look the same.
// Design language matches RT Express COD: teal accent, icon-led controls,
// elegant modal, and a mobile-first bottom sheet on small screens.

.rtgw-gift-wrap-block {
	margin-top: 14px;
	margin-bottom: 14px;
	font-family: var(--rtgw-font);
}

.rtgw-toggle-row {
	display: flex;
	align-items: center;
	gap: 10px;
}

.rtgw-toggle-button {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	width: auto;
	padding: 14px 18px;
	border: 1.5px solid var(--rtgw-line);
	border-radius: var(--rtgw-radius);
	background: var(--rtgw-surface-soft);
	cursor: pointer;
	font-size: 14px;
	font-weight: 650;
	color: var(--rtgw-ink);
	box-shadow: var(--rtgw-shadow);
	text-decoration: none !important;
	transition: border-color .15s, background .15s, transform .1s, box-shadow .15s;

	&:hover,
	&:visited {
		text-decoration: none !important;
	}
	&:hover { border-color: var(--rtgw-accent); transform: translateY(-1px); }
	&:active { transform: translateY(0); }
	&.is-open { background: var(--rtgw-accent-soft); border-color: var(--rtgw-accent); }
	&.is-disabled,
	&:disabled { opacity: .6; cursor: default; transform: none; pointer-events: none; }
	&:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--rtgw-accent-glow); }

	@media (max-width: 480px) {
		width: 100%;
		padding: 13px 14px;
		font-size: 13.5px;
	}
}

// Quick remove — sits beside the toggle once wrap is added, so a shopper
// can drop it in one tap without opening the modal. The toggle itself
// remains the primary control (better discoverability, and it doubles as
// "edit" while wrap is on) — this is a shortcut, not a replacement. A
// filled red circle reads clearly as a destructive action next to the
// neutral toggle, and matches the icon-button sizing used elsewhere.
.rtgw-quick-remove {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: rgba(220, 38, 38, .1);
	color: var(--rtgw-danger);
	text-decoration: none !important;
	cursor: pointer;
	transition: background .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease;

	svg { transition: transform .15s ease; }

	&:hover,
	&:visited { text-decoration: none !important; }
	&:hover {
		background: var(--rtgw-danger);
		color: #fff;
		box-shadow: 0 6px 16px -6px rgba(220, 38, 38, .55);

		svg { transform: scale(1.08); }
	}
	&:active { transform: translateY(1px); }
	&.is-disabled { opacity: .5; cursor: default; pointer-events: none; box-shadow: none; }
	&:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(220, 38, 38, .3); }

	@media (max-width: 480px) {
		width: 42px;
		height: 42px;
	}
}

.rtgw-toggle-button__icon {
	display: inline-flex;
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	align-items: center;
	justify-content: center;
	border-radius: 9px;
	background: var(--rtgw-accent-soft);
	color: var(--rtgw-accent-dark);
}

.rtgw-toggle-button.is-open .rtgw-toggle-button__icon {
	background: var(--rtgw-surface);
}

.rtgw-toggle-button__label { flex: 1; text-align: left; }

.rtgw-toggle-button__badge {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: #fff;
	background: var(--rtgw-success);
	padding: 3px 9px;
	border-radius: 20px;
}

// Modal — self-contained overlay + dialog (see Modal.jsx). No
// @wordpress/components dependency: everything below is our own markup.
.rtgw-modal-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 40px 16px;
	overflow-y: auto;
	background: rgba(16, 24, 40, .55);
	backdrop-filter: blur(2px);

	@media (max-width: 600px) {
		align-items: flex-end;
		padding: 0;
	}
}

.rtgw-modal-frame {
	width: 100%;
	max-width: 480px;
	margin: auto;
	background: var(--rtgw-surface);
	border-radius: var(--rtgw-radius);
	box-shadow: 0 24px 60px -20px rgba(10, 40, 38, .45);
	overflow: hidden;
	font-family: var(--rtgw-font);
	animation: rtgw-modal-pop .16s ease-out;

	// Mobile — slide up as a full-width bottom sheet instead of a small
	// centered dialog, so it's comfortable to use with one thumb.
	@media (max-width: 600px) {
		max-width: 100%;
		max-height: 88vh;
		border-radius: 18px 18px 0 0;
		margin: 0;
		display: flex;
		flex-direction: column;
	}
}

@keyframes rtgw-modal-pop {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

.rtgw-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 20px;
	background: linear-gradient(120deg, var(--rtgw-accent-dark), var(--rtgw-accent));
}

.rtgw-modal-title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	color: #fff;
}

.rtgw-modal-close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	color: rgba(255, 255, 255, .85);
	text-decoration: none !important;
	cursor: pointer;

	&:hover,
	&:visited { text-decoration: none !important; }
	&:hover { color: #fff; background: rgba(255, 255, 255, .18); }
	&:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, .4); }
}

.rtgw-modal-content {
	padding: 20px 24px 24px;

	@media (max-width: 600px) {
		padding: 18px 18px calc(24px + env(safe-area-inset-bottom, 0px));
		overflow-y: auto;
	}
}

.rtgw-modal__intro {
	margin: 0 0 16px;
	font-size: 13.5px;
	color: var(--rtgw-ink-soft);
}

.rtgw-modal__footer {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--rtgw-line);

	@media (max-width: 480px) {
		flex-direction: column-reverse;

		.rtgw-action { width: 100%; justify-content: center; }
	}
}

// Action buttons — rendered as <a role="button"> to keep every clickable
// control in the gift wrap UI on one semantic (matches the toggle above).
.rtgw-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 10px 18px;
	border-radius: 10px;
	font-size: 13.5px;
	font-weight: 650;
	font-family: inherit;
	cursor: pointer;
	text-decoration: none !important;
	border: 1.5px solid transparent;
	transition: filter .15s ease, background .15s ease, box-shadow .15s ease, transform .05s ease;

	&:hover,
	&:visited { text-decoration: none !important; }
	&:active { transform: translateY(1px); }
	&:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--rtgw-accent-glow); }
	&.is-disabled { opacity: .65; cursor: progress; pointer-events: none; }

	&--primary {
		background: linear-gradient(120deg, var(--rtgw-accent), var(--rtgw-accent-dark));
		color: #fff;
		box-shadow: 0 8px 18px -8px var(--rtgw-accent-glow);

		&:hover { filter: brightness(1.06); }
	}

	&--ghost {
		background: transparent;
		border-color: var(--rtgw-line);
		color: var(--rtgw-danger);

		&:hover { background: rgba(220, 38, 38, .06); border-color: var(--rtgw-danger); }
	}
}

.rtgw-style-options {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-bottom: 16px;
}

.rtgw-style-option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border: 1.5px solid var(--rtgw-line);
	border-radius: var(--rtgw-radius-sm);
	cursor: pointer;
	font-size: 13.5px;
	transition: border-color .12s, background .12s;

	&:hover { border-color: var(--rtgw-accent); }

	&.is-selected {
		border-color: var(--rtgw-accent);
		background: var(--rtgw-accent-soft);
		box-shadow: 0 0 0 3px var(--rtgw-accent-soft);
	}
}

.rtgw-style-option__thumb {
	width: 32px;
	height: 32px;
	border-radius: 6px;
	object-fit: cover;
	flex: 0 0 auto;

	&--placeholder {
		display: flex;
		align-items: center;
		justify-content: center;
		background: var(--rtgw-accent-soft);
		color: var(--rtgw-accent-dark);
	}
}

.rtgw-style-option__text { font-weight: 600; color: var(--rtgw-ink); }

// Grid layout — shows the gift wrap option directly inline at checkout,
// no popup. Same tokens/colours as the modal version, laid out as cards.
.rtgw-grid-panel {
	padding: 16px;
	border: 1.5px solid var(--rtgw-line);
	border-radius: var(--rtgw-radius);
	background: var(--rtgw-surface-soft);
	box-shadow: var(--rtgw-shadow);
}

.rtgw-grid-panel__head {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 14px;
}

.rtgw-grid-panel__icon {
	display: inline-flex;
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	align-items: center;
	justify-content: center;
	border-radius: 9px;
	background: var(--rtgw-accent-soft);
	color: var(--rtgw-accent-dark);
}

.rtgw-grid-panel__label {
	flex: 1;
	font-size: 14px;
	font-weight: 650;
	color: var(--rtgw-ink);
}

.rtgw-style-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 10px;
	margin-bottom: 16px;
}

.rtgw-style-grid-option {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 12px 10px;
	border: 1.5px solid var(--rtgw-line);
	border-radius: var(--rtgw-radius-sm);
	background: var(--rtgw-surface);
	cursor: pointer;
	text-align: center;
	transition: border-color .12s, background .12s, transform .1s;

	input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }

	&:hover { border-color: var(--rtgw-accent); transform: translateY(-1px); }

	&.is-selected {
		border-color: var(--rtgw-accent);
		background: var(--rtgw-accent-soft);
		box-shadow: 0 0 0 3px var(--rtgw-accent-soft);
	}
}

.rtgw-style-grid-option__thumb {
	width: 100%;
	aspect-ratio: 1;
	max-width: 64px;
	border-radius: 8px;
	object-fit: cover;

	&--placeholder {
		display: flex;
		align-items: center;
		justify-content: center;
		background: var(--rtgw-accent-soft);
		color: var(--rtgw-accent-dark);
	}
}

.rtgw-style-grid-option__text {
	font-size: 12.5px;
	font-weight: 600;
	color: var(--rtgw-ink);
	line-height: 1.3;
}

.rtgw-message-input {
	display: block;
	width: 100%;
	margin-bottom: 16px;
	padding: 10px 12px;
	border: 1.5px solid var(--rtgw-line);
	border-radius: var(--rtgw-radius-sm);
	font-size: 14px;
	font-family: var(--rtgw-font);
	line-height: 1.45;
	resize: vertical;
	min-height: 72px;
	box-sizing: border-box;
	transition: border-color .12s, box-shadow .12s;

	&:focus { border-color: var(--rtgw-accent); outline: none; box-shadow: 0 0 0 3px var(--rtgw-accent-glow); }
}

// Layout variants — 'popup' (the default toggle + modal look, styled
// above) and 'grid' (shown inline, no popup). Chosen from the plugin's
// General settings, applied identically to both checkout types.
.rtgw-layout-grid {
	.rtgw-action { width: 100%; justify-content: center; }
}
