/*!
 * CookieShield PRO - Frontend styles
 * (c) compraweb.es
 */

/* Variables base (tema claro por defecto). Se declaran en .csp-root y
 * en #csp-reopen (que vive fuera de .csp-root) para no contaminar :root. */
.csp-root, #csp-reopen, .csp-policy {
	--csp-primary: #2563eb;
	--csp-accent: #0ea5e9;
	--csp-text: #0f172a;
	--csp-bg: #ffffff;
	--csp-muted: #64748b;
	--csp-border: rgba(15, 23, 42, .08);
	--csp-shadow: 0 20px 50px -12px rgba(2, 6, 23, .35);
	--csp-radius: 14px;
	--csp-radius-sm: 10px;
	--csp-transition: .25s cubic-bezier(.4, 0, .2, 1);
	--csp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Tema oscuro: mayor especificidad (.csp-root.csp-theme-dark) que las reglas
 * sueltas .csp-root para que SIEMPRE gane frente a overrides del usuario. */
.csp-root.csp-theme-dark, #csp-reopen.csp-theme-dark {
	--csp-bg: #0f172a;
	--csp-text: #e2e8f0;
	--csp-muted: #94a3b8;
	--csp-border: rgba(255, 255, 255, .08);
}

.csp-root {
	font-family: var(--csp-font);
	color: var(--csp-text);
	line-height: 1.55;
	font-size: 15px;
}
.csp-root *, .csp-root *::before, .csp-root *::after { box-sizing: border-box; }
.csp-root[hidden] { display: none !important; }

/* === Banner === */
.csp-banner {
	position: fixed;
	left: 0;
	right: 0;
	z-index: 999999;
	background: var(--csp-bg);
	color: var(--csp-text);
	box-shadow: var(--csp-shadow);
	border-top: 1px solid var(--csp-border);
	animation: cspSlideUp var(--csp-transition);
}
.csp-pos-bottom .csp-banner { bottom: 0; }
.csp-pos-top    .csp-banner { top: 0; border-top: 0; border-bottom: 1px solid var(--csp-border); animation-name: cspSlideDown; }
.csp-pos-modal  .csp-banner {
	top: 50%; left: 50%; right: auto; bottom: auto;
	transform: translate(-50%, -50%);
	max-width: 680px; width: calc(100% - 32px);
	border-radius: var(--csp-radius);
	animation-name: cspPop;
}
.csp-pos-modal::before {
	content: "";
	position: fixed; inset: 0;
	background: rgba(2, 6, 23, .55);
	backdrop-filter: blur(4px);
	z-index: 999998;
	animation: cspFade var(--csp-transition);
}
.csp-pos-modal { position: static; }

.csp-banner__inner {
	display: grid;
	grid-template-columns: auto 1fr auto;
	gap: 22px;
	align-items: center;
	max-width: 1400px;
	margin: 0 auto;
	padding: 22px 28px;
}
.csp-pos-modal .csp-banner__inner {
	grid-template-columns: 1fr;
	padding: 28px;
	text-align: left;
}

.csp-banner__logo img {
	max-height: 36px;
	max-width: 160px;
	display: block;
}

.csp-banner__title {
	font-size: 17px;
	font-weight: 700;
	margin: 0 0 4px;
	color: var(--csp-text);
}
.csp-banner__desc {
	font-size: 14px;
	color: var(--csp-muted);
	margin: 0;
}
.csp-banner__desc a, .csp-banner__policy {
	color: var(--csp-primary);
	text-decoration: underline;
}

.csp-banner__actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
}
.csp-pos-modal .csp-banner__actions {
	justify-content: flex-start;
	margin-top: 8px;
}

/* === Buttons === */
.csp-btn {
	appearance: none;
	border: 1px solid transparent;
	border-radius: var(--csp-radius-sm);
	padding: 11px 18px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: transform var(--csp-transition), box-shadow var(--csp-transition), background var(--csp-transition), color var(--csp-transition), border-color var(--csp-transition);
	font-family: inherit;
}
.csp-btn:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--csp-primary) 35%, transparent);
	outline-offset: 2px;
}
.csp-btn--primary {
	background: var(--csp-primary);
	color: #fff;
	box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--csp-primary) 70%, #000);
}
.csp-btn--primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.csp-banner .csp-btn--secondary,
.csp-modal .csp-btn--secondary,
.csp-btn--secondary {
	background: transparent;
	color: var(--csp-text);
	border: 1.5px solid var(--csp-text);
	opacity: .9;
}
.csp-banner .csp-btn--secondary:hover,
.csp-modal .csp-btn--secondary:hover,
.csp-btn--secondary:hover {
	background: var(--csp-text);
	color: var(--csp-bg);
	opacity: 1;
}
.csp-btn--ghost {
	background: transparent;
	color: var(--csp-primary);
	text-decoration: underline;
	padding-left: 12px; padding-right: 12px;
}

