/**
 * Frontend Styles for Global Compliance Icons
 */

.gcw-product-image-wrapper {
	position: relative;
	display: inline-block;
	width: 100%;
	overflow: hidden; /* Ensure icons stay within image bounds */
}

.gcw-product-image-wrapper img {
	display: block;
	width: 100%;
	height: auto;
}

/* Shop loop wrapper */
.woocommerce ul.products li.product {
	position: relative;
}

.woocommerce ul.products li.product .woocommerce-loop-product__link {
	position: relative;
	display: block;
}

.woocommerce ul.products li.product .gcw-icons-container {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 10;
}

/* Single product wrapper */
.gcw-single-product-gallery-wrapper {
	position: relative;
}

.woocommerce div.product .woocommerce-product-gallery {
	position: relative;
}

.woocommerce div.product .woocommerce-product-gallery__wrapper {
	position: relative;
}

.woocommerce div.product .woocommerce-product-gallery__image {
	position: relative;
}

.woocommerce div.product .gcw-icons-container {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 10;
}

.gcw-icons-container {
	position: absolute;
	z-index: 10;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px;
	pointer-events: none;
	max-width: 100%; /* Prevent overflow */
	max-height: 100%; /* Prevent overflow */
	box-sizing: border-box; /* Include padding in width calculation */
}

.gcw-icons-container .gcw-icon {
	width: var(--gcw-icon-size, 32px);
	height: var(--gcw-icon-size, 32px);
	min-width: var(--gcw-icon-size, 32px);
	min-height: var(--gcw-icon-size, 32px);
	max-width: var(--gcw-icon-size, 32px);
	max-height: var(--gcw-icon-size, 32px);
	flex-shrink: 0; /* Prevent icons from shrinking */
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.95);
	border-radius: 50%;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	pointer-events: auto;
	cursor: help;
	transition: all 0.3s ease;
	border: 2px solid rgba(255, 255, 255, 0.8);
	box-sizing: border-box; /* Include border in size calculation */
}

.gcw-icons-container .gcw-icon:hover {
	transform: scale(1.1);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
	z-index: 11;
}

/* Ensure hover transform doesn't affect container positioning */
.gcw-icons-container.gcw-position-top-center .gcw-icon:hover,
.gcw-icons-container.gcw-position-middle-left .gcw-icon:hover,
.gcw-icons-container.gcw-position-middle-center .gcw-icon:hover,
.gcw-icons-container.gcw-position-middle-right .gcw-icon:hover,
.gcw-icons-container.gcw-position-bottom-center .gcw-icon:hover {
	/* Hover transform is on icon, not container, so no conflict */
}

.gcw-icons-container .gcw-icon img,
.gcw-icons-container .gcw-icon svg {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 4px;
}

/* Position Classes - Ensure proper positioning */
.gcw-position-top-left {
	top: 8px !important;
	left: 8px !important;
	right: auto !important;
	bottom: auto !important;
	justify-content: flex-start;
	align-items: flex-start;
	max-width: calc(100% - 16px);
	max-height: calc(100% - 16px);
	transform: none !important;
}

.gcw-position-top-center {
	top: 8px !important;
	left: 50% !important;
	right: auto !important;
	bottom: auto !important;
	transform: translateX(-50%) !important;
	justify-content: center;
	align-items: flex-start;
	max-width: calc(100% - 16px);
	max-height: calc(100% - 16px);
}

.gcw-position-top-right {
	top: 8px !important;
	right: 8px !important;
	left: auto !important;
	bottom: auto !important;
	justify-content: flex-end;
	align-items: flex-start;
	max-width: calc(100% - 16px);
	max-height: calc(100% - 16px);
	transform: none !important;
}

.gcw-position-middle-left {
	top: 50% !important;
	left: 8px !important;
	right: auto !important;
	bottom: auto !important;
	transform: translateY(-50%) !important;
	justify-content: flex-start;
	align-items: center;
	max-width: calc(100% - 16px);
	max-height: calc(100% - 16px);
}

.gcw-position-middle-center {
	top: 50% !important;
	left: 50% !important;
	right: auto !important;
	bottom: auto !important;
	transform: translate(-50%, -50%) !important;
	justify-content: center;
	align-items: center;
	max-width: calc(100% - 16px);
	max-height: calc(100% - 16px);
}

