/* MediConnect chat widget.
 *
 * Inherits the theme's brand tokens where they exist and falls back to literals
 * so the widget still looks right if the theme changes.
 */

#mcc-root {
	--mcc-brand: var(--mc-primary, #D6135A);
	--mcc-brand-dark: var(--mc-primary-dark, #B00E4A);
	--mcc-ink: var(--mc-ink, #1F2937);
	--mcc-body: var(--mc-body, #374151);
	--mcc-line: var(--mc-border-light, #E5E7EB);
	--mcc-surface: #fff;

	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 9998;
	font-family: 'Source Sans 3', system-ui, -apple-system, sans-serif;
}

/* --- Launcher ------------------------------------------------------------ */

#mcc-launch {
	display: flex;
	align-items: center;
	gap: 9px;
	min-height: 52px;
	padding: 0 20px;
	border: 0;
	border-radius: 99px;
	background: var(--mcc-brand);
	color: #fff;
	font: 600 15.5px/1 inherit;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(31, 41, 55, .22);
	transition: background 200ms ease, transform 200ms ease;
}
#mcc-launch:hover { background: var(--mcc-brand-dark); transform: translateY(-1px); }
#mcc-launch:focus-visible { outline: 3px solid var(--mcc-brand); outline-offset: 3px; }

#mcc-root[data-state="open"] #mcc-launch { display: none; }

/* --- Panel --------------------------------------------------------------- */

#mcc-panel {
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 100px);
	display: flex;
	flex-direction: column;
	background: var(--mcc-surface);
	border: 1px solid var(--mcc-line);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 18px 48px rgba(31, 41, 55, .2);
	animation: mcc-in 200ms cubic-bezier(.22,.61,.36,1) both;
}
#mcc-panel[hidden] { display: none; }

@keyframes mcc-in {
	from { opacity: 0; transform: translateY(12px) scale(.98); }
	to   { opacity: 1; transform: none; }
}

.mcc-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	background: var(--mcc-brand);
	color: #fff;
}
.mcc-head strong { display: block; font-size: 15.5px; font-weight: 600; }
.mcc-sub { display: block; font-size: 12.5px; opacity: .9; margin-top: 2px; }

#mcc-close {
	background: transparent;
	border: 0;
	color: #fff;
	cursor: pointer;
	min-width: 44px;
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	flex: none;
}
#mcc-close:hover { background: rgba(255,255,255,.16); }

.mcc-disclaimer {
	margin: 0;
	padding: 10px 16px;
	background: #FFF9E6;
	border-bottom: 1px solid #F2E4B8;
	font-size: 12.5px;
	line-height: 1.45;
	color: #6B5A18;
}
.mcc-disclaimer a { color: #6B5A18; }

/* --- Message log --------------------------------------------------------- */

#mcc-log {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--mc-base, #F8F9FA);
}

.mcc-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 15px;
	line-height: 1.5;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	animation: mcc-msg-in 180ms ease both;
}
@keyframes mcc-msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.mcc-msg--bot {
	align-self: flex-start;
	background: var(--mcc-surface);
	border: 1px solid var(--mcc-line);
	color: var(--mcc-body);
	border-bottom-left-radius: 4px;
}
.mcc-msg--you {
	align-self: flex-end;
	background: var(--mcc-brand);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.mcc-msg--warn { background: #FDF0E7; border-color: #F3D2B8; color: #8A3D07; }

.mcc-msg a { color: inherit; text-decoration: underline; }
.mcc-msg--bot a { color: var(--mcc-brand); }

/* Right-to-left replies (Arabic, Hebrew, Persian, Urdu). */
.mcc-msg[dir="rtl"] { text-align: right; }

.mcc-fallback { margin: 4px 0 0; font-size: 14px; }
.mcc-fallback a { color: var(--mcc-brand); font-weight: 600; }

.mcc-typing { display: flex; gap: 4px; align-items: center; padding: 14px; }
.mcc-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--mc-faint, #9CA3AF);
	animation: mcc-bounce 1.2s infinite ease-in-out;
}
.mcc-typing span:nth-child(2) { animation-delay: .15s; }
.mcc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes mcc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* --- Composer ------------------------------------------------------------ */

#mcc-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--mcc-line);
	background: var(--mcc-surface);
}

#mcc-input {
	flex: 1;
	resize: none;
	border: 1px solid var(--mc-border, #D1D5DB);
	border-radius: 10px;
	padding: 11px 13px;
	/* 16px minimum — anything smaller makes iOS Safari zoom the page on focus
	   and never zoom back out. */
	font: 400 16px/1.4 inherit;
	color: var(--mcc-ink);
	max-height: 120px;
}
#mcc-input:focus { outline: 2px solid var(--mcc-brand); outline-offset: -1px; border-color: transparent; }
#mcc-input:disabled { background: var(--mc-base, #F8F9FA); }

#mcc-send {
	flex: none;
	min-width: 44px;
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 10px;
	background: var(--mcc-brand);
	color: #fff;
	cursor: pointer;
	transition: background 200ms ease;
}
#mcc-send:hover:not(:disabled) { background: var(--mcc-brand-dark); }
#mcc-send:disabled { opacity: .5; cursor: default; }

/* --- Mobile -------------------------------------------------------------- */

@media (max-width: 781px) {
	#mcc-root { right: 12px; bottom: 12px; left: 12px; }

	#mcc-launch { margin-left: auto; }
	/* The label costs width the sticky CTA also wants — icon only. */
	.mcc-launch-label { display: none; }
	#mcc-launch { padding: 0; width: 56px; min-height: 56px; justify-content: center; }

	#mcc-panel {
		width: 100%;
		height: 78dvh;
		max-height: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	#mcc-panel, .mcc-msg { animation: none; }
	.mcc-typing span { animation-duration: .01ms; }
}
