/* ═══════════════════════════════════════════════════════════════
   Newstour AI Asistan — W4: Canlı Sesli Görüşme (Gemini Live) Stilleri
   #nai-chat-window'un içine JS ile eklenir (bkz. public/js/live-voice.js);
   mobil/responsive/safe-area davranışını sohbet penceresinden miras alır.
   Dokunmatik hedef ≥44px, prefers-reduced-motion destekli.
   ═══════════════════════════════════════════════════════════════ */

/* Sesli görüşme aktifken metin sohbeti bileşenlerini gizle. */
#nai-chat-window.nai-live-active #nai-chat-messages,
#nai-chat-window.nai-live-active #nai-typing-indicator,
#nai-chat-window.nai-live-active #nai-chat-input-area {
	display: none;
}

#nai-live-voice-panel {
	display: none;
	position: relative; /* köşe video önizlemesi (#nai-live-video-preview-wrap) için */
	flex-direction: column;
	flex: 1;
	min-height: 0;
	background: #f7f9fc;
}
#nai-chat-window.nai-live-active #nai-live-voice-panel {
	display: flex;
}

/* ── "Canlı" Giriş Butonu (chat-widget.js tarafından header'a eklenir) ──
   0.7.0 fix — eskiden ikon-only bir mikrofon butonuydu (kullanıcı ne
   olduğunu anlamıyordu); artık yanıp sönen bir nokta + "Canlı" metniyle
   kendini açıklayan bir pil (badge) şeklinde. Dokunmatik hedef ≥44px:
   `min-height` TEK BAŞINA yetmez, `inline-flex` + `align-items:center` ile
   metin dikey ortalanır (bkz. proje geçmişindeki hizalama hatası dersi). */
#nai-live-voice-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 0 14px;
	border-radius: 20px;
	border: none;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	transition: background-color 0.2s ease;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
}
#nai-live-voice-btn:hover {
	background: rgba(255, 255, 255, 0.28);
}
#nai-live-voice-btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}
.nai-live-btn-dot {
	width: 7px;
	height: 7px;
	min-width: 7px;
	border-radius: 50%;
	background: #4ade80;
	animation: naiLiveBtnDotPulse 1.8s ease infinite;
}
@keyframes naiLiveBtnDotPulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.4; }
}
.nai-live-btn-label {
	line-height: 1;
}

/* ── Durum Satırı ── */
#nai-live-status-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	background: #fff;
	flex-shrink: 0;
}
#nai-live-status-dot {
	width: 8px;
	height: 8px;
	min-width: 8px;
	border-radius: 50%;
	background: #9ca3af;
}
[data-nai-live-phase="live"] #nai-live-status-dot {
	background: #4ade80;
	animation: naiLivePulseDot 1.6s ease infinite;
}
[data-nai-live-phase="connecting"] #nai-live-status-dot {
	background: var(--nai-primary, #5191fa);
	animation: naiLivePulseDot 1s ease infinite;
}
[data-nai-live-phase="error"] #nai-live-status-dot {
	background: #f87171;
}
@keyframes naiLivePulseDot {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.4; }
}
#nai-live-status-text {
	flex: 1;
	min-width: 0;
	font-size: 0.8125rem;
	color: #4b5563;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
#nai-live-close {
	width: 32px;
	height: 32px;
	min-width: 44px;
	min-height: 44px;
	border-radius: 50%;
	border: none;
	background: transparent;
	color: #6b7280;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
#nai-live-close:hover {
	background: rgba(0, 0, 0, 0.06);
}
#nai-live-close svg {
	width: 16px;
	height: 16px;
}

/* ── KVKK Onay Ekranı ── */
#nai-live-consent {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 12px;
	padding: 24px 20px;
	overflow-y: auto;
}
#nai-live-consent-title {
	margin: 0;
	font-weight: 700;
	font-size: 0.95rem;
	color: #1f2937;
	text-align: center;
}
#nai-live-consent-text {
	margin: 0;
	font-size: 0.8125rem;
	line-height: 1.6;
	color: #4b5563;
	text-align: center;
}
#nai-live-consent-actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 8px;
}
#nai-live-consent-accept,
#nai-live-consent-cancel {
	min-height: 44px;
	border-radius: 22px;
	border: none;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
#nai-live-consent-accept {
	background: var(--nai-primary, #5191fa);
	color: #fff;
}
#nai-live-consent-accept:hover {
	opacity: 0.92;
}
#nai-live-consent-cancel {
	background: transparent;
	color: #6b7280;
}
#nai-live-consent-cancel:hover {
	background: rgba(0, 0, 0, 0.05);
}

/* ── Canlı Sahne (nabız animasyonu + altyazı) ── */
#nai-live-stage {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 20px 16px;
	gap: 16px;
	overflow: hidden;
}

