@import "variables";
$table_border       : #e1e1e1;
$table_bg_gray      : #e9e9e9;
$table_bg_warning   : #ffefc1;

.cp-expenses {}
.cp-expenses-headline {
	display: flex;
	align-items: center;
	margin-bottom: 16px;
	.headline {
		font-size: 24px;
		font-weight: bold;
		&:not(:last-child){
			padding-right: 160px;
		}
	}
	.filter {}
	@media(max-width: 767px){
		flex-direction: column;
		align-items: flex-start;
		.filter {
			margin-top: 12px;
		}
	}
}
.cp-expenses-total {
	font-size: 12px;
	table {
		tr {
			th {
				background: #e5e5e5;
				padding: 8px;
				&:not(:first-child){
					border-left: 1px solid $table_border;
					text-align: right;
				}
			}
			td {
				padding: 4px 8px;
				vertical-align: top;
				&:not(:first-child){
					border-left: 1px solid $table_border;
					text-align: right;
				}
			}
			&:not(:first-child){
				td {
					border-top: 1px solid $table_border;
				}
			}
			&.footer {
				td {
					background: #e5e5e5;
					font-weight: bold;
				}
			}
			&:not(.footer).highlight {
				padding: 0;
				td {
					background: $table_bg_warning;
				}
			}
			&:not(.footer):hover {
				td {
					background: $blue_light;
				}
			}
		}
		a {
			border-bottom-color: transparent;
			color: $blue;
			&:hover {
				border-bottom-color: $blue;
			}
		}
	}
}
.cp-expenses-scroller {
	position: relative;
	overflow: hidden;
	overflow-x: auto;
}
.cp-expenses-table {
	position: relative;
	width: auto;
	//min-width: 1450px;
	font-size: 11px;
	.cpe-table-head {
		position: relative;
		z-index: 55;
		@include transform(translateZ(0));
		will-change: transform;
	}
	&:not(.headFixed) {
		.cpe-table-head {
			@include transform(none !important);
		}
	}
	.cpe-table-row {
		//border-bottom: 1px solid $table_border;
		width: auto;
		&:not(:first-child) {
			border-top: 1px solid $table_border;
		}
		&.head {
			& > .cpe-table-list {
				font-weight: bold;
				li {
					background: $table_bg_gray !important;
					padding-top: 8px;
					padding-bottom: 8px;
				}
			}
		}
		&.strong {
			& > .cpe-table-list {
				font-weight: bold;
			}
		}
		&.danger {
			& > .cpe-table-list {
				color: $red;
			}
		}
		&.footer {
			& > .cpe-table-list {
				font-weight: bold;
				li {
					background: $table_bg_gray !important;
				}
			}
		}

		.cpe-table-row {
			display: none;
			//padding-left: 5px;
			.control {
				padding-left: 14px;
				min-width: 34px !important;
			}
			.cpe-table-row {
				//background: #eaf2fa;
				.control {
					padding-left: 24px;
					min-width: 44px !important;
				}
				.cpe-table-row {
					//background: #f5f5f5;
					.control {
						padding-left: 34px;
						min-width: 54px !important;
					}
					.cpe-table-row {
						//background: $white;
						.control {
							padding-left: 44px;
							min-width: 64px !important;
						}
						.cpe-table-row {
							//background: $white;
							&:nth-child(2n){
								//background: #f5f5f5;
							}
							.control {
								padding-left: 54px;
								min-width: 74px !important;
							}
						}
					}
				}
			}
		}
		.cpe-table-toggle {
			position: relative;
			display: block;
			width: 12px;
			height: 12px;
			&:before, &:after {
				content: '';
				background: #b3c1cf;
				position: absolute; top: 50%; left: 50%;
				display: block;
				width: 8px;
				height: 2px;
				@include transform(translateX(-50%) translateY(-50%));
			}
			&:after {
				@include transform(translateX(-50%) translateY(-50%) rotate(90deg));
			}
		}

		&.highlight {
			padding: 0;
			& > .cpe-table-list {
				li {
					background: $table_bg_warning;
				}
			}
		}

		&.in {
			& > .cpe-table-list {
				@include box-shadow(0 2px 4px rgba(0,0,0,.15));
				li {
					background: #dde4ec;
				}
				.cpe-table-toggle {
					&:after {
						display: none;
					}
				}
			}
			& > .cpe-table-row {
				display: block;
			}
		}
	}
	.cpe-table-list {
		display: flex;
		margin: 0;
		padding: 0;
		list-style: none;
		& > li {
			border-right: 1px solid $table_border;
			padding: 2px 4px;
			&.control {
				border-right-color: transparent;
				position: relative;
				display: flex;
				align-items: center;
				min-width: 24px;
			}
			&.title {
				position: relative;
				display: flex;
				flex-grow: 1;
				width: auto;
				min-width: 275px;
				text-align: left;
				&:first-child {
					min-width: 184px;
				}
				.control {
					display: flex;
					align-items: center;
					min-width: 24px;
					height: 18px;
				}
				.controls {
					position: absolute; top: 50%; right: 6px;
					@include transform(translateY(-50%));
					i {
						&:hover {
							cursor: pointer;
							color: $blue;
						}
					}
				}
				.text {
					flex-grow: 1;
				}
			}
			&.person {
				width: 100px;
				min-width: 100px;
			}
			&.data {
				width: 70px;
				min-width: 70px;
				text-align: right;

				@media(min-width: 1600px){
					width: 80px;
					min-width: 80px;
				}
				@media(min-width: 1800px){
					width: 90px;
					min-width: 90px;
				}
			}
		}
		&.--clickable {
			&:hover {
				cursor: pointer;
			}
		}
		&:hover {
			li {
				background: $blue_light !important;
			}
		}
	}
	a {
		border-bottom-color: transparent;
		color: inherit;
		&:hover {
			border-bottom-color: $blue;
			color: $blue;
		}
	}
}

