/**
 * BHM Gatekeeper Consent Banner Frontend CSS
 * v2.1.0 — CIPA Compliance Edition
 *
 * All selectors are scoped under #bhm-gatekeeper-root (ID) and use !important
 * on critical visual properties to absolutely override conflicting theme styles.
 * This is necessary because WordPress themes regularly apply global resets,
 * button styles, and box-model overrides that can hide buttons, break toggles,
 * or misalign the consent banner layout.
 */

/* ==========================================================================
   Root Container & Reset
   ========================================================================== */

#bhm-gatekeeper-root {
	/* Colors will be overwritten by localized JS settings */
	--bhm-bg: var(--bhm-bg-color, #ffffff);
	--bhm-text: var(--bhm-text-color, #1f2937);
	--bhm-accept-bg: var(--bhm-accept-bg-color, #4f46e5);
	--bhm-accept-text: var(--bhm-accept-text-color, #ffffff);
	--bhm-decline-bg: var(--bhm-decline-bg-color, #e5e7eb);
	--bhm-decline-text: var(--bhm-decline-text-color, #1f2937);
	--bhm-overlay-bg: var(--bhm-overlay-bg-color, rgba(0, 0, 0, 0.4));

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
	box-sizing: border-box !important;
	line-height: 1.5 !important;
	-webkit-text-size-adjust: 100% !important;
	-webkit-font-smoothing: antialiased !important;
}

#bhm-gatekeeper-root *,
#bhm-gatekeeper-root *::before,
#bhm-gatekeeper-root *::after {
	box-sizing: inherit !important;
	margin: 0;
	padding: 0;
}

/* ==========================================================================
   Modal Overlay
   ========================================================================== */

#bhm-gatekeeper-root .bhm-consent-overlay {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	width: 100vw !important;
	height: 100vh !important;
	z-index: 999990 !important;
	background-color: var(--bhm-overlay-bg) !important;
	backdrop-filter: blur(4px) !important;
	transition: opacity 0.3s ease !important;
	opacity: 0 !important;
	pointer-events: auto !important;
}

#bhm-gatekeeper-root .bhm-consent-overlay.show {
	opacity: 1 !important;
}

/* ==========================================================================
   Core Banner Wrapper
   ========================================================================== */

#bhm-gatekeeper-root .bhm-consent-banner {
	position: fixed !important;
	z-index: 999999 !important;
	background-color: var(--bhm-bg) !important;
	color: var(--bhm-text) !important;
	border: 1px solid rgba(255, 255, 255, 0.2) !important;
	box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1), 0 0 1px 1px rgba(0, 0, 0, 0.05) !important;
	transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
	opacity: 0 !important;
	box-sizing: border-box !important;
	padding: 24px !important;
	display: flex !important;
	flex-direction: column !important;
	gap: 16px !important;
	max-height: 90vh !important;
	overflow-y: auto !important;
	visibility: visible !important;
	float: none !important;
	text-align: left !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	text-indent: 0 !important;
	text-decoration: none !important;
	width: auto !important;
	height: auto !important;
	min-height: 0 !important;
}

#bhm-gatekeeper-root .bhm-consent-banner.show {
	opacity: 1 !important;
}

/* ==========================================================================
   Positioning Layouts
   ========================================================================== */

/* Toasts */
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-right {
	bottom: 24px !important;
	right: 24px !important;
	top: auto !important;
	left: auto !important;
	width: 460px !important;
	border-radius: 16px !important;
	transform: translateY(20px) !important;
}
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-left {
	bottom: 24px !important;
	left: 24px !important;
	top: auto !important;
	right: auto !important;
	width: 460px !important;
	border-radius: 16px !important;
	transform: translateY(20px) !important;
}
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-right {
	top: 24px !important;
	right: 24px !important;
	bottom: auto !important;
	left: auto !important;
	width: 460px !important;
	border-radius: 16px !important;
	transform: translateY(-20px) !important;
}
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-left {
	top: 24px !important;
	left: 24px !important;
	bottom: auto !important;
	right: auto !important;
	width: 460px !important;
	border-radius: 16px !important;
	transform: translateY(-20px) !important;
}

#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-right.show,
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-left.show,
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-right.show,
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-left.show {
	transform: translateY(0) !important;
}

