/* Chat FlipAura - Modern responsive chat UI */

.cfa-wrap {
	--cfa-bg: #020617;
	--cfa-surface: rgba(15, 23, 42, 0.96);
	--cfa-surface-soft: rgba(15, 23, 42, 0.85);
	--cfa-border: rgba(148, 163, 184, 0.35);
	--cfa-border-soft: rgba(51, 65, 85, 0.85);
	--cfa-text: #e5e7eb;
	--cfa-muted: #9ca3af;
	--cfa-accent: #22c55e;
	--cfa-accent-soft: rgba(34, 197, 94, 0.14);
	--cfa-accent-blue: #22d3ee;
	--cfa-danger: #f97373;
	--cfa-shadow: 0 22px 80px rgba(15, 23, 42, 0.95);

	font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", Segoe UI, Roboto, Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
	color: var(--cfa-text);
}

.cfa-shell {
	max-width: 960px;
	margin: 18px auto;
	border-radius: 20px;
	background:
		radial-gradient(900px 380px at 0% 0%, rgba(37, 99, 235, 0.4), transparent 55%),
		radial-gradient(1000px 460px at 100% 0%, rgba(14, 165, 233, 0.4), transparent 60%),
		linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.97));
	border: 1px solid rgba(30, 64, 175, 0.9);
	box-shadow: var(--cfa-shadow);
	backdrop-filter: blur(18px);
	-webkit-backdrop-filter: blur(18px);
	overflow: hidden;
}

.cfa-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 14px;
	border-bottom: 1px solid rgba(30, 64, 175, 0.7);
	background:
		linear-gradient(90deg, rgba(15, 118, 110, 0.2), rgba(37, 99, 235, 0.45), rgba(109, 40, 217, 0.3)),
		linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.96));
}

.cfa-headerLeft {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.cfa-headerRight {
	display: flex;
	align-items: center;
	gap: 10px;
}

.cfa-brand { display: flex; gap: 10px; align-items: center; min-width: 0; }

.cfa-logo {
	width: 34px;
	height: 34px;
	border-radius: 12px;
	position: relative;
	background: radial-gradient(circle at 0 0, rgba(34, 211, 238, 0.35), transparent 60%);
	border: 1px solid rgba(148, 163, 184, 0.55);
	overflow: hidden;
}
.cfa-logo span {
	position: absolute;
	inset: -60%;
	background: conic-gradient(from 160deg, rgba(8, 47, 73, 0.3), rgba(34, 211, 238, 0.7), rgba(59, 130, 246, 0.8), rgba(167, 139, 250, 0.85), rgba(8, 47, 73, 0.3));
	animation: cfaSpin 5.5s linear infinite;
}
.cfa-logo span:nth-child(2){ animation-duration: 7.2s; opacity: 0.55;}
.cfa-logo span:nth-child(3){ animation-duration: 9s; opacity: 0.35;}
.cfa-logo::after{
	content: "";
	position: absolute;
	inset: 4px;
	border-radius: 10px;
	background:
		radial-gradient(circle at 0 0, rgba(34, 197, 94, 0.3), transparent 60%),
		radial-gradient(circle at 100% 100%, rgba(59, 130, 246, 0.3), transparent 60%),
		rgba(15, 23, 42, 0.96);
	border: 1px solid rgba(30, 64, 175, 0.7);
}

@keyframes cfaSpin { to { transform: rotate(360deg); } }

.cfa-titles { min-width: 0; }
.cfa-title {
	font-weight: 750;
	letter-spacing: -0.01em;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.cfa-subtitle {
	font-size: 12px;
	color: var(--cfa-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-top: 2px;
}
.cfa-toggleWrap {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--cfa-muted);
	font-size: 11px;
}

.cfa-switch {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
}
.cfa-switch input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}
.cfa-switchTrack {
	position: relative;
	width: 34px;
	height: 18px;
	border-radius: 999px;
	background: rgba(15, 23, 42, 0.9);
	border: 1px solid rgba(148, 163, 184, 0.7);
	box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.8);
	transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.cfa-switchThumb {
	position: absolute;
	top: 2px;
	left: 3px;
	width: 12px;
	height: 12px;
	border-radius: 999px;
	background: #e5e7eb;
	box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.8), 0 4px 10px rgba(15, 23, 42, 0.9);
	transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.cfa-switch input:checked + .cfa-switchTrack {
	background: linear-gradient(90deg, rgba(34, 197, 94, 0.2), rgba(56, 189, 248, 0.3));
	border-color: rgba(56, 189, 248, 0.9);
	box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.6);
}
.cfa-switch input:checked + .cfa-switchTrack .cfa-switchThumb {
	transform: translateX(14px);
	background: #bbf7d0;
	box-shadow: 0 4px 12px rgba(34, 197, 94, 0.6);
}
.cfa-switchLabel {
	font-size: 11px;
	color: #e5e7eb;
}

