/*
 * Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
 */


.ck.ck-find-and-replace-form {
	width: 400px;
	max-width: 100%;

	/*
	 * The <form> needs tabindex="-1" for proper Esc handling after being clicked
	 * but the side effect is that this creates a nasty focus outline in some browsers.
	 */
	&:focus {
		outline: none;
	}

	/* Generic styles for the form inputs and actions. */
	& .ck-find-and-replace-form__inputs,
	& .ck-find-and-replace-form__actions {
		display: flex;
		flex: 1 1 auto;
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		align-content: stretch;

		padding: var(--ck-spacing-large);
		margin: 0;

		& > .ck-button {
			flex: 0 0 auto;
		}

		[dir="ltr"] & {
			& > * + * {
				margin-left: var(--ck-spacing-standard);
			}
		}

		[dir="rtl"] & {
			& > * + * {
				margin-right: var(--ck-spacing-standard);
			}
		}

		& .ck-labeled-field-view {
			flex: 1 1 auto;

			& .ck-input {
				width: 100%;
				min-width: 50px;
			}
		}

	}

	/* Styles specific for inputs area. */
	& .ck-find-and-replace-form__inputs {
		/* To display all controls in line when there's an error under the input */
		align-items: flex-start;

		& > .ck-button-prev > .ck-icon {
			transform: rotate(90deg);
		}

		& > .ck-button-next > .ck-icon {
			transform: rotate(-90deg);
		}

		& .ck-results-counter {
			position: absolute;
			top: 50%;
			transform: translateY(-50%);

			color: var(--ck-color-base-border);

			[dir="ltr"] & {
				right: var(--ck-spacing-standard);
			}

			[dir="rtl"] & {
				left: var(--ck-spacing-standard);
			}
		}

		& > .ck-labeled-field-replace {
			flex: 0 0 100%;
			padding-top: var(--ck-spacing-standard);

			[dir="ltr"] & {
				margin-left: 0;
			}

			[dir="rtl"] & {
				margin-right: 0;
			}
		}
	}

	/* Styles specific for actions area. */
	& .ck-find-and-replace-form__actions {
		flex-wrap: wrap;
		justify-content: flex-end;
		margin-top: calc( -1 * var(--ck-spacing-large) );

		& > .ck-button-find {
			font-weight: bold;

			/* Beef the find button up a little. It's the main action button in the form */
			& .ck-button__label {
				padding-left: var(--ck-spacing-large);
				padding-right: var(--ck-spacing-large);
			}
		}
	}

	& .ck-switchbutton {
		width: 100%;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: space-between;
		align-items: center;
	}
}

@media screen and (max-width: 600px) {
	.ck.ck-find-and-replace-form {
		width: 300px;

		/* Don't let the form overflow from the dialog (https://github.com/ckeditor/ckeditor5-commercial/issues/5913) */
		max-width: 100%;

		/* Styles specific for inputs area. */
		&.ck-find-and-replace-form__input {
			flex-wrap: wrap;

			& .ck-labeled-field-view {
				flex: 1 0 auto;
				width: 100%;
				margin-bottom: var(--ck-spacing-standard);
			}

			& > .ck-button {
				text-align: center;

				&:first-of-type {
					flex: 1 1 auto;

					[dir="ltr"] & {
						margin-left: 0;
					}

					[dir="rtl"] & {
						margin-right: 0;
					}

					& .ck-button__label {
						width: 100%;
						text-align: center;
					}
				}
			}
		}

		/* Styles specific for actions area. */
		&.ck-find-and-replace-form__actions > :not(.ck-labeled-field-view) {
			flex-wrap: wrap;
			flex: 1 1 auto;

			/* stylelint-disable-next-line no-descending-specificity */
			& > .ck-button {
				text-align: center;

				&:first-of-type {
					flex: 1 1 auto;

					[dir="ltr"] & {
						margin-left: 0;
					}

					[dir="rtl"] & {
						margin-right: 0;
					}
				}

				& .ck-button__label {
					width: 100%;
					text-align: center;
				}
			}
		}
	}
}
