/**
 * Button 按钮
 * @Author 瞿龙俊 - qulongjun@shine.design
 * @Date 2019/3/24 14:43
 */

.btn {
	background: transparent;
	outline: none !important;
	vertical-align: middle;

	&:focus:not(.btn-elevate) {
		box-shadow: none !important;
	}
}

// Clean button
.btn.btn-clean {
	border-color: transparent;
	background: transparent;
	color: shine-base-color(shape, 3);

	i {
		color: shine-base-color(shape, 3);
	}

	.show > &,
	&.active,
	&:active,
	&:hover {
		color: shine-brand-color();
		background: shine-base-color(shape, 1);

		i {
			color: shine-brand-color();
		}
	}
}

// Default button
.btn.btn-default {
	border: 0;
	background: transparent;
	color: shine-base-color(label, 2);
	border: 1px solid shine-base-color(shape, 2);

	i {
		color: shine-base-color(shape, 3);
	}

	.show > &,
	&.active,
	&:active,
	&:hover {
		i {
			color: shine-brand-color(inverse);
		}

		color: shine-brand-color(inverse);
		background: shine-brand-color();
		border-color: shine-brand-color();
	}
}

// Secondary button
.btn-secondary {
    background-color: transparent;
    border: 1px solid $input-border-color;
    color: $btn-secondary-color;

    .show > &.dropdown-toggle,
    &:focus,
	&.active,
	&:active,
	&:hover {
		color: $btn-secondary-color;
		border-color: $input-border-color;
		background-color: $btn-secondary-hover-bg-color;
	}
}

// Button states
@each $name, $color in join($shine-state-colors, $shine-social-colors) {
    .btn-#{$name} {
		@include button-variant(shine-get($color, base), shine-get($color, base));
		color: shine-get($color, inverse);

        @if $name == light {
	        .show > &.dropdown-toggle,
		    &:focus,
			&.active,
			&:active,
			&:hover {
				background-color: shine-base-color(grey, 1);
				border-color: shine-base-color(grey, 1);
			}
		}

        & + .btn.dropdown-toggle {
    		position: relative;

    		&:before {
                display: block;
                content: ' ';
                border-left: 1px solid shine-get($color, inverse);
                position: absolute;
                top: 3px;
                left: -1px;
                bottom: 3px;
                opacity: 0.3;
            }

            &:hover,
            &:focus,
            &.active {
                &:before {
                    display: none;
                }
            }
        }
    }
}

// Outline states
@each $name, $color in $shine-state-colors {
    .btn-outline-#{$name} {
        @include button-outline-variant(shine-get($color, base), shine-get($color, inverse));
    }
}

// Hover states
@each $name, $color in $shine-state-colors {
    .btn-hover-#{$name} {
    	//background: transparent;
    	//color: shine-get($color, base);

    	.show > &,
	  	&.active,
	  	&:active,
	  	&:hover {
			color: shine-get($color, inverse);
			background-color: shine-get($color, base);
			border-color: shine-get($color, base);
		}
    }

    .btn-outline-hover-#{$name} {
    	//background: transparent;

	  	&.btn-clean {
    		border: 1px solid transparent;
    	}

    	.show > &,
	  	&.active,
	  	&:active,
	  	&:hover {
	  		color: shine-get($color, base);
			border-color: shine-get($color, base);
			background-color: transparent;
		}
    }
}

// Font states
@each $name, $color in $shine-state-colors {
	.btn-font-#{$name} {
		color: shine-get($color, base);
    }

    .btn-font-hover-#{$name} {
    	.show > &,
	  	&.active,
	  	&:active,
	  	&:hover {
			color: shine-get($color, base);
		}
    }
}

// Secondary outline button
.btn.btn-outline-secondary {
  	color: darken(shine-get($theme-colors, secondary), 50%);

  	.show > &,
  	&.active,
  	&:active,
  	&:hover {
  		background-color: shine-get($theme-colors, secondary);
  		//color: #fff;
  	}
}