/* Full Width Bars */
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-fixed {
	bottom: 0 !important;
	left: 0 !important;
	top: auto !important;
	right: auto !important;
	width: 100vw !important;
	border-radius: 0 !important;
	border-left: none !important;
	border-right: none !important;
	border-bottom: none !important;
	transform: translateY(100%) !important;
	flex-direction: row !important;
	align-items: center !important;
	justify-content: space-between !important;
	padding: 20px 40px !important;
}
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-fixed {
	top: 0 !important;
	left: 0 !important;
	bottom: auto !important;
	right: auto !important;
	width: 100vw !important;
	border-radius: 0 !important;
	border-left: none !important;
	border-right: none !important;
	border-top: none !important;
	transform: translateY(-100%) !important;
	flex-direction: row !important;
	align-items: center !important;
	justify-content: space-between !important;
	padding: 20px 40px !important;
}

#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-fixed.show,
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-fixed.show {
	transform: translateY(0) !important;
}

/* Centered Modal */
#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-modal {
	top: 50% !important;
	left: 50% !important;
	bottom: auto !important;
	right: auto !important;
	transform: translate(-50%, -40%) scale(0.95) !important;
	width: 540px !important;
	max-width: 90vw !important;
	border-radius: 16px !important;
	z-index: 999995 !important;
}

#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-modal.show {
	transform: translate(-50%, -50%) scale(1) !important;
}

/* ==========================================================================
   Content Styles
   ========================================================================== */

#bhm-gatekeeper-root .bhm-banner-content {
	flex: 1 !important;
	display: block !important;
	visibility: visible !important;
}

#bhm-gatekeeper-root .bhm-banner-title {
	margin: 0 0 8px 0 !important;
	padding: 0 !important;
	font-size: 18px !important;
	font-weight: 700 !important;
	line-height: 1.3 !important;
	color: inherit !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	text-align: left !important;
	border: none !important;
	background: none !important;
	display: block !important;
	visibility: visible !important;
}

#bhm-gatekeeper-root .bhm-pos-bottom-fixed .bhm-banner-title,
#bhm-gatekeeper-root .bhm-pos-top-fixed .bhm-banner-title {
	font-size: 16px !important;
}

#bhm-gatekeeper-root .bhm-banner-message {
	font-size: 14px !important;
	line-height: 1.5 !important;
	opacity: 0.9 !important;
	color: inherit !important;
	display: block !important;
	visibility: visible !important;
}

#bhm-gatekeeper-root .bhm-pos-bottom-fixed .bhm-banner-message,
#bhm-gatekeeper-root .bhm-pos-top-fixed .bhm-banner-message {
	font-size: 13px !important;
	margin-bottom: 0 !important;
}

#bhm-gatekeeper-root .bhm-banner-message p {
	margin: 0 !important;
	padding: 0 !important;
}

#bhm-gatekeeper-root .bhm-banner-message a {
	color: inherit !important;
	text-decoration: underline !important;
	font-weight: 600 !important;
	transition: opacity 0.2s ease !important;
	background: none !important;
	border: none !important;
	padding: 0 !important;
}

#bhm-gatekeeper-root .bhm-banner-message a:hover {
	opacity: 0.8 !important;
}

/* ==========================================================================
   Preferences Panel — Category-Based Consent (CIPA Compliance)
   ========================================================================== */

#bhm-gatekeeper-root .bhm-preferences-panel {
	margin-top: 16px !important;
	padding-top: 16px !important;
	border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
}

#bhm-gatekeeper-root .bhm-categories {
	display: flex !important;
	flex-direction: column !important;
	gap: 12px !important;
}

#bhm-gatekeeper-root .bhm-category-item {
	padding: 12px 14px !important;
	border: 1px solid rgba(0, 0, 0, 0.08) !important;
	border-radius: 10px !important;
	background: rgba(0, 0, 0, 0.02) !important;
	transition: background 0.2s ease !important;
	display: block !important;
	visibility: visible !important;
}

#bhm-gatekeeper-root .bhm-category-item:hover {
	background: rgba(0, 0, 0, 0.04) !important;
}

#bhm-gatekeeper-root .bhm-category-header {
	display: flex !important;
	align-items: center !important;
	justify-content: space-between !important;
	gap: 12px !important;
}

