/* JSON Viewer */

#developer .tool-card {
	width: 100%;
}

#developer .tool-field {
	margin-top: 22px;
}

#developer .tool-field label {
	display: block;
	margin-bottom: 9px;
	color: var(--text);
	font-size: 14px;
	font-weight: 650;
}

.jsonviewer-hint {
	margin: 8px 0 0;
	color: var(--muted);
	font-size: 13px;
	line-height: 1.6;
}

/* File input */

#jsonViewerFile {
	display: block;
	width: 100%;
	min-height: 48px;
	padding: 7px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 14px;
	transition: border-color 0.2s, box-shadow 0.2s;
}

#jsonViewerFile::file-selector-button {
	margin-right: 12px;
	padding: 9px 15px;
	border: 0;
	border-radius: 8px;
	background: var(--primary, #315efb);
	color: #fff;
	font-size: 13px;
	font-weight: 650;
	cursor: pointer;
	transition: opacity 0.2s;
}

#jsonViewerFile::file-selector-button:hover {
	opacity: 0.85;
}

#jsonViewerFile:focus {
	outline: none;
	border-color: var(--primary, #315efb);
	box-shadow: 0 0 0 3px rgba(49, 94, 251, 0.12);
}

/* Buttons */

#developer .tool-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 24px;
}

#developer .tool-actions button,
.jsonviewer-tree-actions button {
	min-height: 42px;
	padding: 0 18px;
	border: 1px solid var(--primary, #315efb);
	border-radius: 9px;
	background: var(--primary, #315efb);
	color: #fff;
	font-size: 13px;
	font-weight: 650;
	cursor: pointer;
	transition:
		background 0.2s,
		border-color 0.2s,
		box-shadow 0.2s,
		transform 0.2s;
}

#developer .tool-actions button:hover,
.jsonviewer-tree-actions button:hover {
	opacity: 0.92;
	transform: translateY(-1px);
	box-shadow: 0 3px 10px rgba(49, 94, 251, 0.12);
}

#developer .tool-actions button:active,
.jsonviewer-tree-actions button:active {
	transform: translateY(0);
}

#developer .tool-actions button:focus-visible,
.jsonviewer-tree-actions button:focus-visible,
.jsonviewer-toggle:focus-visible {
	outline: 2px solid var(--primary, #315efb);
	outline-offset: 3px;
}

#developer .tool-actions button.secondary-button,
.jsonviewer-tree-actions button.secondary-button {
	border-color: var(--line);
	background: var(--surface);
	color: var(--text);
	box-shadow: none;
}

#developer .tool-actions button.secondary-button:hover,
.jsonviewer-tree-actions button.secondary-button:hover {
	border-color: var(--primary, #315efb);
	color: var(--primary, #315efb);
}

/* Status */

#jsonViewerStatus {
	margin-top: 16px;
	font-size: 14px;
	line-height: 1.6;
}

#jsonViewerStatus:empty {
	display: none;
}

/* Results */

.jsonviewer-results {
	width: 100%;
	margin-top: 28px;
}

.jsonviewer-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 14px;
	margin-bottom: 14px;
}

.jsonviewer-summary {
	color: var(--muted);
	font-size: 13px;
	font-weight: 550;
	line-height: 1.6;
}

.jsonviewer-tree-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.jsonviewer-tree-actions button {
	min-height: 36px;
	padding: 0 14px;
}

/* Tree container */

.jsonviewer-tree {
	width: 100%;
	max-height: 620px;
	overflow: auto;
	padding: 18px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface);
	color: var(--text);
	font-family: Consolas, Monaco, "Courier New", monospace;
	font-size: 13px;
	line-height: 1.85;
	scrollbar-width: thin;
	scrollbar-color: var(--line) transparent;
}

.jsonviewer-tree::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

.jsonviewer-tree::-webkit-scrollbar-thumb {
	border-radius: 8px;
	background: var(--line);
}

.jsonviewer-tree::-webkit-scrollbar-thumb:hover {
	background: var(--muted);
}

.jsonviewer-node {
	min-width: max-content;
}

.jsonviewer-children {
	margin-left: 20px;
	padding-left: 14px;
	border-left: 1px solid var(--line);
}

.jsonviewer-row {
	display: flex;
	align-items: baseline;
	flex-wrap: nowrap;
	gap: 5px;
	min-height: 27px;
	padding: 1px 5px 1px 0;
	border-radius: 5px;
	transition: background 0.15s;
}

.jsonviewer-row:hover {
	background: rgba(127, 127, 127, 0.07);
}

.jsonviewer-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 18px;
	width: 18px;
	height: 20px;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: var(--muted);
	font-size: 12px;
	cursor: pointer;
	transition: color 0.15s, background 0.15s;
}

