/* ==========================================================================
   Code / data tools shared styles (JSON, encoding, hash, regex, formatters)
   ========================================================================== */

.uth-tool,
.uth-tool-shortcode {
	--ct-editor-bg: #0f172a;
	--ct-editor-fg: #e2e8f0;
	--ct-editor-muted: #94a3b8;
	--ct-editor-border: #1e293b;
	--ct-editor-accent: #38bdf8;
	--ct-ok: #16a34a;
	--ct-warn: #d97706;
	--ct-err: #dc2626;
	--ct-info-bg: #eff6ff;
}

.uth-code-tool {
	display: grid;
	gap: 16px;
}

.uth-code-tool__panel {
	display: grid;
	gap: 14px;
}

.uth-code-tool__actions {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
}

.uth-code-tool__actions .uth-button {
	margin: 0;
}

.uth-code-tool__status {
	min-height: 22px;
	margin: 0;
	color: var(--uth-muted);
	font-size: 0.88rem;
	line-height: 1.5;
}

.uth-code-tool__status.is-ok {
	color: var(--ct-ok);
	font-weight: 600;
}

.uth-code-tool__status.is-err {
	color: var(--ct-err);
	font-weight: 600;
}

/* ---- Code editor / output ---- */

.uth-code-editor,
.uth-code-output {
	position: relative;
	display: grid;
	gap: 8px;
}

.uth-code-output__box {
	position: relative;
}

.uth-code-editor__label,
.uth-code-output__label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	color: var(--uth-heading);
	font-size: 0.9rem;
	font-weight: 700;
}

.uth-code-editor__meta,
.uth-code-output__meta {
	color: var(--uth-muted);
	font-size: 0.78rem;
	font-weight: 500;
}

.uth-code-editor textarea,
.uth-code-output textarea {
	width: 100%;
	min-height: 220px;
	padding: 16px;
	color: var(--ct-editor-fg);
	background: var(--ct-editor-bg);
	border: 1px solid var(--ct-editor-border);
	border-radius: 12px;
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
	font-size: 0.86rem;
	line-height: 1.6;
	tab-size: 4;
	resize: vertical;
}

.uth-code-editor textarea:focus {
	background: var(--ct-editor-bg);
	color: var(--ct-editor-fg);
	border-color: var(--uth-primary);
	outline: none;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.uth-code-output textarea {
	background: var(--ct-editor-bg);
	color: var(--ct-editor-fg);
	border-color: var(--ct-editor-border);
}

.uth-code-output textarea:focus {
	background: var(--ct-editor-bg);
	color: var(--ct-editor-fg);
	border-color: var(--uth-primary);
	outline: none;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.uth-code-output.is-empty {
	display: none;
}

/* ---- Inline result chips (hash / uuid) ---- */

.uth-chip-list {
	display: grid;
	gap: 10px;
}

.uth-chip-list[hidden] {
	display: none;
}

.uth-chip {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	background: var(--uth-surface-soft);
	border: 1px solid var(--uth-border);
	border-radius: 10px;
}

.uth-chip code {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
	color: var(--uth-heading);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.84rem;
	line-height: 1.5;
}

/* ---- Regex tester ---- */

.uth-regex-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
	gap: 20px;
	align-items: start;
}

.uth-regex-side {
	display: grid;
	gap: 14px;
}

.uth-regex-input-row {
	display: flex;
	gap: 8px;
}

.uth-regex-input-row .uth-input {
	flex: 1 1 auto;
	min-width: 0;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9rem;
}

.uth-regex-flags {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 0 4px;
}

.uth-regex-flag {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 34px;
	height: 34px;
	padding: 0 6px;
	color: var(--uth-muted);
	background: var(--uth-background);
	border: 1px solid var(--uth-border);
	border-radius: 8px;
	font: inherit;
	font-size: 0.8rem;
	font-weight: 700;
	cursor: pointer;
}

.uth-regex-flag.is-active {
	color: #fff;
	background: var(--uth-primary);
	border-color: var(--uth-primary);
}

.uth-regex-matches {
	display: grid;
	gap: 8px;
	max-height: 380px;
	overflow: auto;
}

.uth-regex-match {
	display: grid;
	gap: 4px;
	padding: 10px 12px;
	background: var(--uth-surface-soft);
	border: 1px solid var(--uth-border);
	border-left: 3px solid var(--uth-primary);
	border-radius: 8px;
}

.uth-regex-match__index {
	color: var(--uth-muted);
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.uth-regex-match__value {
	overflow-wrap: anywhere;
	color: var(--uth-heading);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.86rem;
	line-height: 1.5;
}

.uth-regex-reference {
	display: grid;
	gap: 8px;
	margin: 0;
	padding: 14px;
	background: var(--ct-info-bg);
	border: 1px solid var(--uth-border);
	border-radius: 10px;
	list-style: none;
	font-size: 0.84rem;
}

.uth-regex-reference li {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--uth-text);
}

.uth-regex-reference code {
	color: var(--uth-heading);
	font-weight: 700;
}

/* ---- Timestamp converter ---- */

.uth-ts-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 18px;
}

