/* =============================================================================
   BRANWELL CHATBOT — bw-styles-chatbot.css
   v3.0.0
   Uses s2p dashboard token set (--s2p-*) which is always available
   when this plugin is active alongside soul2path-child.
============================================================================= */

/* =============================================================================
   FAB LAUNCHER
============================================================================= */

.bw-chat-fab {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: var(--s2p-dark, #1E3F7A);
	color: #fff;
	cursor: pointer;
	z-index: 10000;
	display: none;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(30, 63, 122, 0.4);
	transition: transform 0.18s, box-shadow 0.18s;
	border: none;
}

.bw-chat-fab:hover {
	transform: scale(1.06);
	box-shadow: 0 6px 22px rgba(30, 63, 122, 0.55);
}

.bw-chat-fab__ring,
.bw-chat-fab__ring--2 {
	display: none;
}

.bw-chat-fab__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	width: 20px;
	height: 20px;
	background: #e24b4a;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #fff;
	pointer-events: none;
	transition: opacity 0.2s;
}

.bw-chat-fab__icon {
	width: 26px;
	height: 26px;
	position: absolute;
	transition: opacity 0.2s, transform 0.2s;
}

.bw-chat-fab__icon--chat  { opacity: 1; transform: rotate(0deg); }
.bw-chat-fab__icon--close { opacity: 0; transform: rotate(-90deg); }

.bw-chat-fab.is-open .bw-chat-fab__icon--chat  { opacity: 0; transform: rotate(90deg); }
.bw-chat-fab.is-open .bw-chat-fab__icon--close { opacity: 1; transform: rotate(0deg); }
.bw-chat-fab.is-open .bw-chat-fab__ring,
.bw-chat-fab.is-open .bw-chat-fab__badge { opacity: 0; pointer-events: none; }

/* =============================================================================
   CHAT PANEL
============================================================================= */

.bw-chat-panel {
	display: none;
	position: fixed;
	bottom: 96px;
	right: 24px;
	width: 360px;
	max-height: 540px;
	background: #fff;
	border-radius: 20px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.16), 0 4px 16px rgba(0, 0, 0, 0.08);
	flex-direction: column;
	z-index: 9999;
	overflow: hidden;
	font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

