/* ==========================================================================
   ESignature Creator — Styles
   ========================================================================== */

#esc-app {
	max-width: 960px;
	margin: 0 auto;
	padding: 40px 20px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
		Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	color: #1a1a2e;
	box-sizing: border-box;
}

#esc-app *,
#esc-app *::before,
#esc-app *::after {
	box-sizing: border-box;
}

/* ---------- View Switching ---------- */

.esc-view {
	display: none;
}

.esc-view--active {
	display: block;
}

/* ---------- VIEW 1: Entry Screen ---------- */

.esc-main-heading {
	text-align: center;
	font-size: 32px;
	font-weight: 800;
	color: #1a1a2e;
	margin: 0 0 8px;
}

.esc-main-subheading {
	text-align: center;
	font-size: 16px;
	color: #888;
	font-weight: 400;
	margin: 0 0 48px;
}

.esc-cards {
	display: flex;
	gap: 28px;
	justify-content: center;
}

.esc-card {
	flex: 1;
	max-width: 440px;
	border: 2px dashed #c0c0cc;
	border-radius: 16px;
	overflow: hidden;
	cursor: pointer;
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.esc-card:hover {
	border-color: #6c5ce7;
	box-shadow: 0 6px 24px rgba(108, 92, 231, 0.15);
}

.esc-card__top {
	background: #e8e8ed;
	padding: 48px 24px 40px;
	text-align: center;
}

.esc-card__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: #6c5ce7;
	margin-bottom: 20px;
}

.esc-card__title {
	font-size: 22px;
	font-weight: 700;
	color: #6c5ce7;
	margin: 0;
}

.esc-card__bottom {
	background: #fff;
	padding: 24px 28px;
}

.esc-card__bottom p {
	margin: 0;
	font-size: 14px;
	line-height: 1.7;
	color: #444;
}

/* ---------- Back Button ---------- */

.esc-back-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: none;
	border: none;
	color: #6c5ce7;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	padding: 4px 0;
	margin-bottom: 12px;
}

.esc-back-btn:hover {
	opacity: 0.8;
}

/* ---------- Shared Heading ---------- */

.esc-heading {
	text-align: center;
	font-size: 26px;
	font-weight: 700;
	color: #1a1a2e;
	margin: 0 0 24px;
}

/* ---------- VIEW 2: Type Signature ---------- */

.esc-type-input {
	display: block;
	width: 100%;
	padding: 14px 18px;
	font-size: 16px;
	border: 2px solid #c0c0cc;
	border-radius: 10px;
	outline: none;
	margin-bottom: 24px;
	color: #1a1a2e;
	background: #fff;
}

.esc-type-input:focus {
	border-color: #6c5ce7;
	box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.18);
}

.esc-type-layout {
	display: flex;
	gap: 28px;
}

.esc-type-preview-wrap {
	flex: 0 0 58%;
	background: #f5f5f7;
	border-radius: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 380px;
	overflow: hidden;
}

.esc-type-preview-wrap {
	position: relative;
}

#esc-type-canvas {
	display: block;
	width: 100%;
	height: 100%;
	min-height: 280px;
	border-radius: 16px;
}

.esc-type-controls {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 18px;
}

.esc-control-row {
	display: flex;
	gap: 16px;
}

.esc-control-row .esc-control-group {
	flex: 1;
}

.esc-control-group--full {
	width: 100%;
}

.esc-label {
	display: block;
	font-size: 14px;
	font-weight: 700;
	color: #1a1a2e;
	margin-bottom: 6px;
}

/* Font select */
.esc-font-select {
	width: 100%;
	padding: 10px 12px;
	border: 2px solid #d0d0d8;
	border-radius: 8px;
	font-size: 14px;
	background: #fff;
	color: #1a1a2e;
	outline: none;
	cursor: pointer;
}

.esc-font-select:focus {
	border-color: #6c5ce7;
}

/* Font size control */
.esc-font-size-control {
	display: flex;
	align-items: center;
	border: 2px solid #d0d0d8;
	border-radius: 8px;
	overflow: hidden;
	background: #fff;
}

.esc-size-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: none;
	background: #2d2d3a;
	border-radius: 50%;
	cursor: pointer;
	margin: 4px;
	flex-shrink: 0;
}

.esc-size-btn:hover {
	background: #1a1a2e;
}

.esc-font-size-display {
	flex: 1;
	text-align: center;
	font-size: 16px;
	font-weight: 600;
	color: #1a1a2e;
}

/* Color inputs */
.esc-color-input-wrap {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 12px;
	border: 2px solid #d0d0d8;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	position: relative;
}

.esc-color-swatch {
	display: inline-block;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #000;
	border: 2px solid #e0e0e0;
	flex-shrink: 0;
}

.esc-color-swatch--transparent {
	background: #fff;
	position: relative;
	overflow: hidden;
}

