// Forms list (DataViews look over WP_List_Table). Built by `npm run build` into build/forms.css.
// The panel, row title and shared table rules are in _components.scss. Type is the wp-admin
// system font stack, inherited; nothing here sets a font family.
@use "tokens" as *;
@use "components";

.cf7hs-ui {
	&__conn { font-size: 13px; color: #007017; }
	&__conn.is-off { color: $text-muted; }

	// Rows.
	&__row-top { display: block; }
	&__mobile-status, &__mobile-meta, &__mobile-action { display: none; }
	&__none { color: $text-muted; }
	&__targets { display: flex; flex-wrap: wrap; gap: $grid-unit-05; }
	&__targets .cf7hs-ui__badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

	// The row's two buttons: the mapping (one width for Set up / Edit) and Edit in CF7.
	// No display here: the phone copy in the Form cell must stay hidden on desktop.
	&__row-buttons { flex-wrap: nowrap; gap: $grid-unit-10; }
	&__row-buttons .button { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: $button-size-compact; margin: 0; white-space: nowrap; }
	&__row-buttons .button:first-child { min-width: 128px; }

	// Bulk bar: always shown without JavaScript; with it, only while rows are checked, in place of the views.
	&__bulkbar {
		order: 2;
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: $grid-unit-10;
		padding-block: $grid-unit-10;

		.button { min-height: $button-size-compact; }
	}
	&__selcount { font-size: 13px; color: $gray-900; padding-inline: $grid-unit-10; }
	&__selcount + .button { margin-inline-start: 0; }
	.button-link.cf7hs-ui__clearsel { margin-inline-start: $grid-unit-05; font-size: 13px; }

	&__panel.has-js:not(.is-selecting) &__bulkbar { display: none; }
	&__panel.is-selecting {
		.tablenav.top { background: $row-selected; box-shadow: inset 0 -1px 0 #c5d9ed; }
		.cf7hs-ui__views-nav { display: none; }
		.cf7hs-ui__selcount { font-weight: 600; }
	}

	// Table: the shared rules are in _components.scss; these are the Forms columns.
	.wp-list-table {
		table-layout: fixed;

		thead th.sortable a, thead th.sorted a {
			display: inline-flex;
			align-items: center;
			gap: $grid-unit-05;
			padding: 0;
			color: $gray-900;
		}
		thead th.sortable a:focus, thead th.sorted a:focus { box-shadow: none; outline: $focus-width solid $accent; outline-offset: 2px; }

		tbody > tr > * { vertical-align: middle; }
		tbody > tr:hover > * { background: $row-tint; }
		tbody > tr.is-selected > * { background: $row-selected; }

		// Checkbox column: the box sits on the row's middle, and the row line runs under it too.
		.check-column { width: 44px; box-sizing: border-box; padding-block: 0; padding-inline: $grid-unit-20 0; vertical-align: middle; }
		.check-column input[type="checkbox"] { margin: 0; vertical-align: middle; }

		.column-sync { width: 132px; }
		.column-targets { width: 250px; }
		.column-actions { width: 236px; padding-inline-end: $grid-unit-20; text-align: end; }
		.column-actions .cf7hs-ui__row-buttons { display: inline-flex; }

		.no-items td { padding: 28px $grid-unit-20; text-align: center; color: $text-muted; }
	}
	&__nores { color: $gray-900; }

	// Between phone and wide desktop, narrower side columns leave Form room for its title.
	@media (min-width: 783px) and (max-width: 1280px) {
		.wp-list-table {
			.column-sync { width: 112px; }
			.column-targets { width: 140px; }
		}
	}

	@media (max-width: 782px) {
		&__bulkbar {
			padding-inline: $grid-unit-15;

			.button, .button-link.cf7hs-ui__clearsel { min-height: $button-size-next-default-40px; }
		}

		// One cell per row: Form carries the status, "N fields · targets" and the actions.
		.wp-list-table {
			thead .column-sync, thead .column-targets, thead .column-actions,
			.toggle-row { display: none; }

			.check-column { width: 52px; padding-block: 14px 0; padding-inline: $grid-unit-15 0; vertical-align: top; }
			thead .check-column { padding-block: 10px; vertical-align: middle; }
			thead th.column-primary { vertical-align: middle; }
		}
		&__row-top { display: flex; align-items: flex-start; justify-content: space-between; gap: $grid-unit-15; }
		&__row-title { font-size: 15px; line-height: 1.4; }
		&__row-sub { display: none; }
		&__mobile-status { display: block; flex: none; }
		&__mobile-meta { display: block; margin-block-start: 2px; font-size: 13px; color: $text-muted; overflow-wrap: anywhere; }
		// Both buttons side by side, half the row each.
		&__mobile-action { display: flex; margin-block-start: $grid-unit-15; }
		&__mobile-action .button { flex: 1 1 0; min-width: 0; min-height: $button-size-next-default-40px; }
	}

	@media (forced-colors: active) {
		.wp-list-table tbody > tr.is-selected > * { outline: 1px solid Highlight; outline-offset: -1px; }
	}
}
