/**
 * Topymedia Connect widget styles. Everything is scoped under
 * #topymedia-chat-root so it never leaks into (or inherits from) the host theme.
 */
#topymedia-chat-root {
	--tm-primary: #1d4ed8;
	--tm-on-primary: #ffffff;
	--tm-bg: #ffffff;
	--tm-text: #1f2937;
	--tm-muted: #6b7280;
	--tm-border: #e5e7eb;
	--tm-bot-bg: #f3f4f6;
	--tm-radius: 14px;
	--tm-shadow: 0 10px 30px rgba( 0, 0, 0, 0.18 );

	position: fixed;
	bottom: 20px;
	z-index: 2147483000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.4;
}

#topymedia-chat-root[data-position="bottom-right"] { right: 20px; }
#topymedia-chat-root[data-position="bottom-left"] { left: 20px; }

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

/* --- Launcher ----------------------------------------------------------- */
#topymedia-chat-root .tmc-launcher {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: 0;
	cursor: pointer;
	background: var( --tm-primary );
	color: var( --tm-on-primary );
	font-size: 26px;
	box-shadow: var( --tm-shadow );
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease;
}
#topymedia-chat-root .tmc-launcher:hover { transform: scale( 1.05 ); }
#topymedia-chat-root .tmc-launcher:focus-visible { outline: 3px solid var( --tm-text ); outline-offset: 2px; }
#topymedia-chat-root .tmc-launcher.tmc-hidden { display: none; }

/* Custom launcher visual (per-client mascot): let the image own the button so
   an animated WebP/GIF fills the circle; the brand colour shows through any
   transparent pixels. */
#topymedia-chat-root .tmc-launcher-custom { padding: 0; overflow: hidden; }
#topymedia-chat-root .tmc-launcher-img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	border-radius: 50%;
	display: block;
	pointer-events: none;
}

/* --- Panel -------------------------------------------------------------- */
#topymedia-chat-root .tmc-panel {
	position: absolute;
	bottom: 74px;
	width: 360px;
	max-width: calc( 100vw - 40px );
	height: 520px;
	max-height: calc( 100vh - 110px );
	background: var( --tm-bg );
	color: var( --tm-text );
	border: 1px solid var( --tm-border );
	border-radius: var( --tm-radius );
	box-shadow: var( --tm-shadow );
	/* Hidden until opened; .tmc-open flips it to a flex column. */
	display: none;
	flex-direction: column;
	overflow: hidden;
}
#topymedia-chat-root .tmc-panel.tmc-open { display: flex; }
#topymedia-chat-root[data-position="bottom-right"] .tmc-panel { right: 0; }
#topymedia-chat-root[data-position="bottom-left"] .tmc-panel { left: 0; }

#topymedia-chat-root .tmc-header {
	background: var( --tm-primary );
	color: var( --tm-on-primary );
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
#topymedia-chat-root .tmc-header-title { font-weight: 600; }
#topymedia-chat-root .tmc-close {
	background: transparent;
	border: 0;
	color: inherit;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
}

/* --- Thread ------------------------------------------------------------- */
#topymedia-chat-root .tmc-thread {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #fafafa;
}
#topymedia-chat-root .tmc-msg {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 85%;
}
#topymedia-chat-root .tmc-msg-visitor { align-self: flex-end; flex-direction: row-reverse; }
#topymedia-chat-root .tmc-msg-bot,
#topymedia-chat-root .tmc-msg-human { align-self: flex-start; }

#topymedia-chat-root .tmc-avatar {
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var( --tm-bot-bg );
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
}
#topymedia-chat-root .tmc-msg-human .tmc-avatar { background: #d1fae5; }

#topymedia-chat-root .tmc-bubble {
	padding: 9px 12px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
}
#topymedia-chat-root .tmc-msg-visitor .tmc-bubble {
	background: var( --tm-primary );
	color: var( --tm-on-primary );
	border-bottom-right-radius: 4px;
}
#topymedia-chat-root .tmc-msg-bot .tmc-bubble,
#topymedia-chat-root .tmc-msg-human .tmc-bubble {
	background: var( --tm-bot-bg );
	color: var( --tm-text );
	border-bottom-left-radius: 4px;
}

