/* Chat Window */
.bkbchat {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 380px;
	height: 500px;
	min-width: 300px;
	min-height: 350px;
	max-width: 90vw;
	max-height: 90vh;
	border-radius: 12px;
	background: #fff;
	display: flex;
	flex-direction: column;
	z-index: 999999;
	box-shadow: 0 4px 20px rgba(0,0,0,.15);
	font-family: var(--bkb-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
	font-size: var(--bkb-font-size, 14px);
	overflow: hidden;
}
.bkbchat--left { right: auto; left: 20px; }

/* Resize handle — top-left corner */
.bkbchat__resize {
	position: absolute;
	top: 0;
	left: 0;
	width: 18px;
	height: 18px;
	cursor: nwse-resize;
	z-index: 10;
}
.bkbchat__resize::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: 8px;
	height: 8px;
	border-top: 2px solid rgba(255,255,255,.5);
	border-left: 2px solid rgba(255,255,255,.5);
}
.bkbchat--resizing { transition: none !important; }

/* Header */
.bkbchat__header {
	padding: 12px 16px;
	background: var(--bkb-header-bg, #232f3e);
	color: var(--bkb-header-color, #fff);
	display: flex;
	justify-content: space-between;
	align-items: center;
	user-select: none;
}
.bkbchat__title { font-weight: 600; font-size: 15px; }
.bkbchat__header-btns { display: flex; gap: 6px; }
.bkbchat__btn {
	background: none; border: none; color: inherit; cursor: pointer; padding: 2px;
	display: flex; align-items: center;
}
.bkbchat__btn:hover { opacity: .7; }
.bkbchat__btn .dashicons { width: 18px; height: 18px; font-size: 18px; }

/* Body */
.bkbchat__body {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Messages */
.bkbchat__messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
}

/* Message */
.bkbchat-msg { margin-bottom: 12px; animation: bkbchat-fade .25s ease-in; }
.bkbchat-msg--user { display: flex; flex-direction: column; align-items: flex-end; margin-left: 20%; }
.bkbchat-msg--bot  { display: flex; flex-direction: column; align-items: flex-start; margin-right: 20%; }

.bkbchat-msg__author { font-size: 11px; color: #888; margin-bottom: 3px; padding: 0 10px; }

.bkbchat-msg__text {
	padding: 10px 14px;
	border-radius: 16px;
	max-width: 100%;
	word-wrap: break-word;
	line-height: 1.45;
	box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.bkbchat-msg--user .bkbchat-msg__text {
	background: var(--bkb-user-bg, #232f3e);
	color: var(--bkb-user-color, #fff);
	border-bottom-right-radius: 4px;
}
.bkbchat-msg--bot .bkbchat-msg__text {
	background: var(--bkb-bot-bg, #f4f4f4);
	color: var(--bkb-bot-color, #222);
	border: 1px solid #e5e5e5;
	border-bottom-left-radius: 4px;
}

/* Typing indicator */
.bkbchat-typing {
	display: flex; gap: 4px; padding: 10px 14px;
	background: var(--bkb-bot-bg, #f4f4f4); border-radius: 16px; border-bottom-left-radius: 4px;
	border: 1px solid #e5e5e5;
}
.bkbchat-typing span {
	width: 7px; height: 7px; background: #999; border-radius: 50%;
	animation: bkbchat-bounce .6s infinite alternate;
}
.bkbchat-typing span:nth-child(2) { animation-delay: .2s; }
.bkbchat-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes bkbchat-bounce {
	to { transform: translateY(-4px); opacity: .5; }
}
@keyframes bkbchat-fade {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Citations */
.bkbchat-citations {
	margin-top: 8px;
	padding: 10px;
	background: #f9fafb;
	border-radius: 8px;
	border-left: 3px solid var(--bkb-header-bg, #232f3e);
}
.bkbchat-citations__title {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .5px;
	color: var(--bkb-header-bg, #232f3e);
	margin-bottom: 6px;
}
.bkbchat-citations__link {
	display: block;
	padding: 4px 8px;
	margin-top: 3px;
	font-size: 12px;
	color: #0073aa;
	text-decoration: none;
	border-radius: 4px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.bkbchat-citations__link:hover {
	background: #e8f4fd;
}

/* Form */
.bkbchat__form {
	display: flex;
	padding: 10px;
	border-top: 1px solid #eee;
	gap: 8px;
}
.bkbchat__input {
	flex: 1;
	padding: 8px 12px;
	border: 1px solid #ddd;
	border-radius: 20px;
	outline: none;
	font-size: inherit;
	font-family: inherit;
}
.bkbchat__input:focus { border-color: var(--bkb-header-bg, #232f3e); }

.bkbchat__send {
	position: relative;
	background: var(--bkb-send-bg, #232f3e);
	color: #fff;
	border: none;
	padding: 8px 18px;
	border-radius: 20px;
	cursor: pointer;
	font-size: inherit;
	font-family: inherit;
	transition: opacity .2s;
}
.bkbchat__send:hover { opacity: .85; }
.bkbchat__send:disabled { opacity: .7; cursor: not-allowed; }

.bkbchat__spinner {
	display: none;
	position: absolute;
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
	width: 14px; height: 14px;
	border: 2px solid #fff;
	border-radius: 50%;
	border-top-color: transparent;
	animation: bkbchat-spin .8s linear infinite;
}
.bkbchat__send--loading .bkbchat__spinner { display: block; }
.bkbchat__send--loading .bkbchat__send-text { opacity: .6; }
.bkbchat__send--loading { padding-right: 32px; }

@keyframes bkbchat-spin {
	to { transform: translateY(-50%) rotate(360deg); }
}

/* Launcher */
.bkbchat-launcher {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 52px; height: 52px;
	background: var(--bkb-launcher-bg, #232f3e);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 999999;
	box-shadow: 0 4px 12px rgba(0,0,0,.2);
	transition: transform .2s;
}
.bkbchat-launcher:hover { transform: scale(1.1); }
.bkbchat-launcher.bkbchat--left { right: auto; left: 20px; }
.bkbchat-launcher .dashicons { color: #fff; font-size: 24px; width: 24px; height: 24px; }

/* Utility */
.bkbchat--hidden { display: none !important; }

/* Responsive */
@media (max-width: 480px) {
	.bkbchat { width: calc(100% - 20px); right: 10px; left: 10px; bottom: 10px; height: 70vh; }
	.bkbchat--left { right: 10px; }
	.bkbchat-launcher, .bkbchat-launcher.bkbchat--left { right: 10px; left: auto; bottom: 10px; }
	.bkbchat__resize { display: none; }
}
