/* ---------------------------------------------------------------------------
 * privacy_consent - consent dialog, category panel and policy modal.
 *
 * Hand-written and self-contained on purpose: it ships inside the ocmod so the
 * banner is correct the moment the extension installs, with no build step and
 * no dependency on the Laravel Mix manifest. Dimensions are the exact values
 * mandated by Sarcina Tehnica sections 4.1-4.3.
 *
 * Palette taken from tailwind.config.js so the dialog matches Angro's identity:
 *   black #2B2A2A  primary #FF6E8E  secondary #73474E
 *   washedWhite #F7F3F3  grayDark #707070  grayLight #DDDDDD
 * ------------------------------------------------------------------------- */

/* Pre-lock scrolling before the dialog paints, so there is no flash of a
 * scrollable page. The class is added by the head bootstrap. */
html.privacy-consent-pending,
html.privacy-consent-locked {
	overflow: hidden !important;
}

html.privacy-consent-locked body {
	overflow: hidden !important;
}

.pc-root {
	font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #2B2A2A;
}

.pc-root[hidden] {
	display: none !important;
}

/* ----- 4.1 Overlay ----- */
.pc-overlay {
	position: fixed;
	inset: 0;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 2147483100;
	background: rgba(0, 0, 0, .35);
}

/* ----- Dialog, shared ----- */
.pc-dialog {
	position: fixed;
	z-index: 2147483101;
	background: #ffffff;
	box-sizing: border-box;
	overflow: hidden;
	outline: none;
}

.pc-dialog:focus-visible {
	outline: 2px solid #FF6E8E;
	outline-offset: 2px;
}

.pc-logo {
	display: block;
	max-width: 220px;
	height: auto;
	margin: 0 0 14px;
}

.pc-logo--text {
	font-size: 20px;
	font-weight: 700;
	color: #73474E;
}

.pc-title {
	margin: 0 0 10px;
	font-size: 22px;
	line-height: 1.25;
	font-weight: 700;
	color: #2B2A2A;
}

.pc-intro {
	margin: 0 0 12px;
}

.pc-benefits {
	margin: 0 0 12px;
	padding: 0 0 0 18px;
	list-style: disc;
}

.pc-benefits li {
	margin: 0 0 4px;
}

.pc-explain {
	margin: 0 0 12px;
	color: #707070;
	font-size: 13px;
}

.pc-links {
	margin: 0;
	font-size: 13px;
}

.pc-links a {
	color: #73474E;
	text-decoration: underline;
}

.pc-links a:hover,
.pc-links a:focus {
	color: #FF6E8E;
}

.pc-links__sep {
	margin: 0 6px;
	color: #DDDDDD;
}

.pc-nojs {
	margin: 12px 0 0;
	padding: 10px 12px;
	background: #F7F3F3;
	border-radius: 8px;
	font-size: 13px;
}

/* ----- Buttons -----
 * Section 4.2 / 18: accept and reject must be identical in width, height and
 * visual weight. They share every declaration; only the data-pc-action differs.
 * Do NOT add a variant that makes one of them louder than the other. */