.uth-ts-card {
	display: grid;
	gap: 10px;
	padding: 18px;
	background: var(--uth-surface-soft);
	border: 1px solid var(--uth-border);
	border-radius: 12px;
}

.uth-ts-card h3 {
	margin: 0;
	color: var(--uth-heading);
	font-size: 1rem;
	font-weight: 700;
}

.uth-ts-result {
	padding: 12px 14px;
	color: var(--ct-editor-fg);
	background: var(--ct-editor-bg);
	border: 1px solid var(--ct-editor-border);
	border-radius: 8px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.86rem;
	line-height: 1.6;
	overflow-wrap: anywhere;
}

.uth-ts-formats {
	display: grid;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.uth-ts-formats li {
	display: flex;
	align-items: baseline;
	gap: 8px;
	font-size: 0.86rem;
}

.uth-ts-formats strong {
	width: 96px;
	flex: none;
	color: var(--uth-muted);
	font-size: 0.76rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.uth-ts-formats code {
	overflow-wrap: anywhere;
	color: var(--uth-heading);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- JWT decoder ---- */

.uth-jwt-parts {
	display: grid;
	gap: 14px;
}

.uth-jwt-part {
	position: relative;
	display: grid;
	gap: 8px;
}

.uth-jwt-part__box {
	position: relative;
}

.uth-jwt-part__label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	color: var(--uth-heading);
	font-size: 0.9rem;
	font-weight: 700;
}

.uth-jwt-part__label .uth-badge {
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 700;
}

.uth-badge--ok {
	color: #fff;
	background: var(--ct-ok);
}

.uth-badge--warn {
	color: #fff;
	background: var(--ct-warn);
}

.uth-badge--err {
	color: #fff;
	background: var(--ct-err);
}

.uth-jwt-part pre {
	margin: 0;
	padding: 14px 16px;
	color: var(--ct-editor-fg);
	background: var(--ct-editor-bg);
	border: 1px solid var(--ct-editor-border);
	border-radius: 10px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.84rem;
	line-height: 1.6;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

/* ---- CSV/JSON + Base64/URL shared ---- */

.uth-pair-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 18px;
	align-items: start;
}

.uth-pair-grid .uth-code-editor textarea {
	min-height: 260px;
}

.uth-csv-table-wrap {
	max-height: 420px;
	overflow: auto;
	border: 1px solid var(--uth-border);
	border-radius: 10px;
}

.uth-csv-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.86rem;
}

.uth-csv-table th,
.uth-csv-table td {
	padding: 9px 12px;
	border-bottom: 1px solid var(--uth-border);
	text-align: left;
	vertical-align: top;
}

.uth-csv-table th {
	position: sticky;
	top: 0;
	background: var(--uth-surface);
	color: var(--uth-heading);
	font-weight: 700;
}

.uth-csv-table td {
	color: var(--uth-text);
}

.uth-hash-modes {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.uth-hash-mode {
	padding: 8px 14px;
	color: var(--uth-muted);
	background: var(--uth-background);
	border: 1px solid var(--uth-border);
	border-radius: 999px;
	font: inherit;
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
}

.uth-hash-mode.is-active {
	color: #fff;
	background: var(--uth-primary);
	border-color: var(--uth-primary);
}

.uth-uuid-toolbar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
}

.uth-uuid-count {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--uth-muted);
	font-size: 0.84rem;
}

.uth-uuid-count input {
	width: 72px;
	padding: 7px 10px;
	color: var(--uth-heading);
	background: var(--uth-background);
	border: 1px solid var(--uth-border);
	border-radius: 8px;
	font: inherit;
	font-size: 0.86rem;
}

/* ---- Download links ---- */

.uth-download-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--uth-primary);
	font-size: 0.84rem;
	font-weight: 600;
	text-decoration: none;
}

.uth-download-link:hover {
	color: var(--uth-primary-hover);
	text-decoration: underline;
}

@media (max-width: 860px) {
	.uth-regex-layout,
	.uth-ts-grid,
	.uth-pair-grid {
		grid-template-columns: 1fr;
	}
}
