/**
 * E4Egg Quick Order - Product Grid Widget & Shortcode Styles
 * Ultra-Clean Modern UI/UX, Mobile-First 2-Column Responsive Grid, Tabular Numerals
 *
 * @package E4Egg_Quick_Order
 */

:root {
	--e4-brand-green: #16a34a;
	--e4-brand-green-hover: #15803d;
	--e4-brand-green-light: rgba(22, 163, 74, 0.08);
	--e4-brand-green-border: rgba(22, 163, 74, 0.28);
	--e4-grid-card-bg: #ffffff;
	--e4-grid-border: #edf2f7;
	--e4-grid-border-hover: #cbd5e1;
	--e4-grid-text-main: #0f172a;
	--e4-grid-text-sub: #475569;
	--e4-grid-text-muted: #94a3b8;
	--e4-grid-radius: 14px;
	--e4-grid-btn-radius: 8px;
	--e4-grid-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
	--e4-grid-shadow: 0 2px 6px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
	--e4-grid-shadow-hover: 0 12px 24px -6px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.03);
}

/* Container Reset & Wrapper */
.e4egg-grid-wrapper {
	width: 100%;
	max-width: 1200px;
	margin: 0 auto;
	padding: 12px 0;
	font-family: var(--e4-grid-font);
	color: var(--e4-grid-text-main);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	box-sizing: border-box;
}

.e4egg-grid-wrapper *,
.e4egg-grid-wrapper *::before,
.e4egg-grid-wrapper *::after {
	box-sizing: border-box;
}

