@import "_mixins";

.page.settings {
	padding-top: $header_height;

	@include media-phablet {
		padding-top: $header_width_mobile;
	}

	&.active .scroll_content {
		display: flex;

		@include media-phablet {
			display: block;
		}
	}

	.navigation {
		display: flex;
		justify-content: space-between;

		.advanced_toggle {
			display: flex;
			align-items: center;

			span {
				margin-right: $padding / 2;
			}
		}
	}

	.tab_content {
		display: none;

		&.active {
			display: block;
		}
	}

	.tabs {
		margin: 0 $padding $padding;
		list-style: none;
		font-size: 24px;

		@include media-phablet {
			margin: 0 $padding/2 $padding;
		}

		ul {
			list-style: none;
			font-size: $font_size;
		}

		li {
			a {
				color: rgba(0,0,0,.5);

				@include theme-dark {
					color: rgba(255,255,255,.5);
				}
			}

			&.active {
				a {
					@include theme(color, text);
				}
			}
		}

	}

	form.containers {
		margin: 0 $padding 0 0;
		flex: 1;

		@include media-phablet {
			margin: 0 $padding/2 0 0;
		}
	}

	fieldset {
		border: 0;
		padding: $padding/2 0;
		position: relative;

		h2 {
			display: flex;
			flex-flow: row wrap;
			align-items: baseline;
			padding: 0 0 0 $padding;

			@include media-phablet {
				display: block;
				padding: 0 0 0 $padding/2;
			}

			.icon {
				margin-right: $padding/2;

				img {
					vertical-align: middle;
					position: relative;
					top: -1px;
				}
			}

			.group_label {
				margin-right: $padding/2;
			}

			.hint {
				flex: 1;
				font-size: 1rem;

				@include media-phablet {
					margin: 0;
					display: block;
				}

				a {
					font-weight: 400;
					@include theme(color, primary);
					text-decoration: underline;
					display: inline;
				}


			}
		}

		.more_hint {
			position: relative;

			.tooltip {
				display: inline;
				padding: $padding/2;

				.icon-info {
					vertical-align: middle;
					display: inline-block;
					text-align: center;
					border: 1px solid transparent;
					@include theme(border-color, primary);
					border-radius: 50%;
					width: 18px;
					height: 18px;
					line-height: 16px;
					font-size: .8em;
					text-decoration: none;
				}

				.tip {
					bottom: 100%;
					left: 0;
					right: 0;
					position: absolute;
					@include theme(background, off);
					z-index: 20;
					display: none;
					padding: $padding/2;
					margin-left: -$padding/2;
				}

				&:hover {
					.tip {
						display: block;
					}
				}
			}
		}

		.ctrlHolder {
			padding: $padding/3 $padding;
			border-bottom: 1px solid transparent;
			@include theme(border-color, off);
			display: flex;
			flex-flow: row nowrap;
			align-items: center;

			@include media-phablet {
				flex-flow: row wrap;
				padding: $padding/3 0 $padding/3 $padding/2;
			}

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

			&:nth-child(2) {
				margin-top: $padding/2;
			}

			label {
				display: inline-block;
				min-width: 150px;

				@include media-phablet {
					flex: 1 1 auto;
				}
			}

			input, textarea, select {
				min-width: 200px;

				@include media-phablet {
					flex: 1 1 auto;
				}
			}

			input[type=checkbox] {
				width: auto;
				min-width: 0;

				@include media-phablet {
					margin-right: $padding;
					flex: none;
				}
			}

			.select_wrapper {
				position: relative;
				display: flex;
				align-items: center;

				@include media-phablet {
					width: 100%;
				}

				select {
					cursor: pointer;
					appearance: none;
					width: 100%;
					min-width: 200px;
					border-radius: 0;

					&::-ms-expand {
						display: none;
					}
				}

				&:before {
					vertical-align: top;
					pointer-events: none;
					position: absolute;
					top: 0;
					line-height: 2em;
					right: $padding/2;
					height: 100%;
				}
			}

			.formHint {
				flex: 1;
				opacity: .8;
				margin-left: $padding;

				a {
					font-weight: 400;
					@include theme(color, primary);
					text-decoration: underline;
				}

				@include media-phablet {
					min-width: 100%;
					margin-left: 0;
				}
			}

			&.test_button {
				a {
					margin: 0;
				}

				.success {
					margin-left: $padding / 2;
				}
			}

			&.read_only {
				opacity: .5;

				label {
					position: relative;
				}

				label:after {
					left: 0;
					bottom: -10px;
					position: absolute;
					content: '(read-only)';
					font-size: .7em;
				}
			}
		}

		&.disabled {

			.ctrlHolder {
				display: none;
			}

			> .ctrlHolder:first-child {
				display: flex;
			}
		}

		&.enabler {
			display: block;

			&.disabled:hover {
				background: rgba(255,255,255,.1);

				@include theme-dark {
					background: rgba(0,0,0,.1);
				}
			}

			> :first-child {
				position: absolute;
				right: 0;
				border: 0;
				padding: 0;
				z-index: 10;

				~ h2 {
					margin-right: 66px + $padding;

					@include media-phablet {
						margin-right: 0;
					}
				}
			}

			> :nth-child(2){
				margin-top: 0;
			}

			> :nth-child(3){
				margin-top: $padding/2;
			}

		}
	}

	fieldset.advanced,
	fieldset .ctrlHolder.advanced {
		display: none;
		@include theme(color, primary);
	}

	&.show_advanced {
		fieldset.advanced {
			display: block;
		}
		fieldset:not(.disabled) > .ctrlHolder.advanced {
			display: flex;
		}
	}

	.switch {
		$switch_height: 20px;
		display: inline-block;
		@include theme(background, primary);
		height: $switch_height;
		width: $switch_height * 2.5;
		min-width: 0 !important;
		transition: all 250ms;
		cursor: pointer;
		border-radius: $switch_height;

		input {
			display: none;
		}

		.toggle {
			@include theme(background, background);
			margin: 1px;
			height: $switch_height - 2px;
			width: $switch_height - 2px;
			transition: transform 250ms;
			transform: translateX($switch_height*1.5);
			border-radius: $switch_height;
		}

	}

	fieldset.enabler.disabled .switch,
	&:not(.show_advanced) .advanced_toggle .switch {
		@include theme(background, off);
		@include theme(border-color, off);

		@include theme-dark {
			background: lighten(get-theme-dark(off), 10);
			border-color: lighten(get-theme-dark(off), 10);
		}

		.toggle {
			transform: translateX(0);
		}


		&:hover {
			background: darken(get-theme(off), 20);
			border-color: darken(get-theme(off), 20);

			@include theme-dark {
				background: darken(get-theme-dark(off), 20);
				border-color: darken(get-theme-dark(off), 20);
			}
		}
	}

	/** Options list **/
	.option_list {
		@include theme(background, background);
		margin-top: $padding/2;

		fieldset {
			position: relative;

			h2 {

				.group_label {
					min-width: 100px;
				}

			}

			&.disabled h2 {
				padding: 0 $padding;

				@include media-phablet {
					padding: 0 $padding/2;
				}
			}
		}

		fieldset:after {
			position: absolute;
			content: '';
			display: block;
			width: 100%;
			border-bottom: 1px solid transparent;
			@include theme(border-color, off);
			bottom: 0;

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

		h2 {
			font-size: 1em;
			font-weight: 400;

			.hint {
				font-weight: 300;
			}
		}
	}


	.combined_table {
		margin-top: $padding;

		.head {
			margin: 0 ($padding/2) 0 ($padding+26px);
			font-size: .8em;

			abbr {
				display: inline-block;
				font-weight: bold;
				border-bottom: 1px dotted #fff;
				line-height: 140%;
				cursor: help;
				margin-right: $padding/2;
				text-align: center;

				&:first-child {
					display: none;
				}
			}
		}

		input {
			min-width: 0 !important;
			display: inline-block;
			margin-right: $padding/2;
		}

		.use { }
		.host, .automation_ids, .automation_urls { width: 200px; }
		.api_key, .pass_key { width: 150px; }
		.name { width: 150px; }
		.extra_score, .seed_ratio, .seed_time { width: 70px; text-align: center; }
		.custom_tag { width: 120px; text-align: center; }

		.ctrlHolder {
			margin: 0 0 0 $padding;
			padding-left: 0;

			.delete {
				display: none;
				font-size: 20px;
				width: 22px;
				height: 22px;
				line-height: 20px;
				text-align: center;
				vertical-align: middle;
			}

			&:hover .delete {
				display: inline-block;
			}

			&.is_empty .delete,
			&.is_empty input[type=checkbox] {
				visibility: hidden;
			}
		}

	}
	.disabled .combined_table { display: none; }


	.tab_about {
		.usenet {
			padding: $padding $padding 0;
			font-size: 1.5em;
			line-height: 1.3em;

			@include media-phablet {
				padding: $padding/2 !important;
				font-size: 1em;
				line-height: 1.5em;
			}

			a {
				@include theme(color, primary);
				padding: 0 5px;
			}

			ul {
				list-style: none;
				float: left;
				width: 50%;
				margin: 10px 0;
				padding: 0;

				@include media-phablet {
					float: none;
					width: auto;
					margin: 0;
				}
			}

			li {
				font-size: .8em;

				&:before {
					margin-right: 10px;
				}
			}
		}

		.donate {
			float: left;
			width: 42%;
			text-align: center;
			font-size: 17px;
			padding: 0 0 0 4%;
			margin: 20px 0 0;
			border-left: 1px solid rgba(0,0,0,.2);
			height: 150px;

			@include media-phablet {
				padding: 0;
				float: none;
				width: auto;
				margin: 0;
				border: none;
			}

			@include theme-dark {
				border-color: rgba(255,255,255,.2);
			}

			iframe {
				border: none;
				width: 100%;
				height: 100%;
			}
		}

		.info {
			padding: $padding;
			margin: 0;
			overflow: hidden;

			@include media-phablet {
				padding: $padding/2;
			}

			dt {
				clear: both;
				float: left;
				width: 17%;
				font-weight: bold;

				@include media-phablet {
					float: none;
					width: auto;
				}
			}

			dd {
				float: right;
				width: 80%;
				padding: 0;
				margin: 0;
				font-style: italic;

				@include media-phablet {
					float: none;
					width: auto;
					margin-bottom: $padding/2;
				}

				&.version { cursor: pointer; }
			}
		}

		.group_actions {

			> div {
				padding: $padding;
				text-align: center;
			}

			a {
				margin: 0 10px;
				font-size: 20px;
			}
		}
	}

	.directory {

		@include media-phablet {
			width: 100%;
		}

		input {
			width: 100%;
		}
	}

	.multi_directory {

		.delete {
			@include theme(color, primary);
			padding: 0 $padding/2;
			opacity: .6;
			font-size: 1.5em;

			&:hover {
				opacity: 1;
			}
		}

		&.is_empty .delete {
			display: none;
		}
	}

	.choice {
		.select_wrapper {
			margin-left: $padding;
			width: 120px;
			min-width: 120px;

			@include media-phablet {
				margin: $padding/2 0 0;
			}

			select {
				min-width: 0 !important;
			}

		}
	}

	.renamer_to.renamer_to {
		flex-flow: row wrap;

		.ctrlHolder {
			width: 100%;
		}
	}

}

.directory_list {
	z-index: 2;
	position: absolute;
	width: 450px;
	margin: 75px 0 20px 0;
	@include theme(background, primary);
	box-shadow: 0 0 15px 2px rgba(0,0,0,.15);
	border-radius: $border_radius $border_radius 0 0;

	@include theme-dark {
		box-shadow: 0 5px 15px 2px rgba(0,0,0,.4);
	}

	.pointer {
		border-right: 6px solid transparent;
		border-left: 6px solid transparent;
		border-bottom: 6px solid transparent;
		@include theme(border-bottom-color, primary);
		display: block;
		position: absolute;
		width: 0;
		margin: -6px 0 0 100px;
	}

	.wrapper {
		@include theme(background, background);
		border-radius: $border_radius $border_radius 0 0;
		margin-top: 5px;
	}

	ul {
		width: 92%;
		height: 300px;
		overflow: auto;
		margin: 0 $padding;
	}

	li {
		padding: 4px $padding 4px 0;
		cursor: pointer;
		margin: 0 !important;
		border-top: 1px solid rgba(255,255,255,0.1);
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;

		&.blur {
			opacity: .3;
		}

		&:last-child {
			border-bottom: 1px solid rgba(255,255,255,0.1);
		}

		&:hover {
			@include theme(color, primary);
		}

		&.empty {
			background: none;
			height: 100px;
			text-align: center;
			font-style: italic;
			border: none;
			line-height: 100px;
			cursor: default;
			color: #BBB;
			text-shadow: none;
			font-size: 12px;
		}
	}

	.actions {
		clear: both;
		padding: $padding;
		min-height: 45px;
		position: relative;
		width: 100%;
		text-align: right;

		label {
			float: right;
			width: auto;
			padding: 0;

			input {
				margin-left: $padding/2;
			}
		}

		.back {
			font-weight: bold;
			width: 160px;
			display: inline-block;
			padding: 0;
			line-height: 120%;
			vertical-align: top;
			position: absolute;
			text-align: left;
			left: $padding;
		}

		&:last-child {
			padding: $padding;

			> span {
				padding: 0 5px;
				text-shadow: none;
			}

			> .clear {
				left: $padding;
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				margin: 0;
			}

			> .cancel {
				opacity: .7;
			}

			> .save {
				margin-right: 0;
			}
		}
	}
}
