/**
 * TaskBrowse Consent Control - front-end styles.
 *
 * Brand tokens:
 *   --tbcc-red          #C8102E  accent only (focus, links, small marks)
 *   --tbcc-charcoal     #202124  primary text + solid buttons
 *   --tbcc-offwhite     #F7F4F0  category rows
 *   --tbcc-white        #FFFFFF  dialog surface
 *   --tbcc-border       #E3E5E8  dividers, toggle track
 *   --tbcc-muted        #6B6B70  secondary text
 *
 * Equal-weight choices: "reject" and "accept" share size and contrast.
 * Red is never used to push one choice over another.
 */

:root {
	--tbcc-red: #c8102e;
	--tbcc-charcoal: #202124;
	--tbcc-offwhite: #f7f4f0;
	--tbcc-white: #ffffff;
	--tbcc-border: #e3e5e8;
	--tbcc-muted: #6b6b70;
	--tbcc-radius: 12px;
	--tbcc-radius-sm: 8px;
	--tbcc-font: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	--tbcc-shadow: 0 12px 40px rgba(32, 33, 36, 0.18);
	--tbcc-z: 2147483600;
}

/* ----- containers ----- */

.tbcc-root,
.tbcc-floating,
.tbcc-preferences-link,
.tbcc-placeholders {
	font-family: var(--tbcc-font);
	box-sizing: border-box;
}

.tbcc-root *,
.tbcc-root *::before,
.tbcc-root *::after {
	box-sizing: border-box;
}

.tbcc-root[hidden],
.tbcc-overlay[hidden],
.tbcc-layer[hidden],
.tbcc-floating[hidden] {
	display: none !important;
}

.tbcc-root {
	position: fixed;
	inset: 0;
	z-index: var(--tbcc-z);
	color: var(--tbcc-charcoal);
	font-size: 15px;
	line-height: 1.5;
}

.tbcc-overlay {
	position: fixed;
	inset: 0;
	background: rgba(32, 33, 36, 0.45);
	z-index: 1;
}

/* ----- dialog placement ----- */

.tbcc-dialog {
	position: fixed;
	z-index: 2;
	background: var(--tbcc-white);
	color: var(--tbcc-charcoal);
	box-shadow: var(--tbcc-shadow);
	border: 1px solid var(--tbcc-border);
	padding: 24px;
	width: min(720px, calc(100% - 32px));
	max-height: calc(100vh - 32px);
	overflow-y: auto;
}

/* Bottom banner (desktop) */
.tbcc-pos-bottom .tbcc-dialog {
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	border-radius: var(--tbcc-radius);
}

/* Centered modal */
.tbcc-pos-center .tbcc-dialog {
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	border-radius: var(--tbcc-radius);
}

/* ----- typography ----- */

.tbcc-title {
	margin: 0 0 8px;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--tbcc-charcoal);
}

.tbcc-body {
	margin: 0 0 16px;
	color: var(--tbcc-charcoal);
}

.tbcc-policy {
	margin: 0 0 16px;
	font-size: 13px;
}

.tbcc-policy a,
.tbcc-link-back {
	color: var(--tbcc-red);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* ----- actions ----- */

.tbcc-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.tbcc-actions-three {
	margin-top: 8px;
}

.tbcc-actions-three .tbcc-btn {
	flex: 1 1 160px;
}

.tbcc-btn {
	appearance: none;
	border: 1.5px solid var(--tbcc-charcoal);
	border-radius: var(--tbcc-radius-sm);
	padding: 11px 18px;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

/* Reject + Settings: high-contrast outline. As prominent as Accept. */
.tbcc-btn-secondary {
	background: var(--tbcc-white);
	color: var(--tbcc-charcoal);
}

.tbcc-btn-secondary:hover {
	background: var(--tbcc-offwhite);
}

/* Accept: inverted fill. Same size + contrast as reject, not red. */
.tbcc-btn-primary {
	background: var(--tbcc-charcoal);
	color: var(--tbcc-white);
}

.tbcc-btn-primary:hover {
	background: #000;
}

/* ----- settings: categories ----- */

.tbcc-categories {
	list-style: none;
	margin: 0 0 16px;
	padding: 0;
	border-top: 1px solid var(--tbcc-border);
}

.tbcc-category {
	padding: 14px 0;
	border-bottom: 1px solid var(--tbcc-border);
}

.tbcc-category-head {
	margin-bottom: 4px;
}

.tbcc-switch {
	display: flex;
	align-items: center;
	gap: 12px;
	position: relative;
	cursor: pointer;
}

.tbcc-switch:has(.tbcc-toggle:disabled) {
	cursor: default;
}

/* Visually-hidden but focusable checkbox */
.tbcc-toggle {
	position: absolute;
	width: 44px;
	height: 24px;
	margin: 0;
	opacity: 0;
	cursor: inherit;
}

.tbcc-switch-track {
	position: relative;
	flex: 0 0 auto;
	width: 44px;
	height: 24px;
	border-radius: 999px;
	background: var(--tbcc-border);
	transition: background-color 0.15s ease;
}

.tbcc-switch-track::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var(--tbcc-white);
	box-shadow: 0 1px 2px rgba(32, 33, 36, 0.35);
	transition: transform 0.15s ease;
}

.tbcc-toggle:checked + .tbcc-switch-track {
	background: var(--tbcc-charcoal);
}

.tbcc-toggle:checked + .tbcc-switch-track::after {
	transform: translateX(20px);
}

.tbcc-toggle:disabled + .tbcc-switch-track {
	background: var(--tbcc-muted);
	opacity: 0.6;
}

.tbcc-toggle:focus-visible + .tbcc-switch-track {
	outline: 2px solid var(--tbcc-red);
	outline-offset: 2px;
}

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

.tbcc-badge {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--tbcc-muted);
	border: 1px solid var(--tbcc-border);
	border-radius: 999px;
	padding: 2px 8px;
	margin-left: auto;
}