.esc-color-swatch--transparent::after {
	content: "";
	position: absolute;
	top: 50%;
	left: -2px;
	width: calc(100% + 4px);
	height: 2px;
	background: #e74c3c;
	transform: rotate(-45deg);
	transform-origin: center;
}

.esc-color-hex {
	font-size: 14px;
	color: #1a1a2e;
	font-weight: 500;
}

.esc-hidden-color-input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

/* Range sliders */
.esc-range {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 6px;
	border-radius: 3px;
	background: #d0d0d8;
	outline: none;
}

.esc-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #a29bfe;
	cursor: pointer;
	border: 3px solid #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.esc-range::-moz-range-thumb {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #a29bfe;
	cursor: pointer;
	border: 3px solid #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.esc-range-labels {
	display: flex;
	justify-content: space-between;
	font-size: 12px;
	color: #888;
	margin-top: 4px;
}

/* Save button */
.esc-save-wrap {
	display: flex;
	justify-content: flex-end;
	margin-top: auto;
}

.esc-save-btn {
	display: inline-block;
	padding: 12px 36px;
	background: #6c5ce7;
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 1px;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	text-transform: uppercase;
}

.esc-save-btn:hover {
	background: #5a4bd1;
}

.esc-btn-outline {
	display: inline-block;
	padding: 12px 28px;
	background: #fff;
	color: #6c5ce7;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 1px;
	border: 2px solid #6c5ce7;
	border-radius: 8px;
	cursor: pointer;
	text-transform: uppercase;
}

.esc-btn-outline:hover {
	background: #f5f3ff;
}

/* ---------- VIEW 3: Draw Signature ---------- */

.esc-draw-card {
	background: #fff;
	border: 2px solid #d0d0d8;
	border-radius: 16px;
	overflow: hidden;
	position: relative;
}

#esc-draw-canvas {
	display: block;
	width: 100%;
	height: 420px;
	cursor: crosshair;
	touch-action: none;
}

.esc-draw-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 20px;
	border-top: 1px solid #e0e0e0;
}

.esc-draw-color-wrap {
	display: flex;
	align-items: center;
	gap: 10px;
}

.esc-draw-color-label {
	font-size: 15px;
	font-weight: 600;
	color: #1a1a2e;
}

.esc-color-swatch--draw {
	width: 32px;
	height: 32px;
	cursor: pointer;
}

.esc-draw-actions {
	display: flex;
	gap: 12px;
}

/* Color picker popup */
.esc-color-picker-popup {
	display: none;
	position: absolute;
	background: #fff;
	border: 1px solid #d0d0d8;
	border-radius: 12px;
	padding: 16px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
	z-index: 100;
}

/* Position for draw view */
.esc-draw-card .esc-color-picker-popup {
	bottom: 70px;
	left: 20px;
}

/* Position for type view — popups inside .esc-color-input-wrap */
.esc-color-input-wrap .esc-color-picker-popup {
	bottom: calc(100% + 8px);
	left: 0;
}

.esc-color-picker-popup--active {
	display: block;
}

/* Compact variant for background picker */
.esc-color-picker-popup--compact {
	padding: 12px;
}

.esc-color-picker-grid--bg {
	grid-template-columns: repeat(4, 1fr) !important;
	gap: 10px !important;
}

.esc-color-picker-grid--bg .esc-cp-swatch {
	width: 40px;
	height: 40px;
}

.esc-color-picker-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 10px;
	margin-bottom: 12px;
}

.esc-color-picker-grid .esc-cp-swatch {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 2px solid transparent;
	cursor: pointer;
	transition: transform 0.15s ease;
}

.esc-color-picker-grid .esc-cp-swatch:hover {
	transform: scale(1.15);
}

.esc-color-picker-footer {
	display: flex;
	align-items: center;
	gap: 8px;
}

.esc-hex-input {
	flex: 1;
	padding: 6px 10px;
	border: 2px solid #1a1a2e;
	border-radius: 4px;
	font-size: 14px;
	font-family: monospace;
	outline: none;
}

