/* ─── AI Knowledge Chatbot ─────────────────────────────────────────────────
 * Wszystkie kolory i wymiary pochodzą ze zmiennych CSS generowanych
 * z ustawień wtyczki (AKC_Frontend::css_variables). Wartości poniżej
 * to jedynie zabezpieczenie na wypadek ich braku.
 * ──────────────────────────────────────────────────────────────────────── */

.akc-root {
	--akc-primary: #2457c5;
	--akc-primary-hover: #1d469e;
	--akc-primary-soft: #e9eef9;
	--akc-primary-ring: rgba(36, 87, 197, .35);
	--akc-primary-shadow: rgba(36, 87, 197, .28);
	--akc-on-primary: #fff;
	--akc-accent: #f2b134;
	--akc-on-accent: #141a24;
	--akc-bg: #fff;
	--akc-text: #141a24;
	--akc-muted: #7b808a;
	--akc-line: #e3e5e9;
	--akc-bot-bg: #eef1f6;
	--akc-bot-text: #1b2230;
	--akc-font: inherit;
	--akc-font-size: 14px;
	--akc-radius: 16px;
	--akc-width: 380px;
	--akc-height: 560px;
	--akc-offset-x: 24px;
	--akc-offset-y: 24px;
	--akc-z: 9999;

	--akc-r-sm: calc(var(--akc-radius) * .5);
	--akc-r-bubble: calc(var(--akc-radius) * .9);
	font-family: var(--akc-font);
	font-size: var(--akc-font-size);
	line-height: 1.55;
	color: var(--akc-text);
}

.akc-root *,
.akc-root *::before,
.akc-root *::after {
	box-sizing: border-box;
}

.akc-root button {
	font: inherit;
	margin: 0;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
}

.akc-root [hidden] {
	display: none !important;
}

/* ─── Przycisk otwierający ─────────────────────────────────────────────── */
.akc-launcher {
	position: fixed;
	bottom: var(--akc-offset-y);
	right: var(--akc-offset-x);
	z-index: var(--akc-z);
	width: 60px;
	height: 60px;
	padding: 0;
	border: 0;
	border-radius: calc(var(--akc-radius) + 6px);
	background: var(--akc-primary);
	color: var(--akc-on-primary);
	cursor: pointer;
	display: grid;
	place-items: center;
	box-shadow: 0 10px 28px -6px var(--akc-primary-shadow), 0 2px 6px rgba(0, 0, 0, .12);
	transition: transform .18s ease, background-color .18s ease, border-radius .25s ease;
}

.akc-pos-left .akc-launcher {
	right: auto;
	left: var(--akc-offset-x);
}

.akc-launcher:hover {
	background: var(--akc-primary-hover);
	transform: translateY(-2px);
}

.akc-launcher:focus-visible {
	outline: 3px solid var(--akc-primary-ring);
	outline-offset: 3px;
}

.akc-launcher > span {
	grid-area: 1 / 1;
	display: grid;
	place-items: center;
	transition: opacity .18s ease, transform .22s ease;
}

.akc-launcher-glyph {
	font-size: 26px;
	line-height: 1;
}

.akc-launcher .akc-img {
	width: 34px;
	height: 34px;
	object-fit: contain;
	border-radius: 6px;
}

.akc-launcher-close {
	opacity: 0;
	transform: rotate(-45deg) scale(.6);
}

.akc-is-open .akc-launcher {
	border-radius: 50%;
}

.akc-is-open .akc-launcher-open {
	opacity: 0;
	transform: scale(.6);
}

.akc-is-open .akc-launcher-close {
	opacity: 1;
	transform: none;
}

.akc-badge {
	position: absolute;
	top: -8px;
	right: -6px;
	padding: 3px 8px;
	border-radius: 999px;
	background: var(--akc-accent);
	color: var(--akc-on-accent);
	font-size: 11px;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}

.akc-pos-left .akc-badge {
	right: auto;
	left: -6px;
}

.akc-is-open .akc-badge {
	display: none;
}

/* ─── Okno ─────────────────────────────────────────────────────────────── */
.akc-window {
	display: flex;
	flex-direction: column;
	width: var(--akc-width);
	max-width: calc(100vw - 24px);
	height: min(var(--akc-height), calc(100vh - 120px));
	background: var(--akc-bg);
	border: 1px solid var(--akc-line);
	border-radius: var(--akc-radius);
	overflow: hidden;
	box-shadow: 0 24px 60px -20px rgba(15, 20, 30, .35), 0 4px 14px rgba(15, 20, 30, .08);
}

