/* ==========================================================================
   E2Z Image Compressor — mobile-first stylesheet (v2.0.0).

   Base rules ~360px phones ke liye; min-width queries tablet (768px) aur
   desktop (1024px+) par progressively enhance karti hain. Sab kuch
   .e2zimg-wrap ke andar scoped hai aur e2zimg- prefix use karta hai, taaki
   theme CSS se collide na ho.

   KATEN / ELEMENTOR COMPATIBILITY
   Katen (aur zyadatar magazine themes) global `button`, `input`, `select`,
   `details` par apni styling lagati hain — uppercase text, apna border-radius,
   full-width buttons, custom focus rings. Isliye neeche ek scoped reset block
   hai jo sirf is tool ke andar apply hota hai; site ke baaki buttons chhue
   bina nahi jaate.
   ========================================================================== */

.e2zimg-wrap {
	--e2zimg-bg: #f6f7fb;
	--e2zimg-panel: #ffffff;
	--e2zimg-text: #1c2128;
	--e2zimg-muted: #6b7280;
	--e2zimg-border: #e3e6ec;
	--e2zimg-accent: #2563eb;
	--e2zimg-accent-dark: #1d4ed8;
	--e2zimg-success: #16a34a;
	--e2zimg-warn: #b45309;
	--e2zimg-warn-bg: #fef3c7;
	--e2zimg-checker: #00000010;
	--e2zimg-shadow: 0 2px 10px rgba(20, 20, 40, 0.06);

	box-sizing: border-box;
	max-width: 100%;
	width: 100%;
	font-family: inherit;
	font-size: 15px;
	color: var(--e2zimg-text);
	background: var(--e2zimg-bg);
	border: 1px solid var(--e2zimg-border);
	border-radius: 14px;
	padding: 14px;
	margin: 20px 0;
	line-height: 1.5;
	text-align: left;
	contain: layout style;
}

/* Dark mode: JS theme ka actual background colour padh kar decide karta hai
   (Katen ho ya koi bhi theme/plugin), aur agar koi signal na mile to OS-level
   preference follow karta hai. Tool me apna alag toggle nahi hai — ye hamesha
   page ke mode ko mirror karta hai. */
.e2zimg-wrap.e2zimg-dark {
	--e2zimg-bg: #0f1420;
	--e2zimg-panel: #161d2b;
	--e2zimg-text: #e8ebf2;
	--e2zimg-muted: #9aa4b5;
	--e2zimg-border: #273047;
	--e2zimg-warn-bg: #3a2f10;
	--e2zimg-checker: #ffffff12;
	--e2zimg-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
	.e2zimg-wrap:not(.e2zimg-light-forced):not(.e2zimg-theme-detected) {
		--e2zimg-bg: #0f1420;
		--e2zimg-panel: #161d2b;
		--e2zimg-text: #e8ebf2;
		--e2zimg-muted: #9aa4b5;
		--e2zimg-border: #273047;
		--e2zimg-warn-bg: #3a2f10;
		--e2zimg-checker: #ffffff12;
	}
}

.e2zimg-wrap * { box-sizing: border-box; }

/* ---------------- scoped theme reset (Katen/Elementor safe) ---------------- */

.e2zimg-wrap button,
.e2zimg-wrap input,
.e2zimg-wrap select,
.e2zimg-wrap textarea {
	font-family: inherit;
	text-transform: none;
	letter-spacing: normal;
	line-height: 1.25;
	box-shadow: none;
	margin: 0;
	max-width: 100%;
	width: auto;
	float: none;
	text-shadow: none;
}

.e2zimg-wrap button {
	-webkit-appearance: none;
	appearance: none;
	text-decoration: none;
	outline-offset: 2px;
}

.e2zimg-wrap button::after,
.e2zimg-wrap button::before { content: none; }

.e2zimg-wrap :focus-visible {
	outline: 2px solid var(--e2zimg-accent);
	outline-offset: 2px;
}

.e2zimg-wrap h3,
.e2zimg-wrap h4 { font-family: inherit; }

.e2zimg-wrap p { margin: 0 0 8px; }
.e2zimg-wrap ol,
.e2zimg-wrap ul { list-style-position: outside; }

/* ---------------- header bits ---------------- */

.e2zimg-title { margin: 0 0 8px; font-size: 20px; line-height: 1.3; }
.e2zimg-intro { font-size: 14px; margin: 0 0 10px; }