.esc-color-ok-btn {
	padding: 6px 18px;
	background: #3498db;
	color: #fff;
	border: none;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.esc-color-ok-btn:hover {
	background: #2980b9;
}

/* ---------- VIEW 4: Upload Signature ---------- */

.esc-upload-card {
	max-width: 700px;
	margin: 0 auto;
}

.esc-upload-dropzone {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 320px;
	border: 2px dashed #c0c0cc;
	border-radius: 16px;
	background: #f9f9fb;
	cursor: pointer;
	transition: border-color 0.2s ease, background 0.2s ease;
}

.esc-upload-dropzone:hover,
.esc-upload-dropzone--dragover {
	border-color: var(--esc-accent, #6c5ce7);
	background: #f3f0ff;
}

.esc-upload-dropzone-content {
	text-align: center;
	padding: 40px 20px;
}

.esc-upload-icon {
	color: #b0b0b0;
	margin-bottom: 16px;
}

.esc-upload-dropzone:hover .esc-upload-icon,
.esc-upload-dropzone--dragover .esc-upload-icon {
	color: var(--esc-accent, #6c5ce7);
}

.esc-upload-text {
	font-size: 16px;
	font-weight: 600;
	color: #1a1a2e;
	margin: 0 0 8px;
}

.esc-upload-subtext {
	font-size: 14px;
	color: #888;
	margin: 0 0 16px;
}

.esc-upload-browse-btn {
	display: inline-block;
	padding: 10px 28px;
	background: var(--esc-accent, #6c5ce7);
	color: #fff;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.5px;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	text-transform: uppercase;
}

.esc-upload-browse-btn:hover {
	opacity: 0.9;
}

.esc-upload-formats {
	font-size: 12px;
	color: #aaa;
	margin: 12px 0 0;
}

.esc-upload-file-input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.esc-upload-preview-area {
	text-align: center;
}

.esc-upload-preview-wrap {
	background: #f5f5f7;
	border-radius: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 280px;
	padding: 24px;
	margin-bottom: 20px;
}

/* Checkerboard background to show transparency */
.esc-upload-preview-wrap--checker {
	background-image:
		linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
		linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
		linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
	background-size: 20px 20px;
	background-position: 0 0, 0 10px, 10px -10px, -10px 0;
	background-color: #fff;
}

#esc-upload-canvas {
	max-width: 100%;
	max-height: 400px;
	border-radius: 8px;
}

.esc-upload-controls {
	max-width: 400px;
	margin: 0 auto 20px;
}

.esc-upload-actions {
	display: flex;
	gap: 12px;
	justify-content: center;
}

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

@media (max-width: 768px) {
	#esc-app {
		padding: 24px 14px;
	}

	.esc-main-heading {
		font-size: 24px;
	}

	.esc-main-subheading {
		font-size: 14px;
		margin-bottom: 32px;
	}

	.esc-cards {
		flex-direction: column;
		align-items: stretch;
		gap: 18px;
	}

	.esc-card {
		max-width: 100%;
	}

	.esc-card__top {
		padding: 32px 16px 28px;
	}

	.esc-card__bottom {
		padding: 18px 20px;
	}

	.esc-heading {
		font-size: 20px;
		margin-bottom: 16px;
	}

	/* Type signature — stack preview above controls */
	.esc-type-layout {
		flex-direction: column;
		gap: 20px;
	}

	.esc-type-preview-wrap {
		flex: none;
		min-height: 220px;
	}

	#esc-type-canvas {
		min-height: 220px;
	}

	.esc-type-input {
		padding: 12px 14px;
		font-size: 15px;
		margin-bottom: 16px;
	}

	.esc-control-row {
		flex-direction: column;
		gap: 14px;
	}

	.esc-type-controls {
		gap: 14px;
	}

	/* Draw canvas */
	#esc-draw-canvas {
		height: 300px;
	}

	.esc-draw-footer {
		padding: 12px 14px;
		flex-wrap: wrap;
		gap: 12px;
	}

	.esc-draw-color-wrap {
		flex: 0 0 auto;
	}

	.esc-draw-actions {
		flex: 1;
		justify-content: flex-end;
	}

	/* Buttons — larger touch targets */
	.esc-save-btn {
		padding: 14px 28px;
		font-size: 14px;
	}

	.esc-btn-outline {
		padding: 14px 22px;
		font-size: 14px;
	}

	.esc-back-btn {
		font-size: 14px;
	}

	/* Color picker popups — full width on small screens */
	.esc-color-input-wrap .esc-color-picker-popup {
		left: auto;
		right: 0;
		min-width: 220px;
	}

	.esc-size-btn {
		width: 36px;
		height: 36px;
	}

	/* Upload view */
	.esc-upload-dropzone {
		min-height: 240px;
	}

	.esc-upload-preview-wrap {
		min-height: 200px;
		padding: 16px;
	}
}

@media (max-width: 480px) {
	.esc-main-heading {
		font-size: 20px;
	}

	.esc-card__icon {
		width: 52px;
		height: 52px;
	}

	.esc-card__title {
		font-size: 18px;
	}

	.esc-heading {
		font-size: 18px;
	}

	#esc-draw-canvas {
		height: 240px;
	}

	.esc-draw-footer {
		flex-direction: column;
		align-items: stretch;
	}

	.esc-draw-color-wrap {
		justify-content: center;
	}

	.esc-draw-actions {
		justify-content: center;
		gap: 10px;
	}

	.esc-save-btn {
		padding: 12px 20px;
		flex: 1;
		text-align: center;
	}

	.esc-btn-outline {
		padding: 12px 16px;
		flex: 1;
		text-align: center;
	}
}
