/* AI Chat Support — front-end widget styles.
   All rules namespaced under #aics-launcher, #aics-chat-window, .aics-*.
   Theming via --aics-primary / --aics-text custom properties (set at runtime). */

:root {
	--aics-primary: #6366f1;
	--aics-primary-dark: #4f51d8;
	--aics-text: #ffffff;
}

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

#aics-launcher {
	position: fixed;
	bottom: 24px;
	z-index: 99998;
	width: 56px;
	height: 56px;
	border: none;
	border-radius: 50%;
	background: var(--aics-primary);
	color: var(--aics-text);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
	transition: transform 0.15s ease, background 0.15s ease;
}

#aics-launcher:hover {
	background: var(--aics-primary-dark);
	transform: scale(1.06);
}

#aics-launcher.aics-pos-right { right: 24px; }
#aics-launcher.aics-pos-left { left: 24px; }

.aics-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 10px;
	background: #ef4444;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

/* ---------------------------------------------------------------- *
 * Window
 * ---------------------------------------------------------------- */

.aics-window {
	position: fixed;
	bottom: 92px;
	z-index: 99999;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	border-radius: 16px;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
	animation: aics-pop 0.18s ease;
}

.aics-window.aics-pos-right { right: 24px; }
.aics-window.aics-pos-left { left: 24px; }

@keyframes aics-pop {
	from { opacity: 0; transform: translateY(12px) scale(0.97); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Inline embed via shortcode */
.aics-inline {
	width: 100%;
	border-radius: 12px;
	overflow: hidden;
	border: 1px solid #e5e7eb;
}

.aics-panel {
	display: flex;
	flex-direction: column;
	height: 100%;
	width: 100%;
	background: #fff;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	color: #1f2937;
}

/* ---------------------------------------------------------------- *
 * Header
 * ---------------------------------------------------------------- */

.aics-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: var(--aics-primary);
	color: var(--aics-text);
	flex-shrink: 0;
}

.aics-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.aics-avatar-fallback {
	background: rgba(255, 255, 255, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 16px;
	text-transform: uppercase;
}

.aics-header-meta { flex: 1; min-width: 0; }

.aics-header-title {
	font-weight: 600;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.aics-header-status {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 12px;
	opacity: 0.9;
}

.aics-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #34d399;
	display: inline-block;
}

.aics-close,
.aics-clear {
	background: none;
	border: none;
	color: var(--aics-text);
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
	opacity: 0.85;
}

.aics-clear { font-size: 20px; }

.aics-close:hover,
.aics-clear:hover { opacity: 1; }

/* ---------------------------------------------------------------- *
 * Messages
 * ---------------------------------------------------------------- */

.aics-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f9fafb;
}

.aics-msg { display: flex; }
.aics-msg-user { justify-content: flex-end; }
.aics-msg-assistant { justify-content: flex-start; }

.aics-bubble {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 16px;
	line-height: 1.45;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.aics-msg-user .aics-bubble {
	background: var(--aics-primary);
	color: var(--aics-text);
	border-bottom-right-radius: 4px;
}

.aics-msg-assistant .aics-bubble {
	background: #fff;
	color: #1f2937;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
}

.aics-bubble code {
	background: rgba(0, 0, 0, 0.08);
	padding: 1px 5px;
	border-radius: 4px;
	font-size: 13px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.aics-msg-user .aics-bubble code { background: rgba(255, 255, 255, 0.22); }

.aics-bubble pre {
	background: #111827;
	color: #f3f4f6;
	padding: 10px 12px;
	border-radius: 8px;
	overflow-x: auto;
	margin: 6px 0;
}

.aics-bubble pre code {
	background: none;
	padding: 0;
	color: inherit;
}

.aics-bubble a {
	color: var(--aics-primary);
	text-decoration: underline;
}

.aics-msg-user .aics-bubble a { color: var(--aics-text); }

/* Typing indicator */
.aics-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 14px;
}

.aics-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9ca3af;
	animation: aics-bounce 1.2s infinite ease-in-out;
}

.aics-dot:nth-child(2) { animation-delay: 0.15s; }
.aics-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes aics-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------------------------------------------------------------- *
 * Input area
 * ---------------------------------------------------------------- */

.aics-input-area {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
	flex-shrink: 0;
}

.aics-textarea {
	flex: 1;
	resize: none;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 9px 12px;
	font: inherit;
	max-height: 120px;
	outline: none;
	background: #fff;
	color: #1f2937;
}

.aics-textarea:focus { border-color: var(--aics-primary); }

.aics-send {
	width: 38px;
	height: 38px;
	border: none;
	border-radius: 10px;
	background: var(--aics-primary);
	color: var(--aics-text);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s ease;
}

.aics-send:hover:not(:disabled) { background: var(--aics-primary-dark); }
.aics-send:disabled { opacity: 0.5; cursor: default; }

/* Inline SVG icons must render even when the active theme resets `svg`
   globally (e.g. `svg { fill: none }` or zeroed width/height) — that is why
   the send icon can vanish on the live site but show in the admin preview.
   Force fill and size with high specificity. */
.aics-send svg,
#aics-launcher svg {
	display: block;
	pointer-events: none;
	fill: var(--aics-text, #fff) !important;
}
.aics-send svg,
.aics-send svg path { fill: var(--aics-text, #fff) !important; }
.aics-send svg { width: 18px !important; height: 18px !important; }
#aics-launcher svg { width: 26px !important; height: 26px !important; }
#aics-launcher svg,
#aics-launcher svg path { fill: var(--aics-text, #fff) !important; }

/* Deactivated widget: the composer is replaced by a notice. */
.aics-input-disabled {
	justify-content: center;
}

.aics-disabled-note {
	font-size: 13px;
	color: #6b7280;
	text-align: center;
	padding: 4px 0;
}

.aics-branding {
	text-align: center;
	font-size: 11px;
	color: #9ca3af;
	padding: 5px 0 7px;
	background: #fff;
	flex-shrink: 0;
}

/* ---------------------------------------------------------------- *
 * Email gate
 * ---------------------------------------------------------------- */

.aics-email-gate {
	position: absolute;
	inset: 64px 0 0 0;
	background: #f9fafb;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	justify-content: center;
	gap: 12px;
	padding: 24px;
}

.aics-panel { position: relative; }
.aics-panel.aics-gated .aics-input-area { pointer-events: none; opacity: 0.4; }

.aics-email-prompt {
	margin: 0;
	font-size: 14px;
	color: #374151;
	text-align: center;
}

.aics-email-input {
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 10px 12px;
	font: inherit;
	outline: none;
}

.aics-email-input:focus { border-color: var(--aics-primary); }
.aics-email-input.aics-input-error { border-color: #ef4444; }

.aics-btn-primary {
	border: none;
	border-radius: 10px;
	background: var(--aics-primary);
	color: var(--aics-text);
	padding: 10px 16px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.aics-btn-primary:hover { background: var(--aics-primary-dark); }

/* ---------------------------------------------------------------- *
 * Mobile: full-width bottom sheet
 * ---------------------------------------------------------------- */

@media (max-width: 480px) {
	.aics-window {
		left: 0 !important;
		right: 0 !important;
		bottom: 0;
		width: 100vw;
		max-width: 100vw;
		height: 88vh;
		max-height: 88vh;
		border-radius: 16px 16px 0 0;
	}
}
