/**
 * Cozy Telegram Chat — frontend styles.
 * Scoped under .cozy-chat-widget to survive WooCommerce/theme button styles.
 */

:root {
	--cozy-chat-mobile-bottom-offset: 96px;
	--cozy-chat-mobile-side-offset: 14px;
	--cozy-chat-mobile-lang-extra: 0px;
	--cozy-chat-floating-side-offset: 24px;
	--cozy-chat-floating-bottom-offset: 24px;
}

.cozy-chat-widget {
	--cozy-primary: #2563eb;
	--cozy-primary-hover: #1d4ed8;
	--cozy-bg: #f6f7f9;
	--cozy-surface: #ffffff;
	--cozy-text: #111827;
	--cozy-muted: #6b7280;
	--cozy-border: #e5e7eb;
	--cozy-success: #22c55e;
	--cozy-error: #ef4444;
	--cozy-shadow-window: 0 24px 70px rgba(15, 23, 42, 0.22);
	--cozy-shadow-toggle: 0 16px 35px rgba(37, 99, 235, 0.35);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	color: var(--cozy-text);
	box-sizing: border-box;
	-webkit-font-smoothing: antialiased;
}

.cozy-chat-widget *,
.cozy-chat-widget *::before,
.cozy-chat-widget *::after {
	box-sizing: border-box;
}

/* Theme reset inside widget */
.cozy-chat-widget button,
.cozy-chat-widget input,
.cozy-chat-widget textarea {
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
}

.cozy-chat-widget button {
	margin: 0;
}

.cozy-chat-widget svg {
	display: block;
	flex-shrink: 0;
}

/* Floating launcher */
.cozy-chat-widget--floating {
	position: fixed;
	bottom: var(--cozy-chat-floating-bottom-offset);
	z-index: 99990;
}

.cozy-chat-widget--floating.cozy-chat-mobile-left {
	left: var(--cozy-chat-floating-side-offset);
	right: auto;
	bottom: var(--cozy-chat-floating-bottom-offset);
}

.cozy-chat-widget--floating.cozy-chat-mobile-right {
	right: var(--cozy-chat-floating-side-offset);
	left: auto;
	bottom: var(--cozy-chat-floating-bottom-offset);
}

.cozy-chat-widget--inline {
	position: relative;
	width: 100%;
	max-width: 460px;
	margin: 20px 0;
}

.cozy-chat-widget .cozy-chat-toggle {
	-webkit-appearance: none;
	appearance: none;
	display: inline-flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: auto;
	height: 44px;
	min-width: 44px;
	min-height: 44px;
	padding: 0 14px 0 12px !important;
	border: none !important;
	border-radius: 999px !important;
	background: var(--cozy-primary) !important;
	color: #fff !important;
	cursor: pointer;
	box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
	transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
	position: relative;
	overflow: visible;
}

.cozy-chat-toggle__label {
	display: inline;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
}

.cozy-chat-toggle__icon--open svg {
	width: 22px;
	height: 22px;
}

.cozy-chat-widget .cozy-chat-toggle:hover {
	background: var(--cozy-primary-hover) !important;
	transform: translateY(-1px);
}

.cozy-chat-widget--floating.is-open .cozy-chat-toggle {
	display: none !important;
}

.cozy-chat-widget .cozy-chat-toggle:focus-visible {
	outline: 2px solid var(--cozy-primary);
	outline-offset: 3px;
}

.cozy-chat-toggle__icon {
	display: flex;
	align-items: center;
	justify-content: center;
}

.cozy-chat-toggle__icon--close {
	display: none;
	font-size: 34px;
	line-height: 1;
	font-weight: 300;
}

.cozy-chat-widget.is-open .cozy-chat-toggle__icon--open {
	display: none;
}

.cozy-chat-widget.is-open .cozy-chat-toggle__icon--close {
	display: flex;
}

.cozy-chat-toggle__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	background: var(--cozy-error);
	border: 2px solid #fff;
	border-radius: 999px;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	pointer-events: none;
}

.cozy-chat-toggle__badge[hidden] {
	display: none !important;
}

.cozy-chat-toggle--pulse {
	animation: cozy-chat-launcher-pulse 0.55s ease-in-out 2;
}

