/**
 * Estilos para vista previa y edición de imágenes en el carrito.
 * Color base: #198fd9
 */

/* ===================================
   VISTA PREVIA EN EL CARRITO
   =================================== */

.wc-print-workflow-cart-images {
	margin: 15px 0;
	padding: 15px;
	background: #f9f9f9;
	border-radius: 8px;
	border-left: 3px solid #198fd9;
}

.cart-images-grid {
	display: flex;
	flex-wrap: nowrap; /* keep thumbnails in a single horizontal row */
	gap: 10px;
	margin-bottom: 12px;
	align-items: flex-start;
	overflow-x: auto; /* allow horizontal scroll when container is narrow */
	-webkit-overflow-scrolling: touch;
	padding-bottom: 6px;
}

.cart-image-item {
	position: relative;
	flex: 0 0 80px;
	width: 80px;
	height: 80px;
	border-radius: 6px;
	overflow: hidden;
	background: #ffffff;
	border: 2px solid #e0e0e0;
	transition: all 0.3s ease;
	cursor: pointer;
}

.cart-image-item + .cart-image-item {
	margin-left: 6px;
}

/* If you prefer wrapping on wider screens, allow it */
@media (min-width: 900px) {
	.cart-images-grid {
		flex-wrap: wrap;
	}
}

/* High-specificity overrides to prevent theme styles from forcing vertical layout
   Ensures thumbnails stay in a horizontal row and allow horizontal scrolling. */
.wc-print-workflow-cart-edit-section .cart-images-grid,
.wc-print-workflow-cart-images .cart-images-grid {
	display: flex !important;
	flex-wrap: nowrap !important;
	gap: 10px !important;
	margin-bottom: 12px !important;
	align-items: flex-start !important;
	overflow-x: auto !important;
	-webkit-overflow-scrolling: touch !important;
	padding-bottom: 6px !important;
}

.wc-print-workflow-cart-edit-section .cart-image-item,
.wc-print-workflow-cart-images .cart-image-item {
	flex: 0 0 72px !important;
	width: 72px !important;
	height: 72px !important;
	max-width: none !important;
}

.wc-print-workflow-cart-edit-section .cart-image-item + .cart-image-item,
.wc-print-workflow-cart-images .cart-image-item + .cart-image-item {
	margin-left: 6px !important;
}

/* If parent container is very narrow, keep the grid scrollable horizontally */
.wc-print-workflow-cart-edit-section,
.wc-print-workflow-cart-images {
	overflow: visible !important;
}

.cart-image-item:hover {
	border-color: #198fd9;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(25, 143, 217, 0.2);
}

.cart-image-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cart-image-item .image-number {
	position: absolute;
	top: 5px;
	right: 5px;
	background: rgba(25, 143, 217, 0.9);
	color: #ffffff;
	font-size: 11px;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 10px;
	line-height: 1;
}

.cart-images-count {
	color: #666666;
	font-size: 13px;
	font-weight: 500;
	text-align: center;
}

/* ===================================
   SECCIÓN DE EDICIÓN DEL CARRITO
   =================================== */

.wc-print-workflow-cart-edit-section {
	margin: 20px 0;
}

.wc-print-workflow-cart-edit-item {
	margin-bottom: 25px;
	padding: 20px;
	background: #f9f9f9;
	border-radius: 8px;
	border-left: 4px solid #198fd9;
}

.wc-print-workflow-cart-edit-title {
	margin: 0 0 15px 0 !important;
	padding: 0 !important;
	font-size: 18px !important;
	font-weight: 600 !important;
	color: #333 !important;
	line-height: 1.4 !important;
}

/* Override Avada and other theme h3 styles */
h3.wc-print-workflow-cart-edit-title,
.wc-print-workflow-cart-edit-section h3,
.wc-print-workflow-cart-edit-item h3 {
	margin: 0 0 15px 0 !important;
	padding: 0 !important;
	font-size: 18px !important;
	font-weight: 600 !important;
	color: #333 !important;
	line-height: 1.4 !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	border: none !important;
}

/* ===================================
   BOTÓN DE EDICIÓN
   =================================== */

.wc-print-workflow-cart-actions {
	margin-top: 10px;
}

.wc-print-workflow-edit-images {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: #198fd9;
	color: #ffffff;
	border: none;
	padding: 8px 16px;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.3s ease;
}

.wc-print-workflow-edit-images .dashicons {
	width: 18px;
	height: 18px;
	font-size: 18px;
}

.wc-print-workflow-edit-images:hover {
	background: #1565c0;
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(25, 143, 217, 0.3);
}

.wc-print-workflow-edit-images:active {
	transform: translateY(0);
}

/* ===================================
   MODAL DE EDICIÓN
   =================================== */

.wc-print-workflow-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	box-sizing: border-box;
}

.wc-print-workflow-hidden {
	display: none !important;
}

.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.7);
	backdrop-filter: blur(4px);
	animation: fadeIn 0.3s ease;
	z-index: 0;
}

