/**
 * AdminEase — shared chrome for the native meta boxes.
 *
 * These boxes render inside core wp-admin screens, so they reuse the core
 * control classes (.button, .widefat, .wp-list-table, .notice) and this file
 * only adds the layout and the modal shell that wp-admin has no component for.
 * Every colour comes from the wpds token layer or from --wp-admin-theme-color,
 * so the boxes follow whatever colour scheme the user picked in their profile.
 */


/* ── Box shell ────────────────────────────────────────────────────── */

.adminease-native-box,
.adminease-modal {
	color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
	font-size: var(--wpds-typography-font-size-md, 13px);
	line-height: 1.5;
}

.adminease-native-box *,
.adminease-modal * {
	box-sizing: border-box;
}


/* ── Icons inside core buttons ────────────────────────────────────── */

.adminease-native-box .button,
.adminease-modal .button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--wpds-dimension-gap-xs, 4px);
}

.adminease-native-box .ae-icon,
.adminease-modal .ae-icon {
	flex-shrink: 0;
	width: 16px;
	height: 16px;
}

.adminease-native-box .button-small .ae-icon,
.adminease-modal .button-small .ae-icon {
	width: 12px;
	height: 12px;
}


/* ── Action row ───────────────────────────────────────────────────── */

.adminease-metadata-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wpds-dimension-gap-sm, 8px);
	justify-content: space-between;
	margin-bottom: var(--wpds-dimension-gap-sm, 8px);
}

.adminease-metadata-actions > div.col:first-child {
	display: flex;
	gap: var(--wpds-dimension-gap-xs, 4px);
}


/* ── Metadata table ───────────────────────────────────────────────── */

#adminease-metadata-table-container {
	margin-top: var(--wpds-dimension-gap-md, 12px);
}

.adminease-metadata-table td code {
	background: var(--wpds-color-background-surface-neutral-weak, #f4f4f4);
	border-radius: var(--wpds-border-radius-sm, 2px);
	padding: 2px 6px;
	font-size: var(--wpds-typography-font-size-sm, 12px);
	white-space: nowrap;
}

.adminease-metadata-table .flex {
	display: flex;
	flex-wrap: nowrap;
	gap: var(--wpds-dimension-gap-xs, 4px);
}

.adminease-metadata-table .adminease-meta-protected code {
	background: var(--wpds-color-background-surface-warning-weak, #fff7e1);
	color: var(--wpds-color-foreground-content-warning, #2e1900);
}

.adminease-metadata-table .adminease-meta-protected .ae-icon {
	color: var(--wpds-color-foreground-content-warning, #2e1900);
	vertical-align: middle;
}

.adminease-metadata-table .adminease-meta-value {
	min-height: 28px;
	margin: 0;
	padding: 3px 6px;
	overflow: auto;
	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-sm, 2px);
	font-family: var(--wpds-typography-font-family-mono, Menlo, Consolas, monaco, monospace);
	font-size: var(--wpds-typography-font-size-sm, 12px);
}

.adminease-metadata-table .adminease-meta-readonly {
	color: var(--wpds-color-foreground-content-neutral-weak, #707070);
	font-style: italic;
}


/* ── Empty and loading states ─────────────────────────────────────── */

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

#adminease-metadata-table-container .loading {
	position: relative;
	padding-right: 45px;
}

#adminease-metadata-table-container .loading::after {
	content: "";
	position: absolute;
	top: 10px;
	right: 10px;
	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-metadata-notice {
	margin: 0 0 var(--wpds-dimension-gap-sm, 8px);
}


/* ── Modal ────────────────────────────────────────────────────────── */

.adminease-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
}

.adminease-modal-overlay {
	position: absolute;
	inset: 0;
	z-index: 1;
	background: rgba(0, 0, 0, 0.7);
}

.adminease-modal-content {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	width: 90%;
	max-width: var(--wpds-dimension-surface-width-xl, 720px);
	max-height: 90vh;
	margin: 4vh auto;
	overflow: hidden;
	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-lg, 8px);
	box-shadow: 0 20px 48px -20px rgba(0, 0, 0, 0.35);
}

.adminease-modal-header {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: space-between;
	padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
	border-bottom: 1px solid var(--wpds-color-stroke-surface-neutral, #dbdbdb);
}

.adminease-modal-header h3 {
	margin: 0;
	font-size: var(--wpds-typography-font-size-lg, 15px);
	line-height: 1.4;
}

.adminease-modal-header .adminease-modal-close {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: var(--wpds-border-radius-sm, 2px);
	color: var(--wpds-color-foreground-content-neutral-weak, #707070);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

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

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

.adminease-modal-body {
	flex: 1;
	padding: var(--wpds-dimension-padding-2xl, 24px);
	overflow-y: auto;
}

.adminease-modal-footer {
	display: flex;
	flex-shrink: 0;
	gap: var(--wpds-dimension-gap-sm, 8px);
	justify-content: flex-end;
	padding: var(--wpds-dimension-padding-lg, 16px) var(--wpds-dimension-padding-2xl, 24px);
	background: var(--wpds-color-background-surface-neutral-weak, #f4f4f4);
	border-top: 1px solid var(--wpds-color-stroke-surface-neutral, #dbdbdb);
}

body.adminease-modal-open {
	overflow: hidden;
}


/* ── Modal fields ─────────────────────────────────────────────────── */

.adminease-modal-errors:empty {
	display: none;
}

.adminease-modal-errors {
	margin-bottom: var(--wpds-dimension-gap-md, 12px);
}

.adminease-field-group {
	margin-bottom: var(--wpds-dimension-gap-lg, 16px);
}

.adminease-field-group > label {
	display: block;
	margin-bottom: var(--wpds-dimension-gap-xs, 4px);
	font-weight: 600;
}

.adminease-required {
	color: #b32d2e;
}

.adminease-modal-field-desc {
	margin-bottom: 0;
}


/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 786px) {

	.adminease-metadata-table {
		font-size: var(--wpds-typography-font-size-sm, 12px);
	}

	#adminease-metadata-table-container {
		position: relative;
		overflow: auto;
	}

	#adminease-metadata-table-container table {
		min-width: 600px;
	}

	#adminease-metadata-table-container table thead th {
		width: 35%;
	}

	#adminease-metadata-table-container table thead th:first-child {
		width: 40%;
	}

	#adminease-metadata-table-container table thead th:last-child {
		width: 25%;
	}

	.adminease-modal-content {
		width: 95%;
		max-height: 94vh;
		margin: 3vh auto;
	}

	.adminease-modal-header,
	.adminease-modal-body,
	.adminease-modal-footer {
		padding: var(--wpds-dimension-padding-lg, 16px);
	}
}
