/**
 * WP Post Builder - Public Styles
 *
 * 100% responsive. Optimizado para iOS/Android.
 * Padding base 10px en todos los componentes.
 *
 * @package WP_Post_Builder
 */

/* ==========================================================================
   Reset y contenedor general
   ========================================================================== */

.wppb-form-wrapper {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	padding: 10px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	color: #1d2327;
	-webkit-text-size-adjust: 100%;
}

.wppb-form-wrapper *,
.wppb-form-wrapper *::before,
.wppb-form-wrapper *::after {
	box-sizing: border-box;
}

.wppb-form {
	width: 100%;
	max-width: 100%;
	margin: 0;
}

/* ==========================================================================
   Mensajes globales
   ========================================================================== */

.wppb-form-messages {
	margin-bottom: 12px;
}

.wppb-form-messages:empty {
	display: none;
}

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

.wppb-message.is-error {
	background: #fcf0f1;
	color: #a91e22;
	border-left: 4px solid #d63638;
}

.wppb-message.is-success {
	background: #ecf7ed;
	color: #1e6b30;
	border-left: 4px solid #00a32a;
}

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

.wppb-field {
	width: 100%;
	margin-bottom: 14px;
	padding: 10px;
	background: #ffffff;
	border-radius: 6px;
	border: 1px solid #e5e5e5;
}

.wppb-label {
	display: block;
	font-weight: 600;
	font-size: 14px;
	margin-bottom: 6px;
	color: #1d2327;
	line-height: 1.4;
}

.wppb-required {
	color: #d63638;
	margin-left: 2px;
}

.wppb-help {
	font-size: 12px;
	color: #666;
	margin: 6px 0 0;
	line-height: 1.4;
}

.wppb-field-error {
	color: #d63638;
	font-size: 13px;
	margin-top: 6px;
	min-height: 0;
	line-height: 1.3;
}

.wppb-field-error:empty {
	display: none;
}

.wppb-field.has-error {
	border-color: #d63638;
}

/* Inputs comunes */
.wppb-input,
.wppb-textarea,
.wppb-select {
	width: 100%;
	max-width: 100%;
	padding: 10px 12px;
	font-size: 16px; /* Importante en iOS para evitar zoom al enfocar. */
	line-height: 1.4;
	color: #1d2327;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	font-family: inherit;
}

.wppb-input:focus,
.wppb-textarea:focus,
.wppb-select:focus {
	border-color: #2271b1;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
	outline: none;
}

.wppb-textarea {
	min-height: 100px;
	resize: vertical;
	font-family: inherit;
}

.wppb-select {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23555' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 36px;
}

.wppb-select[multiple] {
	background-image: none;
	padding-right: 12px;
	min-height: 120px;
}

/* Radio y checkbox */
.wppb-options-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.wppb-label-inline {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-weight: normal;
	cursor: pointer;
	padding: 8px;
	border-radius: 4px;
	transition: background 0.15s ease;
	font-size: 14px;
}

.wppb-label-inline:hover {
	background: #f6f7f7;
}

.wppb-label-inline input[type="checkbox"],
.wppb-label-inline input[type="radio"] {
	margin: 2px 0 0;
	width: 18px;
	height: 18px;
	cursor: pointer;
	flex-shrink: 0;
	accent-color: #2271b1;
}

.wppb-label-inline span {
	flex: 1;
	line-height: 1.4;
}

.wppb-acceptance {
	background: #f9f9f9;
	padding: 10px;
}

/* Date picker (iOS friendly) */
.wppb-date {
	-webkit-appearance: none;
	min-height: 44px; /* touch target accesible */
}

/* ==========================================================================
   Botón submit
   ========================================================================== */

.wppb-field-submit {
	border: none;
	padding: 0;
	background: transparent;
	margin-top: 16px;
}

.wppb-submit-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	min-height: 50px;
	padding: 12px 24px;
	background: #2271b1;
	color: #fff;
	border: 0;
	border-radius: 6px;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.05s ease;
	-webkit-tap-highlight-color: transparent;
	-webkit-appearance: none;
	appearance: none;
	font-family: inherit;
}

.wppb-submit-btn:hover {
	background: #135e96;
}

.wppb-submit-btn:active {
	transform: translateY(1px);
}

.wppb-submit-btn:disabled {
	background: #999;
	cursor: not-allowed;
}

.wppb-submit-btn.is-loading .wppb-btn-label {
	visibility: hidden;
}

.wppb-btn-loader {
	display: none;
	width: 20px;
	height: 20px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: wppb-spin 0.8s linear infinite;
	position: absolute;
}

.wppb-submit-btn.is-loading .wppb-btn-loader {
	display: inline-block;
}

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

/* ==========================================================================
   Subida de imágenes
   ========================================================================== */

.wppb-image-uploader {
	width: 100%;
	padding: 10px;
	background: #fafafa;
	border-radius: 6px;
	border: 1px solid #e5e5e5;
}

.wppb-file-input {
	position: absolute;
	left: -9999px;
	opacity: 0;
}

.wppb-image-drop-zone {
	width: 100%;
}