.modal-container {
	position: relative;
	background: #ffffff;
	border-radius: 12px;
	width: 90%;
	max-width: 700px;
	max-height: 90vh;
	overflow: hidden;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	animation: slideUp 0.3s ease;
	display: flex;
	flex-direction: column;
	z-index: 1;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translateY(30px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Modal Header */
.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	background: linear-gradient(135deg, #198fd9 0%, #1565c0 100%);
	color: #ffffff;
	border-bottom: 3px solid #0d5fa3;
}

.modal-header h3 {
	margin: 0;
	font-size: 20px;
	font-weight: 700;
}

.modal-close {
	background: rgba(255, 255, 255, 0.2);
	border: none;
	color: #ffffff;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
}

.modal-close .dashicons {
	width: 24px;
	height: 24px;
	font-size: 24px;
}

.modal-close:hover {
	background: rgba(255, 255, 255, 0.3);
	transform: rotate(90deg);
}

/* Modal Body */
.modal-body {
	padding: 24px;
	overflow-y: auto;
	flex: 1;
}

.current-images-section,
.upload-section {
	margin-bottom: 30px;
}

.current-images-section h4,
.upload-section h4 {
	margin: 0 0 15px 0;
	font-size: 16px;
	font-weight: 600;
	color: #333333;
	display: flex;
	align-items: center;
	gap: 8px;
}

.current-images-section h4::before {
	content: '📸';
	font-size: 20px;
}

.upload-section h4::before {
	content: '📤';
	font-size: 20px;
}

.current-images-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
	gap: 12px;
	padding: 15px;
	background: #f9f9f9;
	border-radius: 8px;
}

.current-images-grid .cart-image-item {
	aspect-ratio: 1;
}

.upload-instructions {
	margin: 0 0 15px 0;
	color: #666666;
	font-size: 14px;
	line-height: 1.5;
}

/* Upload Area */
.upload-area {
	position: relative;
	margin-bottom: 20px;
}

.upload-area input[type="file"] {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	overflow: hidden;
}

.upload-label {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	border: 3px dashed #198fd9;
	border-radius: 12px;
	background: linear-gradient(135deg, rgba(25, 143, 217, 0.05) 0%, rgba(25, 143, 217, 0.1) 100%);
	cursor: pointer;
	transition: all 0.3s ease;
}

.upload-label:hover {
	border-color: #1565c0;
	background: linear-gradient(135deg, rgba(25, 143, 217, 0.1) 0%, rgba(25, 143, 217, 0.15) 100%);
	transform: translateY(-2px);
}

.upload-label .dashicons {
	width: 48px;
	height: 48px;
	font-size: 48px;
	color: #198fd9;
	margin-bottom: 10px;
}

.upload-text {
	display: block;
	font-size: 16px;
	font-weight: 600;
	color: #198fd9;
	margin-bottom: 5px;
}

.upload-hint {
	display: block;
	font-size: 13px;
	color: #666666;
}

.upload-area.drag-over .upload-label {
	border-color: #1565c0;
	background: rgba(25, 143, 217, 0.2);
	transform: scale(1.02);
}

/* Selected Files Preview */
.selected-files-preview {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
	gap: 12px;
	margin-top: 20px;
}

.selected-file-item {
	position: relative;
	aspect-ratio: 1;
	border-radius: 8px;
	overflow: hidden;
	background: #f9f9f9;
	border: 2px solid #198fd9;
}

.selected-file-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.selected-file-item .file-remove {
	position: absolute;
	top: 5px;
	right: 5px;
	background: rgba(244, 67, 54, 0.9);
	color: #ffffff;
	border: none;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	font-weight: 600;
	transition: all 0.3s ease;
}

.selected-file-item .file-remove:hover {
	background: rgba(244, 67, 54, 1);
	transform: scale(1.1);
}

/* Current Files (archivos existentes) */
.current-file-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
}

.current-file-thumb {
	position: relative;
	width: 100%;
	aspect-ratio: 1;
	border-radius: 8px;
	overflow: hidden;
	background: #f9f9f9;
	border: 2px solid #10a37f;
}

.current-file-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}



.current-file-item .wc-print-workflow-file-name {
	display: none; /* Hide filename, use number badge only */
}

.current-file-item .wc-print-workflow-file-meta {
	margin-top: 10px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: center;
	text-align: center;
	max-width: 100%;
	width: 100%;
	box-sizing: border-box;
}

.wc-print-workflow-transparency-badge {
	font-size: 10px;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 999px;
	color: #ffffff;
	line-height: 1.2;
	background: rgba(0, 0, 0, 0.7);
	max-width: 100%;
	box-sizing: border-box;
	text-align: center;
	white-space: normal;
	overflow-wrap: anywhere;
}

.wc-print-workflow-transparency-badge.transparent {
	background: rgba(16, 163, 127, 0.95);
}

.wc-print-workflow-transparency-badge.opaque {
	background: rgba(244, 67, 54, 0.95);
}


