/**
 * Per-post access restriction panel + modal.
 */
// TinyMCE appends link dialogs to body, outside the WordPress modal.
body:has(.arraysubs-restriction-modal) {
	.mce-floatpanel {
		z-index: 100100 !important;
	}

	#mce-modal-block {
		z-index: 100099 !important;
	}
}

.arraysubs-restriction-panel {
	&__summary {
		margin: 0 0 12px;
		font-size: 12px;
	}

	&__row {
		display: flex;
		gap: 8px;
		justify-content: space-between;
		padding: 4px 0;
		border-bottom: 1px solid #f0f0f0;

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

		dt {
			flex: 0 0 auto;
			color: #757575;
		}

		dd {
			margin: 0;
			text-align: right;
			font-weight: 600;
			overflow-wrap: anywhere;
		}
	}

	&__empty {
		margin: 0 0 12px;
		font-size: 12px;
		color: #757575;
	}

	&__configure {
		width: 100%;
		justify-content: center;
		margin-top: 8px;
	}
}

.arraysubs-restriction-modal {
	&.components-modal__frame {
		width: calc(100% - 32px);
		max-width: 1280px;
		height: calc(100dvh - 32px);
		max-height: calc(100dvh - 32px);
		margin: 16px auto;
		border-radius: 8px;

		@media (min-width: 600px) {
			width: calc(100% - 48px);
		}
	}

	.components-modal__content,
	.components-modal__children-container {
		display: flex;
		flex-direction: column;
		min-height: 0;
	}

	.components-modal__content {
		padding: 0;
		overflow: hidden;
	}

	.components-modal__children-container {
		flex: 1;
	}

	.arraysubs-restriction-fields {
		flex: 1;
		min-height: 0;
		padding: 4px 24px 16px;
		overflow-y: auto;
	}

	.components-form-token-field__input-container,
	.components-combobox-control__suggestions-container {
		position: relative;
	}

	.components-form-token-field__suggestions-list {
		position: absolute;
		z-index: 10;
		top: 100%;
		right: 0;
		left: 0;
		box-sizing: border-box;
		border: 1px solid var(--wp-components-color-gray-600, #949494);
		background: var(--wp-components-color-background, #fff);
		box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
	}

	// The final picker opens above its input to stay inside the scrolling form.
	.arraysubs-restriction-fields__section--plan-feature .components-form-token-field__suggestions-list {
		top: auto;
		bottom: 100%;
	}

	&__actions {
		display: flex;
		flex-shrink: 0;
		justify-content: flex-end;
		gap: 8px;
		padding: 16px 24px;
		border-top: 1px solid #e0e0e0;
	}
}

.arraysubs-restriction-fields {
	.components-notice {
		margin: 12px 0;
		border-radius: 2px;
	}

	&__section {
		margin-top: 12px;
		padding: 12px;
		border: 1px solid var(--wp-components-color-gray-300, #c3c4c7);
		border-radius: 2px;
	}

	&__section-title {
		margin: 0 0 12px;
		font-size: 13px;
		font-weight: 600;
		line-height: 1.4;
	}

	&__section-content {
		> .components-form-token-field,
		> .components-base-control,
		> .arraysubs-control-note {
			margin-bottom: 16px;
		}

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

	.arraysubs-control-note {
		margin: 0 0 12px;
		font-size: 12px;
		font-style: italic;
		color: #757575;
	}
}

.arraysubs-post-restriction-metabox {
	.components-base-control {
		margin-bottom: 12px;
	}
}