.cfa-body {
	background: radial-gradient(circle at 0 0, rgba(30, 64, 175, 0.4), transparent 60%), radial-gradient(circle at 100% 100%, rgba(6, 182, 212, 0.3), transparent 55%), linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.98));
	padding: 0;
}

.cfa-messages {
	height: min(68vh, 640px);
	min-height: 380px;
	overflow: auto;
	padding: 18px 18px 16px;
	scrollbar-width: thin;
	scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
}
.cfa-messages::-webkit-scrollbar { height: 10px; width: 10px; }
.cfa-messages::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.6); border-radius: 999px; }
.cfa-messages::-webkit-scrollbar-track { background: transparent; }

.cfa-row { display: flex; margin: 10px 0; }
.cfa-row.is-user { justify-content: flex-end; }
.cfa-row.is-ai { justify-content: flex-start; }

.cfa-bubble {
	max-width: min(720px, 90%);
	border-radius: 16px;
	padding: 10px 12px;
	border: 1px solid rgba(30, 64, 175, 0.5);
	background: radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.12), transparent 70%), rgba(15, 23, 42, 0.96);
	box-shadow: 0 14px 22px rgba(15, 23, 42, 0.9);
	transform-origin: 50% 100%;
	animation: cfaPop 180ms ease-out;
}
.cfa-row.is-user .cfa-bubble{
	background: linear-gradient(180deg, rgba(30, 64, 175, 0.52), rgba(30, 64, 175, 0.30));
	border-color: rgba(37, 99, 235, 0.9);
}
.cfa-row.is-ai .cfa-bubble{
	background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.96));
	border-color: rgba(30, 64, 175, 0.7);
}

@keyframes cfaPop {
	from { opacity: 0; transform: translateY(8px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cfa-bubble .cfa-role {
	font-size: 11px;
	color: var(--cfa-muted);
	margin-bottom: 4px;
	display: flex;
	gap: 8px;
	align-items: center;
}
.cfa-pill {
	font-size: 11px;
	padding: 2px 8px;
	border-radius: 999px;
	border: 1px solid rgba(30, 64, 175, 0.85);
	background: rgba(15, 23, 42, 0.95);
}
.cfa-text {
	font-size: 14px;
	line-height: 1.55;
	white-space: pre-wrap;
	word-break: break-word;
}

.cfa-footer {
	border-top: 1px solid rgba(30, 64, 175, 0.75);
	background:
		linear-gradient(90deg, rgba(6, 95, 70, 0.3), rgba(37, 99, 235, 0.45), rgba(30, 64, 175, 0.4)),
		linear-gradient(180deg, rgba(15, 23, 42, 0.97), rgba(15, 23, 42, 0.98));
	padding: 10px 12px 12px;
}

.cfa-form { margin: 0; }

.cfa-inputWrap {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 10px;
	align-items: end;
}

.cfa-inputMain {
	position: relative;
}

.cfa-input {
	width: 100%;
	resize: none;
	border-radius: 14px;
	padding: 11px 12px 26px;
	border: 1px solid rgba(30, 64, 175, 0.85);
	background: rgba(15, 23, 42, 0.95);
	color: var(--cfa-text);
	outline: none;
	min-height: 46px;
	max-height: 160px;
	transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}
.cfa-input:focus {
	border-color: rgba(59, 130, 246, 0.95);
	box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.9), 0 0 0 1px rgba(15, 23, 42, 1);
	background: rgba(15, 23, 42, 0.98);
}

.cfa-inputTools {
	position: absolute;
	right: 8px;
	bottom: 6px;
	display: flex;
	align-items: center;
	gap: 4px;
}

.cfa-iconBtn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 999px;
	border: 1px solid rgba(148, 163, 184, 0.6);
	background: radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.22), transparent 55%), rgba(15, 23, 42, 0.95);
	color: var(--cfa-text);
	cursor: pointer;
	transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.cfa-iconBtn:hover {
	transform: translateY(-1px);
	border-color: rgba(59, 130, 246, 0.95);
	box-shadow: 0 6px 16px rgba(15, 23, 42, 0.9);
}
.cfa-iconBtn:active {
	transform: translateY(0) scale(0.97);
}

