/* PSB Chatbot Widget — all selectors scoped to #psb-chatbot */

/* ── Layout foundations ──────────────────────────────────────────────────── */

#psb-chatbot * {
	box-sizing: border-box;
}

/* ── FAB ─────────────────────────────────────────────────────────────────── */

#psb-chatbot-fab {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 56px;
	height: 56px;
	background-color: var(--psb-primary, #2E6DA4);
	color: #ffffff;
	border: none;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 999998;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	outline: none;
	padding: 0;
}

#psb-chatbot-fab:hover,
#psb-chatbot-fab:focus-visible {
	transform: scale(1.08);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.psb-chatbot-fab-icon {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.psb-chatbot-fab-icon--open  { opacity: 1; transform: scale(1); }
.psb-chatbot-fab-icon--close { opacity: 0; transform: scale(0.6); }

#psb-chatbot[data-psb-state="open"] .psb-chatbot-fab-icon--open  { opacity: 0; transform: scale(0.6); }
#psb-chatbot[data-psb-state="open"] .psb-chatbot-fab-icon--close { opacity: 1; transform: scale(1); }

/* ── Notification badge ──────────────────────────────────────────────────── */

#psb-chatbot-notif {
	position: absolute;
	top: 0;
	right: 0;
	width: 20px;
	height: 20px;
	background: #e53935;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: scale(0);
	transition: opacity 0.25s ease, transform 0.25s ease;
}

#psb-chatbot-notif.psb-chatbot-notif--visible {
	opacity: 1;
	transform: scale(1);
}

/* ── Proactive preview bubble ────────────────────────────────────────────── */

#psb-chatbot-preview {
	position: fixed;
	bottom: 90px;
	right: 24px;
	z-index: 999998;
	pointer-events: none;
}

#psb-chatbot-preview[aria-hidden="true"],
#psb-chatbot-preview.psb-chatbot-preview--hidden {
	opacity: 0;
	transform: translateY(8px);
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
}

#psb-chatbot-preview.psb-chatbot-preview--visible {
	opacity: 1;
	transform: translateY(0);
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.psb-chatbot-preview-bubble {
	background: #ffffff;
	border-radius: 16px 16px 4px 16px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
	padding: 10px 16px;
	max-width: 240px;
	font-size: 14px;
	line-height: 1.5;
	color: #1a1a1a;
	display: flex;
	gap: 5px;
	align-items: center;
}

/* ── Chat panel ──────────────────────────────────────────────────────────── */

#psb-chatbot-panel {
	position: fixed;
	bottom: 92px;
	right: 24px;
	width: 380px;
	height: 560px;
	background: #ffffff;
	border-radius: 16px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	z-index: 999998;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: opacity 0.25s ease, transform 0.25s ease;
}

#psb-chatbot-panel[aria-hidden="true"] {
	opacity: 0;
	pointer-events: none;
	transform: translateY(16px);
}

#psb-chatbot[data-psb-state="open"] #psb-chatbot-panel {
	opacity: 1;
	transform: translateY(0);
}

/* ── Header ──────────────────────────────────────────────────────────────── */

#psb-chatbot-header {
	background-color: var(--psb-primary, #2E6DA4);
	color: #ffffff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	margin-bottom: 1px;
}

#psb-chatbot-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

#psb-chatbot-header-logo {
	width: 32px;
	height: 32px;
	border-radius: 6px;
	object-fit: contain;
	flex-shrink: 0;
}

#psb-chatbot-header-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

#psb-chatbot-title {
	font-weight: 700;
	font-size: 15px;
	letter-spacing: 0.01em;
}

#psb-chatbot-subtitle {
	font-size: 12px;
	opacity: 0.8;
}

#psb-chatbot-close,
#psb-chatbot-clear,
#psb-chatbot-debug-export {
	background: none;
	border: none;
	color: #ffffff;
	padding: 4px;
	cursor: pointer;
	opacity: 0.8;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.15s ease, color 0.15s ease;
}

#psb-chatbot-close:hover,
#psb-chatbot-close:focus-visible,
#psb-chatbot-clear:hover,
#psb-chatbot-clear:focus-visible,
#psb-chatbot-debug-export:hover,
#psb-chatbot-debug-export:focus-visible {
	opacity: 1;
	outline: 2px solid rgba(255,255,255,0.5);
}

/* Test-only export button: dim by default, green flash on success */
#psb-chatbot-debug-export {
	opacity: 0.55;
}

#psb-chatbot-debug-export.psb-chatbot-debug-export--done {
	color: #4ade80;
	opacity: 1;
}

.psb-chatbot-header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* ── Messages area ───────────────────────────────────────────────────────── */

#psb-chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

/* ── Message bubbles ─────────────────────────────────────────────────────── */

