/**
 * HNG Commerce - Sticky Badge Cart Layout
 * Pequeno ícone fixo no canto que expande ao hover
 *
 * Features:
 * - Botão circular fixo que se expande em hover
 * - Pop-over elegante com mini-carrinho
 * - Pulsação sutil no badge
 * - Responsivo em mobile
 */

.hng-cart-sticky {
	position: fixed;
	/* Use dynamic positioning based on chat status */
	bottom: var(--hng-cart-bottom-with-chat, 92px);
	right: 20px;
	z-index: 99990;
}

/* When chat is disabled or on different side */
body.hng-chat-disabled .hng-cart-sticky,
body.hng-chat-left .hng-cart-sticky {
	bottom: var(--hng-cart-bottom-no-chat, 20px);
}

/* Ajuste para admin bar do WordPress */
body.admin-bar .hng-cart-sticky {
	bottom: calc(var(--hng-cart-bottom-with-chat, 92px) + 32px);
}

body.admin-bar.hng-chat-disabled .hng-cart-sticky,
body.admin-bar.hng-chat-left .hng-cart-sticky {
	bottom: calc(var(--hng-cart-bottom-no-chat, 20px) + 32px);
}

@media screen and (max-width: 782px) {
	body.admin-bar .hng-cart-sticky {
		bottom: calc(var(--hng-cart-bottom-with-chat, 92px) + 46px);
	}

	body.admin-bar.hng-chat-disabled .hng-cart-sticky,
	body.admin-bar.hng-chat-left .hng-cart-sticky {
		bottom: calc(var(--hng-cart-bottom-no-chat, 20px) + 46px);
	}
}

