/* Theme Support Chat – front-end widget */
#tsc-root {
	--tsc-primary: #2563eb;
	--tsc-on-primary: #fff;
	--tsc-x: 24px;
	--tsc-y: 24px;
	--tsc-size: 60px;
	--tsc-bg: #ffffff;
	--tsc-surface: #f3f4f6;
	--tsc-text: #111827;
	--tsc-muted: #6b7280;
	--tsc-border: #e5e7eb;
	--tsc-radius: 16px;
	position: fixed;
	z-index: 2147483000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--tsc-text);
	-webkit-font-smoothing: antialiased;
}
#tsc-root *, #tsc-root *::before, #tsc-root *::after { box-sizing: border-box; }

/* ---------- Position ---------- */
#tsc-root.tsc-pos-bottom-right { right: var(--tsc-x); bottom: var(--tsc-y); }
#tsc-root.tsc-pos-bottom-left  { left:  var(--tsc-x); bottom: var(--tsc-y); }
#tsc-root.tsc-pos-top-right    { right: var(--tsc-x); top: var(--tsc-y); }
#tsc-root.tsc-pos-top-left     { left:  var(--tsc-x); top: var(--tsc-y); }
#tsc-root.tsc-pos-middle-right { right: var(--tsc-x); top: 50%; transform: translateY(-50%); }
#tsc-root.tsc-pos-middle-left  { left:  var(--tsc-x); top: 50%; transform: translateY(-50%); }

/* Panel placement relative to the launcher */
#tsc-root .tsc-panel { position: absolute; }
#tsc-root[class*="-right"] .tsc-panel { right: 0; }
#tsc-root[class*="-left"]  .tsc-panel { left: 0; }
#tsc-root[class*="bottom-"] .tsc-panel { bottom: calc(var(--tsc-size) + 14px); transform-origin: bottom; }
#tsc-root[class*="top-"]    .tsc-panel { top: calc(var(--tsc-size) + 14px); transform-origin: top; }
#tsc-root[class*="middle-"] .tsc-panel { top: 50%; translate: 0 -50%; }
#tsc-root.tsc-pos-middle-right .tsc-panel { right: calc(var(--tsc-size) + 14px); }
#tsc-root.tsc-pos-middle-left  .tsc-panel { left:  calc(var(--tsc-size) + 14px); }

/* ---------- Launcher ---------- */
#tsc-root .tsc-launcher {
	all: unset;
	box-sizing: border-box;
	width: var(--tsc-size);
	height: var(--tsc-size);
	border-radius: 50%;
	background: var(--tsc-primary);
	color: var(--tsc-on-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 8px 24px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.12);
	transition: transform .2s ease, box-shadow .2s ease;
	position: relative;
}
#tsc-root .tsc-launcher:hover { transform: scale(1.06); box-shadow: 0 10px 28px rgba(0,0,0,.22); }
#tsc-root .tsc-launcher:focus,
#tsc-root .tsc-x:focus,
#tsc-root .tsc-send:focus { outline: none; }
#tsc-root .tsc-x:focus-visible,
#tsc-root .tsc-send:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
#tsc-root .tsc-launcher:focus-visible { outline: 3px solid var(--tsc-primary); outline-offset: 3px; }
#tsc-root .tsc-launcher svg { width: 46%; height: 46%; transition: transform .25s ease, opacity .2s ease; position: absolute; }
#tsc-root .tsc-launcher .tsc-ic-close { opacity: 0; transform: rotate(-90deg); }
#tsc-root.tsc-open .tsc-launcher .tsc-ic-chat { opacity: 0; transform: rotate(90deg); }
#tsc-root.tsc-open .tsc-launcher .tsc-ic-close { opacity: 1; transform: none; }

#tsc-root .tsc-badge {
	position: absolute; top: -2px; right: -2px;
	min-width: 20px; height: 20px; padding: 0 6px;
	border-radius: 10px; background: #ef4444; color: #fff;
	font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
	border: 2px solid #fff;
}
#tsc-root .tsc-badge[hidden] { display: none; }

