
//Main Theme Variables
@backgroundColor: #793109; //background color of tabulator
@borderColor:#fff; //border to tablulator
@textSize:14px; //table text size

//header themeing
@headerBackgroundColor:#59270C; //border to tablulator
@headerTextColor:#E4C24D; //header text colour
@headerBorderColor:#59270C;  //header border color
@headerSeperatorColor:#391D04; //header bottom seperator color
@headerMargin:4px; //padding round header

//column header arrows
@sortArrowActive: #E4B101;
@sortArrowInactive: #933907;

//row themeing
@rowBackgroundColor:#DEB21A; //table row background color
@rowAltBackgroundColor:#DE8D1A; //table row background color
@rowBorderColor:#fff; //table border color
@rowTextColor:#090601; //table text color
@rowHoverBackground:#A0640F; //row background color on hover

@rowSelectedBackground: #F3E837; //row background color when selected
@rowSelectedBackgroundHover: #F3CD37;//row background color when selected and hovered


@editBoxColor:#1D68CD; //border color for edit boxes

//footer themeing
@footerBackgroundColor:#59270C; //border to tablulator
@footerTextColor:#DE8D1A; //footer text colour
@footerBorderColor:#933907; //footer border color
@footerSeperatorColor:#391D04; //footer bottom seperator color