// Elevate buttons
.btn {
	// Elevate 1
	&.btn-elevate {
		transition: all 0.3s ease 0s;

		&.btn-elevate-air {
			&:hover {
		  		transform: translate(0, -4px);
		  	}
		}
	}

	@each $name, $color in $shine-state-colors {
		$base-color: shine-get($color, base);

		@if $name == light {
			$base-color: #999999;
		}

		&.btn-#{$name}.btn-elevate {
			box-shadow: 0px 4px 16px 0px rgba($base-color,0.15);

			.show > &,
			&:focus,
			&.active,
	  		&:active,
	  		&:hover {
	  			box-shadow: 0px 9px 16px 0px rgba($base-color, 0.25) !important;

	  			&.btn-sm {
	  				box-shadow: 0px 6px 16px 0px rgba($base-color, 0.25) !important;
	  			}

	  			@if $name == light {
					background-color: transparent;
					border-color: transparent;
				}
	  		}
	  	}

	  	&.btn-#{$name}.btn-elevate-hover {
			.show > &,
			&.active,
			&:focus,
	  		&:active,
	  		&:hover {
	  			box-shadow: 0px 9px 16px 0px rgba($base-color, 0.25) !important;

	  			&.btn-sm {
	  				box-shadow: 0px 6px 16px 0px rgba($base-color, 0.25) !important;
	  			}

	  			@if $name == light {
					background-color: transparent;
					border-color: transparent;
				}
	  		}
	  	}
	}
}

// Square buttons
.btn {
	&.btn-square {
		border-radius: 0;
	}
}

// Pill buttons
.btn {
	&.btn-pill {
		border-radius: 2rem;
	}
}

// Text transform
.btn {
	&.btn-upper {
		text-transform: uppercase;
	}

	&.btn-bold {
		font-weight: 600;
	}

	&.btn-bolder {
		font-weight: 600;
	}

	&.btn-boldest {
		font-weight: 700;
	}

	&.btn-thin {
		font-weight: 400;
	}

	&.btn-lower {
		text-transform: lowercase;
	}
}

// Custom sizing
.btn {
	&.btn-wide {
		padding-left: 2.25rem;
		padding-right: 2.25rem;
	}

	&.btn-wider {
		padding-left: 2.75rem;
		padding-right: 2.75rem;
	}

	&.btn-widest {
		padding-left: 3rem;
		padding-right: 3rem;
	}

	&.btn-tall {
		padding-top: 0.85rem;
		padding-bottom: 0.85rem;
	}

	&.btn-taller {
		padding-top: 1.15rem;
		padding-bottom: 1.15rem;
	}

	&.btn-tallest {
		padding-top: 1.35rem;
		padding-bottom: 1.35rem;
	}
}

// Custom font sizing
.btn {
	&.btn-font-sm {
		font-size: 0.85rem;
	}

	&.btn-font-md {
		font-size: 1rem;
	}

	&.btn-font-lg {
		font-size: 1.1rem;
	}
}

// Button with icon
.btn {
	//display: inline-flex;
	align-items: center;

	@include shine-icons-size((lineawesome: 1.5rem, fontawesome: 1.2rem, flaticon: 1.2rem));

	i {
		padding-right: 0.5rem;
		vertical-align: middle;
		line-height: 0;
	}

	&.btn-sm {
		@include shine-icons-size((lineawesome: 1.3rem, fontawesome: 1rem, flaticon: 1rem));

		i {
			padding-right: 0.35rem;
		}
	}

	&.btn-lg {
		@include shine-icons-size((lineawesome: 1.7rem, fontawesome: 1.4rem, flaticon: 1.3rem));

		i {
			padding-right: 0.75rem;
		}
	}
}

// Label button
.btn.btn-label {
	background-color: shine-base-color(shape, 1);
	color: shine-brand-color();
	cursor: text !important;
}

.btn.btn-link,
a.btn.btn-label,
button.btn.btn-label,
input.btn.btn-label {
	cursor: pointer !important;

	&:focus,
	&:hover,
	&.active {
	    background-color: shine-brand-color();
	    color: shine-brand-color(inverse);
	}
}

