/**
 * Simple Image Popup — frontend.
 * Semua nilai boleh ubah melalui CSS variable yang dicetak pada elemen popup.
 */

.sip-popup {
	--sip-z: 99990;
	--sip-max: 600px;
	--sip-radius: 12px;
	--sip-close-size: 44px;
	--sip-close-fg: #fff;
	--sip-close-bg: rgba(17, 17, 17, 0.55);
	--sip-accent: #111;
	--sip-accent-fg: #fff;
	--sip-gap: 12px;

	position: fixed;
	inset: 0;
	z-index: var(--sip-z);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	box-sizing: border-box;
}

.sip-popup[hidden] {
	display: none;
}

.sip-popup * {
	box-sizing: border-box;
}

/* Overlay -------------------------------------------------------------- */

.sip-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	cursor: pointer;
}

/* Kotak ---------------------------------------------------------------- */

.sip-box {
	position: relative;
	width: 100%;
	max-width: var(--sip-max);
	max-height: calc(100vh - 40px);
	overflow: visible;
	text-align: center;
	line-height: 0;
}

.sip-action,
.sip-action--static {
	display: block;
	line-height: 0;
	border-radius: var(--sip-radius);
	overflow: hidden;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.sip-popup img.sip-img {
	display: block;
	width: 100%;
	height: auto;
	max-height: calc(100vh - 140px);
	object-fit: contain;
	border-radius: var(--sip-radius);
}

/* Posisi --------------------------------------------------------------- */

.sip-pos-bottom-right {
	align-items: flex-end;
	justify-content: flex-end;
}

.sip-pos-bottom-right .sip-box {
	max-width: min(var(--sip-max), 360px);
}

.sip-pos-bottom-bar {
	align-items: flex-end;
	justify-content: center;
	padding: 0;
}

.sip-pos-bottom-bar .sip-box {
	max-width: 100%;
}

.sip-pos-bottom-bar .sip-action,
.sip-pos-bottom-bar .sip-popup img.sip-img {
	border-radius: 0;
}

/* Butang tutup --------------------------------------------------------- */

.sip-close {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--sip-close-size);
	height: var(--sip-close-size);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--sip-close-bg);
	color: var(--sip-close-fg);
	cursor: pointer;
	line-height: 1;
	backdrop-filter: blur(2px);
	transition: transform 0.15s ease, background-color 0.15s ease, opacity 0.2s ease;
}

.sip-close:hover,
.sip-close:focus-visible {
	background: rgba(17, 17, 17, 0.8);
	transform: scale(1.06);
}

.sip-close:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

.sip-close[hidden] {
	display: none;
}

.sip-close-outside .sip-close {
	top: -18px;
	right: -18px;
	background: #fff;
	color: #111;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.sip-close-corner-image .sip-close {
	top: 0;
	right: 0;
	border-radius: 0 var(--sip-radius) 0 var(--sip-radius);
}

@media (max-width: 480px) {
	.sip-close-outside .sip-close {
		top: 8px;
		right: 8px;
		background: var(--sip-close-bg);
		color: var(--sip-close-fg);
	}
}

/* Baris butang salin --------------------------------------------------- */

.sip-actions {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--sip-gap);
	flex-wrap: wrap;
	margin-top: var(--sip-gap);
	line-height: 1.4;
}

.sip-actions--inline {
	display: inline-flex;
	margin-top: 0;
	vertical-align: middle;
}

.sip-code {
	display: inline-block;
	padding: 9px 14px;
	border: 1px dashed rgba(255, 255, 255, 0.7);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.08em;
	user-select: all;
}

.sip-actions--inline .sip-code {
	border-color: rgba(0, 0, 0, 0.25);
	background: rgba(0, 0, 0, 0.05);
	color: inherit;
}

.sip-copy {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	min-height: 44px;
	padding: 10px 18px;
	border: 0;
	border-radius: 8px;
	background: var(--sip-accent-fg);
	color: var(--sip-accent);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease;
}

.sip-copy:hover {
	transform: translateY(-1px);
}

.sip-copy:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

.sip-copy.is-done {
	background: #12894f;
	color: #fff;
}

.sip-copy[disabled] {
	opacity: 0.7;
	cursor: default;
}

.sip-copy-icon {
	flex: none;
}

/* Mesej langsung ------------------------------------------------------- */

.sip-live {
	margin: 10px 0 0;
	color: #fff;
	font-size: 14px;
	line-height: 1.4;
	min-height: 1em;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.sip-actions--inline .sip-live {
	color: inherit;
	text-shadow: none;
}

.sip-popup.is-busy .sip-action {
	opacity: 0.7;
	pointer-events: none;
}

/* Butang pencetus shortcode -------------------------------------------- */

.sip-trigger-btn {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 12px 22px;
	border: 0;
	border-radius: 8px;
	background: #111;
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
}

/* Utiliti -------------------------------------------------------------- */

.sip-sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

html.sip-scroll-lock {
	overflow: hidden;
}

/* Animasi -------------------------------------------------------------- */

.sip-popup .sip-overlay {
	animation: sip-fade 0.25s ease both;
}

.sip-anim-fade .sip-box {
	animation: sip-fade 0.28s ease both;
}

.sip-anim-zoom .sip-box {
	animation: sip-zoom 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.sip-anim-slide .sip-box {
	animation: sip-slide 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes sip-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes sip-zoom {
	from { opacity: 0; transform: scale(0.92); }
	to   { opacity: 1; transform: scale(1); }
}

@keyframes sip-slide {
	from { opacity: 0; transform: translateY(24px); }
	to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.sip-popup .sip-overlay,
	.sip-popup .sip-box {
		animation: none !important;
	}

	.sip-close,
	.sip-copy {
		transition: none !important;
	}
}
