/**
 * Captain Sky sohbet widget'ı (sağ alt köşe).
 *
 * Renkler eklenti ayarlarından CSS değişkenleriyle gelir (kapsayıcı
 * #ifc-chat-root üzerinde): --ifc-chat-primary / --ifc-chat-on-primary.
 *
 * Masaüstünde pencere başlıktan sürüklenip taşınabilir ve sağ alt köşeden
 * yeniden boyutlandırılabilir (JS + CSS resize). Mobilde (≤640px) pencere
 * tam ekran açılır; sürükleme/boyutlandırma kapalıdır.
 */

#ifc-chat-root {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}
#ifc-chat-root * {
	box-sizing: border-box;
}

/* ---- Açma balonu ----
 * Buton stilleri tema `button` kurallarına karşı ID öncelikli + !important. */
#ifc-chat-root .ifc-chat-bubble {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 60px !important;
	height: 60px !important;
	min-width: 0 !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: var(--ifc-chat-primary, #1e73be) !important;
	background: linear-gradient(135deg, var(--ifc-chat-primary, #1e73be), color-mix(in srgb, var(--ifc-chat-primary, #1e73be) 72%, #000)) !important;
	color: var(--ifc-chat-on-primary, #fff) !important;
	line-height: 0 !important;
	cursor: pointer;
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3) !important;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}
#ifc-chat-root .ifc-chat-bubble:hover {
	transform: translateY(-2px) scale(1.06);
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35) !important;
}
#ifc-chat-root .ifc-chat-bubble svg {
	display: block;
	width: 28px !important;
	height: 28px !important;
	fill: var(--ifc-chat-on-primary, #fff) !important;
	pointer-events: none;
}

/* ---- Pencere ---- */
.ifc-chat-window {
	position: absolute;
	right: 0;
	bottom: 74px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 120px);
	min-width: 300px;
	min-height: 380px;
	display: none;
	flex-direction: column;
	background: #fff;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 12px 48px rgba(15, 23, 42, 0.32), 0 2px 8px rgba(15, 23, 42, 0.12);
	resize: both; /* sağ alt köşeden boyutlandırma (masaüstü) */
}
#ifc-chat-root.ifc-chat-open .ifc-chat-window {
	display: flex;
}

/* Büyütülmüş mod: sağa yaslı geniş pencere (sürüklenebilir kalır). */
#ifc-chat-root.ifc-chat-full .ifc-chat-window {
	position: fixed;
	top: 16px;
	right: 16px;
	bottom: 16px;
	left: auto;
	width: min(760px, calc(100vw - 32px));
	height: auto;
	max-width: none;
	max-height: none;
}

