/**
 * IEM 3D Model Viewer - ortak frontend stilleri.
 */

.iem3d-viewer-wrapper {
	--iem3d-height: 480px;
	--iem3d-background: #f2f2f2;
	position: relative;
	width: 100%;
	max-width: 100%;
	height: var(--iem3d-height);
	border-radius: 8px;
	overflow: hidden;
	background: var(--iem3d-background);
	box-sizing: border-box;
	margin: 0 0 1.5em;
}

.iem3d-viewer-wrapper * {
	box-sizing: border-box;
}

.iem3d-viewer-inner {
	position: relative;
	width: 100%;
	height: 100%;
}

.iem3d-model-viewer,
.iem3d-splat-canvas {
	width: 100%;
	height: 100%;
	display: block;
	background-color: var(--iem3d-background);
	--poster-color: transparent;
}

/* Fullscreen durumu */
.iem3d-viewer-wrapper:fullscreen,
.iem3d-viewer-wrapper:-webkit-full-screen {
	--iem3d-height: 100vh;
	border-radius: 0;
}

.iem3d-viewer-wrapper:fullscreen .iem3d-viewer-inner,
.iem3d-viewer-wrapper:-webkit-full-screen .iem3d-viewer-inner {
	height: 100vh;
}

/* Toolbar */
.iem3d-toolbar {
	position: absolute;
	bottom: 12px;
	right: 12px;
	display: flex;
	gap: 6px;
	z-index: 20;
}

.iem3d-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	color: #23282d;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s ease;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.iem3d-btn:hover {
	background: #fff;
}

.iem3d-btn:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.iem3d-btn:active {
	transform: scale(0.94);
}

.iem3d-btn[aria-pressed="true"] {
	background: #2271b1;
	color: #fff;
}

.iem3d-btn .dashicons {
	width: 18px;
	height: 18px;
	font-size: 18px;
}

/* Loading overlay / spinner */
.iem3d-loading-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: rgba(255, 255, 255, 0.6);
	z-index: 10;
	pointer-events: none;
}

.iem3d-loading-overlay[hidden] {
	display: none;
}

.iem3d-spinner {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: 3px solid rgba(0, 0, 0, 0.15);
	border-top-color: #2271b1;
	animation: iem3d-spin 0.8s linear infinite;
}

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

.iem3d-progress-track {
	width: 60%;
	max-width: 240px;
	height: 4px;
	background: rgba(0, 0, 0, 0.1);
	border-radius: 2px;
	overflow: hidden;
}

.iem3d-progress-fill {
	height: 100%;
	background: #2271b1;
	width: 0%;
	transition: width 0.15s ease;
}

/* model-viewer'ın kendi progress bar slotu */
.iem3d-progress-bar {
	display: block;
	width: 60%;
	max-width: 240px;
	height: 4px;
	background: rgba(0, 0, 0, 0.1);
	border-radius: 2px;
	overflow: hidden;
	position: absolute;
	bottom: 20%;
	left: 50%;
	transform: translateX(-50%);
}

.iem3d-progress-bar-fill {
	height: 100%;
	width: 0%;
	background: #2271b1;
	transition: width 0.2s ease;
}

/* Poster overlay (PLY) */
.iem3d-poster-overlay {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 15;
}

.iem3d-poster-play-icon {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	position: relative;
}

.iem3d-poster-play-icon::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 55%;
	transform: translate(-50%, -50%);
	border-style: solid;
	border-width: 12px 0 12px 20px;
	border-color: transparent transparent transparent #23282d;
}

/* Hata kutuları */
.iem3d-error-box {
	padding: 16px;
	background: #fcf0f1;
	border-left: 4px solid #d63638;
	color: #451313;
	border-radius: 4px;
}

.iem3d-error-overlay,
.iem3d-webgl-unsupported,
.iem3d-renderer-unavailable {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 24px;
	background: rgba(255, 255, 255, 0.95);
	color: #451313;
	z-index: 25;
}

.iem3d-error-overlay[hidden],
.iem3d-webgl-unsupported[hidden] {
	display: none;
}

.iem3d-renderer-unavailable {
	position: static;
	background: #fcf0f1;
	color: #451313;
	flex-direction: column;
	gap: 4px;
	height: 100%;
}

/* Responsive */
@media (max-width: 600px) {
	.iem3d-viewer-wrapper {
		height: min(var(--iem3d-height), 60vh);
	}

	.iem3d-btn {
		width: 34px;
		height: 34px;
	}
}
