/*
 * Notificaciones — panel/js/notificaciones.js: toasts, bell dropdown, home
 * widget and the /admin/notificaciones page. Theme tokens throughout.
 *
 * Colour per tipo: high = danger, medium = warn, low = info.
 */

.notif-it.is-high,   .notif-toast.is-high   { --n-c: var(--danger); --n-soft: var(--danger-soft); }
.notif-it.is-medium, .notif-toast.is-medium { --n-c: var(--warn);   --n-soft: var(--warn-soft); }
.notif-it.is-low,    .notif-toast.is-low    { --n-c: var(--info);   --n-soft: var(--info-soft); }

/* ── Badges in the menu ─────────────────────────────────────────────── */
#notif-nav-li > a { position: relative; }
.notif-badge {
	position: absolute;
	top: 8px;
	left: calc(100% - 45px);
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: var(--r-pill);
	background: var(--danger);
	color: #fff;
	font-size: .7rem;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	pointer-events: none;
}
.notif-badge--inline { position: static; display: inline-block; margin-left: 6px; }
.notif-badge[hidden] { display: none !important; }

/* ── One notification (widget, dropdown, page) ──────────────────────── */
.notif-it {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 12px 14px;
	color: var(--ink);
}
.notif-it + .notif-it { border-top: 1px solid var(--line); }

.notif-it__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--n-soft);
	color: var(--n-c);
	font-size: 16px;
}
.notif-it:not(.is-unread) .notif-it__icon { opacity: .55; }

.notif-it__main { flex: 1 1 auto; min-width: 0; }
.notif-it__top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.notif-it__tit { font-size: var(--fs-md); font-weight: 600; color: var(--ink-soft); overflow-wrap: anywhere; }
.notif-it.is-unread .notif-it__tit { font-weight: 800; color: var(--ink); }

.notif-it__new {
	padding: 1px 8px;
	border-radius: var(--r-pill);
	background: var(--brand-50);
	color: var(--brand-700);
	font-size: var(--fs-xs);
	font-weight: 800;
}

.notif-it__desc {
	margin: 3px 0 0;
	font-size: var(--fs-sm);
	line-height: 1.5;
	color: var(--ink-soft);
	white-space: pre-line;
	overflow-wrap: anywhere;
}
.notif-it.is-compact .notif-it__desc {
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
	white-space: normal;
}

.notif-it__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; }
.notif-it__time { font-size: var(--fs-xs); color: var(--ink-mute); font-variant-numeric: tabular-nums; }

