/* ==========================================================================
   Asystio AI Assistant – scoped stylesheet
   All selectors start with .asystio-ai- to avoid collisions.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Card wrapper
   -------------------------------------------------------------------------- */
.asystio-ai-assistant {
	max-width: 760px;
	margin: 0 auto;
	background: #fff;
	border: 1px solid #d1d9e6;
	border-radius: 16px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	font-family: inherit;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10), 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.asystio-ai-assistant__header {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 20px 24px;
	background: linear-gradient(135deg, #1a73e8 0%, #1558c0 100%);
	color: #fff;
}

.asystio-ai-assistant__avatar {
	font-size: 2.2rem;
	line-height: 1;
	flex-shrink: 0;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.20));
}

.asystio-ai-assistant__title {
	margin: 0 0 3px;
	font-size: 1.15rem;
	font-weight: 700;
	color: #fff;
	letter-spacing: -0.01em;
}

.asystio-ai-assistant__subtitle {
	margin: 0;
	font-size: 0.82rem;
	opacity: 0.85;
	line-height: 1.45;
}

/* --------------------------------------------------------------------------
   Messages area
   -------------------------------------------------------------------------- */
.asystio-ai-assistant__messages {
	flex: 1;
	overflow-y: auto;
	padding: 24px 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	min-height: 280px;
	max-height: 440px;
	background: #f5f7fa;
	scroll-behavior: smooth;
}

/* --------------------------------------------------------------------------
   Individual message bubble
   -------------------------------------------------------------------------- */
.asystio-ai-message {
	display: flex;
	flex-direction: column;
	max-width: 82%;
}

.asystio-ai-message--user {
	align-self: flex-end;
	align-items: flex-end;
}

.asystio-ai-message--assistant {
	align-self: flex-start;
	align-items: flex-start;
}

.asystio-ai-message__content {
	padding: 11px 16px;
	border-radius: 18px;
	font-size: 0.93rem;
	line-height: 1.6;
	white-space: pre-wrap;
	word-break: break-word;
	overflow-wrap: break-word;
}

.asystio-ai-message--user .asystio-ai-message__content {
	background: #1a73e8;
	color: #fff;
	border-bottom-right-radius: 5px;
	box-shadow: 0 1px 3px rgba(26, 115, 232, 0.30);
}