//Tabulator Containing Element
.tabulator{
	position: relative;
	border: 1px solid @borderColor;
	background-color: @backgroundColor;
	overflow:hidden;
	font-size:@textSize;
	text-align: left;

	//column header containing element
	.tabulator-header{
		position:relative;

		width:100%;

		border-bottom:2px solid @headerSeperatorColor;
		background-color: @headerBackgroundColor;
		color: @headerTextColor;
		font-weight:bold;

		white-space: nowrap;
		overflow:hidden;

		-moz-user-select: none;
		-khtml-user-select: none;
		-webkit-user-select: none;
		-o-user-select: none;

		font-size: 1.1em;

		//individual column header element
		.tabulator-col{
			display:inline-block;

			//hold content of column header
			.tabulator-col-content{
				position: relative;
				padding:4px;

				//hold title of column header
				.tabulator-col-title{
					width: 100%;

					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					vertical-align:bottom;

					//element to hold title editor
					.tabulator-title-editor{
						box-sizing: border-box;
						width: 100%;

						border:2px solid darken(@headerBackgroundColor, 10%);

						background: lighten(@headerBackgroundColor, 10%);

						padding:1px;

						font-size: 1em;
						color: #fff;
					}
				}

				//column sorter arrow
				.tabulator-arrow{
					display: inline-block;
					position: absolute;
					top:9px;
					right:8px;
					width: 0;
					height: 0;
					border-left: 6px solid transparent;
					border-right: 6px solid transparent;
					border-bottom: 6px solid @sortArrowInactive;

					&.asc{
						border-top: none;
						border-bottom: 6px solid @sortArrowActive;
					}

					&.desc{
						border-top: 6px solid @sortArrowActive;
						border-bottom: none;
					}
				}
			}

			//column resize handles
			.tabulator-handle{
				position:absolute;
				right:0;
				top:0;
				bottom:0;
				width:5px;

				&.prev{
					left:0;
					right:auto;
				}

				&:hover{
					cursor:ew-resize;
				}
			}

			//complex header column group
			&.tabulator-col-group{

				//gelement to hold sub columns in column group
				.tabulator-col-group-cols{
					position:relative;
					display: flex;

					border-top:2px solid @sortArrowActive;
					overflow: hidden;

					.tabulator-col:last-child{
						margin-right:-1px;
					}
				}
			}

			//hide left resize handle on first column
			&:first-child{
				.tabulator-handle.prev{
					display: none;
				}
			}

			//placeholder element for sortable columns
			&.ui-sortable-helper{
				position: absolute;
				background-color: darken(@headerBackgroundColor, 10%) !important;
				border:1px solid @headerBorderColor;
			}

			//header filter containing element
			.tabulator-header-filter{
				position: relative;
				box-sizing: border-box;
				margin-top:2px;
				width:100%;
				text-align: center;

				//styling adjustment for inbuilt editors
				textarea{
					height:auto !important;
				}

				svg{
					margin-top: 3px;
				}

				input,select{
					border:2px solid darken(@headerBackgroundColor, 10%);
					background: lighten(@headerBackgroundColor, 10%);
					outline: lighten(@headerBackgroundColor, 10%);
				}
			}


			//styling child elements for sortable columns
			&[data-sortable=true]{
				.tabulator-col-title{
					width:calc(~"100% - 25px");
				}

				&:hover{
					cursor:pointer;
					background-color:darken(@headerBackgroundColor, 10%);
				}
			}

		}

		//empty column for spacing row handlers on tables with movable rows enabled
		.tabulator-col-row-handle{
			width:30px;
			max-width:30px;
			display:inline-block;
		}

		.tabulator-col, .tabulator-col-row-handle{
			position:relative;
			box-sizing:border-box;
			border-right:2px solid @headerBorderColor;
			text-align:left;
			vertical-align: bottom;
			overflow: hidden;
		}
	}

	//scrolling element to hold table
	.tabulator-tableHolder{
		position:relative;
		width:100%;
		white-space: nowrap;
		overflow:auto;
		-webkit-overflow-scrolling: touch;

		//element to hold table rows
		.tabulator-table{
			position:relative;
			display:inline-block;
			background-color:@rowBackgroundColor;
			white-space: nowrap;
			overflow:visible;
			color:@rowTextColor;

			//row element
			.tabulator-row{
				min-height:@textSize + (@headerMargin * 2);
				background-color: @rowBackgroundColor;


				&:nth-child(even){
					background-color: @rowAltBackgroundColor;
				}

				&.tabulator-selectable:hover{
					background-color:@rowHoverBackground;
					cursor: pointer;
				}

				&.tabulator-selected{
					background-color:@rowSelectedBackground;
				}

				&.tabulator-selected:hover{
					background-color:@rowSelectedBackgroundHover;
					cursor: pointer;
				}

				//movable row handle
				.tabulator-row-handle{
					display:inline-block;
					box-sizing:border-box;
					width:30px;
					max-width:30px;
					padding:4px;
					border-right:1px solid @rowBorderColor;
					text-align: center;
					vertical-align:middle;
					white-space:nowrap;
					overflow:hidden;
					text-overflow:ellipsis;

					&:hover{
						cursor:move;
						background-color:rgba(0,0,0,.1);
					}

					//Hamburger element
					div{
						width:80%;
						height:3px;
						margin:2px 10% 0 10%;
						background:#666;
					}
				}

				//cell element
				.tabulator-cell{
					position: relative;
					box-sizing:border-box;
					padding:4px;
					border-bottom:2px solid @backgroundColor;
					vertical-align:middle;
					white-space:nowrap;
					overflow:hidden;
					text-overflow:ellipsis;


					&.tabulator-editing{
						border:1px solid  @editBoxColor;
						padding: 0;

						input, select{
							border:1px;
							background:transparent;
						}
					}
				}

			}

			//row grouping element
			.tabulator-group{

				&.show{
					.tabulator-group-header{
						.tabulator-arrow{
							margin-left:5px;
							margin-right:10px;
							border-left: 6px solid transparent;
							border-right: 6px solid transparent;
							border-top: 6px solid @sortArrowActive;
							border-bottom: 0;
						}
					}

					.tabulator-group-body{
						visibility: visible;
						height:auto;
					}
				}

				//row grouping header
				.tabulator-group-header{
					box-sizing:border-box;
					border-bottom:1px solid #592808;
					border-right:1px solid @rowBorderColor;
					border-top:1px solid #592808;
					padding:5px;
					background:#813808;
					font-weight:bold;
					color: #fff;

					//sorting arrow
					.tabulator-arrow{
						display: inline-block;
						width: 0;
						height: 0;
						margin-left:8px;
						margin-right:13px;
						border-top: 6px solid transparent;
						border-bottom: 6px solid transparent;
						border-right: 0;
						border-left: 6px solid @sortArrowActive;
						vertical-align:middle;

						&:hover{
							cursor:pointer;
							background-color:rgba(0,0,0,.1);
						}
					}

					span{
						margin-left:10px;
						color:@rowBackgroundColor;
					}
				}

				//row grouping footer
				.tabulator-group-body{
					visibility:hidden;
					height:0;
				}
			}
		}
	}

	//footer element
	.tabulator-footer{
		padding:5px 10px;
		border-top:1px solid @footerSeperatorColor;
		background-color: @footerBackgroundColor;
		text-align:right;
		color: @footerTextColor;
		font-weight:bold;
		white-space:nowrap;
		user-select:none;

		-moz-user-select: none;
		-khtml-user-select: none;
		-webkit-user-select: none;
		-o-user-select: none;

		//pagination container element
		.tabulator-pages{
			margin:0 7px;
		}

		//pagination button
		.tabulator-page{
			display:inline-block;
			margin:0 2px;
			border:1px solid @footerBorderColor;
			border-radius:3px;
			padding:2px 5px;
			background:rgba(255,255,255,.2);
			color: @footerTextColor;

			&.active{
				color:@rowBackgroundColor;
			}

			&.disabled{
				opacity:.5;
			}

			&:not(.disabled){
				&:hover{
					cursor:pointer;
					background:rgba(0,0,0,.2);
					color:#fff;
				}
			}
		}
	}

	//holding div that contains loader and covers tabulator element to prevent interaction
	.tablulator-loader{
		position:absolute;
		top:0;
		left:0;
		z-index:100;
		height:100%;
		width:100%;
		background:rgba(0,0,0,.4);
		text-align:center;

		//loading message element
		.tabulator-loader-msg{

			//loading message
			.tabulator-loading{
				display:inline-block;
				border:4px solid #333;
				border-radius:10px;
				padding:10px 20px;
				background:#fff;
				font-weight:bold;
				font-size:16px;
				color:#000;
			}

			//error message
			.tabulator-error{
				display:inline-block;
				border:4px solid #D00;
				border-radius:10px;
				padding:10px 20px;
				background:#fff;
				font-weight:bold;
				font-size:16px;
				color:#590000;
			}
		}
	}
}