.psb-chatbot-message {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.psb-chatbot-message--user {
	align-items: flex-end;
}

.psb-chatbot-message--assistant {
	align-items: flex-start;
}

.psb-chatbot-message--error {
	align-self: flex-start;
}

.psb-chatbot-bubble {
	max-width: 82%;
	padding: 9px 13px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.55;
	word-wrap: break-word;
}

.psb-chatbot-message--user .psb-chatbot-bubble {
	background-color: var(--psb-primary, #2E6DA4);
	color: #ffffff;
	border-bottom-right-radius: 3px;
}

.psb-chatbot-message--error {
	background: #FFF0F0;
	color: #c0392b;
	padding: 9px 13px;
	border-radius: 14px;
	font-size: 13px;
	max-width: 82%;
}

/* ── Text segment ────────────────────────────────────────────────────────── */

.psb-chatbot-text {
	background-color: #F1F3F5;
	color: var(--psb-text, #1a1a1a);
	padding: 10px 14px;
	border-radius: 14px;
	border-bottom-left-radius: 3px;
	font-size: 14px;
	line-height: 1.6;
	max-width: 88%;
	word-wrap: break-word;
}

/* When text is followed by a card/form/etc., keep all corners fully rounded
   so it doesn't look like the conversation ended mid-message. */
.psb-chatbot-text:not(:last-child) {
	border-bottom-left-radius: 14px;
}

.psb-chatbot-text strong { font-weight: 700; }
.psb-chatbot-text em    { font-style: italic; }

.psb-chatbot-text ul {
	margin: 6px 0 0 0;
	padding-left: 18px;
}

.psb-chatbot-text li {
	margin-bottom: 3px;
}

.psb-chatbot-text a {
	color: var(--psb-primary, #2E6DA4);
	text-decoration: underline;
}

/* ── Typing indicator ────────────────────────────────────────────────────── */

.psb-chatbot-bubble--typing {
	background-color: #F1F3F5;
	padding: 12px 16px !important;
	border-radius: 14px;
	border-bottom-left-radius: 3px;
	display: flex;
	gap: 5px;
	align-items: center;
}

.psb-chatbot-dot {
	width: 7px;
	height: 7px;
	background-color: var(--psb-secondary, #7F8C8D);
	border-radius: 50%;
	animation: psb-bounce 1.2s infinite ease-in-out;
	display: inline-block;
}

.psb-chatbot-dot:nth-child(2) { animation-delay: 0.2s; }
.psb-chatbot-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes psb-bounce {
	0%, 60%, 100% { transform: translateY(0); }
	30%            { transform: translateY(-6px); }
}

/* ── Cards (product + category) ──────────────────────────────────────────── */

.psb-chatbot-card {
	border: 1px solid #E8ECEF;
	border-radius: 10px;
	overflow: hidden;
	max-width: 280px;
	font-size: 13px;
	background: #fff;
}

.psb-chatbot-card__image {
	width: 100%;
	height: 140px;
	object-fit: cover;
	display: block;
}

.psb-chatbot-card__body {
	padding: 10px 12px 12px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.psb-chatbot-card__title {
	font-weight: 700;
	font-size: 14px;
	color: var(--psb-text, #1a1a1a);
}

.psb-chatbot-card__meta {
	font-size: 12px;
	color: var(--psb-secondary, #7F8C8D);
}

.psb-chatbot-card__excerpt {
	font-size: 13px;
	color: #444;
	line-height: 1.4;
}

.psb-chatbot-card__link {
	display: inline-block;
	margin-top: 8px;
	padding: 6px 12px;
	background-color: var(--psb-primary, #2E6DA4);
	color: #ffffff !important;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 600;
	text-decoration: none !important;
	transition: opacity 0.15s ease;
	text-align: center;
}

.psb-chatbot-card__link:hover { opacity: 0.88; }

/* ── Contact card ────────────────────────────────────────────────────────── */

.psb-chatbot-contact-card {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	max-width: 280px;
}

.psb-chatbot-contact-btn {
	display: inline-flex;
	align-items: center;
	padding: 7px 14px;
	border-radius: 20px;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	transition: opacity 0.15s ease;
	background: #F1F3F5;
	color: var(--psb-text, #1a1a1a);
}

.psb-chatbot-contact-btn:hover { opacity: 0.8; }

.psb-chatbot-contact-btn__icon {
	display: inline-flex;
	align-items: center;
	margin-left: 6px;
}

.psb-chatbot-contact-btn__icon svg {
	display: block;
	width: 15px;
	height: 15px;
}

.psb-chatbot-contact-btn--whatsapp { background: #25d366; color: #fff; }
.psb-chatbot-contact-btn--viber    { background: #7360f2; color: #fff; }
.psb-chatbot-contact-btn--telegram { background: #229ed9; color: #fff; }

.psb-chatbot-contact-btn--whatsapp:hover,
.psb-chatbot-contact-btn--viber:hover,
.psb-chatbot-contact-btn--telegram:hover {
	color: #fff;
}

/* ── Quote CTA ───────────────────────────────────────────────────────────── */

.psb-chatbot-quote-cta {
	background: linear-gradient(135deg, var(--psb-primary, #2E6DA4) 0%, var(--psb-accent, #3DBE3D) 100%);
	border-radius: 10px;
	padding: 14px 16px;
	max-width: 280px;
}

.psb-chatbot-quote-cta__heading {
	color: #fff;
	font-weight: 700;
	font-size: 14px;
	margin-bottom: 10px;
}

.psb-chatbot-quote-cta__btn {
	display: inline-block;
	background: #fff;
	color: var(--psb-primary, #2E6DA4) !important;
	padding: 8px 16px;
	border-radius: 6px;
	font-weight: 700;
	font-size: 13px;
	text-decoration: none !important;
	transition: opacity 0.15s ease;
}

.psb-chatbot-quote-cta__btn:hover { opacity: 0.9; }

/* ── Pills ───────────────────────────────────────────────────────────────── */

.psb-chatbot-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	max-width: 320px;
}

.psb-chatbot-pill {
	background: #ffffff;
	border: 1.5px solid var(--psb-primary, #2E6DA4);
	color: var(--psb-primary, #2E6DA4);
	border-radius: 20px;
	padding: 6px 14px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.psb-chatbot-pill:hover:not(:disabled) {
	background: var(--psb-primary, #2E6DA4);
	color: #ffffff;
}

.psb-chatbot-pills--used .psb-chatbot-pill,
.psb-chatbot-pill:disabled {
	opacity: 0.45;
	cursor: default;
}

/* ── Lead form ───────────────────────────────────────────────────────────── */

.psb-chatbot-lead-form {
	background: #F8F9FA;
	border: 1px solid #E8ECEF;
	border-radius: 10px;
	padding: 14px;
	max-width: 300px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.psb-chatbot-form-group {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.psb-chatbot-form-group label {
	font-size: 12px;
	font-weight: 600;
	color: var(--psb-secondary, #7F8C8D);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.psb-chatbot-form-field {
	width: 100%;
	border: 1px solid #D0D5DD;
	border-radius: 6px;
	padding: 7px 10px;
	font-size: 13px;
	font-family: inherit;
	background: #fff;
	color: var(--psb-text, #1a1a1a);
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	resize: none;
}

.psb-chatbot-form-field:focus {
	border-color: var(--psb-primary, #2E6DA4);
	box-shadow: 0 0 0 3px rgba(46, 109, 164, 0.12);
}

.psb-chatbot-form-error {
	font-size: 12px;
	color: #c0392b;
	background: #FFF0F0;
	padding: 6px 10px;
	border-radius: 5px;
}

.psb-chatbot-form-submit {
	background-color: var(--psb-accent, #3DBE3D);
	color: #ffffff;
	border: none;
	border-radius: 7px;
	padding: 9px 16px;
	font-size: 14px;
	font-weight: 700;
	font-family: inherit;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.psb-chatbot-form-submit:hover:not(:disabled) {
	background-color: #33a833;
}

.psb-chatbot-form-submit:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

/* ── Lead confirmation ───────────────────────────────────────────────────── */

.psb-chatbot-lead-confirmation {
	background: #F0FFF0;
	border: 1px solid #46b450;
	border-radius: 8px;
	padding: 12px 16px;
	color: #2e7d32;
	font-size: 14px;
	font-weight: 600;
	max-width: 280px;
}

/* ── Input area ──────────────────────────────────────────────────────────── */

#psb-chatbot-input-area {
	display: flex;
	padding: 12px;
	gap: 8px;
	border-top: 1px solid #E8ECEF;
	flex-shrink: 0;
	background: #ffffff;
}

#psb-chatbot-input {
	flex: 1;
	border: 1px solid #D0D5DD;
	border-radius: 8px;
	padding: 9px 12px;
	font-size: 14px;
	font-family: inherit;
	outline: none;
	background: #ffffff;
	color: var(--psb-text, #1a1a1a);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#psb-chatbot-input:focus {
	border-color: var(--psb-primary, #2E6DA4);
	box-shadow: 0 0 0 3px rgba(46, 109, 164, 0.1);
}

#psb-chatbot-send {
	background-color: var(--psb-accent, #3DBE3D);
	color: #ffffff;
	border: none;
	border-radius: 8px;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background-color 0.15s ease;
	padding: 0;
}

#psb-chatbot-send:hover:not(:disabled) {
	background-color: #33a833;
}

#psb-chatbot-send:disabled,
#psb-chatbot-input:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
	#psb-chatbot-panel {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		width: 100%;
		height: 100dvh;
		border-radius: 0;
	}

	/* Pin header to top so it's always visible, even when keyboard is open.
	   Mirrors WhatsApp: header stays fixed, messages scroll underneath. */
	#psb-chatbot-header {
		position: sticky;
		top: 0;
		z-index: 1;
	}

	#psb-chatbot-fab {
		bottom: 16px;
		right: 16px;
	}

	/* Prevent iOS auto-zoom when focusing the input. */
	#psb-chatbot-input {
		font-size: 16px;
	}

	/* Hide FAB on mobile when chat is open — the header's X button is enough. */
	#psb-chatbot[data-psb-state="open"] #psb-chatbot-fab {
		display: none;
	}

	#psb-chatbot-preview {
		right: 16px;
		bottom: 84px;
	}
}
