//
// buttons.scss
//

@use "../variables" as *;
@use "../utils/mixins" as *;
@use "sass:map";

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 500;
	padding: 8px 14px;
	border-radius: 5px;
	box-shadow: none;
	&-icon {
		position: relative;
		display: inline-flex;
		justify-content: center;
		align-items: center;
		height: 38px;
		width: 38px;
		padding: 0;
		font-size: 16px;

		:is(i, svg, img) {
			vertical-align: middle;
		}
		&.btn-xs {
			height: 20px;
    		width: 20px;
		}
		&.btn-sm {
			height: calc(0.6rem + 1.5em + 2px);
    		width: calc(0.6rem + 1.5em + 2px);
		}

		&.btn-lg {
			height: calc(1.3rem + 1.5em + 2px);
   			width: calc(1.3rem + 1.5em + 2px);
		}
	}

	&.btn-sm {
		font-size: 13px;
		padding: 6px 10px;
	}

	&.btn-xs {
		font-size: 12px;
		padding: 4px 8px;
    }

	&.btn-lg {
		font-size: 18px;
		padding: 8px 12px;
	}

	&.btn-outline-white {
		border-color: $border-color;
	}
}

.btn.disabled, .btn:disabled, fieldset:disabled .btn {
	background-color: $white;
	border-color: $border-color;
	color: $gray-900;
}
.btn-check:checked+.btn, .btn.active, .btn.show, .btn:first-child:active, :not(.btn-check)+.btn:active {
	background-color: $white;
	border-color: $primary;
	color: $gray-900;
}
@each $state in map.keys($theme-colors) {
	.btn-#{$state} {
		color: #fff;
		background-color: var(--#{$state});
		border-color: var(--#{$state});
		&:hover, &:active, &.active, &.disabled, &:disabled, &.show {
			color: #fff;
			background-color: var(--#{$state}-hover);
			border-color: var(--#{$state}-hover);
		}
	}
	.btn-check:checked + .btn-#{$state},  .btn-#{$state}:first-child:active, :not(.btn-check) + .btn-#{$state}:active, .btn-check+.btn-#{$state}:hover {
		background-color: var(--#{$state}-hover);
		border-color: var(--#{$state}-hover);
		color: #fff;
	}
}
.btn-light {
	color: $gray-900 !important;
	&:hover, &:active, &.active, &.disabled, &:disabled {
		color: $gray-900 !important;
	}
}
.btn-dark {
	background-color: $darkmode-dark;
	border-color: $darkmode-dark;
	&:hover {
		background-color: $gray-700;
		border-color: $gray-700;
	}
}
.btn-white {
	background-color: $white;
	border-color: $border-color;
	color: $gray-900;
	&:hover,  &.disabled, &:disabled {
		color: $gray-900;
		background-color: $light;
		border-color: $border-color;
	}
	&:active, &.active {
		color: #fff;
		background-color: $primary;
		border-color: $primary;
	}
}

@each $state in map.keys($theme-colors) {
	.btn-outline-#{$state} {
		color: var(--#{$state});
		background-color: #{$white};
		border-color: var(--#{$state});
		&:hover, &:active, &.active, &.disabled, &:disabled {
			color: #{$white};
			background-color: var(--#{$state});
			border-color: var(--#{$state});
		}
	}
	.btn-check:checked + .btn-outline-#{$state},  .btn-outline-#{$state}:first-child:active, :not(.btn-check) + .btn-outline-#{$state}:active,
	.btn-check+.btn-outline-#{$state}:hover {
		background-color: var(--#{$state}-hover);
		border-color: var(--#{$state}-hover);
		color: #{$white};
	}
}
.btn-outline-light {
	color: $gray-900 !important;
	border-color: $border-color;
	&:hover, &.disabled, &:disabled {
		color: $gray-900 !important;
		background-color: $primary-transparent;
	}
	&:active, &.active, &.show{
		color: $darkmode-white !important;
		background-color: $primary !important;
	}
}

@each $state in map.keys($theme-colors) {
	.btn-soft-#{$state} {
		color: var(--#{$state});
		background-color: var(--#{$state}-transparent);
		border-color: var(--#{$state});
		&:hover, &:active, &.active, &.disabled, &:disabled {
			color: #{$white};
			background-color: var(--#{$state});
			border-color: var(--#{$state});
		}
	}
}
.btn-soft-light {
	color: $gray-900 !important;
	&:hover, &:active, &.active, &.disabled, &:disabled {
		color: $gray-900 !important;
	}
}
.btn-effect {
	position: relative;
	cursor: pointer;
	display: inline-block;
	overflow: hidden;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent
}

.btn-animation {
	overflow: hidden;
	-webkit-transition: border-color .3s, background-color .3s;
	transition: border-color .3s, background-color .3s;
	-webkit-transition-timing-function: cubic-bezier(.2, 1, .3, 1);
	transition-timing-function: cubic-bezier(.2, 1, .3, 1);
	position: relative;

	&::after {
		content: attr(data-text);
		position: absolute;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		opacity: 0;
		-webkit-transform: translate3d(0, 25%, 0);
		transform: translate3d(0, 25%, 0);
		padding: 0.5rem 0.85rem;
		-webkit-transition: opacity .3s, -webkit-transform .3s;
		transition: opacity .3s, -webkit-transform .3s;
		transition: transform .3s, opacity .3s;
		transition: transform .3s, opacity .3s, -webkit-transform .3s;
		-webkit-transition-timing-function: cubic-bezier(.2, 1, .3, 1);
		transition-timing-function: cubic-bezier(.2, 1, .3, 1)
	}

	&>span {
		display: block;
		-webkit-transition: opacity .3s, -webkit-transform .3s;
		transition: opacity .3s, -webkit-transform .3s;
		transition: transform .3s, opacity .3s;
		transition: transform .3s, opacity .3s, -webkit-transform .3s;
		-webkit-transition-timing-function: cubic-bezier(.2, 1, .3, 1);
		transition-timing-function: cubic-bezier(.2, 1, .3, 1)
	}

	&:hover {
		&::after {
			opacity: 1;
			-webkit-transform: translate3d(0, 0, 0);
			transform: translate3d(0, 0, 0);
		}
	}
}

.btn-animation:hover>span {
	opacity: 0;
	-webkit-transform: translate3d(0, -25%, 0);
	transform: translate3d(0, -25%, 0)
}

.btn-primary {
	&.btn-animation:is(:hover, :focus, :active, :focus-visible) {
		color: $primary !important;
		border-color: $primary !important;
		background-color: rgba($primary-rgb, .1)
	}
}

.btn-secondary {
	&.btn-animation:is(:hover, :focus, :active, :focus-visible) {
		color: $secondary !important;
		border-color: $secondary !important;
		background-color: rgba($secondary-rgb, .1)
	}
}

.btn-warning {
	&.btn-animation:is(:hover, :focus, :active, :focus-visible) {
		color: $warning !important;
		background-color: rgba($warning-rgb, .1)
	}
}

.btn-danger {
	&.btn-animation:is(:hover, :focus, :active, :focus-visible) {
		color: $danger !important;
		background-color: rgba($danger-rgb, .1)
	}
}

.btn-info {
	&.btn-animation:is(:hover, :focus, :active, :focus-visible) {
		color: $info !important;
		background-color: rgba($info-rgb, .1)
	}
}

.btn-success {
	&.btn-animation:is(:hover, :focus, :active, :focus-visible) {
		color: $success !important;
		background-color: rgba($success-rgb, .1)
	}
}

.btn-dark {
	&.btn-animation:is(:hover, :focus, :active, :focus-visible) {
		color: $dark !important;
		background-color: rgba($dark-rgb, .1)
	}
}