/*
 * Modern WhatsApp Butonu — sağ alt WhatsApp butonu ve sohbet kutusu
 * İki stil: .mowa--classic (WhatsApp yeşili) ve .mowa--theme (sitenin tema renkleri).
 * Renkler değişkenlerdir; eklenti ayarlarında özel renk seçilirse satır içi olarak ezilir.
 */
.mowa {
	--mowa-accent: #25d366;
	--mowa-accent-dark: #1da851;
	--mowa-on-accent: #fff;
	--mowa-head-bg: var(--mowa-accent);
	--mowa-head-text: #fff;
	--mowa-head-muted: rgba(255, 255, 255, .85);
	--mowa-body-bg: #f6f3ee;
	--mowa-dot: rgba(0, 0, 0, .045);
	--mowa-text: #4a4a4a;
	--mowa-radius: 18px;
	--mowa-cta-radius: 30px;
	--mowa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mowa-offset: 20px;
	position: fixed;
	right: var(--mowa-offset);
	bottom: var(--mowa-offset);
	z-index: 9990;
	font-family: var(--mowa-font);
	font-size: 16px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	pointer-events: none;
}

/* Tema stili: sitenin theme.json renklerini kullanır (primary, primary-dark, dark). */
.mowa--theme {
	--mowa-accent: var(--wp--preset--color--primary, #1f74e0);
	--mowa-accent-dark: var(--wp--preset--color--primary-dark, #1557b8);
	--mowa-head-bg: var(--wp--preset--color--dark, var(--wp--preset--color--surface, #0b151c));
	--mowa-head-muted: rgba(255, 255, 255, .62);
	--mowa-body-bg: #f4f6f9;
	--mowa-dot: rgba(15, 33, 73, .06);
	--mowa-text: #2b3442;
	--mowa-radius: 12px;
	--mowa-cta-radius: 8px;
	--mowa-font: inherit;
}

.mowa--left { right: auto; left: var(--mowa-offset); }
.mowa *, .mowa *::before, .mowa *::after { box-sizing: border-box; }
.mowa svg { display: block; }

/* ---------- Yuvarlak buton ---------- */
.mowa__btn {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	margin-left: auto;
	border: 0;
	border-radius: 50%;
	background: var(--mowa-accent);
	color: var(--mowa-on-accent);
	box-shadow: 1px 6px 24px rgba(7, 94, 84, .24);
	cursor: pointer;
	text-decoration: none;
	pointer-events: auto;
	opacity: 0;
	transform: scale(0);
	transition: transform .3s cubic-bezier(.18, .89, .32, 1.28), opacity .2s, background-color .2s, box-shadow .2s;
}
.mowa--theme .mowa__btn {
	box-shadow: 0 8px 24px color-mix(in srgb, var(--mowa-accent) 45%, transparent), 0 2px 6px rgba(0, 0, 0, .2);
}
.mowa--left .mowa__btn { margin-left: 0; }
.mowa--show .mowa__btn { opacity: 1; transform: scale(1); }
.mowa__btn:hover { background: var(--mowa-accent-dark); }
.mowa__btn:focus-visible, .mowa__close:focus-visible, .mowa__cta:focus-visible {
	outline: 3px solid var(--mowa-accent-dark);
	outline-offset: 3px;
}
.mowa__btn svg { width: 34px; height: 34px; fill: currentColor; transition: transform .25s, opacity .2s; }
.mowa__btn .mowa__ico-send { position: absolute; width: 26px; height: 26px; opacity: 0; transform: rotate(-90deg) scale(.4); }
.mowa--open .mowa__btn .mowa__ico-wa { opacity: 0; transform: rotate(90deg) scale(.4); }
.mowa--open .mowa__btn .mowa__ico-send { opacity: 1; transform: none; }

/* Dikkat çeken halka */
.mowa__btn::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--mowa-accent);
	opacity: 0;
	pointer-events: none;
}
.mowa--show:not(.mowa--open) .mowa__btn::before { animation: mowa-ring 2.4s ease-out 1s 3; }
@keyframes mowa-ring {
	0% { opacity: .8; transform: scale(1); }
	70%, 100% { opacity: 0; transform: scale(1.6); }
}

/* ---------- Sohbet kutusu ---------- */
.mowa__box {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: 380px;
	max-width: calc(100vw - 2 * var(--mowa-offset));
	border-radius: var(--mowa-radius);
	overflow: hidden;
	background: var(--mowa-body-bg);
	box-shadow: 0 12px 40px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .08);
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px) scale(.94);
	transform-origin: bottom right;
	transition: opacity .25s, transform .3s cubic-bezier(.2, .8, .3, 1.1), visibility 0s .3s;
}
.mowa--theme .mowa__box {
	box-shadow: 0 18px 48px rgba(3, 10, 24, .32), 0 0 0 1px rgba(255, 255, 255, .06);
}
.mowa--left .mowa__box { right: auto; left: 0; transform-origin: bottom left; }
.mowa--open .mowa__box {
	opacity: 1;
	visibility: visible;
	transform: none;
	pointer-events: auto;
	transition: opacity .25s, transform .3s cubic-bezier(.2, .8, .3, 1.1), visibility 0s;
}

/* Başlık */
.mowa__head {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 70px;
	padding: 0 16px 0 22px;
	background: var(--mowa-head-bg);
	color: var(--mowa-head-text);
}
.mowa--theme .mowa__head {
	min-height: 84px;
	padding: 16px 16px 16px 18px;
	background:
		radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--mowa-accent) 32%, transparent), transparent 60%),
		var(--mowa-head-bg);
	border-bottom: 3px solid var(--mowa-accent);
}