@keyframes cozy-chat-launcher-pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.08); }
}

.cozy-chat-toast {
	position: absolute;
	right: 0;
	bottom: 62px;
	width: min(280px, calc(100vw - 24px));
	padding: 10px 12px;
	border-radius: 14px;
	background: #fff;
	border: 1px solid var(--cozy-border);
	box-shadow: var(--cozy-shadow-window);
	display: flex;
	flex-direction: column;
	gap: 8px;
	z-index: 5;
}

.cozy-chat-widget.cozy-chat-mobile-left .cozy-chat-toast {
	right: auto;
	left: 0;
}

.cozy-chat-toast[hidden] {
	display: none !important;
}

.cozy-chat-toast__body {
	appearance: none;
	border: 0;
	background: transparent;
	padding: 0;
	margin: 0;
	text-align: left;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	gap: 4px;
	color: inherit;
	font: inherit;
}

.cozy-chat-toast__title {
	font-size: 13px;
	font-weight: 700;
	color: var(--cozy-text);
}

.cozy-chat-toast__preview {
	font-size: 12px;
	line-height: 1.35;
	color: var(--cozy-muted, #6b7280);
}

.cozy-chat-toast__open {
	appearance: none;
	border: 0;
	border-radius: 10px;
	background: var(--cozy-primary, #111827);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	padding: 8px 10px;
	cursor: pointer;
}

.cozy-chat-status-area {
	flex-shrink: 0;
	margin: 6px 12px 0;
	padding: 8px 10px;
	border-radius: 12px;
	background: #f8fafc;
	border: 1px solid #e5e7eb;
	font-size: 12px;
	line-height: 1.4;
	color: #374151;
}

.cozy-chat-status-area[hidden] {
	display: none !important;
}

.cozy-chat-contact-offer {
	flex-shrink: 0;
	margin: 6px 12px 0;
}

.cozy-chat-contact-offer[hidden] {
	display: none !important;
}

.cozy-chat-contact-offer.is-visible .cozy-chat-contact-offer__success {
	animation: cozy-chat-contact-fade-in 200ms ease-out;
}

@keyframes cozy-chat-contact-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.cozy-chat-contact-offer.is-visible .cozy-chat-contact-offer__success {
		animation: none;
	}
}

.cozy-chat-contact-offer__card {
	padding: 10px 12px;
	border-radius: 12px;
	background: #f0f7ff;
	border: 1px solid #dbeafe;
	font-size: 12px;
	line-height: 1.4;
	color: #1f2937;
}

.cozy-chat-contact-offer__title {
	font-weight: 700;
	margin-bottom: 4px;
}

.cozy-chat-contact-offer__desc {
	color: #4b5563;
	margin-bottom: 8px;
}

.cozy-chat-contact-offer__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 8px;
}

.cozy-chat-contact-offer__btn {
	border: 0;
	border-radius: 8px;
	padding: 7px 10px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	line-height: 1.2;
}

.cozy-chat-contact-offer__btn--primary {
	background: #2563eb;
	color: #fff;
}

.cozy-chat-contact-offer__btn--ghost {
	background: transparent;
	color: #6b7280;
	border: 1px solid #e5e7eb;
}

.cozy-chat-contact-offer__label {
	display: block;
	font-weight: 600;
	margin: 6px 0 4px;
}

.cozy-chat-contact-offer__input {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 14px;
}