/* === Modal (preferences) === */
.csp-modal {
	position: fixed; inset: 0;
	z-index: 9999999;
	background: rgba(2, 6, 23, .55);
	backdrop-filter: blur(4px);
	display: flex; align-items: center; justify-content: center;
	padding: 16px;
	animation: cspFade var(--csp-transition);
}
.csp-modal[hidden] { display: none; }
.csp-modal__panel {
	width: 100%;
	max-width: 720px;
	max-height: 88vh;
	background: var(--csp-bg);
	color: var(--csp-text);
	border-radius: var(--csp-radius);
	box-shadow: var(--csp-shadow);
	display: flex; flex-direction: column;
	overflow: hidden;
	animation: cspPop var(--csp-transition);
}
.csp-modal__header {
	display: flex; align-items: center; justify-content: space-between;
	padding: 18px 24px;
	border-bottom: 1px solid var(--csp-border);
}
.csp-modal__header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.csp-modal__close {
	background: none; border: 0;
	font-size: 28px; line-height: 1;
	color: var(--csp-muted);
	cursor: pointer;
	width: 34px; height: 34px; border-radius: 8px;
	transition: background var(--csp-transition);
}
.csp-modal__close:hover { background: rgba(15,23,42,.06); color: var(--csp-text); }
.csp-modal__body {
	padding: 10px 24px;
	overflow-y: auto;
}
.csp-modal__footer {
	padding: 16px 24px;
	border-top: 1px solid var(--csp-border);
	display: flex; gap: 10px; flex-wrap: wrap;
	justify-content: flex-end;
	background: rgba(15, 23, 42, .02);
}

/* === Category cards === */
.csp-cat {
	padding: 16px 0;
	border-bottom: 1px solid var(--csp-border);
}
.csp-cat:last-child { border-bottom: 0; }
.csp-cat__head {
	display: flex; align-items: flex-start; justify-content: space-between;
	gap: 16px;
}
.csp-cat__name { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.csp-cat__desc { margin: 0; font-size: 13px; color: var(--csp-muted); }
.csp-cat__cookies {
	margin-top: 8px;
	font-size: 13px;
}
.csp-cat__cookies summary {
	cursor: pointer;
	color: var(--csp-primary);
	user-select: none;
}
.csp-cat__cookies ul {
	margin: 6px 0 0; padding-left: 18px;
	color: var(--csp-muted);
}
.csp-cat__cookies code {
	background: rgba(15, 23, 42, .05);
	padding: 2px 6px; border-radius: 5px; font-size: 12px;
}

/* === Switch === */
.csp-switch {
	position: relative;
	display: inline-block;
	width: 44px; height: 24px;
	flex-shrink: 0;
}
.csp-switch input { opacity: 0; width: 0; height: 0; }
.csp-switch__slider {
	position: absolute; inset: 0;
	background: #cbd5e1;
	border-radius: 999px;
	cursor: pointer;
	transition: background var(--csp-transition);
}
.csp-switch__slider::before {
	content: "";
	position: absolute;
	width: 18px; height: 18px;
	left: 3px; top: 3px;
	background: #fff;
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0,0,0,.25);
	transition: transform var(--csp-transition);
}
.csp-switch input:checked + .csp-switch__slider { background: var(--csp-primary); }
.csp-switch input:checked + .csp-switch__slider::before { transform: translateX(20px); }
.csp-switch input:disabled + .csp-switch__slider { opacity: .6; cursor: not-allowed; }