.e2zimg-howto { margin: 0 0 12px; font-size: 13px; }
.e2zimg-howto summary { cursor: pointer; font-weight: 700; padding: 8px; min-height: 44px; display: flex; align-items: center; list-style: revert; }
.e2zimg-howto ol { margin: 6px 0 0; padding-left: 20px; }
.e2zimg-howto li { margin-bottom: 6px; }

.e2zimg-badge {
	display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
	color: var(--e2zimg-success); background: rgba(22, 163, 74, 0.1);
	border: 1px solid rgba(22, 163, 74, 0.25); padding: 6px 10px; border-radius: 999px;
	margin-bottom: 12px;
}

/* ---------------- upload ---------------- */

.e2zimg-drop {
	border: 2px dashed var(--e2zimg-border); border-radius: 12px; background: var(--e2zimg-panel);
	padding: 22px 14px; text-align: center; cursor: pointer; transition: 0.15s; margin-bottom: 14px;
	min-height: 44px;
}
.e2zimg-drop.e2zimg-drag { border-color: var(--e2zimg-accent); background: rgba(37, 99, 235, 0.06); }
.e2zimg-drop p { margin: 6px 0 0; color: var(--e2zimg-muted); font-size: 13px; }
.e2zimg-drop strong { font-size: 15px; }
.e2zimg-file-input { display: none; }

/* ---------------- thumbnail rail ---------------- */

.e2zimg-workspace { display: block; }
.e2zimg-rail {
	display: flex; flex-direction: row; gap: 8px; overflow-x: auto;
	padding-bottom: 4px; margin-bottom: 12px; -webkit-overflow-scrolling: touch;
}
.e2zimg-thumb {
	flex: 0 0 auto; width: 64px; height: 64px; border-radius: 9px; overflow: hidden; position: relative;
	border: 2px solid transparent; background: var(--e2zimg-panel); cursor: grab; min-width: 44px; min-height: 44px;
}
.e2zimg-thumb.e2zimg-active { border-color: var(--e2zimg-accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25); }
.e2zimg-thumb.e2zimg-dragover { outline: 2px dashed var(--e2zimg-accent); }
.e2zimg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.e2zimg-thumb .e2zimg-x {
	position: absolute; top: 2px; right: 2px; background: rgba(0, 0, 0, 0.6); color: #fff; border: none;
	border-radius: 50%; width: 20px; height: 20px; min-height: 0; font-size: 12px; line-height: 1; cursor: pointer; padding: 0;
	display: flex; align-items: center; justify-content: center;
}
.e2zimg-thumb .e2zimg-pct {
	position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, 0.55);
	color: #fff; font-size: 9px; text-align: center; padding: 1px 0;
}

/* ---------------- panels ---------------- */