#bhm-gatekeeper-root .bhm-category-label {
	display: flex !important;
	align-items: center !important;
	gap: 8px !important;
	font-weight: 600 !important;
	font-size: 14px !important;
	cursor: pointer !important;
	color: inherit !important;
}

#bhm-gatekeeper-root .bhm-category-name {
	font-weight: 600 !important;
}

#bhm-gatekeeper-root .bhm-category-badge {
	display: inline-block !important;
	font-size: 11px !important;
	font-weight: 500 !important;
	padding: 2px 8px !important;
	border-radius: 20px !important;
	background: rgba(0, 0, 0, 0.06) !important;
	opacity: 0.7 !important;
	color: inherit !important;
}

#bhm-gatekeeper-root .bhm-category-desc {
	margin: 6px 0 0 !important;
	padding: 0 !important;
	font-size: 12px !important;
	line-height: 1.4 !important;
	opacity: 0.7 !important;
	color: inherit !important;
}

/* ==========================================================================
   Toggle Switch — Hardened Against Theme Overrides
   ========================================================================== */

#bhm-gatekeeper-root .bhm-toggle {
	position: relative !important;
	display: inline-block !important;
	width: 44px !important;
	height: 24px !important;
	flex-shrink: 0 !important;
	vertical-align: middle !important;
	border: none !important;
	background: none !important;
	padding: 0 !important;
	margin: 0 !important;
	overflow: visible !important;
}

#bhm-gatekeeper-root .bhm-toggle input[type="checkbox"] {
	opacity: 0 !important;
	width: 0 !important;
	height: 0 !important;
	position: absolute !important;
	margin: 0 !important;
	padding: 0 !important;
	border: none !important;
	appearance: none !important;
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
}

#bhm-gatekeeper-root .bhm-toggle-slider {
	position: absolute !important;
	cursor: pointer !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 44px !important;
	height: 24px !important;
	background-color: rgba(0, 0, 0, 0.15) !important;
	border-radius: 24px !important;
	transition: all 0.25s ease !important;
	border: none !important;
	outline: none !important;
	box-shadow: none !important;
	display: block !important;
	visibility: visible !important;
}

#bhm-gatekeeper-root .bhm-toggle-slider::before {
	content: '' !important;
	position: absolute !important;
	height: 18px !important;
	width: 18px !important;
	left: 3px !important;
	bottom: 3px !important;
	top: auto !important;
	right: auto !important;
	background-color: white !important;
	border-radius: 50% !important;
	transition: all 0.25s ease !important;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15) !important;
	border: none !important;
	transform: none !important;
}

#bhm-gatekeeper-root .bhm-toggle input[type="checkbox"]:checked + .bhm-toggle-slider {
	background-color: var(--bhm-accept-bg) !important;
}

#bhm-gatekeeper-root .bhm-toggle input[type="checkbox"]:checked + .bhm-toggle-slider::before {
	transform: translateX(20px) !important;
}

#bhm-gatekeeper-root .bhm-toggle input[type="checkbox"]:disabled + .bhm-toggle-slider {
	opacity: 0.5 !important;
	cursor: not-allowed !important;
}

/* ==========================================================================
   Buttons — Equal Visual Weight (Anti-Dark-Pattern)
   All properties use !important to defeat theme button resets.
   ========================================================================== */

#bhm-gatekeeper-root .bhm-banner-buttons {
	display: flex !important;
	gap: 10px !important;
	align-items: center !important;
	justify-content: flex-end !important;
	flex-wrap: wrap !important;
}

#bhm-gatekeeper-root .bhm-pos-bottom-fixed .bhm-banner-buttons,
#bhm-gatekeeper-root .bhm-pos-top-fixed .bhm-banner-buttons {
	flex-shrink: 0 !important;
}

#bhm-gatekeeper-root .bhm-btn {
	padding: 10px 20px !important;
	font-size: 14px !important;
	font-weight: 600 !important;
	font-family: inherit !important;
	border: none !important;
	border-radius: 8px !important;
	cursor: pointer !important;
	transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	line-height: 1.2 !important;
	text-decoration: none !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	text-shadow: none !important;
	box-shadow: none !important;
	outline: none !important;
	appearance: none !important;
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	white-space: nowrap !important;
	visibility: visible !important;
	opacity: 1 !important;
	float: none !important;
	position: relative !important;
	width: auto !important;
	height: auto !important;
	min-height: 0 !important;
	min-width: 0 !important;
	max-width: none !important;
	overflow: visible !important;
	vertical-align: middle !important;
	margin: 0 !important;
}

