/* ALN Live Chat - Frontend widget */

#aln-chat-root {
	--aln-navy: #1a2b4a;
	--aln-cyan: #00b0c8;
	--aln-light: #f5f8fa;
	--aln-border: rgba(0,0,0,0.1);
	--aln-muted: #6b7280;
	--aln-text: #111827;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	color: var(--aln-text);
}

/* Reset button styles within the widget so themes can't color our controls. */
#aln-chat-root button {
	background: none;
	border: none;
	padding: 0;
	margin: 0;
	font: inherit;
	color: inherit;
	cursor: pointer;
	line-height: 1;
	box-shadow: none;
	text-transform: none;
	letter-spacing: normal;
}
#aln-chat-root button:hover,
#aln-chat-root button:focus,
#aln-chat-root button:active {
	background: none;
	box-shadow: none;
	outline: none;
}

#aln-chat-root .aln-bubble {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--aln-navy);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0,0,0,0.15);
	z-index: 999998;
	border: none;
	transition: transform 0.15s ease;
}
#aln-chat-root .aln-bubble:hover { transform: scale(1.05); background: var(--aln-navy); }
#aln-chat-root .aln-bubble svg { width: 26px; height: 26px; fill: #fff; }
.aln-bubble-badge {
	position: absolute;
	top: -2px; right: -2px;
	background: #ef4444;
	color: #fff;
	font-size: 11px;
	min-width: 18px;
	height: 18px;
	border-radius: 9px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 5px;
	font-weight: 600;
}

.aln-panel {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 320px;
	height: 440px;
	max-height: calc(100vh - 40px);
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 12px 32px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.08);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 999998;
}
.aln-header {
	background: var(--aln-navy);
	color: #fff;
	padding: 12px 14px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	position: relative;
}
.aln-header-title { font-size: 14px; font-weight: 600; }
.aln-header-status {
	font-size: 11px;
	opacity: 0.8;
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 2px;
}
.aln-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
#aln-chat-root .aln-close {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	opacity: 0.75;
	padding: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
}
#aln-chat-root .aln-close:hover { opacity: 1; background: none; }
#aln-chat-root .aln-close svg { width: 16px; height: 16px; fill: #fff; }

.aln-header-actions {
	display: flex;
	align-items: center;
	gap: 10px;
}
#aln-chat-root .aln-end-link {
	background: none;
	border: none;
	color: #fff;
	opacity: 0.75;
	cursor: pointer;
	font-size: 12px;
	font-family: inherit;
	padding: 2px 4px;
	text-decoration: underline;
	text-underline-offset: 2px;
}
#aln-chat-root .aln-end-link:hover { opacity: 1; background: none; }
#aln-chat-root .aln-end-link.aln-armed {
	opacity: 1;
	background: #dc2626;
	color: #fff;
	padding: 2px 8px;
	border-radius: 4px;
	text-decoration: none;
	font-weight: 600;
	text-transform: uppercase;
	font-size: 10px;
	letter-spacing: 0.3px;
	animation: aln-armed-pulse 1s ease-in-out infinite;
}
@keyframes aln-armed-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.7; }
}

.aln-body {
	flex: 1;
	padding: 12px;
	overflow-y: auto;
	background: var(--aln-light);
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.aln-msg { max-width: 82%; }
.aln-msg-bubble {
	padding: 8px 11px;
	border-radius: 10px;
	font-size: 13px;
	line-height: 1.45;
	word-wrap: break-word;
}
.aln-msg-meta {
	font-size: 10px;
	color: var(--aln-muted);
	margin-top: 3px;
}
.aln-msg.aln-from-visitor { align-self: flex-end; }
.aln-msg.aln-from-visitor .aln-msg-bubble { background: var(--aln-cyan); color: #fff; }
.aln-msg.aln-from-visitor .aln-msg-meta { text-align: right; }
.aln-msg.aln-from-operator, .aln-msg.aln-from-system { align-self: flex-start; }
.aln-msg.aln-from-operator .aln-msg-bubble { background: #fff; border: 1px solid var(--aln-border); }
.aln-msg.aln-from-system .aln-msg-bubble {
	background: transparent;
	color: var(--aln-muted);
	font-style: italic;
	border: none;
	padding: 4px 0;
	font-size: 12px;
}

.aln-input-row {
	border-top: 1px solid var(--aln-border);
	padding: 8px;
	display: flex;
	gap: 6px;
	background: #fff;
}
.aln-input-row input {
	flex: 1;
	border: 1px solid var(--aln-border);
	border-radius: 6px;
	padding: 0 10px;
	height: 34px;
	font-size: 13px;
	outline: none;
	font-family: inherit;
}
.aln-input-row input:focus { border-color: var(--aln-cyan); }
#aln-chat-root .aln-input-row button {
	height: 34px;
	padding: 0 14px;
	background: var(--aln-navy);
	color: #fff;
	border: none;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
}
#aln-chat-root .aln-input-row button:hover { background: #243a66; }
#aln-chat-root .aln-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.aln-waiting {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 24px 16px;
	color: var(--aln-muted);
	font-size: 13px;
	gap: 8px;
	flex: 1;
}
.aln-waiting-spinner {
	width: 24px; height: 24px;
	border: 2px solid var(--aln-border);
	border-top-color: var(--aln-cyan);
	border-radius: 50%;
	animation: aln-spin 0.9s linear infinite;
}
@keyframes aln-spin { to { transform: rotate(360deg); } }

.aln-hidden { display: none !important; }

/* PII detection notice — shown above input when sensitive data was masked */
.aln-pii-notice {
	background: #fef3c7;
	color: #78350f;
	border-top: 1px solid #fde68a;
	font-size: 12px;
	padding: 10px 14px;
	display: flex;
	align-items: flex-start;
	gap: 8px;
	line-height: 1.4;
	animation: aln-pii-in 0.3s ease-out;
}
.aln-pii-notice svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.aln-pii-notice.aln-pii-notice-out { animation: aln-pii-out 0.4s ease-in forwards; }
@keyframes aln-pii-in {
	from { opacity: 0; transform: translateY(-6px); }
	to { opacity: 1; transform: translateY(0); }
}
@keyframes aln-pii-out {
	to { opacity: 0; }
}

/* Contact card (shown when no operator is online and a contact URL is configured) */
.aln-contact-body {
	flex: 1;
	overflow-y: auto;
	background: var(--aln-light);
	padding: 28px 24px;
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 16px;
}
.aln-contact-icon {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: #fff;
	color: var(--aln-cyan);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.aln-contact-icon svg { width: 26px; height: 26px; }
.aln-contact-intro {
	font-size: 14px;
	color: var(--aln-text);
	line-height: 1.5;
	max-width: 280px;
}
#aln-chat-root .aln-contact-btn {
	display: inline-block;
	background: var(--aln-navy);
	color: #fff;
	border: none;
	border-radius: 6px;
	padding: 10px 20px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	text-decoration: none;
	transition: background 0.15s;
	margin-top: 4px;
}
#aln-chat-root .aln-contact-btn:hover { background: #243a66; color: #fff; text-decoration: none; }

/* Typing indicator */
.aln-typing {
	align-self: flex-start;
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 8px 12px;
	background: #fff;
	border: 1px solid var(--aln-border);
	border-radius: 10px;
	margin: 2px 0;
}
.aln-typing-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--aln-muted);
	animation: aln-typing-bounce 1.2s infinite ease-in-out;
}
.aln-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.aln-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes aln-typing-bounce {
	0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-3px); }
}
