/* Patterns - Interaction - MonthPicker */
////
/// @group Patterns-MonthPicker
/// Patterns - Interaction - MonthPicker

/// Import Flatpickr library styles
@use 'provider/flatpickr';
@use "../../../tokens/variables";

///
.osui-monthpicker {
	// ─── Component CSS API ─────────────────────────────────────────────
	--osui-monthpicker-disabled-background: var(--color-background-input-disabled);
	--osui-monthpicker-disabled-border-color: var(--color-border);
	--osui-monthpicker-disabled-color: var(--color-text-disabled);
	--osui-monthpicker-input-border-radius: var(--border-radius-xs, #{variables.$token-shape-soft-xs});
	--osui-input-border-radius: var(--osui-monthpicker-input-border-radius);
	// ───────────────────────────────────────────────────────────────────

	// Service Studio Preview Container Styles
	&-ss-preview {
		display: none;

		// Service Studio Preview
		& {
			-servicestudio-display: inline-block;
			-servicestudio-margin-top: 2px;
			-servicestudio-overflow: hidden;
			-servicestudio-position: relative;
			-servicestudio-z-index: var(--layer-local-tier-1);

			& + .placeholder-ss-preview {
				-servicestudio-height: 0;
				-servicestudio-opacity: 0;
				-servicestudio-overflow: hidden;
				-servicestudio-width: 100%;
			}

			&:before,
			&:after {
				-servicestudio-color: var(--color-primary);
				-servicestudio-font-family: var(--osui-icon-font-family);
				-servicestudio-font-size: clamp(20px, 1.7vw, 20px);
				-servicestudio-position: absolute;
				-servicestudio-height: 34px;
				-servicestudio-padding-top: 3%;
				-servicestudio-top: 0;
			}

			&:before {
				-servicestudio-content: var(--osui-icon-arrow-left);
				-servicestudio-padding-right: 16%;
				-servicestudio-right: 0;
			}

			&:after {
				-servicestudio-content: var(--osui-icon-arrow-right);
				-servicestudio-padding-right: 8%;
				-servicestudio-right: 0;
			}
		}
	}

	.not-valid + .input,
	.not-valid + .flatpickr-mobile {
		border-color: variables.$token-semantics-danger-base;
	}

	input {
		// Disable states for Datepicker
		&[disabled] + input {
			background-color: var(--osui-monthpicker-disabled-background);
			border: variables.$token-border-size-025 solid var(--osui-monthpicker-disabled-border-color);
			color: var(--osui-monthpicker-disabled-color);
			pointer-events: none;
		}

		// Hide the platform input which is set as hidden by the library and we're change it into the expected type, however we do not want it visible since library will add a clone to better deal with the selected dates.
		// We cannot use the provider class since the provider class will not be taken into consideration on the input widget react lifecycle
		&:first-of-type:not(.flatpickr-calendar.inline input) {
			display: none;

			// Make the platform input visible in Service Studio
			& {
				-servicestudio-display: inline-flex !important;
			}
		}
	}
}

///
.form {
	// Service Studio Preview
	.osui-monthpicker-ss-preview {
		-servicestudio-margin-top: -22px;
	}
}
