/**
 * Estilos del configurador frontend.
 *
 * @package PimpamPrint
 * @since 1.0.0
 */

/* ==========================================================================
   Configurador principal
   ========================================================================== */

/* Ocultar dimensiones cuando envelope_type está activo */
.pimpam-hidden-when-envelope {
	display: none !important;
}

/* Ocultar gramaje por defecto (mostrar solo cuando paper_type está seleccionado) */
[data-field="paper_weight"] {
	display: none;
}

[data-field="paper_weight"]:visible {
	display: block;
}

.pimpam-configurator {
	padding: 24px;
	margin: 24px 0;
}

.pimpam-configurator-content {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 20px;
}

@media (max-width: 768px) {
	.pimpam-configurator-content {
		grid-template-columns: 1fr;
	}
}

/* ==========================================================================
   Campos
   ========================================================================== */

.pimpam-fields-wrapper {
	display: grid;
	grid-template-columns: repeat(2, 100%);
	gap: 20px;
	margin-bottom: 30px;
}

@media (max-width: 768px) {
	.pimpam-fields-wrapper {
		grid-template-columns: 1fr;
	}
}

.pimpam-fields {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.pimpam-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.pimpam-field label {
	font-weight: 600;
	color: #333;
	font-size: 14px;
}

.pimpam-field .required {
	color: #dc3232;
	margin-left: 4px;
}

.pimpam-field select,
.pimpam-field input[type="number"] {
	padding: 10px 12px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 14px;
	background: #fff;
	transition: border-color 0.2s ease;
}

.pimpam-field select:focus,
.pimpam-field input[type="number"]:focus {
	outline: none;
	border-color: #0073aa;
	box-shadow: 0 0 0 1px #0073aa;
}

.pimpam-field select:disabled,
.pimpam-field input[type="number"]:disabled {
	background: #eee;
	color: #454545;
}

.pimpam-field-checkbox label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 500;
	cursor: pointer;
}

.pimpam-field-checkbox input[type="checkbox"] {
	width: 18px;
	height: 18px;
	cursor: pointer;
}

.pimpam-field.hidden {
	display: none;
}

.pimpam-file-selected {
	font-size: 12px;
}

.pimpam-cantidad-limits {
	font-size: 12px;
	color: #666;
	font-weight: 400;
}

/* ==========================================================================
   Precio
   ========================================================================== */

.pimpam-price-display {
	position: sticky;
	align-self: start;
}

.pimpam-price-loading {
	display: flex;
	align-items: center;
	gap: 12px;
	color: #666;
	padding: 16px;
	text-align: center;
	justify-content: center;
}

.pimpam-price-loading .spinner {
	width: 20px;
	height: 20px;
	border: 3px solid #f3f3f3;
	border-top: 3px solid #0073aa;
	border-radius: 50%;
	animation: spin 1s linear infinite;
}

@keyframes spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

.pimpam-price-result h4 {
	margin: 0 0 16px;
	font-size: 1.1em;
	color: #333;
}

.pimpam-price-breakdown table {
	width: 100%;
	border-collapse: collapse;
}

.pimpam-price-breakdown tbody tr {
	border-bottom: 1px solid #f0f0f0;
}

.pimpam-price-breakdown tbody tr:last-child {
	border-bottom: none;
}

.pimpam-price-breakdown td {
	padding: 10px 0;
	font-size: 14px;
}

.pimpam-price-breakdown td:last-child {
	text-align: right;
	font-weight: 500;
}

.pimpam-price-total td {
	padding-top: 16px;
	font-size: 1.2em;
	color: #0073aa;
}

.pimpam-price-total td .price {
	font-size: 1.3em;
}

/* Precio sin IVA (más pequeño y discreto) */
.pimpam-price-without-tax {
	display: block;
	font-size: 0.5em;
	color: #666;
	font-weight: normal;
	margin-top: 0;
}

.pimpam-price-error {
	padding: 16px;
	background: #fef5f5;
	border: 1px solid #dc3232;
	border-radius: 4px;
	color: #dc3232;
}

.pimpam-price-error .error-message {
	margin: 0;
	font-size: 14px;
}

/* ==========================================================================
   Subir archivo
   ========================================================================== */

.pimpam-file-upload-section {
    grid-column: 1 / -1;
}

.pimpam-field-file {
    width: 100%;
}

