/* ============================================
   AI ASSISTANT CHAT BUBBLE STYLES

   The AI chat offcanvas uses the shared .msg-* template
   (see style.css "MESSAGE BUBBLE TEMPLATE" section) so it
   feels like a cousin of the Driver Messages and User Chat
   offcanvases. The styles below are limited to:
   - the floating edge-tab toggle button
   - the offcanvas shell + gradient header (the "this is AI"
     signal so users don't confuse it with a human chat)
   - a third .msg-bubble--ai variant + bot avatar
   - the typing indicator dots
   ============================================ */

/* Floating toggle button — thin edge tab that expands on hover */
.ai-chat-toggle {
	position: fixed;
	top: calc(50% - 30px);
	right: 0;
	width: 14px;
	height: 48px;
	border-radius: 8px 0 0 8px;
	background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
	border: none;
	border-right: 2px solid #06b6d4;
	color: white;
	font-size: 20px;
	cursor: pointer;
	box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
	transition: all 0.25s ease;
	z-index: 1039;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 12px 8px;
	overflow: hidden;
	opacity: 0.6;
}

.ai-chat-toggle i {
	opacity: 0;
	transition: opacity 0.25s ease;
}

.ai-chat-toggle:hover {
	width: 42px;
	opacity: 1;
	box-shadow: -4px 0 15px rgba(30, 41, 59, 0.35);
}

.ai-chat-toggle:hover i {
	opacity: 1;
}

.ai-chat-toggle:active {
	width: 38px;
}

/* Offcanvas shell — wider than the driver messages offcanvas (420px) because
   AI replies often include markdown tables / lists that need horizontal room. */
.ai-chat-offcanvas {
	width: 600px !important;
	max-width: 90vw;
}

.ai-chat-offcanvas .offcanvas-body {
	background-color: #f6f8fb;
}

/* Flex-scroll fix — same trick as #chatMessages in style.css; without this
   the message thread can blow past the offcanvas height on long conversations. */
#aiChatMessages {
	min-height: 0;
}

/* Slate header with cyan accent — the primary "you're talking to AI" cue.
   Distinct from the primary navy used by the messaging offcanvas so the
   two surfaces don't get confused. */
.ai-chat-header {
	background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
	color: white;
	padding: 0.65rem 1rem;
	border-bottom: 2px solid #06b6d4;
}

.ai-chat-header .offcanvas-title i {
	font-size: 1.05rem;
	color: #67e8f9;
}

.ai-chat-header__subtitle {
	font-size: 0.65rem;
	opacity: 0.75;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	font-weight: 500;
	display: block;
	line-height: 1.1;
	color: #67e8f9;
}

/* AI bubble variant — sits alongside .msg-bubble--in / --out */
.msg-bubble--ai {
	background-color: #f0f9ff;
	color: #0f172a;
	border: 1px solid #bae6fd;
	border-bottom-left-radius: 4px;
}

.msg-bubble--ai .msg-bubble__sender {
	color: #0c4a6e;
}

.msg-bubble--ai .msg-bubble__tag {
	background-color: #cffafe;
	color: #0e7490;
}

.msg-bubble--ai .msg-bubble__footer {
	color: #64748b;
}

/* Robot avatar that flags every AI message — strongest visual
   "this is not a real person" signal inside the thread */
.ai-msg-row {
	gap: 0.5rem;
}

.ai-msg-avatar {
	flex-shrink: 0;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
	color: #67e8f9;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.8rem;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.35);
	margin-top: 2px;
}

/* Links inside AI bubbles */
.msg-bubble--ai a {
	color: #0e7490;
	text-decoration: none;
	font-weight: 500;
	border-bottom: 1px dashed #0e7490;
}

.msg-bubble--ai a:hover {
	color: #155e75;
	border-bottom-color: #155e75;
}

.msg-bubble--ai code {
	background: rgba(14, 116, 144, 0.1);
	padding: 1px 5px;
	border-radius: 4px;
	font-size: 0.8rem;
}

/* Beta-warning callout shown in the welcome message */
.ai-beta-warning {
	margin-top: 0.4rem;
	padding-top: 0.4rem;
	border-top: 1px dashed #bae6fd;
	font-size: 0.72rem;
	color: #0e7490;
	line-height: 1.35;
}

/* Typing indicator — three dots inside an AI bubble */
.ai-typing-indicator .msg-bubble__body {
	display: flex;
	gap: 4px;
	padding: 4px 2px;
}

.typing-dot {
	width: 7px;
	height: 7px;
	background: #0e7490;
	border-radius: 50%;
	animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.6; }
	40% { transform: scale(1); opacity: 1; }
}

/* Dark-mode tweaks for the AI bubble variant */
[data-bs-theme="dark"] .ai-chat-offcanvas .offcanvas-body {
	background-color: #1e2228;
}

[data-bs-theme="dark"] .msg-bubble--ai {
	background-color: #1e2a3a;
	color: #e6edf3;
	border-color: #1e4a5e;
}

[data-bs-theme="dark"] .msg-bubble--ai .msg-bubble__sender { color: #67e8f9; }

[data-bs-theme="dark"] .msg-bubble--ai .msg-bubble__tag {
	background-color: #1e4a5e;
	color: #a5f3fc;
}

[data-bs-theme="dark"] .msg-bubble--ai .msg-bubble__footer { color: #768390; }

[data-bs-theme="dark"] .msg-bubble--ai a { color: #67e8f9; border-bottom-color: #67e8f9; }

[data-bs-theme="dark"] .ai-beta-warning {
	color: #67e8f9;
	border-top-color: #1e4a5e;
}

/* Responsive */
@media (max-width: 768px) {
	.ai-chat-toggle {
		top: calc(50% - 25px);
		width: 12px;
		height: 44px;
		font-size: 18px;
	}

	.ai-chat-toggle:hover { width: 38px; }

	.ai-chat-offcanvas {
		width: 100vw !important;
		max-width: 100vw;
	}
}

@media (max-width: 480px) {
	.ai-chat-toggle {
		top: calc(50% - 20px);
		width: 10px;
		height: 40px;
		font-size: 16px;
	}

	.ai-chat-toggle:hover { width: 36px; }
}

/* Scrollbar styling for the message thread inside the AI offcanvas */
.ai-chat-offcanvas .msg-thread::-webkit-scrollbar { width: 6px; }
.ai-chat-offcanvas .msg-thread::-webkit-scrollbar-track { background: transparent; }
.ai-chat-offcanvas .msg-thread::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.ai-chat-offcanvas .msg-thread::-webkit-scrollbar-thumb:hover { background: #aaa; }
