////
/// @group Functions
/// Global Functions

/// Returns the safe area value with fallback for both env() and CSS variable
/// @param {String} $side - The side (top, right, bottom, left)
/// @return {String} - The max() expression with env() and CSS variable fallback
@function safe-area($side) {
	@return unquote('max(env(safe-area-inset-#{$side}), var(--safe-area-inset-#{$side}, 0px))');
}

/// Returns the safe area top value for specifically for Android devices.
/// @return {String} - The max() expression with current variable and new CSS variable
@function android-safe-area-top() {
	@return unquote('max(var(--status-bar-height, 0px), var(--safe-area-inset-top, 0px))');
}

/// Returns the app settings background color for a given part name
/// @param {String} $partName - The part name (header, body, login)
/// @param {String} $defaultColorValue - The default color value
/// @return {String} - The app settings background color
@function get-app-settings-background-color($partName, $defaultColorValue) {
	@return var(--background-color-#{$partName}, var(#{$defaultColorValue}));
}

/// Returns the background color for a given color name
/// @param {String} $colorName - The color name
/// @return {String} - The background color
@function get-background-color($colorName) {
	@if ($colorName == 'transparent') {
		@return transparent;
	}
	@if ($colorName == 'overlay') {
		@return var(--background-color-overlay, var(--overlay-background));
	}
	@return var(--background-color-#{$colorName}, var(--color-#{$colorName}));
}

/// Returns the border color for a given color name
/// @param {String} $colorName - The color name
/// @return {String} - The border color
@function get-border-color($colorName) {
	@if ($colorName == 'transparent' or $colorName == 'currentColor') {
		@return unquote($colorName);
	}
	@return var(--border-color-#{$colorName}, var(--color-#{$colorName}));
}

/// Returns the text color for a given color name
/// @param {String} $colorName - The color name
/// @return {String} - The text color
@function get-text-color($colorName) {
	@return var(--text-color-#{$colorName}, var(--color-#{$colorName}));
}
