﻿/* Floating action button (bottom-left) */
.ai-fab {
	position: fixed;
	left: 10px;
	bottom: 10px;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: #1976d2;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 20px;
	line-height: 1;
	box-shadow: 0 6px 18px rgba(0,0,0,.25);
	cursor: pointer;
	z-index: 2147483000;
	transition: transform .2s ease, background .2s ease;
}

	.ai-fab:hover {
		transform: translateY(-1px);
		background: #175fb1;
	}

	.ai-fab.open {
		background: #b71c1c;
	}

.ai-fab-close {
	font-size: 26px;
	margin-top: -2px;
}

/* Slide-up panel */
.ai-panel {
	position: fixed;
	left: 10px;
	bottom: 70px;
	width: 360px;
	max-width: 90vw;
	max-height: 70vh;
	background: #fff;
	border: 1px solid #e5e5e5;
	border-radius: 10px;
	box-shadow: 0 14px 34px rgba(0,0,0,.25);
	display: none;
	overflow: hidden;
	z-index: 2147483001;
}

	.ai-panel.show {
		display: block;
		animation: ai-slide-up .18s ease-out;
	}

@keyframes ai-slide-up {
	from {
		transform: translateY(14px);
		opacity: 0
	}

	to {
		transform: translateY(0);
		opacity: 1
	}
}

/* Fullscreen mode */
.ai-panel.fullscreen {
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100vw;
	height: 100vh;
	max-width: none;
	max-height: none;
	border-radius: 0;
	box-shadow: none;
	z-index: 2147483600;
}

/* Header */
.ai-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 12px;
	background: #f7f9fc;
	border-bottom: 1px solid #eee;
}

.ai-title {
	font-weight: 600;
}

.ai-x, .ai-fs {
	border: 0;
	background: transparent;
	font-size: 20px;
	cursor: pointer;
	padding: 4px 6px;
}

.ai-header .ai-fs {
	font-size: 18px;
}

/* Body */
.ai-body {
	padding: 12px;
	display: flex;
	flex-direction: column;
	height: calc(100% - 52px);
}

/* Chat history */
.ai-chat-box {
	flex: 1 1 auto;
	overflow-y: auto;
	margin-bottom: 10px;
	border: 1px solid #eee;
	border-radius: 8px;
	padding: 8px;
	background: #fff;
	max-height: 40vh; /* in non-fullscreen */
}

.ai-panel.fullscreen .ai-chat-box {
	max-height: none; /* stretch in fullscreen */
}

/* Bubbles */
.ai-msg {
	padding: 6px 10px;
	border-radius: 8px;
	margin: 6px 0;
	max-width: 85%;
}

	.ai-msg.user {
		background: #1976d2;
		color: #fff;
		margin-left: auto;
		box-shadow: 0 1px 3px rgba(0,0,0,0.15);
		border-radius: 10px 10px 2px 10px;
	}

	.ai-msg.bot {
		background: #f7f9fc;
		color: #111;
		margin-right: auto;
		box-shadow: 0 1px 3px rgba(0,0,0,0.1);
		border-radius: 10px 10px 10px 2px;
		line-height: 1.55;
		font-size: 14px;
		white-space: normal; /* we render HTML inside */
	}

		/* Bot message content (HTML) */
		.ai-msg.bot p {
			margin: 6px 0;
		}

		.ai-msg.bot strong {
			color: #0d47a1;
			font-weight: 600;
		}

		.ai-msg.bot ul {
			margin: 6px 0 6px 18px;
			padding-left: 12px;
		}

		.ai-msg.bot li {
			list-style-type: disc;
			margin: 4px 0;
		}

			.ai-msg.bot li + li {
				margin-top: 2px;
			}

/* Textarea (allow full width, grow in fullscreen) */
.ai-body textarea {
	width: 100%;
	min-height: 100px;
	resize: vertical;
	padding: 8px 10px;
	font-family: inherit;
	border: 1px solid #ddd;
	border-radius: 8px;
	outline: none;
	max-width: 100% !important; /* key fix: no 350px cap */
	box-sizing: border-box;
}

	.ai-body textarea:focus {
		border-color: #1976d2;
		box-shadow: 0 0 0 3px rgba(25,118,210,.12);
	}

.ai-panel.fullscreen .ai-body textarea {
	min-height: 22vh; /* taller default in fullscreen */
	max-width: 100% !important;
}

/* Controls (Ask above checkbox) */
.ai-controls {
	display: flex;
	flex-direction: column; /* vertical layout */
	align-items: stretch;
	gap: 8px;
	margin-top: 8px;
}

.ai-checkbox {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	user-select: none;
}

/* Send button */
.ai-send {
	width: 100%;
	height: 38px;
	border-radius: 8px;
	border: 1px solid #1976d2;
	background: #1976d2;
	color: #fff;
	cursor: pointer;
	font-weight: 600;
}

	.ai-send:disabled {
		opacity: .6;
		cursor: default;
	}

/* Error + Footer */
.ai-error {
	color: #b00020;
	margin-top: 10px;
}

.ai-foot {
	text-align: center;
}

/* Spinner */
.ai-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255,255,255,0.6);
	border-top: 2px solid #fff;
	border-radius: 50%;
	animation: ai-spin .8s linear infinite;
	vertical-align: middle;
}

@keyframes ai-spin {
	from {
		transform: rotate(0)
	}

	to {
		transform: rotate(360deg)
	}
}

/* Mobile tweaks */
@media (max-width:480px) {
	.ai-panel {
		left: 10px;
		bottom: 76px;
		width: calc(100vw - 20px);
		max-height: 70vh;
	}

	.ai-body textarea {
		max-width: 100% !important;
	}
}