.cfa-icon {
	width: 15px;
	height: 15px;
	fill: currentColor;
}

.cfa-btn {
	border: 1px solid rgba(255,255,255,0.14);
	background: rgba(15, 23, 42, 0.96);
	color: var(--cfa-text);
	border-radius: 14px;
	padding: 12px 14px;
	cursor: pointer;
	user-select: none;
	transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
	font-weight: 650;
}
.cfa-btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,0.22); }
.cfa-btn:active { transform: translateY(0px) scale(0.99); }
.cfa-btn:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

.cfa-btn-ghost {
	padding: 10px 12px;
	border-radius: 12px;
	background: rgba(15, 23, 42, 0.6);
}
.cfa-btn-ghost:hover {
	background: rgba(15, 23, 42, 0.95);
}

.cfa-btn-primary {
	position: relative;
	border-color: rgba(34, 197, 94, 0.9);
	background:
		radial-gradient(110px 60px at 30% 20%, rgba(74, 222, 128,0.32), transparent 60%),
		linear-gradient(180deg, rgba(16, 185, 129, 0.9), rgba(34, 197, 94, 0.95));
}
.cfa-btn-primary:hover { border-color: rgba(74, 222, 128, 0.9); }

.cfa-spinner {
	display: none;
	width: 16px;
	height: 16px;
	border-radius: 999px;
	border: 2px solid rgba(255,255,255,0.35);
	border-top-color: rgba(255,255,255,0.92);
	animation: cfaSpin 0.9s linear infinite;
	margin-left: 10px;
	vertical-align: middle;
}

.cfa-btn.is-loading .cfa-spinner { display: inline-block; }
.cfa-btn.is-loading .cfa-sendText { opacity: 0.9; }

.cfa-meta {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	margin-top: 8px;
	font-size: 11px;
	color: var(--cfa-muted);
}
.cfa-status { color: rgba(255,255,255,0.72); }
.cfa-status.is-error { color: rgba(239,68,68,0.92); }

/* Modal for saving chat */
.cfa-modal {
	position: fixed;
	inset: 0;
	z-index: 9999;
	pointer-events: none;
	opacity: 0;
	transition: opacity 140ms ease;
}
.cfa-modal.is-open {
	opacity: 1;
	pointer-events: auto;
}
.cfa-modalBack {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.78);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
}
.cfa-modalCard {
	position: relative;
	max-width: 420px;
	margin: 80px auto;
	border-radius: 18px;
	background: radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.18), transparent 60%), rgba(15, 23, 42, 0.98);
	border: 1px solid rgba(30, 64, 175, 0.9);
	box-shadow: 0 18px 80px rgba(15, 23, 42, 1);
	padding: 14px 14px 12px;
}
.cfa-modalHeader {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	margin-bottom: 6px;
}
.cfa-modalTitle {
	font-size: 15px;
	font-weight: 700;
}
.cfa-modalSubtitle {
	font-size: 12px;
	color: var(--cfa-muted);
}
.cfa-modalBody {
	margin-top: 4px;
}
.cfa-field {
	margin-top: 8px;
}
.cfa-label {
	display: block;
	font-size: 11px;
	color: var(--cfa-muted);
	margin-bottom: 4px;
}
.cfa-inputControl {
	width: 100%;
	border-radius: 10px;
	border: 1px solid rgba(30, 64, 175, 0.9);
	background: rgba(15, 23, 42, 0.95);
	color: var(--cfa-text);
	padding: 7px 8px;
	font-size: 13px;
}
.cfa-inputControl:focus {
	outline: none;
	border-color: rgba(59, 130, 246, 0.95);
	box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.9);
}
.cfa-note {
	font-size: 11px;
	color: var(--cfa-muted);
	margin-top: 4px;
}
.cfa-modalFooter {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 10px;
}

/* Mobile polish */
@media (max-width: 600px) {
	.cfa-shell { border-radius: 0; margin: 0 -16px; box-shadow: none; }
	.cfa-messages { height: min(72vh, 540px); min-height: 320px; padding: 14px 10px 12px; }
	.cfa-inputWrap { grid-template-columns: 1fr; }
	.cfa-btn-primary { width: 100%; }
	.cfa-modalCard { margin: 40px 18px; }
}