.gcw-position-middle-right {
	top: 50% !important;
	right: 8px !important;
	left: auto !important;
	bottom: auto !important;
	transform: translateY(-50%) !important;
	justify-content: flex-end;
	align-items: center;
	max-width: calc(100% - 16px);
	max-height: calc(100% - 16px);
}

.gcw-position-bottom-left {
	bottom: 8px !important;
	left: 8px !important;
	top: auto !important;
	right: auto !important;
	justify-content: flex-start;
	align-items: flex-end;
	max-width: calc(100% - 16px);
	max-height: calc(100% - 16px);
	transform: none !important;
}

.gcw-position-bottom-center {
	bottom: 8px !important;
	left: 50% !important;
	top: auto !important;
	right: auto !important;
	transform: translateX(-50%) !important;
	justify-content: center;
	align-items: flex-end;
	max-width: calc(100% - 16px);
	max-height: calc(100% - 16px);
}

.gcw-position-bottom-right {
	bottom: 8px !important;
	right: 8px !important;
	top: auto !important;
	left: auto !important;
	justify-content: flex-end;
	align-items: flex-end;
	max-width: calc(100% - 16px);
	max-height: calc(100% - 16px);
	transform: none !important;
}

/* Shop loop specific positioning */
.woocommerce ul.products li.product .woocommerce-loop-product__link {
	position: relative;
	display: block;
	overflow: hidden; /* Ensure icons stay within image bounds */
}

.woocommerce ul.products li.product .woocommerce-loop-product__link img {
	display: block;
	width: 100%;
	height: auto;
}

.woocommerce ul.products li.product .gcw-icons-container {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	max-width: 100%;
	max-height: 100%;
	box-sizing: border-box;
}

/* Single product specific positioning */
.woocommerce div.product .woocommerce-product-gallery__image {
	position: relative;
	overflow: hidden; /* Ensure icons stay within image bounds */
}

.woocommerce div.product .woocommerce-product-gallery__image img {
	display: block;
	width: 100%;
	height: auto;
}

.woocommerce div.product .woocommerce-product-gallery__wrapper .gcw-icons-container {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	max-width: 100%;
	max-height: 100%;
	box-sizing: border-box;
}

/* Tooltip Styles */
.gcw-tooltip {
	position: absolute;
	background: #333;
	color: #fff;
	padding: 6px 12px;
	border-radius: 4px;
	font-size: 12px;
	white-space: nowrap;
	z-index: 1000;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.3s ease;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.gcw-tooltip.show {
	opacity: 1;
}

.gcw-tooltip::after {
	content: '';
	position: absolute;
	width: 0;
	height: 0;
	border: 5px solid transparent;
}

.gcw-tooltip.top::after {
	bottom: -10px;
	left: 50%;
	transform: translateX(-50%);
	border-top-color: #333;
}

.gcw-tooltip.bottom::after {
	top: -10px;
	left: 50%;
	transform: translateX(-50%);
	border-bottom-color: #333;
}

.gcw-tooltip.left::after {
	right: -10px;
	top: 50%;
	transform: translateY(-50%);
	border-left-color: #333;
}

.gcw-tooltip.right::after {
	left: -10px;
	top: 50%;
	transform: translateY(-50%);
	border-right-color: #333;
}

/* Shop Loop Context */
.gcw-context-loop .gcw-icons-container {
	padding: 4px;
	gap: 4px;
}

.gcw-context-loop .gcw-icon {
	width: calc(var(--gcw-icon-size, 32px) * 0.75);
	height: calc(var(--gcw-icon-size, 32px) * 0.75);
}

/* Responsive Design */
@media (max-width: 768px) {
	.gcw-icons-container {
		padding: 4px;
		gap: 4px;
	}
	
	.gcw-icon {
		width: calc(var(--gcw-icon-size, 32px) * 0.85) !important;
		height: calc(var(--gcw-icon-size, 32px) * 0.85) !important;
	}
	
	.gcw-tooltip {
		font-size: 11px;
		padding: 4px 8px;
	}
}

/* High DPI / Retina Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
	.gcw-icon img,
	.gcw-icon svg {
		image-rendering: -webkit-optimize-contrast;
		image-rendering: crisp-edges;
	}
}

/* Animation for icon appearance */
@keyframes gcw-icon-fade-in {
	from {
		opacity: 0;
		transform: scale(0.8);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

.gcw-icon {
	animation: gcw-icon-fade-in 0.3s ease;
}

/* Custom CSS support */
.gcw-icons-container.custom-position {
	position: static;
}

