@use "../common/variables" as *;
@use "../common/mixins/utilities" as *;

//
// Atum Order Meta Boxes
//-----------------------

@use "sass:math";

#atum-help-guide-link-wrap {
	margin-top: -5px !important;
}

//
// Data meta box
//---------------

#atum_order_data {
	
	.hndle, .handlediv, .postbox-header {
		display: none;
	}
	
	.inside {
		padding: 0;
	}
	
	.panel {
		padding: 23px 24px;
		
		h2 {
			margin: 0;
			font-size: 21px;
			font-weight: 300;
			line-height: 1.2;
			text-shadow: 1px 1px 1px $white;
			padding: 0;
		}
		
		h3 {
			font-size: 14px;
		}
		
		h3, h4 {
			color: $dark;
			margin: 1.33em 0 0
		}
		
		p {
			&.atum_order_number {
				margin: 0;
				line-height: 1.6em;
				font-size: 16px;
			}
		}
		
		select {
			display: none;
		
			+ .select2-container {
				max-width: 297px;
			}
		
		}
		
		.atum_order_data_column_container {
			clear: both;
			margin-top: math.div($grid-gutter-width, 2);
		}
		
		.atum_order_data_column {
			width: 100%;
			padding: 0 2% 0 0;
			float: left;
			
			> h3 {
				span {
					display: block;
				}
			}
			
			&:last-child {
				padding-right: 0;
			}
			
			p {
				padding: 0 !important;
				
				&.none_set {
					color: $wp-gray-1;
				}
			}
			
			.address {
				strong {
					display: block;
				}
			}
			
			.atum-datepicker {
				width: 50%;
			}
			
			.hour, .minute {
				width: 3.5em;
			}
			
		}
		
	}
	
}

//
// Actions meta box
//------------------

#atum_order_actions {
	.atum-meta-box {
		padding: 0;
	}
}

.atum_order_actions {
	margin: 0;
	overflow: hidden;
	zoom: 1;
	
	li {
		padding: 6px 0;
		margin: 0;
		line-height: 1.6em;
		float: left;
		width: 50%;
		text-align: center;
		
		a {
			float: none;
			text-align: center;
			text-decoration: underline;
		}
		
		&.wide {
			width: auto;
			float: none;
			clear: both;
			padding: 6px;
			text-align: left;
			overflow: hidden;
		}
		
		#delete-action {
			line-height: 25px;
			vertical-align: middle;
			text-align: left;
			float: left;
		}
		
		.pdf-link {
			i {
				font-size: 1.5em;
				line-height: 1.5em;
				vertical-align: middle;
			}
		}
		
		.save-atum-order {
			float: right;
		}
		
		&#actions {
			overflow: hidden;
			
			.button {
				width: 24px;
				box-sizing: border-box;
				float: right;
			}
			
			select {
				width: 225px;
				box-sizing: border-box;
				float: left;
			}
		}
	}
	// WMPL lang dropdown compatibility
	.wpml-ls .select2-container {
		width: auto !important;
	}
}

//
// Notes meta box
//----------------

#atum_order_notes {
	.inside, .atum-meta-box {
		margin: 0;
		padding: 0;
	}
}

ul.atum_order_notes {
	padding: 2px 0 0;
	
	li {
		padding: 0 10px;
		
		.note_content {
			padding: 10px;
			background: $gray-200;
			position: relative;
			
			p {
				margin: 0;
				padding: 0;
				word-wrap: break-word;
			}
		}
		
		&.system-note {
			.note_content {
				background-color: $wc-red-light-alt;
				
				&:after {
					border-color: $wc-red-light-alt transparent;
				}
			}
		}
		
		p.meta {
			padding: 10px;
			color: $wp-gray-1;
			margin: 0;
			font-size: 11px;
			
			.exact-date {
				border-bottom: 1px dotted $wp-gray-1;
			}
		}
		
		a.delete_note {
			color: $wp-red;
		}
		
		.note_content::after {
			content: '';
			display: block;
			position: absolute;
			bottom: -10px;
			left: 20px;
			width: 0;
			height: 0;
			border-width: 10px 10px 0 0;
			border-style: solid;
			border-color: $gray-200 transparent;
		}
	}
	
}

