/**
 * BHM Gatekeeper Consent Banner Frontend CSS
 * v2.0.0 — CIPA Compliance Edition
 */

#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;
	box-sizing: border-box;
}

#bhm-gatekeeper-root *,
#bhm-gatekeeper-root *::before,
#bhm-gatekeeper-root *::after {
	box-sizing: inherit;
}

/* Modal Overlay */
.bhm-consent-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: 999990;
	background-color: var(--bhm-overlay-bg);
	backdrop-filter: blur(4px);
	transition: opacity 0.3s ease;
	opacity: 0;
}

.bhm-consent-overlay.show {
	opacity: 1;
}

/* Core Banner Wrapper */
.bhm-consent-banner {
	position: fixed;
	z-index: 999999;
	background-color: var(--bhm-bg);
	color: var(--bhm-text);
	border: 1px solid rgba(255, 255, 255, 0.2);
	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);
	transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
	opacity: 0;
	box-sizing: border-box;
	
	/* Default layout */
	padding: 24px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	max-height: 90vh;
	overflow-y: auto;
}

/* Animations Trigger */
.bhm-consent-banner.show {
	opacity: 1;
}

/* Positioning Layouts */
/* Toasts */
.bhm-consent-banner.bhm-pos-bottom-right {
	bottom: 24px;
	right: 24px;
	width: 460px;
	border-radius: 16px;
	transform: translateY(20px);
}
.bhm-consent-banner.bhm-pos-bottom-left {
	bottom: 24px;
	left: 24px;
	width: 460px;
	border-radius: 16px;
	transform: translateY(20px);
}
.bhm-consent-banner.bhm-pos-top-right {
	top: 24px;
	right: 24px;
	width: 460px;
	border-radius: 16px;
	transform: translateY(-20px);
}
.bhm-consent-banner.bhm-pos-top-left {
	top: 24px;
	left: 24px;
	width: 460px;
	border-radius: 16px;
	transform: translateY(-20px);
}

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

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

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

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

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

/* Content Styles */
.bhm-banner-content {
	flex: 1;
}

.bhm-banner-title {
	margin: 0 0 8px 0;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
}

.bhm-pos-bottom-fixed .bhm-banner-title,
.bhm-pos-top-fixed .bhm-banner-title {
	font-size: 16px;
}

.bhm-banner-message {
	font-size: 14px;
	line-height: 1.5;
	opacity: 0.9;
}

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

.bhm-banner-message p {
	margin: 0;
}

.bhm-banner-message a {
	color: inherit;
	text-decoration: underline;
	font-weight: 600;
	transition: opacity 0.2s ease;
}

.bhm-banner-message a:hover {
	opacity: 0.8;
}

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

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

.bhm-categories {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.bhm-category-item {
	padding: 12px 14px;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 10px;
	background: rgba(0, 0, 0, 0.02);
	transition: background 0.2s ease;
}

.bhm-category-item:hover {
	background: rgba(0, 0, 0, 0.04);
}

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

.bhm-category-label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
}

.bhm-category-name {
	font-weight: 600;
}

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

.bhm-category-desc {
	margin: 6px 0 0;
	font-size: 12px;
	line-height: 1.4;
	opacity: 0.7;
}

/* Toggle Switch */
.bhm-toggle {
	position: relative;
	display: inline-block;
	width: 44px;
	height: 24px;
	flex-shrink: 0;
}

.bhm-toggle input {
	opacity: 0;
	width: 0;
	height: 0;
}

.bhm-toggle-slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(0, 0, 0, 0.15);
	border-radius: 24px;
	transition: all 0.25s ease;
}

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

.bhm-toggle input:checked + .bhm-toggle-slider {
	background-color: var(--bhm-accept-bg);
}

.bhm-toggle input:checked + .bhm-toggle-slider::before {
	transform: translateX(20px);
}

.bhm-toggle input:disabled + .bhm-toggle-slider {
	opacity: 0.5;
	cursor: not-allowed;
}

