/**
 * WWB LLM Studio — Frontend AI Chat & Assistant Widget
 */

/* ── Floating Toggle Button ── */
.wwb-llm-chat-toggle {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99990;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: linear-gradient(135deg, #4f46e5, #06b6d4);
	color: #ffffff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 20px rgba(79, 70, 229, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 26px;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	outline: none;
}

.wwb-llm-chat-toggle:hover {
	transform: scale(1.08) translateY(-2px);
	box-shadow: 0 6px 25px rgba(79, 70, 229, 0.6);
}

.wwb-llm-chat-toggle:active {
	transform: scale(0.96);
}

.wwb-llm-chat-toggle-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	background: #ef4444;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 10px;
	border: 2px solid #fff;
}

/* ── Chat Panel Container ── */
.wwb-llm-chat-panel {
	position: fixed;
	bottom: 92px;
	right: 24px;
	z-index: 99991;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 120px);
	background: #ffffff;
	border-radius: 18px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
	display: none;
	flex-direction: column;
	overflow: hidden;
	animation: wwbLlmSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.wwb-llm-chat-panel.is-open {
	display: flex;
}

@keyframes wwbLlmSlideUp {
	from {
		opacity: 0;
		transform: translateY(16px) scale(0.96);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* ── Panel Header ── */
.wwb-llm-chat-header {
	background: linear-gradient(135deg, #1e1b4b, #312e81);
	color: #ffffff;
	padding: 14px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.wwb-llm-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.wwb-llm-header-icon {
	font-size: 22px;
}

.wwb-llm-header-title {
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	color: #ffffff;
}

.wwb-llm-header-subtitle {
	font-size: 11px;
	color: #a5b4fc;
	margin-top: 2px;
}

.wwb-llm-header-actions {
	display: flex;
	gap: 6px;
}

.wwb-llm-header-btn {
	background: rgba(255, 255, 255, 0.12);
	border: none;
	color: #ffffff;
	width: 28px;
	height: 28px;
	border-radius: 6px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 13px;
	transition: background 0.15s;
}

.wwb-llm-header-btn:hover {
	background: rgba(255, 255, 255, 0.25);
}

/* ── Persona Badge ── */
.wwb-llm-persona-badge {
	background: #f1f5f9;
	border-bottom: 1px solid #e2e8f0;
	padding: 8px 16px;
	font-size: 12px;
	color: #475569;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.wwb-llm-persona-name {
	font-weight: 700;
	color: #0f172a;
}

.wwb-llm-vest-tag {
	background: #e0e7ff;
	color: #4338ca;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 4px;
}

/* ── LLM Config Accordion ── */
.wwb-llm-cfg-details {
	background: #f8fafc;
	border-bottom: 1px solid #e2e8f0;
	font-size: 12px;
	flex-shrink: 0;
}

.wwb-llm-cfg-details summary {
	padding: 8px 16px;
	cursor: pointer;
	font-weight: 600;
	color: #334155;
	user-select: none;
	list-style: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.wwb-llm-cfg-details summary::-webkit-details-marker {
	display: none;
}

.wwb-llm-cfg-form {
	padding: 10px 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #ffffff;
	border-top: 1px solid #e2e8f0;
}

.wwb-llm-input-sm {
	width: 100%;
	padding: 6px 10px;
	font-size: 12px;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	box-sizing: border-box;
	outline: none;
	background: #f8fafc;
}

.wwb-llm-input-sm:focus {
	border-color: #6366f1;
	background: #ffffff;
}

.wwb-llm-save-btn {
	background: #4f46e5;
	color: #ffffff;
	border: none;
	padding: 7px 12px;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s;
	margin-top: 4px;
}

.wwb-llm-save-btn:hover {
	background: #4338ca;
}

/* ── Speech & Zhuyin Toolbar ── */
.wwb-llm-speech-toolbar {
	background: #ffffff;
	border-bottom: 1px solid #f1f5f9;
	padding: 6px 14px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 11px;
	color: #64748b;
	flex-shrink: 0;
	gap: 8px;
	flex-wrap: wrap;
}

.wwb-llm-speech-row {
	display: flex;
	align-items: center;
	gap: 6px;
}

.wwb-llm-select-xs {
	font-size: 11px;
	padding: 3px 6px;
	border: 1px solid #cbd5e1;
	border-radius: 4px;
	background: #fff;
	color: #334155;
	max-width: 140px;
}

/* ── Messages Stream ── */
.wwb-llm-messages {
	flex: 1;
	padding: 16px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: #f8fafc;
}

.wwb-llm-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 13px;
	line-height: 1.55;
	word-break: break-word;
	position: relative;
}

.wwb-llm-msg-user {
	align-self: flex-end;
	background: linear-gradient(135deg, #4f46e5, #6366f1);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}

.wwb-llm-msg-assistant {
	align-self: flex-start;
	background: #ffffff;
	color: #1e293b;
	border: 1px solid #e2e8f0;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
	border-bottom-left-radius: 4px;
}

.wwb-llm-msg-text {
	margin-bottom: 6px;
}

.wwb-llm-speak-btn {
	background: #f1f5f9;
	border: 1px solid #cbd5e1;
	border-radius: 12px;
	font-size: 11px;
	padding: 2px 8px;
	cursor: pointer;
	color: #475569;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	transition: all 0.15s;
}

.wwb-llm-speak-btn:hover {
	background: #e2e8f0;
	color: #0f172a;
}

.wwb-llm-speak-btn.is-speaking {
	background: #fee2e2;
	border-color: #fca5a5;
	color: #b91c1c;
	animation: wwbPulse 1.2s infinite;
}

@keyframes wwbPulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.04); }
}

/* ── Input Bar ── */
.wwb-llm-input-bar {
	padding: 10px 14px;
	background: #ffffff;
	border-top: 1px solid #e2e8f0;
	display: flex;
	gap: 8px;
	align-items: flex-end;
	flex-shrink: 0;
}

.wwb-llm-textarea {
	flex: 1;
	min-height: 38px;
	max-height: 100px;
	padding: 8px 12px;
	border: 1px solid #cbd5e1;
	border-radius: 10px;
	font-size: 13px;
	line-height: 1.4;
	resize: none;
	outline: none;
	background: #f8fafc;
	color: #0f172a;
	font-family: inherit;
	box-sizing: border-box;
}

.wwb-llm-textarea:focus {
	border-color: #6366f1;
	background: #ffffff;
}

.wwb-llm-send-btn {
	background: #4f46e5;
	color: #ffffff;
	border: none;
	width: 38px;
	height: 38px;
	border-radius: 10px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	flex-shrink: 0;
	transition: background 0.15s, transform 0.1s;
}

.wwb-llm-send-btn:hover {
	background: #4338ca;
}

.wwb-llm-send-btn:active {
	transform: scale(0.95);
}

.wwb-llm-send-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* ── Zhuyin (Bopomofo) Support ── */
.wwb-llm-use-zhuyin,
.wwb-llm-use-zhuyin * {
	font-family: 'BpmfZihiKaiStd', "BpmfZihiKaiStd", "DFKai-SB", "BiauKai", sans-serif !important;
}

/* ── Guest Lock ── */
.wwb-llm-guest-box {
	text-align: center;
	padding: 30px 20px;
	background: #f8fafc;
	border-radius: 12px;
	margin: 20px;
	border: 1px dashed #cbd5e1;
}

.wwb-llm-guest-icon {
	font-size: 36px;
	margin-bottom: 10px;
}

.wwb-llm-login-btn {
	display: inline-block;
	background: #4f46e5;
	color: #ffffff !important;
	text-decoration: none !important;
	font-weight: 600;
	padding: 8px 20px;
	border-radius: 8px;
	font-size: 13px;
	margin-top: 12px;
	transition: background 0.15s;
}

.wwb-llm-login-btn:hover {
	background: #4338ca;
}