/* ---------- Panel ---------- */
#tsc-root .tsc-panel {
	width: 370px;
	max-width: calc(100vw - 2 * var(--tsc-x));
	height: 540px;
	max-height: calc(100vh - var(--tsc-size) - var(--tsc-y) - 40px);
	background: var(--tsc-bg);
	border-radius: var(--tsc-radius);
	box-shadow: 0 20px 60px rgba(0,0,0,.22), 0 4px 14px rgba(0,0,0,.1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	scale: .96;
	transition: opacity .18s ease, scale .18s ease, visibility 0s linear .18s;
}
#tsc-root.tsc-open .tsc-panel { opacity: 1; visibility: visible; scale: 1; transition: opacity .18s ease, scale .18s ease; }

#tsc-root .tsc-head {
	background: var(--tsc-primary);
	color: var(--tsc-on-primary);
	padding: 18px 18px 16px;
	display: flex; align-items: flex-start; gap: 12px;
}
#tsc-root .tsc-head-txt { flex: 1; min-width: 0; }
#tsc-root .tsc-title { margin: 0; font-size: 17px; font-weight: 700; color: inherit; line-height: 1.3; }
#tsc-root .tsc-sub { margin: 3px 0 0; font-size: 13px; opacity: .9; color: inherit; }
#tsc-root .tsc-x {
	all: unset; cursor: pointer; width: 30px; height: 30px; border-radius: 8px;
	display: flex; align-items: center; justify-content: center; color: inherit; opacity: .85;
}
#tsc-root .tsc-x:hover { background: rgba(255,255,255,.15); opacity: 1; }
#tsc-root .tsc-x svg { width: 18px; height: 18px; }

#tsc-root .tsc-body { flex: 1; overflow-y: auto; padding: 16px; background: var(--tsc-bg); overscroll-behavior: contain; }

/* ---------- Start form ---------- */
#tsc-root .tsc-welcome { margin: 0 0 14px; color: var(--tsc-text); font-size: 14px; }
#tsc-root .tsc-field { margin: 0 0 10px; }
#tsc-root .tsc-field label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 4px; color: var(--tsc-text); }
#tsc-root .tsc-field input,
#tsc-root .tsc-field select,
#tsc-root .tsc-compose textarea {
	width: 100%; margin: 0;
	font: inherit; font-size: 15px; color: var(--tsc-text);
	background: #fff; border: 1px solid var(--tsc-border); border-radius: 10px;
	padding: 10px 12px; box-shadow: none; outline: none; min-height: 0; height: auto;
	transition: border-color .15s, box-shadow .15s;
}
#tsc-root .tsc-field input:focus,
#tsc-root .tsc-field select:focus,
#tsc-root .tsc-compose textarea:focus { border-color: var(--tsc-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tsc-primary) 20%, transparent); }
#tsc-root .tsc-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
#tsc-root .tsc-privacy { font-size: 12px; color: var(--tsc-muted); margin: 8px 0 12px; }
#tsc-root .tsc-btn {
	all: unset; box-sizing: border-box; cursor: pointer; text-align: center;
	width: 100%; padding: 11px 16px; border-radius: 10px;
	background: var(--tsc-primary); color: var(--tsc-on-primary);
	font-weight: 600; font-size: 15px; transition: filter .15s;
}
#tsc-root .tsc-btn:hover { filter: brightness(1.08); }
#tsc-root .tsc-btn[disabled] { opacity: .6; cursor: default; }
#tsc-root .tsc-error { color: #b91c1c; font-size: 13px; margin: 8px 0 0; }
#tsc-root .tsc-error:empty { display: none; }