.cozy-chat-contact-offer__methods {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.cozy-chat-contact-offer__method {
	border: 1px solid #d1d5db;
	background: #fff;
	border-radius: 999px;
	padding: 5px 10px;
	font-size: 12px;
	cursor: pointer;
}

.cozy-chat-contact-offer__method.is-active {
	border-color: #2563eb;
	background: #eff6ff;
	color: #1d4ed8;
	font-weight: 600;
}

.cozy-chat-contact-offer__privacy {
	margin-top: 8px;
	color: #6b7280;
	font-size: 11px;
}

.cozy-chat-contact-offer__privacy-link {
	display: inline-block;
	margin-top: 2px;
	font-size: 11px;
	color: #2563eb;
}

.cozy-chat-contact-offer__error {
	margin-top: 6px;
	color: #b91c1c;
	font-size: 12px;
}

.cozy-chat-contact-offer__note {
	margin-bottom: 8px;
	padding: 6px 8px;
	border-radius: 8px;
	background: #fffbeb;
	color: #92400e;
	font-size: 11px;
}

.cozy-chat-contact-offer__success {
	padding: 10px 12px;
	border-radius: 12px;
	background: #ecfdf5;
	border: 1px solid #a7f3d0;
	color: #065f46;
	font-size: 12px;
	font-weight: 600;
}

.cozy-chat-status-area__line {
	display: flex;
	align-items: center;
	gap: 6px;
	font-weight: 600;
}

.cozy-chat-status-area__sub,
.cozy-chat-status-area__hint {
	margin-top: 4px;
	font-weight: 400;
	color: #6b7280;
}

.cozy-chat-typing-dots {
	display: inline-flex;
	gap: 3px;
	margin-left: 4px;
}

.cozy-chat-typing-dots i {
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: #9ca3af;
	display: block;
	animation: cozy-chat-dot 1s infinite ease-in-out;
}

.cozy-chat-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.cozy-chat-typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes cozy-chat-dot {
	0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-2px); }
}

.cozy-chat-notif-prompt {
	flex-shrink: 0;
	margin: 6px 12px 0;
	padding: 8px 10px;
	border-radius: 12px;
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	font-size: 12px;
	position: relative;
	z-index: 4;
}

.cozy-chat-notif-prompt[hidden] {
	display: none !important;
}

.cozy-chat-notif-prompt__actions {
	display: flex;
	gap: 8px;
	margin-top: 6px;
}

.cozy-chat-notif-prompt__yes,
.cozy-chat-notif-prompt__no {
	appearance: none;
	border: 0;
	border-radius: 8px;
	padding: 6px 10px;
	font-size: 12px;
	cursor: pointer;
}

.cozy-chat-notif-prompt__yes {
	background: #1d4ed8;
	color: #fff;
}

.cozy-chat-notif-prompt__no {
	background: #e5e7eb;
	color: #111827;
}

.cozy-chat-scroll-latest {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	bottom: 88px;
	z-index: 3;
	appearance: none;
	border: 0;
	border-radius: 999px;
	padding: 6px 12px;
	font-size: 12px;
	font-weight: 600;
	background: #111827;
	color: #fff;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.cozy-chat-scroll-latest[hidden] {
	display: none !important;
}

@keyframes cozy-chat-panel-in {
	from { opacity: 0; transform: translateY(14px); }
	to { opacity: 1; transform: translateY(0); }
}

@keyframes cozy-chat-message-in {
	from { opacity: 0; transform: translateY(5px); }
	to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.cozy-chat-widget.is-open .cozy-chat-window,
	.cozy-chat-message--enter,
	.cozy-chat-toggle--pulse,
	.cozy-chat-typing-dots i {
		animation: none !important;
	}
}

.cozy-chat-status-area {
	position: relative;
	z-index: 2;
	flex-shrink: 0;
}

/* Chat window */
.cozy-chat-window,
.cozy-chat-panel {
	display: flex;
	flex-direction: column;
	width: 370px;
	height: 580px;
	max-height: calc(100vh - 120px);
	background: var(--cozy-bg);
	border-radius: 22px;
	box-shadow: var(--cozy-shadow-window);
	overflow: hidden;
	border: 1px solid rgba(229, 231, 235, 0.85);
	position: relative;
}

.cozy-chat-widget--floating .cozy-chat-window,
.cozy-chat-widget--floating .cozy-chat-panel {
	position: absolute;
	right: 0;
	bottom: 56px;
	max-width: calc(100vw - 32px);
}

.cozy-chat-widget--floating.cozy-chat-mobile-left .cozy-chat-window,
.cozy-chat-widget--floating.cozy-chat-mobile-left .cozy-chat-panel {
	right: auto;
	left: 0;
}

.cozy-chat-widget--floating.is-open .cozy-chat-window,
.cozy-chat-widget--floating.is-open .cozy-chat-panel {
	animation: cozy-chat-panel-in 0.22s ease;
}

