/**
 * AdminEase Enhanced Taxonomy Meta Box Styles
 *
 * The box sits in the narrow post-edit sidebar, so it uses the core control
 * classes at their compact sizes (32px fields, 24px .button-small pagination)
 * and this file only adds the pieces wp-admin has no component for: the term
 * tree, the selected-term chips and the overflow panel. Colours come from the
 * wpds token layer and --wp-admin-theme-color, so the box follows the user's
 * admin colour scheme.
 */


/* ── Container ────────────────────────────────────────────────────── */

.adminease-taxonomy-meta-box {
	position: relative;
	font-size: var(--wpds-typography-font-size-md, 13px);
}

.adminease-taxonomy-tree {
	height: 220px;
	overflow-y: auto;
	background: var(--wpds-color-background-surface-neutral-strong, #fff);
	border: 1px solid var(--wpds-color-stroke-surface-neutral, #dbdbdb);
	border-radius: var(--wpds-border-radius-sm, 2px);
}


/* ── Term tree ────────────────────────────────────────────────────── */

.adminease-terms-list {
	margin: 0;
	padding: var(--wpds-dimension-padding-xs, 4px);
	list-style: none;
}

.adminease-term-item {
	margin: 0;
}

.adminease-term-label {
	display: flex;
	align-items: flex-start;
	gap: var(--wpds-dimension-gap-sm, 8px);
	padding: 3px var(--wpds-dimension-padding-sm, 8px);
	border-radius: var(--wpds-border-radius-xs, 1px);
	line-height: 1.4;
	cursor: pointer;
}

.adminease-term-label:hover {
	background: var(--wpds-color-background-surface-neutral-weak, #f4f4f4);
}

.adminease-term-label:has(input[type="checkbox"]:checked) {
	color: var(--wp-admin-theme-color, #3858e9);
	font-weight: 600;
}

.adminease-term-label input[type="checkbox"] {
	flex-shrink: 0;
	margin: 2px 0 0;
}

.adminease-term-name {
	flex: 1;
	min-width: 0;
	overflow-wrap: anywhere;
}

.adminease-hierarchy-indicator {
	color: var(--wpds-color-foreground-content-neutral-weak, #707070);
	font-family: var(--wpds-typography-font-family-mono, Menlo, Consolas, monaco, monospace);
	white-space: pre;
}

.adminease-term-count {
	flex-shrink: 0;
	color: var(--wpds-color-foreground-content-neutral-weak, #707070);
	font-family: var(--wpds-typography-font-family-mono, Menlo, Consolas, monaco, monospace);
	font-size: var(--wpds-typography-font-size-xs, 11px);
}


/* ── Search ───────────────────────────────────────────────────────── */

.adminease-taxonomy-search {
	position: relative;
	margin-bottom: var(--wpds-dimension-gap-sm, 8px);
}

/* Compact height for the sidebar column, with room for the clear button and
   the spinner stacked at the right edge. */
.adminease-taxonomy-meta-box .adminease-taxonomy-search-input {
	width: 100%;
	min-height: 32px;
	padding: 0 52px 0 8px;
	font-size: var(--wpds-typography-font-size-md, 13px);
	line-height: 30px;
}

.adminease-search-clear {
	position: absolute;
	top: 50%;
	right: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	margin-top: -10px;
	padding: 0;
	background: none;
	border: none;
	border-radius: 50%;
	color: var(--wpds-color-foreground-content-neutral-weak, #707070);
	font-size: 10px;
	line-height: 1;
	cursor: pointer;
}

.adminease-search-clear:hover {
	background: var(--wpds-color-background-surface-neutral-weak, #f4f4f4);
	color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
}

.adminease-search-clear:focus-visible {
	outline: var(--wpds-border-width-focus, 2px) solid var(--wp-admin-theme-color, #3858e9);
	outline-offset: 1px;
}

.adminease-search-spinner {
	position: absolute;
	top: 50%;
	right: 8px;
	display: none;
	width: 16px;
	height: 16px;
	margin-top: -8px;
	border: 2px solid var(--wpds-color-stroke-surface-neutral, #dbdbdb);
	border-top-color: var(--wp-admin-theme-color, #3858e9);
	border-radius: 50%;
	animation: adminease-spin 0.6s linear infinite;
}

.adminease-search-spinner.searching {
	display: block;
}

.adminease-taxonomy-search.searching .adminease-search-clear {
	display: none;
}


/* ── Pagination & controls ────────────────────────────────────────── */

.adminease-pagination-controls {
	display: flex;
	flex-direction: column;
	gap: var(--wpds-dimension-gap-sm, 8px);
	margin: var(--wpds-dimension-gap-sm, 8px) 0;
	color: var(--wpds-color-foreground-content-neutral-weak, #707070);
	font-size: var(--wpds-typography-font-size-xs, 11px);
}

.adminease-taxonomy-pagination:empty {
	display: none;
}

.adminease-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 2px;
}

.adminease-taxonomy-meta-box .adminease-pagination .button {
	min-width: 24px;
	padding: 0 6px;
	text-align: center;
}

.adminease-page-ellipsis {
	padding: 0 2px;
}

.adminease-controls-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--wpds-dimension-gap-sm, 8px);
}

.adminease-per-page-selector,
.adminease-go-to-page {
	display: flex;
	align-items: center;
	gap: var(--wpds-dimension-gap-xs, 4px);
}

.adminease-per-page-selector label,
.adminease-go-to-page label {
	margin: 0;
}

/* Compact sizing for the two controls that share the sidebar row. */
.adminease-taxonomy-meta-box .adminease-per-page-select,
.adminease-taxonomy-meta-box .adminease-goto-page-input {
	width: auto;
	min-width: 0;
	min-height: 24px;
	padding: 0 6px;
	font-size: var(--wpds-typography-font-size-xs, 11px);
	line-height: 22px;
}

.adminease-taxonomy-meta-box .adminease-per-page-select {
	padding-right: 20px;
	background-position: right 4px top 55%;
	background-size: 12px 12px;
}

.adminease-taxonomy-meta-box .adminease-goto-page-input {
	width: 56px;
}


/* ── Selected term chips ──────────────────────────────────────────── */

.adminease-selected-chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wpds-dimension-gap-xs, 4px);
	max-height: 96px;
	overflow-y: auto;
	margin-bottom: var(--wpds-dimension-gap-sm, 8px);
}

.adminease-selected-chips:empty {
	display: none;
}

.adminease-chip,
.adminease-chip-clear-all,
.adminease-popover-chip {
	display: inline-flex;
	align-items: center;
	gap: var(--wpds-dimension-gap-xs, 4px);
	max-width: 100%;
	padding: 3px 8px;
	background: var(--wpds-color-background-surface-neutral-weak, #f4f4f4);
	border: 1px solid var(--wpds-color-stroke-surface-neutral, #dbdbdb);
	border-radius: var(--wpds-border-radius-md, 4px);
	color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
	font-size: var(--wpds-typography-font-size-xs, 11px);
	line-height: 1.4;
	white-space: nowrap;
	cursor: pointer;
}

.adminease-chip:hover,
.adminease-popover-chip:hover {
	border-color: var(--wp-admin-theme-color, #3858e9);
	color: var(--wp-admin-theme-color, #3858e9);
}

.adminease-chip:focus-visible,
.adminease-chip-clear-all:focus-visible,
.adminease-popover-chip:focus-visible {
	outline: var(--wpds-border-width-focus, 2px) solid var(--wp-admin-theme-color, #3858e9);
	outline-offset: 1px;
}

.adminease-chip-text {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.adminease-chip-remove {
    position: relative;
    top: -1px;
	flex-shrink: 0;
	font-size: 13px;
	line-height: 1;
	opacity: 0.65;
}

.adminease-chip:hover .adminease-chip-remove {
	opacity: 1;
}

.adminease-chip-more {
	font-family: var(--wpds-typography-font-family-mono, Menlo, Consolas, monaco, monospace);
}

.adminease-chip-clear-all {
	margin-left: auto;
	color: #b32d2e;
}

.adminease-chip-clear-all:hover {
	border-color: #b32d2e;
}


/* ── Overflow panel ───────────────────────────────────────────────── */

.adminease-chips-popover {
	max-height: 180px;
	overflow-y: auto;
	margin-bottom: var(--wpds-dimension-gap-sm, 8px);
	background: var(--wpds-color-background-surface-neutral-strong, #fff);
	border: 1px solid var(--wpds-color-stroke-surface-neutral, #dbdbdb);
	border-radius: var(--wpds-border-radius-md, 4px);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.adminease-popover-content {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wpds-dimension-gap-xs, 4px);
	padding: var(--wpds-dimension-padding-sm, 8px);
}


/* ── Create new term link ─────────────────────────────────────────── */

.adminease-taxonomy-new-term {
	margin-top: var(--wpds-dimension-gap-sm, 8px);
}


/* ── States ───────────────────────────────────────────────────────── */

.adminease-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--wpds-dimension-gap-sm, 8px);
	height: 100%;
	padding: var(--wpds-dimension-padding-xl, 20px);
	color: var(--wpds-color-foreground-content-neutral-weak, #707070);
}

.adminease-loading::before {
	content: "";
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid var(--wpds-color-stroke-surface-neutral, #dbdbdb);
	border-top-color: var(--wp-admin-theme-color, #3858e9);
	border-radius: 50%;
	animation: adminease-spin 0.6s linear infinite;
}

.adminease-no-results,
.adminease-no-terms {
	padding: var(--wpds-dimension-padding-xl, 20px) var(--wpds-dimension-padding-md, 12px);
	color: var(--wpds-color-foreground-content-neutral-weak, #707070);
	font-style: italic;
	text-align: center;
}

.adminease-no-results p {
	margin: 0 0 var(--wpds-dimension-gap-sm, 8px);
}

.adminease-no-results a {
	font-style: normal;
}

.adminease-taxonomy-meta-box .adminease-error,
.adminease-taxonomy-meta-box .adminease-notice {
	margin: var(--wpds-dimension-gap-sm, 8px);
	padding: var(--wpds-dimension-padding-md, 12px);
	background: var(--wpds-color-background-surface-neutral-weak, #f4f4f4);
	border-left: 4px solid var(--wp-admin-theme-color, #3858e9);
	line-height: 1.5;
}

.adminease-taxonomy-meta-box .adminease-error {
	border-left-color: #d63638;
}

/* ── RTL ──────────────────────────────────────────────────────────── */

[dir="rtl"] .adminease-taxonomy-meta-box .adminease-taxonomy-search-input {
	padding: 0 8px 0 52px;
}

[dir="rtl"] .adminease-search-clear {
	right: auto;
	left: 28px;
}

[dir="rtl"] .adminease-search-spinner {
	right: auto;
	left: 8px;
}

[dir="rtl"] .adminease-taxonomy-meta-box .adminease-per-page-select {
	padding-right: 0;
	padding-left: 20px;
}

[dir="rtl"] .adminease-chip-clear-all {
	margin-right: auto;
	margin-left: 0;
}

[dir="rtl"] .adminease-taxonomy-meta-box .adminease-notice {
	border-right: 4px solid var(--wp-admin-theme-color, #3858e9);
	border-left: 0;
}

[dir="rtl"] .adminease-taxonomy-meta-box .adminease-error {
	border-right-color: #d63638;
}