/* ---- Başlık ---- */
.ifc-chat-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 12px 12px 14px;
	background: var(--ifc-chat-primary, #1e73be);
	background: linear-gradient(135deg, var(--ifc-chat-primary, #1e73be), color-mix(in srgb, var(--ifc-chat-primary, #1e73be) 74%, #000));
	color: var(--ifc-chat-on-primary, #fff);
	flex: 0 0 auto;
	cursor: move;
	user-select: none;
	touch-action: none;
}
.ifc-chat-header .ifc-chat-avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35);
	flex: 0 0 auto;
	position: relative;
}
.ifc-chat-header .ifc-chat-avatar svg {
	width: 20px;
	height: 20px;
	fill: currentColor;
}
/* Çevrimiçi noktası */
.ifc-chat-header .ifc-chat-avatar::after {
	content: "";
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #34d399;
	border: 2px solid var(--ifc-chat-primary, #1e73be);
}
.ifc-chat-header .ifc-chat-titles {
	flex: 1 1 auto;
	min-width: 0; /* başlık uzunsa üç noktayla kısalt, butonlara taşma */
}
.ifc-chat-header .ifc-chat-title {
	font-weight: 700;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.ifc-chat-header .ifc-chat-subtitle {
	font-size: 12px;
	opacity: 0.85;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Başlık ikon butonları (yeni sohbet / büyüt / kapat).
 * Tema `button` stillerini ezmek için ID öncelikli seçici + !important:
 * temalar butonlara padding/min-width/renk basabiliyor. */
#ifc-chat-root .ifc-chat-header .ifc-chat-icon {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 32px !important;
	height: 32px !important;
	min-width: 0 !important;
	min-height: 0 !important;
	flex: 0 0 auto;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 8px !important;
	background: rgba(255, 255, 255, 0.14) !important;
	color: var(--ifc-chat-on-primary, #fff) !important;
	line-height: 0 !important;
	box-shadow: none !important;
	cursor: pointer;
	transition: background 0.15s ease;
}
#ifc-chat-root .ifc-chat-header .ifc-chat-icon:hover {
	background: rgba(255, 255, 255, 0.28) !important;
}
#ifc-chat-root .ifc-chat-header .ifc-chat-icon svg {
	display: block;
	width: 17px !important;
	height: 17px !important;
	fill: var(--ifc-chat-on-primary, #fff) !important;
	pointer-events: none;
}

/* ---- Mesaj listesi ---- */
.ifc-chat-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px 14px;
	background: linear-gradient(180deg, #f2f5f9 0%, #e9eef5 100%);
	scrollbar-width: thin;
	scrollbar-color: #b9c2cd transparent;
}
.ifc-chat-body::-webkit-scrollbar {
	width: 6px;
}
.ifc-chat-body::-webkit-scrollbar-thumb {
	background: #b9c2cd;
	border-radius: 3px;
}
.ifc-chat-msg {
	display: flex;
	margin-bottom: 12px;
	animation: ifc-chat-in 0.18s ease;
}
@keyframes ifc-chat-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}
.ifc-chat-msg.ifc-user {
	justify-content: flex-end;
}
.ifc-chat-msg .ifc-chat-text {
	max-width: 84%;
	padding: 10px 14px;
	border-radius: 16px;
	white-space: pre-wrap;
	word-break: break-word;
	font-size: 14px;
}
.ifc-chat-msg.ifc-bot .ifc-chat-text {
	background: #fff;
	border: 1px solid #e4e9ef;
	border-bottom-left-radius: 6px;
	color: #1f2937;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.ifc-chat-msg.ifc-user .ifc-chat-text {
	background: var(--ifc-chat-primary, #1e73be);
	background: linear-gradient(135deg, var(--ifc-chat-primary, #1e73be), color-mix(in srgb, var(--ifc-chat-primary, #1e73be) 78%, #000));
	color: var(--ifc-chat-on-primary, #fff);
	border-bottom-right-radius: 6px;
	box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}
.ifc-chat-msg.ifc-error .ifc-chat-text {
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #991b1b;
}
.ifc-chat-msg .ifc-chat-text a {
	color: inherit;
	text-decoration: underline;
	word-break: break-all;
}
.ifc-chat-msg.ifc-bot .ifc-chat-text a {
	color: var(--ifc-chat-primary, #1e73be);
}
.ifc-chat-msg .ifc-chat-text b {
	font-weight: 700;
}

/* Mesaj saati (balonun içinde, sağ altta) */
.ifc-chat-msg .ifc-chat-time {
	font-size: 10.5px;
	line-height: 1;
	opacity: 0.55;
	margin-top: 6px;
	text-align: right;
}

/* Yazıyor... animasyonu */
.ifc-chat-typing .ifc-chat-text {
	display: inline-flex;
	gap: 5px;
	align-items: center;
	padding: 13px 16px;
}
.ifc-chat-typing .ifc-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #94a3b8;
	animation: ifc-chat-blink 1.2s infinite both;
}
.ifc-chat-typing .ifc-dot:nth-child(2) { animation-delay: 0.2s; }
.ifc-chat-typing .ifc-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ifc-chat-blink {
	0%, 80%, 100% { opacity: 0.25; transform: scale(0.9); }
	40% { opacity: 1; transform: scale(1); }
}

/* ---- Sohbet öncesi form ---- */
.ifc-chat-intro {
	flex: 1 1 auto;
	padding: 22px 18px;
	overflow-y: auto;
	background: linear-gradient(180deg, #f2f5f9 0%, #e9eef5 100%);
}
.ifc-chat-intro p {
	margin: 0 0 14px;
	color: #374151;
}
.ifc-chat-intro label {
	display: block;
	margin-bottom: 12px;
	font-size: 13px;
	color: #111827;
}
.ifc-chat-intro label span {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
}
.ifc-chat-intro label span em {
	font-weight: 400;
	font-style: normal;
	color: #6b7280;
}
.ifc-chat-intro input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	font-size: 14px;
	background: #fff;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ifc-chat-intro input:focus {
	outline: none;
	border-color: var(--ifc-chat-primary, #1e73be);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--ifc-chat-primary, #1e73be) 18%, transparent);
}
.ifc-chat-intro .ifc-chat-form-error {
	color: #dc2626;
	font-size: 12.5px;
	margin: 0 0 10px;
	min-height: 16px;
}
#ifc-chat-root .ifc-chat-intro button {
	display: block !important;
	width: 100% !important;
	margin: 0 !important;
	padding: 12px !important;
	border: 0 !important;
	border-radius: 10px !important;
	background: var(--ifc-chat-primary, #1e73be) !important;
	background: linear-gradient(135deg, var(--ifc-chat-primary, #1e73be), color-mix(in srgb, var(--ifc-chat-primary, #1e73be) 74%, #000)) !important;
	color: var(--ifc-chat-on-primary, #fff) !important;
	font-size: 15px !important;
	font-weight: 600;
	line-height: 1.3 !important;
	cursor: pointer;
	box-shadow: 0 4px 14px color-mix(in srgb, var(--ifc-chat-primary, #1e73be) 35%, transparent) !important;
	transition: transform 0.12s ease;
}
#ifc-chat-root .ifc-chat-intro button:hover {
	transform: translateY(-1px);
}
#ifc-chat-root .ifc-chat-intro button:disabled {
	opacity: 0.6;
	cursor: wait;
	transform: none;
}

/* ---- Giriş alanı ---- */
.ifc-chat-input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #e5e9ef;
	background: #fff;
	flex: 0 0 auto;
}
.ifc-chat-input textarea {
	flex: 1;
	resize: none;
	border: 1px solid #d1d5db;
	border-radius: 12px;
	padding: 9px 12px;
	font-size: 14px;
	font-family: inherit;
	line-height: 1.45;
	max-height: 96px;
	min-height: 40px;
	background: #f8fafc;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.ifc-chat-input textarea:focus {
	outline: none;
	background: #fff;
	border-color: var(--ifc-chat-primary, #1e73be);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--ifc-chat-primary, #1e73be) 18%, transparent);
}
/* Gönder butonu — tema `button` stillerine karşı sertleştirilmiş. */
#ifc-chat-root .ifc-chat-input button {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 40px !important;
	height: 40px !important;
	min-width: 0 !important;
	min-height: 0 !important;
	flex: 0 0 auto;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: var(--ifc-chat-primary, #1e73be) !important;
	background: linear-gradient(135deg, var(--ifc-chat-primary, #1e73be), color-mix(in srgb, var(--ifc-chat-primary, #1e73be) 74%, #000)) !important;
	color: var(--ifc-chat-on-primary, #fff) !important;
	line-height: 0 !important;
	cursor: pointer;
	box-shadow: 0 3px 10px color-mix(in srgb, var(--ifc-chat-primary, #1e73be) 35%, transparent) !important;
	transition: transform 0.12s ease;
}
#ifc-chat-root .ifc-chat-input button:hover {
	transform: scale(1.07);
}
#ifc-chat-root .ifc-chat-input button:disabled {
	opacity: 0.6;
	cursor: wait;
	transform: none;
}
#ifc-chat-root .ifc-chat-input button svg {
	display: block;
	width: 18px !important;
	height: 18px !important;
	fill: var(--ifc-chat-on-primary, #fff) !important;
	pointer-events: none;
}

/* ---- Mobil: tam ekran sohbet ---- */
@media (max-width: 640px) {
	#ifc-chat-root {
		right: 14px;
		bottom: 14px;
	}
	.ifc-chat-window,
	#ifc-chat-root.ifc-chat-full .ifc-chat-window {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 100%;
		max-width: none;
		max-height: none;
		min-width: 0;
		min-height: 0;
		border-radius: 0;
		resize: none; /* mobilde boyutlandırma yok */
	}
	/* Pencere tüm ekranı kapladığından balonu gizle. */
	#ifc-chat-root.ifc-chat-open .ifc-chat-bubble {
		display: none;
	}
	/* Zaten tam ekran: büyüt butonu gereksiz. */
	.ifc-chat-header .ifc-chat-fullbtn {
		display: none;
	}
	.ifc-chat-header {
		cursor: default;
		padding-top: max(12px, env(safe-area-inset-top));
	}
	.ifc-chat-input {
		padding-bottom: max(10px, env(safe-area-inset-bottom));
	}
	/* iOS odaklanınca yakınlaştırmasın diye 16px. */
	.ifc-chat-input textarea,
	.ifc-chat-intro input {
		font-size: 16px;
	}
	.ifc-chat-msg .ifc-chat-text {
		max-width: 88%;
		font-size: 15px;
	}
}
