
@use "sass:color";
@use 'mixins.scss';
@use 'common.scss';

$dtb-button-colour: rgba(0, 0, 0, 0.1) !default;
$dtb-button-focus-colour: rgba(121, 172, 233, 1) !default;
$dtb-button-border: 1px solid mixins.dtb-shade(transparent, 30%) !default;

$dtb-dark-button-colour: rgba(255, 255, 255, 0.15);
// $dtb-dark-button-focus-colour: 
$dtb-dark-button-border: 1px solid rgb(89, 91, 94);

div.dt-buttons {
	> .dt-button,
	> div.dt-button-split .dt-button {
		position: relative;
		display: inline-block;
		box-sizing: border-box;
		margin-left: 0.167em;
		margin-right: 0.167em;
		margin-bottom: 0.333em;
		padding: 0.5em 1em;
		border: $dtb-button-border;
		border-radius: 2px;
		cursor: pointer;
		font-size: 0.88em;
		line-height: 1.6em;
		color: inherit;
		white-space: nowrap;
		overflow: hidden;
		@include mixins.dtb-two-stop-gradient(
			color.adjust($dtb-button-colour, $lightness: 90%),
			$dtb-button-colour
		);
		-webkit-user-select: none;
		-moz-user-select: none;
		-ms-user-select: none;
		user-select: none;
		text-decoration: none;
		outline: none;
		text-overflow: ellipsis;

		&:first-child {
			margin-left: 0;
		}

		&.disabled {
			cursor: default;
			opacity: 0.4;
		}

		&.dt-button-active:not(.disabled) {
			@include mixins.dtb-two-stop-gradient(
				color.adjust($dtb-button-colour, $lightness: 70%),
				color.adjust($dtb-button-colour, $lightness: -20%)
			);
			box-shadow: inset 1px 1px 3px #999999;

			&:hover:not(.disabled) {
				box-shadow: inset 1px 1px 3px #999999;
				@include mixins.dtb-two-stop-gradient(
					color.adjust($dtb-button-colour, $lightness: 50%),
					color.adjust($dtb-button-colour, $lightness: -50%)
				);
			}
		}

		&:hover {
			text-decoration: none;
		}

		&:hover:not(.disabled) {
			border: 1px solid #666;
			@include mixins.dtb-two-stop-gradient(
				color.adjust($dtb-button-colour, $lightness: 60%),
				color.adjust($dtb-button-colour, $lightness: -30%)
			);
		}

		&:focus:not(.disabled) {
			outline: 2px solid rgb(53, 132, 228);
		}
		
		embed { 
			outline: none;
		}
	}

	> div.dt-button-split {
		.dt-button:first-child {
			border-right: 1px solid rgba(0, 0, 0, 0.15);
			border-top-right-radius: 0;
			border-bottom-right-radius: 0;
	
			&:hover {
				border-right: 1px solid #666;
			}
		}
	
		.dt-button:last-child {
			border-left: 1px solid transparent; // Allows hover on border
			border-top-left-radius: 0;
			border-bottom-left-radius: 0;
	
			&:hover {
				border-left: 1px solid #666;
			}
		}
	}

	span.dt-button-down-arrow {
		position: relative;
		top: -2px;
		font-size: 10px;
		padding-left: 10px;
		line-height: 1em;
		opacity: 0.6;
	}

	div.dt-button-split {
		display: inline-block;

		.dt-button:first-child {
			margin-right: 0;
		}

		.dt-button:last-child {
			margin-left: -1px;
			padding-left: 0.75em;
			padding-right: 0.75em;
			z-index: 2;
			
			span {
				padding-left: 0;
			}
		}
	}
}


div.dt-button-collection {
	position: absolute;
	top: 0;
	left: 0;
	width: 200px;
	margin-top: 3px;
	margin-bottom: 3px;
	padding: 0.75em 0;
	border: 1px solid rgba( 0, 0, 0, 0.4 );
	background-color: white;
	overflow: hidden;
	z-index: 2002;
	border-radius: 5px;
	box-shadow: 3px 4px 10px 1px rgba(0, 0, 0, 0.3);
	box-sizing: border-box;

	.dt-button {
		position: relative;
		left: 0;
		right: 0;
		width: 100%;

		display: flex;
		float: none;
		justify-content: space-between;
		align-items: center;

		background: none;
		margin: 0;
		padding: 0.5em 1em;
		border: none;
		text-align: left;
		cursor: pointer;
		color: inherit;

		&.dt-button-active {
			background: none;
			box-shadow: none;
		}

		&.disabled {
			cursor: default;
			opacity: 0.4;
		}

		&:hover:not(.disabled) {
			border: none;
			background: rgba(153, 153, 153, 0.1);
			box-shadow: none;
		}

		&:focus {
			outline-offset: -2px;
		}
	}

	div.dt-button-split {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: flex-start;
		align-content: flex-start;
		align-items: stretch;

		button.dt-button {
			margin: 0;
			display: inline-block;
			width: 0;
			flex-grow: 1;
			flex-shrink: 0;
			flex-basis: 50px;
		}

		button.dt-button-split-drop {
			min-width: 33px;
			flex: 0;
		}
	}

	&.fixed {
		.dt-button {
			border-radius: 0.25em;
			background: rgba(255, 255, 255, 0.1);
		}
	}

	@include mixins.dtb-fixed-collection();
}

div.dt-button-background {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;

	@include mixins.dtb-radial-gradient( rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.7) );

	z-index: 2001;
}

.dt-button.processing {
	@include mixins.dtb-processing();
}

@media screen and (max-width: 640px) {
	div.dt-buttons {
		float: none !important;
		text-align: center;
	}
}

html.dark {
	div.dt-buttons {
		> .dt-button,
		> div.dt-button-split .dt-button {
			border: $dtb-dark-button-border;
			background: $dtb-dark-button-colour;
			
			&.dt-button-active:not(.disabled) {
				background: color.adjust($dtb-dark-button-colour, $lightness: -30%);
				box-shadow: inset 1px 1px 2px black;
		
				&:hover:not(.disabled) {
					background: color.adjust($dtb-dark-button-colour, $lightness: -50%);
					box-shadow: inset 1px 1px 3px black;
				}
			}
		
			&:hover:not(.disabled) {
				background: color.adjust($dtb-dark-button-colour, $lightness: -30%);
			}

			&:focus:not(.disabled) {
				outline: 2px solid rgb(110, 168, 254);
			}
		}

		> div.dt-button-split {
			.dt-button:first-child {
				border-right: 1px solid rgba(255, 255, 255, 0.1);

				&:hover {
					border-right: $dtb-dark-button-border;
				}
			}
		
			.dt-button:last-child {
				&:hover {
					border-left: $dtb-dark-button-border;
				}
			}
		}
	}

	div.dt-button-collection {
		border: 1px solid rgba(255, 255, 255, 0.15);
		background-color: rgb(33, 37, 41);
		box-shadow: 3px 4px 10px 1px rgba(0, 0, 0, 0.8);
	}

	div.dt-button-info {
		background-color: var(--dt-html-background);
		border: 1px solid rgba(255, 255, 255, 0.15);
	}
}