.notif-it__accion,
.notif-it__leida {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	min-height: 30px;
	margin: 0;
	padding: 0 10px;
	border-radius: var(--r-sm);
	font-family: inherit;
	font-size: var(--fs-sm);
	font-weight: 700;
	text-decoration: none;
	cursor: pointer;
}
.notif-it__accion { border: 0; background: var(--brand-solid); color: #fff; }
.notif-it__accion:hover { background: var(--brand-hover); color: #fff; text-decoration: none; }
.notif-it__leida { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); }
.notif-it__leida:hover { border-color: var(--brand-300); background: var(--brand-50); color: var(--brand-700); }
.notif-it.is-compact .notif-it__leida { width: 30px; padding: 0; justify-content: center; margin-left: auto; }
.notif-it__accion:focus-visible,
.notif-it__leida:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Toasts (medium / low) ──────────────────────────────────────────── */
.notif-toasts {
	position: fixed;
	top: 16px;
	right: 16px;
	z-index: 10050;
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: min(380px, calc(100vw - 32px));
	pointer-events: none;
}
.notif-toasts > * { pointer-events: auto; }

.notif-toast {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 14px 40px 14px 14px;
	overflow: hidden;
	border: 1px solid var(--line-strong);
	border-left: 4px solid var(--n-c);
	border-radius: var(--r-md);
	background: var(--surface);
	box-shadow: var(--sh-3);
	color: var(--ink);
	animation: ui-slide-in-right var(--dur-3) var(--ease-out);
	transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.notif-toast.is-leaving { opacity: 0; transform: translateX(16px); }

.notif-toast__icon { flex: 0 0 auto; font-size: 20px; line-height: 1.2; color: var(--n-c); }
.notif-toast__body { flex: 1 1 auto; min-width: 0; }
.notif-toast__tit { display: block; font-size: var(--fs-md); font-weight: 800; overflow-wrap: anywhere; }
.notif-toast__desc {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin: 3px 0 0;
	font-size: var(--fs-sm);
	line-height: 1.45;
	color: var(--ink-soft);
	white-space: pre-line;
}
.notif-toast__acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; }
.notif-toast__accion {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	min-height: 32px;
	padding: 0 12px;
	border: 0;
	border-radius: var(--r-sm);
	background: var(--brand-solid);
	color: #fff;
	font-family: inherit;
	font-size: var(--fs-sm);
	font-weight: 700;
	text-decoration: none;
	cursor: pointer;
}
.notif-toast__accion:hover { background: var(--brand-hover); color: #fff; text-decoration: none; }
.notif-toast__ver { font-size: var(--fs-sm); font-weight: 700; color: var(--brand-600); }

.notif-toast__x {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 28px;
	height: 28px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--ink-mute);
	cursor: pointer;
}
.notif-toast__x:hover { background: var(--bg-sunken); color: var(--ink); }
.notif-toast__x:focus-visible,
.notif-toast__accion:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* low: time left before it leaves (pauses on hover/focus) */
.notif-toast__timer {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 3px;
	width: 100%;
	background: var(--n-c);
	opacity: .5;
	transform-origin: left;
	animation: notif-timer linear forwards;
}
@keyframes notif-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.notif-toasts__mas {
	align-self: flex-end;
	padding: 6px 12px;
	border-radius: var(--r-pill);
	background: var(--nav-900);
	color: #fff;
	font-size: var(--fs-sm);
	font-weight: 700;
	box-shadow: var(--sh-2);
}
.notif-toasts__mas:hover { color: #fff; background: var(--nav-800); text-decoration: none; }

/* high: Swal modal, accent on top */
.swal2-popup.notif-modal { border-top: 5px solid var(--danger); }

/* ── YouTube tutorials ──────────────────────────────────────────────── */
/* Action button of a video: the play icon tells it plays here */
.notif-it__accion.is-video .fa,
.notif-toast__accion.is-video .fa { font-size: 1.15em; }

/* Player dialog: 16:9, as wide as the screen allows */
.swal2-popup.notif-video-modal { padding: 16px 16px 12px; }
.swal2-popup.notif-video-modal .swal2-title { padding: 4px 36px 10px 4px; font-size: var(--fs-lg); text-align: left; }
.swal2-popup.notif-video-modal .swal2-html-container { margin: 0; padding: 0; overflow: visible; }
.notif-video {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	max-width: 100%;
	overflow: hidden;
	border-radius: var(--r-md);
	background: #000;
}
.notif-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.swal2-popup.notif-video-modal .swal2-footer { margin: 10px 0 0; padding: 10px 0 0; justify-content: flex-end; }
.notif-video__yt { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--brand-600); }
.notif-video__yt .fa { color: #e62117; font-size: 1.2em; }

/* Page: thumbnail with a play mark */
.notif-thumb {
	position: relative;
	display: block;
	width: 100%;
	max-width: 320px;
	aspect-ratio: 16 / 9;
	margin: 10px 0 2px;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: var(--r-md);
	background: var(--nav-900);
	cursor: pointer;
}
.notif-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-2) var(--ease-out); }
.notif-thumb:hover img { transform: scale(1.03); opacity: .9; }
.notif-thumb__play {
	position: absolute;
	top: 50%;
	left: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 40px;
	margin: -20px 0 0 -28px;
	border-radius: 12px;
	background: rgba(230, 33, 23, .92);
	color: #fff;
	font-size: 18px;
	box-shadow: var(--sh-2);
}
.notif-thumb:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Sound toggle ───────────────────────────────────────────────────── */
.notif-sonido {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 30px;
	margin: 0;
	padding: 0 10px;
	border: 1px solid var(--line-strong);
	border-radius: var(--r-pill);
	background: var(--surface);
	color: var(--ink-soft);
	font-family: inherit;
	font-size: var(--fs-xs);
	font-weight: 700;
	cursor: pointer;
}
.notif-sonido[aria-pressed="true"] { color: var(--brand-700); border-color: var(--brand-300); background: var(--brand-50); }
.notif-sonido:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Bell dropdown ──────────────────────────────────────────────────── */
.notif-pop {
	position: fixed;
	z-index: 10040;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--line-strong);
	border-radius: var(--r-lg);
	background: var(--surface);
	box-shadow: var(--sh-4);
	color: var(--ink);
	animation: ui-dropdown-in var(--dur-2) var(--ease-out);
}
.notif-pop__head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 12px 14px;
	border-bottom: 1px solid var(--line);
}
.notif-pop__title { font-size: var(--fs-md); font-weight: 800; }
.notif-pop__count { margin-right: auto; font-size: var(--fs-sm); color: var(--ink-mute); }
.notif-pop__todas {
	margin: 0;
	padding: 4px 8px;
	border: 0;
	border-radius: var(--r-sm);
	background: transparent;
	color: var(--brand-600);
	font-family: inherit;
	font-size: var(--fs-sm);
	font-weight: 700;
	cursor: pointer;
}
.notif-pop__todas:hover { background: var(--brand-50); }
.notif-pop__todas[hidden] { display: none; }
.notif-pop__list { flex: 1 1 auto; overflow-y: auto; }
.notif-pop__empty { padding: 24px 16px; text-align: center; color: var(--ink-mute); font-size: var(--fs-sm); }
.notif-pop__foot {
	display: block;
	padding: 11px 14px;
	border-top: 1px solid var(--line);
	background: var(--surface-alt);
	color: var(--brand-600);
	font-size: var(--fs-sm);
	font-weight: 700;
	text-align: center;
}
.notif-pop__foot:hover { background: var(--brand-50); text-decoration: none; }

