/**
 * Panel de notificaciones push (shortcode, Mi cuenta y wp-admin).
 *
 * Aislamiento: todo cuelga de `.sims-push` y usa tokens propios, de modo que
 * ni el tema de la tienda ni los estilos de wp-admin alteren el panel. Sin
 * dependencias externas (CLAUDE.md: nada de CDNs en el plugin).
 */

.sims-push {
	--sp-primary: #0a7a4b;
	--sp-primary-ink: #ffffff;
	--sp-surface: #ffffff;
	--sp-surface-alt: #f6f7f9;
	--sp-border: #e3e6ea;
	--sp-text: #151515;
	--sp-muted: #6b7280;
	--sp-danger: #b3261e;
	--sp-warning: #b45309;
	--sp-success: #0a7a4b;
	--sp-radius: 14px;
	--sp-gap: 20px;
	--sp-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);

	box-sizing: border-box;
	max-width: 1080px;
	margin: 0 auto;
	padding: 0;
	color: var(--sp-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	text-align: left;
}

.sims-push *,
.sims-push *::before,
.sims-push *::after {
	box-sizing: border-box;
}

/* ---------- Encabezado ---------- */

.sims-push__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--sp-gap);
	margin-bottom: 16px;
}

.sims-push__title {
	margin: 0 0 4px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--sp-text);
}

.sims-push__subtitle {
	margin: 0;
	color: var(--sp-muted);
	font-size: 14px;
}

/* ---------- Cuota ---------- */

.sims-push__quota {
	padding: 16px 18px;
	margin-bottom: var(--sp-gap);
	background: var(--sp-surface);
	border: 1px solid var(--sp-border);
	border-radius: var(--sp-radius);
	box-shadow: var(--sp-shadow);
}

.sims-push__quota-row {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 10px;
}

.sims-push__quota-label {
	font-size: 15px;
}

.sims-push__quota-label strong {
	font-size: 20px;
	font-weight: 700;
	color: var(--sp-primary);
}

.sims-push__quota--low .sims-push__quota-label strong {
	color: var(--sp-warning);
}

.sims-push__quota--empty .sims-push__quota-label strong {
	color: var(--sp-danger);
}

.sims-push__quota-reset {
	color: var(--sp-muted);
	font-size: 13px;
}

/* Alcance real: a cuántos dispositivos llega el push y cuántos quedaron
   solo con el aviso in-app (sin permiso o con la app desinstalada). */
.sims-push__audience {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: -4px 0 16px;
}

.sims-push__audience-main {
	font-size: 14px;
}

.sims-push__audience-main strong {
	font-weight: 700;
	color: var(--sp-primary);
}

.sims-push__audience-note {
	color: var(--sp-muted);
	font-size: 13px;
	line-height: 1.4;
}

.sims-push__bar {
	position: relative;
	height: 10px;
	overflow: hidden;
	background: var(--sp-surface-alt);
	border-radius: 999px;
}

.sims-push__bar-fill {
	display: block;
	height: 100%;
	width: 0;
	background: var(--sp-primary);
	border-radius: 999px;
	transition: width .3s ease;
}

.sims-push__quota--low .sims-push__bar-fill {
	background: var(--sp-warning);
}

.sims-push__quota--empty .sims-push__bar-fill {
	background: var(--sp-danger);
}

/* ---------- Rejilla formulario / vista previa ---------- */

.sims-push__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 300px;
	gap: var(--sp-gap);
	align-items: start;
}

.sims-push__form {
	padding: 20px;
	background: var(--sp-surface);
	border: 1px solid var(--sp-border);
	border-radius: var(--sp-radius);
	box-shadow: var(--sp-shadow);
}

.sims-push__field {
	position: relative;
	margin-bottom: 18px;
}

.sims-push__label {
	display: block;
	margin-bottom: 6px;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: .01em;
	color: var(--sp-text);
}

.sims-push__optional {
	margin-left: 6px;
	font-weight: 400;
	color: var(--sp-muted);
	text-transform: lowercase;
}

