/**
 * Jany Chat Widget styles.
 * Self-scoped to avoid theme conflicts. Uses CSS variables set from settings.
 */

#jany-chat-root {
	--jany-primary: #465140;
	--jany-accent: #FBB72E;
	--jany-neutral: #999999;
	--jany-bg: #ffffff;
	--jany-text: #222222;
	--jany-user-bg: #465140;
	--jany-user-text: #ffffff;
	--jany-bot-bg: #f3f4ef;
	--jany-bot-text: #222222;
	--jany-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
	--jany-radius: 14px;
	--jany-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-family: var(--jany-font);
}

#jany-chat-root * {
	box-sizing: border-box;
}

.jany-launcher {
	position: fixed;
	bottom: 22px;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: var(--jany-primary);
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: var(--jany-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 28px;
	z-index: 2147483646;
	transition: transform 0.2s ease;
}

.jany-launcher[data-position="bottom-right"] { right: 22px; }
.jany-launcher[data-position="bottom-left"]  { left: 22px; }

.jany-launcher:hover { transform: scale(1.05); }

.jany-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	background: var(--jany-accent);
	color: #222;
	font-size: 11px;
	font-weight: 700;
	border-radius: 10px;
	padding: 2px 6px;
	min-width: 18px;
	text-align: center;
}

.jany-panel {
	position: fixed;
	bottom: 100px;
	width: 370px;
	max-width: calc(100vw - 20px);
	height: min(560px, calc(100vh - 140px));
	background: var(--jany-bg);
	border-radius: var(--jany-radius);
	box-shadow: var(--jany-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	z-index: 2147483647;
	font-size: 14px;
	color: var(--jany-text);
}

.jany-panel[data-position="bottom-right"] { right: 22px; }
.jany-panel[data-position="bottom-left"]  { left: 22px; }

.jany-panel.is-open { display: flex; }

.jany-header {
	background: var(--jany-primary);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 10px;
}

.jany-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #fff;
	color: var(--jany-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 16px;
	overflow: hidden;
}
.jany-avatar img { width: 100%; height: 100%; object-fit: cover; }

.jany-header-title { flex: 1; min-width: 0; }
.jany-header-name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.jany-header-sub  { font-size: 11px; opacity: 0.85; line-height: 1.3; margin-top: 2px; }

.jany-close {
	background: transparent;
	border: none;
	color: #fff;
	cursor: pointer;
	font-size: 20px;
	padding: 4px 8px;
	line-height: 1;
	opacity: 0.85;
}
.jany-close:hover { opacity: 1; }

.jany-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	background: #fafbfa;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.jany-msg { max-width: 82%; padding: 9px 12px; border-radius: 12px; line-height: 1.45; word-wrap: break-word; }
.jany-msg-bot  { background: var(--jany-bot-bg); color: var(--jany-bot-text); align-self: flex-start; border-bottom-left-radius: 4px; }
.jany-msg-user { background: var(--jany-user-bg); color: var(--jany-user-text); align-self: flex-end; border-bottom-right-radius: 4px; }
.jany-msg-typing { background: var(--jany-bot-bg); align-self: flex-start; padding: 12px 14px; border-radius: 12px; }
.jany-msg-typing .dot { display: inline-block; width: 6px; height: 6px; margin: 0 2px; background: var(--jany-neutral); border-radius: 50%; animation: janyBlink 1.3s infinite; }
.jany-msg-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.jany-msg-typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes janyBlink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.jany-footer {
	padding: 10px 12px;
	border-top: 1px solid #eee;
	background: #fff;
}
.jany-input-wrap { display: flex; gap: 8px; align-items: flex-end; }
.jany-input {
	flex: 1;
	border: 1px solid #ddd;
	border-radius: 20px;
	padding: 9px 14px;
	font-size: 14px;
	resize: none;
	max-height: 120px;
	min-height: 40px;
	font-family: inherit;
	outline: none;
}
.jany-input:focus { border-color: var(--jany-primary); }

.jany-send {
	background: var(--jany-primary);
	color: #fff;
	border: none;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	cursor: pointer;
	font-size: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.2s;
}
.jany-send:disabled { opacity: 0.5; cursor: not-allowed; }

.jany-disclaimer {
	font-size: 10px;
	color: var(--jany-neutral);
	text-align: center;
	margin-top: 6px;
	line-height: 1.3;
}
.jany-disclaimer a { color: var(--jany-neutral); text-decoration: underline; }

.jany-error {
	background: #fde8e8;
	color: #9b1c1c;
	border-radius: 8px;
	padding: 8px 12px;
	font-size: 12px;
	margin: 4px 0;
}

@media (max-width: 480px) {
	.jany-panel {
		width: 100vw;
		height: 100vh;
		max-width: 100vw;
		border-radius: 0;
		bottom: 0;
		right: 0 !important;
		left: 0 !important;
	}
	.jany-launcher { bottom: 18px; }
}