.bw-chat-panel.is-open {
	display: flex;
	animation: bwChatSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bwChatSlideUp {
	from { opacity: 0; transform: translateY(14px) scale(0.97); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* HEADER */

.bw-chat-panel__header {
	background: var(--s2p-dark, #1E3F7A);
	padding: 10px 14px;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

.bw-chat-panel__avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.3);
	flex-shrink: 0;
	object-fit: cover;
}

.bw-chat-panel__avatar-fallback {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.3);
	flex-shrink: 0;
	background: var(--s2p-mid, #4169A8);
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	align-items: center;
	justify-content: center;
}

.bw-chat-panel__header-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.bw-chat-panel__name {
	font-size: 15px;
	font-weight: 600;
	color: #fff;
	line-height: 1.2;
}

.bw-chat-panel__status {
	font-size: 12px;
	color: rgba(255, 255, 255, 0.7);
	display: flex;
	align-items: center;
	gap: 5px;
}

.bw-chat-panel__dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 6px rgba(74, 222, 128, 0.8);
	flex-shrink: 0;
}

.bw-chat-panel__close {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: rgba(255, 255, 255, 0.85);
	flex-shrink: 0;
	transition: background 0.15s;
	padding: 0;
}

.bw-chat-panel__close:hover { background: rgba(255, 255, 255, 0.22); }
.bw-chat-panel__close svg   { width: 14px; height: 14px; }

/* KNOWLEDGE BAR */

.bw-chat-panel__kb-bar {
	background: var(--s2p-light, #EBF0F8);
	padding: 7px 14px;
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	font-weight: 500;
	color: var(--s2p-mid, #4169A8);
	border-bottom: 1px solid var(--s2p-border, #C5D3E8);
	flex-shrink: 0;
}

.bw-chat-panel__kb-count {
	margin-left: auto;
	background: var(--s2p-dark, #1E3F7A);
	color: #fff;
	font-size: 10px;
	font-weight: 600;
	padding: 2px 8px;
	border-radius: 999px;
}

/* LOG */

.bw-chat-panel__log {
	flex: 1;
	padding: 14px 14px 8px;
	overflow-y: auto;
	background: #F7F9FC;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.bw-chat-bubble {
	max-width: 88%;
	padding: 11px 13px;
	font-size: 13.5px;
	line-height: 1.55;
	border-radius: 14px;
}

.bw-chat-bubble--bot {
	background: #fff;
	color: var(--s2p-dark, #1E3F7A);
	border-radius: 4px 14px 14px 14px;
	border: 1px solid var(--s2p-border, #C5D3E8);
	align-self: flex-start;
}

.bw-chat-bubble--user {
	background: var(--s2p-dark, #1E3F7A);
	color: #fff;
	border-radius: 14px 4px 14px 14px;
	align-self: flex-end;
}

.bw-chat-bubble--cached {
	background: #fff;
	color: var(--s2p-dark, #1E3F7A);
	border-radius: 4px 14px 14px 14px;
	border: 1px solid var(--s2p-border, #C5D3E8);
	align-self: flex-start;
}

.bw-chat-bubble__cache-tag {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: var(--s2p-light, #EBF0F8);
	color: var(--s2p-mid, #4169A8);
	font-size: 10px;
	font-weight: 600;
	padding: 2px 7px;
	border-radius: 999px;
	margin-bottom: 6px;
}

/* TYPING INDICATOR */

.bw-chat-panel__typing {
	display: none;
	padding: 8px 14px;
	background: #F7F9FC;
	gap: 4px;
	align-items: center;
}

.bw-chat-panel__typing.is-visible { display: flex; }

.bw-chat-panel__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--s2p-mid, #4169A8);
	opacity: 0.4;
	animation: bwTypingDot 1.2s ease-in-out infinite;
}

.bw-chat-panel__typing span:nth-child(2) { animation-delay: 0.2s; }
.bw-chat-panel__typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bwTypingDot {
	0%, 80%, 100% { transform: scale(1);    opacity: 0.4; }
	40%           { transform: scale(1.25); opacity: 1;   }
}

/* SUGGESTIONS */

.bw-chat-panel__suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 4px 14px 10px;
	background: #F7F9FC;
	flex-shrink: 0;
}

.bw-chat-suggestion {
	background: #fff;
	border: 1px solid var(--s2p-border, #C5D3E8);
	color: var(--s2p-dark, #1E3F7A);
	font-size: 12px;
	font-weight: 500;
	padding: 6px 12px;
	border-radius: 999px;
	cursor: pointer;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
	font-family: 'Poppins', -apple-system, sans-serif;
	line-height: 1.3;
}

.bw-chat-suggestion:hover {
	background: var(--s2p-dark, #1E3F7A);
	color: #fff;
	border-color: var(--s2p-dark, #1E3F7A);
}

/* INPUT ROW */

.bw-chat-panel__input-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: #fff;
	border-top: 1px solid var(--s2p-border, #C5D3E8);
	flex-shrink: 0;
}

.bw-chat-panel__input {
	flex: 1;
	border: 1.5px solid var(--s2p-border, #C5D3E8);
	border-radius: 999px;
	padding: 9px 14px;
	font-size: 13.5px;
	font-family: 'Poppins', -apple-system, sans-serif;
	color: var(--s2p-dark, #1E3F7A);
	background: #F7F9FC;
	outline: none;
	transition: border-color 0.15s, background 0.15s;
}

.bw-chat-panel__input:focus {
	border-color: var(--s2p-mid, #4169A8);
	background: #fff;
}

.bw-chat-panel__input::placeholder { color: #8fa3c0; }

.bw-chat-panel__send {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--s2p-dark, #1E3F7A);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	flex-shrink: 0;
	transition: background 0.15s, transform 0.15s;
	padding: 0;
}

.bw-chat-panel__send:hover   { background: var(--s2p-mid, #4169A8); transform: scale(1.05); }
.bw-chat-panel__send:disabled { background: #ccc; cursor: not-allowed; transform: none; }
.bw-chat-panel__send svg { width: 16px; height: 16px; }

/* Links inside bot bubbles */
.bw-chat-bubble--bot a,
.bw-chat-bubble--cached a {
	color: var(--s2p-mid, #4169A8);
	text-decoration: none;
}

.bw-chat-bubble--bot a:hover,
.bw-chat-bubble--cached a:hover { opacity: 0.75; }

/* =============================================================================
   MOBILE
============================================================================= */

@media (max-width: 480px) {
	.bw-chat-panel {
		width: calc(100% - 24px);
		right: 12px;
		bottom: 80px;
		max-height: 72vh;
	}

	.bw-chat-fab {
		width: 44px;
		height: 44px;
		bottom: 16px;
		right: 16px;
		box-shadow: 0 3px 12px rgba(30, 63, 122, 0.4);
	}

	.bw-chat-fab__icon {
		width: 20px;
		height: 20px;
	}
}
