/* RSD Chat — widget gościa. Paleta spójna z aplikacją Flutter. */
.rsd-chat {
	--rsd-primary: #2e4738;
	--rsd-navy: #1b2633;
	--rsd-cta: #d96b27;
	--rsd-parchment: #f4f1e8;
	--rsd-muted: #70757d;
	--rsd-border: #d9d9d4;
	box-sizing: border-box;
}

.rsd-chat *,
.rsd-chat *::before,
.rsd-chat *::after {
	box-sizing: border-box;
}

/* ── Pływający wariant ─────────────────────────────────────────────────── */
.rsd-chat--floating {
	position: fixed;
	right: 16px;
	right: max(16px, env(safe-area-inset-right));
	bottom: 16px;
	bottom: max(16px, env(safe-area-inset-bottom));
	z-index: 99999;
}

.rsd-chat__launcher {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	background: var(--rsd-cta);
	color: #fff;
	font-size: 24px;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
}

.rsd-chat--floating .rsd-chat__panel {
	position: absolute;
	right: 0;
	bottom: 70px;
	width: 340px;
	max-width: calc(100vw - 40px);
	height: 460px;
	max-height: calc(100vh - 120px);
	display: none;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.rsd-chat--floating.is-open .rsd-chat__panel {
	display: flex;
}

/* ── Wspólny panel ─────────────────────────────────────────────────────── */
.rsd-chat__panel {
	display: flex;
	flex-direction: column;
	background: var(--rsd-navy);
	border: 1px solid var(--rsd-border);
	border-radius: 14px;
	overflow: hidden;
	font-family: inherit;
}

.rsd-chat--inline .rsd-chat__panel {
	width: 100%;
	max-width: 420px;
	height: 480px;
	margin: 0 auto;
}

.rsd-chat__header {
	background: var(--rsd-primary);
	color: #fff;
	padding: 12px 14px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.rsd-chat__title {
	font-weight: 600;
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.rsd-chat__close {
	background: none;
	border: none;
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
}

.rsd-chat__toolbar {
	display: flex;
	gap: 8px;
	padding: 8px 12px;
	background: rgba(0, 0, 0, 0.18);
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rsd-chat__action {
	background: rgba(255, 255, 255, 0.15);
	border: none;
	color: #fff;
	font-size: 13px;
	line-height: 1;
	cursor: pointer;
	padding: 8px 12px;
	border-radius: 14px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Przycisk imienia rośnie i przycina długą wartość, reszta ma stałą szerokość. */
.rsd-chat__action--name {
	flex: 1;
	text-align: left;
}

.rsd-chat__msg {
	position: relative;
}

.rsd-chat__msg-del {
	position: absolute;
	top: -6px;
	right: -6px;
	width: 18px;
	height: 18px;
	border: none;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	font-size: 12px;
	line-height: 1;
	cursor: pointer;
	display: none;
}

.rsd-chat__msg.is-mine:hover .rsd-chat__msg-del {
	display: block;
}

.rsd-chat__messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.rsd-chat__msg {
	max-width: 80%;
	padding: 8px 12px;
	border-radius: 12px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	color: #fff;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.rsd-chat__msg.is-mine {
	align-self: flex-end;
	background: var(--rsd-cta);
}

.rsd-chat__msg.is-them {
	align-self: flex-start;
	background: var(--rsd-primary);
}

.rsd-chat__author {
	font-size: 11px;
	font-weight: 600;
	opacity: 0.8;
}

.rsd-chat__body {
	white-space: pre-wrap;
}

.rsd-chat__form {
	display: flex;
	gap: 8px;
	padding: 8px;
	background: var(--rsd-navy);
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.rsd-chat__input {
	flex: 1;
	resize: none;
	border-radius: 18px;
	border: none;
	padding: 10px 14px;
	background: var(--rsd-primary);
	color: #fff;
	font-family: inherit;
	/* 16px zapobiega automatycznemu przybliżaniu strony na iOS przy fokusie. */
	font-size: 16px;
	max-height: 96px;
}

.rsd-chat__input::placeholder {
	color: var(--rsd-muted);
}

.rsd-chat__send {
	border: none;
	border-radius: 18px;
	padding: 0 16px;
	background: var(--rsd-cta);
	color: #fff;
	cursor: pointer;
	font-weight: 600;
}

.rsd-chat__send:disabled {
	opacity: 0.6;
	cursor: default;
}

/* ── Mobile: czat na pełnym ekranie ──────────────────────────────────────── */
@media (max-width: 600px) {
	.rsd-chat--floating.is-open .rsd-chat__panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: 100%;
		height: 100vh;
		height: 100dvh;
		max-height: none;
		border-radius: 0;
		box-shadow: none;
	}

	/* Launcher chowamy, gdy czat zajmuje cały ekran. */
	.rsd-chat--floating.is-open .rsd-chat__launcher {
		display: none;
	}

	/* Marginesy bezpieczne: notch u góry, pasek gestów u dołu. */
	.rsd-chat--floating.is-open .rsd-chat__header {
		padding-top: max(12px, env(safe-area-inset-top));
	}

	.rsd-chat--floating.is-open .rsd-chat__form {
		padding-bottom: max(8px, env(safe-area-inset-bottom));
	}

	/* Większe, wygodniejsze elementy dotykowe. */
	.rsd-chat__header {
		padding: 14px 16px;
	}

	.rsd-chat__title {
		font-size: 17px;
	}

	.rsd-chat__close {
		font-size: 26px;
		padding: 0 8px;
	}

	.rsd-chat__msg {
		max-width: 85%;
	}

	.rsd-chat__send {
		padding: 0 20px;
	}

	/* Wariant inline (shortcode/blok) — pełna szerożność, wyższy. */
	.rsd-chat--inline .rsd-chat__panel {
		max-width: 100%;
		height: 70vh;
	}
}
