/**
 * IdeaPlugins Product Side Panel — Frontend styles.
 * All selectors are ideap_ prefixed; all colors/sizes come from
 * ideap_-prefixed CSS custom properties set by IDEAP_Frontend.
 */

.ideap_product_panel_wrapper,
.ideap_product_panel_wrapper * {
	box-sizing: border-box;
}

.ideap_product_panel_wrapper {
	--ideap_z_base: 99990;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--ideap_panel_text, #4b5563);
}

/* ---------- Trigger button ---------- */

.ideap_panel_trigger {
	position: fixed;
	top: 50%;
	transform: translateY(-50%);
	z-index: var(--ideap_z_base);
	width: var(--ideap_trigger_width, 48px);
	min-height: var(--ideap_trigger_height, 140px);
	background: var(--ideap_trigger_background, #111827);
	color: var(--ideap_trigger_text, #fff);
	border: none;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	cursor: pointer;
	padding: 14px 8px;
	font-size: var(--ideap_trigger_font_size, 14px);
	font-weight: var(--ideap_trigger_font_weight, 600);
	transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}

.ideap_pos_right .ideap_panel_trigger {
	right: 0;
	border-radius: var(--ideap_trigger_radius, 12px) 0 0 var(--ideap_trigger_radius, 12px);
}

.ideap_pos_left .ideap_panel_trigger {
	left: 0;
	border-radius: 0 var(--ideap_trigger_radius, 12px) var(--ideap_trigger_radius, 12px) 0;
}

.ideap_vpos_top .ideap_panel_trigger { top: 100px; transform: none; }
.ideap_vpos_middle .ideap_panel_trigger { top: 50%; transform: translateY(-50%); }
.ideap_vpos_bottom .ideap_panel_trigger { top: auto; bottom: 60px; transform: none; }

.ideap_trigger_shadow {
	box-shadow: 0 10px 30px -10px var(--ideap_panel_shadow, rgba(15,23,42,.3));
}

.ideap_trigger_hover:hover {
	background: var(--ideap_trigger_hover_background, #1f2937);
	color: var(--ideap_trigger_hover_text, #fff);
}

.ideap_trigger_hover:hover .ideap_trigger_icon {
	color: var(--ideap_trigger_hover_text, #fff);
}

.ideap_trigger_icon {
	display: flex;
	color: var(--ideap_trigger_icon, currentColor);
}

.ideap_trigger_text {
	writing-mode: vertical-rl;
	text-orientation: mixed;
	letter-spacing: .02em;
	white-space: nowrap;
}

.ideap_panel_trigger:focus-visible {
	outline: 2px solid #2563eb;
	outline-offset: 2px;
}

/* ---------- Overlay ---------- */

.ideap_panel_overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, .45);
	z-index: calc(var(--ideap_z_base) + 1);
	opacity: 0;
	transition: opacity .25s ease;
}

.ideap_panel_overlay.is-visible {
	opacity: 1;
}

/* ---------- Panel ---------- */

.ideap_product_panel {
	position: fixed;
	top: 0;
	bottom: 0;
	width: min(var(--ideap_panel_width, 380px), 92vw);
	max-width: 92vw;
	background: var(--ideap_panel_background, #fff);
	color: var(--ideap_panel_text, #4b5563);
	z-index: calc(var(--ideap_z_base) + 2);
	box-shadow: 0 20px 60px -16px var(--ideap_panel_shadow, rgba(15,23,42,.35));
	border: 1px solid var(--ideap_panel_border, #e5e7eb);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: transform .32s cubic-bezier(.16,1,.3,1);
	visibility: hidden;
}

.ideap_pos_right .ideap_product_panel {
	right: 0;
	border-radius: var(--ideap_border_radius, 16px) 0 0 var(--ideap_border_radius, 16px);
	transform: translateX(100%);
}

.ideap_pos_left .ideap_product_panel {
	left: 0;
	border-radius: 0 var(--ideap_border_radius, 16px) var(--ideap_border_radius, 16px) 0;
	transform: translateX(-100%);
}

.ideap_product_panel.is-open {
	transform: translateX(0);
	visibility: visible;
}

.ideap_panel_header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 22px 22px 16px;
	border-bottom: 1px solid var(--ideap_panel_border, #eef0f2);
}

.ideap_panel_title {
	margin: 0 0 4px;
	font-size: var(--ideap_heading_font_size, 16px);
	font-weight: var(--ideap_heading_font_weight, 600);
	letter-spacing: var(--ideap_heading_letter_spacing, 0);
	color: var(--ideap_panel_heading, #111827);
}

.ideap_panel_subtitle {
	margin: 0;
	font-size: 12.5px;
	color: var(--ideap_panel_text, #6b7280);
	opacity: .85;
}

.ideap_panel_close {
	border: none;
	background: transparent;
	color: var(--ideap_panel_text, #4b5563);
	cursor: pointer;
	padding: 6px;
	border-radius: 8px;
	flex-shrink: 0;
	display: flex;
}

.ideap_panel_close:hover {
	background: rgba(0,0,0,.05);
}

.ideap_panel_content {
	padding: 18px 22px 26px;
	overflow-y: auto;
	flex: 1;
}

/* ---------- Product grid / cards ---------- */

.ideap_product_grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 16px;
}

.ideap_product_card {
	background: var(--ideap_card_background, #fff);
	border: 1px solid var(--ideap_card_border, #eef0f2);
	border-radius: calc(var(--ideap_border_radius, 16px) * 0.6);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: box-shadow .2s ease, transform .2s ease;
}

.ideap_product_card:hover {
	box-shadow: 0 12px 30px -16px rgba(15,23,42,.25);
	transform: translateY(-2px);
}

.ideap_product_link {
	text-decoration: none;
	color: inherit;
	display: flex;
	gap: 12px;
	padding: 12px;
}

.ideap_product_image_wrap {
	position: relative;
	width: 84px;
	height: 84px;
	flex-shrink: 0;
	border-radius: 10px;
	overflow: hidden;
	background: #f3f4f6;
}

.ideap_product_image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ideap_sale_badge,
.ideap_popular_badge {
	position: absolute;
	top: 6px;
	left: 6px;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .03em;
	padding: 3px 7px;
	border-radius: 999px;
	color: #fff;
	background: var(--ideap_card_badge, #dc2626);
}

.ideap_popular_badge {
	background: #111827;
}

.ideap_product_body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.ideap_product_title {
	margin: 0;
	font-size: var(--ideap_body_font_size, 13px);
	font-weight: var(--ideap_body_font_weight, 500);
	line-height: var(--ideap_body_line_height, 1.4);
	color: var(--ideap_card_title, #111827);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ideap_product_rating {
	font-size: 11px;
	color: #f59e0b;
	display: flex;
	align-items: center;
	gap: 4px;
}

.ideap_product_review_count {
	color: var(--ideap_panel_text, #9ca3af);
}

.ideap_product_excerpt {
	margin: 2px 0 0;
	font-size: 11.5px;
	color: var(--ideap_panel_text, #6b7280);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ideap_product_price {
	font-size: 13px;
	font-weight: 700;
	color: var(--ideap_card_price, #111827);
	margin-top: 2px;
}

.ideap_product_price del {
	color: var(--ideap_panel_text, #9ca3af);
	font-weight: 400;
	opacity: .8;
	margin-right: 6px;
}

.ideap_product_price ins {
	text-decoration: none;
	color: var(--ideap_card_sale_price, #dc2626);
}

.ideap_product_actions {
	display: flex;
	gap: 8px;
	padding: 0 12px 12px;
}

.ideap_add_to_cart_btn,
.ideap_view_product_btn {
	flex: 1;
	text-align: center;
	font-size: 12px;
	font-weight: 600;
	border-radius: 8px;
	padding: 8px 10px;
	cursor: pointer;
	text-decoration: none;
	border: 1px solid transparent;
	transition: background .15s ease, color .15s ease;
}

.ideap_add_to_cart_btn {
	background: var(--ideap_button_background, #111827);
	color: var(--ideap_button_text, #fff);
}

.ideap_add_to_cart_btn:hover {
	background: var(--ideap_button_hover_background, #2563eb);
	color: var(--ideap_button_hover_text, #fff);
}

.ideap_add_to_cart_btn.added::after {
	content: "✓";
	margin-left: 6px;
}

.ideap_add_to_cart_btn.loading {
	opacity: .6;
	pointer-events: none;
}

.ideap_view_product_btn {
	background: transparent;
	color: var(--ideap_button_background, #111827);
	border-color: var(--ideap_card_border, #e5e7eb);
}

.ideap_view_product_btn:hover {
	background: rgba(0,0,0,.04);
}

/* ---------- Empty / skeleton / error states ---------- */

.ideap_empty_state {
	text-align: center;
	padding: 50px 16px;
	color: var(--ideap_panel_text, #6b7280);
}

.ideap_empty_state svg { margin-bottom: 12px; opacity: .5; }

.ideap_empty_title {
	font-weight: 600;
	color: var(--ideap_panel_heading, #111827);
	margin: 0 0 4px;
}

.ideap_empty_text { margin: 0; font-size: 12.5px; }

.ideap_panel_skeleton {
	display: grid;
	gap: 16px;
}

.ideap_skeleton_card {
	display: flex;
	gap: 12px;
	padding: 12px;
}

.ideap_skeleton_image,
.ideap_skeleton_line {
	background: linear-gradient(90deg, #eef0f2 25%, #f6f7f8 37%, #eef0f2 63%);
	background-size: 400% 100%;
	animation: ideap_shimmer 1.4s ease infinite;
	border-radius: 8px;
}

.ideap_skeleton_image { width: 84px; height: 84px; flex-shrink: 0; }
.ideap_skeleton_line { height: 10px; margin-bottom: 8px; }
.ideap_skeleton_line_lg { width: 80%; }
.ideap_skeleton_line_sm { width: 50%; }

@keyframes ideap_shimmer {
	0% { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}

.ideap_panel_error {
	text-align: center;
	padding: 30px 16px;
	font-size: 13px;
	color: #dc2626;
}

/* ---------- Confetti effect ---------- */

.ideap_confetti_container {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 5;
}

.ideap_confetti_piece {
	position: absolute;
	top: -12px;
	opacity: 0;
	animation-name: ideap_confetti_fall;
	animation-timing-function: cubic-bezier(.22,.61,.36,1);
	animation-fill-mode: forwards;
}

@keyframes ideap_confetti_fall {
	0% {
		transform: translate(0, -10px) rotate(0deg);
		opacity: 0;
	}
	8% {
		opacity: 1;
	}
	100% {
		transform: translate(var(--ideap-confetti-drift, 0), 420px) rotate(var(--ideap-confetti-rotate, 180deg));
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ideap_confetti_container {
		display: none;
	}
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.ideap_product_panel,
	.ideap_panel_overlay,
	.ideap_product_card,
	.ideap_panel_trigger {
		transition: none !important;
		animation: none !important;
	}
}

/* ---------- Responsive ---------- */

@media (max-width: 782px) {
	.ideap_product_panel {
		width: 100%;
		max-width: 100%;
		border-radius: 0;
	}

	.ideap_pos_left .ideap_product_panel,
	.ideap_pos_right .ideap_product_panel {
		border-radius: 0;
	}

	.ideap_panel_trigger {
		min-height: 56px;
		width: 56px;
		flex-direction: row;
		padding: 0;
	}

	.ideap_trigger_text { display: none; }

	.ideap_vpos_top .ideap_panel_trigger { top: 70px; }
	.ideap_vpos_bottom .ideap_panel_trigger { bottom: 24px; }
}

@media (min-width: 783px) and (max-width: 1024px) {
	.ideap_product_panel {
		width: min(360px, 88vw);
	}
}