.pimpam-file-input-wrapper {
	position: relative;
	display: flex;
	gap: 10px;
}

#pimpam_file_select_btn {
	padding: 10px 20px;
	font-size: 14px;
	font-weight: 600;
	border: none;
	background-color: #00A6FB;
	color: #fff;
	cursor: pointer;
	transition: background-color 0.3s ease;
}

#pimpam_file_select_btn:hover {
	background-color: #005a87;
}

/* Dropzone - Zona de arrastre */
.pimpam-dropzone {
	position: relative;
	padding: 32px 20px;
	border: 3px dashed #ccc;
	background-color: #fafafa;
	text-align: center;
	transition: all 0.3s ease;
	cursor: pointer;
}

.pimpam-dropzone:hover {
	background-color: #f0f0f0;
	border-color: #999;
}

.pimpam-dropzone-content {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 15px;
}

.pimpam-upload-icon {
	color: #666;
	width: 36px;
	height: 36px;
}

.pimpam-dropzone-text {
	margin: 0;
	font-size: 16px;
	color: #666;
	font-weight: 500;
}

/* Ocultar icono y texto cuando hay archivo seleccionado */
.pimpam-dropzone.pimpam-has-file .pimpam-upload-icon,
.pimpam-dropzone.pimpam-has-file .pimpam-dropzone-text {
	display: none;
}

.pimpam-file-selected {
	margin-top: 10px;
	font-size: 14px;
	color: #0073aa;
	font-weight: 600;
}

/* Estado cuando se arrastra un archivo sobre la zona */
.pimpam-dropzone.pimpam-drag-over {
	border-color: #0073aa;
	border-style: solid;
	background-color: #e6f2ff;
	box-shadow: 0 0 10px rgba(0, 115, 170, 0.3);
}

/* Overlay que aparece al arrastrar */
.pimpam-drop-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: #00A6FB;
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 10;
	pointer-events: none;
}

.pimpam-drop-overlay.pimpam-visible {
	display: flex;
}

.pimpam-drop-overlay-content {
	text-align: center;
	color: #fff;
}

.pimpam-drop-overlay-content svg {
	color: #fff;
	margin-bottom: 10px;
}

.pimpam-drop-overlay-content p {
	margin: 0;
	font-size: 20px;
	font-weight: 600;
}

/* Cursor durante el arrastre */
.pimpam-dropzone.pimpam-drag-over * {
	pointer-events: none;
}

/* ==========================================================================
   Sección de Compra (Precio y Botón)
   ========================================================================== */

.pimpam-purchase-section {
	grid-column: 1 / -1;
	display: flex;
	align-items: center;
  	justify-content: space-between;
}

.pimpam-price-total {
	font-size: 28px;
	font-weight: 700;
	color: #333;
	margin-bottom: 20px;
}

.pimpam-add-to-cart {
	display: flex;
	gap: 12px;
}

.pimpam-add-to-cart button {
	flex: 1;
	padding: 14px 24px;
	font-size: 16px;
	font-weight: 600;
	border: none;
	cursor: pointer;
	transition: all 0.3s ease;
}

.pimpam-add-to-cart button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

@media (max-width: 768px) {
	.pimpam-purchase-section {
		grid-column: 1;
		padding: 16px;
	}
	
	.pimpam-price-total {
		font-size: 24px;
	}
}

/* ==========================================================================
   Estados
   ========================================================================== */

.pimpam-field.has-error select,
.pimpam-field.has-error input {
	border-color: #dc3232;
}

.pimpam-field .error-message {
	color: #dc3232;
	font-size: 13px;
	margin-top: 4px;
}

.pimpam-field.is-loading {
	opacity: 0.6;
	pointer-events: none;
}

.pimpam-field .description {
	font-size: 12px;
}

button#pimpam_add_to_cart:disabled {
	background-color: #7ed2fc;
}

#pimpam_max_qty_warning {
	font-size: 0.8em;
	color: #dc3232;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 480px) {
	.pimpam-configurator {
		padding: 16px;
	}

	.pimpam-configurator-title {
		font-size: 1.2em;
	}

	.pimpam-price-display {
		position: static;
		width: 100%;
	}

	.pimpam-purchase-section {
		flex-direction: column;
		align-items: stretch;
		gap: 16px;
	}

	.pimpam-price-total .woocommerce-Price-amount {
		display: flex;
		justify-content: space-evenly;
		align-items: baseline;
	}
}
