/**
 * UP Cookie Consent — styles publics.
 * Design neutre, personnalisable via variables CSS (voir class-upcc-frontend.php).
 */

:root {
	--upcc-text-color: #1f2933;
	--upcc-bg: #ffffff;
	--upcc-border: #e2e5e9;
	--upcc-accept-bg: #1f7a4d;
	--upcc-accept-text: #ffffff;
	--upcc-reject-bg: #ffffff;
	--upcc-reject-text: #1f2933;
	--upcc-accent: #1f7a4d;
	--upcc-radius: 10px;
	--upcc-shadow: 0 6px 24px rgba(20, 24, 31, 0.16);
	--upcc-z: 999999;
}

.upcc-root, .upcc-root * {
	box-sizing: border-box;
}

.upcc-root {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--upcc-text-color);
}

/* ---------- Bandeau ---------- */

.upcc-banner {
	position: fixed;
	z-index: var(--upcc-z);
	background: var(--upcc-bg);
	border: 1px solid var(--upcc-border);
	box-shadow: var(--upcc-shadow);
}

.upcc-banner[hidden] {
	display: none;
}

.upcc-position-bottom-bar {
	left: 0;
	right: 0;
	bottom: 0;
	border-left: none;
	border-right: none;
	border-bottom: none;
}

.upcc-position-bottom-bar .upcc-banner__inner {
	max-width: 1200px;
	margin: 0 auto;
	padding: 18px 24px;
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	align-items: center;
	justify-content: space-between;
}

.upcc-position-bottom-left,
.upcc-position-bottom-right {
	bottom: 20px;
	max-width: 420px;
	width: calc(100% - 40px);
	max-height: calc(100vh - 40px);
	overflow-y: auto;
	border-radius: var(--upcc-radius);
}

.upcc-position-bottom-left {
	left: 20px;
}

.upcc-position-bottom-right {
	right: 20px;
}

.upcc-position-bottom-left .upcc-banner__inner,
.upcc-position-bottom-right .upcc-banner__inner {
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.upcc-banner__text {
	flex: 0 1 auto;
	min-width: 220px;
}

/* En mode "barre pleine largeur", l'axe principal est horizontal : on peut
   laisser le bloc de texte grandir jusqu'à 420px de large. */
.upcc-position-bottom-bar .upcc-banner__text {
	flex: 1 1 420px;
}

/* En mode "carte" (bas-gauche/bas-droite), l'axe principal est vertical :
   le bloc de texte ne doit pas hériter d'une base de 420px, sinon il force
   une hauteur minimale de 420px et laisse un grand vide avant les boutons. */
.upcc-position-bottom-left .upcc-banner__text,
.upcc-position-bottom-right .upcc-banner__text {
	flex: 0 1 auto;
	min-width: 0;
}

.upcc-banner__title {
	margin: 0 0 6px;
	font-weight: 600;
	font-size: 16px;
}

.upcc-banner__desc {
	margin: 0 0 8px;
	color: var(--upcc-text-color);
	opacity: 0.85;
}

.upcc-banner__note {
	margin: 0;
	font-size: 13px;
	opacity: 0.75;
}

.upcc-banner__note a {
	color: var(--upcc-accent);
	text-decoration: underline;
}

.upcc-banner__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	flex-shrink: 0;
}

/* ---------- Boutons ---------- */

.upcc-btn {
	appearance: none;
	border-radius: 6px;
	padding: 10px 18px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	border: 1px solid transparent;
	white-space: nowrap;
	transition: opacity 0.15s ease, transform 0.05s ease;
}

.upcc-btn:hover {
	opacity: 0.9;
}

.upcc-btn:active {
	transform: translateY(1px);
}

.upcc-btn:focus-visible {
	outline: 2px solid var(--upcc-accent);
	outline-offset: 2px;
}

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

.upcc-btn--reject {
	background: var(--upcc-reject-bg);
	color: var(--upcc-reject-text);
	border-color: var(--upcc-border);
}

.upcc-btn--ghost {
	background: transparent;
	color: var(--upcc-text-color);
	border-color: var(--upcc-border);
}

/* ---------- Fenetre de preferences ---------- */

.upcc-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 18, 22, 0.55);
	z-index: var(--upcc-z);
}