.akc-floating .akc-window {
	position: fixed;
	right: var(--akc-offset-x);
	bottom: calc(var(--akc-offset-y) + 76px);
	z-index: var(--akc-z);
	visibility: hidden;
	opacity: 0;
	transform: translateY(12px);
	transform-origin: bottom right;
	transition: opacity .2s ease, transform .22s ease, visibility 0s linear .22s;
}

.akc-pos-left.akc-floating .akc-window {
	right: auto;
	left: var(--akc-offset-x);
	transform-origin: bottom left;
}

.akc-floating.akc-is-open .akc-window {
	visibility: visible;
	opacity: 1;
	transform: none;
	transition: opacity .2s ease, transform .22s ease, visibility 0s;
}

.akc-inline .akc-window {
	width: 100%;
	max-width: 100%;
	height: var(--akc-height);
	box-shadow: none;
}

/* ─── Nagłówek ─────────────────────────────────────────────────────────── */
.akc-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 14px 14px 16px;
	background: var(--akc-primary);
	color: var(--akc-on-primary);
	flex-shrink: 0;
}

.akc-head-avatar {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	border-radius: var(--akc-r-sm);
	display: grid;
	place-items: center;
	background: color-mix(in srgb, var(--akc-on-primary) 16%, transparent);
	overflow: hidden;
}

.akc-avatar-glyph {
	font-size: 20px;
	line-height: 1;
}

.akc-head-avatar .akc-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	background: #fff;
}