.cozy-chat-widget--floating .cozy-chat-window[hidden],
.cozy-chat-widget--floating .cozy-chat-panel[hidden] {
	display: none !important;
}

.cozy-chat-widget--inline .cozy-chat-window,
.cozy-chat-widget--inline .cozy-chat-panel {
	width: 100%;
	height: 600px;
	max-height: 640px;
	border-radius: 18px;
}

.cozy-chat-widget--inline .cozy-chat-toggle {
	display: none !important;
}

/* Header */
.cozy-chat-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	flex-shrink: 0;
	min-height: 80px;
	padding: 16px;
	background: linear-gradient(135deg, #2563eb 0%, #3b82f6 52%, #1d4ed8 100%);
	color: #fff;
}

.cozy-chat-header-content {
	min-width: 0;
	flex: 1 1 auto;
}

.cozy-chat-title,
.cozy-chat-header__title {
	margin: 0 0 4px;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.25;
	color: #fff;
}

.cozy-chat-subtitle,
.cozy-chat-header__subtitle {
	margin: 0 0 8px;
	font-size: 13px;
	line-height: 1.35;
	color: rgba(255, 255, 255, 0.92);
}

.cozy-chat-status,
.cozy-chat-header__status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	font-size: 12px;
	line-height: 1.2;
	color: rgba(255, 255, 255, 0.95);
}

.cozy-chat-status-dot,
.cozy-chat-header__status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--cozy-success);
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
	flex-shrink: 0;
}

.cozy-chat-widget .cozy-chat-close {
	flex-shrink: 0;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 36px !important;
	height: 36px !important;
	min-width: 36px !important;
	min-height: 36px !important;
	padding: 0 !important;
	border: none !important;
	border-radius: 999px !important;
	background: rgba(255, 255, 255, 0.16) !important;
	color: #fff !important;
	cursor: pointer;
	transition: background 0.2s ease;
}

.cozy-chat-widget .cozy-chat-close:hover {
	background: rgba(255, 255, 255, 0.28) !important;
}

.cozy-chat-widget .cozy-chat-close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.cozy-chat-close__icon {
	display: block;
	font-size: 24px;
	line-height: 1;
	font-weight: 400;
	color: #fff;
}

/* Messages */
.cozy-chat-messages {
	flex: 1 1 auto;
	min-height: 0;
	overflow-x: hidden;
	overflow-y: auto;
	padding: 14px 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--cozy-bg);
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}

.cozy-chat-messages::-webkit-scrollbar {
	width: 6px;
}

.cozy-chat-messages::-webkit-scrollbar-thumb {
	background: rgba(107, 114, 128, 0.35);
	border-radius: 999px;
}

.cozy-chat-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 28px 20px;
	color: var(--cozy-muted);
}

.cozy-chat-empty__icon {
	font-size: 28px;
	margin-bottom: 10px;
}

.cozy-chat-empty__title {
	margin: 0 0 8px;
	font-size: 16px;
	font-weight: 600;
	color: var(--cozy-text);
}

.cozy-chat-empty__text {
	margin: 0;
	max-width: 260px;
	font-size: 14px;
	line-height: 1.5;
}

/* Product context card (under header, sticky) */
.cozy-chat-product-slot {
	flex-shrink: 0;
	padding: 8px 10px 0;
	background: var(--cozy-bg);
}

.cozy-chat-product-slot[hidden] {
	display: none !important;
}

.cozy-chat-product-context {
	position: relative;
	width: 100%;
	max-width: 100%;
	border-radius: 14px;
	background: var(--cozy-surface);
	border: 1px solid var(--cozy-border);
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
	overflow: hidden;
}

.cozy-chat-widget .cozy-chat-product-toggle {
	-webkit-appearance: none;
	appearance: none;
	display: block;
	width: 100% !important;
	min-height: 44px;
	margin: 0 !important;
	padding: 0 !important;
	border: none !important;
	background: transparent !important;
	color: inherit !important;
	text-align: left;
	cursor: pointer;
	box-shadow: none !important;
}

.cozy-chat-widget .cozy-chat-product-toggle:focus-visible {
	outline: 2px solid var(--cozy-primary);
	outline-offset: 2px;
}

