/* «Фото по эталону» — шорткод [aimp_reference]. */

.aimp-ref {
	--aimp-ref-accent: #6c5ce7;
	--aimp-ref-line: #e3e5ef;
	max-width: 900px;
}

.aimp-ref-step {
	margin-bottom: 2em;
}

.aimp-ref-step-title {
	display: flex;
	align-items: center;
	gap: .6em;
	margin: 0 0 .4em;
	font-size: 1.05em;
}

.aimp-ref-step-title span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.7em;
	height: 1.7em;
	border-radius: 50%;
	background: var(--aimp-ref-accent);
	color: #fff;
	font-size: .8em;
	flex: 0 0 auto;
}

.aimp-ref-hint {
	margin: 0 0 1em;
	color: #6b7080;
	font-size: .92em;
}

/* --- эталоны --- */

.aimp-ref-profiles {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.aimp-ref-profile,
.aimp-ref-add {
	position: relative;
	width: 130px;
	border: 2px solid var(--aimp-ref-line);
	border-radius: 10px;
	padding: 8px;
	cursor: pointer;
	background: #fff;
	display: flex;
	flex-direction: column;
	gap: 6px;
	transition: border-color .15s;
}

.aimp-ref-profile input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.aimp-ref-profile img {
	width: 100%;
	height: 90px;
	object-fit: cover;
	border-radius: 6px;
	display: block;
}

.aimp-ref-profile-title {
	font-size: .8em;
	line-height: 1.25;
	color: #3a3f51;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.aimp-ref-profile:has(input:checked) {
	border-color: var(--aimp-ref-accent);
}

.aimp-ref-profile-del {
	position: absolute;
	top: -8px;
	right: -8px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 1px solid var(--aimp-ref-line);
	background: #fff;
	color: #98304a;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
	opacity: 0;
	transition: opacity .15s;
}

.aimp-ref-profile:hover .aimp-ref-profile-del,
.aimp-ref-profile:focus-within .aimp-ref-profile-del {
	opacity: 1;
}

.aimp-ref-add {
	align-items: center;
	justify-content: center;
	border-style: dashed;
	min-height: 128px;
	text-align: center;
	font-size: .82em;
	color: #6b7080;
}

.aimp-ref-add-plus {
	font-size: 1.6em;
	line-height: 1;
	color: var(--aimp-ref-accent);
}

/* --- загрузка фото --- */

.aimp-ref-drop {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.4em;
	border: 2px dashed var(--aimp-ref-line);
	border-radius: 10px;
	cursor: pointer;
	color: #6b7080;
	font-size: .92em;
	transition: border-color .15s;
}

.aimp-ref-drop:hover,
.aimp-ref-drop.is-dragover {
	border-color: var(--aimp-ref-accent);
}

.aimp-ref-run {
	margin-top: 1em;
	padding: .7em 1.5em;
	border: 0;
	border-radius: 8px;
	background: var(--aimp-ref-accent);
	color: #fff;
	font-size: .95em;
	cursor: pointer;
}

.aimp-ref-run:disabled {
	opacity: .5;
	cursor: default;
}

/* --- статусы --- */

.aimp-ref-status {
	margin-top: .9em;
	padding: .7em .9em;
	border-radius: 8px;
	font-size: .9em;
	background: #f4f5fa;
	color: #3a3f51;
}

.aimp-ref-status.is-ok {
	background: #e9f7ee;
	color: #1a7f37;
}

.aimp-ref-status.is-error {
	background: #fdf0f0;
	color: #a02020;
}

/* --- результаты --- */

.aimp-ref-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 16px;
}

.aimp-ref-card {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	padding: 8px;
	border: 1px solid var(--aimp-ref-line);
	border-radius: 10px;
	background: #fff;
}

.aimp-ref-card img {
	width: 100%;
	height: auto;
	border-radius: 6px;
	display: block;
}

.aimp-ref-card-after {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	font-size: .82em;
	color: #6b7080;
	text-align: center;
}

.aimp-ref-card.is-pending .aimp-ref-card-after {
	background: #f4f5fa;
	border-radius: 6px;
	min-height: 80px;
}

.aimp-ref-card.is-failed .aimp-ref-card-after {
	color: #a02020;
}

.aimp-ref-download {
	font-size: .95em;
	color: var(--aimp-ref-accent);
}

@media (max-width: 600px) {
	.aimp-ref-profile,
	.aimp-ref-add {
		width: calc(50% - 6px);
	}
}

.aimp-ref-res {
	display: flex;
	align-items: center;
	gap: .6em;
	flex-wrap: wrap;
	margin-top: 1em;
	font-size: .92em;
}

