/**
 * Nill WP Core — Frontend Styling
 * App-Style Mobile Bottom Navigation & Floating Chat Suite
 */

/* ==========================================================================
   1. MODULE A: Mobile Bottom Navigation
   ========================================================================== */

/* Hidden on desktop / above breakpoint by default */
.nill-bottom-nav,
.nill-bottom-nav-spacer {
	display: none !important;
	pointer-events: none !important;
}

@media screen and (max-width: 768px) {
	/* The actual breakpoint is dynamically controlled via CSS custom property, but 768px is default fallback */

	.nill-bottom-nav {
		display: block !important;
		pointer-events: auto !important;
		position: fixed !important;
		bottom: 0 !important;
		left: 0 !important;
		right: 0 !important;
		width: 100% !important;
		background-color: var(--nill-nav-bg, #ffffff) !important;
		border-top: 1px solid var(--nill-nav-border-color, #e2e8f0) !important;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06) !important;
		z-index: 99999 !important;
		box-sizing: border-box !important;
		transform: translateZ(0);
		-webkit-transform: translateZ(0);
	}

	/* iPhone Home Indicator Safe Area Inset */
	.nill-bottom-nav.nill-has-safe-area {
		padding-bottom: env(safe-area-inset-bottom, 0px) !important;
	}

	.nill-bottom-nav-inner {
		display: flex !important;
		align-items: center !important;
		justify-content: space-around !important;
		height: var(--nill-nav-bar-height, 60px) !important;
		max-width: 100% !important;
		margin: 0 auto !important;
		padding: 0 var(--nill-nav-spacing, 4px) !important;
		box-sizing: border-box !important;
	}

	.nill-nav-item {
		flex: 1 1 0 !important;
		min-width: 0 !important;
		height: 100% !important;
		display: flex !important;
		flex-direction: column !important;
		align-items: center !important;
		justify-content: center !important;
		text-decoration: none !important;
		color: var(--nill-nav-inactive-color, #64748b) !important;
		padding: 4px 2px !important;
		position: relative !important;
		transition: color 0.15s ease, transform 0.15s ease !important;
		user-select: none !important;
		-webkit-tap-highlight-color: transparent !important;
		box-sizing: border-box !important;
		min-height: 44px !important; /* Touch target standard */
	}

	.nill-nav-item:hover,
	.nill-nav-item:focus {
		color: var(--nill-nav-active-color, #0284c7) !important;
		outline: none !important;
	}

	.nill-nav-item:focus-visible {
		outline: 2px solid var(--nill-nav-active-color, #0284c7) !important;
		outline-offset: -2px !important;
	}

	/* Active State */
	.nill-nav-item.is-active {
		color: var(--nill-nav-active-color, #0284c7) !important;
	}

	/* Icon and Badges */
	.nill-nav-icon-wrap {
		position: relative !important;
		display: inline-flex !important;
		align-items: center !important;
		justify-content: center !important;
		width: 36px !important;
		height: 28px !important;
		transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
	}

	.nill-nav-icon {
		width: var(--nill-nav-icon-size, 22px) !important;
		height: var(--nill-nav-icon-size, 22px) !important;
		stroke-width: 2 !important;
		transition: stroke 0.15s ease !important;
	}

	.nill-nav-item.is-active .nill-nav-icon {
		stroke: var(--nill-nav-active-color, #0284c7) !important;
	}

	.nill-nav-item.is-active .nill-nav-icon-wrap {
		transform: translateY(-1px);
	}

	/* Text Label */
	.nill-nav-label {
		display: block !important;
		font-size: var(--nill-nav-label-size, 11px) !important;
		line-height: 1.2 !important;
		font-weight: 500 !important;
		text-align: center !important;
		white-space: nowrap !important;
		overflow: hidden !important;
		text-overflow: ellipsis !important;
		max-width: 100% !important;
		margin-top: 2px !important;
	}

	.nill-nav-item.is-active .nill-nav-label {
		font-weight: 600 !important;
	}

	/* Active Indicators */
	/* 1. Pill Indicator */
	.nill-indicator-pill .nill-nav-item.is-active .nill-nav-icon-wrap {
		background-color: rgba(2, 132, 199, 0.1) !important;
		border-radius: 16px !important;
	}

	/* 2. Top Bar Indicator */
	.nill-indicator-bar .nill-nav-item.is-active::before {
		content: "" !important;
		position: absolute !important;
		top: 0 !important;
		left: 20% !important;
		right: 20% !important;
		height: 3px !important;
		background-color: var(--nill-nav-active-color, #0284c7) !important;
		border-radius: 0 0 3px 3px !important;
	}

	/* 3. Subtle Dot Indicator */
	.nill-indicator-dot .nill-nav-item.is-active::after {
		content: "" !important;
		position: absolute !important;
		bottom: 3px !important;
		width: 4px !important;
		height: 4px !important;
		background-color: var(--nill-nav-active-color, #0284c7) !important;
		border-radius: 50% !important;
	}

	/* WooCommerce Live Cart Badge */
	.nill-cart-badge {
		position: absolute !important;
		top: -4px !important;
		right: -6px !important;
		background-color: #ef4444 !important;
		color: #ffffff !important;
		font-size: 10px !important;
		font-weight: 700 !important;
		line-height: 1 !important;
		padding: 3px 5px !important;
		min-width: 16px !important;
		height: 16px !important;
		border-radius: 10px !important;
		display: inline-flex !important;
		align-items: center !important;
		justify-content: center !important;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
		z-index: 1 !important;
	}

	/* Content Spacing Compensation */
	.nill-bottom-nav-spacer {
		display: block !important;
		width: 100% !important;
		height: calc(var(--nill-nav-bar-height, 60px) + env(safe-area-inset-bottom, 0px)) !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}
}

/* ==========================================================================
   2. MODULE C: Floating WhatsApp and Facebook Messenger
   ========================================================================== */

.nill-chat-floating-container {
	position: fixed !important;
	z-index: 99998 !important;
	display: flex !important;
	flex-direction: column !important;
	gap: 12px !important;
	box-sizing: border-box !important;
}

/* Positioning */
.nill-chat-floating-container.nill-chat-right {
	right: var(--nill-chat-offset-x, 20px) !important;
	bottom: var(--nill-chat-offset-y, 20px) !important;
	align-items: flex-end !important;
}

.nill-chat-floating-container.nill-chat-left {
	left: var(--nill-chat-offset-x, 20px) !important;
	bottom: var(--nill-chat-offset-y, 20px) !important;
	align-items: flex-start !important;
}

/* Mobile Safe Elevation to ensure chat buttons float cleanly ABOVE the mobile bottom navigation bar */
@media screen and (max-width: 768px) {
	.nill-chat-floating-container,
	.nill-chat-floating-container.nill-chat-right,
	.nill-chat-floating-container.nill-chat-left {
		bottom: calc(var(--nill-chat-bottom-adjusted, calc(var(--nill-nav-bar-height, 60px) + env(safe-area-inset-bottom, 0px) + var(--nill-chat-offset-y, 20px))) + 16px) !important;
	}
}

body.nill-has-bottom-nav .nill-chat-floating-container,
body.nill-has-bottom-nav .nill-chat-floating-container.nill-chat-right,
body.nill-has-bottom-nav .nill-chat-floating-container.nill-chat-left {
	bottom: calc(var(--nill-chat-bottom-adjusted, calc(var(--nill-nav-bar-height, 60px) + env(safe-area-inset-bottom, 0px) + var(--nill-chat-offset-y, 20px))) + 16px) !important;
}

/* Visibility Rules */
.nill-chat-floating-container.nill-vis-desktop {
	display: flex !important;
}
@media screen and (max-width: 768px) {
	.nill-chat-floating-container.nill-vis-desktop {
		display: none !important;
	}
}

.nill-chat-floating-container.nill-vis-mobile {
	display: none !important;
}
@media screen and (max-width: 768px) {
	.nill-chat-floating-container.nill-vis-mobile {
		display: flex !important;
	}
}

/* Individual Item & Tooltip */
.nill-chat-item {
	position: relative !important;
	display: flex !important;
	align-items: center !important;
}

.nill-chat-greeting {
	position: absolute !important;
	background: #1e293b !important;
	color: #ffffff !important;
	padding: 6px 12px !important;
	border-radius: 8px !important;
	font-size: 12px !important;
	font-weight: 500 !important;
	white-space: nowrap !important;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
	pointer-events: none !important;
	opacity: 0 !important;
	transition: opacity 0.2s ease, transform 0.2s ease !important;
	z-index: 10 !important;
}

.nill-chat-right .nill-chat-greeting {
	right: calc(100% + 12px) !important;
	transform: translateX(6px);
}

.nill-chat-left .nill-chat-greeting {
	left: calc(100% + 12px) !important;
	transform: translateX(-6px);
}

.nill-chat-item:hover .nill-chat-greeting,
.nill-chat-item:focus-within .nill-chat-greeting {
	opacity: 1 !important;
	transform: translateX(0) !important;
}

/* Chat Action Buttons */
.nill-chat-btn {
	width: var(--nill-chat-btn-size, 54px) !important;
	height: var(--nill-chat-btn-size, 54px) !important;
	border-radius: var(--nill-chat-radius, 50%) !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	color: var(--nill-chat-text-color, #ffffff) !important;
	text-decoration: none !important;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18) !important;
	transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease !important;
	-webkit-tap-highlight-color: transparent !important;
}

.nill-chat-btn:hover {
	transform: scale(1.08) !important;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24) !important;
	color: var(--nill-chat-text-color, #ffffff) !important;
}

.nill-chat-btn:active {
	transform: scale(0.95) !important;
}

.nill-chat-btn:focus-visible {
	outline: 3px solid #0284c7 !important;
	outline-offset: 3px !important;
}

.nill-btn-whatsapp {
	background-color: var(--nill-chat-bg-wa, #25D366) !important;
}

.nill-btn-messenger {
	background-color: var(--nill-chat-bg-ms, #0084FF) !important;
}

.nill-chat-icon {
	width: var(--nill-chat-icon-size, 26px) !important;
	height: var(--nill-chat-icon-size, 26px) !important;
	stroke: currentColor !important;
	fill: none !important;
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
	.nill-nav-item,
	.nill-nav-icon-wrap,
	.nill-chat-btn,
	.nill-chat-greeting {
		transition: none !important;
		transform: none !important;
	}
}
