@use "sass:math";

@use "sass:color";

@import 'theme/theme_variables';

$defaultPadding: 8px;
$maxEntryWidth: 48px;
$maxEntryHeight: 48px;
$entriesLimit: 6;
$header-height: 48px;
$border: 1px solid rgba(0, 0, 0, 0.125);

@mixin defaultSquare($activeColor) {
	border: 0;
	padding: 8px;
	width: $maxEntryWidth;
	height: $maxEntryHeight;
	justify-content: center;
	align-items: center;
	display: flex;
	background-color: $activeColor;
}

.visualization-result {
	text-align: center;
	font-size: 24px;
	padding: 30px 10px;
	border: 1px solid #4e5d6c;
}

.production-nav-tabs {
	border-bottom: 0;

	.nav-item {
		// for proper border color match with card content
		background-color: $gray-200;

		&:hover {
			background-color: $gray-700;
		}

		.nav-link {
			@include defaultSquare(inherit);

			&.active {
				background-color: $primary !important;
			}
		}

		// for proper border color match with card content
		&.new-tab {
			.nav-link {
				background-color: $success;
			}
		}
	}
}

.production-input {
	border: 0;

	.nav.nav-tabs {
		.nav-item:hover {
			background-color: $gray-700;
		}
	}

	.production-input-table {
		width: 100%;

		tr {
			td:nth-child(1) {
				width: 25px;
			}

			td:nth-child(2) {
				width: 40%;
			}

			td:nth-child(3) {
				width: 20%;
			}

			td:nth-child(4) {
				width: 25%;
			}
		}
	}

	.input-table {
		width: 100%;

		tr {
			td:nth-child(1) {
				width: 25px;
			}

			td:nth-child(2) {
				width: 40%;
			}

			td:nth-child(3) {
				width: 30%;
			}
		}
	}

	& > .card-header {
		padding: 0;
		min-height: $header-height;
		vertical-align: middle;
		background: $primary;
		border-bottom: 0;

		.production-line-name {
			display: flex;
			align-items: center;
			font-size: 24px;

			input {
				display: inline-block;
				max-width: 50%;
			}
		}

		.production-line-name-title span {
			margin-left: 15px;
			font-size: 24px;
		}

		.production-image {
			.image-picker {
				@include defaultSquare($primary);

				&:hover {
					background-color: color.adjust($primary, $lightness: -10%, $space: hsl);
					cursor: pointer;
				}

				span {
					&.fas {
						margin-left: 4px
					}
				}

				item-icon {
					margin-left: 4px
				}
			}

			.dropdown-toggle:after {
				border: 0;
			}

			align-items: center;

			.dropdown-menu {
				.dropdown-menu-content {
					display: flex;
					position: relative;
					flex-direction: row;
					flex-wrap: wrap;
					max-width: ($maxEntryWidth * $entriesLimit) + 2 * $defaultPadding;
					padding: $defaultPadding;
					max-height: 30vh;

					.dropdown-item {
						flex: math.div(100, $entriesLimit) ($maxEntryWidth - $defaultPadding);
						max-width: $maxEntryWidth;
						padding: $defaultPadding;

						&.active, &:hover {
							background-color: $primary;
						}
					}
				}
			}
		}

		.btn-group {
			display: flex;

			.btn {
				display: flex;
				width: $header-height;
				align-items: center;
				justify-content: center;

				span:before {
					font-size: 18px;
				}
			}
		}
	}
}

.card-header-with-buttons {
	display: flex;
	padding: 0;
	height: $header-height;
	background-color: transparent;

	.card-header-text {
		display: flex;
		align-items: center;
		margin-left: 20px;
		margin-right: 10px;
		font-size: 20px;
		flex-grow: 1;
	}

	.btn-group {
		height: 100%;
		display: flex !important;

		.btn {
			display: flex !important;
			min-width: $header-height;
			align-items: center;
			justify-content: center;
		}
	}
}

.recipe-list-card {
	vertical-align: middle;

	background-color: transparent;
	border: 1px solid $gray-700;

	.card-header, .card-body {
		background-color: transparent;
	}

	.card-header {
		padding: 0;
		height: $header-height;
	}

	.recipe-list-card-title {
		margin-left: 20px;
		margin-right: 10px;
		display: flex;
		align-items: center;
		font-size: 20px;
	}

	input {
		margin-top: 4px;
		margin-right: 10px;
		background-color: $gray-400;

		&:focus {
			background-color: $gray-300;
		}
	}

	.btn-group {
		display: flex !important;

		.btn {
			display: flex !important;
			min-width: $header-height;
			align-items: center;
			justify-content: center;
		}
	}
}

.alternate-recipe-list {
	width: 100%;

	tr:not(.table-row-header):hover {
		cursor: pointer;
		background-color: $gray-700;
	}

	tr.disabled {
		color: $gray-600;
		text-decoration: line-through;
	}

	td {
		padding: 2px;
		.recipe-item {
			margin-left: 7px;

			img {
				margin-left: 3px;
			}
		}
	}

	td:nth-child(1) {
		padding-left: 6px;
		width: 28px;
	}
}

.production-item-picker {
	.ui-select-toggle, .form-control {
		background-color: $gray-300;
	}

	.ui-select-choices {
		display: block;

		.ui-select-choices-row-inner {
			color: $gray-100;

			&:hover {
				background-color: $primary !important;
				color: $gray-100;
			}
		}
	}

	i.caret {
		top: 25% !important;
	}

	i.caret:before {
		color: $gray-200;
		font-style: normal;
		font-weight: 900;
		font-family: "Font Awesome 5 Free";
		content: "\f078";
	}

	.ui-select-placeholder {
		display: inline-block !important;
		color: $gray-600 !important;
	}

	.ui-select-placeholder.ng-hide {
		display: none !important;
	}

	.ui-select-match-text {
		color: $gray-700;

		span {
			margin-right: 15px;
		}
	}
}

.item-list {
	width: 100%;

	tbody {
		tr:not(.table-row-header):hover {
			background-color: $gray-700;
		}
	}

	td {
		width: 50%;

		&:nth-child(1) {
			padding-left: 10px;
			cursor: pointer;
		}
	}
}

.result-nav {
	.nav-link {
		padding-top: 0.75rem;
		padding-bottom: 0.75rem;
		font-size: 1.15rem;
	}

	border-left: 1px solid #4e5d6c;
	border-right: 1px solid #4e5d6c;
}

.table-cell-micro {
	width: 48px;
}

.table-cell-adjust-size {
	width: 1px;
	white-space: nowrap;
}

.table-row-separator td {
	border-bottom: 2px solid $table-border-color;
}

.table-row-separator-double td {
	border-bottom: 2px solid $table-border-color;
}

.table-row-separator-above td {
	border-top: 2px solid $table-border-color;
}

.alt-recipe-row td {
	.recipe-item {
		margin-left: 7px;

		img {
			margin-left: 3px;
		}
	}
}

.visualization-result-container {
	position: relative;

	.calculating-alert {
		display: none;
		position: absolute;
		width: 100%;
		height: calc(100% - 52px);
		background-color: rgba(0, 0, 0, 0.3);
		padding-top: 100px;
		font-size: 36px;
		text-align: center;
		margin-top: 52px;
		z-index: 100;
	}

	&.calculating .calculating-alert {
		display: block;
	}
}