.asystio-ai-message--assistant .asystio-ai-message__content {
	background: #fff;
	color: #212121;
	border: 1px solid #dde3ed;
	border-bottom-left-radius: 5px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Links inside assistant responses */
.asystio-ai-message--assistant .asystio-ai-message__content a {
	color: #1a73e8;
	text-decoration: underline;
}

.asystio-ai-message--assistant .asystio-ai-message__content a:hover {
	color: #1558c0;
}

/* Code-like text inside messages */
.asystio-ai-message__content code {
	font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 0.87em;
	background: rgba(0, 0, 0, 0.07);
	padding: 1px 5px;
	border-radius: 4px;
	white-space: pre-wrap;
	word-break: break-word;
}

.asystio-ai-message--user .asystio-ai-message__content code {
	background: rgba(255, 255, 255, 0.20);
}

/* --------------------------------------------------------------------------
   Sources used (appended by JS after assistant messages)
   -------------------------------------------------------------------------- */
.asystio-ai-message__sources {
	margin-top: 8px;
	padding: 9px 12px;
	background: #eef2f9;
	border: 1px solid #d1d9e6;
	border-radius: 8px;
	max-width: 100%;
}

.asystio-ai-message__sources-label {
	margin: 0 0 5px;
	font-size: 0.78rem;
	font-weight: 600;
	color: #5a6a80;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.asystio-ai-message__sources-list {
	margin: 0;
	padding: 0 0 0 16px;
	list-style: disc;
}

.asystio-ai-message__sources-list li {
	font-size: 0.82rem;
	color: #4a5568;
	line-height: 1.5;
	margin-bottom: 2px;
}

.asystio-ai-message__sources-list li:last-child {
	margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Typing indicator
   -------------------------------------------------------------------------- */
.asystio-ai-assistant__typing-indicator {
	padding: 6px 20px 10px;
	display: flex;
	gap: 5px;
	align-items: center;
	background: #f5f7fa;
}

.asystio-ai-assistant__typing-indicator span {
	display: inline-block;
	width: 8px;
	height: 8px;
	background: #9aa3b0;
	border-radius: 50%;
	animation: asystio-ai-bounce 1.1s infinite ease-in-out both;
}

.asystio-ai-assistant__typing-indicator span:nth-child(1) { animation-delay: -0.3s; }
.asystio-ai-assistant__typing-indicator span:nth-child(2) { animation-delay: -0.15s; }
.asystio-ai-assistant__typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes asystio-ai-bounce {
	0%, 80%, 100% { transform: scale(0); }
	40%            { transform: scale(1); }
}

/* --------------------------------------------------------------------------
   Notice bar
   -------------------------------------------------------------------------- */
.asystio-ai-assistant__notice {
	margin: 0 20px 10px;
	padding: 9px 14px;
	border-radius: 8px;
	font-size: 0.88rem;
	line-height: 1.45;
}

.asystio-ai-assistant__notice--error {
	background: #fce8e6;
	color: #c5221f;
	border: 1px solid #f4c3c2;
}

.asystio-ai-assistant__notice--success {
	background: #e6f4ea;
	color: #137333;
	border: 1px solid #b7dfbb;
}

/* --------------------------------------------------------------------------
   Input area
   -------------------------------------------------------------------------- */
.asystio-ai-input {
	display: flex;
	flex-direction: column;
	padding: 16px 20px 18px;
	border-top: 1px solid #dde3ed;
	background: #fff;
	gap: 10px;
}

.asystio-ai-input__field {
	width: 100%;
	padding: 11px 14px;
	border: 1px solid #c8d0dc;
	border-radius: 10px;
	font-size: 0.93rem;
	line-height: 1.55;
	resize: vertical;
	box-sizing: border-box;
	font-family: inherit;
	color: #212121;
	background: #fafbfc;
	transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
	min-height: 72px;
}

.asystio-ai-input__field::placeholder {
	color: #96a0ae;
}

.asystio-ai-input__field:focus {
	outline: none;
	border-color: #1a73e8;
	background: #fff;
	box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.asystio-ai-input__field:disabled {
	opacity: 0.60;
	cursor: not-allowed;
	background: #f0f2f5;
}

.asystio-ai-input__actions {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 10px;
}

.asystio-ai-input__send:disabled {
	opacity: 0.50;
	cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Escalation area
   -------------------------------------------------------------------------- */
.asystio-ai-escalate {
	padding: 14px 20px 18px;
	border-top: 1px solid #dde3ed;
	background: #f0f6ff;
	display: flex;
	align-items: center;
	gap: 14px;
	flex-wrap: wrap;
}

.asystio-ai-escalate__prompt {
	margin: 0;
	font-size: 0.87rem;
	color: #4a5568;
	flex: 1;
	line-height: 1.5;
}

.asystio-ai-escalate__btn {
	white-space: nowrap;
	flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Shared button styles – scoped so only affect buttons inside the component.
   The theme may override .asystio-btn freely without affecting these.
   -------------------------------------------------------------------------- */
.asystio-ai-assistant .asystio-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 9px 20px;
	border-radius: 8px;
	border: none;
	cursor: pointer;
	font-size: 0.93rem;
	font-weight: 600;
	text-decoration: none;
	transition: background 0.18s, box-shadow 0.18s, opacity 0.18s;
	line-height: 1.4;
	min-height: 38px;
}

.asystio-ai-assistant .asystio-btn--primary {
	background: #1a73e8;
	color: #fff;
	box-shadow: 0 1px 4px rgba(26, 115, 232, 0.35);
}

.asystio-ai-assistant .asystio-btn--primary:hover {
	background: #1558c0;
	box-shadow: 0 2px 8px rgba(26, 115, 232, 0.40);
}

.asystio-ai-assistant .asystio-btn--primary:focus-visible {
	outline: 3px solid rgba(26, 115, 232, 0.45);
	outline-offset: 2px;
}

.asystio-ai-assistant .asystio-btn--secondary {
	background: #fff;
	color: #1a73e8;
	border: 1.5px solid #1a73e8;
}

.asystio-ai-assistant .asystio-btn--secondary:hover {
	background: #e8f0fe;
}

.asystio-ai-assistant .asystio-btn--secondary:focus-visible {
	outline: 3px solid rgba(26, 115, 232, 0.45);
	outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Ticket created confirmation
   -------------------------------------------------------------------------- */
.asystio-ai-escalate__created {
	font-size: 0.88rem;
	color: #137333;
	font-weight: 600;
}

.asystio-ai-escalate__created a {
	color: #137333;
	text-decoration: underline;
}

.asystio-ai-escalate__created a:hover {
	color: #0d5225;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
	.asystio-ai-assistant {
		border-radius: 12px;
	}

	.asystio-ai-assistant__header {
		padding: 16px 18px;
		gap: 10px;
	}

	.asystio-ai-assistant__title {
		font-size: 1rem;
	}

	.asystio-ai-assistant__messages {
		max-height: 320px;
		min-height: 220px;
		padding: 16px 14px;
	}

	.asystio-ai-message {
		max-width: 93%;
	}

	.asystio-ai-input {
		padding: 12px 14px 16px;
	}

	.asystio-ai-input__field {
		min-height: 60px;
	}

	.asystio-ai-escalate {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.asystio-ai-escalate__btn {
		width: 100%;
		text-align: center;
	}
}

@media (max-width: 380px) {
	.asystio-ai-assistant__subtitle {
		display: none;
	}
}

/* --------------------------------------------------------------------------
   Screen-reader utility
   -------------------------------------------------------------------------- */
.asystio-ai-assistant .screen-reader-text {
	clip: rect(1px, 1px, 1px, 1px);
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	white-space: nowrap;
}