/* Grid Layout */
.e4egg-grid-container {
	display: grid;
	gap: 14px;
	width: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Desktop Columns */
.e4egg-grid-cols-2 .e4egg-grid-container {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.e4egg-grid-cols-3 .e4egg-grid-container {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.e4egg-grid-cols-4 .e4egg-grid-container {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

.e4egg-grid-cols-5 .e4egg-grid-container {
	grid-template-columns: repeat(5, minmax(0, 1fr));
}

.e4egg-grid-cols-6 .e4egg-grid-container {
	grid-template-columns: repeat(6, minmax(0, 1fr));
}

/* Tablet Breakpoint (641px - 880px) */
@media (max-width: 880px) {
	.e4egg-grid-container {
		gap: 12px;
	}
	.e4egg-grid-cols-3 .e4egg-grid-container,
	.e4egg-grid-cols-4 .e4egg-grid-container,
	.e4egg-grid-cols-5 .e4egg-grid-container,
	.e4egg-grid-cols-6 .e4egg-grid-container {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* Mobile Breakpoint (<= 640px) - STRICT 2 EQUAL COLUMNS */
@media (max-width: 640px) {
	.e4egg-grid-wrapper {
		padding: 6px 0;
	}
	.e4egg-grid-container {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 10px !important;
	}
}

/* Very Small Mobile (< 360px) */
@media (max-width: 360px) {
	.e4egg-grid-container {
		gap: 8px !important;
	}
}

/* Product Card */
.e4egg-grid-card {
	background: var(--e4-grid-card-bg);
	border: 1px solid var(--e4-grid-border);
	border-radius: var(--e4-grid-radius);
	box-shadow: var(--e4-grid-shadow);
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	overflow: hidden;
	position: relative;
	transition: border-color 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
	height: 100%;
}

.e4egg-grid-card:hover {
	border-color: var(--e4-grid-border-hover);
	box-shadow: var(--e4-grid-shadow-hover);
	transform: translateY(-3px);
}

.e4egg-grid-card.is-out-of-stock {
	opacity: 0.72;
}

.e4egg-grid-card.is-out-of-stock:hover {
	transform: none;
	box-shadow: var(--e4-grid-shadow);
}

/* Image Wrapper (1:1 Ratio) */
.e4egg-grid-thumb-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	background: #f8fafc;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.e4egg-grid-thumb-link {
	display: block;
	width: 100%;
	height: 100%;
	text-decoration: none;
}

.e4egg-grid-thumb,
.e4egg-grid-thumb-link img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	image-rendering: -webkit-optimize-contrast;
	image-rendering: crisp-edges;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	transform: translateZ(0);
	transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.e4egg-grid-card:hover .e4egg-grid-thumb,
.e4egg-grid-card:hover .e4egg-grid-thumb-link img {
	transform: scale(1.05) translateZ(0);
}

.e4egg-grid-thumb-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #cbd5e1;
	background: #f1f5f9;
}

.e4egg-grid-thumb-placeholder svg {
	width: 44px !important;
	height: 44px !important;
	opacity: 0.6;
}

/* Badges Overlay */
.e4egg-grid-badges {
	position: absolute;
	top: 8px;
	left: 8px;
	right: 8px;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	pointer-events: none;
	z-index: 2;
}

.e4egg-grid-discount-badge {
	background: #f43f5e;
	color: #ffffff;
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.02em;
	padding: 3px 7px;
	border-radius: 6px;
	line-height: 1.2;
	text-transform: uppercase;
	box-shadow: 0 2px 6px rgba(244, 63, 94, 0.3);
}

.e4egg-grid-incart-badge {
	background: #16a34a;
	color: #ffffff;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.02em;
	padding: 3px 7px;
	border-radius: 6px;
	line-height: 1.2;
	box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
	display: inline-flex;
	align-items: center;
}

.e4egg-grid-oos-badge {
	background: rgba(15, 23, 42, 0.85);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	color: #ffffff;
	font-size: 10px;
	font-weight: 600;
	padding: 3px 6px;
	border-radius: 5px;
	line-height: 1.2;
	text-transform: uppercase;
	margin-left: auto;
}

/* Card Details */
.e4egg-grid-details {
	padding: 10px 10px 12px;
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	justify-content: space-between;
	background: #ffffff;
}

/* Unit Badge */
.e4egg-grid-unit {
	display: inline-block;
	align-self: flex-start;
	font-size: 10px;
	font-weight: 700;
	color: var(--e4-grid-text-sub);
	background: #f1f5f9;
	border-radius: 4px;
	padding: 2px 6px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	margin-bottom: 5px;
	line-height: 1.2;
}

/* Product Title - Clean 2-Line Truncation & Equal Baseline */
.e4egg-grid-title {
	margin: 0 0 6px;
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--e4-grid-text-main);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
	height: 38px;
	min-height: 38px;
	max-height: 38px;
}

.e4egg-grid-title a {
	color: inherit;
	text-decoration: none;
	transition: color 0.15s ease;
}

.e4egg-grid-title a:hover {
	color: var(--e4-brand-green, #16a34a);
}

/* Price Row */
.e4egg-grid-price-row {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 5px;
	min-height: 22px;
	margin-bottom: 4px;
}

.e4egg-grid-price {
	font-size: 15.5px;
	font-weight: 700;
	color: var(--e4-brand-green, #16a34a);
	font-variant-numeric: tabular-nums;
	line-height: 1.2;
}

.e4egg-grid-price .e4egg-price-del,
.e4egg-grid-price del {
	font-size: 12px;
	color: var(--e4-grid-text-muted);
	font-weight: 400;
	margin-right: 4px;
	text-decoration: line-through;
}

.e4egg-grid-price .e4egg-price-ins,
.e4egg-grid-price ins {
	text-decoration: none;
	color: var(--e4-brand-green, #16a34a);
	font-weight: 700;
}

/* Stock Pending Status Indicator */
.e4egg-grid-stock {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 11px;
	font-weight: 500;
	color: #059669;
	min-height: 16px;
	margin-bottom: 8px;
	line-height: 1;
}

.e4egg-grid-stock.is-low {
	color: #d97706;
}

.e4egg-grid-stock-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #10b981;
	flex-shrink: 0;
}

.e4egg-grid-stock.is-low .e4egg-grid-stock-dot {
	background: #f59e0b;
	animation: e4eggPulseDot 1.6s infinite ease-in-out;
}

@keyframes e4eggPulseDot {
	0%, 100% {
		opacity: 1;
		transform: scale(1);
	}
	50% {
		opacity: 0.5;
		transform: scale(1.3);
	}
}

/* Dual Action Buttons Row */
.e4egg-grid-actions {
	display: flex;
	gap: 6px;
	margin-top: auto;
	width: 100%;
}

/* Base button overrides against theme rules */
.e4egg-grid-actions button.button,
.e4egg-grid-actions a.button,
.e4egg-grid-actions .button {
	position: relative;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 5px !important;
	flex: 1 1 0 !important;
	min-width: 0 !important;
	min-height: 36px !important;
	height: 36px !important;
	padding: 0 6px !important;
	border-radius: var(--e4-grid-btn-radius) !important;
	font-family: inherit !important;
	font-size: 12px !important;
	font-weight: 600 !important;
	line-height: 1 !important;
	text-decoration: none !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	box-shadow: none !important;
	cursor: pointer;
	transition: all 0.16s ease !important;
	border: 1px solid transparent !important;
	margin: 0 !important;
	outline: none !important;
	-webkit-tap-highlight-color: transparent;
}

.e4egg-grid-actions button.button:active,
.e4egg-grid-actions a.button:active {
	transform: scale(0.97);
}

/* Locked SVG Icon dimensions */
.e4egg-grid-actions svg.e4egg-icon {
	width: 14px !important;
	height: 14px !important;
	min-width: 14px !important;
	min-height: 14px !important;
	max-width: 14px !important;
	max-height: 14px !important;
	flex-shrink: 0 !important;
	display: inline-block !important;
	vertical-align: middle !important;
	margin: 0 !important;
}

/* Responsive Button Text Labels */
.e4egg-btn-txt-short {
	display: none;
}

@media (max-width: 640px) {
	.e4egg-grid-actions {
		flex-direction: column !important;
		gap: 6px !important;
	}
	.e4egg-grid-actions button.button,
	.e4egg-grid-actions a.button,
	.e4egg-grid-actions .button {
		width: 100% !important;
		min-width: 100% !important;
		flex: none !important;
		height: 34px !important;
		min-height: 34px !important;
	}
	.e4egg-grid-btn-quick {
		order: 1 !important;
	}
	.e4egg-grid-btn-cart {
		order: 2 !important;
	}
	.e4egg-btn-txt-long {
		display: inline !important;
	}
	.e4egg-btn-txt-short {
		display: none !important;
	}
}

/* Add to Cart Button (Clean outlined style) */
.e4egg-grid-actions .e4egg-grid-btn-cart {
	background: #f8fafc !important;
	border-color: #cbd5e1 !important;
	color: #334155 !important;
}

.e4egg-grid-actions .e4egg-grid-btn-cart:hover:not(:disabled) {
	background: #f1f5f9 !important;
	border-color: var(--e4-brand-green, #16a34a) !important;
	color: var(--e4-brand-green, #16a34a) !important;
}

.e4egg-grid-actions .e4egg-grid-btn-cart.is-added {
	background: #059669 !important;
	border-color: #059669 !important;
	color: #ffffff !important;
}

/* Quick Order Button (High-conversion filled brand style) */
.e4egg-grid-actions .e4egg-grid-btn-quick {
	background: var(--e4-brand-green, #16a34a) !important;
	border-color: var(--e4-brand-green, #16a34a) !important;
	color: #ffffff !important;
	box-shadow: 0 2px 6px rgba(22, 163, 74, 0.22) !important;
}

.e4egg-grid-actions .e4egg-grid-btn-quick:hover:not(:disabled) {
	background: var(--e4-brand-green-hover, #15803d) !important;
	border-color: var(--e4-brand-green-hover, #15803d) !important;
	color: #ffffff !important;
	box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3) !important;
}

/* Button Loading Spinner */
.e4egg-btn-spinner {
	display: none;
	width: 13px;
	height: 13px;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: currentColor;
	border-radius: 50%;
	animation: e4eggGridSpin 0.6s linear infinite;
	flex-shrink: 0;
}

.e4egg-grid-btn-cart .e4egg-btn-spinner {
	border-color: rgba(51, 65, 85, 0.25);
	border-top-color: #334155;
}

.e4egg-grid-actions .button.is-loading .e4egg-icon,
.e4egg-grid-actions .button.is-loading .e4egg-btn-label {
	display: none !important;
}

.e4egg-grid-actions .button.is-loading .e4egg-btn-spinner {
	display: inline-block !important;
}

@keyframes e4eggGridSpin {
	to {
		transform: rotate(360deg);
	}
}

/* Out of Stock Label */
.e4egg-grid-unavailable {
	width: 100%;
	text-align: center;
	padding: 8px 6px;
	background: #f1f5f9;
	color: #64748b;
	font-size: 11.5px;
	font-weight: 600;
	border-radius: var(--e4-grid-btn-radius);
	border: 1px dashed #cbd5e1;
}

/* Empty State */
.e4egg-grid-empty {
	text-align: center;
	padding: 32px 16px;
	background: #ffffff;
	border: 1px solid var(--e4-grid-border);
	border-radius: var(--e4-grid-radius);
	color: var(--e4-grid-text-sub);
	font-size: 14px;
}

/* Toast Notification (Floating bottom-right or bottom-center on mobile) */
.e4egg-toast-banner {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99999;
	background: #0f172a;
	color: #ffffff;
	padding: 11px 16px;
	border-radius: 12px;
	box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.35);
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 13.5px;
	font-weight: 500;
	animation: e4eggToastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
	max-width: calc(100vw - 32px);
}

.e4egg-toast-banner a {
	color: #4ade80;
	text-decoration: underline;
	font-weight: 600;
}

.e4egg-toast-banner.is-error {
	background: #b91c1c;
}

@keyframes e4eggToastIn {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.96);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@media (max-width: 640px) {
	.e4egg-toast-banner {
		left: 16px;
		right: 16px;
		bottom: 16px;
		justify-content: center;
	}
}
