// AI Conduit Admin Styles

// Variables
$primary: #2271b1;
$primary-hover: #135e96;
$border: #c3c4c7;
$bg-light: #f0f0f1;
$bg-white: #fff;
$text: #1e1e1e;
$text-muted: #757575;
$destructive: #cc1818;
$success: #00a32a;
$radius: 4px;

// Layout
.aic-header {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 24px;
	flex-wrap: wrap;

	h1 {
		flex: 1;
		margin: 0;
		font-size: 23px;
		font-weight: 400;
	}

	&-actions {
		display: flex;
		gap: 8px;
	}
}

// Tool List
.aic-tool-list {
	max-width: 1200px;
	padding: 20px;
}

.aic-tools-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 16px;
}

.aic-tool-card {
	.components-card__header h3 {
		margin: 0;
		font-size: 16px;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
}

.aic-tool-description {
	color: $text-muted;
	margin: 0 0 12px;
}

.aic-tool-meta {
	display: flex;
	gap: 16px;
	font-size: 12px;
	color: $text-muted;
	margin-bottom: 12px;
}

.aic-tool-actions {
	display: flex;
	gap: 8px;
}

.aic-empty-state {
	text-align: center;
	color: $text-muted;
	padding: 40px 20px;
}

// Import/Export Notices
.aic-notice {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 12px;
	border-radius: $radius;
	border: 1px solid $border;
	margin-bottom: 16px;
	background: $bg-white;

	p {
		margin: 0;
		font-size: 13px;
	}

	&--success {
		border-color: $success;
		background: lighten($success, 60%);
	}

	&--error {
		border-color: $destructive;
		background: lighten($destructive, 48%);
	}
}

// Tool Builder
.aic-tool-builder {
	padding: 20px;
}

.aic-builder-header {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 20px;

	h1 {
		flex: 1;
		margin: 0;
		font-size: 23px;
		font-weight: 400;
	}
}

.aic-builder-settings {
	background: $bg-white;
	border: 1px solid $border;
	border-radius: $radius;
	padding: 16px;
	margin-bottom: 20px;

	.components-base-control {
		margin-bottom: 12px;

		&:last-child {
			margin-bottom: 0;
		}
	}
}

.aic-builder-workspace {
	display: grid;
	grid-template-columns: 200px 1fr 320px;
	gap: 16px;
	min-height: 500px;
}

// Block Palette
.aic-palette {
	background: $bg-white;
	border: 1px solid $border;
	border-radius: $radius;
	padding: 16px;

	h3 {
		margin: 0 0 4px;
		font-size: 14px;
	}
}

.aic-palette-hint {
	color: $text-muted;
	font-size: 12px;
	margin: 0 0 12px;
}

.aic-palette-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: $bg-light;
	border: 1px solid $border;
	border-radius: $radius;
	margin-bottom: 8px;
	cursor: grab;
	font-size: 13px;
	user-select: none;

	&:hover {
		border-color: $primary;
		background: lighten($primary, 52%);
	}

	&--dragging {
		opacity: 0.8;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	}

	.dashicons {
		color: $text-muted;
		font-size: 18px;
		width: 18px;
		height: 18px;
	}
}

// Builder Canvas
.aic-canvas {
	background: $bg-white;
	border: 2px dashed $border;
	border-radius: $radius;
	padding: 16px;
	min-height: 400px;
	transition: border-color 0.2s, background-color 0.2s;

	h3 {
		margin: 0 0 12px;
		font-size: 14px;
	}

	&--over {
		border-color: $primary;
		background: lighten($primary, 54%);
	}
}

.aic-canvas-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 300px;
	color: $text-muted;

	.dashicons {
		font-size: 48px;
		width: 48px;
		height: 48px;
		margin-bottom: 12px;
	}

	p {
		margin: 0;
	}
}

.aic-canvas-block {
	background: $bg-white;
	border: 1px solid $border;
	border-radius: $radius;
	margin-bottom: 12px;
	overflow: hidden;

	&:last-child {
		margin-bottom: 0;
	}
}

.aic-canvas-block-header {
	display: flex;
	align-items: center;
	padding: 0 12px 0 0;
	background: $bg-light;
	border-bottom: 1px solid $border;
}

.aic-canvas-block-drag {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	padding: 10px 12px;
	cursor: grab;

	.dashicons {
		color: $text-muted;
		font-size: 18px;
		width: 18px;
		height: 18px;
	}

	.aic-canvas-block-label {
		font-weight: 600;
		font-size: 13px;
	}
}

.aic-canvas-block-body {
	padding: 12px;
}

// Block Configurator
.aic-configurator {
	.components-select-control {
		margin-bottom: 12px;
	}
}

