/**
 * Site AI Chat – Widget (front-end)
 * Flat, minimal, light shadow. No heavy colors.
 */

.sac-widget {
	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	color: #1e1e1e;
	box-sizing: border-box;
}

.sac-widget *,
.sac-widget *::before,
.sac-widget *::after {
	box-sizing: border-box;
}

/* Position */
.sac-widget--bottom-right {
	bottom: 20px;
	right: 20px;
}
.sac-widget--bottom-left {
	bottom: 20px;
	left: 20px;
}
.sac-widget--top-right {
	top: 20px;
	right: 20px;
}
.sac-widget--top-left {
	top: 20px;
	left: 20px;
}

/* Toggle button */
.sac-widget__toggle {
	width: 56px;
	height: 56px;
	border: none;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #50575e;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.sac-widget__toggle:hover {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
	color: #1e1e1e;
}
.sac-widget__toggle:focus {
	outline: none;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.4);
}
.sac-widget__toggle-icon {
	flex-shrink: 0;
}

/* Panel – anchor so it stays fully in view; hide when [hidden] */
.sac-widget__panel {
	position: absolute;
	bottom: 72px;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 480px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 8px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.sac-widget__panel[hidden] {
	display: none !important;
}
/* When open, keep toggle above panel so it stays clickable to close */
.sac-widget--open .sac-widget__toggle {
	position: relative;
	z-index: 1;
}
/* Right-side positions: panel opens to the left so it stays on screen */
.sac-widget--bottom-right .sac-widget__panel,
.sac-widget--top-right .sac-widget__panel {
	right: 0;
	left: auto;
}
/* Left-side positions: panel opens to the right so it stays on screen */
.sac-widget--bottom-left .sac-widget__panel,
.sac-widget--top-left .sac-widget__panel {
	left: 0;
	right: auto;
}
.sac-widget--top-right .sac-widget__panel,
.sac-widget--top-left .sac-widget__panel {
	bottom: auto;
	top: 72px;
}

/* Header */
.sac-widget__header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	border-bottom: 1px solid #eee;
	background: #fafafa;
	flex-shrink: 0;
}
.sac-widget__avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
}
.sac-widget__avatar--placeholder {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #dcdcde;
	color: #50575e;
	font-size: 1rem;
	font-weight: 600;
}
.sac-widget__bot-name {
	flex: 1;
	font-weight: 600;
	font-size: 0.9375rem;
	color: #1e1e1e;
}
.sac-widget__header-actions {
	display: flex;
	align-items: center;
	gap: 2px;
}
.sac-widget__end-chat {
	width: 32px;
	height: 32px;
	border: none;
	background: transparent;
	border-radius: 4px;
	color: #646970;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, color 0.15s ease;
}
.sac-widget__end-chat:hover {
	background: #fcf0f1;
	color: #d63638;
}
.sac-widget__end-chat[hidden] {
	display: none;
}
.sac-widget__close {
	width: 36px;
	height: 36px;
	border: none;
	background: transparent;
	border-radius: 4px;
	cursor: pointer;
	color: #646970;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, color 0.15s ease;
}
.sac-widget__close:hover {
	background: #f0f0f1;
	color: #1e1e1e;
}
.sac-widget__close:focus {
	outline: none;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.3);
}