/* === Reopen floating button === */
.csp-reopen {
	position: fixed;
	left: 20px; bottom: 20px;
	width: 52px; height: 52px;
	border-radius: 50%;
	background: var(--csp-primary);
	color: #fff;
	border: 0;
	box-shadow: 0 10px 30px -6px color-mix(in srgb, var(--csp-primary) 60%, #000), 0 2px 6px rgba(0,0,0,.15);
	cursor: pointer;
	z-index: 2147483000;
	display: inline-flex; align-items: center; justify-content: center;
	transition: transform var(--csp-transition), box-shadow var(--csp-transition);
}
.csp-reopen:hover { transform: translateY(-3px) scale(1.05); }
.csp-reopen svg { width: 26px; height: 26px; }
.csp-reopen.csp-theme-dark {
	background: var(--csp-primary);
	color: #fff;
}

/* === Dark theme (reglas visuales extra; las variables están arriba) === */
.csp-theme-dark .csp-banner,
.csp-theme-dark .csp-modal__panel,
.csp-reopen.csp-theme-dark { background: var(--csp-bg); color: var(--csp-text); }
.csp-theme-dark .csp-btn--secondary { color: var(--csp-text); }
.csp-theme-dark .csp-modal__footer { background: rgba(255,255,255,.02); }
.csp-theme-dark .csp-cat__cookies code { background: rgba(255,255,255,.06); }

/* === Placeholder for blocked embeds === */
.csp-placeholder {
	display: flex; align-items: center; justify-content: center;
	min-height: 220px;
	background: linear-gradient(135deg, rgba(37, 99, 235, .06), rgba(14, 165, 233, .06));
	border: 1px dashed var(--csp-border);
	border-radius: var(--csp-radius);
	padding: 20px;
	color: var(--csp-text);
	text-align: center;
	margin: 14px 0;
}
.csp-placeholder__inner { max-width: 520px; }
.csp-placeholder svg { color: var(--csp-primary); }
.csp-placeholder__title {
	margin: 10px 0 4px; font-weight: 700; font-size: 16px;
}
.csp-placeholder__desc {
	margin: 0 0 12px;
	color: var(--csp-muted);
	font-size: 14px;
}

/* === Policy shortcode === */
.csp-policy h2, .csp-policy h3, .csp-policy h4 { margin-top: 1.4em; }
.csp-policy-cookies { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.csp-policy-cookies code {
	background: rgba(15, 23, 42, .05);
	padding: 3px 8px; border-radius: 6px; font-size: 12px;
}

/* === Animations === */
@keyframes cspSlideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes cspSlideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes cspPop { from { transform: translate(-50%, -50%) scale(.96); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.csp-modal .csp-modal__panel { animation-name: cspPopPlain; }
@keyframes cspPopPlain { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes cspFade { from { opacity: 0; } to { opacity: 1; } }

/* === Responsive === */
@media (max-width: 780px) {
	.csp-banner__inner {
		grid-template-columns: 1fr;
		padding: 18px 18px;
	}
	.csp-banner__actions { justify-content: stretch; }
	.csp-banner__actions .csp-btn { flex: 1 1 auto; text-align: center; }
	.csp-banner__logo img { max-height: 32px; }
	.csp-modal__body { padding: 4px 18px; }
	.csp-modal__header, .csp-modal__footer { padding: 14px 18px; }
}

/* =========================================================================
 * BLINDAJE FRENTE AL CSS DEL TEMA DEL SITIO (anti-leak)
 * Si el tema del WP define estilos genéricos para h1-h6 o button, se cuelan
 * dentro del banner/modal. Estas reglas tienen mayor especificidad (.csp-root
 * como prefijo = doble clase) y ganan a las reglas genéricas del tema.
 * ========================================================================= */

/* Encabezados: color correcto dentro del banner y del modal */
.csp-root h1, .csp-root h2, .csp-root h3, .csp-root h4, .csp-root h5, .csp-root h6 {
	color: var(--csp-text);
	background: transparent;
	font-family: inherit;
	text-shadow: none;
	letter-spacing: normal;
	text-transform: none;
	line-height: 1.25;
	padding: 0;
}
.csp-root .csp-modal__header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.csp-root .csp-banner__title { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.csp-root .csp-cat__name { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--csp-text); }
.csp-root .csp-cat__desc { color: var(--csp-muted); font-size: 13px; margin: 0; }

/* Botones: garantizar colores correctos frente a button{} genéricos del tema */
.csp-root button,
.csp-root .csp-btn,
#csp-reopen {
	font-family: inherit;
	text-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	appearance: none;
	-webkit-appearance: none;
}
.csp-root .csp-btn--primary,
.csp-root button.csp-btn--primary {
	background: var(--csp-primary);
	color: #fff;
	border: 1px solid var(--csp-primary);
}
.csp-root .csp-btn--primary:hover { filter: brightness(1.08); }
.csp-root .csp-btn--secondary,
.csp-root button.csp-btn--secondary {
	background: transparent;
	color: var(--csp-text);
	border: 1.5px solid var(--csp-text);
}
.csp-root .csp-btn--secondary:hover {
	background: var(--csp-text);
	color: var(--csp-bg);
}
.csp-root .csp-btn--ghost,
.csp-root button.csp-btn--ghost {
	background: transparent;
	color: var(--csp-primary);
	border: 1px solid transparent;
	text-decoration: underline;
}
.csp-root .csp-btn--ghost:hover { background: rgba(37, 99, 235, .08); }

/* Botón cerrar del modal: sin fondo blanco heredado del tema */
.csp-root .csp-modal__close,
.csp-root button.csp-modal__close {
	background: transparent;
	color: var(--csp-muted);
	border: 0;
	box-shadow: none;
	width: 34px; height: 34px;
	border-radius: 8px;
	padding: 0;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}
.csp-root .csp-modal__close:hover {
	background: rgba(148, 163, 184, .18);
	color: var(--csp-text);
}

/* Links dentro del modal/banner */
.csp-root a { color: var(--csp-primary); text-decoration: underline; }
.csp-root a:hover { filter: brightness(.9); }

/* Details/summary (lista de cookies) */
.csp-root details summary { color: var(--csp-primary); cursor: pointer; }
