/* ── Contenedor principal ────────────────────────────────────── */
.img-placeholder {
	position: relative;
	overflow: hidden;
	max-width: 100% !important;
	background-color: #f5f5f5;
	border: 2px dashed #ccc;
	border-radius: 8px;
	cursor: pointer;
	box-sizing: border-box;
	transition: border-color 0.2s, background-color 0.2s;
	z-index: 2500;
}

.img-placeholder.img-ph--drag-over {
	border-color: #6c757d;
	background-color: #e9ecef;
}

.img-placeholder.img-ph--has-image {
	cursor: default;
}

/* ── Hint (estado vacío) ─────────────────────────────────────── */
.img-placeholder .img-ph-hint {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	pointer-events: none;
	color: #999;
}

.img-placeholder .img-ph-hint svg {
	width: 60px;
	height: 60px;
	margin-bottom: 15px;
	color: #999;
}

.img-placeholder .img-ph-hint p {
	font-size: 14px;
	margin: 0;
	text-align: center;
}

/* ── Image wrapper (draggable + resizable) ───────────────────── */
.img-placeholder .img-ph-wrapper {
	position: absolute;
	display: none;
	cursor: move;
	touch-action: none;
	outline: 2px solid rgba(255, 255, 255, 0.85);
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 2px 12px rgba(0, 0, 0, 0.25);
	/* Sin transform aquí: jQuery UI draggable necesita un wrapper sin transform */
}

.img-placeholder .img-ph-inner {
	position: absolute;
	inset: 0;
	transform-origin: center center;
	overflow: hidden;
	border-radius: 6px;
	touch-action: none;
}

.img-placeholder .img-ph-wrapper img {
	width: 100%;
	height: 100%;
	object-fit: fill;
	display: block;
	pointer-events: none;
	user-select: none;
	-webkit-user-drag: none;
}

.img-placeholder .img-ph-wrapper .ui-resizable-se {
	display: none;
}

.img-ph-resize-handle {
	position: absolute;
	z-index: 9999;
	display: none;
	touch-action: none;
	background: rgba(0, 0, 0, 0.45);
	border-radius: 4px;
	box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
}

.img-ph-resize-handle--t,
.img-ph-resize-handle--b {
	width: 40px;
	height: 8px;
	cursor: ns-resize;
	border-left: 3px solid #fff;
	border-right: 3px solid #fff;
}

.img-ph-resize-handle--l,
.img-ph-resize-handle--r {
	width: 8px;
	height: 40px;
	cursor: ew-resize;
	border-top: 3px solid #fff;
	border-bottom: 3px solid #fff;
}

.img-ph-resize-handle--tl,
.img-ph-resize-handle--tr,
.img-ph-resize-handle--bl,
.img-ph-resize-handle--br {
	width: 14px;
	height: 14px;
	border: 3px solid #fff;
}

.img-ph-resize-handle--tl {
	cursor: nw-resize;
}

.img-ph-resize-handle--tr {
	cursor: ne-resize;
}

.img-ph-resize-handle--bl {
	cursor: sw-resize;
}

.img-ph-resize-handle--br {
	cursor: se-resize;
}

/* ── Zoom badge ──────────────────────────────────────────────── */
/* ── Botones flotantes ───────────────────────────────────────── */
.img-placeholder .img-ph-actions {
	position: absolute;
	top: 50%;
	right: 12px;
	transform: translateY(-50%);
	display: none;
	flex-direction: column;
	gap: 8px;
	z-index: 20;
}

.img-placeholder.img-ph--has-image .img-ph-actions {
	display: flex;
}

.img-placeholder .img-ph-btn {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.2s;
	color: #fff;
}

.img-placeholder .img-ph-btn svg {
	width: 16px;
	height: 16px;
	stroke: currentColor;
	flex-shrink: 0;
}

.img-placeholder .img-ph-btn-save {
	background-color: #28a745;
}

.img-placeholder .img-ph-btn-save:hover {
	background-color: #218838;
	transform: scale(1.1);
}

.img-placeholder .img-ph-btn-reset {
	background-color: #ffc107;
	color: #333;
}

.img-placeholder .img-ph-btn-reset:hover {
	background-color: #e0a800;
	transform: scale(1.1);
}

