/* Typestor Interactive Image Editor — styles
 * Uses the app's CSS custom properties (var(--bg-*), var(--border), etc.)
 * defined in style.css.
 */

.ts-editor-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.72);
	z-index: 3000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	backdrop-filter: blur(2px);
}
.ts-editor-overlay.open {
	display: flex;
}

.ts-editor {
	background: var(--bg-primary);
	border: 1px solid var(--border);
	border-radius: var(--radius, 12px);
	box-shadow: var(--shadow-lg, 0 20px 60px rgba(0, 0, 0, 0.4));
	width: 100%;
	max-width: 1040px;
	max-height: 92vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.ts-editor-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}
.ts-editor-title {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin: 0;
	font-size: 1.15rem;
	font-weight: 600;
	color: var(--text-primary);
	min-width: 0;
}
.ts-editor-title span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ts-editor-body {
	display: grid;
	grid-template-columns: 1fr 320px;
	gap: 0;
	min-height: 0;
	flex: 1;
	overflow: hidden;
}

/* Stage / preview canvas */
.ts-editor-stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.25rem;
	min-height: 320px;
	background:
		repeating-conic-gradient(
				var(--bg-tertiary) 0% 25%,
				var(--bg-secondary) 0% 50%
			)
			50% / 24px 24px;
}
.ts-editor-stage canvas {
	max-width: 100%;
	max-height: 100%;
	border-radius: 4px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}
.ts-editor-dims {
	position: absolute;
	bottom: 0.6rem;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	font-size: 0.72rem;
	font-family: monospace;
	padding: 0.2rem 0.55rem;
	border-radius: 999px;
	pointer-events: none;
}

/* Controls panel */
.ts-editor-panel {
	border-left: 1px solid var(--border);
	background: var(--bg-secondary);
	padding: 1.1rem;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 1.1rem;
}

.ts-field {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}
.ts-field-sub {
	margin-top: 0.35rem;
}
.ts-label {
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-secondary);
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.ts-label-sm {
	font-size: 0.68rem;
	text-transform: none;
	letter-spacing: 0;
	color: var(--text-muted);
}
.ts-val {
	font-weight: 600;
	color: var(--text-primary);
	font-family: monospace;
}

/* Swatches */
.ts-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}
.ts-swatch {
	width: 28px;
	height: 28px;
	border-radius: 6px;
	border: 2px solid var(--border);
	cursor: pointer;
	padding: 0;
	transition:
		transform 0.12s,
		border-color 0.12s;
}
.ts-swatch:hover {
	transform: scale(1.08);
}
.ts-swatch.active {
	border-color: var(--accent);
	box-shadow: 0 0 0 2px var(--accent);
}
.ts-swatch-transparent {
	background:
		linear-gradient(45deg, #ccc 25%, transparent 25%),
		linear-gradient(-45deg, #ccc 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #ccc 75%),
		linear-gradient(-45deg, transparent 75%, #ccc 75%);
	background-size: 10px 10px;
	background-position:
		0 0,
		0 5px,
		5px -5px,
		-5px 0px;
	background-color: #fff;
}

.ts-bg-custom {
	display: flex;
	gap: 0.4rem;
	align-items: center;
}
.ts-bg-custom input[type="color"] {
	width: 36px;
	height: 36px;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: none;
	cursor: pointer;
	flex-shrink: 0;
}
.ts-hex {
	flex: 1;
	min-width: 0;
	font-family: monospace;
}

/* Segmented controls */
.ts-seg {
	display: flex;
	border: 1px solid var(--border);
	border-radius: 8px;
	overflow: hidden;
}
.ts-seg.ts-seg-wrap {
	flex-wrap: wrap;
	border: none;
	gap: 0.4rem;
}
.ts-seg button {
	flex: 1;
	padding: 0.5rem 0.4rem;
	background: var(--bg-primary);
	color: var(--text-secondary);
	border: none;
	border-right: 1px solid var(--border);
	cursor: pointer;
	font-size: 0.8rem;
	font-weight: 500;
	transition: all 0.15s;
	white-space: nowrap;
}
.ts-seg.ts-seg-wrap button {
	flex: 0 0 auto;
	border: 1px solid var(--border);
	border-radius: 7px;
}
.ts-seg button:last-child {
	border-right: none;
}
.ts-seg button:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
}
.ts-seg button.active {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
}

.ts-size-custom {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.ts-size-custom .form-input {
	flex: 1;
	min-width: 0;
}
.ts-x {
	color: var(--text-muted);
	font-weight: 600;
}

/* Range sliders */
.ts-range {
	width: 100%;
	accent-color: var(--accent);
	cursor: pointer;
}

/* Footer */
.ts-editor-foot {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.9rem 1.25rem;
	border-top: 1px solid var(--border);
	flex-shrink: 0;
}
.ts-foot-spacer {
	flex: 1;
}

.ts-editor-toast {
	position: fixed;
	bottom: 2rem;
	left: 50%;
	transform: translateX(-50%);
	background: var(--bg-secondary);
	color: var(--text-primary);
	border: 1px solid var(--border);
	box-shadow: var(--shadow-lg, 0 10px 30px rgba(0, 0, 0, 0.3));
	padding: 0.8rem 1.2rem;
	border-radius: 10px;
	z-index: 4000;
	opacity: 0;
	transition: opacity 0.3s;
	font-size: 0.9rem;
}

/* -------------------------------------------------- responsive: stacked UI */
@media (max-width: 820px) {
	.ts-editor {
		max-height: 96vh;
	}
	.ts-editor-body {
		grid-template-columns: 1fr;
		overflow-y: auto;
	}
	.ts-editor-stage {
		min-height: 240px;
		max-height: 42vh;
		position: sticky;
		top: 0;
		z-index: 1;
	}
	.ts-editor-panel {
		border-left: none;
		border-top: 1px solid var(--border);
	}
}

@media (max-width: 480px) {
	.ts-editor-overlay {
		padding: 0;
	}
	.ts-editor {
		max-width: 100%;
		max-height: 100vh;
		height: 100vh;
		border-radius: 0;
		border: none;
	}
	.ts-editor-head,
	.ts-editor-foot {
		padding: 0.85rem 1rem;
	}
	.ts-editor-panel {
		padding: 1rem;
	}
	.ts-editor-foot .btn {
		min-height: 44px;
	}
	/* Compact the footer: hide labels on the smallest screens is optional;
	   keep them but allow wrap */
	.ts-editor-foot {
		flex-wrap: wrap;
	}
	.ts-foot-spacer {
		display: none;
	}
	.ts-editor-foot .btn {
		flex: 1;
		justify-content: center;
	}
	.ts-seg button {
		min-height: 40px;
	}
}
