/*!
 * C.tech AI Chatbot — frontend widget styles
 * Variables --ctech-primary & --ctech-secondary are injected from PHP settings.
 */

:root {
	--ctech-primary: #f9c51d;
	--ctech-primary-hover: #faaf00;
	--ctech-secondary: #111111;
	--ctech-bg: #ffffff;
	--ctech-bg-soft: #f6f7f9;
	--ctech-border: #e5e7eb;
	--ctech-text: #111827;
	--ctech-text-muted: #6b7280;
	--ctech-success: #22c55e;
	--ctech-radius: 16px;
	--ctech-shadow: 0 18px 60px -12px rgba(0, 0, 0, 0.35);
	--ctech-z: 2147483600;
}

.ctech-chatbot-root,
.ctech-chatbot-root * {
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
		Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.ctech-chatbot-root {
	position: fixed;
	bottom: 22px;
	right: 22px;
	z-index: var(--ctech-z);
	color: var(--ctech-text);
}

/* ───────────────────────── Launcher ───────────────────────── */
.ctech-chatbot-launcher {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--ctech-primary);
	color: var(--ctech-secondary);
	border: none;
	cursor: pointer;
	box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
	position: relative;
}
.ctech-chatbot-launcher:hover {
	background: var(--ctech-primary-hover);
	transform: translateY(-2px) scale(1.03);
}
.ctech-chatbot-launcher:focus-visible {
	outline: 3px solid var(--ctech-secondary);
	outline-offset: 3px;
}
.ctech-chatbot-launcher .ctech-icon-close { display: none; }
.ctech-chatbot-root[data-state="open"] .ctech-chatbot-launcher .ctech-icon-chat { display: none; }
.ctech-chatbot-root[data-state="open"] .ctech-chatbot-launcher .ctech-icon-close { display: block; }

.ctech-launcher-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	background: #ef4444;
	color: #fff;
	border-radius: 9px;
	font-size: 11px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	border: 2px solid var(--ctech-bg);
}
.ctech-chatbot-root[data-state="open"] .ctech-launcher-badge,
.ctech-chatbot-root[data-engaged="1"] .ctech-launcher-badge {
	display: none;
}

/* ───────────────────────── Chat window ───────────────────────── */
.ctech-chatbot-window {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: 380px;
	height: 560px;
	max-height: calc(100vh - 110px);
	background: var(--ctech-bg);
	border-radius: var(--ctech-radius);
	box-shadow: var(--ctech-shadow);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transform-origin: bottom right;
	animation: ctech-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes ctech-pop {
	from { transform: translateY(10px) scale(0.95); opacity: 0; }
	to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* Header */
.ctech-chatbot-header {
	background: var(--ctech-secondary);
	color: #fff;
	padding: 14px 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-bottom: 3px solid var(--ctech-primary);
	gap: 10px;
}
.ctech-header-left {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}
.ctech-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--ctech-primary);
	color: var(--ctech-secondary);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.ctech-header-titles { min-width: 0; }
.ctech-header-title {
	font-size: 15px;
	font-weight: 700;
	margin: 0;
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.ctech-header-status {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.85);
}
.ctech-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--ctech-success);
	box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
	animation: ctech-pulse 1.8s infinite;
}
@keyframes ctech-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
	70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
	100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.ctech-header-right {
	display: flex;
	align-items: center;
	gap: 8px;
}
.ctech-lang-toggle {
	display: inline-flex;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 999px;
	overflow: hidden;
	border: 1px solid rgba(255, 255, 255, 0.18);
}
.ctech-lang-btn {
	background: transparent;
	color: rgba(255, 255, 255, 0.78);
	border: none;
	padding: 4px 9px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}
