/* ========================================
   RxSpot Shared Mobile Fixes
   Loaded by ALL templates. Contains only
   @media-guarded rules so desktop is untouched.
   ======================================== */

/* ── Prevent horizontal overflow on mobile ── */
@media screen and (max-width: 980px) {
	html, body {
		overflow-x: hidden;
	}
}

/* ── Cart sidebar: full-width on tablets and below ── */
@media screen and (max-width: 980px) {
	#cart-sidebar {
		width: 100% !important;
	}
}

@media screen and (max-width: 480px) {
	#cart-sidebar .inner {
		padding: 1em;
	}

	.cart-item {
		flex-wrap: wrap;
	}

	.cart-item-image {
		width: 3em;
		height: 3em;
	}

	.cart-item-quantity {
		flex-wrap: wrap;
		gap: 0.5rem;
	}

	.cart-item-quantity .button.remove-btn {
		margin-left: 0;
		width: 100%;
		text-align: left;
		padding-left: 0;
	}
}

/* ── Sticky cart bar: stack vertically on narrow screens ── */
@media screen and (max-width: 736px) {
	#sticky-cart-bar {
		flex-direction: column;
		gap: 0.75em;
		padding: 0.75em 1em;
		padding-bottom: calc(0.75em + env(safe-area-inset-bottom));
	}

	.sticky-cart-actions {
		width: 100%;
	}

	.sticky-cart-actions .button {
		flex: 1;
	}
}

@media screen and (max-width: 480px) {
	.sticky-cart-actions .button {
		font-size: 0.85em;
		padding: 0 1.25em;
	}

	.sticky-cart-count {
		min-width: 2em;
		height: 2em;
		font-size: 0.85em;
	}
}

/* ── Product cards: prevent text clipping ── */
@media screen and (max-width: 480px) {
	.product-card .product-description,
	.product-desc,
	.product-description {
		word-break: break-word;
		overflow-wrap: break-word;
	}

	.product-card h3,
	.product-card h4,
	.product-name {
		word-break: break-word;
		overflow-wrap: break-word;
	}
}

/* ── Product card buttons: stack on mobile ── */
@media screen and (max-width: 736px) {
	.product-card .actions {
		flex-direction: column;
	}

	.product-card .actions li {
		width: 100%;
	}

	.product-card .button {
		width: 100%;
		text-align: center;
	}
}

/* ── Product grid: single column on phones ── */
@media screen and (max-width: 736px) {
	.product-grid {
		grid-template-columns: 1fr !important;
		gap: 1.5em;
	}
}

/* ── Category grid: compact on phones ── */
@media screen and (max-width: 736px) {
	.category-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 1em;
	}

	.category-card {
		padding: 1.5em 1em;
	}

	.category-card .icon {
		font-size: 2em;
	}
}

@media screen and (max-width: 480px) {
	.category-grid {
		grid-template-columns: 1fr;
	}
}

/* ── Trust badges: stack on small screens ── */
@media screen and (max-width: 480px) {
	.trust-badges {
		flex-direction: column;
		gap: 1.5em;
		align-items: center;
	}
}

/* ── Action buttons (ul.actions): wrap instead of overflow ── */
@media screen and (max-width: 736px) {
	ul.actions:not(.stacked) {
		flex-wrap: wrap;
		gap: 0.75em;
	}

	ul.actions:not(.stacked) li {
		padding-left: 0;
	}
}

@media screen and (max-width: 480px) {
	ul.actions:not(.stacked) li {
		flex: 1 1 100%;
	}

	ul.actions:not(.stacked) li .button {
		width: 100%;
		text-align: center;
	}
}

/* ── Checkout container: single column on mobile ── */
@media screen and (max-width: 980px) {
	.checkout-container {
		grid-template-columns: 1fr;
		gap: 2em;
	}

	.checkout-sidebar {
		position: static;
	}
}

/* ── Checkout progress: wrap steps on mobile ── */
@media screen and (max-width: 736px) {
	.checkout-progress {
		flex-wrap: wrap;
		gap: 1em;
	}

	.checkout-progress::before {
		display: none;
	}

	.progress-step {
		flex: 1;
		min-width: 80px;
	}

	.progress-step .step-label {
		font-size: 0.75em;
	}
}

/* ── Auth form: single column fields on phones ── */
@media screen and (max-width: 736px) {
	.auth-form .field-row {
		grid-template-columns: 1fr;
	}
}

