/**
 * Shared responsive styles for form PDF preview panels
 * (1099 / 1040 / W-2 / W-4 and similar).
 */
[id$="-pdf-viewer-wrap"],
#w2-pdf-viewer-wrap {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	overflow: hidden;
}

[id$="-pdf-viewer-shell"] {
	position: relative;
	width: 100%;
	max-width: 100%;
	overflow: hidden;
}

[id$="-pdf-viewer"],
#w2-pdf-viewer {
	display: block;
	box-sizing: border-box;
	width: 100% !important;
	max-width: 100%;
	height: min(780px, 75vh) !important;
	min-height: 360px;
	border: 1px solid #ccc !important;
	border-radius: 4px;
	background: #f6f8fa;
}

[id$="-pdf-viewer-wrap"] > div:first-child,
[id$="-pdf-toolbar"],
.w2-pdf-toolbar,
.c1099-pdf-toolbar,
.form1040-pdf-toolbar,
.nec1099-pdf-toolbar,
.misc1099-pdf-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 14px;
	margin-bottom: 8px;
	padding: 6px 0;
	border-bottom: 1px solid #ccc;
	box-sizing: border-box;
}

[id$="-pdf-viewer-wrap"] a,
#w2-pdf-viewer-wrap a {
	display: inline-block;
	line-height: 1.4;
	word-break: break-word;
}

.ps-pdf-mobile-hint {
	display: none;
	margin: 0 0 10px;
	padding: 10px 12px;
	border: 1px solid #d0d7de;
	border-radius: 4px;
	background: #fff8c5;
	color: #24292f;
	font-size: 14px;
	line-height: 1.45;
}

@media (max-width: 991px) {
	/* Stack form + preview columns (with and without :has support) */
	.wp-block-columns:has([id$="-pdf-viewer-wrap"]),
	.wp-block-columns:has(#w2-pdf-viewer-wrap),
	.wp-block-columns:has([id^="step2"]) {
		flex-wrap: wrap !important;
		flex-direction: column !important;
	}

	.wp-block-columns:has([id$="-pdf-viewer-wrap"]) > .wp-block-column,
	.wp-block-columns:has(#w2-pdf-viewer-wrap) > .wp-block-column,
	.wp-block-columns:has([id^="step2"]) > .wp-block-column,
	.wp-block-columns:not(.is-not-stacked-on-mobile) > .wp-block-column {
		flex-basis: 100% !important;
		width: 100% !important;
		max-width: 100% !important;
	}

	/* Sticky preview columns break / clip on phones */
	.wp-block-column:has([id$="-pdf-viewer-wrap"]) > div[style*="sticky"],
	.wp-block-column:has(#w2-pdf-viewer-wrap) > div[style*="sticky"],
	.wp-block-column:has([id^="step2"]) > div[style*="sticky"],
	.wp-block-column > div[style*="position:sticky"],
	.wp-block-column > div[style*="position: sticky"],
	.wp-block-column > div[style*="-webkit-sticky"] {
		position: static !important;
		top: auto !important;
	}

	#step2,
	#step2_1040,
	#step2_1040sub,
	#step2_w4,
	[id^="step2"] {
		width: 100%;
		max-width: 100%;
		box-sizing: border-box;
		overflow-x: hidden;
	}

	[id$="-pdf-viewer-wrap"],
	#w2-pdf-viewer-wrap,
	[id$="-legacy-wrap"],
	[id$="-actions-wrap"],
	#w2-actions-wrap,
	.ps-hint {
		margin-left: 0 !important;
		margin-right: 0 !important;
		padding-left: 0;
		padding-right: 0;
		width: 100%;
		max-width: 100%;
		box-sizing: border-box;
	}

	[id$="-pdf-viewer"],
	#w2-pdf-viewer {
		height: min(65vh, 560px) !important;
		min-height: 300px;
	}

	[id$="-actions-wrap"] .btn,
	[id$="-actions-wrap"] input.btn,
	[id$="-actions-wrap"] input[type="button"],
	#w2-actions-wrap .btn,
	#w2-actions-wrap input[type="button"],
	#btncontinue,
	#btncontinue1040,
	#btncontinue1040sub {
		float: none !important;
		display: block;
		width: 100%;
		max-width: 100%;
		box-sizing: border-box;
		margin-top: 8px !important;
	}

	.ps-pdf-mobile-hint {
		display: block;
	}
}

@media (max-width: 480px) {
	[id$="-pdf-viewer"],
	#w2-pdf-viewer {
		height: min(55vh, 420px) !important;
		min-height: 260px;
	}
}

/* iOS / Android: in-page PDF iframes are unreliable — emphasize open/download */
body.ps-pdf-mobile-ua [id$="-pdf-viewer"],
body.ps-pdf-mobile-ua #w2-pdf-viewer {
	min-height: 220px;
	height: min(50vh, 360px) !important;
}
