/**
 * Toolzio tool-interface styles.
 *
 * Self-contained so tools look premium under ANY theme. Uses the Toolzio
 * design tokens when present (provided by the theme) and falls back to sensible
 * defaults otherwise.
 */
.tz-tool {
	--_bg: var(--tz-surface, #ffffff);
	--_bg2: var(--tz-surface-2, #f6f8fc);
	--_text: var(--tz-text, #0b1020);
	--_muted: var(--tz-muted, #5b647a);
	--_border: var(--tz-border, #e4e8f0);
	--_accent: var(--tz-accent, #2563eb);
	--_accent2: var(--tz-accent-2, #7c3aed);
	--_radius: var(--tz-radius, 14px);
	--_radius-sm: var(--tz-radius-sm, 10px);
	--_ok: var(--tz-success, #16a34a);
	--_err: var(--tz-error, #dc2626);
	--_shadow: var(--tz-shadow, 0 10px 30px -12px rgba(16, 24, 40, .18));

	background: var(--_bg);
	border: 1px solid var(--_border);
	border-radius: var(--_radius);
	padding: clamp(16px, 3vw, 28px);
	box-shadow: var(--_shadow);
	color: var(--_text);
}

.tz-fields {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
}
.tz-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tz-field-textarea, .tz-field-file, .tz-field[data-field="text"], .tz-field[data-field="json"], .tz-field[data-field="data"] { grid-column: 1 / -1; }
.tz-field[hidden] { display: none; }

.tz-field label, .tz-segmented legend {
	font-weight: 600;
	font-size: .92rem;
	color: var(--_text);
}
.tz-help { font-size: .8rem; color: var(--_muted); }

.tz-tool input[type="text"],
.tz-tool input[type="number"],
.tz-tool input[type="date"],
.tz-tool select,
.tz-tool textarea {
	width: 100%;
	font: inherit;
	color: var(--_text);
	background: var(--_bg2);
	border: 1px solid var(--_border);
	border-radius: var(--_radius-sm);
	padding: 12px 14px;
	min-height: 48px;
	transition: border-color .15s ease, box-shadow .15s ease;
	-webkit-appearance: none;
	appearance: none;
}
.tz-tool textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.tz-tool input:focus, .tz-tool select:focus, .tz-tool textarea:focus {
	outline: none;
	border-color: var(--_accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--_accent) 22%, transparent);
}

.tz-input-wrap { position: relative; display: flex; align-items: stretch; }
.tz-input-wrap.has-affix input { border-radius: var(--_radius-sm); }
.tz-affix {
	display: inline-flex; align-items: center; padding: 0 12px;
	background: var(--_bg2); border: 1px solid var(--_border); color: var(--_muted);
	font-weight: 600;
}
.tz-prefix { border-right: 0; border-radius: var(--_radius-sm) 0 0 var(--_radius-sm); }
.tz-suffix { border-left: 0; border-radius: 0 var(--_radius-sm) var(--_radius-sm) 0; }
.tz-input-wrap.has-affix input { border-radius: 0; }
.tz-input-wrap.has-affix .tz-prefix + input { border-left: 0; }
.tz-input-wrap.has-affix input:first-child { border-radius: var(--_radius-sm) 0 0 var(--_radius-sm); }

.tz-select-wrap { position: relative; }
.tz-select-wrap::after {
	content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px;
	border-right: 2px solid var(--_muted); border-bottom: 2px solid var(--_muted);
	transform: translateY(-65%) rotate(45deg); pointer-events: none;
}
.tz-tool select { padding-right: 38px; }

/* Range */
.tz-range-wrap { display: flex; align-items: center; gap: 12px; }
.tz-tool input[type="range"] { min-height: 0; padding: 0; accent-color: var(--_accent); flex: 1; }
.tz-range-out { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 56px; text-align: right; }

/* File */
.tz-file { padding: 10px 14px; }
.tz-file::file-selector-button {
	font: inherit; font-weight: 600; cursor: pointer; margin-right: 12px;
	border: 0; border-radius: 8px; padding: 8px 14px;
	background: var(--_accent); color: #fff;
}

/* Segmented (radio) */
.tz-segmented { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.tz-segmented-options { display: inline-flex; background: var(--_bg2); border: 1px solid var(--_border); border-radius: 999px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.tz-seg { position: relative; }
.tz-seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.tz-seg span {
	display: block; padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem;
	color: var(--_muted); cursor: pointer; min-height: 40px; display: flex; align-items: center;
}
.tz-seg input:checked + span { background: var(--_accent); color: #fff; }
.tz-seg input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--_accent) 30%, transparent); }

/* Checkbox */
.tz-field-checkbox { justify-content: center; }
.tz-check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; font-weight: 600; font-size: .92rem; }
.tz-check input { width: 20px; height: 20px; accent-color: var(--_accent); margin: 0; flex: none; cursor: pointer; }

/* Buttons */
.tz-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; align-items: center; }
.tz-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	font: inherit; font-weight: 650; cursor: pointer; border: 1px solid transparent;
	border-radius: var(--_radius-sm); padding: 0 20px; min-height: 48px;
	transition: transform .12s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
	-webkit-tap-highlight-color: transparent;
}
.tz-btn:active { transform: translateY(1px) scale(.99); }
.tz-btn-primary {
	background: linear-gradient(135deg, var(--_accent), var(--_accent2));
	color: #fff; box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--_accent) 60%, transparent);
}
.tz-btn-primary:hover { box-shadow: 0 12px 26px -8px color-mix(in srgb, var(--_accent) 70%, transparent); }
.tz-btn-secondary { background: var(--_bg2); color: var(--_text); border-color: var(--_border); }
.tz-btn-secondary:hover { border-color: var(--_accent); color: var(--_accent); }
.tz-btn-ghost { background: transparent; color: var(--_muted); }
.tz-btn-ghost:hover { color: var(--_accent); }
.tz-btn-sm { min-height: 40px; padding: 0 14px; font-size: .88rem; }
.tz-btn.is-done { background: var(--_ok); color: #fff; border-color: var(--_ok); }
.tz-btn svg { flex: none; }

/* Error */
.tz-error {
	margin: 14px 0 0; padding: 12px 14px; border-radius: var(--_radius-sm);
	background: color-mix(in srgb, var(--_err) 10%, transparent);
	color: var(--_err); border: 1px solid color-mix(in srgb, var(--_err) 30%, transparent);
	font-weight: 600; font-size: .9rem;
}

/* Result card */
.tz-result { margin-top: 20px; opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease; }
.tz-result.is-visible { opacity: 1; transform: none; }
.tz-result-card {
	background: linear-gradient(180deg, var(--_bg2), var(--_bg));
	border: 1px solid var(--_border); border-radius: var(--_radius); padding: clamp(16px, 3vw, 26px);
	position: relative; overflow: hidden;
}
.tz-result-card::before {
	content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
	background: linear-gradient(90deg, var(--_accent), var(--_accent2));
}
.tz-r-main { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.tz-r-value {
	font-size: clamp(1.9rem, 6vw, 2.8rem); font-weight: 800; line-height: 1.05;
	letter-spacing: -.02em; font-variant-numeric: tabular-nums;
	background: linear-gradient(135deg, var(--_accent), var(--_accent2));
	-webkit-background-clip: text; background-clip: text; color: transparent;
}
.tz-r-label { color: var(--_muted); font-weight: 600; }
.tz-r-table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.tz-r-table th, .tz-r-table td { text-align: left; padding: 10px 0; border-bottom: 1px solid var(--_border); }
.tz-r-table th { color: var(--_muted); font-weight: 600; }
.tz-r-table td { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.tz-r-table tr:last-child th, .tz-r-table tr:last-child td { border-bottom: 0; }
.tz-r-note { color: var(--_muted); font-size: .86rem; margin-top: 10px; }
.tz-r-status { font-weight: 700; margin-bottom: 12px; }
.tz-r-status.tz-ok { color: var(--_ok); }
.tz-r-status.tz-bad { color: var(--_err); }
.tz-code {
	background: #0b1020; color: #d7e0f5; border-radius: var(--_radius-sm); padding: 16px;
	overflow: auto; max-height: 420px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: .86rem; line-height: 1.5; white-space: pre;
}
.tz-r-preview, .tz-r-qr { margin: 14px 0; text-align: center; }
.tz-r-preview img, .tz-r-qr img { max-width: 100%; height: auto; border-radius: var(--_radius-sm); border: 1px solid var(--_border); }
.tz-r-qr img { background: #fff; padding: 8px; }
.tz-skeleton { height: 120px; border-radius: var(--_radius-sm); background: linear-gradient(90deg, var(--_bg2), var(--_border), var(--_bg2)); background-size: 200% 100%; animation: tz-shimmer 1.2s infinite; }
@keyframes tz-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.tz-result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* SERP preview */
.tz-serp { background: var(--_bg); border: 1px solid var(--_border); border-radius: var(--_radius-sm); padding: 16px 18px; margin-bottom: 14px; max-width: 600px; }
.tz-serp-url { color: var(--tz-success, #1a7f37); font-size: .82rem; }
.tz-serp-title { color: #1a0dab; font-size: 1.25rem; line-height: 1.3; margin: 2px 0 4px; }
[data-theme="dark"] .tz-serp-title { color: #8ab4f8; }
.tz-serp-desc { color: var(--_muted); font-size: .9rem; }

/* Colour swatch + gradient preview */
.tz-swatch { width: 100%; height: 90px; border-radius: var(--_radius-sm); border: 1px solid var(--_border); margin-bottom: 14px; }
.tz-gradient-preview { width: 100%; height: 130px; border-radius: var(--_radius-sm); border: 1px solid var(--_border); margin-bottom: 14px; }

/* Advertisement container */
.tz-ad { margin: 22px auto; text-align: center; max-width: 100%; }
.tz-ad-label { display: block; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--tz-muted, #8a92a6); margin-bottom: 6px; }
.tz-ad-unit { display: block; }

/* Mobile */
@media (max-width: 620px) {
	.tz-fields { grid-template-columns: 1fr; }
	.tz-actions .tz-btn-primary { flex: 1 1 100%; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.tz-result, .tz-btn, .tz-skeleton { transition: none; animation: none; }
	.tz-result { opacity: 1; transform: none; }
}