.e2zimg-main { display: block; }
.e2zimg-panel {
	background: var(--e2zimg-panel); border: 1px solid var(--e2zimg-border); border-radius: 12px;
	padding: 12px; box-shadow: var(--e2zimg-shadow); margin-bottom: 14px;
}
.e2zimg-panel h4 {
	margin: 14px 0 10px; font-size: 13px; text-transform: uppercase;
	letter-spacing: 0.04em; color: var(--e2zimg-muted);
}
.e2zimg-panel h4:first-child { margin-top: 0; }
.e2zimg-panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.e2zimg-view-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.e2zimg-vtab {
	cursor: pointer; border: 1px solid var(--e2zimg-border); background: var(--e2zimg-bg);
	color: var(--e2zimg-text); font-size: 11px; font-weight: 700; padding: 8px 10px;
	border-radius: 7px; min-height: 44px; display: flex; align-items: center;
}
.e2zimg-vtab.e2zimg-active { background: var(--e2zimg-accent); border-color: var(--e2zimg-accent); color: #fff; }

/* ---------------- preview ---------------- */

.e2zimg-preview-box {
	position: relative; width: 100%; min-height: 220px;
	background-image:
		linear-gradient(45deg, var(--e2zimg-checker) 25%, transparent 25%),
		linear-gradient(-45deg, var(--e2zimg-checker) 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, var(--e2zimg-checker) 75%),
		linear-gradient(-45deg, transparent 75%, var(--e2zimg-checker) 75%);
	background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
	border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.e2zimg-preview-box canvas {
	max-width: 100%; max-height: 420px; display: block; touch-action: none;
	width: auto; height: auto;
}
.e2zimg-dims { font-size: 11px; color: var(--e2zimg-muted); margin-top: 6px; word-break: break-word; }

/* ---------------- before/after ---------------- */

.e2zimg-zoom-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.e2zimg-zbtn {
	cursor: pointer; border: 1px solid var(--e2zimg-border); background: var(--e2zimg-bg);
	color: var(--e2zimg-text); font-size: 16px; font-weight: 700; width: 44px; height: 44px; border-radius: 7px;
}
.e2zimg-zoom-label { font-size: 11px; color: var(--e2zimg-muted); min-width: 40px; text-align: center; }

.e2zimg-compare-outer {
	position: relative; width: 100%; overflow: hidden; border-radius: 10px;
	background-image:
		linear-gradient(45deg, var(--e2zimg-checker) 25%, transparent 25%),
		linear-gradient(-45deg, var(--e2zimg-checker) 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, var(--e2zimg-checker) 75%),
		linear-gradient(-45deg, transparent 75%, var(--e2zimg-checker) 75%);
	background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
	touch-action: none; cursor: ew-resize;
}
.e2zimg-compare-inner { position: relative; width: 100%; height: 100%; transform-origin: center center; }
.e2zimg-compare-inner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; max-width: none; }
.e2zimg-after { clip-path: inset(0 0 0 50%); }

.e2zimg-handle {
	position: absolute; top: 0; bottom: 0; left: 50%; width: 44px; margin-left: -22px;
	cursor: ew-resize; z-index: 3; background: transparent;
}
.e2zimg-handle::before {
	content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 3px;
	background: var(--e2zimg-accent); transform: translateX(-50%);
}
.e2zimg-handle::after {
	content: "⟷"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
	background: #fff; color: #111; width: 34px; height: 34px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center; font-size: 14px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Side-by-side mode: dono images ko aadha-aadha dikhata hai. */
.e2zimg-compare-outer.e2zimg-side-by-side { cursor: default; }
.e2zimg-compare-outer.e2zimg-side-by-side .e2zimg-compare-inner { display: flex; }
.e2zimg-compare-outer.e2zimg-side-by-side .e2zimg-compare-inner img {
	position: relative; inset: auto; width: 50%; height: 100%; flex: 0 0 50%;
}
.e2zimg-compare-outer.e2zimg-side-by-side .e2zimg-after { clip-path: none; }

.e2zimg-compare-outer .e2zimg-tag {
	position: absolute; top: 6px; font-size: 10px; background: rgba(0, 0, 0, 0.6);
	color: #fff; padding: 2px 6px; border-radius: 4px; z-index: 4;
}
.e2zimg-tag.e2zimg-left { left: 6px; }
.e2zimg-tag.e2zimg-right { right: 6px; }

.e2zimg-loupe {
	position: absolute; width: 110px; height: 110px; border-radius: 50%; border: 3px solid #fff;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); pointer-events: none; z-index: 5;
	display: none; background-repeat: no-repeat;
}

/* ---------------- banners, tabs, controls ---------------- */

.e2zimg-banner {
	display: flex; align-items: center; justify-content: space-between; gap: 10px;
	background: var(--e2zimg-warn-bg); color: var(--e2zimg-warn);
	border: 1px solid rgba(180, 83, 9, 0.3); border-radius: 8px; padding: 8px 10px;
	font-size: 12px; margin-bottom: 10px; flex-wrap: wrap;
}

.e2zimg-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.e2zimg-tab {
	cursor: pointer; border: 1px solid var(--e2zimg-border); background: var(--e2zimg-bg);
	color: var(--e2zimg-text); font-size: 12px; font-weight: 600; padding: 10px 12px;
	border-radius: 8px; min-height: 44px; display: flex; align-items: center;
}
.e2zimg-tab.e2zimg-active { background: var(--e2zimg-accent); border-color: var(--e2zimg-accent); color: #fff; }

.e2zimg-adv-toggle {
	display: inline-flex; align-items: center; cursor: pointer; border: 1px solid var(--e2zimg-border);
	background: var(--e2zimg-bg); color: var(--e2zimg-text); font-size: 12px; font-weight: 600;
	padding: 10px 12px; border-radius: 8px; min-height: 44px;
}
.e2zimg-advanced-block,
.e2zimg-responsive-block,
.e2zimg-extra-block { margin-top: 14px; border-top: 1px solid var(--e2zimg-border); padding-top: 10px; }

.e2zimg-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.e2zimg-row label { font-size: 12px; color: var(--e2zimg-muted); min-width: 78px; display: inline-flex; align-items: center; gap: 6px; }

.e2zimg-wrap input[type="range"] {
	flex: 1 1 120px; min-width: 100px; accent-color: var(--e2zimg-accent);
	height: 30px; padding: 0; background: transparent; border: 0;
}
.e2zimg-wrap input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--e2zimg-accent); flex: 0 0 auto; }
.e2zimg-wrap input[type="color"] { width: 46px; height: 40px; padding: 2px; border: 1px solid var(--e2zimg-border); border-radius: 6px; background: var(--e2zimg-bg); cursor: pointer; }
.e2zimg-wrap input[type="file"] { font-size: 12px; color: var(--e2zimg-muted); max-width: 100%; }

.e2zimg-wrap input[type="number"],
.e2zimg-wrap input[type="text"],
.e2zimg-wrap select,
.e2zimg-wrap textarea {
	background: var(--e2zimg-bg); color: var(--e2zimg-text); border: 1px solid var(--e2zimg-border);
	border-radius: 6px; padding: 8px; font-size: 13px; min-height: 40px;
}
.e2zimg-wrap input[type="number"] { width: 92px; }
.e2zimg-wrap input[type="text"] { flex: 1 1 160px; min-width: 120px; }
.e2zimg-hint { font-size: 12px; color: var(--e2zimg-muted); }

.e2zimg-btn {
	cursor: pointer; border: 1px solid var(--e2zimg-border); background: var(--e2zimg-bg);
	color: var(--e2zimg-text); font-size: 12px; font-weight: 600; padding: 10px 14px;
	border-radius: 8px; min-height: 44px;
}
.e2zimg-btn:hover { border-color: var(--e2zimg-accent); }
.e2zimg-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.e2zimg-btn.e2zimg-active { background: var(--e2zimg-accent); border-color: var(--e2zimg-accent); color: #fff; }
.e2zimg-btn.e2zimg-primary { background: var(--e2zimg-accent); border-color: var(--e2zimg-accent); color: #fff; }
.e2zimg-btn.e2zimg-primary:hover { background: var(--e2zimg-accent-dark); }
.e2zimg-btn.e2zimg-warn-btn { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.e2zimg-btn-group { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.e2zimg-history-row { margin-top: 14px; border-top: 1px solid var(--e2zimg-border); padding-top: 12px; margin-bottom: 0; }

.e2zimg-estimate { font-size: 11px; color: var(--e2zimg-muted); margin: -4px 0 10px; }
.e2zimg-estimate b { color: var(--e2zimg-text); }

/* ---------------- watermark position grid ---------------- */

.e2zimg-pos-grid { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
.e2zimg-pos {
	width: 34px; height: 34px; min-height: 0; cursor: pointer; border-radius: 6px; padding: 0;
	border: 1px solid var(--e2zimg-border); background: var(--e2zimg-bg); color: var(--e2zimg-text);
	font-size: 13px; line-height: 1;
}
.e2zimg-pos.e2zimg-active { background: var(--e2zimg-accent); border-color: var(--e2zimg-accent); color: #fff; }

/* ---------------- stats & progress ---------------- */

.e2zimg-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.e2zimg-stat { background: var(--e2zimg-bg); border: 1px solid var(--e2zimg-border); border-radius: 8px; padding: 8px; text-align: center; }
.e2zimg-stat .e2zimg-val { font-size: 14px; font-weight: 800; }
.e2zimg-stat .e2zimg-lbl { font-size: 10px; color: var(--e2zimg-muted); text-transform: uppercase; }
.e2zimg-stat.e2zimg-good .e2zimg-val { color: var(--e2zimg-success); }
.e2zimg-stat.e2zimg-flat .e2zimg-val { color: var(--e2zimg-warn); }

.e2zimg-progress { height: 6px; background: var(--e2zimg-border); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.e2zimg-progress-bar { height: 100%; width: 0; background: var(--e2zimg-accent); transition: width 0.2s linear; }

/* ---------------- crop overlay ---------------- */

.e2zimg-crop-overlay {
	position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.45);
	cursor: move; touch-action: none; z-index: 6;
}
.e2zimg-crop-overlay.e2zimg-crop-grid-on::before,
.e2zimg-crop-overlay.e2zimg-crop-grid-on::after {
	content: ""; position: absolute; inset: 0; pointer-events: none;
}
.e2zimg-crop-overlay.e2zimg-crop-grid-on::before {
	background-image: linear-gradient(to right, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
	background-size: 33.333% 100%;
}
.e2zimg-crop-overlay.e2zimg-crop-grid-on::after {
	background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
	background-size: 100% 33.333%;
}
.e2zimg-crop-overlay .e2zimg-rs {
	position: absolute; width: 22px; height: 22px; background: #fff; border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); touch-action: none;
}
.e2zimg-rs-nw { left: -11px; top: -11px; cursor: nwse-resize; }
.e2zimg-rs-n  { left: 50%; top: -11px; margin-left: -11px; cursor: ns-resize; }
.e2zimg-rs-ne { right: -11px; top: -11px; cursor: nesw-resize; }
.e2zimg-rs-e  { right: -11px; top: 50%; margin-top: -11px; cursor: ew-resize; }
.e2zimg-rs-se { right: -11px; bottom: -11px; cursor: nwse-resize; }
.e2zimg-rs-s  { left: 50%; bottom: -11px; margin-left: -11px; cursor: ns-resize; }
.e2zimg-rs-sw { left: -11px; bottom: -11px; cursor: nesw-resize; }
.e2zimg-rs-w  { left: -11px; top: 50%; margin-top: -11px; cursor: ew-resize; }
.e2zimg-crop-nums .e2zimg-row label { min-width: 18px; }
.e2zimg-crop-nums .e2zimg-row input[type="number"] { width: 84px; }

/* ---------------- extras ---------------- */

.e2zimg-palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.e2zimg-swatch {
	width: 76px; height: 56px; border-radius: 8px; border: 1px solid var(--e2zimg-border);
	cursor: pointer; padding: 0; display: flex; align-items: flex-end; justify-content: center;
	min-height: 0; overflow: hidden;
}
.e2zimg-swatch span {
	display: block; width: 100%; background: rgba(0, 0, 0, 0.55); color: #fff;
	font-size: 10px; padding: 2px 0; text-align: center; font-family: monospace;
}

.e2zimg-kv { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; }
.e2zimg-kv th,
.e2zimg-kv td { border: 1px solid var(--e2zimg-border); padding: 6px 8px; text-align: left; vertical-align: top; }
.e2zimg-kv th { width: 42%; color: var(--e2zimg-muted); font-weight: 600; background: var(--e2zimg-bg); }
.e2zimg-kv td { word-break: break-word; }

.e2zimg-b64-out,
.e2zimg-responsive-snippet,
.e2zimg-favicon-snippet {
	width: 100%; min-height: 90px; font-family: monospace; font-size: 11px;
	margin-top: 8px; resize: vertical; word-break: break-all;
}

/* ---------------- misc ---------------- */

.e2zimg-status { font-size: 12px; color: var(--e2zimg-muted); margin-top: 8px; min-height: 16px; }
.e2zimg-kbd { font-size: 11px; color: var(--e2zimg-muted); margin-top: 10px; display: none; }
.e2zimg-note { font-size: 11px; color: var(--e2zimg-muted); margin: 0 0 10px; }
.e2zimg-hidden { display: none !important; }

.e2zimg-editor-placeholder { border: 1px dashed #ccc; padding: 16px; border-radius: 8px; background: #fafafa; }

@media (prefers-reduced-motion: reduce) {
	.e2zimg-wrap * { transition: none !important; animation: none !important; }
}

/* ---------------- tablet and up ---------------- */

@media (min-width: 768px) {
	.e2zimg-wrap { padding: 18px; }
	.e2zimg-workspace { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: start; }
	.e2zimg-rail { flex-direction: column; overflow-x: visible; overflow-y: auto; max-height: 560px; margin-bottom: 0; }
	.e2zimg-thumb { width: 76px; height: 76px; }
	.e2zimg-preview-box canvas { max-height: 520px; }
	.e2zimg-kbd { display: block; }
}

/* ---------------- desktop and up ---------------- */

@media (min-width: 1024px) {
	.e2zimg-main { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; align-items: start; }
	.e2zimg-panel { margin-bottom: 0; }
}
