/**
 * Variations Gallery Module - Admin Styles
 *
 * @package OM_Product_Page_Essentials
 */

/*
 * The gallery in WooCommerce's variation panel (11.3.16, A3, the owner): a form row as its neighbours are (its label is
 * WooCommerce's field label: the panel's own rule draws it), WordPress's admin buttons, the thumbnails and their remove
 * control as WooCommerce's product gallery draws them (#product_images_container in WooCommerce's admin sheet).
 */
.om-ppe-variation-gallery label {
	display: block;
}

/* Sortable gallery list: an empty one takes no room (no blank box). */
.om-ppe-variation-gallery-sortable {
	display: flex;
	flex-wrap: wrap;
	gap: 9px;
	list-style: none;
	margin: 9px 0 0;
	padding: 0;
}

.om-ppe-variation-gallery-sortable:empty {
	display: none;
}

.om-ppe-variation-gallery-sortable li {
	position: relative;
	box-sizing: border-box;
	width: 80px;
	height: 80px;
	margin: 0;
	background: #f7f7f7;
	border: 1px solid #d5d5d5;
	border-radius: 2px;
	cursor: move;
}

.om-ppe-variation-gallery-sortable li figure {
	width: 100%;
	height: 100%;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.om-ppe-variation-gallery-sortable li figure img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

/*
 * Remove control: WooCommerce's gallery delete, a dismiss icon on a white disc at the corner, shown on hover and while
 * it holds the focus (a button: a keyboard reaches it; its own box reset to keep the disc). Hidden by its opacity, never
 * by display: a control with display none takes no focus (A3b, the reviewer), and a tap on the corner still hits it.
 */
.om-ppe-variation-gallery-sortable li .om-ppe-remove-item {
	position: absolute;
	top: -8px;
	right: -8px;
	display: block;
	opacity: 0;
	box-sizing: content-box;
	width: 1em;
	height: 1em;
	margin: 0;
	padding: 0;
	border: 0;
	font: inherit;
	font-size: 1.4em;
	line-height: 1em;
	color: #999;
	background: #fff;
	border-radius: 50%;
	cursor: pointer;
	z-index: 10;
}

.om-ppe-variation-gallery-sortable li .om-ppe-remove-item::before {
	font-size: 1em;
	width: 1em;
	height: 1em;
	line-height: 1em;
}

.om-ppe-variation-gallery-sortable li:hover .om-ppe-remove-item,
.om-ppe-variation-gallery-sortable li:focus-within .om-ppe-remove-item,
.om-ppe-variation-gallery-sortable li .om-ppe-remove-item:focus-visible {
	opacity: 1;
}

.om-ppe-variation-gallery-sortable li .om-ppe-remove-item:hover {
	color: #a00;
}

/* Video thumbnail indicator */
.om-ppe-video-thumbnail figure::after,
.om-ppe-video-url-thumbnail figure::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 24px;
	height: 24px;
	background: rgba(0, 0, 0, 0.6);
	border-radius: 50%;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 14px;
	pointer-events: none;
}

/* Edit overlay for video URLs */
.om-ppe-video-url-thumbnail figure::before {
	content: attr(data-edit-text);
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	font-size: 10px;
	text-align: center;
	padding: 2px;
	opacity: 0;
	transition: opacity 0.2s;
	cursor: pointer;
}

.om-ppe-video-url-thumbnail:hover figure::before {
	opacity: 1;
}

/* Sortable placeholder: WooCommerce's gallery's, a dashed frame. */
.om-ppe-variation-gallery-sortable .ui-sortable-placeholder {
	visibility: visible !important;
	border: 3px dashed #ddd;
}

/* The buttons: WordPress's admin buttons, inline with a space between them (WordPress's own gap). */
.om-ppe-variation-gallery-actions {
	margin: 9px 0 0;
}

/* Video URL Popup */
.om-ppe-video-url-popup {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.7);
	z-index: 100050;
	display: flex;
	align-items: center;
	justify-content: center;
}

.om-ppe-video-url-popup-inner {
	width: 90%;
	max-width: 500px;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
	overflow: hidden;
}

.om-ppe-video-url-popup-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 15px 20px;
	background: #f0f0f1;
	border-bottom: 1px solid #ddd;
}

.om-ppe-video-url-popup-header h3 {
	margin: 0;
	font-size: 16px;
}

.om-ppe-video-url-popup-close {
	text-decoration: none;
	color: #666;
	font-size: 20px;
}

.om-ppe-video-url-popup-close:hover {
	color: #000;
}

.om-ppe-video-url-popup-content {
	padding: 20px;
}

.om-ppe-video-url-popup-field {
	margin-bottom: 15px;
}

.om-ppe-video-url-popup-field:last-child {
	margin-bottom: 0;
}

.om-ppe-video-url-popup-field label {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
}

.om-ppe-video-url-popup-field input[type="text"],
.om-ppe-video-url-popup-field select {
	width: 100%;
}

.om-ppe-video-url-popup-field .description {
	display: block;
	margin-top: 5px;
	color: #666;
	font-size: 12px;
}

.om-ppe-video-url-popup-footer {
	padding: 15px 20px;
	background: #f0f0f1;
	border-top: 1px solid #ddd;
	text-align: right;
}