/* ── Home widget ────────────────────────────────────────────────────── */
.notif-widget {
	margin: 0 0 18px;
	overflow: hidden;
	border: 1px solid var(--line-strong);
	border-radius: var(--r-lg);
	background: var(--surface);
	box-shadow: var(--sh-1);
}
.notif-widget__head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px 12px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}
.notif-widget__head h3 {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: var(--fs-lg);
	font-weight: 800;
	color: var(--ink);
	text-transform: none;
}
.notif-widget__head h3 .fa { color: var(--brand-500); }
.notif-widget__chip {
	padding: 2px 10px;
	border-radius: var(--r-pill);
	background: var(--danger-soft);
	color: var(--danger);
	font-size: var(--fs-xs);
	font-weight: 800;
}
.notif-widget__chip.is-zero { background: var(--ok-soft); color: var(--ok); }
.notif-widget__acts { display: flex; align-items: center; gap: 6px 14px; margin-left: auto; }
.notif-widget__todas {
	margin: 0;
	padding: 4px 8px;
	border: 0;
	border-radius: var(--r-sm);
	background: transparent;
	color: var(--brand-600);
	font-family: inherit;
	font-size: var(--fs-sm);
	font-weight: 700;
	cursor: pointer;
}
.notif-widget__todas:hover { background: var(--brand-50); }
.notif-widget__todas[hidden] { display: none; }
.notif-widget__ver { font-size: var(--fs-sm); font-weight: 700; color: var(--brand-600); white-space: nowrap; }
.notif-widget__list { max-height: 460px; overflow-y: auto; }
.notif-widget__empty { margin: 0; padding: 14px 16px; color: var(--ink-mute); font-size: var(--fs-sm); }
.notif-widget.is-empty .notif-widget__list { max-height: none; }

