/**
 * Amazon Blocks - Editor Styles
 *
 * Editor-only styles for the Amazon Gutenberg blocks.
 * These styles are enqueued only in the block editor context.
 *
 * @package AffiliateHub
 * @subpackage Modules\AmazonProducts
 * @since 2.0.0
 */

/* ==========================================================================
   Shared: Block Placeholder
   ========================================================================== */

.afh-amazon-block-placeholder {
	max-width: 600px;
	margin: 0 auto;
}

.afh-amazon-block-placeholder .components-placeholder__instructions {
	margin-bottom: 12px;
}

/* ==========================================================================
   Shared: Block Preview Wrapper
   ========================================================================== */

.afh-block-preview {
	position: relative;
}

.afh-block-preview--product,
.afh-block-preview--comparison,
.afh-block-preview--bestseller,
.afh-block-preview--product-grid {
	max-width: 100%;
	overflow: hidden;
}

/* ==========================================================================
   ASIN Search Component (from window.afhAmazonSearch)
   ========================================================================== */

.afh-amazon-search {
	position: relative;
	width: 100%;
}

.afh-amazon-search__input {
	width: 100%;
}

.afh-amazon-search__results {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 100;
	max-height: 240px;
	overflow-y: auto;
	margin: 4px 0 0;
	padding: 0;
	list-style: none;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.afh-amazon-search__result {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	cursor: pointer;
	border-bottom: 1px solid #f0f0f0;
	transition: background-color 0.15s ease;
}

.afh-amazon-search__result:last-child {
	border-bottom: none;
}

.afh-amazon-search__result:hover,
.afh-amazon-search__result:focus {
	background-color: #f0f7fc;
	outline: none;
}

.afh-amazon-search__result:focus {
	box-shadow: inset 0 0 0 2px #2271b1;
}

.afh-amazon-search__result-image {
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
	object-fit: contain;
	border-radius: 3px;
	background: #fafafa;
}

.afh-amazon-search__result-info {
	flex: 1 1 0%;
	min-width: 0;
}

.afh-amazon-search__result-title {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: #1d2327;
	line-height: 1.3;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.afh-amazon-search__result-asin {
	display: block;
	font-size: 11px;
	color: #757575;
	font-family: monospace;
}

.afh-amazon-search__result-price {
	flex: 0 0 auto;
	font-size: 13px;
	font-weight: 700;
	color: #0f1111;
}

.afh-amazon-search__loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 16px;
	color: #757575;
	font-size: 13px;
}

.afh-amazon-search__no-results {
	padding: 16px;
	text-align: center;
	color: #757575;
	font-size: 13px;
	font-style: italic;
}

.afh-amazon-search__result.is-active,
.afh-amazon-search__manual.is-active {
	background-color: #f0f7fc;
	outline: none;
	box-shadow: inset 0 0 0 2px #2271b1;
}

.afh-amazon-search__error {
	padding: 12px 16px;
	color: #d63638;
	font-size: 13px;
	background: #fcf0f1;
	border-left: 4px solid #d63638;
}

.afh-amazon-search__manual {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 10px 12px;
	border-top: 1px solid #e0e0e0;
	cursor: pointer;
}

/* ==========================================================================
   Inspector: Product Info
   ========================================================================== */

.afh-amazon-block-inspector-info {
	margin-bottom: 12px;
	padding: 10px;
	background: #f8f9fa;
	border-radius: 4px;
}

.afh-amazon-block-inspector-info p {
	margin: 4px 0;
	font-size: 12px;
	color: #50575e;
}

.afh-amazon-block-inspector-info code {
	font-size: 11px;
	word-break: break-all;
}

.afh-amazon-block-change-btn {
	margin-top: 8px;
}

/* ==========================================================================
   Comparison: Product List Editor Items
   ========================================================================== */

.afh-amazon-comparison-editor__item {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 10px;
	margin-bottom: 8px;
	background: #f8f9fa;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
}

.afh-amazon-comparison-editor__item:last-child {
	margin-bottom: 0;
}

.afh-amazon-comparison-editor__item-header {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: #1d2327;
}

.afh-amazon-comparison-editor__item-header strong {
	flex: 0 0 auto;
}

.afh-amazon-comparison-editor__item-header code {
	flex: 1 1 auto;
	font-size: 11px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.afh-amazon-comparison-editor__remove {
	flex: 0 0 auto;
	margin-left: auto;
}

.afh-amazon-comparison-editor__item .components-select-control {
	margin-bottom: 0;
}

/* ==========================================================================
   Bestsellers: Setup Form
   ========================================================================== */

.afh-amazon-bestsellers-setup {
	width: 100%;
	max-width: 400px;
}

.afh-amazon-bestsellers-setup .components-text-control__input {
	width: 100%;
}

.afh-amazon-bestsellers-setup .components-button {
	margin-top: 8px;
}

/* ==========================================================================
   Editor Overrides: Constrain ServerSideRender preview width
   ========================================================================== */

.wp-block[data-type="frumbik-affiliate-hub/amazon-product"] .afh-product-box {
	max-width: 100%;
}

.wp-block[data-type="frumbik-affiliate-hub/amazon-product"] .afh-product-box--vertical {
	max-width: 360px;
}

.wp-block[data-type="frumbik-affiliate-hub/amazon-comparison"] .afh-comparison {
	max-width: 100%;
}

.wp-block[data-type="frumbik-affiliate-hub/amazon-comparison"] .afh-comparison__wrapper {
	overflow-x: auto;
}

.wp-block[data-type="frumbik-affiliate-hub/amazon-bestseller"] .afh-bestsellers {
	max-width: 100%;
}

/* ==========================================================================
   Product Link Block: Placeholder
   ========================================================================== */

.afh-amazon-block-placeholder--link {
	max-width: 500px;
}

.afh-amazon-block-placeholder--link .afh-amazon-search {
	margin-bottom: 12px;
}

/* ==========================================================================
   Product Link Block: Inline Preview
   ========================================================================== */

.afh-block-preview--product-link {
	display: inline-block;
	max-width: 100%;
	padding: 4px 0;
}

/* Prevent link navigation in the editor while allowing visual hover states */
.wp-block[data-type="frumbik-affiliate-hub/amazon-product-link"] a {
	pointer-events: none;
	cursor: default;
}

/* Ensure tooltip preview is visible inside editor context */
.wp-block[data-type="frumbik-affiliate-hub/amazon-product-link"] .afh-product-link-tooltip {
	pointer-events: none;
}

/* Disable hover effects and click events in editor (prevent confusing interactivity) */
.wp-block[data-type="frumbik-affiliate-hub/amazon-product"] .afh-product-box__cta,
.wp-block[data-type="frumbik-affiliate-hub/amazon-comparison"] .afh-comparison__cta,
.wp-block[data-type="frumbik-affiliate-hub/amazon-bestseller"] .afh-product-card__button,
.wp-block[data-type="frumbik-affiliate-hub/amazon-product-grid"] .afh-product-card__button {
	pointer-events: none;
}