#topymedia-chat-root .tmc-system {
	align-self: center;
	color: var( --tm-muted );
	font-size: 13px;
	text-align: center;
	padding: 4px 8px;
}

#topymedia-chat-root .tmc-handoff {
	align-self: flex-start;
	margin-top: 2px;
	background: transparent;
	border: 1px solid var( --tm-primary );
	color: var( --tm-primary );
	border-radius: 999px;
	padding: 6px 14px;
	cursor: pointer;
	font-size: 14px;
}
#topymedia-chat-root .tmc-handoff:disabled { opacity: 0.5; cursor: default; }

/* Typing indicator. */
#topymedia-chat-root .tmc-dot {
	display: inline-block;
	width: 6px;
	height: 6px;
	margin: 0 2px;
	border-radius: 50%;
	background: var( --tm-muted );
	animation: tmc-blink 1.2s infinite both;
}
#topymedia-chat-root .tmc-dot:nth-child( 2 ) { animation-delay: 0.2s; }
#topymedia-chat-root .tmc-dot:nth-child( 3 ) { animation-delay: 0.4s; }
@keyframes tmc-blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

/* --- Consent ------------------------------------------------------------ */
#topymedia-chat-root .tmc-consent {
	padding: 12px 14px;
	border-top: 1px solid var( --tm-border );
	background: var( --tm-bg );
}
#topymedia-chat-root .tmc-consent-text { margin: 0 0 8px; font-size: 13px; color: var( --tm-muted ); }
#topymedia-chat-root .tmc-consent-accept {
	background: var( --tm-primary );
	color: var( --tm-on-primary );
	border: 0;
	border-radius: 8px;
	padding: 8px 14px;
	cursor: pointer;
}

/* --- Composer ----------------------------------------------------------- */
#topymedia-chat-root .tmc-composer {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid var( --tm-border );
	background: var( --tm-bg );
}
#topymedia-chat-root .tmc-input {
	flex: 1;
	resize: none;
	max-height: 96px;
	border: 1px solid var( --tm-border );
	border-radius: 10px;
	padding: 9px 11px;
	font: inherit;
	color: var( --tm-text );
	background: #fff;
}
#topymedia-chat-root .tmc-input:focus-visible { outline: 2px solid var( --tm-primary ); }
#topymedia-chat-root .tmc-input:disabled { background: #f3f4f6; }
#topymedia-chat-root .tmc-send {
	background: var( --tm-primary );
	color: var( --tm-on-primary );
	border: 0;
	border-radius: 10px;
	padding: 0 16px;
	cursor: pointer;
	font-weight: 600;
}
#topymedia-chat-root .tmc-send:disabled { opacity: 0.5; cursor: default; }

/* Shown in place of the composer once a conversation is closed. */
#topymedia-chat-root .tmc-restart {
	margin: 10px;
	background: var( --tm-primary );
	color: var( --tm-on-primary );
	border: 0;
	border-radius: 10px;
	padding: 11px 16px;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
}

#topymedia-chat-root .tmc-footer {
	text-align: center;
	font-size: 11px;
	color: var( --tm-muted );
	padding: 6px;
	background: var( --tm-bg );
}
#topymedia-chat-root .tmc-powered-link {
	color: var( --tm-muted );
	text-decoration: none;
	font-weight: 600;
}
#topymedia-chat-root .tmc-powered-link:hover,
#topymedia-chat-root .tmc-powered-link:focus-visible {
	color: var( --tm-primary );
	text-decoration: underline;
}

/* --- Mobile: fullscreen overlay ---------------------------------------- */
@media ( max-width: 640px ) {
	#topymedia-chat-root .tmc-panel {
		position: fixed;
		inset: 0;
		width: 100vw;
		height: 100vh;
		max-width: none;
		max-height: none;
		border-radius: 0;
		border: 0;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	#topymedia-chat-root .tmc-launcher { transition: none; }
	#topymedia-chat-root .tmc-dot { animation: none; }
}