#bhm-gatekeeper-root .bhm-btn:active {
	transform: scale(0.97) !important;
}

#bhm-gatekeeper-root .bhm-btn-accept {
	background-color: var(--bhm-accept-bg) !important;
	color: var(--bhm-accept-text) !important;
}

#bhm-gatekeeper-root .bhm-btn-accept:hover {
	opacity: 0.9 !important;
	box-shadow: 0 4px 10px rgba(0,0,0,0.12) !important;
}

/*
 * Decline/Reject button — visually balanced with Accept.
 * Equal font-weight, visible contrast, no suppressed opacity.
 * This prevents dark pattern claims per CNIL/EDPB/FTC guidance.
 */
#bhm-gatekeeper-root .bhm-btn-decline {
	background-color: var(--bhm-decline-bg) !important;
	color: var(--bhm-decline-text) !important;
}

#bhm-gatekeeper-root .bhm-btn-decline:hover {
	opacity: 0.9 !important;
	box-shadow: 0 4px 10px rgba(0,0,0,0.08) !important;
}

/* Manage Preferences button — tertiary style */
#bhm-gatekeeper-root .bhm-btn-preferences {
	background: transparent !important;
	color: var(--bhm-text) !important;
	border: 1px solid rgba(0, 0, 0, 0.15) !important;
	font-size: 13px !important;
	padding: 8px 16px !important;
}

#bhm-gatekeeper-root .bhm-btn-preferences:hover {
	background: rgba(0, 0, 0, 0.04) !important;
}

/* Focus Management for Accessibility */
#bhm-gatekeeper-root .bhm-btn:focus-visible,
#bhm-gatekeeper-root .bhm-banner-message a:focus-visible,
#bhm-gatekeeper-root .bhm-toggle input:focus-visible + .bhm-toggle-slider {
	outline: 3px solid var(--bhm-accept-bg) !important;
	outline-offset: 2px !important;
}

/* ==========================================================================
   Revoke/Privacy Settings Tab Badge
   NOTE: This is appended to document.body, so it lives outside
   #bhm-gatekeeper-root. We use the specific ID #bhm-revoke-widget.
   ========================================================================== */

button#bhm-revoke-widget.bhm-revoke-tab {
	position: fixed !important;
	z-index: 999980 !important;
	background-color: var(--bhm-revoke-bg-color, var(--bhm-bg, #ffffff)) !important;
	color: var(--bhm-revoke-text-color, var(--bhm-text, #1f2937)) !important;
	box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 1px rgba(0,0,0,0.1) !important;
	border: 1px solid rgba(0, 0, 0, 0.1) !important;
	padding: 10px 16px !important;
	font-size: 13px !important;
	font-weight: 600 !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
	cursor: pointer !important;
	display: flex !important;
	align-items: center !important;
	gap: 8px !important;
	transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
	opacity: 0 !important;
	visibility: visible !important;
	appearance: none !important;
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	text-decoration: none !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	line-height: 1.2 !important;
	text-shadow: none !important;
	outline: none !important;
	float: none !important;
	width: auto !important;
	height: auto !important;
	min-height: 0 !important;
	min-width: 0 !important;
	margin: 0 !important;
}

/* Position mapping for revoke badge */
button#bhm-revoke-widget.bhm-revoke-bottom-right {
	bottom: 20px !important;
	right: 20px !important;
	top: auto !important;
	left: auto !important;
	border-radius: 30px !important;
	transform: translateY(80px) !important;
}

button#bhm-revoke-widget.bhm-revoke-bottom-left {
	left: 20px !important;
	bottom: 20px !important;
	top: auto !important;
	right: auto !important;
	border-radius: 30px !important;
	transform: translateY(80px) !important;
}

button#bhm-revoke-widget.bhm-revoke-top-right {
	top: 20px !important;
	right: 20px !important;
	bottom: auto !important;
	left: auto !important;
	border-radius: 30px !important;
	transform: translateY(-80px) !important;
}