.tbcc-category-desc {
	margin: 0;
	padding-left: 56px;
	color: var(--tbcc-muted);
	font-size: 13.5px;
}

.tbcc-link-back {
	display: inline-block;
	margin-top: 4px;
	background: none;
	border: 0;
	padding: 6px 0;
	font-family: inherit;
	font-size: 14px;
	cursor: pointer;
}

/* ----- focus ring (shared) ----- */

.tbcc-btn:focus-visible,
.tbcc-link-back:focus-visible,
.tbcc-policy a:focus-visible,
.tbcc-floating:focus-visible,
.tbcc-preferences-link:focus-visible,
.tbcc-placeholder:focus-visible {
	outline: 2px solid var(--tbcc-red);
	outline-offset: 2px;
}

/* ----- floating "change settings" button ----- */

.tbcc-floating {
	position: fixed;
	left: 16px;
	bottom: 16px;
	z-index: 2147483400;
	background: var(--tbcc-white);
	color: var(--tbcc-charcoal);
	border: 1px solid var(--tbcc-border);
	border-radius: 999px;
	padding: 9px 16px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(32, 33, 36, 0.14);
}

.tbcc-floating:hover {
	background: var(--tbcc-offwhite);
}

/* ----- inline "change settings" link (shortcode / helper) ----- */

.tbcc-preferences-link {
	display: inline-block;
	background: none;
	border: 0;
	padding: 0;
	color: var(--tbcc-red);
	font-family: inherit;
	font-size: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

/* ----- click-to-load placeholders (e.g. chat assistant) ----- */

.tbcc-placeholders {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 2147483300;
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: flex-end;
}

.tbcc-placeholder {
	background: var(--tbcc-charcoal);
	color: var(--tbcc-white);
	border: 0;
	border-radius: 999px;
	padding: 11px 18px;
	font-family: var(--tbcc-font);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(32, 33, 36, 0.22);
	max-width: 280px;
}

.tbcc-placeholder:hover {
	background: #000;
}

.tbcc-placeholder-hint {
	font-size: 12px;
	font-weight: 400;
	color: var(--tbcc-muted);
	background: var(--tbcc-white);
	border: 1px solid var(--tbcc-border);
	border-radius: var(--tbcc-radius-sm);
	padding: 8px 12px;
	max-width: 280px;
}

/* ----- mobile: bottom sheet ----- */

@media (max-width: 600px) {
	.tbcc-pos-bottom .tbcc-dialog,
	.tbcc-pos-center .tbcc-dialog {
		left: 0;
		right: 0;
		bottom: 0;
		top: auto;
		transform: none;
		width: 100%;
		max-height: 88vh;
		border-radius: var(--tbcc-radius) var(--tbcc-radius) 0 0;
		padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
	}

	.tbcc-actions-three .tbcc-btn {
		flex: 1 1 100%;
	}

	.tbcc-category-desc {
		padding-left: 0;
	}

	.tbcc-floating {
		font-size: 12px;
		padding: 8px 14px;
	}
}

/* ----- reduced motion ----- */

@media (prefers-reduced-motion: reduce) {
	.tbcc-btn,
	.tbcc-switch-track,
	.tbcc-switch-track::after {
		transition: none;
	}
}

/* ----- RTL (Arabic and other right-to-left locales) ----- */
/* The banner root, the floating button and the JS-created placeholder
   container all carry dir="rtl" on RTL locales. Flex rows (actions, switch,
   category head) mirror automatically from the inherited direction, so only
   the physically-positioned pieces need explicit flipping here. */

[dir="rtl"] .tbcc-switch-track::after {
	left: auto;
	right: 2px;
}

[dir="rtl"] .tbcc-toggle:checked + .tbcc-switch-track::after {
	transform: translateX(-20px);
}

[dir="rtl"] .tbcc-badge {
	margin-left: 0;
	margin-right: auto;
}

[dir="rtl"] .tbcc-category-desc {
	padding-left: 0;
	padding-right: 56px;
}

[dir="rtl"].tbcc-floating {
	left: auto;
	right: 16px;
}

[dir="rtl"].tbcc-placeholders {
	right: auto;
	left: 16px;
	align-items: flex-start;
}

@media (max-width: 600px) {
	[dir="rtl"] .tbcc-category-desc {
		padding-right: 0;
	}
}
