/* Public Styles for Affiliate Boxes WP */

/* Base Styles */
.affiliate-box {
	margin: 1.5em 0;
	position: relative;
	clear: both;
}

/* Admin Actions */
.affiliateboxes-admin-actions {
	background: #f8f9fa;
	border: 1px solid #dcdcde;
	padding: 8px 12px;
	margin-bottom: 15px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
}

.affiliateboxes-admin-actions .affiliateboxes-refresh {
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.affiliateboxes-admin-actions .affiliateboxes-refresh:before {
	content: "↻";
	display: inline-block;
	animation: affiliateboxes-spin 1s infinite linear;
	animation-play-state: paused;
}

.affiliateboxes-admin-actions .affiliateboxes-refresh:hover:before {
	animation-play-state: running;
}

.affiliateboxes-admin-actions .last-updated {
	color: #646970;
	font-size: 0.9em;
}

@keyframes affiliateboxes-spin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}

/* Responsive Images */
.affiliate-box img {
	max-width: 100%;
	height: auto;
	display: block;
}

/* Responsive Iframes */
.affiliate-box .responsive-iframe-container {
	position: relative;
	padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
	height: 0;
	overflow: hidden;
	margin: 1em 0;
}

.affiliate-box .responsive-iframe-container iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Error Messages */
.affiliateboxes-error {
	padding: 1em;
	background-color: #f8d7da;
	border: 1px solid #f5c6cb;
	color: #721c24;
	border-radius: 4px;
	margin: 1em 0;
}

/* Loading State */
.affiliate-box.loading {
	position: relative;
	min-height: 100px;
	background: #f8f9fa;
	border-radius: 4px;
}

.affiliate-box.loading:after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 30px;
	height: 30px;
	margin: -15px 0 0 -15px;
	border: 3px solid rgba(0, 0, 0, 0.1);
	border-top-color: #0073aa;
	border-radius: 50%;
	animation: affiliateboxes-spin 1s linear infinite;
}

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

/* Responsive Adjustments */
@media (max-width: 768px) {
	.affiliate-box {
		margin: 1em 0;
	}

	.affiliate-box .responsive-iframe-container {
		padding-bottom: 75%; /* 4:3 for mobile */
	}
}

/* Print Styles */
@media print {
	.affiliate-box {
		page-break-inside: avoid;
	}
}

/* Accessibility */
.affiliate-box :focus {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

/* Custom Animations */
.affiliate-box {
	opacity: 0;
	transform: translateY(20px);
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.affiliate-box.loaded {
	opacity: 1;
	transform: translateY(0);
}

/* Enhancements for specific box types */
.affiliate-box.banner {
	text-align: center;
}

.affiliate-box.text {
	padding: 1.5em;
	background: #f8f9fa;
	border-radius: 4px;
}

.affiliate-box.product {
	border: 1px solid #e5e5e5;
	padding: 15px;
	border-radius: 4px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.affiliate-box.product img {
	margin-bottom: 15px;
}

/* Clearfix for floated content */
.affiliate-box:after {
	content: "";
	display: table;
	clear: both;
}

/* Block Editor Styles */
.affiliateboxes-block-editor {
	min-height: 100px;
}

.affiliateboxes-block-preview {
	background: #fff;
	border: 2px solid #0073aa;
	border-radius: 4px;
	overflow: hidden;
}

.affiliateboxes-block-preview-content {
	background: #fff;
}

/* Ensure preview content is properly styled */
.affiliateboxes-block-preview-content img {
	max-width: 100%;
	height: auto;
}

.affiliateboxes-block-preview-content iframe {
	max-width: 100%;
}

.affiliateboxes-block-preview-content * {
	max-width: 100%;
}

.affiliateboxes-block-placeholder {
	padding: 20px;
	text-align: center;
	background: #f9f9f9;
	border: 1px dashed #ccc;
	border-radius: 4px;
	color: #666;
}

/* Make the Choices.js select fill the block placeholder fieldset */
.components-placeholder .components-base-control {
	width: 100%;
}

/*
 * Size normalisation for the product picker in the block placeholder.
 *
 * Choices.js ships a 16px control with a 44px minimum height and a 24px bottom margin,
 * which reads oversized next to the editor's own controls. Scoped to the block wrapper so
 * the identical picker in the inspector sidebar keeps the styling it already has.
 */
.affiliateboxes-block-editor .choices {
	margin-bottom: 0;
	font-size: 13px;
	text-align: left;
}

.affiliateboxes-block-editor .choices__inner {
	min-height: 36px;
	padding: 5px 8px 1px;
	font-size: 13px;
	background-color: #fff;
}

.affiliateboxes-block-editor .choices__list--dropdown .choices__item,
.affiliateboxes-block-editor .choices__input {
	font-size: 13px;
}

.affiliateboxes-block-editor .choices[data-type*="select-one"]::after {
	right: 11px;
}