.wc-print-workflow-bg-remove {
	font-size: 10px;
	font-weight: 600;
	padding: 4px 8px;
	border-radius: 6px;
	background: rgba(25, 143, 217, 0.95);
	color: #ffffff;
	text-decoration: none;
	max-width: 100%;
	box-sizing: border-box;
	text-align: center;
	white-space: normal;
	overflow-wrap: anywhere;
}

.wc-print-workflow-bg-remove:hover {
	background: rgba(21, 101, 192, 0.95);
	color: #ffffff;
}

.current-file-item .current-file-remove {
	position: absolute;
	top: 5px;
	right: 5px;
	background: rgba(244, 67, 54, 0.9);
	color: #ffffff;
	border: none;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	font-weight: 600;
	transition: all 0.3s ease;
	z-index: 10;
}

.current-file-item .current-file-remove:hover {
	background: rgba(244, 67, 54, 1);
	transform: scale(1.1);
}

.current-file-item .file-number {
	position: absolute;
	bottom: 5px;
	left: 5px;
	background: rgba(0, 0, 0, 0.7);
	color: #ffffff;
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 600;
}

/* Modal Messages */
.modal-messages {
	margin-top: 20px;
}

.wc-print-workflow-modal .wc-print-workflow-bg-remove-notice {
	margin: 18px 0 0;
	padding: 14px 16px;
	border: 1px solid #f1c40f;
	border-radius: 8px;
	background: #ffffff;
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	box-sizing: border-box;
}

.wc-print-workflow-modal .wc-print-workflow-bg-remove-notice .wc-print-workflow-bg-remove-text {
	margin: 0;
	font-size: 13px;
	line-height: 1.4;
	color: #333;
}

.wc-print-workflow-modal .wc-print-workflow-bg-remove-notice a.wc-print-workflow-bg-remove-button.button {
	float: none !important;
	margin: 0 !important;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 36px;
	padding: 0 18px;
	border-radius: 6px;
	background: #2271b1 !important;
	border-color: #2271b1 !important;
	color: #ffffff !important;
	text-decoration: none;
}

.wc-print-workflow-modal .wc-print-workflow-bg-remove-notice a.wc-print-workflow-bg-remove-button.button:hover {
	background: #135e96 !important;
	border-color: #135e96 !important;
	color: #ffffff !important;
}

.modal-message {
	padding: 12px 16px;
	border-radius: 6px;
	margin-bottom: 10px;
	font-size: 14px;
	line-height: 1.5;
}

.modal-message.success {
	background: #e8f5e9;
	color: #2e7d32;
	border-left: 3px solid #4caf50;
}

.modal-message.error {
	background: #ffebee;
	color: #c62828;
	border-left: 3px solid #f44336;
}

.modal-message.info {
	background: #e3f2fd;
	color: #1565c0;
	border-left: 3px solid #198fd9;
}

/* Modal Footer */
.modal-footer {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	flex-wrap: nowrap;
	gap: 12px;
	padding: 20px 24px;
	background: #f9f9f9;
	border-top: 1px solid #e0e0e0;
}

.modal-footer .button {
	padding: 10px 24px;
	border-radius: 6px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.3s ease;
	border: none;
	flex: 0 0 auto;
	white-space: nowrap;
}

.modal-footer .button-secondary {
	background: #ffffff;
	color: #666666;
	border: 2px solid #e0e0e0;
	min-width: 140px;
}

.modal-footer .button-secondary:hover {
	background: #f5f5f5;
	border-color: #cccccc;
	transform: none;
	box-shadow: none;
}

.modal-footer .button-primary {
	background: #198fd9;
	color: #ffffff;
	min-width: 170px;
}

.modal-footer .button-primary:hover {
	background: #1565c0;
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(25, 143, 217, 0.3);
}

.modal-footer .button-primary:disabled {
	background: #cccccc;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

/* Loading State */
.modal-loading {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(255, 255, 255, 0.9);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	gap: 15px;
	z-index: 10;
}

.modal-loading .spinner {
	width: 50px;
	height: 50px;
	border: 4px solid #e0e0e0;
	border-top-color: #198fd9;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.modal-loading .loading-text {
	font-size: 16px;
	font-weight: 600;
	color: #198fd9;
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 768px) {
	.cart-images-grid {
		grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
		gap: 8px;
	}

	.modal-container {
		width: 95%;
		max-height: 95vh;
	}

	.modal-header {
		padding: 16px 20px;
	}

	.modal-header h3 {
		font-size: 18px;
	}

	.modal-body {
		padding: 20px;
	}

	.current-images-grid,
	.selected-files-preview {
		grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
		gap: 10px;
	}

	.upload-label {
		padding: 30px 20px;
	}

	.upload-label .dashicons {
		width: 40px;
		height: 40px;
		font-size: 40px;
	}

	.modal-footer {
		flex-direction: column;
		gap: 10px;
	}

	.modal-footer .button {
		width: 100%;
	}
}

@media (max-width: 480px) {
	.cart-images-grid {
		grid-template-columns: repeat(3, 1fr);
	}

	.current-images-grid,
	.selected-files-preview {
		grid-template-columns: repeat(3, 1fr);
	}
}
