/*
 * XDesigner dla WooCommerce — karta produktu.
 *
 * Style neutralne: kroje, kolory i przyciski przejmujemy z motywu sklepu
 * (inherit, currentColor, klasa .button). Motyw może je nadpisać — klasy
 * zaczynają się od „xdw-”.
 */

.xdw {
	flex: 1 0 100%;
	width: 100%;
	margin: 0 0 1.25em;
	--xdw-line: rgba(0, 0, 0, .14);
	--xdw-muted: rgba(0, 0, 0, .6);
	--xdw-error-bg: #fdeeed;
	--xdw-error: #7d1a14;
}
.xdw__title { margin: 0 0 .6em; font-weight: 700; font-size: 1.1em; }

/* Edytor z kreatora */
.xdw-editor { position: relative; margin: 0 0 1em; }
.xdw-editor__frame { display: block; width: 100%; height: 560px; border: 0; background: transparent; }
.xdw-editor:not(.is-ready) .xdw-editor__frame { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.xdw-editor.is-ready .xdw-editor__loading { display: none; }
.xdw-editor__loading {
	padding: 2.2em 1em;
	border-radius: 8px;
	text-align: center;
	color: var(--xdw-muted);
	background: linear-gradient(90deg, rgba(0, 0, 0, .04) 25%, rgba(0, 0, 0, .08) 50%, rgba(0, 0, 0, .04) 75%) 0 0 / 200% 100%;
	animation: xdw-loading 1.4s linear infinite;
}
@keyframes xdw-loading { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .xdw-editor__loading { animation: none; } }

/* Zanim edytor się wczyta — bez migania prostego formularza; bez edytora — bez pustej ramki. */
html.xdw-pending .xdw [data-xdw-fallback] { display: none; }
html:not(.xdw-pending):not(.xdw-active) .xdw-editor { display: none; }
.xdw [data-xdw-fallback][hidden] { display: none; }

.xdw-error { margin: 0 0 1em; padding: .7em .9em; border-radius: 6px; background: var(--xdw-error-bg); color: var(--xdw-error); font-weight: 600; }
.xdw-error[hidden] { display: none; }

/* Podgląd na miejscu zdjęć produktu */
.xdw-stage { width: 100%; aspect-ratio: 4 / 5; margin: 0 0 .5em; }
.xdw-stage[hidden] { display: none; }
.xdw-stage__frame,
[data-xdw-preview-slot] > .xdw-stage__frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
.xdw-hidden { display: none !important; }
.xdw-stage__toggle {
	display: inline-flex;
	margin: 0 0 1.25em;
	padding: .35em 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

/* „Zaprojektuj sam” */
.xdw-own { display: grid; gap: .4em; margin: 0 0 1em; }
.xdw-own__button.button { display: inline-flex; align-items: center; justify-content: center; gap: .5em; width: 100%; text-align: center; }
.xdw-own__button svg { flex: none; }
.xdw-own small { color: var(--xdw-muted); font-size: .85em; text-align: center; }
/* Kreator nie odpowiada (sprawdzenie w product.js) */
.xdw-own__button.is-down { opacity: .55; cursor: not-allowed; }
.xdw-own small.xdw-own__down { color: #b32d2e; font-weight: 600; }

/* Prosty formularz */
.xdw-form { margin: 0 0 1em; padding: 1em 1.1em; border: 1px solid var(--xdw-line); border-radius: 8px; min-width: 0; }
.xdw-form__title { padding: 0 .4em; margin-left: -.4em; font-weight: 700; }
.xdw-field { margin: 0 0 .9em; }
.xdw-field:last-child { margin-bottom: 0; }
.xdw-field label,
.xdw-label { display: block; margin-bottom: .35em; font-weight: 600; }
.xdw-field input[type="text"] { width: 100%; box-sizing: border-box; }
.xdw-req { color: #b3261e; }
.xdw-opt { font-weight: 400; color: var(--xdw-muted); }
.xdw-hint { margin: .35em 0 0; font-size: .85em; color: var(--xdw-muted); }
.xdw-fonts { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: .5em; }
.xdw-fonts__option { position: relative; display: grid; justify-items: center; gap: .15em; padding: .6em .4em; border: 1px solid var(--xdw-line); border-radius: 6px; cursor: pointer; }
.xdw-fonts__option input { position: absolute; opacity: 0; }
.xdw-fonts__option:has(input:checked) { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.xdw-fonts__option:has(input:focus-visible) { outline: 2px solid currentColor; outline-offset: 2px; }
.xdw-fonts__sample { font-size: 1.5em; line-height: 1.1; }
.xdw-fonts__name { font-size: .8em; color: var(--xdw-muted); }

/* Projekt z pełnego kreatora */
.xdw-design { display: flex; gap: 1em; align-items: flex-start; padding: 1em; border: 1px solid var(--xdw-line); border-radius: 8px; }
.xdw-design img { width: 120px; height: auto; border-radius: 6px; background: rgba(0, 0, 0, .04); }
.xdw-design > div { display: grid; gap: .25em; }
.xdw-design small { color: var(--xdw-muted); }
.xdw-design a { font-weight: 600; font-size: .9em; }

/* Kilka projektów z kreatora (od 1.8.0): lista z podglądami na produkcie */
.xdw-design.xdw-design--multi { display: grid; grid-template-columns: minmax(0, 1fr); gap: .8em; align-items: start; }
.xdw-design__head { display: grid; gap: .15em; }
.xdw-design__head span { color: var(--xdw-muted); font-size: .9em; }
.xdw-design__list { display: grid; gap: .5em; margin: 0; padding: 0; list-style: none; }
.xdw-design__item { display: flex; align-items: center; gap: .8em; padding: .5em; border: 1px solid var(--xdw-line); border-radius: 8px; }
.xdw-design .xdw-design__item img { flex: none; width: 56px; height: 75px; object-fit: contain; background: #fff; border-radius: 4px; }
.xdw-design__info { flex: 1; min-width: 0; display: grid; gap: .1em; }
.xdw-design__info span { color: var(--xdw-muted); font-size: .88em; }
.xdw-design__qty { flex: none; font-weight: 700; white-space: nowrap; }
/* Ilość ustawił klient przy każdym projekcie w kreatorze — pole ilości sklepu tu nie działa. */
form.cart:has(.xdw-design--multi) .quantity { display: none !important; }

/* Podgląd projektu na miejscu zdjęć po powrocie z kreatora */
.xdw-stage--design { aspect-ratio: auto; display: grid; gap: .6em; }
.xdw-design ~ .xdw-stage--design,
.xdw-stage--design:has(+ .xdw-design) { max-width: 26rem; margin-inline: auto; }

/* Powiększenie podglądu (klik w miniaturę projektu) */
.xdw-zoomable { cursor: zoom-in; }
.xdw-zoom {
	position: fixed; inset: 0; z-index: 100000; display: grid; place-items: center; align-content: center; gap: .8em;
	padding: 3em 1em; background: rgba(10, 14, 22, .82); animation: xdw-fade .15s ease-out;
}
.xdw-zoom img { max-width: min(92vw, 820px); max-height: 80vh; width: auto; height: auto; border-radius: 8px; background: #fff; box-shadow: 0 20px 50px rgba(0, 0, 0, .4); }
.xdw-zoom p { margin: 0; color: #fff; font-weight: 600; text-align: center; }
.xdw-zoom__close {
	position: absolute; top: .6em; right: .6em; width: 2.4em; height: 2.4em; padding: 0; border: 0; border-radius: 50%;
	background: rgba(255, 255, 255, .16); color: #fff; font-size: 1.4em; line-height: 1; cursor: pointer;
}
.xdw-zoom__close:hover { background: rgba(255, 255, 255, .28); }
@keyframes xdw-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .xdw-zoom { animation: none; } }
.xdw-stage__image { display: block; width: 100%; height: auto; border-radius: 6px; }
.xdw-stage__thumbs { display: flex; flex-wrap: wrap; gap: .4em; }
.xdw-stage__thumb { padding: 2px; border: 1px solid var(--xdw-line, rgba(0, 0, 0, .14)); border-radius: 6px; background: #fff; cursor: pointer; }
.xdw-stage__thumb[aria-pressed="true"] { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.xdw-stage__thumb img { display: block; width: 52px; height: 70px; object-fit: contain; }

/* Przycisk w trakcie zapisu */
.single_add_to_cart_button.xdw-busy { opacity: .75; cursor: progress; }