.akc-head-text {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.akc-title {
	font-size: 1.07em;
	font-weight: 700;
	line-height: 1.25;
}

.akc-subtitle {
	font-size: .82em;
	opacity: .82;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.akc-head-actions {
	display: flex;
	gap: 4px;
}

.akc-icon-btn {
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
	display: grid;
	place-items: center;
	opacity: .85;
	transition: background-color .15s ease, opacity .15s ease;
}

.akc-icon-btn:hover {
	opacity: 1;
	background: color-mix(in srgb, var(--akc-on-primary) 16%, transparent);
}

.akc-icon-btn:focus-visible {
	outline: 2px solid var(--akc-on-primary);
	outline-offset: 1px;
}

/* ─── Wiadomości ───────────────────────────────────────────────────────── */
.akc-log {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 16px 8px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scrollbar-width: thin;
	scrollbar-color: var(--akc-line) transparent;
}

.akc-msg {
	display: flex;
	max-width: 100%;
}

.akc-msg-user {
	justify-content: flex-end;
}

.akc-bubble {
	max-width: 86%;
	padding: 10px 14px;
	border-radius: var(--akc-r-bubble);
	overflow-wrap: anywhere;
}

.akc-msg-bot .akc-bubble {
	background: var(--akc-bot-bg);
	color: var(--akc-bot-text);
	border-bottom-left-radius: 4px;
}

.akc-msg-user .akc-bubble {
	background: var(--akc-primary);
	color: var(--akc-on-primary);
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}

.akc-bubble p {
	margin: 0 0 .55em;
}

.akc-bubble p:last-child,
.akc-bubble ul:last-child,
.akc-bubble ol:last-child {
	margin-bottom: 0;
}

.akc-bubble ul,
.akc-bubble ol {
	margin: .2em 0 .6em;
	padding-left: 1.25em;
}

.akc-bubble li {
	margin: 0 0 .25em;
}

.akc-bubble strong {
	font-weight: 700;
}

.akc-bubble a {
	color: var(--akc-primary);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.akc-msg-user .akc-bubble a {
	color: inherit;
}

.akc-bubble code {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: .88em;
	padding: 1px 5px;
	border-radius: 4px;
	background: rgba(0, 0, 0, .06);
}

.akc-error .akc-bubble {
	background: #fdf0ef;
	color: #9b2c22;
	box-shadow: inset 0 0 0 1px #f3cfcb;
}

/* Wskaźnik pisania */
.akc-typing {
	display: inline-flex;
	gap: 5px;
	align-items: center;
	padding: 14px 16px;
}

.akc-typing i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	opacity: .35;
	animation: akc-pulse 1.1s infinite ease-in-out;
}

.akc-typing i:nth-child(2) { animation-delay: .15s; }
.akc-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes akc-pulse {
	0%, 70%, 100% { opacity: .25; transform: translateY(0); }
	35% { opacity: .9; transform: translateY(-3px); }
}

/* ─── Szybkie odpowiedzi ──────────────────────────────────────────────── */
.akc-quick {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 4px 16px 12px;
	flex-shrink: 0;
}

.akc-chip {
	padding: 6px 12px;
	border: 1px solid var(--akc-primary);
	border-radius: 999px;
	background: var(--akc-bg);
	color: var(--akc-primary);
	font-size: .9em;
	font-weight: 600;
	line-height: 1.3;
	cursor: pointer;
	text-align: left;
	transition: background-color .15s ease, color .15s ease;
}

.akc-chip:hover {
	background: var(--akc-primary-soft);
}

.akc-chip:focus-visible {
	outline: 2px solid var(--akc-primary-ring);
	outline-offset: 2px;
}

/* ─── Pole wiadomości ─────────────────────────────────────────────────── */
.akc-compose {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--akc-line);
	flex-shrink: 0;
}

.akc-field {
	position: relative;
	flex: 1;
	min-width: 0;
}

.akc-root .akc-input {
	display: block;
	width: 100%;
	min-height: 42px;
	max-height: 120px;
	margin: 0;
	padding: 10px 14px;
	border: 1px solid var(--akc-line);
	border-radius: calc(var(--akc-r-sm) + 4px);
	background: var(--akc-bg);
	color: var(--akc-text);
	font: inherit;
	line-height: 1.45;
	resize: none;
	box-shadow: none;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.akc-root .akc-input:focus {
	outline: none;
	border-color: var(--akc-primary);
	box-shadow: 0 0 0 3px var(--akc-primary-ring);
}

.akc-root .akc-input::placeholder {
	color: var(--akc-muted);
	opacity: 1;
}

.akc-counter {
	position: absolute;
	right: 10px;
	bottom: 4px;
	font-size: 10px;
	color: var(--akc-muted);
	pointer-events: none;
}

.akc-send {
	flex-shrink: 0;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: calc(var(--akc-r-sm) + 4px);
	background: var(--akc-primary);
	color: var(--akc-on-primary);
	cursor: pointer;
	display: grid;
	place-items: center;
	transition: background-color .15s ease, opacity .15s ease;
}

.akc-send:hover {
	background: var(--akc-primary-hover);
}

.akc-send:focus-visible {
	outline: 3px solid var(--akc-primary-ring);
	outline-offset: 2px;
}

.akc-send:disabled {
	opacity: .45;
	cursor: progress;
}

/* ─── Stopka ──────────────────────────────────────────────────────────── */
.akc-foot {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 4px 12px;
	padding: 0 14px 10px;
	font-size: .76em;
	color: var(--akc-muted);
	flex-shrink: 0;
}

.akc-privacy {
	flex-basis: 100%;
	opacity: .8;
}

.akc-cta {
	margin-left: auto;
	color: var(--akc-primary);
	font-weight: 700;
	text-decoration: none;
}

.akc-cta:hover {
	text-decoration: underline;
}

/* ─── Mobile ──────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
	.akc-floating .akc-window,
	.akc-pos-left.akc-floating .akc-window {
		left: 8px;
		right: 8px;
		bottom: calc(var(--akc-offset-y) + 72px);
		width: auto;
		max-width: none;
		height: calc(100vh - var(--akc-offset-y) - 90px);
		height: calc(100dvh - var(--akc-offset-y) - 90px);
	}

	.akc-root .akc-input {
		font-size: 16px; /* brak auto-zoomu w iOS */
	}
}

@media (prefers-reduced-motion: reduce) {
	.akc-root *,
	.akc-root *::before,
	.akc-root *::after {
		transition-duration: 0s !important;
		animation-duration: 0s !important;
	}
}

@media print {
	.akc-floating {
		display: none !important;
	}
}

/* ─── Podgląd w panelu ────────────────────────────────────────────────── */
.akc-preview .akc-window {
	position: relative;
	height: auto;
	max-height: none;
	visibility: visible;
	opacity: 1;
	transform: none;
}

.akc-preview .akc-log {
	overflow: visible;
}

.akc-preview .akc-launcher {
	position: relative;
	right: auto;
	bottom: auto;
	left: auto;
	margin-top: 16px;
	margin-left: auto;
}