.wppb-image-label {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 24px 16px;
	width: 100%;
	min-height: 160px;
	background: #fff;
	border: 2px dashed #c3c4c7;
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.15s ease;
	color: #555;
	text-align: center;
	-webkit-tap-highlight-color: transparent;
}

.wppb-image-label:hover,
.wppb-image-label:focus,
.wppb-image-uploader.is-dragover .wppb-image-label {
	border-color: #2271b1;
	background: #f0f6fc;
	color: #2271b1;
}

.wppb-image-icon {
	width: 40px;
	height: 40px;
	color: #999;
}

.wppb-image-label:hover .wppb-image-icon {
	color: #2271b1;
}

.wppb-image-cta {
	font-weight: 600;
	font-size: 15px;
}

.wppb-image-hint {
	font-size: 12px;
	color: #888;
}

/* Cropper */
.wppb-image-cropper {
	margin-top: 10px;
	padding: 10px;
	background: #fff;
	border-radius: 6px;
	border: 1px solid #c3c4c7;
}

.wppb-cropper-wrapper {
	width: 100%;
	max-height: 60vh;
	background: #f0f0f0;
	border-radius: 4px;
	overflow: hidden;
	position: relative;
}

.wppb-cropper-img {
	display: block;
	max-width: 100%;
	width: auto;
	height: auto;
}

.wppb-cropper-actions {
	display: flex;
	gap: 10px;
	margin-top: 10px;
	flex-wrap: wrap;
}

.wppb-cropper-actions button {
	flex: 1;
	min-width: 120px;
	min-height: 44px;
	padding: 10px 16px;
	border-radius: 6px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	border: 0;
	transition: background 0.15s ease;
	-webkit-tap-highlight-color: transparent;
	-webkit-appearance: none;
	appearance: none;
	font-family: inherit;
}

.wppb-cropper-cancel {
	background: #f6f7f7;
	color: #1d2327;
	border: 1px solid #c3c4c7 !important;
}

.wppb-cropper-cancel:hover {
	background: #e5e7e9;
}

.wppb-cropper-upload {
	background: #00a32a;
	color: #fff;
}

.wppb-cropper-upload:hover {
	background: #008a23;
}

.wppb-cropper-upload:disabled {
	background: #999;
	cursor: not-allowed;
}

.wppb-cropper-progress {
	margin-top: 10px;
	padding: 10px;
	background: #f0f6fc;
	border-radius: 4px;
	text-align: center;
}

.wppb-cropper-progress-bar {
	height: 6px;
	background: #c3c4c7;
	border-radius: 3px;
	overflow: hidden;
	position: relative;
	margin-bottom: 6px;
}

.wppb-cropper-progress-bar::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 30%;
	height: 100%;
	background: #2271b1;
	animation: wppb-progress 1.2s ease-in-out infinite;
	border-radius: 3px;
}

@keyframes wppb-progress {
	0% { left: -30%; }
	100% { left: 100%; }
}

.wppb-cropper-progress-text {
	font-size: 13px;
	color: #555;
}

/* Resultado */
.wppb-image-result {
	margin-top: 10px;
	padding: 10px;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	text-align: center;
}

.wppb-image-success {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	color: #1e6b30;
	font-weight: 600;
	margin-bottom: 10px;
	background: #ecf7ed;
	padding: 8px 10px;
	border-radius: 4px;
}

.wppb-image-success svg {
	flex-shrink: 0;
}

.wppb-image-thumb {
	max-width: 100%;
	max-height: 250px;
	width: auto;
	height: auto;
	border-radius: 6px;
	display: block;
	margin: 0 auto 10px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wppb-image-remove {
	background: transparent;
	color: #d63638;
	border: 1px solid #d63638;
	padding: 8px 16px;
	border-radius: 4px;
	cursor: pointer;
	font-size: 14px;
	font-family: inherit;
	min-height: 40px;
	-webkit-tap-highlight-color: transparent;
}

.wppb-image-remove:hover {
	background: #d63638;
	color: #fff;
}

/* ==========================================================================
   Mobile (iOS / Android)
   ========================================================================== */

@media (max-width: 600px) {
	.wppb-form-wrapper {
		padding: 10px;
	}

	.wppb-field {
		padding: 10px;
	}

	.wppb-input,
	.wppb-textarea,
	.wppb-select {
		font-size: 16px; /* Mantener 16px para evitar zoom iOS. */
	}

	.wppb-submit-btn {
		font-size: 16px;
		min-height: 52px;
	}

	.wppb-image-label {
		min-height: 140px;
		padding: 20px 12px;
	}

	.wppb-cropper-actions {
		flex-direction: column;
	}

	.wppb-cropper-actions button {
		width: 100%;
	}
}

/* Smartphones pequeños */
@media (max-width: 360px) {
	.wppb-form-wrapper {
		padding: 8px;
	}

	.wppb-image-label {
		min-height: 120px;
	}

	.wppb-image-cta {
		font-size: 14px;
	}
}

/* Errores genéricos */
.wppb-error {
	padding: 12px;
	background: #fcf0f1;
	color: #a91e22;
	border-left: 4px solid #d63638;
	border-radius: 4px;
	margin: 10px 0;
}