.aimp-ref-res select {
	padding: .45em .6em;
	border: 1px solid var(--aimp-ref-line);
	border-radius: 8px;
	background: #fff;
}

.aimp-ref-res-total {
	color: var(--aimp-ref-accent);
	font-weight: 600;
}

.aimp-ref-files {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 12px;
}

.aimp-ref-file {
	position: relative;
	width: 110px;
	padding: 6px;
	border: 1px solid var(--aimp-ref-line);
	border-radius: 10px;
	background: #fff;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.aimp-ref-file img {
	width: 100%;
	height: 74px;
	object-fit: cover;
	border-radius: 6px;
	display: block;
}

.aimp-ref-file-name {
	font-size: .72em;
	line-height: 1.2;
	color: #3a3f51;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.aimp-ref-file-size {
	font-size: .7em;
	color: #8b8fa3;
}

.aimp-ref-file-del {
	position: absolute;
	top: -7px;
	right: -7px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 1px solid var(--aimp-ref-line);
	background: #fff;
	color: #98304a;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}

.aimp-ref-file-del:hover {
	background: #98304a;
	color: #fff;
}

/* --- подписи «До/После» и воздух вокруг результата --- */

.aimp-ref-results {
	margin-top: 2em;
	/* Отбивка снизу: под шорткодом идёт текст страницы, и без неё описание
	   липнет прямо к картинкам. */
	margin-bottom: 2.5em;
}

.aimp-ref-side {
	position: relative;
	display: flex;
	flex-direction: column;
}

.aimp-ref-badge {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 2;
	padding: .18em .6em;
	border-radius: 999px;
	font-size: .68em;
	font-weight: 600;
	letter-spacing: .02em;
	text-transform: uppercase;
	backdrop-filter: blur(4px);
}

.aimp-ref-badge.is-before {
	background: rgba(27, 30, 43, .62);
	color: #fff;
}

.aimp-ref-badge.is-after {
	background: var(--aimp-ref-accent);
	color: #fff;
}

.aimp-ref-card {
	align-items: start;
}

.aimp-ref-side .aimp-ref-card-after {
	flex: 1 1 auto;
}

/* --- пожелания и кнопки скачивания --- */

.aimp-ref-notes {
	margin-top: 1em;
}

.aimp-ref-notes label {
	display: block;
	margin-bottom: .35em;
	font-size: .92em;
	color: #3a3f51;
}

.aimp-ref-notes label span {
	color: #8b8fa3;
	font-weight: 400;
}

.aimp-ref-notes textarea {
	width: 100%;
	padding: .6em .8em;
	border: 1px solid var(--aimp-ref-line);
	border-radius: 8px;
	font: inherit;
	font-size: .92em;
	resize: vertical;
}

.aimp-ref-notes-hint {
	margin: .4em 0 0;
	font-size: .82em;
	color: #8b8fa3;
}

.aimp-ref-downloads {
	display: flex;
	gap: .8em;
	align-items: center;
	flex-wrap: wrap;
	justify-content: center;
}

/* --- крупный просмотр «до/после» --- */

.aimp-ref-card.is-zoomable img {
	cursor: zoom-in;
}

.aimp-ref-lb {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 24px;
	background: rgba(16, 18, 27, .93);
}

.aimp-ref-lb.is-open {
	display: flex;
}

.aimp-ref-lb-stage {
	--aimp-pos: 50%;
	position: relative;
	width: min(94vw, 1400px);
	height: min(78vh, 900px);
	touch-action: none;
	cursor: ew-resize;
	user-select: none;
	overflow: hidden;
	border-radius: 10px;
}

.aimp-ref-lb-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	pointer-events: none;
}

/* Результат показываем поверх оригинала и обрезаем по позиции шторки —
   так обе картинки совмещены в одном кадре, а не стоят рядом. */
.aimp-ref-lb-img.is-after {
	clip-path: inset(0 0 0 var(--aimp-pos));
}

.aimp-ref-lb-handle {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--aimp-pos);
	width: 2px;
	background: #fff;
	pointer-events: none;
	box-shadow: 0 0 12px rgba(0, 0, 0, .5);
}

.aimp-ref-lb-handle span {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 38px;
	height: 38px;
	margin: -19px 0 0 -19px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
}

.aimp-ref-lb-handle span::before,
.aimp-ref-lb-handle span::after {
	content: '';
	position: absolute;
	top: 50%;
	width: 0;
	height: 0;
	margin-top: -5px;
	border: 5px solid transparent;
}

.aimp-ref-lb-handle span::before {
	left: 6px;
	border-right-color: #6c5ce7;
}

