/**
 * The following styles get applied inside the editor only.
 */

@import url(@wordpress/dataviews/build-style/style.css);

.remote-data-blocks-loading-overlay {
	align-items: center;
	background-color: rgba(255, 255, 255, 0.25);
	display: flex;
	height: 100%;
	justify-content: center;
	left: 0;
	pointer-events: none;
	position: absolute;
	top: 0;
	width: 100%;
	z-index: 1;
}

.remote-data-blocks-button-group {
	display: flex;
	gap: 0.75em;
}

.remote-data-blocks-existing-item,
.remote-data-blocks-meta-item,
.remote-data-blocks-new-item {
	margin: 1em 0;
}

h4.remote-data-blocks-new-item-heading {
	margin: 0.5em 0;
}

// Block previews inside selector modals
.remote-data-blocks-modal {
	// Column gap
	.wp-block-columns {
		gap: 2em;
	}
}

/* Inline bindings */

remote-data-blocks-inline-field {
	background-color: #bfdbfe;
	border-radius: 0.5rem;
	padding: 0.15rem 0.35rem;
}

.rich-text:focus remote-data-blocks-inline-field[data-rich-text-format-boundary] {
	background-color: #bae6fd;
	border-radius: 0.5rem;
}

.remote-data-blocks-inline-field-choice-link {
	color: #00f;
	cursor: pointer;
	text-decoration: underline;
}

.remote-data-blocks-inline-field-selected-icon {
	display: inline-block;
	height: 20px;
	vertical-align: bottom;
	width: 20px;
}

/* DataViews */

// fix title field overflow for grid layouts
.dataviews-view-grid__title-field {
	white-space: normal;
}

// limit image size
.dataviews-column-primary__media img {
	width: 52px;
	height: 52px;
	object-fit: cover;
	border-radius: 4px;
	background-color: #f0f0f0;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

// fix field width to limit horizontal scrolling
.rdb-editor_dataviews-modal-item-select .dataviews-view-table tbody .dataviews-view-table__row:not(.has-bulk-actions) .dataviews-view-table__cell-content-wrapper:not(.dataviews-column-primary__media) {
	white-space: normal;
	width: 250px;
	max-width: 100%;
	min-width: 150px;
	overflow-wrap: anywhere;
}

// hide actions column
.dataviews-view-table__row .dataviews-view-table__actions-column .components-button.is-compact.has-icon:not(.has-text) {
	opacity: 0;
	display: inline-flex;
	align-items: center;
	background: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
	color: var(--wp-components-color-accent-inverted, #fff);
	height: 32px;
	padding: 6px 12px;
	border-radius: 2px;
	width: auto;
}

// show actions column on hover
.dataviews-view-table__row:hover .dataviews-view-table__actions-column .components-button.is-compact.has-icon:not(.has-text),
.dataviews-view-table__row:focus-within .dataviews-view-table__actions-column .components-button.is-compact.has-icon:not(.has-text) {
	opacity: 1;

}

// center table cell content
.dataviews-view-table tbody td {
	vertical-align: middle;
}

// align padding with designs

.rdb-dataviews-bulk-actions-modal .components-modal__content {
	scroll-padding-bottom: 121px;
	max-height: calc(100% - 121px);

	@media screen and (min-width: 782px) {
		scroll-padding-bottom: 88px;
		max-height: calc(100% - 88px);
	}

	.dataviews-view-table tr td:first-child,
	.dataviews-view-table tr th:first-child {
		padding-left: 32px;
	}

	// custom total item count actions
	.rdb-dataviews-bulk-actions-footer__selection-total {
		position: fixed;
		bottom: 0;
		right: 0;
		padding: 0 32px 24px;
		z-index: 3;

		@media screen and (min-width: 782px) {
			width: auto;
		}
	}

	// hide bulk actions in footer
	.dataviews-footer {
		padding: 24px 32px 0;
		position: fixed;
		bottom: 64px;
		left: 0;
		right: 0;

		@media screen and (min-width: 782px) {
			bottom: 0;
			height: 88px;
			padding-bottom: 24px;
		}

		.dataviews-bulk-actions-footer__container  .dataviews-bulk-actions-footer__action-buttons {
			display: none;
		}

	}

}

.rdb-editor_dataviews-modal-item-select .components-modal__content {
	padding: 0;
	margin-top: 0;

	// keep header static
	.components-modal__header {
		background-color: #fff;
		position: sticky;
	}

	.dataviews__view-actions,
	.dataviews-filters__container {
		padding-left: 32px;
		padding-right: 32px;
	}

	// align padding with modal
	.dataviews-view-grid {
		padding-left: 32px;
		padding-right: 32px;
	}

	.dataviews-view-table {
		padding: 4px 32px 32px;

		// make actions column sticky
		tr th.dataviews-view-table__actions-column,
		tr td.dataviews-view-table__actions-column {
			position: sticky;
			right: 0;
			background: #fff;
			z-index: 1;
			padding-left: 32px;
			padding-right: 32px;
			text-align: center;
		}

		td.dataviews-view-table__actions-column::before {
			content: "";
			position: absolute;
			top: 0;
			left: -1px;
			width: 1px;
			height: 100%;
			background-color: #f0f0f0;
			z-index: 2;
		}
	}


}

// add spacing below table
.rdb-editor_dataviews-modal-item-select:not(.rdb-dataviews-bulk-actions-modal) .dataviews-view-table {
	margin-bottom: 48px;
}

// remove border on modal header when scrolled
.components-modal__content.has-scrolled-content:not(.hide-header) .components-modal__header {
	border: none;
}

// Mirror the Gutenberg helper text style for the RDB block
.rdb-block-helper-text {
	font-size: 0.75rem;
	color: rgb(117, 117, 117);
}
