/**
 * QR Generator ML — widget styles.
 *
 * Everything is scoped under .qrgml so nothing leaks into the theme.
 * Override any of the custom properties below in your theme's Additional
 * CSS to retheme the widget per site without touching this file:
 *
 *   .qrgml { --qrgml-accent: #0b6b52; --qrgml-radius: 2px; }
 */

.qrgml {
	--qrgml-bg:            #ffffff;
	--qrgml-surface:       #f6f7f8;
	--qrgml-border:        #d9dde1;
	--qrgml-border-strong: #b3bac1;
	--qrgml-text:          #16191c;
	--qrgml-muted:         #5c6670;
	--qrgml-accent:        #1f4f8f;
	--qrgml-accent-text:   #ffffff;
	--qrgml-danger:        #a02020;
	--qrgml-radius:        6px;
	--qrgml-gap:           1rem;

	display: grid;
	grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
	gap: calc(var(--qrgml-gap) * 1.5);
	align-items: start;

	padding: calc(var(--qrgml-gap) * 1.25);
	border: 1px solid var(--qrgml-border);
	border-radius: var(--qrgml-radius);
	background: var(--qrgml-bg);
	color: var(--qrgml-text);
	font-size: 1rem;
	line-height: 1.5;
}

/* ---------- Controls ---------- */

.qrgml__controls {
	display: flex;
	flex-direction: column;
	gap: var(--qrgml-gap);
	min-width: 0;
}

.qrgml__row {
	display: flex;
	flex-wrap: wrap;
	gap: var(--qrgml-gap);
}

.qrgml__field {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	/* 11rem basis, not 8rem: at 8rem the select boxes squeeze narrow enough
	   to clip longer option text ("Korekcja błędów" / "Fehlerkorrektur" are
	   the ones that expose it). Wrapping is cheaper than truncating. */
	flex: 1 1 11rem;
	min-width: 0;
}

.qrgml__field--wide {
	flex-basis: 100%;
}

/* Keeps the two colour pickers travelling as a pair. Without this, a long
   translated label (German and Polish are the worst offenders) wraps one
   picker onto its own row and leaves a hole in the layout. */
.qrgml__colors {
	display: flex;
	gap: var(--qrgml-gap);
	flex: 0 0 auto;
}

.qrgml__field--color {
	flex: 0 0 auto;
}

.qrgml__label {
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--qrgml-text);
	margin: 0;
}

.qrgml__textarea,
.qrgml__select {
	width: 100%;
	box-sizing: border-box;
	padding: 0.55rem 0.65rem;
	border: 1px solid var(--qrgml-border-strong);
	border-radius: var(--qrgml-radius);
	background: var(--qrgml-bg);
	color: var(--qrgml-text);
	font: inherit;
	font-size: 0.9375rem;
}

.qrgml__textarea {
	resize: vertical;
	min-height: 4.5rem;
	/* Long URLs shouldn't blow out the layout. */
	word-break: break-all;
}

.qrgml__textarea:focus-visible,
.qrgml__select:focus-visible,
.qrgml__color:focus-visible,
.qrgml__button:focus-visible {
	outline: 2px solid var(--qrgml-accent);
	outline-offset: 2px;
}

.qrgml__color {
	width: 3rem;
	height: 2.5rem;
	padding: 0.2rem;
	border: 1px solid var(--qrgml-border-strong);
	border-radius: var(--qrgml-radius);
	background: var(--qrgml-bg);
	cursor: pointer;
}

.qrgml__help {
	margin: 0;
	font-size: 0.8125rem;
	line-height: 1.45;
	color: var(--qrgml-muted);
}

.qrgml__help--ec {
	margin-top: -0.25rem;
}

/* ---------- Output ---------- */

.qrgml__output {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	min-width: 0;
}

.qrgml__preview {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1 / 1;
	padding: var(--qrgml-gap);
	box-sizing: border-box;
	border: 1px solid var(--qrgml-border);
	border-radius: var(--qrgml-radius);
	background: var(--qrgml-surface);
}

.qrgml__preview canvas {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	/* Keep the modules sharp when the canvas is scaled down for display. */
	image-rendering: pixelated;
}

.qrgml__empty {
	margin: 0;
	text-align: center;
	font-size: 0.875rem;
	color: var(--qrgml-muted);
}

.qrgml__empty[hidden] {
	display: none;
}

.qrgml__error {
	margin: 0;
	min-height: 0;
	font-size: 0.875rem;
	color: var(--qrgml-danger);
}

.qrgml__error:empty {
	display: none;
}

/* ---------- Actions ---------- */

.qrgml__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.qrgml__button {
	flex: 1 1 auto;
	padding: 0.6rem 0.9rem;
	border: 1px solid var(--qrgml-accent);
	border-radius: var(--qrgml-radius);
	background: var(--qrgml-accent);
	color: var(--qrgml-accent-text);
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

.qrgml__button--ghost {
	background: transparent;
	color: var(--qrgml-accent);
}

.qrgml__button:hover:not(:disabled) {
	opacity: 0.88;
}

.qrgml__button:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* ---------- Footer ---------- */

.qrgml__note {
	grid-column: 1 / -1;
	margin: 0;
	padding-top: 0.75rem;
	border-top: 1px solid var(--qrgml-border);
	font-size: 0.8125rem;
	color: var(--qrgml-muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
	.qrgml {
		grid-template-columns: minmax(0, 1fr);
	}

	.qrgml__field--color {
		flex: 1 1 5rem;
	}

	.qrgml__color {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.qrgml__button {
		transition: none;
	}
}