.pc-btn {
	display: block;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 12px 18px;
	box-sizing: border-box;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	border: 1px solid transparent;
	border-radius: 8px;
	cursor: pointer;
	transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.pc-btn:focus-visible {
	outline: 2px solid #2B2A2A;
	outline-offset: 2px;
}

.pc-btn--primary {
	background: #73474E;
	border-color: #73474E;
	color: #ffffff;
}

.pc-btn--primary:hover {
	background: #FF6E8E;
	border-color: #FF6E8E;
}

.pc-btn--ghost {
	background: #ffffff;
	border-color: #73474E;
	color: #73474E;
}

.pc-btn--ghost:hover {
	background: #F7F3F3;
}

/* ----- Category panel ----- */
.pc-dialog__panel[hidden] {
	display: none !important;
}

.pc-categories {
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}

.pc-category {
	border-top: 1px solid #DDDDDD;
}

.pc-category:last-child {
	border-bottom: 1px solid #DDDDDD;
}

.pc-category__label {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 14px 2px;
	margin: 0;
	cursor: pointer;
}

.pc-category--unavailable .pc-category__label,
.pc-category__label:has(.pc-switch:disabled) {
	cursor: default;
}

/* The real checkbox stays in the accessibility tree and keeps native keyboard
 * behaviour; it is visually replaced, never removed. */
.pc-switch {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.pc-switch__ui {
	position: relative;
	flex: 0 0 auto;
	width: 42px;
	height: 24px;
	margin-top: 2px;
	background: #DDDDDD;
	border-radius: 12px;
	transition: background-color .2s ease;
}

.pc-switch__ui::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	background: #ffffff;
	border-radius: 50%;
	transition: transform .2s ease;
}

.pc-switch:checked + .pc-switch__ui {
	background: #73474E;
}

.pc-switch:checked + .pc-switch__ui::after {
	transform: translateX(18px);
}

.pc-switch:disabled + .pc-switch__ui {
	opacity: .5;
}

.pc-switch:focus-visible + .pc-switch__ui {
	outline: 2px solid #2B2A2A;
	outline-offset: 2px;
}

.pc-category__text {
	display: block;
}

.pc-category__title {
	display: block;
	font-weight: 600;
	color: #2B2A2A;
}

.pc-category__badge {
	display: inline-block;
	margin: 4px 0 0;
	padding: 2px 8px;
	background: #F7F3F3;
	border-radius: 10px;
	font-size: 11px;
	font-weight: 600;
	color: #73474E;
	text-transform: none;
}

.pc-category__badge--off {
	background: #DDDDDD;
	color: #707070;
}

.pc-category__desc {
	display: block;
	margin-top: 4px;
	font-size: 13px;
	color: #707070;
}

.pc-panel__actions {
	margin-top: 16px;
}

.pc-status {
	margin: 10px 0 0;
	font-size: 13px;
	color: #707070;
	min-height: 1em;
}

/* ----- 4.2 Desktop, min-width 992px ----- */
@media (min-width: 992px) {
	.pc-dialog {
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: calc(100% - 32px);
		max-width: 880px;
		max-height: min(720px, 88vh);
		padding: 34px 40px 32px;
		border-radius: 16px;
		box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
		display: grid;
		grid-template-columns: 1fr 250px;
		gap: 36px;
		align-content: start;
		overflow-y: auto;
	}

	.pc-dialog__text {
		grid-column: 1;
	}

	/* Actions sit vertically in the right-hand column. */
	.pc-dialog__actions {
		grid-column: 2;
		display: flex;
		flex-direction: column;
		gap: 10px;
		align-self: start;
	}

	/* The category panel spans both columns (section 4.2). */
	.pc-dialog__panel {
		grid-column: 1 / -1;
	}

	.pc-categories {
		max-height: 48vh;
	}

	.pc-status {
		grid-column: 1 / -1;
	}
}

/* ----- 4.3 Mobile and tablet, below 992px: bottom sheet ----- */
@media (max-width: 991px) {
	.pc-dialog {
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		max-height: calc(100% - 16px);
		padding: 14px 18px max(16px, env(safe-area-inset-bottom));
		border-radius: 16px 16px 0 0;
		box-shadow: 0 -8px 40px rgba(0, 0, 0, .22);
		display: flex;
		flex-direction: column;
		overflow-y: auto;
	}

	.pc-title {
		font-size: 19px;
	}

	/* Buttons stack full width. */
	.pc-dialog__actions {
		display: flex;
		flex-direction: column;
		gap: 8px;
		margin-top: 14px;
	}

	/* With the panel open the list scrolls internally so the actions stay
	 * reachable; the first level itself never needs scrolling to reach
	 * accept or reject. */
	.pc-dialog__panel {
		display: flex;
		flex-direction: column;
		min-height: 0;
		margin-top: 14px;
	}

	.pc-categories {
		max-height: 42vh;
		min-height: 0;
	}
}

/* ----- Motion (4.3): ~280ms slide-in, only when motion is welcome ----- */
@media (prefers-reduced-motion: no-preference) {
	@media (max-width: 991px) {
		.pc-root:not([hidden]) .pc-dialog {
			animation: pc-slide-up 280ms cubic-bezier(.22, .61, .36, 1) both;
		}
	}

	.pc-root:not([hidden]) .pc-overlay {
		animation: pc-fade-in 200ms ease both;
	}

	/* Overlay clicks do not dismiss; they pulse to signal a choice is required. */
	.pc-dialog--pulse {
		animation: pc-pulse 320ms ease;
	}
}

html.privacy-reduced-motion .pc-dialog,
html.privacy-reduced-motion .pc-overlay {
	animation: none !important;
	transition: none !important;
}

@keyframes pc-slide-up {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

@keyframes pc-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes pc-pulse {
	0%   { transform: scale(1); }
	40%  { transform: scale(1.012); }
	100% { transform: scale(1); }
}

@media (min-width: 992px) {
	@keyframes pc-pulse {
		0%   { transform: translate(-50%, -50%) scale(1); }
		40%  { transform: translate(-50%, -50%) scale(1.012); }
		100% { transform: translate(-50%, -50%) scale(1); }
	}
}

/* ----- Policy modal: stacks ABOVE the consent overlay ----- */
.pc-modal[hidden] {
	display: none !important;
}

.pc-modal__overlay {
	position: fixed;
	inset: 0;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 2147483200;
	background: rgba(0, 0, 0, .55);
}

.pc-modal__dialog {
	position: fixed;
	z-index: 2147483201;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: flex;
	flex-direction: column;
	width: calc(100% - 24px);
	max-width: 820px;
	max-height: 86vh;
	background: #ffffff;
	border-radius: 16px;
	box-shadow: 0 24px 64px rgba(0, 0, 0, .32);
	font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: #2B2A2A;
	box-sizing: border-box;
	overflow: hidden;
}

.pc-modal__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 18px 20px;
	border-bottom: 1px solid #DDDDDD;
}

.pc-modal__title {
	flex: 1 1 auto;
	margin: 0;
	font-size: 18px;
	font-weight: 700;
}

.pc-modal__external {
	flex: 0 0 auto;
	font-size: 13px;
	color: #73474E;
	text-decoration: underline;
}

.pc-modal__close {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	padding: 0;
	background: #F7F3F3;
	border: 0;
	border-radius: 50%;
	font-size: 22px;
	line-height: 1;
	color: #2B2A2A;
	cursor: pointer;
}

.pc-modal__close:hover {
	background: #DDDDDD;
}

.pc-modal__close:focus-visible {
	outline: 2px solid #2B2A2A;
	outline-offset: 2px;
}

.pc-modal__body {
	flex: 1 1 auto;
	min-height: 0;
	padding: 20px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	font-size: 14px;
	line-height: 1.6;
}

.pc-modal__body:focus-visible {
	outline: 2px solid #FF6E8E;
	outline-offset: -2px;
}

.pc-modal__body h2,
.pc-modal__body h3,
.pc-modal__body h4 {
	margin: 20px 0 8px;
	line-height: 1.3;
}

.pc-modal__body h2 { font-size: 18px; }
.pc-modal__body h3 { font-size: 16px; }
.pc-modal__body h4 { font-size: 15px; }

.pc-modal__body p,
.pc-modal__body ul,
.pc-modal__body ol {
	margin: 0 0 12px;
}

.pc-modal__body ul,
.pc-modal__body ol {
	padding-left: 20px;
}

.pc-modal__body a {
	color: #73474E;
	text-decoration: underline;
	word-break: break-word;
}

/* Policy tables are wide; they scroll inside their own container so the modal
 * body never scrolls horizontally. */
.pc-modal__body table {
	display: block;
	width: 100%;
	max-width: 100%;
	overflow-x: auto;
	border-collapse: collapse;
	margin: 0 0 12px;
	font-size: 13px;
}

.pc-modal__body th,
.pc-modal__body td {
	padding: 8px 10px;
	border: 1px solid #DDDDDD;
	text-align: left;
	vertical-align: top;
}

.pc-modal__body th {
	background: #F7F3F3;
	font-weight: 600;
}

.pc-modal__loading {
	color: #707070;
}

@media (max-width: 991px) {
	.pc-modal__dialog {
		top: auto;
		bottom: 0;
		left: 0;
		transform: none;
		width: 100%;
		max-width: none;
		max-height: calc(100% - 16px);
		border-radius: 16px 16px 0 0;
	}
}

/* ----- Footer entry point ----- */
.privacy-consent-footer {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 14px;
	margin-right: 14px;
}

.privacy-consent-footer__link {
	padding: 0;
	background: none;
	border: 0;
	font: inherit;
	color: inherit;
	text-decoration: underline;
	cursor: pointer;
	opacity: .9;
}

.privacy-consent-footer__link:hover,
.privacy-consent-footer__policy:hover {
	opacity: 1;
	text-decoration: underline;
}

.privacy-consent-footer__policy {
	color: inherit;
	text-decoration: underline;
	opacity: .9;
}

.privacy-consent-footer__link:focus-visible,
.privacy-consent-footer__policy:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}
