@use "../tokens/variables";

////
/// @group Layout
/// Layout

// OutSystems UI only supports viewport-fit=cover, so 100vh already reflects the full visual
// viewport here; dynamic viewport units (dvh/svh/lvh) are intentionally not used.
html {
	height: 100vh;
}

body,
#reactContainer,
#transitionContainer,
.screen-container {
	height: 100%;
}

///
.screen-container {
	overflow-x: hidden;
	overflow-y: auto;
}

///
.layout {
	display: flex;
	min-height: 100vh;

	&.layout {
		&-top,
		&-side:not(.layout-native) {
			flex-direction: column;
		}

		&-left {
			flex-direction: row;
		}

		&-side {
			// ─── Component CSS API ─────────────────────────────────────────────
			--osui-layout-aside-lines: #{variables.$token-border-size-025} solid #{variables.$token-border-subtle};
			// ───────────────────────────────────────────────────────────────────

			.main {
				margin-inline-start: var(--side-menu-size);
			}

			&.aside-overlay .main {
				margin-inline-start: 0;
			}

			.app-menu-content {
				border-inline-end: var(--osui-layout-aside-lines);
			}

			.app-menu-links {
				gap: variables.$token-space-200;
			}

			.app-login-info {
				border-block-start: var(--osui-layout-aside-lines);
			}
		}

		&-side-no-header {
			.menu-icon {
				margin-block: variables.$token-space-400;
				margin-inline: variables.$token-space-600;
			}
		}

		&-native {
			// Service Studio Preview
			& {
				-servicestudio-min-height: 100vh !important;
			}

			.main {
				width: 100%;
			}
		}
	}

	&.aside-expandable {
		.main {
			margin-inline-start: 0;
		}
	}

	.main {
		display: flex;
		flex: 1;
		flex-direction: column;
	}
}

.main,
.fixed-header .main {
	padding-block-start: 0;
}

///
.layout-native,
.layout-top {
	.aside-navigation {
		// Service Studio Preview
		& {
			-servicestudio-display: none !important;
		}
	}
}

// android

.android {
	.layout-native {
		.footer {
			height: calc(var(--safe-area-inset-bottom, 0px) + var(--bottom-bar-size));
		}
	}
}

// iOS ---------------------------------------------------------------------------
///
.ios {
	.layout {
		min-height: 100%;

		&-native .footer {
			height: calc(var(--os-safe-area-bottom) + var(--bottom-bar-size));
		}

		.header {
			padding-top: var(--os-safe-area-top);
		}
	}
}

// Responsive --------------------------------------------------------------------
///
.desktop,
.tablet {
	.layout-native {
		&.aside {
			&-visible,
			&-expandable {
				--side-menu-size: 264px;
			}
		}
	}
}

///
.desktop {
	.layout-native {
		&.aside {
			&-visible,
			&-expandable {
				.main {
					width: calc(100% - var(--side-menu-size));
				}
			}
		}
	}
}

///
.tablet {
	&.landscape {
		.layout-native {
			&.menu-visible {
				&.aside {
					&-visible,
					&-expandable {
						.main {
							margin-inline-start: var(--side-menu-size);
							width: calc(100% - var(--side-menu-size));
						}
					}
				}
			}
		}

		.layout-side.layout-native.aside-expandable {
			&.menu-visible .main {
				margin-inline-start: var(--side-menu-size);
			}

			.main {
				margin-inline-end: 0;
			}
		}
	}
}

///
.tablet,
.phone {
	.layout-side .main {
		margin-inline-start: 0;
	}
}

// Follows the 16px page gutter.
///
.tablet .layout-side-no-header .menu-icon,
.phone .layout-side-no-header .menu-icon {
	margin-inline: variables.$token-space-400;
}

// Nested layout SS preview
///
.layout .main-content .layout {
	-servicestudio-min-width: calc(100vw - (variables.$token-scale-1000 * 2));
}

.phone .layout .main-content .layout {
	-servicestudio-min-width: calc(100vw - (variables.$token-scale-400 * 2));

	&.layout-native {
		-servicestudio-min-width: 100vw;
	}
}
