/**
 * AI Concierge — styl w 100% na zmiennych motywu (--apl-*). Żaden kolor nie
 * jest zaszyty na sztywno, więc panel dopasowuje się automatycznie do
 * kolorystyki i trybu jasny/ciemny KAŻDEJ z 9 instalacji [Branża]Tu.pl bez
 * jednej linijki zmian.
 *
 * [Faza B.2, 2026-09-15] Wizualny przeprojekt — poprzednia wersja (Faza A/B)
 * była funkcjonalnie kompletna, ale stylistycznie nieodróżnialna od
 * dowolnego gotowego widgetu czatu (płaski nagłówek, generyczna ikona
 * dymka, płaskie karty-linki). Ten plik dodaje spójny "znak firmowy"
 * asystenta (awatar-iskra, gradientowy nagłówek, mikro-animacje wejścia),
 * bez zmiany ani jednego mechanizmu z Fazy A/B/B.1 — tylko warstwa wizualna,
 * nadal w 100% oparta o var(--apl-*), więc przenosi się bez zmian na
 * pozostałe 8 stron sieci.
 *
 * @package AddiListo
 */

.apx-launcher-item.apx-concierge-item .apx-launcher-ico {
	color: var(--apl-primary, #4f46e5);
}

/**
 * BAZOWY STYL PŁYWAJĄCEGO PRZYCISKU (#apx-launcher / #apx-launcher-btn).
 *
 * [Hotfix 1, 2026-09-15] Na żywej stronie DekarzTU.pl zdiagnozowałem, że w tej
 * chwili ŻADEN inny moduł AddiPress Pro (ani „Dodaj ogłoszenie", ani kalkulator
 * płac) nie renderuje swojego przycisku #apx-launcher na tej stronie — a to
 * właśnie ich własny, wbudowany <style> nadawał mu do tej pory fixed position,
 * rozmiar, kolor i cień. Poniższe reguły czynią asystenta w pełni samodzielnym.
 *
 * [Faza B.2] Przycisk dostał subtelny, stały pierścień pulsu (przyciąga wzrok
 * bez krzykliwości) i ikonę-iskrę zamiast płaskiego "+" — pierwszy sygnał, że
 * to inteligentny asystent, nie zwykły formularz kontaktowy.
 */
#apx-launcher {
	position: fixed;
	bottom: 28px;
	right: 28px;
	z-index: 9999999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
}

#apx-launcher-btn {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 18px;
	border: none;
	cursor: pointer;
	background: linear-gradient(150deg, var(--apl-primary, #4f46e5) 0%, var(--apl-primary-600, #4338ca) 100%);
	box-shadow: 0 8px 24px rgba(79, 70, 229, .35);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .2s, box-shadow .2s;
}

#apx-launcher-btn:hover {
	transform: scale(1.06);
	box-shadow: 0 12px 32px rgba(79, 70, 229, .45);
}

.apx-launcher-btn__ico {
	position: relative;
	z-index: 1;
	color: #fff;
	width: 24px;
	height: 24px;
	display: inline-flex;
}

.apx-launcher-btn__ico svg { width: 100%; height: 100%; }