/* Klasik başlık: WhatsApp logosu + yazı */
.mowa__brand { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.mowa__brand svg { width: 30px; height: 30px; fill: currentColor; }

/* Tema başlığı: site ikonu + ad + durum */
.mowa__agent { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mowa__avatar {
	position: relative;
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--mowa-accent) 70%, transparent);
}
.mowa__avatar img { width: 30px; height: 30px; object-fit: contain; }
.mowa__initial { font-size: 20px; font-weight: 700; color: var(--mowa-accent-dark); }
.mowa__who { min-width: 0; }
.mowa__avatar::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: 1px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #25d366;
	border: 2px solid var(--mowa-head-bg);
}
.mowa__name { display: block; font-size: 16.5px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mowa__status { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 13px; color: var(--mowa-head-muted); }
.mowa__status svg { width: 13px; height: 13px; fill: #25d366; }

.mowa__close {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, .14);
	color: #fff;
	cursor: pointer;
	transition: background-color .2s;
}
.mowa--theme .mowa__close { align-self: flex-start; background: rgba(255, 255, 255, .1); }
.mowa__close:hover { background: rgba(0, 0, 0, .24); }
.mowa--theme .mowa__close:hover { background: rgba(255, 255, 255, .2); }
.mowa__close svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }

/* Gövde */
.mowa__body {
	display: flex;
	flex-direction: column;
	gap: 22px;
	padding: 22px 20px 20px;
	background-color: var(--mowa-body-bg);
	background-image: radial-gradient(var(--mowa-dot) 1px, transparent 1.4px);
	background-size: 14px 14px;
}

.mowa__bubble, .mowa__typing {
	position: relative;
	align-self: flex-start;
	max-width: calc(100% - 20px);
	margin-left: 8px;
	padding: 16px 20px;
	border-radius: 0 22px 22px 22px;
	background: #fff;
	color: var(--mowa-text);
	font-size: 15.5px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.mowa--theme .mowa__bubble, .mowa--theme .mowa__typing {
	padding: 12px 16px 10px;
	border-radius: 0 12px 12px 12px;
	font-size: 15px;
	box-shadow: 0 1px 2px rgba(15, 33, 73, .1), 0 4px 14px rgba(15, 33, 73, .05);
}
.mowa__bubble::before, .mowa__typing::before {
	content: "";
	position: absolute;
	top: 0;
	left: -8px;
	border-top: 10px solid #fff;
	border-left: 8px solid transparent;
}
.mowa__bubble { display: none; animation: mowa-pop .3s ease-out; }
.mowa__bubble p { margin: 0; font: inherit; color: inherit; }
.mowa__bubble p + p { margin-top: 4px; }
.mowa__from { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 700; color: var(--mowa-accent-dark); }
.mowa__time { display: block; margin-top: 4px; font-size: 11.5px; color: #8a94a3; text-align: right; }

.mowa__typing { display: flex; gap: 5px; padding: 18px 20px; }
.mowa--theme .mowa__typing { padding: 16px 18px; }
.mowa__typing span { width: 8px; height: 8px; border-radius: 50%; background: #b5b5b5; animation: mowa-dot 1s infinite; }
.mowa__typing span:nth-child(2) { animation-delay: .15s; }
.mowa__typing span:nth-child(3) { animation-delay: .3s; }
.mowa--typed .mowa__typing { display: none; }
.mowa--typed .mowa__bubble { display: block; }
@keyframes mowa-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes mowa-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.mowa__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	align-self: flex-end;
	gap: 10px;
	min-height: 52px;
	padding: 0 24px 0 28px;
	border-radius: var(--mowa-cta-radius);
	background: var(--mowa-accent);
	color: var(--mowa-on-accent) !important;
	font-size: 16px;
	font-weight: 600;
	text-decoration: none !important;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
	transition: background-color .2s, transform .2s;
}
.mowa--theme .mowa__cta {
	align-self: stretch;
	min-height: 50px;
	padding: 0 20px;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
	box-shadow: 0 6px 16px color-mix(in srgb, var(--mowa-accent) 35%, transparent);
}
.mowa__cta:hover { background: var(--mowa-accent-dark); transform: translateY(-1px); }
.mowa__cta svg { width: 20px; height: 20px; fill: currentColor; }

/* Stile göre gösterilen parçalar */
.mowa--classic .mowa__agent,
.mowa--classic .mowa__from,
.mowa--classic .mowa__time,
.mowa--classic .mowa__cta-wa,
.mowa--theme .mowa__brand,
.mowa--theme .mowa__cta-send { display: none; }

/* Cihaz seçimi */
@media (min-width: 769px) { .mowa--only-mobile:not(.mowa--preview) { display: none; } }
@media (max-width: 768px) { .mowa--only-desktop:not(.mowa--preview) { display: none; } }

/* Panel önizlemesi */
.mowa--preview { position: absolute; right: 20px; bottom: 20px; z-index: 1; }
.mowa--preview.mowa--left { right: auto; left: 20px; }
.mowa--preview .mowa__box { max-width: 340px; }

/* ---------- Telefon ---------- */
@media (max-width: 480px) {
	.mowa { --mowa-offset: 14px; }
	.mowa__btn { width: 56px; height: 56px; }
	.mowa__btn svg { width: 31px; height: 31px; }
	.mowa__box { bottom: 70px; width: calc(100vw - 2 * var(--mowa-offset)); }
	.mowa__head { min-height: 62px; }
	.mowa--theme .mowa__head { min-height: 76px; }
}

@media (prefers-reduced-motion: reduce) {
	.mowa *, .mowa *::before { animation: none !important; transition: none !important; }
}

@media print { .mowa { display: none !important; } }
