/* ===========================================
   Chat Demo - Container & Layout
   =========================================== */

.nnaico-chat-demo,
.nnaico-chat-demo button,
.nnaico-chat-demo input {
	font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.nnaico-chat-demo {
	position: relative;
	z-index: 5;
	max-width: 900px;
	margin: 0 auto;
	margin-top: var(--space-3xl-4xl);
	margin-bottom: calc(-1 * var(--space-xl-2xl)) !important;
	padding: 0 var(--space-s-m);
}

.chat-demo-inner {
	position: relative;
}

.chat-demo-inner::before {
	content: '';
	position: absolute;
	inset: calc(-1 * var(--space-3xl));
	background: radial-gradient(ellipse at center, rgba(147, 197, 253, 0.6) 0%, rgba(96, 165, 250, 0.35) 45%, transparent 75%);
	border-radius: var(--space-2xl);
	filter: blur(80px);
	z-index: -1;
}

/* ===========================================
   Navigation Arrows
   =========================================== */

.chat-nav {
	position: absolute;
	top: 50%;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: rgba(15, 23, 42, 0.8);
	backdrop-filter: blur(12px);
	border: 1px solid rgba(51, 65, 85, 0.5);
	color: #cbd5e1;
	cursor: pointer;
	transition: all 0.2s ease;
}

.chat-nav:hover {
	color: #ffffff;
	background: rgba(30, 41, 59, 1);
}

.chat-nav svg {
	width: 20px;
	height: 20px;
}

.chat-nav--prev {
	left: 0;
	transform: translate(-150%, -50%);
}

.chat-nav--next {
	right: 0;
	transform: translate(150%, -50%);
}

@media (max-width: 1150px) {
	.chat-nav { display: none; }
}

/* ===========================================
   Badge Carousel
   =========================================== */

.chat-demo-badges {
	display: none;
	overflow-x: auto;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	gap: var(--space-2xs);
	padding: var(--space-xs) var(--space-m) var(--space-xs);
	scroll-behavior: smooth;
}

.chat-demo-badges::-webkit-scrollbar {
	display: none;
}

.chat-demo-badge {
	flex-shrink: 0;
	font-size: var(--step--2);
	font-weight: 500;
	color: rgba(191, 219, 254, 0.6);
	background: transparent;
	padding: 6px 14px;
	border-radius: 9999px;
	border: 1px solid rgba(59, 130, 246, 0.2);
	cursor: pointer;
	white-space: nowrap;
	transition: all 0.3s ease;
	font-family: inherit;
}

.chat-demo-badge.is-active {
	color: #fff;
	background: rgba(37, 99, 235, 0.5);
	border-color: rgba(96, 165, 250, 0.5);
}

@media (max-width: 782px) {
	.chat-demo-badges { display: flex; }
	.chat-indicators { display: none !important; }
}

/* ===========================================
   Chat Frame
   =========================================== */

.chat-frame {
	display: flex;
	background: #ffffff;
	border-radius: 8px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 80px rgba(147, 197, 253, 0.25);
	border: 1px solid #e5e7eb;
	overflow: hidden;
}

/* ===========================================
   Sidebar
   =========================================== */

.chat-sidebar {
	display: flex;
	flex-direction: column;
	width: 260px;
	border-right: 1px solid #e5e7eb;
	background: #f3f4f6;
	flex-shrink: 0;
}

.chat-sidebar__header {
	padding: 12px;
	border-bottom: 1px solid #e5e7eb;
}

.chat-sidebar__new-chat {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	color: #4b5563;
	background: none;
	border: none;
	cursor: pointer;
	padding: 6px 8px;
	width: 100%;
}

.chat-sidebar__new-chat:hover {
	color: #111827;
}

.chat-sidebar__new-chat svg {
	width: 16px;
	height: 16px;
}

.chat-sidebar__section {
	padding: 12px;
}

.chat-sidebar__section--history {
	flex: 1;
}

.chat-sidebar__history-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.chat-sidebar__section-label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
}

.chat-sidebar__section-label span {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #6b7280;
}

.chat-sidebar__section-label svg {
	width: 14px;
	height: 14px;
	color: #9ca3af;
}

.chat-sidebar__ast-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 8px;
	border-radius: 4px;
	font-size: 14px;
	border: none;
	cursor: pointer;
	width: 100%;
	text-align: left;
	background: none;
	color: #4b5563;
	transition: background 0.15s ease;
}

.chat-sidebar__ast-btn:hover {
	background: rgba(229, 231, 235, 0.6);
}

.chat-sidebar__ast-btn.is-active {
	background: #dbeafe;
	color: #1e3a8a;
}

.chat-sidebar__ast-btn.is-active .chat-sidebar__ast-name {
	font-weight: 500;
	color: #111827;
}

.chat-sidebar__ast-icon {
	width: 20px;
	height: 20px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	flex-shrink: 0;
}