// Label button states
@each $name, $color in join($shine-state-colors, $shine-social-colors) {
	.btn.btn-label-#{$name} {
		background-color: rgba(shine-get($color, base), 0.1);
		color: shine-get($color, base);
		cursor: text !important;
	}

	.btn.btn-label-#{$name}-o2 {
		background-color: rgba(shine-get($color, base), 0.2);
		color: shine-get($color, base);
		cursor: text !important;
	}

	a.btn.btn-label-#{$name},
	button.btn.btn-label-#{$name},
	input.btn.btn-label-#{$name} {
		cursor: pointer !important;
		&:focus,
		&:hover,
		&.active {
		    background-color: shine-get($color, base);
		    color: shine-get($color, inverse);
		}
	}
}

// Button with icon only
.btn.btn-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;

	&.btn-circle {
		border-radius: 50%;
	}

	i {
		padding: 0;
		margin: 0;
		line-height: 0;
	}

	[class^="socicon-"],
	[class*=" socicon-"] {
		line-height: 1;
	}

	& {
		height: 3rem;
		width: 3rem;
	}

	&.btn-sm {
		height: 2.5rem;
		width: 2.5rem;
	}

	&.btn-lg {
		height: 4rem;
		width: 4rem;
	}

	// Icon sizing
	&.btn-icon-sm {
		@include shine-icons-size((lineawesome: 1.25rem, fontawesome: 1.15rem, flaticon: 1.15rem));
	}

	// Icon sizing
	&.btn-icon-md {
		@include shine-icons-size((lineawesome: 1.3rem, fontawesome: 1.2rem, flaticon: 1.2rem));
	}

	&.btn-icon-lg {
		@include shine-icons-size((lineawesome: 1.4rem, fontawesome: 1.4rem, flaticon: 1.4rem));
	}

	// Icon button states
	@each $name, $color in $shine-state-colors {
	    &.btn-#{$name} {
	        i {
	        	color: shine-get($color, inverse);
	        }

	        &:focus,
	        &:hover,
	        &.active {
	        	i {
	        		color: shine-get($color, inverse);
	        	}
	        }
	    }
	}
}

// Same height with icon btn
.btn-icon-h {
	& {
		height: 3rem;
	}

	&.btn-sm {
		height: 2.25rem;
	}

	&.btn-lg {
		height: 4rem;
	}
}

// Input group workarounds
.input-group-append,
.input-group-prepend {
	.btn.btn-icon {
		height: auto;
	}
}

// Button with spinner
.btn.shine-spinner {
	& {
		&:not(.shine-spinner--center) {
			padding-left: 3 * $input-btn-padding-x;

			&:before {
				left: $input-btn-padding-x;
			}
		}

		// Right
		&.shine-spinner--right {
			padding-left: $input-btn-padding-x;
			padding-right: 3 * $input-btn-padding-x;

			&:before {
				left: auto;
				right: $input-btn-padding-x;
			}
		}
	}

	&.shine-spinner--sm {
		&:not(.shine-spinner--center) {
			padding-left: 2.5 * $input-btn-padding-x;

			&:before {
				left: $input-btn-padding-x;
			}
		}

		// Right
		&.shine-spinner--right {
			padding-left: $input-btn-padding-x;
			padding-right: 2.5 * $input-btn-padding-x;

			&:before {
				left: auto;
				right: $input-btn-padding-x;
			}
		}
	}

	&.shine-spinner--lg {
		&:not(.shine-spinner--center) {
			padding-left: 3.5 * $input-btn-padding-x;

			&:before {
				left: $input-btn-padding-x;
			}
		}

		// Right
		&.shine-spinner--right {
			padding-left: $input-btn-padding-x;
			padding-right: 3.5 * $input-btn-padding-x;

			&:before {
				left: auto;
				right: $input-btn-padding-x;
			}
		}
	}
}

// Button glow style
.btn{
	&.btn-glow {
		box-shadow: 0px 2px 14px 2px rgba(255,255,255,0.1);

		.show > &,
  		&.active,
  		&:active,
  		&:hover {
  			box-shadow: 0px 2px 14px 2px rgba(255,255,255,0.3);
  		}
	}
}