.jsonviewer-toggle:hover {
	background: rgba(49, 94, 251, 0.09);
	color: var(--primary, #315efb);
}

.jsonviewer-toggle-placeholder {
	display: inline-block;
	flex: 0 0 18px;
	width: 18px;
}

.jsonviewer-key {
	color: var(--primary, #315efb);
	font-weight: 650;
}

.jsonviewer-punctuation {
	color: var(--muted);
}

.jsonviewer-string {
	color: #16845b;
	overflow-wrap: anywhere;
}

.jsonviewer-number {
	color: #b66a12;
}

.jsonviewer-boolean {
	color: #8955c7;
	font-weight: 600;
}

.jsonviewer-null {
	color: var(--muted);
	font-style: italic;
}

.jsonviewer-preview {
	color: var(--muted);
	font-size: 12px;
}

.jsonviewer-empty {
	color: var(--muted);
	font-style: italic;
}

/* Search result highlighting */
.jsonviewer-search-highlight {
	background: #fff176;
	color: #222;
	border-radius: 2px;
	padding: 0 1px;
}

/* Currently selected search result */
.jsonviewer-search-current>.jsonviewer-row {
	background: #dbeafe;
	outline: 2px solid #3b82f6;
	border-radius: 4px;
}

/* Highlight the active match more prominently */
.jsonviewer-search-current .jsonviewer-search-highlight {
	background: #f97316;
	color: #fff;
	border-radius: 3px;
}

/* Smooth visual transition */
.jsonviewer-row {
	transition: background-color 0.15s ease;
}

/* Selected JSON node */
.jsonviewer-node-selected>.jsonviewer-row {
	background: #eff6ff;
	outline: 2px solid #3b82f6;
	border-radius: 5px;
}

/* Node operation panel */
.jsonviewer-node-panel {
	margin-top: 18px;
	padding: 18px;
	background: var(--surface, #f8fafc);
	border: 1px solid var(--border, #e2e8f0);
	border-radius: 10px;
}

.jsonviewer-node-panel h3 {
	margin: 0 0 14px;
	font-size: 16px;
	font-weight: 600;
}

.jsonviewer-node-info {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-bottom: 16px;
}

.jsonviewer-node-info label {
	font-size: 13px;
	color: var(--text-secondary, #64748b);
}

.jsonviewer-node-info code {
	display: block;
	padding: 10px 12px;
	overflow-wrap: anywhere;
	background: var(--background, #ffffff);
	border: 1px solid var(--border, #e2e8f0);
	border-radius: 6px;
	font-size: 13px;
}

.jsonviewer-node-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.jsonviewer-node-actions button {
	min-height: 36px;
}

/* JSON Viewer search buttons */
.jsonviewer-search button,
.jsonviewer-node-actions button {
	min-height: 38px;
	padding: 8px 14px;
	border: 1px solid var(--border, #dbe2ea);
	border-radius: 7px;
	background: var(--surface, #ffffff);
	color: var(--text, #1e293b);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.jsonviewer-search button:hover:not(:disabled),
.jsonviewer-node-actions button:hover {
	background: var(--background, #f1f5f9);
	border-color: #94a3b8;
}

.jsonviewer-search button:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.jsonviewer-search input {
	min-height: 38px;
	border-radius: 7px;
}

.jsonviewer-node-actions button {
	background: var(--surface, #ffffff);
}

.jsonviewer-node-actions button:hover {
	background: #eff6ff;
	border-color: #93c5fd;
}

/* JSON Viewer search layout */
.jsonviewer-search {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	width: 100%;
}

.jsonviewer-search input {
	flex: 1 1 220px;
	min-width: 160px;
	width: auto;
	box-sizing: border-box;
}

.jsonviewer-search button {
	flex: 0 0 auto;
}

.jsonviewer-search-status {
	margin-top: 8px;
	font-size: 13px;
}

@media (max-width: 480px) {
	.jsonviewer-search input {
		flex-basis: 100%;
		width: 100%;
	}

	.jsonviewer-search button {
		flex: 1 1 auto;
	}
}

/* JSON tree readability */
.jsonviewer-tree {
	font-size: 13px;
	line-height: 1.8;
}

.jsonviewer-row {
	min-height: 27px;
	padding: 2px 6px;
	border-radius: 4px;
	transition: background-color 0.15s ease;
}

.jsonviewer-row:hover {
	background: #f1f5f9;
}

.jsonviewer-key {
	font-weight: 600;
}

.jsonviewer-toggle {
	min-width: 18px;
	min-height: 20px;
	padding: 0;
	font-size: 11px;
}

.jsonviewer-children {
	margin-left: 10px;
	padding-left: 10px;
}

@media (max-width: 600px) {
	.jsonviewer-node-panel {
		padding: 14px;
	}

	.jsonviewer-node-actions {
		display: grid;
		grid-template-columns: 1fr;
	}

	.jsonviewer-node-actions button {
		width: 100%;
	}
}

/* Responsive */

@media (max-width: 640px) {
	#developer .tool-actions {
		display: grid;
		grid-template-columns: 1fr 1fr;
	}

	#developer .tool-actions button {
		width: 100%;
		padding: 0 12px;
	}

	.jsonviewer-toolbar {
		align-items: flex-start;
		flex-direction: column;
	}

	.jsonviewer-tree-actions {
		width: 100%;
	}

	.jsonviewer-tree-actions button {
		flex: 1;
	}

	.jsonviewer-tree {
		max-height: 500px;
		padding: 12px;
		font-size: 12px;
	}

	.jsonviewer-children {
		margin-left: 14px;
		padding-left: 9px;
	}
}