.img-placeholder .img-ph-btn-cancel {
	background-color: #dc3545;
}

.img-placeholder .img-ph-btn-cancel:hover {
	background-color: #c82333;
	transform: scale(1.1);
}

.img-placeholder .img-ph-btn-crop {
	background-color: #0d6efd;
}

.img-placeholder .img-ph-btn-crop:hover {
	background-color: #0b5ed7;
	transform: scale(1.1);
}

.img-placeholder .img-ph-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

/* ─── Controles de zoom ─────────────────────────────────────────────────── */
.img-placeholder .img-ph-zoom-controls {
	position: absolute;
	top: 10px;
	left: 10px;
	display: none;
	gap: 6px;
	z-index: 20;
}

.img-placeholder.img-ph--has-image .img-ph-zoom-controls {
	display: flex;
}

.img-placeholder .img-ph-zoom-btn {
	width: 32px;
	height: 32px;
	border-radius: 6px;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.2s;
	color: #fff;
	background-color: rgba(0, 0, 0, 0.6);
}

.img-placeholder .img-ph-zoom-btn svg {
	width: 14px;
	height: 14px;
	stroke: currentColor;
	flex-shrink: 0;
}

.img-placeholder .img-ph-zoom-btn:hover {
	background-color: rgba(0, 0, 0, 0.8);
	transform: scale(1.1);
}

.img-placeholder .img-ph-zoom-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

/* ─── Controles de flip (arriba derecha) ────────────────────────────────── */
.img-placeholder .img-ph-flip-controls {
	position: absolute;
	top: 10px;
	right: 10px;
	display: none;
	gap: 6px;
	z-index: 20;
}

.img-placeholder.img-ph--has-image .img-ph-flip-controls {
	display: flex;
}

/* ─── Overlay de recorte ─────────────────────────────────────────────────── */
.img-placeholder .img-ph-crop-overlay {
	position: absolute;
	inset: 0;
	z-index: 30;
	background: rgba(0, 0, 0, 0.45);
}

.img-placeholder .img-ph-crop-box {
	position: absolute;
	border: 2px solid #fff;
	box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
	cursor: move;
	box-sizing: border-box;
}

.img-placeholder .img-ph-crop-handle {
	position: absolute;
	width: 12px;
	height: 12px;
	background: #fff;
	border: 2px solid #333;
	border-radius: 2px;
}

.img-placeholder .img-ph-crop-handle--tl {
	top: -6px;
	left: -6px;
	cursor: nw-resize;
}

.img-placeholder .img-ph-crop-handle--tr {
	top: -6px;
	right: -6px;
	cursor: ne-resize;
}

.img-placeholder .img-ph-crop-handle--bl {
	bottom: -6px;
	left: -6px;
	cursor: sw-resize;
}

.img-placeholder .img-ph-crop-handle--br {
	bottom: -6px;
	right: -6px;
	cursor: se-resize;
}

.img-placeholder .img-ph-crop-box .ui-resizable-handle {
	z-index: 32;
	bottom: -6px !important;
	right: -6px !important;
}

.img-placeholder .img-ph-crop-actions {
	position: absolute;
	bottom: 12px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 8px;
	z-index: 31;
}

.img-placeholder .img-ph-btn-crop-apply {
	background-color: #22c55e;
}

.img-placeholder .img-ph-btn-crop-apply:hover {
	background-color: #16a34a;
}

/* ─── Responsive mobile ─────────────────────────────────────────────────── */
@media (max-width: 576px) {
	.img-placeholder .img-ph-actions {
		right: 6px;
		gap: 4px;
	}

	.img-placeholder .img-ph-btn {
		width: 28px;
		height: 28px;
	}

	.img-placeholder .img-ph-btn svg {
		width: 13px;
		height: 13px;
	}

	.img-placeholder .img-ph-zoom-controls {
		top: 6px;
		left: 6px;
		gap: 4px;
	}

	.img-placeholder .img-ph-zoom-btn {
		width: 26px;
		height: 26px;
	}

	.img-placeholder .img-ph-zoom-btn svg {
		width: 12px;
		height: 12px;
	}

	.img-placeholder .img-ph-flip-controls {
		display: none !important;
	}
}