.sims-push__input {
	display: block;
	width: 100%;
	padding: 11px 13px;
	font: inherit;
	color: var(--sp-text);
	background: var(--sp-surface);
	border: 1px solid var(--sp-border);
	border-radius: 10px;
	outline: none;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.sims-push__input::placeholder {
	color: #9aa1ab;
}

.sims-push__input:focus {
	border-color: var(--sp-primary);
	box-shadow: 0 0 0 3px rgba(10, 122, 75, .16);
}

.sims-push__textarea {
	min-height: 84px;
	resize: vertical;
}

.sims-push__counter {
	position: absolute;
	top: 0;
	right: 0;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	color: var(--sp-muted);
}

.sims-push__counter--limit {
	color: var(--sp-warning);
	font-weight: 600;
}

.sims-push__hint {
	display: block;
	margin-top: 6px;
	font-size: 12px;
	color: var(--sp-muted);
}

.sims-push__inline {
	display: flex;
	gap: 8px;
	align-items: stretch;
}

.sims-push__inline .sims-push__input {
	flex: 1 1 auto;
	min-width: 0;
}

/* ---------- Botones ---------- */

.sims-push__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 20px;
	font: inherit;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	border: 1px solid transparent;
	border-radius: 10px;
	cursor: pointer;
	transition: filter .15s ease, opacity .15s ease;
}

.sims-push__btn--primary {
	width: 100%;
	padding: 14px 20px;
	font-size: 15px;
	color: var(--sp-primary-ink);
	background: var(--sp-primary);
}

.sims-push__btn--primary:hover:not(:disabled) {
	filter: brightness(1.08);
}

.sims-push__btn--ghost {
	color: var(--sp-text);
	background: var(--sp-surface-alt);
	border-color: var(--sp-border);
}

.sims-push__btn--ghost:hover {
	filter: brightness(.97);
}

.sims-push__btn:disabled {
	opacity: .55;
	cursor: not-allowed;
}

.sims-push__btn:focus-visible {
	outline: 2px solid var(--sp-primary);
	outline-offset: 2px;
}

/* Spinner: solo visible mientras el formulario está en vuelo. */

.sims-push__spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, .45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: sims-push-spin .7s linear infinite;
}

.sims-push__form.is-sending .sims-push__spinner {
	display: inline-block;
}

@keyframes sims-push-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.sims-push__spinner {
		animation-duration: 2s;
	}

	.sims-push__bar-fill {
		transition: none;
	}
}

/* ---------- Feedback ---------- */

.sims-push__feedback {
	display: none;
	margin: 0 0 14px;
	padding: 11px 13px;
	font-size: 14px;
	border-radius: 10px;
}

.sims-push__feedback.is-visible {
	display: block;
}

.sims-push__feedback.is-error {
	color: var(--sp-danger);
	background: #fdecea;
	border: 1px solid #f5c6c2;
}

.sims-push__feedback.is-success {
	color: var(--sp-success);
	background: #e7f5ee;
	border: 1px solid #b7e0cb;
}

/* ---------- Vista previa (teléfono) ---------- */

.sims-push__preview {
	position: sticky;
	top: 24px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.sims-push__preview-caption {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--sp-muted);
}

.sims-push__phone {
	position: relative;
	width: 260px;
	max-width: 100%;
	padding: 12px;
	background: #101418;
	border: 2px solid #23282e;
	border-radius: 34px;
	box-shadow: 0 12px 32px rgba(16, 24, 40, .22);
}

.sims-push__phone-notch {
	position: absolute;
	top: 12px;
	left: 50%;
	width: 82px;
	height: 18px;
	background: #101418;
	border-radius: 0 0 12px 12px;
	transform: translateX(-50%);
	z-index: 2;
}