.chat-ast-bg--purple { background: #f3e8ff; }
.chat-ast-bg--green { background: #dcfce7; }
.chat-ast-bg--blue { background: #dbeafe; }

.chat-sidebar__hist-btn {
	display: block;
	width: 100%;
	text-align: left;
	padding: 6px 8px;
	border-radius: 4px;
	border: none;
	cursor: pointer;
	background: none;
	transition: background 0.15s ease;
}

.chat-sidebar__hist-btn:hover {
	background: rgba(229, 231, 235, 0.6);
}

.chat-sidebar__hist-btn.is-active {
	background: rgba(229, 231, 235, 0.8);
}

.chat-sidebar__hist-label {
	display: block;
	margin-bottom: 2px;
	font-size: 14px;
	color: #4b5563;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chat-sidebar__hist-btn.is-active .chat-sidebar__hist-label {
	color: #111827;
	font-weight: 500;
}

.chat-sidebar__hist-time {
	display: block;
	font-size: 13px;
	color: #9ca3af;
}

.chat-sidebar__user {
	padding: 12px;
	border-top: 1px solid #e5e7eb;
	display: flex;
	align-items: center;
	gap: 8px;
}

.chat-sidebar__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: #2563eb;
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 500;
}

.chat-sidebar__user-name {
	font-size: 14px;
	color: #374151;
}

@media (max-width: 782px) {
	.chat-sidebar { display: none; }
}

/* ===========================================
   Chat Content
   =========================================== */

.chat-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	padding: var(--space-s);
	min-width: 0;
}

@media (min-width: 783px) {
	.chat-content {
		padding: var(--space-m) var(--space-l);
	}
}

/* ===========================================
   Messages
   =========================================== */

.chat-messages {
	flex: 1;
	min-height: 420px;
	display: flex;
	flex-direction: column;
	gap: var(--space-m);
}

@media (min-width: 783px) {
	.chat-messages { min-height: 500px; }
}

.chat-msg {
	display: flex;
	opacity: 0;
}

.chat-msg--user {
	justify-content: flex-end;
	animation: chatFadeIn 0.4s ease-out forwards;
}

.chat-msg--assistant {
	justify-content: flex-start;
	animation: chatFadeIn 0.4s ease-out 0.3s forwards;
}

.chat-msg__bubble {
	border-radius: 8px;
	padding: 12px 16px;
}

.chat-msg__bubble--user {
	max-width: 85%;
	background: #f3f4f6;
	color: #111827;
	font-size: var(--step-0);
	line-height: 1.5;
}

.chat-msg__bubble--assistant {
	max-width: 95%;
	color: #374151;
	font-size: var(--step-0);
	line-height: 1.6;
	white-space: pre-wrap;
}

@media (min-width: 783px) {
	.chat-msg__bubble--user { max-width: 75%; }
	.chat-msg__bubble--assistant { max-width: 90%; }
}

/* ===========================================
   Typing Dots
   =========================================== */

.chat-typing-dots {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 8px 0;
}

.chat-typing-dot {
	width: 8px;
	height: 8px;
	background: #9ca3af;
	border-radius: 50%;
	animation: chatBounce 1.4s ease-in-out infinite;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatBounce {
	0%, 80%, 100% { transform: translateY(0); }
	40% { transform: translateY(-6px); }
}

/* ===========================================
   Word Animation
   =========================================== */

.chat-word {
	display: inline;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.chat-word.is-visible {
	opacity: 1;
}

.chat-line-first {
	font-weight: 600;
}

/* ===========================================
   Fade Transitions
   =========================================== */

.chat-messages.is-exiting {
	animation: chatFadeOut 0.3s ease-out forwards;
}

@keyframes chatFadeOut {
	to {
		opacity: 0;
		transform: translateY(-10px);
	}
}

@keyframes chatFadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ===========================================
   Indicator Dots
   =========================================== */

.chat-indicators {
	display: flex;
	justify-content: center;
	gap: var(--space-s);
	margin-top: var(--space-s);
}

.chat-indicator-group {
	display: flex;
	gap: 4px;
	align-items: center;
}

.chat-indicator-dot {
	width: 8px;
	height: 8px;
	border-radius: 9999px;
	background: #475569;
	border: none;
	padding: 0;
	cursor: pointer;
	transition: all 0.2s ease;
}

.chat-indicator-dot:hover {
	background: #64748b;
}

.chat-indicator-dot.is-active-assistant {
	background: #93c5fd;
}

.chat-indicator-dot.is-active-assistant:hover {
	background: #60a5fa;
}

.chat-indicator-dot.is-current {
	background: #60a5fa;
	width: 24px;
}

/* ===========================================
   Input Bar
   =========================================== */

.chat-input-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: auto;
	padding: 8px 12px;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-input-bar button {
	background: none;
	border: none;
	cursor: pointer;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.chat-input-bar button svg {
	width: 20px;
	height: 20px;
}

.chat-input-btn--attach {
	color: #9ca3af;
}

.chat-input-btn--attach:hover {
	color: #4b5563;
}

.chat-input-placeholder {
	flex: 1;
	font-size: 16px;
	color: #9ca3af;
	white-space: nowrap;
}

@media (max-width: 782px) {
	.chat-input-placeholder {
		font-size: 13px;
	}
}

.chat-input-btn--mic {
	color: #9ca3af;
	display: none;
}

.chat-input-btn--mic:hover {
	color: #4b5563;
}

@media (min-width: 783px) {
	.chat-input-btn--mic { display: flex; }
}

.chat-input-btn--send {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: #f3f4f6 !important;
	color: #fb923c;
}
