/* =========================================================
   Meshon3D WooCommerce Viewer — Frontend Styles v1.5
   ========================================================= */

/* ── Gallery Item Thumbnail ── */
.woocommerce-product-gallery .meshon3d-gallery-item,
.woocommerce-product-gallery__image.meshon3d-gallery-item {
	position: relative;
	cursor: pointer;
}

.meshon3d-gallery-item .meshon3d-thumb-img {
	border-radius: 4px;
}

/* 3D badge on thumbnail */
.meshon3d-gallery-item::after {
	content: "3D";
	position: absolute;
	top: 6px;
	right: 6px;
	background: linear-gradient(135deg, #e94560, #c0392b);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 4px;
	letter-spacing: 0.5px;
	pointer-events: none;
}

/* ── Main Viewer (gallery slot) ── */
.meshon3d-main-viewer {
	position: relative;
	width: 100%;
}

.meshon3d-iframe-wrapper {
	width: 100%;
	position: relative;
	border-radius: 12px;
	overflow: hidden;
	background: #f8f9fa;
}

.meshon3d-iframe-wrapper iframe {
	display: block;
	width: 100%;
	border: none;
	border-radius: 12px;
}

/* ── AR Button — base styles ── */
.meshon3d-ar-button-wrap {
	margin-bottom: 16px;
}

.meshon3d-viewer-btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	background: var(--wp--preset--color--primary, var(--color-primary, #1a1a2e));
	color: var(--wp--preset--color--background, #fff);
	border: none;
	border-radius: 8px;
	padding: 12px 22px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.15s ease;
	font-family: inherit;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
}

.meshon3d-viewer-btn:hover {
	transform: translateY(-1px);
}

.meshon3d-viewer-btn:active {
	transform: translateY(0);
}

/* ── Responsive: standard button ── */
@media (max-width: 768px) {
	.meshon3d-ar-button-wrap:not(.meshon3d-ar-over-image) .meshon3d-viewer-btn {
		width: 100%;
		justify-content: center;
		font-size: 14px;
		padding: 11px 18px;
	}

	.meshon3d-iframe-wrapper iframe {
		height: 280px !important;
	}
}

/* ── Iframe Loading State ── */
.meshon3d-iframe-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	height: 400px;
	background: #f8f9fa;
	border-radius: 12px;
	color: #646970;
	font-size: 14px;
}

.meshon3d-spinner {
	display: inline-block;
	width: 24px;
	height: 24px;
	border: 3px solid #e0e0e0;
	border-top-color: #e94560;
	border-radius: 50%;
	animation: meshon3d-spin 0.8s linear infinite;
	flex-shrink: 0;
}

@keyframes meshon3d-spin {
	to { transform: rotate(360deg); }
}

/* ── 3D Viewer Tab ── */
.meshon3d-tab-viewer-wrap {
	padding: 20px 0;
	width: 100%;
	box-sizing: border-box;
}

.meshon3d-iframe-responsive {
	box-sizing: border-box;
	max-width: 100%;
	background: #f8f9fa;
	border-radius: 12px;
	overflow: hidden;
}

.meshon3d-iframe-responsive iframe {
	display: block;
	border: none;
}

@media (max-width: 768px) {
	.meshon3d-tab-viewer-wrap { padding: 12px 0; }
	.meshon3d-iframe-responsive {
		padding-top: 56.25% !important;
		height: auto !important;
	}
}

@media (max-width: 480px) {
	.meshon3d-tab-viewer-wrap { padding: 8px 0; }
	.meshon3d-iframe-responsive {
		padding-top: 75% !important;
		height: auto !important;
	}
}

/* ============================================================
   Button Position: Overlaid on Image
   ─────────────────────────────────────────────────────────
   JS appends #meshon3d-overlay-btn-wrap directly inside
   .woocommerce-product-gallery (and sets position:relative
   on it if needed), so all absolute coords are relative to
   the gallery box — exactly where the product image lives.
   ============================================================ */

/* Shared base — all overlay variants */
.meshon3d-ar-over-image {
	position: absolute;
	z-index: 20;
	margin: 0;
}

.meshon3d-ar-over-image .meshon3d-viewer-btn {
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.30);
	font-size: 13px;
	padding: 9px 18px;
}

/* ── Top row ── */
.meshon3d-pos-top-left {
	top: 16px;
	left: 16px;
}

.meshon3d-pos-top-center {
	top: 16px;
	left: 50%;
	transform: translateX(-50%);
}

.meshon3d-pos-top-right {
	top: 16px;
	right: 16px;
}

/* ── Bottom row ── */
.meshon3d-pos-bottom-left {
	bottom: 16px;
	left: 16px;
}

.meshon3d-pos-bottom-center {
	bottom: 16px;
	left: 50%;
	transform: translateX(-50%);
}

.meshon3d-pos-bottom-right {
	bottom: 16px;
	right: 16px;
}