/* Messages area */
.sac-widget__messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.sac-widget__welcome {
	color: #646970;
	font-size: 0.875rem;
	padding: 10px 12px;
	background: #f6f7f7;
	border-radius: 8px;
	border: 1px solid #eee;
	align-self: flex-start;
	max-width: 85%;
}
.sac-widget__msg {
	padding: 10px 12px;
	border-radius: 8px;
	max-width: 85%;
	word-wrap: break-word;
}
.sac-widget__msg--user {
	align-self: flex-end;
	background: #2271b1;
	color: #fff;
	border: none;
}
.sac-widget__msg--bot {
	align-self: flex-start;
	background: #f6f7f7;
	border: 1px solid #eee;
	color: #1e1e1e;
	transition: opacity 0.15s ease;
}
.sac-widget__msg--bot p {
	margin: 0 0 0.4em;
	line-height: 1.5;
}
.sac-widget__msg--bot p:last-child {
	margin-bottom: 0;
}
.sac-widget__msg--bot strong {
	font-weight: 600;
}
.sac-widget__msg--bot em {
	font-style: italic;
}
.sac-widget__msg--bot ol,
.sac-widget__msg--bot ul {
	margin: 0.3em 0 0.5em;
	padding-left: 1.4em;
}
.sac-widget__msg--bot li {
	margin-bottom: 0.2em;
	line-height: 1.45;
}
.sac-widget__msg--bot br {
	display: block;
	content: "";
	margin-top: 0.3em;
}
.sac-widget__msg--error {
	align-self: flex-start;
	background: #fcf0f1;
	border: 1px solid #f1aeb5;
	color: #1e1e1e;
}
.sac-widget__msg-typing {
	align-self: flex-start;
	padding: 12px 18px;
	background: #f6f7f7;
	border: 1px solid #eee;
	border-radius: 8px;
	min-height: 40px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.sac-widget__msg-typing span {
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #646970;
	animation: sac-typing 1.2s ease-in-out infinite;
}
.sac-widget__msg-typing span:nth-child(2) { animation-delay: 0.15s; }
.sac-widget__msg-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sac-typing {
	0%, 60%, 100% { opacity: 0.35; transform: scale(0.85); }
	30% { opacity: 1; transform: scale(1.1); }
}

/* Visitor form (before chat) */
.sac-widget__visitor-form {
	padding: 12px 14px;
	border-bottom: 1px solid #eee;
	background: #fafafa;
	flex-shrink: 0;
}
.sac-widget__visitor-desc {
	font-size: 0.8125rem;
	color: #646970;
	margin: 0 0 0.5rem;
}
.sac-widget__visitor-input {
	display: block;
	width: 100%;
	padding: 0.4rem 0.6rem;
	margin-bottom: 0.5rem;
	font-size: 0.875rem;
	border: 1px solid #dcdcde;
	border-radius: 4px;
}
.sac-widget__start-btn {
	margin-top: 0.25rem;
}

/* Did that help? */
.sac-widget__did-help {
	align-self: flex-start;
	padding: 8px 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}
.sac-widget__did-help-label {
	font-size: 0.8125rem;
	color: #646970;
	margin-right: 4px;
}
.sac-widget__did-help-btn {
	padding: 4px 10px;
	font-size: 0.8125rem;
	border-radius: 4px;
	border: 1px solid #dcdcde;
	background: #fff;
	cursor: pointer;
	color: #50575e;
}
.sac-widget__did-help-btn:hover {
	background: #f0f0f1;
}
.sac-widget__did-help-btn--no {
	border-color: #2271b1;
	color: #2271b1;
}
.sac-widget__did-help-btn--no:hover {
	background: #2271b1;
	color: #fff;
}

/* Talk to a person link */
.sac-widget__help-footer {
	padding: 8px 14px;
	border-top: 1px solid #eee;
	background: #fafafa;
	flex-shrink: 0;
}
.sac-widget__help-link {
	font-size: 0.8125rem;
	color: #2271b1;
	text-decoration: none;
}
.sac-widget__help-link:hover {
	text-decoration: underline;
}

/* Input area */
.sac-widget__input-wrap {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	padding: 12px 14px;
	border-top: 1px solid #eee;
	background: #fff;
	flex-shrink: 0;
}
.sac-widget__input {
	flex: 1;
	min-height: 44px;
	max-height: 120px;
	padding: 10px 12px;
	border: 1px solid #dcdcde;
	border-radius: 8px;
	font-size: 0.875rem;
	line-height: 1.4;
	resize: none;
	transition: border-color 0.15s ease;
}
.sac-widget__input:focus {
	outline: none;
	border-color: #8c8f94;
}
.sac-widget__input::placeholder {
	color: #8c8f94;
}
.sac-widget__send {
	width: 44px;
	height: 44px;
	flex-shrink: 0;
	border: none;
	border-radius: 8px;
	background: #2271b1;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}
.sac-widget__send:hover {
	background: #135e96;
}
.sac-widget__send:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}
.sac-widget__send:focus {
	outline: none;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.4);
}

.sac-widget__live-notice {
	padding: 8px 12px;
	margin-bottom: 8px;
	background: #e7f5fe;
	border-left: 3px solid #2271b1;
	border-radius: 0 6px 6px 0;
	font-size: 0.8125rem;
	color: #1e1e1e;
}

.screen-reader-text {
	clip: rect(1px, 1px, 1px, 1px);
	height: 1px;
	overflow: hidden;
	position: absolute;
	width: 1px;
}
