@use "../variables" as *;

/**
 * Settings history dialog
 */
.tsc-settings-history {
	/**
	 * The History button: tertiary, without the border core gives tertiary buttons
	 */
	&__button.components-button.is-tertiary {
		border-color: transparent;
	}

	/**
	 * The dialog: 640px wide from the small breakpoint up; below it, the modal is full-screen
	 */
	&__modal {
		@media (min-width: 600px) {
			width: 640px;
		}

		/**
		 * The header holds the title and the close button, with the plugin's name under them.
		 * Core fixes it at 72px and positions it absolutely; it sticks to the top of the
		 * scrolling content instead, so its height follows the subtitle, which can wrap.
		 */
		.components-modal__header {
			background: #fff;
			display: grid;
			grid-template-columns: minmax(0, 1fr) auto auto;
			height: auto;
			margin: 0 -24px 16px;
			padding: 24px 24px 16px;
			position: sticky;
			row-gap: 4px;
			width: auto;
		}

		.components-modal__content {
			display: flex;
			flex-direction: column;
			margin-top: 0;
			padding-bottom: 0;
			padding-top: 0;
		}
	}

	&__subtitle {
		grid-column: 1 / -1;
		grid-row: 2;
		margin: 0;
	}

	&__body {
		display: flex;
		flex: 1 1 auto;
		flex-direction: column;
		gap: 16px;
		padding-bottom: 24px;

		p {
			margin: 0;
		}

		.components-notice {
			margin: 0;
		}
	}

	&__muted {
		color: $text-color--gray;
	}

	&__note {
		font-size: 12px;
	}

	/**
	 * List of entries
	 */
	&__entries {
		list-style: none;
		margin: 0;
		padding: 0;
	}

	&__entry {
		border-bottom: 1px solid $border-color;
		margin: 0;
	}

	&__entry-row {
		align-items: flex-start;
		display: flex;
		flex-wrap: wrap;
		gap: 8px 16px;
		padding: 12px 0;
	}

	&__entry-toggle {
		align-items: flex-start;
		background: transparent;
		border: 0;
		border-radius: 2px;
		color: inherit;
		cursor: pointer;
		display: flex;
		flex: 1 1 300px;
		font: inherit;
		gap: 12px;
		margin: 0;
		min-width: 0;
		padding: 2px 0;
		text-align: left;

		&:focus-visible {
			outline: 2px solid $wp-admin--theme-color;
			outline-offset: 2px;
		}
	}

	&__entry-text {
		display: flex;
		flex: 1 1 auto;
		flex-direction: column;
		gap: 2px;
		min-width: 0;
	}

	&__entry-meta {
		align-items: baseline;
		display: flex;
		flex-wrap: wrap;
		gap: 2px 6px;
	}

	&__chevron {
		flex: 0 0 24px;
		fill: currentColor;
		margin-top: 4px;
	}

	&__entry-action {
		align-items: center;
		display: flex;
		margin-left: auto;
		min-height: 32px;
	}

	&__entry-details {
		display: flex;
		flex-direction: column;
		gap: 12px;
		padding: 0 0 16px 44px;

		&[hidden] {
			display: none;
		}

		> p {
			font-size: 12px;
		}
	}

	&__badge {
		align-items: center;
		background: $wp-admin--blue-0;
		border-radius: 2px;
		color: $wp-admin--theme-color-darker-10;
		display: inline-flex;
		font-size: 12px;
		font-weight: 500;
		height: 24px;
		padding: 0 8px;
		white-space: nowrap;
	}

	/**
	 * Who made a change
	 */
	&__actor-badge {
		align-items: center;
		background: $background-color--gray;
		border-radius: 50%;
		display: flex;
		flex: 0 0 32px;
		height: 32px;
		justify-content: center;
		width: 32px;

		svg {
			fill: currentColor;
		}
	}

	&__actor-name {
		font-weight: 600;
	}

	/**
	 * Changes, by section
	 */
	&__sections {
		display: flex;
		flex-direction: column;
		gap: 16px;
	}

	&__section-title {
		color: $text-color--gray;
		font-size: 11px;
		font-weight: 600;
		letter-spacing: 0.04em;
		line-height: 16px;
		margin: 0 0 6px;
		text-transform: uppercase;
	}

	&__changes {
		display: flex;
		flex-direction: column;
		gap: 6px;
		list-style: none;
		margin: 0;
		padding: 0;
	}

	&__change {
		align-items: center;
		display: flex;
		flex-wrap: wrap;
		gap: 4px 8px;
		margin: 0;
	}

	&__change-icon {
		align-items: center;
		border-radius: 50%;
		display: inline-flex;
		flex: 0 0 20px;
		height: 20px;
		justify-content: center;
		width: 20px;

		svg {
			fill: currentColor;
		}

		&--added {
			background: #e9f6ec;
			color: $text-color--green;
		}

		&--removed {
			background: #fcf0f1;
			color: $text-color--red;
		}

		&--changed {
			background: #fdf3e1;
			color: $wp-admin--yellow-50;
		}

		&--reordered {
			background: $wp-admin--blue-0;
			color: $wp-admin--theme-color;
		}
	}

	&__change-kind {
		font-weight: 600;
		min-width: 68px;
	}

	&__change-label {
		flex: 1 1 140px;
		min-width: 0;
	}

	&__change-values {
		color: $text-color--gray;
		overflow-wrap: anywhere;
	}

	&__change-blocked {
		align-items: center;
		display: inline-flex;
		font-size: 12px;
		gap: 4px;

		svg {
			fill: currentColor;
		}
	}

	/**
	 * Restore confirmation
	 */
	&__confirmation {
		display: flex;
		flex-direction: column;
		gap: 20px;

		> p {
			font-size: 12px;
		}
	}

	&__target {
		align-items: flex-start;
		background: $wp-admin--gray-0;
		border-radius: 4px;
		display: flex;
		gap: 12px;
		padding: 12px 16px;

		.tsc-settings-history__actor-badge {
			background: #fff;
		}
	}

	&__target-text {
		display: flex;
		flex-direction: column;
		gap: 2px;
		min-width: 0;

		> p:first-child {
			font-size: 12px;
		}
	}

	&__diff-header {
		align-items: baseline;
		display: flex;
		flex-wrap: wrap;
		gap: 2px 12px;
		justify-content: space-between;
		margin-bottom: 8px;

		> span {
			font-size: 12px;
		}
	}

	&__diff-title {
		font-size: 14px;
		font-weight: 600;
		line-height: 20px;
		margin: 0;
	}

	&__no-differences {
		border: 1px dashed $border-color--darker;
		border-radius: 2px;
		color: $text-color--gray;
		padding: 16px;
	}

	&__footer {
		align-items: center;
		background: #fff;
		border-top: 1px solid $border-color;
		bottom: 0;
		display: flex;
		flex-wrap: wrap;
		gap: 8px;
		justify-content: flex-end;
		margin: 0 -32px;
		padding: 16px 32px;
		position: sticky;

		@media (max-width: 599px) {
			margin: 0 -16px;
			padding: 16px;
		}
	}

	/**
	 * Loading, error and empty states
	 */
	&__loading {
		align-items: center;
		color: $text-color--gray;
		display: flex;
		flex-direction: column;
		gap: 12px;
		padding: 56px 0;

		.components-spinner {
			margin: 0;
		}
	}

	&__error {
		align-items: flex-start;
		display: flex;
		flex-direction: column;
		gap: 16px;

		.components-notice {
			align-self: stretch;
		}
	}

	&__empty {
		align-items: center;
		display: flex;
		flex-direction: column;
		gap: 8px;
		padding: 48px 0;
		text-align: center;

		svg {
			fill: $text-color--gray;
		}

		p {
			max-width: 420px;
		}
	}

	&__empty-title {
		font-size: 15px;
		font-weight: 600;
		line-height: 22px;
		margin: 4px 0 0;
	}
}