.sims-push__phone-screen {
	min-height: 300px;
	padding: 34px 10px 16px;
	/* Fondo tipo pantalla de bloqueo, sin imágenes externas. */
	background: linear-gradient(160deg, #2b5876 0%, #4e4376 55%, #6b4b8a 100%);
	border-radius: 24px;
}

.sims-push__phone-clock {
	margin-bottom: 18px;
	color: #fff;
	text-align: center;
	text-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.sims-push__phone-time {
	display: block;
	font-size: 40px;
	font-weight: 300;
	line-height: 1.1;
}

.sims-push__phone-date {
	display: block;
	font-size: 12px;
	opacity: .9;
}

.sims-push__notif {
	padding: 11px 12px;
	color: #111;
	background: rgba(255, 255, 255, .92);
	border-radius: 16px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
	backdrop-filter: blur(6px);
}

.sims-push__notif-head {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 5px;
	font-size: 11px;
	color: #4b5563;
}

.sims-push__notif-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	font-size: 10px;
	font-weight: 700;
	color: #fff;
	background: var(--sp-primary);
	border-radius: 4px;
}

.sims-push__notif-app {
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .03em;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.sims-push__notif-time {
	margin-left: auto;
	white-space: nowrap;
}

.sims-push__notif-title,
.sims-push__notif-body {
	margin: 0;
	/* Texto largo no debe romper el marco del teléfono. */
	overflow-wrap: anywhere;
}

.sims-push__notif-title {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
}

.sims-push__notif-body {
	margin-top: 2px;
	font-size: 13px;
	line-height: 1.35;
	color: #374151;
	/* Igual que el sistema: recorta a 3 líneas. */
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.sims-push__notif-title.is-placeholder,
.sims-push__notif-body.is-placeholder {
	color: #9ca3af;
	font-style: italic;
}

.sims-push__notif-image {
	display: block;
	width: 100%;
	max-height: 130px;
	margin-top: 9px;
	object-fit: cover;
	border-radius: 10px;
}

.sims-push__notif-image[hidden] {
	display: none;
}

/* ---------- Historial ---------- */

.sims-push__history {
	margin-top: var(--sp-gap);
	padding: 18px 20px;
	background: var(--sp-surface);
	border: 1px solid var(--sp-border);
	border-radius: var(--sp-radius);
	box-shadow: var(--sp-shadow);
}

.sims-push__history-title {
	margin: 0 0 12px;
	font-size: 15px;
	font-weight: 700;
}

.sims-push__history-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.sims-push__history-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 0;
	border-top: 1px solid var(--sp-border);
}

.sims-push__history-item:first-child {
	border-top: 0;
}

.sims-push__history-name {
	flex: 1 1 auto;
	min-width: 0;
	font-weight: 600;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.sims-push__history-date {
	flex: 0 0 auto;
	font-size: 12px;
	color: var(--sp-muted);
	font-variant-numeric: tabular-nums;
}

.sims-push__badge {
	flex: 0 0 auto;
	padding: 3px 9px;
	font-size: 11px;
	font-weight: 600;
	border-radius: 999px;
}

.sims-push__badge--sent {
	color: #05603a;
	background: #d1fae5;
}

.sims-push__badge--failed {
	color: #912018;
	background: #fee4e2;
}

.sims-push__badge--partial {
	color: #93370d;
	background: #fef0c7;
}

.sims-push__empty {
	margin: 0;
	padding: 8px 0;
	color: var(--sp-muted);
	font-size: 14px;
}

/* ---------- Acceso denegado ---------- */

.sims-push--denied {
	display: flex;
	justify-content: center;
	padding: 24px 0;
}

.sims-push__denied-card {
	max-width: 420px;
	padding: 32px 28px;
	text-align: center;
	background: var(--sp-surface);
	border: 1px solid var(--sp-border);
	border-radius: var(--sp-radius);
	box-shadow: var(--sp-shadow);
}

.sims-push__denied-icon {
	display: block;
	margin-bottom: 12px;
	font-size: 34px;
	line-height: 1;
}

.sims-push__denied-title {
	margin: 0 0 8px;
	font-size: 19px;
	font-weight: 700;
}

.sims-push__denied-text {
	margin: 0 0 18px;
	color: var(--sp-muted);
	font-size: 14px;
}

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

@media (max-width: 860px) {
	.sims-push__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.sims-push__preview {
		position: static;
		order: -1;
	}
}

@media (max-width: 480px) {
	.sims-push__form,
	.sims-push__history {
		padding: 16px 14px;
	}

	.sims-push__inline {
		flex-direction: column;
	}

	.sims-push__history-item {
		flex-wrap: wrap;
	}

	.sims-push__history-name {
		flex-basis: 100%;
	}
}

/* ---------- Modo oscuro ---------- */

@media (prefers-color-scheme: dark) {
	.sims-push {
		--sp-surface: #16191d;
		--sp-surface-alt: #21252b;
		--sp-border: #2e343b;
		--sp-text: #e7e9ec;
		--sp-muted: #9aa3ae;
		--sp-shadow: 0 1px 2px rgba(0, 0, 0, .4);
	}

	.sims-push__feedback.is-error {
		background: #2c1614;
		border-color: #5c2b26;
		color: #f5a9a2;
	}

	.sims-push__feedback.is-success {
		background: #10261d;
		border-color: #1f4a37;
		color: #7ddcae;
	}
}

/* wp-admin ya impone su propio fondo claro: el panel no debe invertirse ahí. */
.wp-admin .sims-push {
	--sp-surface: #ffffff;
	--sp-surface-alt: #f6f7f9;
	--sp-border: #dcdcde;
	--sp-text: #1d2327;
	--sp-muted: #646970;
	max-width: none;
}