.apx-launcher-btn__ring {
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: 0 0 0 0 color-mix(in srgb, var(--apl-primary, #4f46e5) 55%, transparent);
	animation: apxLauncherPulse 2.6s ease-out infinite;
	pointer-events: none;
}

@keyframes apxLauncherPulse {
	0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--apl-primary, #4f46e5) 45%, transparent); }
	70%  { box-shadow: 0 0 0 14px color-mix(in srgb, var(--apl-primary, #4f46e5) 0%, transparent); }
	100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--apl-primary, #4f46e5) 0%, transparent); }
}

@media (max-width: 640px) {
	#apx-launcher { bottom: 20px; right: 16px; }
	#apx-launcher-btn { width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
	#apx-launcher-btn { transition: none !important; }
	.apx-launcher-btn__ring { animation: none !important; }
}

.apx-concierge-panel {
	position: fixed;
	right: 20px;
	bottom: calc(var(--apl-bottomnav-h, 0px) + 96px);
	left: auto;
	width: min(392px, calc(100vw - 32px));
	max-height: min(600px, calc(100vh - var(--apl-bottomnav-h, 0px) - 140px));
	background: var(--apl-bg, #fff);
	border: 1px solid var(--apl-line, #e2e8f0);
	border-radius: calc(var(--apl-radius, 14px) + 4px);
	box-shadow: var(--apl-shadow-lg, 0 12px 40px rgba(15, 23, 42, .18));
	display: flex;
	flex-direction: column;
	z-index: 9999998;
	overflow: hidden;
	font-family: var(--apl-font, inherit);
	transform: translateY(14px) scale(.97);
	opacity: 0;
	pointer-events: none;
	transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .18s ease;
}

.apx-concierge-panel[hidden] {
	display: none;
}

.apx-concierge-panel.is-open {
	transform: translateY(0) scale(1);
	opacity: 1;
	pointer-events: auto;
}

@media (max-width: 640px) {
	.apx-concierge-panel {
		right: 12px;
		bottom: calc(var(--apl-bottomnav-h, 0px) + 84px);
		width: calc(100vw - 24px);
	}
}

/* ── Nagłówek: gradient marki + awatar-iskra + podtytuł statusu ────────── */

.apx-concierge-panel__head {
	position: relative;
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 16px 14px;
	background: linear-gradient(135deg, var(--apl-primary, #4f46e5) 0%, var(--apl-primary-600, #4338ca) 100%);
	color: #fff;
	flex: none;
	overflow: hidden;
}

/* Delikatny, nieruchomy blask w rogu — głębia bez ruchu i bez obcego koloru. */
.apx-concierge-panel__head::before {
	content: "";
	position: absolute;
	top: -60%;
	right: -20%;
	width: 180px;
	height: 180px;
	background: radial-gradient(circle, rgba(255,255,255,.16) 0%, rgba(255,255,255,0) 70%);
	pointer-events: none;
}

.apx-concierge-panel__title-wrap {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
}

.apx-concierge-panel__title {
	font-weight: 800;
	font-size: 14.5px;
	line-height: 1.25;
	letter-spacing: -.01em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.apx-concierge-panel__subtitle {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 11.5px;
	font-weight: 500;
	color: rgba(255, 255, 255, .82);
	margin-top: 2px;
}

.apx-concierge-panel__dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 2px rgba(255, 255, 255, .3);
	flex: none;
}

.apx-concierge-panel__head-actions {
	position: relative;
	display: flex;
	gap: 2px;
	flex: none;
}

.apx-concierge-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 8px;
	border: none;
	background: transparent;
	color: inherit;
	cursor: pointer;
	transition: background .15s;
}

.apx-concierge-panel__head .apx-concierge-icon-btn:hover {
	background: rgba(255, 255, 255, .18);
}

/* ── Awatar znaku firmowego (iskra) — nagłówek (md) i wiadomości (sm) ──── */

.apx-concierge-avatar {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 10px;
	background: rgba(255, 255, 255, .2);
	color: #fff;
}

.apx-concierge-avatar--md { width: 34px; height: 34px; }

.apx-concierge-avatar--md svg { width: 18px; height: 18px; }

.apx-concierge-avatar--sm {
	width: 26px;
	height: 26px;
	border-radius: 8px;
	background: linear-gradient(150deg, var(--apl-primary, #4f46e5) 0%, var(--apl-primary-600, #4338ca) 100%);
	box-shadow: 0 2px 6px color-mix(in srgb, var(--apl-primary, #4f46e5) 35%, transparent);
	margin-top: 1px;
}

.apx-concierge-avatar--sm svg { width: 13px; height: 13px; }

.apx-concierge-panel__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px 14px 8px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: var(--apl-bg-2, #f8fafc);
	scrollbar-width: thin;
}

/* ── Wiersz wiadomości asystenta: awatar + kolumna treści ───────────────── */

.apx-cc-row {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	align-self: stretch;
}

.apx-cc-col {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
	flex: 1 1 auto;
}

.apx-cc-msg {
	max-width: 100%;
	padding: 10px 13px;
	border-radius: var(--apl-radius-sm, 10px);
	font-size: var(--apl-t-sm, 13.5px);
	line-height: 1.52;
	white-space: pre-wrap;
	word-break: break-word;
}

.apx-cc-row .apx-cc-msg--assistant {
	max-width: 100%;
}

.apx-cc-msg--assistant {
	align-self: flex-start;
	background: var(--apl-bg, #fff);
	border: 1px solid var(--apl-line, #e2e8f0);
	color: var(--apl-ink, #0f172a);
	border-radius: 4px var(--apl-radius-sm, 10px) var(--apl-radius-sm, 10px);
	box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.apx-cc-msg--user {
	align-self: flex-end;
	max-width: 84%;
	background: linear-gradient(150deg, var(--apl-primary, #4f46e5) 0%, var(--apl-primary-600, #4338ca) 100%);
	color: #fff;
	border-radius: var(--apl-radius-sm, 10px) 4px var(--apl-radius-sm, 10px) var(--apl-radius-sm, 10px);
}

.apx-cc-msg--typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	padding: 12px 14px;
}

.apx-cc-msg--typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--apl-muted, #64748b);
	animation: apxCcBlink 1.1s infinite ease-in-out;
}

.apx-cc-msg--typing span:nth-child(2) { animation-delay: .15s; }
.apx-cc-msg--typing span:nth-child(3) { animation-delay: .3s; }

@keyframes apxCcBlink {
	0%, 80%, 100% { opacity: .25; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-2px); }
}

/* ── Wejście każdej nowej wiadomości/karty — subtelne, jedno wspólne
   uczucie "produktu", a nie statycznego wyskakiwania treści. ──────────── */
.apx-cc-in {
	animation: apxCcFadeIn .28s cubic-bezier(.2,.7,.3,1) both;
}

@keyframes apxCcFadeIn {
	from { opacity: 0; transform: translateY(7px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ── Podpowiedzi startowe — jedno kliknięcie zamiast pustej kartki ──────── */

.apx-cc-suggestions {
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-self: stretch;
	margin-left: 34px;
}

@media (max-width: 640px) {
	.apx-cc-suggestions { margin-left: 0; }
}

.apx-cc-suggestion {
	text-align: left;
	font: inherit;
	font-size: 12.5px;
	font-weight: 500;
	padding: 9px 12px;
	border-radius: var(--apl-radius-sm, 10px);
	border: 1px solid var(--apl-line, #e2e8f0);
	background: var(--apl-bg, #fff);
	color: var(--apl-ink-2, #334155);
	cursor: pointer;
	transition: border-color .15s, color .15s, transform .15s;
}

.apx-cc-suggestion:hover {
	border-color: var(--apl-primary, #4f46e5);
	color: var(--apl-primary, #4f46e5);
	transform: translateX(2px);
}

/* ── Karty firm — awatar z inicjałami, odznaka statusu, chevron ─────────── */

.apx-cc-cards {
	display: flex;
	flex-direction: column;
	gap: 7px;
	align-self: stretch;
}

.apx-cc-card {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 11px;
	border: 1px solid var(--apl-line, #e2e8f0);
	border-radius: var(--apl-radius-sm, 10px);
	background: var(--apl-bg, #fff);
	text-decoration: none;
	color: inherit;
	transition: border-color .15s, box-shadow .15s, transform .15s;
}

.apx-cc-card:hover {
	border-color: var(--apl-primary, #4f46e5);
	box-shadow: 0 4px 14px rgba(15, 23, 42, .08);
	transform: translateY(-1px);
}

.apx-cc-card__avatar {
	flex: none;
	width: 34px;
	height: 34px;
	border-radius: 9px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 700;
	color: #fff;
	background: linear-gradient(150deg, var(--apl-primary, #4f46e5) 0%, var(--apl-secondary, #0ea5e9) 100%);
}

.apx-cc-card__body {
	min-width: 0;
	flex: 1 1 auto;
}

.apx-cc-card__title-row {
	display: flex;
	align-items: center;
	gap: 6px;
}

.apx-cc-card__title {
	font-weight: 700;
	font-size: 13px;
	color: var(--apl-ink, #0f172a);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.apx-cc-card__meta {
	font-size: 11.5px;
	color: var(--apl-muted, #64748b);
	margin-top: 2px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.apx-cc-card__badge {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.apx-cc-card__badge--verified {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--apl-success, #16a34a);
	color: #fff;
}

/* [Faza B.1, 2026-09-15] Ta sama informacja co odznaka "Profil nieprzejęty"
   na stronie ogłoszenia (import Google Places/OSM jeszcze nie potwierdzony
   przez firmę) — teraz jako właściwa odznaka-pigułka, nie sam tekst, żeby
   nie ginęła obok pogrubionej nazwy firmy. */
.apx-cc-card__badge--unclaimed {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .01em;
	padding: 2px 7px;
	border-radius: 99px;
	background: rgba(180, 83, 9, .12);
	color: var(--apl-warning, #b45309);
	white-space: nowrap;
}

.apx-cc-card__chevron {
	flex: none;
	color: var(--apl-muted, #64748b);
	opacity: .6;
	transition: transform .15s, opacity .15s;
}

.apx-cc-card:hover .apx-cc-card__chevron {
	transform: translateX(2px);
	opacity: 1;
	color: var(--apl-primary, #4f46e5);
}

/* ── Akcje: ikona + etykieta, wariant główny i WhatsApp ─────────────────── */

.apx-cc-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-self: flex-start;
	max-width: 100%;
}

.apx-cc-action {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font: inherit;
	font-size: 12px;
	font-weight: 600;
	padding: 7px 12px;
	border-radius: 99px;
	border: 1px solid var(--apl-primary, #4f46e5);
	background: var(--apl-primary-050, #eef2ff);
	color: var(--apl-primary, #4f46e5);
	text-decoration: none;
	cursor: pointer;
	transition: background .15s, color .15s, transform .1s;
}

.apx-cc-action svg { flex: none; }

.apx-cc-action:hover {
	background: var(--apl-primary, #4f46e5);
	color: #fff;
	transform: translateY(-1px);
}

.apx-cc-action--primary {
	background: var(--apl-primary, #4f46e5);
	color: #fff;
}

.apx-cc-action--primary:hover {
	background: var(--apl-primary-600, #4338ca);
}

.apx-cc-action--whatsapp {
	border-color: #25d366;
	background: rgba(37, 211, 102, .12);
	color: #17883f;
}

.apx-cc-action--whatsapp:hover {
	background: #25d366;
	color: #fff;
}

/* ── Pasek wpisywania — pigułka z wtopionym polem, bez ciężkich krawędzi ── */

.apx-concierge-panel__form {
	flex: none;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid var(--apl-line, #e2e8f0);
	background: var(--apl-bg, #fff);
}

.apx-concierge-panel__form textarea {
	flex: 1 1 auto;
	resize: none;
	max-height: 96px;
	min-height: 40px;
	border: 1px solid var(--apl-line, #e2e8f0);
	border-radius: 20px;
	padding: 10px 16px;
	font: inherit;
	font-size: var(--apl-t-sm, 13.5px);
	color: var(--apl-ink, #0f172a);
	background: var(--apl-bg-2, #f8fafc);
	transition: border-color .15s, box-shadow .15s;
}

.apx-concierge-panel__form textarea:focus {
	outline: none;
	border-color: var(--apl-primary, #4f46e5);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--apl-primary, #4f46e5) 14%, transparent);
}

.apx-concierge-send,
.apx-concierge-mic {
	flex: none;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: none;
	background: linear-gradient(150deg, var(--apl-primary, #4f46e5) 0%, var(--apl-primary-600, #4338ca) 100%);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: transform .12s, background .15s;
}

.apx-concierge-send:active { transform: scale(.92); }

.apx-concierge-mic {
	background: var(--apl-bg-2, #f1f5f9);
	color: var(--apl-primary, #4f46e5);
}

.apx-concierge-mic.is-listening {
	background: #dc2626;
	color: #fff;
	animation: apxCcPulse 1.2s infinite;
}

@keyframes apxCcPulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .4); }
	50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

.apx-concierge-send:hover {
	background: linear-gradient(150deg, var(--apl-primary-600, #4338ca) 0%, var(--apl-primary-600, #4338ca) 100%);
}

/**
 * [Faza B, 2026-09-15] Formularz zapytania do firmy WPROST w oknie czatu —
 * zastępuje dawny zwykły link akcji "inquiry", który i tak prowadził do
 * formularza na stronie firmy wymagającego zalogowania (ściana dla
 * anonimowego odwiedzającego). Patrz renderLeadForm() w ai-concierge.js.
 */
.apx-cc-lead {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 7px;
	align-self: stretch;
	padding: 12px;
	border: 1px solid var(--apl-line, #e2e8f0);
	border-radius: var(--apl-radius-sm, 10px);
	background: var(--apl-bg, #fff);
	box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.apx-cc-lead-hp {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	opacity: 0;
	pointer-events: none;
}

.apx-cc-lead input[type="text"],
.apx-cc-lead textarea {
	border: 1px solid var(--apl-line, #e2e8f0);
	border-radius: var(--apl-radius-sm, 10px);
	padding: 8px 11px;
	font: inherit;
	font-size: var(--apl-t-sm, 13.5px);
	color: var(--apl-ink, #0f172a);
	background: var(--apl-bg-2, #f8fafc);
	resize: none;
	transition: border-color .15s, box-shadow .15s;
}

.apx-cc-lead input[type="text"]:focus,
.apx-cc-lead textarea:focus {
	outline: none;
	border-color: var(--apl-primary, #4f46e5);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--apl-primary, #4f46e5) 14%, transparent);
}

.apx-cc-lead-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 2px;
}

.apx-cc-lead-cancel,
.apx-cc-lead-submit {
	font-size: 12px;
	font-weight: 600;
	padding: 7px 13px;
	border-radius: 99px;
	border: 1px solid var(--apl-line, #e2e8f0);
	background: transparent;
	color: var(--apl-muted, #64748b);
	cursor: pointer;
	transition: background .15s, color .15s;
}

.apx-cc-lead-submit {
	border-color: var(--apl-primary, #4f46e5);
	background: var(--apl-primary, #4f46e5);
	color: #fff;
}

.apx-cc-lead-submit:hover {
	background: var(--apl-primary-600, #4338ca);
}

.apx-cc-lead-cancel:disabled,
.apx-cc-lead-submit:disabled {
	opacity: .6;
	cursor: default;
}

/* Nudge — dyskretna dymkowa podpowiedź nad launcherem, tylko raz na sesję,
   uruchamiana wyłącznie po realnym sygnale (0 wyników wyszukiwania). */
.apx-cc-nudge {
	position: fixed;
	right: 20px;
	bottom: calc(var(--apl-bottomnav-h, 0px) + 96px);
	max-width: 220px;
	background: var(--apl-ink, #0f172a);
	color: #fff;
	font-size: 12.5px;
	line-height: 1.4;
	padding: 10px 13px;
	border-radius: var(--apl-radius-sm, 10px);
	box-shadow: var(--apl-shadow, 0 8px 24px rgba(15,23,42,.15));
	z-index: 9999997;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity .25s ease, transform .25s ease;
	pointer-events: none;
}

.apx-cc-nudge.is-visible {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
	cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
	.apx-concierge-panel,
	.apx-cc-nudge,
	.apx-cc-in,
	.apx-cc-msg--typing span,
	.apx-launcher-btn__ring,
	.apx-concierge-mic.is-listening {
		transition: none !important;
		animation: none !important;
	}
	.apx-cc-in { opacity: 1 !important; transform: none !important; }
}