.ctech-lang-btn:hover { color: #fff; }
.ctech-lang-btn.is-active {
	background: var(--ctech-primary);
	color: var(--ctech-secondary);
}
.ctech-close-btn {
	background: rgba(255, 255, 255, 0.08);
	border: none;
	color: #fff;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}
.ctech-close-btn:hover { background: rgba(255, 255, 255, 0.18); }

/* Quick actions */
.ctech-quick-actions {
	padding: 10px 12px 4px;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	background: var(--ctech-bg-soft);
	border-bottom: 1px solid var(--ctech-border);
}
.ctech-quick-btn {
	background: #fff;
	border: 1px solid var(--ctech-border);
	border-radius: 999px;
	padding: 6px 10px;
	font-size: 12px;
	cursor: pointer;
	color: var(--ctech-text);
	transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
	white-space: nowrap;
}
.ctech-quick-btn:hover {
	border-color: var(--ctech-primary);
	background: #fffbe6;
}
.ctech-quick-btn:active { transform: scale(0.97); }

/* Body / messages */
.ctech-chatbot-body {
	flex: 1;
	overflow-y: auto;
	padding: 14px 12px 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--ctech-bg);
	scroll-behavior: smooth;
}
.ctech-chatbot-body::-webkit-scrollbar { width: 6px; }
.ctech-chatbot-body::-webkit-scrollbar-thumb {
	background: #d1d5db;
	border-radius: 3px;
}

.ctech-msg {
	max-width: 84%;
	padding: 9px 12px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.45;
	word-wrap: break-word;
	white-space: pre-wrap;
	animation: ctech-fade 0.18s ease;
}
@keyframes ctech-fade {
	from { opacity: 0; transform: translateY(4px); }
	to   { opacity: 1; transform: translateY(0); }
}
.ctech-msg.from-bot {
	align-self: flex-start;
	background: #fff;
	color: var(--ctech-text);
	border: 1px solid var(--ctech-border);
	border-bottom-left-radius: 4px;
}
.ctech-msg.from-user {
	align-self: flex-end;
	background: var(--ctech-secondary);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.ctech-msg a {
	color: var(--ctech-primary-hover);
	text-decoration: underline;
}
.ctech-msg.from-user a { color: var(--ctech-primary); }

/* Typing indicator */
.ctech-typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 4px;
	padding: 10px 14px;
	background: #fff;
	border: 1px solid var(--ctech-border);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
}
.ctech-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ctech-primary);
	animation: ctech-bounce 1.2s infinite ease-in-out;
}
.ctech-typing span:nth-child(2) { animation-delay: 0.15s; }
.ctech-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ctech-bounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.6; }
	40% { transform: scale(1); opacity: 1; }
}

/* Input */
.ctech-chatbot-input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 10px 8px;
	border-top: 1px solid var(--ctech-border);
	background: #fff;
}
.ctech-chatbot-input textarea {
	flex: 1;
	resize: none;
	border: 1px solid var(--ctech-border);
	border-radius: 12px;
	padding: 9px 12px;
	font-size: 14px;
	line-height: 1.4;
	min-height: 40px;
	max-height: 120px;
	color: var(--ctech-text);
	background: #fff;
	font-family: inherit;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ctech-chatbot-input textarea:focus {
	outline: none;
	border-color: var(--ctech-primary);
	box-shadow: 0 0 0 3px rgba(249, 197, 29, 0.25);
}
.ctech-send-btn {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: var(--ctech-primary);
	color: var(--ctech-secondary);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, transform 0.1s ease;
	flex-shrink: 0;
}
.ctech-send-btn:hover { background: var(--ctech-primary-hover); }
.ctech-send-btn:active { transform: scale(0.94); }
.ctech-send-btn:disabled {
	background: #e5e7eb;
	color: #9ca3af;
	cursor: not-allowed;
}

/* Footer */
.ctech-chatbot-footer {
	padding: 6px 12px 8px;
	text-align: center;
	background: var(--ctech-bg-soft);
	border-top: 1px solid var(--ctech-border);
}
.ctech-powered {
	font-size: 11px;
	color: var(--ctech-text-muted);
	letter-spacing: 0.02em;
}

/* Screen-reader only */
.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0);
	white-space: nowrap; border: 0;
}

/* Mobile */
@media (max-width: 480px) {
	.ctech-chatbot-root {
		bottom: 14px;
		right: 14px;
		left: 14px;
	}
	.ctech-chatbot-launcher {
		position: absolute;
		bottom: 0;
		right: 0;
	}
	.ctech-chatbot-window {
		position: fixed;
		bottom: 86px;
		left: 10px;
		right: 10px;
		width: auto;
		height: calc(100vh - 110px);
		max-height: none;
	}
}

/* RTL safety (Greek/English are LTR but keep it tidy) */
.ctech-chatbot-root[dir="rtl"] { right: auto; left: 22px; }