button#bhm-revoke-widget.bhm-revoke-top-left {
	left: 20px !important;
	top: 20px !important;
	bottom: auto !important;
	right: auto !important;
	border-radius: 30px !important;
	transform: translateY(-80px) !important;
}

/* Compatibility classes for legacy banner positions */
button#bhm-revoke-widget.bhm-revoke-left {
	left: 20px !important;
	bottom: 20px !important;
	top: auto !important;
	right: auto !important;
	border-radius: 30px !important;
	transform: translateY(80px) !important;
}

button#bhm-revoke-widget.bhm-revoke-right {
	right: 20px !important;
	bottom: 20px !important;
	top: auto !important;
	left: auto !important;
	border-radius: 30px !important;
	transform: translateY(80px) !important;
}

button#bhm-revoke-widget.bhm-revoke-tab.show {
	transform: translateY(0) !important;
	opacity: 1 !important;
}

button#bhm-revoke-widget.bhm-revoke-tab:hover {
	box-shadow: 0 6px 16px rgba(0,0,0,0.2) !important;
}

button#bhm-revoke-widget.bhm-revoke-bottom-right:hover,
button#bhm-revoke-widget.bhm-revoke-bottom-left:hover,
button#bhm-revoke-widget.bhm-revoke-left:hover,
button#bhm-revoke-widget.bhm-revoke-right:hover {
	transform: translateY(-2px) !important;
}

button#bhm-revoke-widget.bhm-revoke-top-right:hover,
button#bhm-revoke-widget.bhm-revoke-top-left:hover {
	transform: translateY(2px) !important;
}

button#bhm-revoke-widget.bhm-revoke-tab svg {
	width: 16px !important;
	height: 16px !important;
	fill: currentColor !important;
	display: inline-block !important;
	vertical-align: middle !important;
}

/* Focus for revoke widget */
button#bhm-revoke-widget.bhm-revoke-tab:focus-visible {
	outline: 3px solid #4f46e5 !important;
	outline-offset: 2px !important;
}

/* ==========================================================================
   Responsive Overrides
   ========================================================================== */

@media (max-width: 768px) {
	#bhm-gatekeeper-root .bhm-consent-banner {
		padding: 20px !important;
	}

	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-right,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-left,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-right,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-left {
		width: calc(100% - 32px) !important;
		left: 16px !important;
		right: 16px !important;
		bottom: 16px !important;
		border-radius: 12px !important;
		transform: translateY(20px) !important;
	}

	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-right,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-left {
		top: 16px !important;
		bottom: auto !important;
		transform: translateY(-20px) !important;
	}

	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-fixed,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-fixed {
		flex-direction: column !important;
		align-items: stretch !important;
		padding: 20px !important;
		gap: 16px !important;
	}

	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-fixed {
		transform: translateY(100%) !important;
	}

	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-fixed {
		transform: translateY(-100%) !important;
	}

	/* Ensure show class still works on mobile */
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-right.show,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-left.show,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-bottom-fixed.show,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-right.show,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-left.show,
	#bhm-gatekeeper-root .bhm-consent-banner.bhm-pos-top-fixed.show {
		transform: translateY(0) !important;
	}

	#bhm-gatekeeper-root .bhm-banner-buttons {
		width: 100% !important;
	}

	#bhm-gatekeeper-root .bhm-btn {
		flex: 1 !important;
		min-width: 0 !important;
	}

	#bhm-gatekeeper-root .bhm-btn-preferences {
		flex-basis: 100% !important;
		order: 3 !important;
	}

	button#bhm-revoke-widget.bhm-revoke-tab {
		bottom: 12px !important;
		padding: 8px 12px !important;
		font-size: 12px !important;
	}
	button#bhm-revoke-widget.bhm-revoke-left {
		left: 12px !important;
	}
	button#bhm-revoke-widget.bhm-revoke-right {
		right: 12px !important;
	}

	/* Category items tighter on mobile */
	#bhm-gatekeeper-root .bhm-category-item {
		padding: 10px 12px !important;
	}

	#bhm-gatekeeper-root .bhm-category-label {
		font-size: 13px !important;
	}
}
