/**
 * WooCommerce 3D Viewer - Frontend Styles
 * Version: 3.0.3
 */

/* ==========================================================================
   Main Button & Badge
   ========================================================================== */

.wc-3d-button-wrapper {
	position: absolute;
	top: 15px;
	right: 15px;
	z-index: 10;
}

.wc-3d-badge {
	position: absolute;
	top: -7px;
	left: -2px;
	z-index: 11;
	background: #d94f4f; /* Fallback color for the badge */
	background: var(--bg-main, #d94f4f); /* Use theme variable if available */
	color: #fff;
	font-weight: bold;
	font-size: 12px;
	line-height: 1;
	padding: 5px;
	border-radius: 50%;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
	width: 26px;
	height: 26px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wc-3d-button {
	background: #fff;
	color: #000;
	border: solid 1px;
	padding: 0 10px;
	cursor: pointer;
	border-radius: 4px;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
	font-size: 16px;
	transition: background 0.3s, color 0.3s;
	height: 40px;
}

.wc-3d-button:hover {
	background: #000;
	color: #fff;
}


/* ==========================================================================
   Modal & Viewer
   ========================================================================== */

#wc-3d-modal {
	display: none;
	position: fixed;
	z-index: 99999;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.7);
	-webkit-backdrop-filter: blur(5px);
	backdrop-filter: blur(5px);
	opacity: 0;
	transition: opacity 0.4s ease;
}

#wc-3d-modal.is-opening {
	opacity: 1;
}

#wc-3d-content {
	position: relative;
	width: 90%;
	max-width: 1200px;
	height: 85%;
	margin: 5% auto;
	transform: translateY(50px);
	transition: transform 0.4s ease;
}

#wc-3d-modal.is-opening #wc-3d-content {
	transform: translateY(0);
}

#wc-3d-viewer-wrapper {
	position: relative;
	width: 100%;
	height: 100%;
	border-radius: 8px;
	overflow: hidden;
}

model-viewer {
	width: 100%;
	height: 100%;
	background: #fff;
	border: none;
}


/* ==========================================================================
   Loading Spinner & Animations
   ========================================================================== */

@keyframes wc-3d-spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

.wc-3d-loader {
	display: none;
	animation: wc-3d-spin 1s linear infinite;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 4px solid rgba(0, 0, 0, 0.2);
	border-top-color: #000;
	position: absolute;
	top: 50%;
	left: 50%;
	margin: -16px 0 0 -16px;
	z-index: 1;
}

@keyframes wc-3d-pop-in {
	from { transform: scale(0.95); opacity: 0; }
	to { transform: scale(1); opacity: 1; }
}

#wc-3d-viewer-wrapper:fullscreen > model-viewer {
	animation: wc-3d-pop-in 0.3s ease-out;
}


/* ==========================================================================
   Modal Controls (Close, Zoom, Fullscreen, Switcher)
   ========================================================================== */

#wc-3d-close {
	position: absolute;
	top: 15px;
	/* ✨ UPDATED: Moved from right to left */
	left: 25px; 
	color: #000;
	font-size: 50px;
	font-weight: 700;
	cursor: pointer;
	z-index: 100001;
	transition: transform 0.3s ease, color 0.3s ease;
	line-height: 1;
}

#wc-3d-close:hover {
	transform: scale(1.1);
	color: #ccc;
}

#wc-3d-controls {
	position: absolute;
	top: 15px;
	right: 15px;
	z-index: 2; /* Must be higher than the loader */
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.wc-3d-control-btn {
	background: rgba(255, 255, 255, 0.9);
	border: 1px solid #ccc;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s, box-shadow 0.2s;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wc-3d-control-btn:hover {
	background: #fff;
}

.wc-3d-control-btn svg {
	width: 22px;
	height: 22px;
	color: #333;
}

#wc-3d-exit-fullscreen {
	display: none;
}

#wc-3d-viewer-wrapper:fullscreen #wc-3d-fullscreen {
	display: none;
}

#wc-3d-viewer-wrapper:fullscreen #wc-3d-exit-fullscreen {
	display: flex;
}

#wc-3d-switcher {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 2;
	display: flex;
	gap: 10px;
	background: rgba(255, 255, 255, 0.9);
	padding: 8px;
	border-radius: 8px;
}

.wc-3d-switch-btn {
	padding: 8px 16px;
	border: 1px solid #ccc;
	background: #fff;
	color: #333;
	border-radius: 5px;
	cursor: pointer;
	font-weight: 500;
	transition: background 0.3s, color 0.3s;
}

.wc-3d-switch-btn:hover {
	background: #f0f0f0;
}

.wc-3d-switch-btn.active {
	background: #333;
	color: #fff;
	border-color: #333;
}


/* ==========================================================================
   Mobile Responsive Styles
   ========================================================================== */

@media (max-width: 768px) {
	#wc-3d-content {
		width: 100%;
		height: 100%;
		max-width: none;
		margin: 0;
	}

	#wc-3d-viewer-wrapper {
		border-radius: 0;
	}

	#wc-3d-close {
		top: 10px;
		/* ✨ UPDATED: Moved from right to left */
		left: 10px;
		font-size: 40px;
	}

	#wc-3d-controls {
		top: 10px;
		right: 10px;
		color: #000;
	}

	.wc-3d-control-btn {
		width: 36px;
		height: 36px;
	}

	.wc-3d-control-btn svg {
		width: 20px;
		height: 20px;
	}
	
	#wc-3d-switcher {
		bottom: 10px;
		max-width: 90%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}
	
	/* ✨ NEW: Hide redundant fullscreen buttons on mobile */
	#wc-3d-fullscreen,
	#wc-3d-exit-fullscreen {
		display: none;
	}
}