/* Training Member Area — AI Soru-Cevap widget'ı
   Renkler eğitim paletinden (--tma-*) türetilir; palet değişince widget de uyar. */

.tma-ai-qa {
	/* Yedek değerler (color-mix desteklemeyen tarayıcılar için) */
	--qa-primary: #16255c;
	--qa-accent: #2563eb;
	--qa-surface: #fff;
	--qa-text: #14213d;
	--qa-muted: #6b7280;
	--qa-line: rgba(22, 37, 92, 0.11);
	--qa-tint: #f6f8fd;
	--qa-tint-2: #eef2fb;
	--qa-ring: rgba(37, 99, 235, 0.16);

	max-width: 760px;
	margin: 2.25rem auto;
	position: relative;
	border: 1px solid var(--qa-line);
	border-radius: 22px;
	background: var(--qa-surface);
	box-shadow:
		0 1px 2px rgba(16, 24, 40, 0.04),
		0 14px 38px -12px rgba(16, 24, 40, 0.14);
	overflow: hidden;
	font-family: var(--tma-font, 'Montserrat', -apple-system, 'Segoe UI', sans-serif);
	font-size: 15px;
	line-height: 1.6;
	color: var(--qa-text);
	-webkit-font-smoothing: antialiased;
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
	.tma-ai-qa {
		--qa-primary: var(--tma-primary, #16255c);
		--qa-accent: var(--tma-secondary, #2563eb);
		--qa-surface: var(--tma-surface, #fff);
		--qa-text: var(--tma-text, #14213d);
		--qa-muted: var(--tma-text-muted, #6b7280);
		--qa-line: color-mix(in srgb, var(--qa-primary) 13%, transparent);
		--qa-tint: color-mix(in srgb, var(--qa-primary) 4%, #fff);
		--qa-tint-2: color-mix(in srgb, var(--qa-accent) 7%, #fff);
		--qa-ring: color-mix(in srgb, var(--qa-accent) 18%, transparent);
	}
}

/* İnce degrade üst çizgi — premium detay */
.tma-ai-qa::after {
	content: "";
	position: absolute;
	inset: 0 0 auto;
	height: 3px;
	background: linear-gradient(90deg, var(--qa-primary), var(--qa-accent));
	opacity: 0.9;
	pointer-events: none;
}

/* ---------- Başlık ---------- */

.tma-ai-qa__head {
	display: grid;
	grid-template-columns: auto 1fr;
	grid-template-rows: auto auto;
	column-gap: 13px;
	align-items: center;
	padding: 20px 22px 16px;
	background: linear-gradient(180deg, var(--qa-tint), var(--qa-surface));
	border-bottom: 1px solid var(--qa-line);
}

/* Marka rozeti — Tasarım ayarlarındaki logo, rozetin içinde hafif saydam */
.tma-ai-qa__brand {
	position: relative;
	grid-row: 1 / span 2;
	width: 44px;
	height: 44px;
	border-radius: 13px;
	background: linear-gradient(140deg, var(--qa-primary), var(--qa-accent));
	color: #fff;
	font-size: 17px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 12px -3px rgba(22, 37, 92, 0.42);
}

/* Logonun alfa kanalı maske olarak kullanılır → rozetin rengi bozulmadan
   logo beyaz ve hafif saydam görünür (her logo dosyasıyla çalışır). */
.tma-ai-qa__brand::after {
	content: "";
	position: absolute;
	inset: 0;
	background: #fff;
	opacity: 0.88;
	-webkit-mask: var(--qa-logo) center / 74% auto no-repeat;
	mask: var(--qa-logo) center / 74% auto no-repeat;
}

/* Logo yüklenmemişse yedek simge */
.tma-ai-qa__brand--icon::after {
	content: "✦";
	position: static;
	background: none;
	opacity: 1;
	-webkit-mask: none;
	mask: none;
}

.tma-ai-qa__head h3 {
	grid-column: 2;
	margin: 0;
	font-size: 17.5px;
	font-weight: 650;
	letter-spacing: -0.012em;
	line-height: 1.3;
	color: var(--qa-primary);
}

.tma-ai-qa__head p {
	grid-column: 2;
	margin: 3px 0 0;
	color: var(--qa-muted);
	font-size: 13px;
	line-height: 1.5;
}

/* ---------- Mesaj akışı ---------- */

.tma-ai-qa__messages {
	max-height: 460px;
	overflow-y: auto;
	overscroll-behavior: contain;
	scroll-behavior: smooth;
	padding: 18px 20px 6px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.tma-ai-qa__messages:empty {
	display: none;
}

.tma-ai-qa__messages::-webkit-scrollbar { width: 8px; }
.tma-ai-qa__messages::-webkit-scrollbar-thumb {
	background: var(--qa-line);
	border-radius: 99px;
}

.tma-ai-qa__msg {
	max-width: 86%;
	padding: 12px 16px;
	border-radius: 18px;
	word-wrap: break-word;
	animation: tmaAiIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes tmaAiIn {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

.tma-ai-qa__msg--user {
	align-self: flex-end;
	background: linear-gradient(135deg, var(--qa-primary), var(--qa-accent));
	color: #fff;
	border-bottom-right-radius: 6px;
	box-shadow: 0 6px 16px -8px rgba(22, 37, 92, 0.6);
}

.tma-ai-qa__msg--bot {
	align-self: flex-start;
	background: var(--qa-tint-2);
	border: 1px solid var(--qa-line);
	color: var(--qa-text);
	border-bottom-left-radius: 6px;
}

.tma-ai-qa__msg--error {
	background: #fdf1f1;
	border-color: rgba(160, 40, 40, 0.18);
	color: #8a1f1f;
}

/* Yazıyor animasyonu */
.tma-ai-qa__msg--loading {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	color: var(--qa-muted);
	font-size: 13.5px;
}

.tma-ai-qa__dots {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-left: 7px;
}

.tma-ai-qa__dots i {
	font-size: 0;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	display: inline-block;
	animation: tmaAiBlink 1.25s infinite ease-in-out;
}

.tma-ai-qa__dots i:nth-child(2) { animation-delay: 0.18s; }
.tma-ai-qa__dots i:nth-child(3) { animation-delay: 0.36s; }

@keyframes tmaAiBlink {
	0%, 100% { opacity: 0.22; transform: translateY(0); }
	50%      { opacity: 1; transform: translateY(-2px); }
}

/* ---------- Kaynak kartları ---------- */

.tma-ai-qa__sources {
	margin-top: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.tma-ai-qa__source {
	display: flex;
	align-items: center;
	gap: 11px;
	width: 100%;
	text-align: left;
	padding: 10px 12px;
	border: 1px solid var(--qa-line);
	border-radius: 14px;
	background: var(--qa-surface);
	cursor: pointer;
	font-family: inherit;
	transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.tma-ai-qa__source:hover {
	border-color: var(--qa-accent);
	transform: translateY(-1px);
	box-shadow: 0 8px 20px -12px rgba(16, 24, 40, 0.5);
}

.tma-ai-qa__source-play {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: linear-gradient(140deg, var(--qa-primary), var(--qa-accent));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 10px;
	padding-left: 2px;
	transition: transform 0.18s ease;
}

.tma-ai-qa__source:hover .tma-ai-qa__source-play { transform: scale(1.07); }

.tma-ai-qa__source-body {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.tma-ai-qa__source-body strong {
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--qa-text);
}

.tma-ai-qa__source-body em {
	font-style: normal;
	font-size: 12px;
	color: var(--qa-muted);
	margin-top: 1px;
}

/* ---------- Soru kutusu (composer) ---------- */

.tma-ai-qa__form {
	position: relative;
	display: block;
	padding: 14px 16px 16px;
	border-top: 1px solid var(--qa-line);
	background: var(--qa-surface);
}

.tma-ai-qa__form textarea {
	display: block;
	width: 100%;
	box-sizing: border-box;
	resize: none;
	border: 1.5px solid var(--qa-line);
	border-radius: 16px;
	background: var(--qa-tint);
	padding: 15px 112px 15px 17px;
	font: inherit;
	color: var(--qa-text);
	min-height: 56px;
	max-height: 168px;
	line-height: 1.5;
	transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.tma-ai-qa__form textarea::placeholder {
	color: var(--qa-muted);
	opacity: 0.85;
}

.tma-ai-qa__form textarea:focus {
	outline: none;
	background: var(--qa-surface);
	border-color: var(--qa-accent);
	box-shadow: 0 0 0 4px var(--qa-ring);
}

.tma-ai-qa__form button {
	position: absolute;
	right: 25px;
	bottom: 25px;
	border: 0;
	border-radius: 12px;
	background: linear-gradient(135deg, var(--qa-primary), var(--qa-accent));
	color: #fff;
	height: 38px;
	padding: 0 20px;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.01em;
	cursor: pointer;
	box-shadow: 0 4px 12px -4px rgba(22, 37, 92, 0.55);
	transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.tma-ai-qa__form button:hover:not(:disabled) {
	transform: translateY(-1px);
	box-shadow: 0 8px 18px -6px rgba(22, 37, 92, 0.6);
}

.tma-ai-qa__form button:active:not(:disabled) { transform: translateY(0); }

.tma-ai-qa__form button:disabled {
	opacity: 0.4;
	cursor: default;
	box-shadow: none;
}

.tma-ai-qa__note {
	margin: 0;
	padding: 0 18px 16px;
	font-size: 11.5px;
	line-height: 1.55;
	color: var(--qa-muted);
	opacity: 0.9;
}

/* ---------- Stil varyantları ---------- */

/* SADE: tek satırlık zarif soru alanı — başlık ve not yok */
.tma-ai-qa--sade { max-width: 660px; }
.tma-ai-qa--sade::after { display: none; }
.tma-ai-qa--sade .tma-ai-qa__form { border-top: 0; padding: 12px; }
.tma-ai-qa--sade .tma-ai-qa__form textarea {
	border-color: transparent;
	background: var(--qa-tint);
	min-height: 54px;
}
.tma-ai-qa--sade .tma-ai-qa__form button { right: 21px; bottom: 21px; }
.tma-ai-qa--sade .tma-ai-qa__messages { padding: 18px 18px 2px; }

/* AÇIKLAYICI: başlık + özellik satırları + örnek soru çipleri */
.tma-ai-qa__features {
	list-style: none;
	margin: 0;
	padding: 15px 22px 15px;
	display: grid;
	gap: 9px;
	border-bottom: 1px solid var(--qa-line);
}

.tma-ai-qa__features li {
	position: relative;
	padding-left: 27px;
	font-size: 13px;
	line-height: 1.55;
	color: var(--qa-muted);
}

.tma-ai-qa__features li::before {
	content: "✓";
	position: absolute;
	left: 0;
	top: 1px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: linear-gradient(140deg, var(--qa-primary), var(--qa-accent));
	color: #fff;
	font-size: 9px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.tma-ai-qa__examples {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 15px 22px 4px;
	overflow-x: auto;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.tma-ai-qa__examples::-webkit-scrollbar { display: none; }

.tma-ai-qa__chip {
	flex: 0 0 auto;
	appearance: none;
	border: 1px solid var(--qa-line);
	background: var(--qa-tint);
	color: var(--qa-primary);
	font-family: inherit;
	font-size: 12.5px;
	font-weight: 550;
	padding: 8px 15px;
	border-radius: 999px;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.tma-ai-qa__chip:hover {
	background: linear-gradient(135deg, var(--qa-primary), var(--qa-accent));
	border-color: transparent;
	color: #fff;
	transform: translateY(-1px);
}

/* ---------- Duyarlı ---------- */

@media (max-width: 600px) {
	.tma-ai-qa {
		border-radius: 18px;
		margin: 1.25rem 0;
	}
	.tma-ai-qa__msg { max-width: 94%; }
	.tma-ai-qa__head { padding: 17px 16px 14px; }
	.tma-ai-qa__messages { padding: 15px 14px 4px; }
	.tma-ai-qa__form { padding: 12px 12px 14px; }
	.tma-ai-qa__form textarea { padding-right: 100px; }
	.tma-ai-qa__form button { right: 21px; bottom: 23px; padding: 0 17px; }
	.tma-ai-qa__features,
	.tma-ai-qa__examples { padding-left: 16px; padding-right: 16px; }
	.tma-ai-qa__examples { flex-wrap: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
	.tma-ai-qa__msg { animation: none; }
	.tma-ai-qa__dots i { animation: none; opacity: 0.55; }
	.tma-ai-qa *,
	.tma-ai-qa *::before { transition: none !important; }
}

/* Geri yüklenen sohbet şeridi */
.tma-ai-qa__restored {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 7px 12px;
	margin-bottom: 2px;
	border-radius: 999px;
	background: var(--qa-tint);
	border: 1px solid var(--qa-line);
	font-size: 12px;
	color: var(--qa-muted);
	flex: 0 0 auto;
}
.tma-ai-qa__restored button {
	border: 0;
	background: none;
	padding: 0;
	font: inherit;
	font-size: 12px;
	color: var(--qa-accent);
	text-decoration: underline;
	cursor: pointer;
	white-space: nowrap;
}
.tma-ai-qa__restored button:hover { color: var(--qa-primary); }