#nai-live-orb {
	position: relative;
	width: 84px;
	height: 84px;
	min-height: 84px;
	border-radius: 50%;
	background: var(--nai-primary, #5191fa);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	/* 0.7.0 — ses dalgası topu: JS (bkz. public/js/live-voice.js
	   updateOrbScale()) her requestAnimationFrame'de bu custom property'i
	   asistan sesinin ANLIK genliğine göre günceller (AnalyserNode + RMS +
	   yumuşatma). Analyser kurulamazsa (fail-open) bu değişken hiç
	   set edilmez → varsayılan 1'de sabit kalır, aşağıdaki sabit-ritim
	   `.nai-live-speaking` animasyonu devreye girer. */
	transform: scale(var(--nai-orb-scale, 1));
	transition: transform 0.08s linear;
}
.nai-live-wave {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--nai-primary, #5191fa);
	opacity: 0;
	animation: naiLiveWave 2.2s ease-out infinite;
}
.nai-live-wave:nth-child(2) { animation-delay: 0.6s; }
.nai-live-wave:nth-child(3) { animation-delay: 1.2s; }
@keyframes naiLiveWave {
	0% { transform: scale(1); opacity: 0.55; }
	100% { transform: scale(1.9); opacity: 0; }
}
/* FAIL-OPEN — AnalyserNode kurulamadıysa (`.nai-live-analyser-active` YOK)
   asistan konuşurken orb eskisi gibi sabit ritimde büyüyüp küçülür (bu kural
   `.nai-live-analyser-active` VARKEN devre dışı kalır — JS'in `--nai-orb-scale`
   ile verdiği GERÇEK genlik tepkisiyle ÇAKIŞMASIN diye). */
#nai-live-voice-panel.nai-live-speaking:not(.nai-live-analyser-active) #nai-live-orb {
	animation: naiLiveOrbPulse 0.9s ease-in-out infinite;
}
@keyframes naiLiveOrbPulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.08); }
}

#nai-live-transcript {
	width: 100%;
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: #374151;
}
.nai-live-line {
	margin: 0;
	word-break: break-word;
}
.nai-live-line-user strong {
	color: var(--nai-primary, #5191fa);
}
.nai-live-line-ai strong {
	color: var(--nai-secondary, #1a2e50);
}

#nai-live-retry {
	min-height: 44px;
	padding: 0 20px;
	border-radius: 22px;
	border: none;
	background: var(--nai-secondary, #1a2e50);
	color: #fff;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	flex-shrink: 0;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
#nai-live-retry:hover {
	opacity: 0.92;
}

/* 0.7.0 — "Görüşmeyi Bitir": görüşme yalnızca ✕ ile bitiyordu, kullanıcı
   bulamıyordu. Belirgin, uyarı (kırmızı) tonunda bir buton — dokunmatik
   hedef ≥44px: `min-height` TEK BAŞINA metni dikey ortalamaz, bu yüzden
   `inline-flex` + `align-items:center` ile ortalanır. */
#nai-live-end-call {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0 24px;
	border-radius: 22px;
	border: none;
	background: #dc2626;
	color: #fff;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	flex-shrink: 0;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.15s ease;
}
#nai-live-end-call:hover {
	background: #b91c1c;
}
#nai-live-end-call:focus-visible {
	outline: 2px solid #b91c1c;
	outline-offset: 2px;
}

/* ── FAZ 9: Kamera/Ekran Paylaşımı Kontrolleri ──
   Azamol LiveCall.tsx mantığının Newstour düz-JS relay mimarisine taşınmış
   hali; mevcut ses paneliyle (mikrofon durum satırı) görsel tutarlı. */
#nai-live-video-controls {
	display: flex;
	gap: 10px;
	flex-shrink: 0;
}
#nai-live-camera-btn,
#nai-live-screen-btn {
	width: 40px;
	height: 40px;
	min-width: 44px;
	min-height: 44px;
	border-radius: 50%;
	border: none;
	background: rgba(0, 0, 0, 0.06);
	color: #4b5563;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
#nai-live-camera-btn svg,
#nai-live-screen-btn svg {
	width: 18px;
	height: 18px;
}
#nai-live-camera-btn:hover,
#nai-live-screen-btn:hover {
	background: rgba(0, 0, 0, 0.1);
}
#nai-live-camera-btn:focus-visible,
#nai-live-screen-btn:focus-visible {
	outline: 2px solid var(--nai-primary, #5191fa);
	outline-offset: 2px;
}
#nai-live-camera-btn:disabled,
#nai-live-screen-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}
/* Aktif (açık) kamera/ekran butonu — mutually exclusive, diğeri disabled olur. */
.nai-live-video-btn-active {
	background: var(--nai-primary, #5191fa);
	color: #fff;
}
.nai-live-video-btn-active:hover {
	background: var(--nai-primary, #5191fa);
	opacity: 0.9;
}
/* Mobil/desteklenmeyen tarayıcıda ekran paylaşım butonu PASİF görünür (native
   disabled DEĞİL — bkz. live-voice.js) — dokununca dürüst bir not gösterilir. */
.nai-live-video-btn-unsupported {
	opacity: 0.4;
}

#nai-live-video-note {
	margin: 0;
	max-width: 90%;
	flex-shrink: 0; /* Opus review fix (düşük #7) — dar yükseklikte kırpılmasın */
	font-size: 0.75rem;
	line-height: 1.4;
	color: #9a3412;
	background: #fff7ed;
	border: 1px solid #fed7aa;
	border-radius: 8px;
	padding: 6px 10px;
	text-align: center;
}

/* Kamera/ekran önizlemesi — panelin sağ üst köşesinde sabit küçük kare
   (kaynak, DOM-İÇİ <video> — decode/kare-yakalama burada olur, bkz.
   live-voice.js sendVideoFrame). */
#nai-live-video-preview-wrap {
	position: absolute;
	top: 52px; /* durum satırının hemen altı */
	right: 12px;
	width: 96px;
	height: 72px;
	border-radius: 10px;
	overflow: hidden;
	border: 2px solid #fff;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
	background: #000;
	z-index: 5;
}
#nai-live-video-preview {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ── prefers-reduced-motion: tüm nabız/dalga animasyonlarını kapat ── */
@media (prefers-reduced-motion: reduce) {
	#nai-live-voice-panel,
	#nai-live-voice-panel * {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