.aimp-ref-lb-handle span::after {
	right: 6px;
	border-left-color: #6c5ce7;
}

.aimp-ref-lb-tag {
	position: absolute;
	top: 12px;
	padding: .2em .7em;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	color: #fff;
	pointer-events: none;
}

.aimp-ref-lb-tag.is-left {
	left: 12px;
	background: rgba(27, 30, 43, .72);
}

.aimp-ref-lb-tag.is-right {
	right: 12px;
	background: #6c5ce7;
}

.aimp-ref-lb-bar {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
	justify-content: center;
}

.aimp-ref-lb-bar button {
	padding: .5em 1.1em;
	border: 1px solid rgba(255, 255, 255, .25);
	border-radius: 8px;
	background: transparent;
	color: #fff;
	font-size: .9em;
	cursor: pointer;
}

.aimp-ref-lb-bar button:hover {
	background: rgba(255, 255, 255, .12);
}

.aimp-ref-lb-open {
	color: #b9b2ff;
	font-size: .9em;
	margin-left: 6px;
}

.aimp-ref-lb-close {
	position: absolute;
	top: 16px;
	right: 20px;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.aimp-ref-lb-close:hover {
	background: rgba(255, 255, 255, .22);
}

@media (max-width: 600px) {
	.aimp-ref-lb-stage {
		height: 62vh;
	}
}

/* --- доп. виды и режим обработки --- */

.aimp-ref-extras-box {
	margin-top: 1em;
}

.aimp-ref-extras-label {
	display: block;
	margin-bottom: .35em;
	font-size: .92em;
	color: #3a3f51;
}

.aimp-ref-extras-box select {
	width: 100%;
	max-width: 420px;
	padding: .45em .6em;
	border: 1px solid var(--aimp-ref-line);
	border-radius: 8px;
	background: #fff;
	font: inherit;
	font-size: .92em;
}

.aimp-ref-extras {
	margin-top: .8em;
	padding: .9em;
	border: 1px solid var(--aimp-ref-line);
	border-radius: 10px;
	background: #fbfbfe;
}

.aimp-ref-drop-sm {
	padding: .9em;
	font-size: .88em;
}

.aimp-ref-warn {
	margin: .8em 0 0;
	padding: .6em .8em;
	border-radius: 8px;
	background: #fff6e8;
	color: #8a5a00;
	font-size: .82em;
	line-height: 1.45;
}

/* Поле пожеланий ведёт себя как промпт на странице обычной генерации:
   растёт под текст до потолка, дальше — прокрутка внутри поля. */
.aimp-ref-notes textarea {
	min-height: 96px;
	max-height: 420px;
	overflow-y: auto;
	line-height: 1.5;
}

/* --- кисть «убрать лишнее» --- */

.aimp-ref-lb-canvas {
	position: absolute;
	inset: 0;
	z-index: 3;
	cursor: crosshair;
	touch-action: none;
}

/* В режиме правки шторка и подписи только мешают. */
.aimp-ref-lb.is-cleanup .aimp-ref-lb-handle,
.aimp-ref-lb.is-cleanup .aimp-ref-lb-tag {
	display: none;
}

.aimp-ref-lb.is-cleanup .aimp-ref-lb-stage {
	cursor: crosshair;
}

.aimp-ref-cleanup-bar {
	gap: 14px;
}

.aimp-ref-cleanup-hint {
	color: #fff;
	font-size: .9em;
	opacity: .85;
}

.aimp-ref-cleanup-bar label {
	display: flex;
	align-items: center;
	gap: 8px;
	color: #fff;
	font-size: .85em;
}

.aimp-ref-cleanup-bar input[type="range"] {
	width: 120px;
}

.aimp-ref-lb-bar button.is-primary {
	background: #6c5ce7;
	border-color: #6c5ce7;
}

.aimp-ref-lb-bar button.is-primary:hover {
	background: #5b4bd6;
}

.aimp-ref-lb-bar button:disabled {
	opacity: .55;
	cursor: default;
}

/* display:flex у панели перебивает штатное скрытие через атрибут hidden,
   поэтому выключаем её явно — иначе панель кисти видна всегда. */
.aimp-ref-lb-bar[hidden] {
	display: none !important;
}

/* Подсказка гостю: сервис доступен, но эталон не сохранится. */
.aimp-ref-guestnote {
	margin-bottom: 1em;
	padding: .7em .9em;
	border-radius: 8px;
	background: #f4f5fa;
	color: #3a3f51;
	font-size: .88em;
	line-height: 1.5;
}

.aimp-ref-guestnote a {
	color: var(--aimp-ref-accent);
}