.upcc-modal-overlay[hidden] {
	display: none;
}

.upcc-modal {
	position: fixed;
	z-index: calc(var(--upcc-z) + 1);
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: min(560px, calc(100% - 32px));
	max-height: min(680px, calc(100% - 48px));
}

.upcc-modal[hidden] {
	display: none;
}

.upcc-modal__panel {
	background: var(--upcc-bg);
	border-radius: var(--upcc-radius);
	box-shadow: var(--upcc-shadow);
	padding: 28px;
	max-height: min(680px, calc(100vh - 48px));
	overflow-y: auto;
	position: relative;
}

.upcc-modal__close {
	position: absolute;
	top: 14px;
	right: 14px;
	background: transparent;
	border: none;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	color: var(--upcc-text-color);
	padding: 6px;
}

.upcc-modal__close:focus-visible {
	outline: 2px solid var(--upcc-accent);
}

.upcc-modal__title {
	margin: 0 0 10px;
	font-size: 19px;
	font-weight: 700;
	padding-right: 24px;
}

.upcc-modal__intro {
	margin: 0 0 20px;
	opacity: 0.85;
}

.upcc-categories {
	display: flex;
	flex-direction: column;
	gap: 4px;
	border-top: 1px solid var(--upcc-border);
}

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

.upcc-category__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.upcc-category__title {
	font-weight: 600;
}

.upcc-category__status {
	font-size: 12px;
	font-weight: 600;
	color: var(--upcc-accent);
	white-space: nowrap;
}

.upcc-category__desc {
	margin: 6px 0 0;
	font-size: 13.5px;
	opacity: 0.8;
}

.upcc-modal__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 22px;
}

.upcc-modal__actions .upcc-btn {
	flex: 1 1 auto;
	text-align: center;
}

/* ---------- Interrupteur (switch) ---------- */

.upcc-switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	flex-shrink: 0;
}

.upcc-switch__input {
	position: absolute;
	opacity: 0;
	width: 42px;
	height: 24px;
	margin: 0;
	cursor: pointer;
}

.upcc-switch__track {
	width: 42px;
	height: 24px;
	background: #c7cbd1;
	border-radius: 999px;
	position: relative;
	transition: background 0.15s ease;
	display: inline-block;
}

.upcc-switch__track::before {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	transition: transform 0.15s ease;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.upcc-switch__input:checked + .upcc-switch__track {
	background: var(--upcc-accent);
}

.upcc-switch__input:checked + .upcc-switch__track::before {
	transform: translateX(18px);
}

.upcc-switch__input:focus-visible + .upcc-switch__track {
	outline: 2px solid var(--upcc-accent);
	outline-offset: 2px;
}

/* ---------- Bouton flottant de reouverture ---------- */

.upcc-floating-btn {
	position: fixed;
	z-index: var(--upcc-z);
	bottom: 20px;
	left: 20px;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	background: var(--upcc-bg);
	border: 1px solid var(--upcc-border);
	box-shadow: var(--upcc-shadow);
	color: var(--upcc-accent);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.upcc-floating-btn[hidden] {
	display: none;
}

.upcc-floating-btn:hover {
	opacity: 0.9;
}

/* ---------- Lien preferences (shortcode) ---------- */

.upcc-preferences-link {
	background: none;
	border: none;
	padding: 0;
	margin: 0;
	color: inherit;
	text-decoration: underline;
	cursor: pointer;
	font: inherit;
}

/* ---------- Accessibilite ---------- */

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
	.upcc-position-bottom-bar .upcc-banner__inner {
		flex-direction: column;
		align-items: stretch;
	}

	.upcc-banner__actions {
		flex-direction: column;
	}

	.upcc-banner__actions .upcc-btn {
		width: 100%;
	}

	.upcc-modal__panel {
		padding: 20px;
	}
}

/* ---------- Mode sombre (respecte les preferences systeme) ---------- */

@media (prefers-color-scheme: dark) {
	.upcc-root {
		--upcc-bg: #1d2229;
		--upcc-border: #333a44;
	}

	.upcc-root .upcc-modal-overlay {
		background: rgba(0, 0, 0, 0.65);
	}
}