.cozy-chat-product-compact {
	display: none;
	align-items: center;
	gap: 10px;
	min-height: 56px;
	max-height: 68px;
	padding: 8px 10px;
}

.cozy-chat-product-context[data-state="collapsed"] .cozy-chat-product-compact {
	display: flex;
}

.cozy-chat-product-compact-body {
	min-width: 0;
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.cozy-chat-product-thumb {
	flex-shrink: 0;
	object-fit: contain;
	border-radius: 10px;
	background: #f9fafb;
	border: 1px solid var(--cozy-border);
}

.cozy-chat-product-thumb--compact {
	width: 44px;
	height: 44px;
}

.cozy-chat-product-thumb--details {
	width: 64px;
	height: 64px;
}

.cozy-chat-product-title {
	margin: 0;
	font-size: 13px;
	line-height: 1.3;
	font-weight: 600;
	color: var(--cozy-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.cozy-chat-product-title--compact {
	-webkit-line-clamp: 2;
	line-clamp: 2;
}

.cozy-chat-product-price-compact {
	font-size: 12px;
	line-height: 1.2;
	color: var(--cozy-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cozy-chat-product-chevron {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	margin-left: auto;
	background: no-repeat center / 14px 14px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	transition: transform 0.2s ease;
}

.cozy-chat-product-context[data-state="expanded"] .cozy-chat-product-chevron {
	transform: rotate(180deg);
}

.cozy-chat-product-details {
	padding: 10px 40px 12px 12px;
	display: grid;
	grid-template-rows: 1fr;
	transition: opacity 0.2s ease;
}

.cozy-chat-product-context[data-state="collapsed"] .cozy-chat-product-details {
	display: none;
}

.cozy-chat-product-label {
	margin: 0 0 8px;
	font-size: 12px;
	line-height: 1.3;
	color: var(--cozy-muted);
}

.cozy-chat-product-details-row {
	display: flex;
	gap: 10px;
	align-items: flex-start;
}

.cozy-chat-product-info {
	min-width: 0;
	flex: 1 1 auto;
}

.cozy-chat-product-price {
	margin: 4px 0 6px;
	font-size: 13px;
	line-height: 1.3;
	color: var(--cozy-muted);
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px;
}

.cozy-chat-product-price-current {
	font-weight: 600;
	color: var(--cozy-text);
}

.cozy-chat-product-price-regular {
	text-decoration: line-through;
	opacity: 0.75;
	font-size: 12px;
}

.cozy-chat-product-link {
	display: inline-block;
	font-size: 12px;
	font-weight: 600;
	color: var(--cozy-primary);
	text-decoration: none;
}

.cozy-chat-product-link:hover {
	color: var(--cozy-primary-hover);
	text-decoration: underline;
}

/* Expanded: show floating chevron on the details card via toggle overlay */
.cozy-chat-product-context[data-state="expanded"] .cozy-chat-product-toggle {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 36px !important;
	min-width: 36px !important;
	min-height: 36px !important;
	height: 36px;
	padding: 0 !important;
	border-radius: 999px !important;
	z-index: 2;
}

.cozy-chat-product-context[data-state="expanded"] .cozy-chat-product-compact {
	display: none;
}

.cozy-chat-product-context[data-state="expanded"] .cozy-chat-product-toggle .cozy-chat-product-chevron {
	margin: 0 auto;
	display: block;
}

.cozy-chat-product-context[data-state="expanded"] .cozy-chat-product-toggle .cozy-chat-product-compact-body,
.cozy-chat-product-context[data-state="expanded"] .cozy-chat-product-toggle .cozy-chat-product-thumb {
	display: none;
}

@media (max-width: 380px) {
	.cozy-chat-product-price-compact {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cozy-chat-product-chevron,
	.cozy-chat-product-details {
		transition: none;
	}
}

/* Bubbles */
.cozy-chat-message {
	max-width: 78%;
	padding: 10px 12px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.35;
	word-break: break-word;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}

.cozy-chat-message--enter {
	animation: cozy-chat-message-in 0.2s ease;
}

.cozy-chat-message__text:empty {
	display: none;
}

.cozy-chat-message__text a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.cozy-chat-message--customer {
	align-self: flex-end;
	background: var(--cozy-primary);
	color: #fff;
	border-radius: 16px 16px 4px 16px;
}

.cozy-chat-message--customer .cozy-chat-message__text a {
	color: #fff;
}

.cozy-chat-message--manager {
	align-self: flex-start;
	background: var(--cozy-surface);
	color: var(--cozy-text);
	border: 1px solid var(--cozy-border);
	border-radius: 16px 16px 16px 4px;
}

.cozy-chat-message--system {
	align-self: center;
	max-width: 92%;
	background: transparent;
	color: var(--cozy-muted);
	font-size: 12px;
	padding: 4px 8px;
}

.cozy-chat-message__attachment {
	display: block;
	margin-top: 8px;
	max-width: 100%;
	line-height: 0;
}

.cozy-chat-message__attachment:first-child {
	margin-top: 0;
}

.cozy-chat-message img,
.cozy-chat-message__image,
.cozy-chat-attachment-image {
	display: block;
	max-width: 100%;
	width: auto !important;
	height: auto !important;
	max-height: 170px !important;
	object-fit: contain;
	border-radius: 14px;
	background: var(--cozy-surface);
	border: 1px solid var(--cozy-border);
}

.cozy-chat-message__time {
	display: block;
	margin-top: 6px;
	font-size: 11px;
	line-height: 1.2;
	opacity: 0.65;
}

/* Form / footer */
.cozy-chat-form {
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	background: var(--cozy-surface);
	border-top: 1px solid var(--cozy-border);
}

.cozy-chat-honeypot {
	position: absolute;
	left: -10000px;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.cozy-chat-footer,
.cozy-chat-input-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	background: var(--cozy-surface);
}

.cozy-chat-attachment-preview {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 12px 0;
	padding: 8px;
	border: 1px solid var(--cozy-border);
	border-radius: 12px;
	background: var(--cozy-bg);
}

.cozy-chat-attachment-preview[hidden] {
	display: none !important;
}

.cozy-chat-attachment-preview__image {
	width: 48px;
	height: 48px;
	border-radius: 10px;
	object-fit: cover;
	background: var(--cozy-border);
}

.cozy-chat-attachment-preview__name {
	flex: 1;
	min-width: 0;
	font-size: 12px;
	color: var(--cozy-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.cozy-chat-widget .cozy-chat-attach {
	flex: 0 0 auto;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 44px !important;
	height: 44px !important;
	min-width: 44px !important;
	padding: 0 !important;
	border: 1px solid var(--cozy-border) !important;
	border-radius: 999px !important;
	background: var(--cozy-surface) !important;
	color: var(--cozy-muted) !important;
	cursor: pointer;
}

.cozy-chat-widget .cozy-chat-attach:hover {
	border-color: var(--cozy-primary) !important;
	color: var(--cozy-primary) !important;
	background: rgba(37, 99, 235, 0.06) !important;
}

.cozy-chat-attach__icon {
	width: 22px;
	height: 22px;
}

.cozy-chat-widget .cozy-chat-input {
	flex: 1 1 auto;
	width: auto;
	min-width: 0;
	height: 44px;
	min-height: 44px;
	max-height: 96px;
	margin: 0;
	padding: 11px 14px;
	border: 1px solid var(--cozy-border) !important;
	border-radius: 999px;
	background: var(--cozy-bg) !important;
	color: var(--cozy-text) !important;
	resize: none !important;
	overflow-y: hidden;
	font-size: 14px;
	line-height: 20px;
	box-shadow: none !important;
}

.cozy-chat-widget .cozy-chat-input.is-multiline {
	border-radius: 16px;
	overflow-y: auto;
}

.cozy-chat-widget .cozy-chat-input:focus {
	outline: none;
	border-color: var(--cozy-primary) !important;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
	background: var(--cozy-surface) !important;
}

.cozy-chat-widget .cozy-chat-input::-webkit-scrollbar {
	width: 0;
	height: 0;
}

.cozy-chat-widget .cozy-chat-send {
	flex: 0 0 auto;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 44px !important;
	height: 44px !important;
	min-width: 44px !important;
	padding: 0 !important;
	border: none !important;
	border-radius: 999px !important;
	background: var(--cozy-primary) !important;
	color: #fff !important;
	cursor: pointer;
}

.cozy-chat-widget .cozy-chat-send:hover:not(:disabled) {
	background: var(--cozy-primary-hover) !important;
}

.cozy-chat-widget .cozy-chat-send:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.cozy-chat-send__icon {
	width: 20px;
	height: 20px;
}

.cozy-chat-widget .cozy-chat-attachment-preview__remove {
	width: 32px;
	height: 32px;
	border: 1px solid var(--cozy-border);
	border-radius: 8px;
	background: var(--cozy-surface);
	color: var(--cozy-muted);
	cursor: pointer;
}

.cozy-chat-error {
	padding: 10px 12px;
	background: #fef2f2;
	color: #b91c1c;
	font-size: 13px;
	border-top: 1px solid #fecaca;
	flex-shrink: 0;
}

.cozy-chat-error[hidden] {
	display: none !important;
}

/* Mobile fullscreen + floating toggle strategy */
@media (max-width: 767px) {
	body.cozy-chat-mobile-open {
		overflow: hidden !important;
		position: fixed;
		width: 100%;
		touch-action: none;
	}

	/* Wrapper is a positioning anchor only; toggle is fixed to viewport */
	.cozy-chat-widget--floating:not(.is-open) {
		position: fixed !important;
		inset: auto !important;
		top: auto !important;
		left: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		width: 0 !important;
		height: 0 !important;
		margin: 0 !important;
		padding: 0 !important;
		overflow: visible !important;
		pointer-events: none !important;
		background: transparent !important;
		border: none !important;
		box-shadow: none !important;
		z-index: 99990 !important;
	}

	.cozy-chat-widget--floating .cozy-chat-toggle {
		position: fixed !important;
		top: auto !important;
		bottom: calc(var(--cozy-chat-mobile-bottom-offset) + var(--cozy-chat-mobile-lang-extra) + env(safe-area-inset-bottom)) !important;
		pointer-events: auto !important;
		z-index: 99990 !important;
		transform: none !important;
	}

	.cozy-chat-widget--floating .cozy-chat-toggle:hover {
		transform: none !important;
	}

	.cozy-chat-widget--floating.cozy-chat-mobile-left .cozy-chat-toggle {
		left: var(--cozy-chat-mobile-side-offset) !important;
		right: auto !important;
	}

	.cozy-chat-widget--floating.cozy-chat-mobile-right .cozy-chat-toggle {
		right: var(--cozy-chat-mobile-side-offset) !important;
		left: auto !important;
	}

	.cozy-chat-widget--floating.cozy-chat-mobile-right {
		--cozy-chat-mobile-lang-extra: 0px;
	}

	.cozy-chat-toggle__icon--close {
		display: none !important;
	}

	.cozy-chat-widget.is-open .cozy-chat-toggle__icon--open {
		display: flex;
	}

	body.cozy-chat-mobile-open .cozy-chat-widget--floating .cozy-chat-toggle,
	body.cozy-chat-open .cozy-chat-widget--floating .cozy-chat-toggle {
		display: none !important;
	}

	.cozy-chat-widget--floating.is-open {
		position: fixed !important;
		inset: 0 !important;
		width: 100% !important;
		height: 100dvh !important;
		max-width: none !important;
		max-height: none !important;
		pointer-events: auto !important;
		z-index: 2147483001 !important;
	}

	.cozy-chat-widget--floating.is-open .cozy-chat-window,
	.cozy-chat-widget--floating.is-open .cozy-chat-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100dvh;
		max-width: none;
		max-height: none;
		bottom: auto;
		right: auto;
		border-radius: 0;
		border: none;
		box-shadow: none;
		animation: none;
	}

	.cozy-chat-header {
		min-height: 72px;
		padding: calc(14px + env(safe-area-inset-top)) 14px 14px;
	}

	.cozy-chat-messages {
		padding: 12px 10px;
	}

	.cozy-chat-message img,
	.cozy-chat-message__image,
	.cozy-chat-attachment-image {
		max-height: 190px !important;
	}

	.cozy-chat-footer,
	.cozy-chat-input-row {
		padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
	}
}