.aic-configurator-tabs {
	display: flex;
	border-bottom: 1px solid $border;
	margin-bottom: 12px;
}

.aic-tab {
	padding: 8px 16px;
	background: none;
	border: none;
	border-bottom: 2px solid transparent;
	font-size: 13px;
	cursor: pointer;
	color: $text-muted;

	&:hover {
		color: $text;
	}

	&--active {
		color: $primary;
		border-bottom-color: $primary;
		font-weight: 600;
	}
}

.aic-configurator-content {
	max-height: 400px;
	overflow-y: auto;
	padding-right: 4px;
}

.aic-search-input {
	margin-bottom: 8px;
}

// Selectors
.aic-selector-hint {
	color: $text-muted;
	font-size: 12px;
	margin: 0 0 12px;
}

.aic-selector-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
}

.aic-meta-item,
.aic-taxonomy-item,
.aic-filter-item {
	margin-bottom: 8px;
	padding-bottom: 8px;
	border-bottom: 1px solid $bg-light;

	&:last-child {
		border-bottom: none;
	}
}

.aic-meta-item--internal,
.aic-taxonomy-item--internal {
	opacity: 0.6;
}

.aic-meta-config,
.aic-taxonomy-config,
.aic-filter-config {
	margin-left: 28px;
	padding: 8px 0;
}

.aic-compare-options,
.aic-terms-selector {
	margin-top: 8px;
	padding: 8px;
	background: $bg-light;
	border-radius: $radius;

	> label {
		display: block;
		font-size: 12px;
		font-weight: 600;
		margin-bottom: 4px;
	}
}

.aic-terms-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 4px;

	label {
		font-size: 12px;
		font-weight: 600;
	}
}

// Join Selector
.aic-join-selector {
	.aic-selector-hint {
		margin-bottom: 12px;
	}
}

.aic-join-entry {
	background: $bg-light;
	border: 1px solid $border;
	border-radius: $radius;
	padding: 12px;
	margin-bottom: 12px;

	.components-base-control {
		margin-bottom: 10px;
	}

	h4 {
		font-size: 12px;
		font-weight: 600;
		margin: 12px 0 4px;
	}
}

.aic-join-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 10px;
}

.aic-join-target-fields,
.aic-join-target-meta {
	margin-top: 8px;
	padding: 8px;
	background: $bg-white;
	border-radius: $radius;
}

// Schema Preview
.aic-schema-preview {
	background: $bg-white;
	border: 1px solid $border;
	border-radius: $radius;
	padding: 16px;

	h3 {
		margin: 0 0 4px;
		font-size: 14px;
	}
}

.aic-schema-json {
	background: #2c3338;
	color: #e0e0e0;
	padding: 12px;
	border-radius: $radius;
	overflow-x: auto;
	font-size: 11px;
	line-height: 1.5;
	white-space: pre;
	max-height: 500px;
	overflow-y: auto;
}

// Settings
.aic-settings {
	max-width: 800px;
	padding: 20px;
}

.aic-settings-card {
	margin-bottom: 16px;

	.components-card__header h3 {
		margin: 0;
		font-size: 16px;
	}

	.components-base-control {
		margin-bottom: 16px;

		&:last-child {
			margin-bottom: 0;
		}
	}
}

.aic-settings-actions {
	display: flex;
	align-items: center;
	gap: 12px;
}

.aic-save-notice {
	color: $success;
	font-size: 13px;
}

// Instructions
.aic-instructions {
	max-width: 960px;
	padding: 20px;

	.components-card {
		margin-bottom: 16px;
	}

	.components-card__header h3 {
		margin: 0;
		font-size: 16px;
	}

	h4 {
		font-size: 14px;
		margin: 16px 0 8px;
	}

	p, li {
		line-height: 1.6;
	}
}

.aic-card-highlight {
	border-left: 4px solid $primary;
}

.aic-endpoint-box {
	display: flex;
	align-items: center;
	gap: 12px;
	background: $bg-light;
	padding: 12px 16px;
	border-radius: $radius;
	margin-top: 8px;

	code {
		flex: 1;
		font-size: 13px;
		word-break: break-all;
	}
}

.aic-code-block {
	background: #2c3338;
	color: #e0e0e0;
	padding: 16px;
	border-radius: $radius;
	overflow-x: auto;
	font-size: 12px;
	line-height: 1.5;
	white-space: pre;
}

.aic-steps {
	margin-left: 20px;

	li {
		margin-bottom: 8px;
	}
}

table.widefat {
	margin-top: 8px;

	td, th {
		padding: 10px 12px;
	}
}
