
// Limit resize in firefox, options are none, vertical, horizontal or both
textarea {
	resize: vertical;
}

form {
	margin: 0 auto;

	&:after {
		.clear;
	}

	fieldset {
		border: 1px solid @colorDivider;
		margin: 1rem 0;
		padding: 1rem;
		border-radius: @radius;
		min-width: 0; // stop auto resize on Chrome
	}

	legend {
		padding: 0 .5rem;
		border: 1px solid @colorDivider;
		border-radius: @radius;
	}

	// Labels & validation
	label {
		display: block;
		position: relative;
		font-weight: 500;
		font-size: 1rem;
		color: @formTextDesc;
		top: 0;
		.transition();

		em {
			font-size: .85rem;
			font-style: normal;
			color: fadeout(@formValidatorReq, 13%);
		}

		&.validationError span:first-child {
			display: none;
		}

		&.focused {
			color: @colorPrimary;
		}
	}

	.description {
		padding: .25rem 0 0 0;
		font-size: .85rem;
		color: @formTextDesc;
	}

	.validation {
		color: @formValidatorFailed;
		display: none;

		strong {
			font-weight: normal;
			display: block;
		}
	}

	.ok,
	.failed,
	.ajax {
		display: block;
	}

	// Form elements
	input[disabled] {
		cursor: not-allowed;
		opacity: .5;
	}

	input[type="text"],
	input[type="number"],
	input[type="email"],
	input[type="url"],
	input[type="password"],
	input[type="search"],
	select,
	textarea {
		outline: none;
		font-family: inherit;
		font-size: 1rem;
		width: 100%;
		padding: .5rem .25rem;
		border: 1px solid @colorDivider;
		color: @colorText;
		background-color: transparent;
		.transition();

		&:focus {
			border: 1px solid @colorPrimary;
		}

		&.validationError {
			border-color: @formValidatorFailed;
		}
	}

	dt {
		position: relative;
	}

	input[type="file"] {
		font-size: 1rem;
		width: auto;
	}

	// Radio group
	.radiogroup {
		margin: 0;
		padding: 0;
		list-style: none;

		li {
			padding: .25rem 0;
			margin: 0;
		}

		input {
			margin-right: .5rem;
		}

		label {
			color: @colorText;
			font-size: 1rem;
		}
	}

	// Checklist
	.checklist {
		padding: .25rem;
		margin: 0;
		list-style: none;
		overflow: auto;
		border: 1px solid @colorDivider;
		border-radius: @radius;

		li {
			padding: .25rem;
			margin: 0;
			background-color: transparent;
			.transition();

			&.selected {
				background-color: @checklistHoeverBg;
			}

			&:hover {
				background-color: @checklistHoeverBg;
			}

			label {
				display: block;
				font-weight: normal;
				color: @colorText;
				font-size: 1rem;
				cursor: pointer;
			}
		}

		input {
			margin-right: .25rem;
		}
	}

	// Stacked Layout
	dd {
		padding: 0 0 .3rem 0;
		margin-bottom: .75rem;

		&:last-child {
			margin-bottom: 0;
		}
	}
}

// Give form input fields an application style
.appFormStyle {
	form {
		input[type="text"],
		input[type="number"],
		input[type="email"],
		input[type="url"],
		input[type="password"],
		input[type="search"],
		select,
		textarea {
			padding: .5rem 0;
			border: none;
			border-bottom: 2px solid @colorDivider;

			&:focus {
				border: none;
				border-bottom: 2px solid @colorPrimary;
			}

			&.validationError {
				border: none;
				border-bottom: 2px solid @formValidatorFailed;
			}
		}
	}
}

.floatingLabels {
	label {
		&.floatUp {
			color: @formTextDesc;
			position: absolute;
			top: .25rem;
			left: .25rem;
			font-size: .75rem;

			&.focused {
				color: @colorPrimary;
			}
		}

		&.floatDown {
			color: @formFloatLabel;
			position: absolute;
			top: 1rem;
			left: .25rem;
			cursor: text;

			&.focused {
				color: @colorPrimary;
			}
		}
	}

	form {
		input[type="text"],
		input[type="number"],
		input[type="email"],
		input[type="url"],
		input[type="password"],
		input[type="search"] {
			padding: 1.5rem .25rem .5rem .25rem;
		}

		.selectControl {
			position: relative;
			z-index: 1;

			&:after {
				content: "\f078"; // Fontawesome chevron down
				color: @colorPrimary;
				display: block;
				font: normal normal normal 14px/1 FontAwesome;
				text-rendering: auto;
				-webkit-font-smoothing: antialiased;
				-moz-osx-font-smoothing: grayscale;
				position: absolute;
				width: 16px;
				height: 16px;
				text-align: center;
				font-size: 16px;
				line-height: 1;
				top: 50%;
				margin-top: -8px;
				right: 1rem;
				z-index: 2;
			}

			select {
				padding: 1.5rem .25rem .5rem .25rem;
				margin: 0;
				outline: none;
				border-radius: 0;
				-webkit-appearance: none;
				-moz-appearance: none;
				position: relative;
				z-index: 4;
				cursor: pointer;

				// Hide focus on Firefox
				&:-moz-focusring {
					color: transparent;
					text-shadow: 0 0 0 #000;
				}

				&:disabled {
					cursor: not-allowed;
				}
			}
		}
	}

	&.appFormStyle,
	.appFormStyle {
		label {
			&.floatUp,
			&.floatDown {
				left: 0;
			}
		}

		input[type="text"],
		input[type="number"],
		input[type="email"],
		input[type="url"],
		input[type="password"],
		input[type="search"],
		.selectControl select {
			padding: 1.5rem 0 .5rem 0;
		}
	}
}

// Submit buttons
form input[type="submit"],
form button, button { font-size: 1rem; }

// Horizontal Layout
.hform form,
form.hform {
	dt {
		float: left;
		clear: both;
		width: 28%;
		margin-right: 2%;

		label {
			text-align: right;
			padding: .4rem 0 .5rem 0;
			color: @colorText;
		}
	}
	dd {
		float: right;
		width: 70%;
	}
	.radiogroup {
		li:first-child {
			padding-top: 0;
		}
	}
	input[type="text"],
	input[type="number"],
	input[type="email"],
	input[type="url"],
	input[type="password"],
	input[type="search"],
	.selectControl select {
		padding: .5rem .25rem !important;
	}
}

// Submit button list layout
form {
	#submit-list {
		clear: both;

		dt {
			display: none;
		}
		dd {
			float: none;
			width: auto;
			display: inline;
			padding-left: 2px;
			padding-right: 2px;
		}
	}
}

.hform {
	#submit-list {
		float: right;
		width: 70%;
	}
}

@media (max-width: (@breakpoint-s - 1)) {

	.hform #submit-list {
		float: none;
		width: 100%;
	}
	.hform form,
	form.hform {
		dt, dd {
			float: none;
			width: 100%;
		}

		dt label {
			text-align: left;
			font-size: .85rem;
			color: @formTextDesc;
		}

		.validation {
			width: auto;
			left: 40%;
			bottom: -.5rem;
		}
	}
}