/* ---------- Messages ---------- */
#tsc-root .tsc-msgs { display: flex; flex-direction: column; gap: 8px; }
#tsc-root .tsc-m { max-width: 82%; display: flex; flex-direction: column; }
#tsc-root .tsc-m-bubble {
	padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; font-size: 14.5px;
}
#tsc-root .tsc-m-time { font-size: 11px; color: var(--tsc-muted); margin: 3px 4px 0; }
#tsc-root .tsc-m-visitor { align-self: flex-end; align-items: flex-end; }
#tsc-root .tsc-m-visitor .tsc-m-bubble { background: var(--tsc-primary); color: var(--tsc-on-primary); border-bottom-right-radius: 4px; }
#tsc-root .tsc-m-admin, #tsc-root .tsc-m-system { align-self: flex-start; }
#tsc-root .tsc-m-admin .tsc-m-bubble { background: var(--tsc-surface); color: var(--tsc-text); border-bottom-left-radius: 4px; }
#tsc-root .tsc-m-system .tsc-m-bubble { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; border-bottom-left-radius: 4px; }
#tsc-root .tsc-m-pending { opacity: .6; }
#tsc-root .tsc-note { text-align: center; font-size: 12px; color: var(--tsc-muted); margin: 4px 0 10px; }

/* ---------- Composer ---------- */
#tsc-root .tsc-compose { border-top: 1px solid var(--tsc-border); padding: 10px; display: flex; gap: 8px; align-items: flex-end; background: var(--tsc-bg); }
#tsc-root .tsc-compose textarea { resize: none; max-height: 120px; line-height: 1.4; padding: 9px 12px; }
#tsc-root .tsc-send {
	all: unset; cursor: pointer; flex: 0 0 40px; width: 40px; height: 40px; border-radius: 10px;
	background: var(--tsc-primary); color: var(--tsc-on-primary); display: flex; align-items: center; justify-content: center;
}
#tsc-root .tsc-send[disabled] { opacity: .5; cursor: default; }
#tsc-root .tsc-send svg { width: 18px; height: 18px; }
#tsc-root .tsc-foot { display: flex; justify-content: space-between; padding: 0 12px 8px; font-size: 11.5px; color: var(--tsc-muted); background: var(--tsc-bg); }
#tsc-root .tsc-link { all: unset; cursor: pointer; text-decoration: underline; color: var(--tsc-muted); font-size: 11.5px; }

/* ---------- Inline shortcode button ---------- */
.tsc-inline-btn {
	cursor: pointer; border: 0; border-radius: 8px; padding: 10px 18px;
	background: var(--tsc-primary, #2563eb); color: var(--tsc-on-primary, #fff); font-weight: 600;
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
	#tsc-root.tsc-hide-mobile { display: none !important; }

	#tsc-root.tsc-mpos-bottom-right { inset: auto var(--tsc-x) var(--tsc-y) auto; transform: none; }
	#tsc-root.tsc-mpos-bottom-left  { inset: auto auto var(--tsc-y) var(--tsc-x); transform: none; }
	#tsc-root.tsc-mpos-top-right    { inset: var(--tsc-y) var(--tsc-x) auto auto; transform: none; }
	#tsc-root.tsc-mpos-top-left     { inset: var(--tsc-y) auto auto var(--tsc-x); transform: none; }
	#tsc-root.tsc-mpos-middle-right { inset: 50% var(--tsc-x) auto auto; transform: translateY(-50%); }
	#tsc-root.tsc-mpos-middle-left  { inset: 50% auto auto var(--tsc-x); transform: translateY(-50%); }

	/* Full-screen panel on phones */
	#tsc-root.tsc-open .tsc-panel {
		position: fixed; inset: 0; width: 100vw; max-width: 100vw; height: 100%; max-height: none;
		border-radius: 0; translate: none;
	}
	#tsc-root.tsc-open .tsc-launcher { display: none; }
	#tsc-root.tsc-open { transform: none; }
	#tsc-root .tsc-field input, #tsc-root .tsc-field select, #tsc-root .tsc-compose textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
	#tsc-root * { transition: none !important; }
}

#tsc-root .tsc-turnstile { margin: 0 0 12px; min-height: 65px; }
#tsc-root .tsc-m-failed .tsc-m-bubble { background: #fee2e2; color: #991b1b; }
#tsc-root .tsc-m-failed .tsc-m-time { color: #b91c1c; }
#tsc-root .tsc-retry { all: unset; cursor: pointer; text-decoration: underline; font-weight: 600; color: #b91c1c; font-size: 11px; }
