@import '../style/index';

@input-number-prefix-cls: ~'@{prefix}-input-number';

@border-color: #d9d9d9;
@border-hover-color: #40a9ff;

@color: rgba(0, 0, 0, 0.65);
@bg-color: #fff;

@large-height: 40px;
@large-fontSize: 16px;

@default-height: 32px;
@default-fontSize: 14px;

@small-height: 24px;
@small-fontSize: 14px;

.size-mixin(@height, @fontSize, @inputPadding: 0 11px) {
	height: @height;
	line-height: @height;
	font-size: @fontSize;

	input {
		padding: @inputPadding;
	}
}

.@{input-number-prefix-cls} {
	position: relative;
	display: inline-block;
	box-sizing: border-box;
	-webkit-text-size-adjust: none;
	width: 90px;
	border: 1px solid @border-color;
	color: @color;
	background-color: @bg-color;

	* {
		box-sizing: border-box;
	}

	&:hover {
		border-color: @border-hover-color;

		.@{input-number-prefix-cls}-handler-wrap {
			opacity: 1;
		}
	}

	&-focused {
		border-color: @border-hover-color;
		outline: 0;
		box-shadow: 0 0 0 2px rgba(24, 144, 255, .2);
	}

	&-disabled {
		color: rgba(0, 0, 0, .25);
		background-color: #f5f5f5;

		opacity: 1;

		&:hover {
			border-color: #e6d8d8;
			cursor: not-allowed;

			.@{input-number-prefix-cls}-handler-wrap {
				display: none;
			}

			.@{input-number-prefix-cls}-input {
				cursor: not-allowed;
			}
		}
	}

	&.large {
		.size-mixin(@large-height, @large-fontSize);
	}

	&.default {
		.size-mixin(@default-height, @default-fontSize);
	}

	&.small {
		.size-mixin(@small-height, @small-fontSize, 0 7px);

		.@{input-number-prefix-cls}-handler-down-icon, .@{input-number-prefix-cls}-handler-up-icon {
			transform: scale(.85);
			display: block;
		}
	}

	&-handler-wrap {
		position: absolute;
		top: 0;
		right: 0;
		width: 22px;
		height: 100%;
		background: @bg-color;
		border-left: 1px solid @border-color;
		border-radius: 0 4px 4px 0;
		opacity: 0;
		transition: opacity .24s linear .1s, border-left .24s linear .1s;
	}

	&-handler {
		position: relative;
		display: flex;
		width: 100%;
		height: 50%;
		line-height: 50%;
		justify-content: center;
		align-items: center;
		overflow: hidden;
		color: rgba(0, 0, 0, .45);
		font-weight: bold;
		transition: all .1s linear;

		&:active {
			background: #f4f4f4;
		}
	}

	&-handler-down {
		top: 0;
		border-top: 1px solid @border-color;
	}


	&-handler-up, &-handler-down {
		&:hover {
			cursor: pointer;
			color: @border-hover-color;
		}
	}

	&-handler-disabled {
		&,
		&:hover {
			color: rgba(0, 0, 0, .2);
			cursor: not-allowed;
		}
	}

	&-handler-down-icon, &-handler-up-icon {
		font-size: 8px;
	}

	&-handler-input {
		height: 100%;
	}

	&-input {
		width: 100%;
		height: 100%;
		vertical-align: top;
		text-align: left;
		background-color: transparent;
		border: 0;
		outline: 0;
	}
}