/* ── Search bar: stack on mobile ── */
@media screen and (max-width: 736px) {
	.search-bar form {
		flex-direction: column;
	}
}

/* ── Telehealth: responsive adjustments ── */
@media screen and (max-width: 980px) {
	.telehealth-hero {
		flex-direction: column;
		text-align: center;
		padding: 2.5em 2em;
	}

	.telehealth-hero-illustration {
		max-width: 280px;
		width: 60%;
	}

	.eligibility-layout {
		grid-template-columns: 1fr;
	}

	.eligibility-sidebar-panel {
		position: static;
	}
}

@media screen and (max-width: 736px) {
	.telehealth-field-row {
		grid-template-columns: 1fr;
		gap: 0;
	}

	.telehealth-questionnaire {
		padding: 1.5em;
	}

	.telehealth-hero {
		padding: 2em 1.5em;
	}

	.telehealth-hero-content h1 {
		font-size: 1.75em;
	}

	.telehealth-trust {
		gap: 1em;
	}

	.telehealth-trust-badge {
		flex: 1 1 100%;
		justify-content: center;
	}
}

/* ── Footer: stack on mobile ── */
@media screen and (max-width: 980px) {
	.footer-content {
		flex-direction: column;
		gap: 2em;
	}

	.footer-section:first-child {
		flex: 1;
	}
}

/* ── Logo: constrain on small screens ── */
@media screen and (max-width: 736px) {
	.rxspot-logo-mark[data-rxspot-logo-active="1"] img {
		max-width: min(var(--rxspot-nav-logo-max-width, 12rem), 55vw);
	}
}

/* ── Modal: full-width on phones ── */
@media screen and (max-width: 640px) {
	.rxspot-modal {
		width: 100% !important;
		max-height: calc(100vh - 16px) !important;
		border-radius: 0.375em !important;
	}
}

/* ── Hero section (used by editorial/dimension/etc.): prevent button overflow ── */
@media screen and (max-width: 736px) {
	.hero-section {
		padding: 2.5em 1.5em;
	}

	/* Use flex-direction:column + margin-left:0 instead of flex-wrap+flex-basis:100%.
	   Android Chrome miscalculates flex-basis:100% when the container has margin-left:-1em
	   (inherited from ul.actions base styles), causing buttons to overflow the viewport. */
	.hero-section .actions {
		flex-direction: column;
		flex-wrap: nowrap;
		margin-left: 0;
		gap: 0.75em;
	}

	.hero-section .actions li {
		padding-left: 0;
		width: 100%;
		flex: none;
	}

	.hero-section .actions .button {
		display: block;
		width: 100%;
		text-align: center;
	}

	.hero-content {
		max-width: 100%;
		padding-right: 0;
	}
}

@media screen and (max-width: 480px) {
	.hero-section {
		padding: 2em 1.25em;
		min-height: auto;
	}

	.hero-section h1 {
		font-size: 1.5em;
	}

	.hero-section p {
		font-size: 1em;
	}

	.hero-section::before {
		display: none;
	}
}

/* ── Wrapper bottom padding for sticky cart ── */
@media screen and (max-width: 736px) {
	body.has-sticky-cart #wrapper {
		padding-bottom: calc(10em + env(safe-area-inset-bottom));
	}
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
	#cart-sidebar,
	#sticky-cart-bar {
		transition: none !important;
	}
}

/* ── Cart quantity controls — hidden (single-unit per medication, all templates) ──
   Quantity +/- buttons and the qty count are hidden globally. The Remove button
   is re-styled as a plain text action link so the cart item stays clean. ── */
.cart-item-quantity [data-rxspot-qty-dec],
.cart-item-quantity [data-rxspot-qty-inc],
.cart-item-quantity > span {
	display: none !important;
}

.cart-item-quantity .remove-btn {
	background: none !important;
	border: none !important;
	box-shadow: none !important;
	padding: 0.2em 0 !important;
	margin: 0 !important;
	font-size: 0.72em !important;
	font-weight: 600 !important;
	text-transform: uppercase !important;
	letter-spacing: 0.08em !important;
	height: auto !important;
	line-height: 1.4 !important;
	min-height: unset !important;
	min-width: unset !important;
	width: auto !important;
	color: #bbb !important;
	cursor: pointer !important;
	display: inline-block !important;
	transition: color 0.15s ease !important;
}

.cart-item-quantity .remove-btn:hover {
	background: none !important;
	color: #dc3545 !important;
}