.cp-expenses-detail {
	font-size: 11px;
	table {
		width: 100%;
		tr {
			th {
				background: #e5e5e5;
				padding: 8px;
				white-space: nowrap;
				&:not(:first-child){
					border-left: 1px solid $table_border;
				}
			}
			td {
				padding: 6px 8px 4px;
				vertical-align: top;
				&:not(:first-child){
					border-left: 1px solid $table_border;
				}
			}
			&:not(:first-child){
				td {
					border-top: 1px solid $table_border;
				}
			}
			&.footer {
				td {
					background: #e5e5e5;
					font-weight: bold;
				}
			}
			&:not(.footer).highlight {
				padding: 0;
				td {
					background: $table_bg_warning;
				}
			}
			&:not(.footer):hover {
				td {
					background: $blue_light;
				}
			}
		}
		a {
			border-bottom-color: transparent;
			color: $blue;
			&:hover {
				border-bottom-color: $blue;
			}
		}
	}
}

.table-collapse {
	tr[data-level] {
		.table-collapse-control {
			display: flex;
			.side {
				//padding-top: 1px;
				padding-right: 4px;
			}
			.body {
				flex-grow: 1;
			}
		}
		.table-collapse-plug {
			position: relative;
			display: block;
			width: 16px;
			height: 16px;
		}
		.table-collapse-toggle {
			position: relative;
			display: block;
			width: 16px;
			height: 16px;
			&:before, &:after {
				content: '';
				background: #b3c1cf;
				position: absolute; top: 50%; left: 50%;
				display: block;
				width: 8px;
				height: 2px;
				@include transform(translateX(-50%) translateY(-50%));
			}
			&:after {
				@include transform(translateX(-50%) translateY(-50%) rotate(90deg));
			}
			&:hover {
				cursor: pointer;
			}
		}
		&:not([data-level="1"]){
			&:not(.tr-visible){
				display: none;
			}
			//display: none;
		}
		&.tr-opened {
			//background: #DDE4EC;
			background: rgba(0,0,0,.1);
			position: relative;
			z-index: 2;
			@include box-shadow(0 1px 3px rgba(0,0,0,.25));
			.table-collapse-toggle {
				&:after {
					display: none;
				}
			}
		}
	}
}