/* Botão sticky principal */
.hng-cart-sticky-button {
	width: var(--hng-cart-button-width, 56px);
	height: var(--hng-cart-button-height, 56px);
	border-radius: var(--hng-cart-button-radius, 50%);
	background: linear-gradient(135deg, var(--hng-cart-primary, #2AFFA3) 0%, var(--hng-cart-primary-dark, #1dd49a) 100%);
	color: var(--hng-cart-contrast, #050505);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	box-shadow: 0 4px 16px rgba(42, 255, 163, 0.3);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	font-size: 0;
	/* Reset browser default effects */
	outline: none !important;
	-webkit-tap-highlight-color: transparent !important;
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;
}

/* Reset focus/hover browser defaults */
.hng-cart-sticky-button:focus,
.hng-cart-sticky-button:focus-visible,
.hng-cart-sticky-button:active {
	outline: none !important;
	box-shadow: 0 4px 16px rgba(42, 255, 163, 0.3) !important;
}

/* Override global theme/Tailwind ::before ripple effect */
.hng-cart-sticky-button::before,
.hng-cart-sticky-button::after {
	content: none !important;
	display: none !important;
	width: 0 !important;
	height: 0 !important;
	background: none !important;
	transition: none !important;
}

/* O efeito hover do botão sticky é controlado pelo cart-display.css
	através das classes .hng-no-hover-text para desabilitar */

.hng-cart-sticky-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 20px;
	line-height: 1;
}

.hng-cart-sticky-label {
	display: none;
	white-space: nowrap;
	font-weight: 600;
	font-size: 14px;
}

/* Mostrar label no hover - apenas quando hover text está habilitado */
.hng-cart-sticky:not(.hng-no-hover-text) .hng-cart-sticky-button:hover {
	width: 140px;
	border-radius: 28px;
	justify-content: flex-start;
	padding-left: 12px;
	gap: 12px;
	font-size: 14px;
	box-shadow: 0 8px 24px rgba(42, 255, 163, 0.4);
}

/* Elevação apenas em desktop */
@media (min-width: 769px) {
	.hng-cart-sticky:not(.hng-no-hover-text) .hng-cart-sticky-button:hover {
		transform: translateY(-2px);
	}
}

.hng-cart-sticky:not(.hng-no-hover-text) .hng-cart-sticky-button:hover .hng-cart-sticky-label {
	display: inline-block;
}

/* Quando hover text está desabilitado, sem efeito padrão - use classes .hng-hover-effect-* */
.hng-cart-sticky.hng-no-hover-text .hng-cart-sticky-button:hover {
	transform: none !important;
	width: auto !important;
	min-width: auto !important;
	padding: 0 !important;
	border-radius: 50% !important;
	box-shadow: 0 4px 12px rgba(42, 255, 163, 0.3) !important;
}

/* Badge com quantidade */
.hng-cart-sticky-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	background: var(--hng-cart-accent, #FF7A00);
	color: #fff;
	border-radius: 50%;
	width: 20px;
	height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	border: 2px solid #fff;
	animation: hng-sticky-pulse 2s infinite;
}

@keyframes hng-sticky-pulse {
	0%, 100% {
		transform: scale(1);
		box-shadow: 0 0 0 0 rgba(255, 122, 0, 0.7);
	}
	50% {
		transform: scale(1.1);
		box-shadow: 0 0 0 6px rgba(255, 122, 0, 0);
	}
}

/* Pop-over expandido */
.hng-cart-sticky-expanded {
	position: absolute;
	bottom: 70px;
	right: 0;
	background: var(--hng-cart-surface, #fff);
	border-radius: var(--hng-cart-radius, 12px);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
	width: 320px;
	max-height: 520px;
	overflow: hidden;
	opacity: 0;
	pointer-events: none;
	transform: translateY(10px);
	/* Use CSS variable for animation duration with !important to override theme conflicts */
	transition-property: opacity, transform !important;
	transition-duration: var(--hng-cart-animation-duration, 400ms) !important;
	transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
	z-index: 99998;
	display: flex;
	flex-direction: column;
}

/* Abrir apenas via clique (classe .active adicionada via JS) */
.hng-cart-sticky.active .hng-cart-sticky-expanded {
	opacity: 1 !important;
	pointer-events: auto !important;
	transform: translateY(0) !important;
}

/* Forçar fechamento quando clicado no botão de fechar */
.hng-cart-sticky.force-close .hng-cart-sticky-expanded {
	opacity: 0 !important;
	pointer-events: none !important;
	transform: translateY(10px) !important;
	transition: all 0.15s ease !important;
}

/* Garantir que o botão de fechar do mini carrinho seja clicável */
.hng-mini-cart-header .hng-cart-close {
	position: relative;
	z-index: 10;
	pointer-events: auto !important;
}

/* Seta apontando para botão */
.hng-cart-sticky-expanded::after {
	content: '';
	position: absolute;
	bottom: -10px;
	right: 28px;
	width: 12px;
	height: 12px;
	background: var(--hng-cart-surface, #fff);
	border-radius: 0 0 3px 0;
	box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1);
	transform: rotate(45deg);
}

/* Header do mini carrinho */
.hng-mini-cart-header {
	padding: 14px;
	border-bottom: 1px solid var(--hng-cart-border, #e5e7eb);
	background: var(--hng-cart-header-bg, #f9fafb);
	font-weight: 600;
	font-size: 14px;
	color: var(--hng-cart-text, #1f2937);
	flex-shrink: 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-radius: var(--hng-cart-radius, 12px) var(--hng-cart-radius, 12px) 0 0;
}

.hng-mini-cart-header .hng-cart-close {
	background: transparent;
	border: none;
	color: var(--hng-cart-text-muted, #6b7280);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: all 0.2s ease;
}

.hng-mini-cart-header .hng-cart-close:hover {
	background: rgba(0, 0, 0, 0.05);
	color: var(--hng-cart-text, #1f2937);
}

/* Conteúdo do mini carrinho com scroll */
.hng-mini-cart-content {
	flex: 1;
	overflow-y: auto;
	padding: 8px;
	min-height: 100px;
	background: var(--hng-cart-surface, #fff);
}

.hng-mini-cart-content::-webkit-scrollbar {
	width: 4px;
}

.hng-mini-cart-content::-webkit-scrollbar-track {
	background: transparent;
}

.hng-mini-cart-content::-webkit-scrollbar-thumb {
	background: #cbd5e0;
	border-radius: 2px;
}

.hng-mini-cart-content::-webkit-scrollbar-thumb:hover {
	background: #a0aec0;
}

/* Estado vazio */
.hng-mini-cart-empty {
	text-align: center;
	padding: 24px 12px;
	color: #9ca3af;
	font-size: 13px;
}

.hng-mini-cart-empty-icon {
	font-size: 32px;
	margin-bottom: 8px;
	opacity: 0.5;
}

/* Items do mini carrinho */
.hng-mini-cart-item {
	display: flex;
	gap: 8px;
	padding: 8px;
	border-bottom: 1px solid #f3f4f6;
	font-size: 12px;
	transition: background 0.2s;
}

.hng-mini-cart-item:hover {
	background: #f9fafb;
}

.hng-mini-cart-item:last-child {
	border-bottom: none;
}

.hng-mini-cart-item-image {
	width: 40px;
	height: 40px;
	border-radius: 4px;
	overflow: hidden;
	flex-shrink: 0;
}

.hng-mini-cart-item-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.hng-mini-cart-item-details {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.hng-mini-cart-item-name {
	font-weight: 600;
	color: var(--hng-cart-text, #1f2937);
	line-height: 1.2;
}

.hng-mini-cart-item-price {
	color: var(--hng-cart-muted, #6b7280);
	font-size: 11px;
}

.hng-mini-cart-item-qty {
	color: var(--hng-cart-muted, #9ca3af);
	font-size: 11px;
}

/* Footer com totais e ações */
.hng-mini-cart-footer {
	padding: 12px 12px 16px 12px;
	border-top: 1px solid var(--hng-cart-border, #e5e7eb);
	background: var(--hng-cart-surface, #fff);
	flex-shrink: 0;
	text-align: var(--hng-cart-button-align, center);
	border-radius: 0 0 var(--hng-cart-radius, 12px) var(--hng-cart-radius, 12px);
	overflow: visible;
}

/* Totals dentro do mini cart */
.hng-mini-cart-footer .hng-cart-totals {
	background: transparent;
	padding: 0;
	border: none;
}

/* Mini Cart Totals Section */
.hng-mini-cart-totals {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-bottom: 12px;
}

.hng-mini-cart-subtotal,
.hng-mini-cart-shipping {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 12px;
	color: var(--hng-cart-text, #6b7280);
}

.hng-mini-cart-subtotal strong,
.hng-mini-cart-shipping strong {
	color: var(--hng-cart-text, #1f2937);
}

.hng-mini-cart-total {
	display: flex;
	justify-content: space-between;
	font-weight: 600;
	color: var(--hng-cart-text, #1f2937);
	font-size: 14px;
	padding-top: 8px;
	border-top: 1px solid var(--hng-cart-border, #e5e7eb);
	margin-top: 4px;
}

/* CEP Row Compacto */
.hng-mini-cart-cep-row {
	display: flex;
	gap: 6px;
	margin-top: 4px;
}

.hng-mini-cart-cep-row .hng-cart-cep-input {
	flex: 1;
	padding: 6px 10px;
	border: 1px solid var(--hng-cart-border, #d1d5db);
	border-radius: 6px;
	font-size: 12px;
	min-width: 0;
}

.hng-mini-cart-cep-row .hng-calc-shipping-btn {
	padding: 6px 12px;
	background: var(--hng-cart-primary, #2AFFA3);
	color: var(--hng-cart-contrast, #050505);
	border: none;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: opacity 0.2s;
}

.hng-mini-cart-cep-row .hng-calc-shipping-btn:hover {
	opacity: 0.9;
}

/* Shipping Options Compacto no Mini Cart */
.hng-mini-cart-footer .hng-shipping-options {
	max-height: 100px;
	overflow-y: auto;
	margin-top: 6px;
}

.hng-mini-cart-footer .hng-shipping-option {
	padding: 6px 8px;
	font-size: 11px;
}

.hng-mini-cart-footer .hng-shipping-error,
.hng-mini-cart-footer .hng-shipping-message {
	font-size: 11px;
	padding: 4px 8px;
	margin-top: 4px;
}

.hng-shipping-pending {
	color: var(--hng-cart-muted, #6b7280);
	font-style: italic;
}

.hng-mini-cart-actions {
	display: flex;
	gap: 8px;
}

.hng-mini-cart-actions .btn {
	flex: 1;
	padding: 8px 12px;
	font-size: 12px;
	font-weight: 600;
}

.hng-mini-cart-actions .hng-btn-block,
.hng-mini-cart-actions .btn-block {
	margin-left: auto;
	margin-right: auto;
}

.hng-mini-cart-actions .hng-btn-primary,
.hng-mini-cart-actions .btn-primary {
	background: linear-gradient(135deg, var(--hng-cart-primary, #2AFFA3) 0%, var(--hng-cart-primary-dark, #1dd49a) 100%);
	color: var(--hng-cart-contrast, #050505);
}

.hng-mini-cart-actions .hng-btn-secondary,
.hng-mini-cart-actions .btn-secondary {
	background: var(--hng-cart-border, #e5e7eb);
	color: var(--hng-cart-text, #1f2937);
}

/* Efeto hover nos botões */
.hng-mini-cart-actions .hng-btn:hover,
.hng-mini-cart-actions .btn:hover {
	transform: translateY(-1px);
}

/* Animação de entrada */
@keyframes slideInRight {
	from {
		opacity: 0;
		transform: translateX(10px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

.hng-cart-sticky {
	animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile responsiveness */
/* Otimizações de performance para mobile */
@media (prefers-reduced-motion: reduce) {
	.hng-cart-sticky-badge,
	.hng-cart-trigger,
	.hng-cart-sticky-button,
	.hng-chat-bubble {
		animation: none !important;
		transition: none !important;
	}
}

@media (max-width: 480px) {
	/* Desativar animações pesadas no mobile por padrão */
	.hng-cart-sticky-badge {
		animation: none;
	}

	.hng-cart-sticky {
		right: 16px;
	}

	.hng-cart-sticky-button {
		width: 48px;
		height: 48px;
		font-size: 0;
	}

	/* Hover apenas quando hover text está habilitado */
	.hng-cart-sticky:not(.hng-no-hover-text) .hng-cart-sticky-button:hover {
		width: 120px;
		padding-left: 10px;
		gap: 10px;
		font-size: 13px;
	}

	/* Sem efeito hover quando desabilitado - reset completo */
	.hng-cart-sticky.hng-no-hover-text .hng-cart-sticky-button:hover {
		transform: none !important;
		width: 48px !important;
		padding: 0 !important;
		border-radius: 50% !important;
	}

	.hng-cart-sticky-icon {
		font-size: 18px;
	}

	.hng-cart-sticky-expanded {
		width: 280px;
		right: -20px;
		max-height: 450px;
	}

	.hng-cart-sticky-expanded::after {
		right: 24px;
	}

	.hng-mini-cart-item {
		padding: 6px;
		font-size: 11px;
	}

	.hng-mini-cart-item-image {
		width: 36px;
		height: 36px;
	}

	.hng-mini-cart-footer {
		padding: 10px 10px 14px 10px;
	}

	.hng-mini-cart-actions .btn {
		padding: 6px 10px;
		font-size: 11px;
	}
}

/* Very small screens */
@media (max-width: 360px) {
	.hng-cart-sticky-expanded {
		width: 260px;
		right: -10px;
	}

	.hng-mini-cart-item {
		gap: 6px;
	}

	.hng-mini-cart-item-image {
		width: 32px;
		height: 32px;
	}
}

/* ========================================
	Sticky Synced (inside unified container)
	======================================== */

/* When sticky is inside unified sync container, remove fixed positioning */
.hng-cart-sticky.hng-cart-sticky-synced {
	position: relative !important;
	bottom: auto !important;
	right: auto !important;
	left: auto !important;
	top: auto !important;
}

/* Ensure expanded popover is positioned correctly within slot */
.hng-cart-sticky.hng-cart-sticky-synced .hng-cart-sticky-expanded {
	position: absolute;
	bottom: 70px;
	right: 0;
}

/* For left-aligned unified container, flip expanded position */
.hng-unified-left .hng-cart-sticky.hng-cart-sticky-synced .hng-cart-sticky-expanded {
	right: auto;
	left: 0;
}

/* Arrow adjustment for left side */
.hng-unified-left .hng-cart-sticky.hng-cart-sticky-synced .hng-cart-sticky-expanded::after {
	right: auto;
	left: 28px;
}