/* ── Page /admin/notificaciones ─────────────────────────────────────── */
.notif-page {
	max-width: 880px;
	margin: 24px auto 0;
	padding: 0 20px 60px;
	color: var(--ink);
}
.notif-page__head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px 14px;
	margin-bottom: 14px;
}
.notif-page__head h2 {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	font-size: var(--fs-xl);
	font-weight: 800;
	color: var(--ink);
}
.notif-page__head h2 .fa { color: var(--brand-500); }
.notif-page__resumen { font-size: var(--fs-sm); color: var(--ink-mute); }
.notif-page__acts { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.notif-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: var(--hit);
	margin: 0;
	padding: 0 16px;
	border: 0;
	border-radius: var(--r-sm);
	background: var(--brand-solid);
	color: #fff;
	font-family: inherit;
	font-size: var(--fs-md);
	font-weight: 700;
	cursor: pointer;
}
.notif-btn:hover:not(:disabled) { background: var(--brand-hover); }
.notif-btn:disabled { opacity: .45; cursor: default; }
.notif-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.notif-filtros { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.notif-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 34px;
	margin: 0;
	padding: 0 12px;
	border: 1px solid var(--line-strong);
	border-radius: var(--r-pill);
	background: var(--surface);
	color: var(--ink-soft);
	font-family: inherit;
	font-size: var(--fs-sm);
	font-weight: 700;
	cursor: pointer;
}
.notif-chip:hover { border-color: var(--brand-300); background: var(--brand-50); }
.notif-chip.is-active { border-color: var(--brand-600); background: var(--brand-solid); color: #fff; }
.notif-chip__n {
	min-width: 20px;
	padding: 0 6px;
	border-radius: var(--r-pill);
	background: var(--bg-sunken);
	color: var(--ink-soft);
	font-size: var(--fs-xs);
	font-variant-numeric: tabular-nums;
	text-align: center;
}
.notif-chip.is-active .notif-chip__n { background: rgba(255, 255, 255, .22); color: #fff; }
.notif-chip.is-high::before,
.notif-chip.is-medium::before,
.notif-chip.is-low::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.notif-chip.is-high::before   { background: var(--danger); }
.notif-chip.is-medium::before { background: var(--warn); }
.notif-chip.is-low::before    { background: var(--info); }
.notif-chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.notif-page__lista { display: flex; flex-direction: column; gap: 10px; }
.notif-page.is-loading .notif-page__lista { opacity: .6; }

.notif-grupo {
	margin: 10px 0 0;
	font-size: var(--fs-xs);
	font-weight: 800;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--ink-mute);
}
.notif-grupo:first-child { margin-top: 0; }

.notif-page__lista .notif-it {
	padding: 14px 16px;
	border: 1px solid var(--line-strong);
	border-left: 4px solid var(--n-c);
	border-radius: var(--r-md);
	background: var(--surface);
	box-shadow: var(--sh-1);
}
.notif-page__lista .notif-it + .notif-it { border-top: 1px solid var(--line-strong); }
.notif-page__lista .notif-it:not(.is-unread) { background: var(--surface-alt); box-shadow: none; }

.notif-vacio {
	padding: 48px 20px;
	border: 1px dashed var(--line-strong);
	border-radius: var(--r-lg);
	color: var(--ink-mute);
	text-align: center;
}

.notif-mas {
	width: 100%;
	margin-top: 12px;
	padding: 11px;
	border: 1px solid var(--line-strong);
	border-radius: var(--r-md);
	background: var(--surface);
	color: var(--brand-600);
	font-family: inherit;
	font-size: var(--fs-md);
	font-weight: 700;
	cursor: pointer;
}
.notif-mas:hover:not(:disabled) { border-color: var(--brand-300); background: var(--brand-50); }
.notif-mas[hidden] { display: none; }

@media (max-width: 768px) {
	.notif-toasts { top: 10px; right: 10px; left: 10px; width: auto; }
	.notif-page { margin-top: 12px; padding: 0 12px 80px; }
	.notif-page__acts { width: 100%; margin-left: 0; justify-content: space-between; }
	.notif-page__acts .notif-btn { flex: 1 1 auto; justify-content: center; }
	.notif-it { padding: 12px; gap: 10px; }
	.notif-it__icon { width: 30px; height: 30px; font-size: 14px; }
	.notif-widget__acts { width: 100%; margin-left: 0; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
	.notif-toast, .notif-pop { animation: none; }
	.notif-toast { transition: none; }
	.notif-toast__timer { animation: none; opacity: 0; }
	.notif-thumb img { transition: none; }
}