/* ==========================================================================
   Buttons — Equal Visual Weight (Anti-Dark-Pattern)
   ========================================================================== */

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

.bhm-pos-bottom-fixed .bhm-banner-buttons,
.bhm-pos-top-fixed .bhm-banner-buttons {
	flex-shrink: 0;
}

.bhm-btn {
	padding: 10px 20px;
	font-size: 14px;
	font-weight: 600;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1.2;
}

.bhm-btn:active {
	transform: scale(0.97);
}

.bhm-btn-accept {
	background-color: var(--bhm-accept-bg);
	color: var(--bhm-accept-text);
}

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

/*
 * 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-btn-decline {
	background-color: var(--bhm-decline-bg);
	color: var(--bhm-decline-text);
}

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

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

.bhm-btn-preferences:hover {
	background: rgba(0, 0, 0, 0.04);
}

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

/* Revoke/Privacy Settings Tab Badge */
.bhm-revoke-tab {
	position: fixed;
	z-index: 999980;
	background-color: var(--bhm-revoke-bg-color, var(--bhm-bg, #ffffff));
	color: var(--bhm-revoke-text-color, var(--bhm-text, #1f2937));
	box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 1px rgba(0,0,0,0.1);
	border: 1px solid rgba(0, 0, 0, 0.1);
	padding: 10px 16px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 8px;
	transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
	opacity: 0;
}

/* Position mapping for revoke badge */
.bhm-revoke-tab.bhm-revoke-bottom-right {
	bottom: 20px;
	right: 20px;
	border-radius: 30px;
	transform: translateY(80px);
}

.bhm-revoke-tab.bhm-revoke-bottom-left {
	left: 20px;
	bottom: 20px;
	border-radius: 30px;
	transform: translateY(80px);
}

.bhm-revoke-tab.bhm-revoke-top-right {
	top: 20px;
	right: 20px;
	border-radius: 30px;
	transform: translateY(-80px);
}

.bhm-revoke-tab.bhm-revoke-top-left {
	left: 20px;
	top: 20px;
	border-radius: 30px;
	transform: translateY(-80px);
}

/* Compatibility classes for legacy banner positions */
.bhm-revoke-tab.bhm-revoke-left {
	left: 20px;
	bottom: 20px;
	border-radius: 30px;
	transform: translateY(80px);
}

.bhm-revoke-tab.bhm-revoke-right {
	right: 20px;
	bottom: 20px;
	border-radius: 30px;
	transform: translateY(80px);
}

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

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

.bhm-revoke-tab.bhm-revoke-bottom-right:hover,
.bhm-revoke-tab.bhm-revoke-bottom-left:hover,
.bhm-revoke-tab.bhm-revoke-left:hover,
.bhm-revoke-tab.bhm-revoke-right:hover {
	transform: translateY(-2px);
}

.bhm-revoke-tab.bhm-revoke-top-right:hover,
.bhm-revoke-tab.bhm-revoke-top-left:hover {
	transform: translateY(2px);
}

.bhm-revoke-tab svg {
	width: 16px;
	height: 16px;
	fill: currentColor;
}

/* Responsive Overrides */
@media (max-width: 768px) {
	.bhm-consent-banner {
		padding: 20px;
	}

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

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

	.bhm-consent-banner.bhm-pos-bottom-fixed {
		transform: translateY(100%);
	}

	.bhm-consent-banner.bhm-pos-top-fixed {
		transform: translateY(-100%);
	}

	.bhm-banner-buttons {
		width: 100%;
	}

	.bhm-btn {
		flex: 1;
		min-width: 0;
	}

	.bhm-btn-preferences {
		flex-basis: 100%;
		order: 3;
	}
	
	.bhm-revoke-tab {
		bottom: 12px;
		padding: 8px 12px;
		font-size: 12px;
	}
	.bhm-revoke-tab.bhm-revoke-left {
		left: 12px;
	}
	.bhm-revoke-tab.bhm-revoke-right {
		right: 12px;
	}

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

	.bhm-category-label {
		font-size: 13px;
	}
}