div.add_note {
	border-top: 1px solid $wp-gray-4;
	padding: 10px 10px 0;
	
	h4 {
		margin-top: 5px !important;
	}
	
	#add_atum_order_note {
		width: 100%;
		height: 70px;
		border-radius: 4px;
		margin-top: 4px;
		box-shadow: none;
	}
}

//
// Items meta box
//----------------

#atum_order_items {
	
	.postbox-header {
		display: none;
	}
	
	.inside {
		display: block !important;
		margin: 0;
		padding: 0;
		background: $gray-100;
	}
	
	.atum-meta-box {
		padding: 0;
	}
	
	.atum-order-data-row {
		border-bottom: 1px solid $gray-300;
		padding: 1.5em 2em;
		background: $gray-100;
		line-height: 2em;
		text-align: right;
		
		@include clearfix;
		
		p {
			margin: 0;
			line-height: 2em;
		}
		
		.atum-used-coupons {
			text-align: left;
			
			.tips {
				display: inline-block;
			}
		}
		
	}
	
	.atum-used-coupons {
		float: left;
		width: 50%;
	}
	
	.atum-order-totals {
		float: right;
		width: 50%;
		margin: 0;
		padding: 0;
		text-align: right;
		
		.amount {
			font-weight: 700;
		}
		
		.label {
			vertical-align: top;
		}
		
		.total {
			font-size: 1em !important;
			width: 10em;
			margin: 0 0 0 0.5em;
			box-sizing: border-box;
			
			input[type='text'] {
				width: 96%;
				float: right;
			}
		}
		
		.refunded-total {
			color: $danger;
		}
	}
	
	.refund-actions {
		margin-top: 5px;
		padding-top: 12px;
		border-top: 1px solid $gray-300;
		
		.button {
			float: right;
			margin-left: 4px;
		}
		
		.cancel-action {
			float: left;
			margin-left: 0;
		}
	}
	
	.atum-order-item-bulk-edit {
		.cancel-action {
			float: left;
			margin-left: 0;
		}
	}
	
	.add_meta {
		margin-left: 0 !important;
	}
	
	h3 small {
		color: $wp-gray-1;
	}
	
	.amount {
		white-space: nowrap;
	}
	
	.add-items {
		.description {
			margin-right: 10px;
		}
		
		.button {
			float: left;
			margin-right: 0.25em;
		}
		
		.button-primary {
			float: none;
			margin-right: 0;
		}
	}
	
	.hndle, .handlediv {
		display: none;
	}
	
	.atum_order_items_wrapper {
		margin: 0;
		overflow-x: auto;
		
		table.atum_order_items {
			width: 100%;
			background: $white;
			border-collapse: collapse;
			
			thead {
				
				th {
					text-align: left;
					padding: 1em;
					font-weight: normal;
					color: $wp-gray-1;
					background: $wp-gray-6;
					-webkit-touch-callout: none;
					user-select: none;
					
					&.sortable {
						cursor: pointer;
					}
					
					&:last-child {
						padding-right: 2em;
					}
					
					&:first-child {
						padding-left: 2em;
					}
					
					.atum-arrow {
						float: right;
						position: relative;
						margin-right: -1em;
					}
				}
				
			}
			
			tbody th, td {
				padding: 1.5em 1em 1em;
				text-align: left;
				line-height: 1.5em;
				vertical-align: top;
				border-bottom: 1px solid $wp-gray-6;
				
				textarea {
					width: 100%;
				}
				
				select {
					width: 50%;
				}
				
				input, textarea {
					font-size: 14px;
					padding: 4px;
					color: $wp-gray-2;
				}
				
				&:last-child {
					padding-right: 2em;
				}
				
				&:first-child {
					padding-left: 2em;
				}
				
			}
			
			tbody {
				
				tr {
					
					td {
						cursor: pointer;
					}
					
					&.selected {
						background: $wp-pink-light;
						
						td {
							border-color: $wp-pink;
							opacity: 0.8;
						}
					}
					
					&.invalid {
						background-color: rgba( $wc-red-light, 0.5);
					}
					
					&:last-child {
						td {
							border-bottom: 1px solid $gray-400;
						}
					}
					
					&:first-child {
						td {
							border-top: 8px solid $wp-gray-6;
						}
					}
					
				}
				
				&#order_line_items {
					tr:first-child td {
						border-top: none;
					}
				}
				
			}
			
			td.thumb {
				text-align: left;
				width: 38px;
				padding-bottom: 1.5em;
				
				.atum-order-item-thumbnail {
					width: 38px;
					height: 38px;
					background: $gray-200;
					color: $gray-600;
					position: relative;
					font-size: 21px;
					display: block;
					text-align: center;
					
					&::before {
						@include atum-icon-font-family;
						content: $atmi-picture;
						width: 38px;
						line-height: 38px;
						display: block;
						position: absolute;
					}
					
					img {
						width: 100%;
						height: 100%;
						margin: 0;
						padding: 0;
						position: relative;
					}
					
				}
				
			}
			
			td.name {
				.atum-order-item-sku, .atum-order-item-variation {
					display: block;
					margin-top: 0.5em;
					font-size: 0.92em !important;
					color: $wp-gray-7;
				}
			}
			
			.item {
				min-width: 200px;
			}
			
			.center, .variation-id {
				text-align: center;
			}
			
			.cost, .tax, .quantity, .line_cost, .line_tax, .tax_class, .item_cost {
				text-align: right;
				
				label {
					white-space: nowrap;
					color: $wp-gray-1;
					font-size: 0.833em;
					
					input {
						display: inline;
					}
				}
				
				input {
					width: 70px;
					vertical-align: middle;
					text-align: right;
				}
				
				select {
					width: 85px;
					height: 26px;
					vertical-align: middle;
					font-size: 1em;
				}
				
				.split-input {
					display: inline-block;
					background: $white;
					border: 1px solid $wp-gray-4;
					box-shadow: inset 0 1px 2px rgba($black, 0.07);
					margin: 1px 0;
					min-width: 80px;
					overflow: hidden;
					line-height: 1em;
					text-align: right;
					
					div.input {
						width: 100%;
						box-sizing: border-box;
						
						label {
							font-size: 0.75em;
							padding: 4px 6px 0;
							color: $wp-gray-2;
							display: block;
						}
						
						input {
							width: 100%;
							box-sizing: border-box;
							border: 0;
							box-shadow: none;
							margin: 0;
							padding: 0 6px 4px;
							color: $wp-gray-2;
							background: transparent;
							
							@include placeholder {
								color: $wp-gray-4;
							}
						}
						
					}
					
					div.input:first-child {
						border-bottom: 1px dashed $wp-gray-4;
						background: $white;
						
						label, input {
							color: #ccc;
						}
						
					}
					
				}
				
				.view {
					white-space: nowrap;
				}
				
				.edit {
					text-align: left;
				}
				
				small.times, del, .atum-order-item-taxes, .atum-order-item-discount, .atum-order-item-refund-fields {
					font-size: 0.92em !important;
					color: $wp-gray-7;
				}
				
				.atum-order-item-taxes, .atum-order-item-refund-fields {
					margin: 0;
					label {
						display: block;
					}
				}
				
				.atum-order-item-discount {
					display: block;
					margin-top: 0.5em;
				}
				
				small.times {
					margin-right: 0.25em;
				}
				
			}
			
			.quantity {
				text-align: center;
				
				input {
					text-align: center;
					width: 50px;
				}
				
			}
			
			span.subtotal {
				opacity: 0.5;
			}
			
			td, th {
				&.tax_class {
					text-align: left;
				}
			}
			
			.calculated {
				border-color: $wc-red-light;
				border-style: dotted;
			}
			
			table.meta {
				width: 100%;
				
				button {
					padding-left: 7px;
					padding-right: 7px;
					font-size: 12px;
				}
			}
			
			table.meta, table.display_meta {
				margin: 0.5em 0 0;
				font-size: 0.92em !important;
				color: $wp-gray-7;
				
				tr {
					
					th {
						border: 0;
						padding: 0 4px 0.5em 0;
						line-height: 1.5em;
						width: 20%;
						white-space: nowrap;
					}
					
					td {
						padding: 0 4px 0.5em 0;
						border: 0;
						line-height: 1.5em;
						
						input {
							width: 100%;
							margin: 0;
							position: relative;
							border-bottom: 0;
							box-shadow: none;
						}
						
						textarea {
							width: 100%;
							height: 4em;
							margin: 0;
							box-shadow: none;
						}
						
						input:focus + textarea {
							border-top-color: $wp-gray-1;
						}
						
						p {
							margin: 0 0 0.5em;
							line-height: 1.5em;
						}
						
						p:last-child {
							margin: 0;
						}
						
					}
					
				}
				
			}
			
			.refund_by {
				border-bottom: 1px dotted $wp-gray-1;
			}
			
			tr {
				
				&.fee, &.shipping {
					.thumb {
						div {
							display: block;
							position: relative;
							height: 1em;
							width: 1em;
							font-size: 1.5em;
							line-height: 1em;
							vertical-align: middle;
							margin: 0;
							
							&:before {
								color: $gray-500;
							}
						}
					}
				}
				
				&.fee {
					.thumb div {
						&:before {
							@include atum-icon-font-family;
							content: $atmi-plus-circle;
						}
					}
				}
				
				&.shipping {
					.thumb div {
						&:before {
							@include atum-icon-font-family;
							content: $atmi-shipping;
						}
					}
					
					.shipping_method_name, .shipping_method {
						width: 100%;
						margin: 0 0 0.5em;
					}
				}
				
			}
			
			th.line_tax {
				white-space: nowrap;
			}
			
			th.line_tax, td.line_tax {
				
				.delete-atum-order-tax {
					display: block;
					text-indent: -9999px;
					position: relative;
					height: 1em;
					width: 1em;
					float: right;
					font-size: 14px;
					visibility: hidden;
					margin: 3px -18px 0 0;
					
					&:before {
						@include atum-icon-font-family;
						content: $atmi-cross-circle;
						color: $wp-gray-1;
					}
					
					&:hover {
						&:before {
							color: $danger;
						}
					}
				}
				
				&:hover {
					.delete-atum-order-tax {
						visibility: visible;
					}
				}
				
			}
			
			small.refunded {
				display: block;
				color: $danger;
				white-space: nowrap;
				margin-top: 0.5em;
				
				&:before {
					@include atum-icon-font-family;
					content: $atmi-undo;
					position: relative;
					top: auto;
					left: auto;
					margin: -1px 4px 0 0;
					vertical-align: middle;
					line-height: 1em;
				}
				
			}
			
			.order-item-icons {
				margin-top: 5px;
				
				i, span {
					font-size: 16px;
					display: inline-block;
					vertical-align: middle;
					margin-right: 4px;
				}
			}
			
		}
		
	}
	
	.atum-order-edit-line-item {
		padding-left: 0;
	}
	
	.atum-order-edit-line-item-actions {
		width: 44px;
		text-align: right;
		padding-left: 0;
		vertical-align: middle;
		
		a {
			color: $gray-500;
			display: inline-block;
			cursor: pointer;
			padding: 0 0 0.5em;
			margin: 0 0 0 12px;
			vertical-align: middle;
			text-decoration: none;
			line-height: 16px;
			width: 16px;
			overflow: hidden;
			
			&:before {
				margin: 0;
				padding: 0;
				font-size: 16px;
				width: 16px;
				height: 16px;
			}
			
			&:hover {
				&:before {
					color: $wp-gray-1;
				}
			}
			
			&:first-child {
				margin-left: 0;
			}
			
		}
		
		.edit-atum-order-item {
			&:before {
				@include atum-icon-font-family;
				content: $atmi-pencil;
				position: relative;
			}
			
			&:focus {
				box-shadow: none;
			}
		}
		
		.delete-atum-order-item, .delete_refund {
			
			&:before {
				@include atum-icon-font-family;
				content: $atmi-cross;
				position: relative;
			}
			
			&:hover {
				&:before {
					color: $danger;
				}
			}
			
			&:focus {
				box-shadow: none;
			}
			
		}
		
	}
	
	tbody tr .atum-order-edit-line-item-actions {
		visibility: hidden;
	}
	
	tbody tr:hover .atum-order-edit-line-item-actions {
		visibility: visible;
	}
	
	.atum-order-totals .atum-order-edit-line-item-actions {
		width: 1.5em;
		visibility: visible !important;
		
		a {
			padding: 0;
		}
	}
}

// Items blocker
.items-blocker {
	position: absolute;
	top: 0;
	bottom: 0;
	background: rgba($black, .5);
	z-index: 1;
	
	&, h3 {
		left: 0;
		right: 0;
	}
	
	h3 {
		color: $white;
		font-size: 30px;
		line-height: 1.3;
		margin: 0;
		padding: 0 $grid-gutter-width*2;
		@include vertical-align-absolute;
		text-align: center;
	}
	
	&.unblocked {
		display: none;
	}
}