/**
 * Omar AI Chatbot - Public Stylesheet
 *
 * @package Omar_AI_Chatbot
 */

.oac-chatbot {
	--oac-bg: #ffffff;
	--oac-surface: #f8fafc;
	--oac-border: #e2e8f0;
	--oac-text: #0f172a;
	--oac-text-muted: #64748b;
	--oac-accent: #111827;
	--oac-accent-hover: #1f2937;
	--oac-accent-text: #ffffff;
	--oac-launcher-bg: var(--oac-accent);
	--oac-user-bg: var(--oac-accent);
	--oac-assistant-bg: #f1f5f9;
	--oac-online: #10b981;
	--oac-error-bg: #fef2f2;
	--oac-error-text: #b91c1c;
	--oac-error-border: #fecaca;
	--oac-shadow: 0 20px 45px -12px rgba(15, 23, 42, 0.18), 0 4px 14px -2px rgba(15, 23, 42, 0.08);
	--oac-radius: 16px;
	--oac-window-width: 380px;
	--oac-window-height: 560px;
	--oac-launcher-size: 56px;
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: var(--oac-text);
}

.oac-chatbot.oac-position-bottom-left {
	right: auto;
	left: 24px;
}

.oac-chatbot *,
.oac-chatbot *::before,
.oac-chatbot *::after {
	box-sizing: border-box;
}

.oac-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Floating Launcher */
.oac-launcher {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--oac-launcher-size);
	height: var(--oac-launcher-size);
	padding: 0;
	border: 0;
	border-radius: 9999px;
	background: var(--oac-launcher-bg);
	color: var(--oac-accent-text);
	box-shadow: var(--oac-shadow);
	cursor: pointer;
	transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.oac-launcher:hover {
	background: var(--oac-accent-hover);
	transform: translateY(-2px);
}

.oac-launcher:focus-visible,
.oac-close-btn:focus-visible,
.oac-send-btn:focus-visible,
.oac-input:focus-visible {
	outline: 2px solid #2563eb;
	outline-offset: 2px;
}

.oac-launcher .oac-icon-close {
	display: none;
}

.oac-launcher[aria-expanded="true"] .oac-icon-chat {
	display: none;
}

.oac-launcher[aria-expanded="true"] .oac-icon-close {
	display: block;
}

/* Chat Window */
.oac-window {
	position: fixed;
	right: 24px;
	bottom: calc(var(--oac-launcher-size) + 36px);
	width: var(--oac-window-width);
	max-width: calc(100vw - 32px);
	height: var(--oac-window-height);
	max-height: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	background: var(--oac-bg);
	border: 1px solid var(--oac-border);
	border-radius: var(--oac-radius);
	box-shadow: var(--oac-shadow);
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	transition: opacity 0.22s ease, transform 0.22s ease;
}

.oac-chatbot.oac-position-bottom-left .oac-window {
	right: auto;
	left: 24px;
}

.oac-window[hidden] {
	display: none;
}

.oac-window.is-open {
	opacity: 1;
	transform: translateY(0) scale(1);
}

/* Header */
.oac-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px;
	background: var(--oac-bg);
	border-bottom: 1px solid var(--oac-border);
	flex-shrink: 0;
}

.oac-header-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.oac-header-avatar {
	width: 36px;
	height: 36px;
	border-radius: 9999px;
	object-fit: cover;
	flex-shrink: 0;
	border: 1px solid var(--oac-border);
}

.oac-header-info {
	min-width: 0;
}

.oac-header-title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	color: var(--oac-text);
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.oac-header-status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 2px 0 0;
	font-size: 12px;
	color: var(--oac-text-muted);
}

.oac-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 9999px;
	background: var(--oac-online);
	box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.oac-close-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--oac-text-muted);
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.oac-close-btn:hover {
	background: var(--oac-assistant-bg);
	color: var(--oac-text);
}

/* Messages */
.oac-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: var(--oac-bg);
	scroll-behavior: smooth;
}

.oac-message {
	display: flex;
	flex-direction: column;
	max-width: 85%;
	animation: oac-fade-in 0.18s ease forwards;
}

.oac-message--user {
	align-self: flex-end;
}

.oac-message--assistant {
	align-self: flex-start;
}

.oac-bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.oac-message--user .oac-bubble {
	background: var(--oac-user-bg);
	color: var(--oac-accent-text);
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}

.oac-message--assistant .oac-bubble {
	background: var(--oac-assistant-bg);
	color: var(--oac-text);
	border-bottom-left-radius: 4px;
}

/* Safe Markdown formatting inside assistant bubbles */
.oac-bubble p {
	margin: 0 0 8px;
}

.oac-bubble p:last-child {
	margin-bottom: 0;
}

.oac-bubble ul,
.oac-bubble ol {
	margin: 4px 0 8px;
	padding-left: 18px;
}

.oac-bubble ul:last-child,
.oac-bubble ol:last-child {
	margin-bottom: 0;
}

.oac-bubble li {
	margin-bottom: 4px;
}

.oac-bubble code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	font-size: 12.5px;
	background: rgba(15, 23, 42, 0.07);
	padding: 1px 5px;
	border-radius: 4px;
}

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

.oac-bubble pre code {
	background: transparent;
	padding: 0;
	color: inherit;
}

.oac-bubble a {
	color: #2563eb;
	text-decoration: underline;
}

/* Typing Indicator */
.oac-typing {
	padding: 0 16px 10px;
	flex-shrink: 0;
}

.oac-typing[hidden] {
	display: none;
}

.oac-typing-bubble {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
	background: var(--oac-assistant-bg);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
}

.oac-typing-dot {
	width: 6px;
	height: 6px;
	border-radius: 9999px;
	background: var(--oac-text-muted);
	animation: oac-bounce 1.2s infinite ease-in-out;
}

.oac-typing-dot:nth-child(2) {
	animation-delay: 0.15s;
}

.oac-typing-dot:nth-child(3) {
	animation-delay: 0.3s;
}

/* Error Banner */
.oac-error {
	margin: 0 16px 10px;
	padding: 8px 12px;
	border-radius: 8px;
	background: var(--oac-error-bg);
	color: var(--oac-error-text);
	border: 1px solid var(--oac-error-border);
	font-size: 12.5px;
	flex-shrink: 0;
}

.oac-error[hidden] {
	display: none;
}

/* Input Area */
.oac-input-area {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 14px;
	background: var(--oac-surface);
	border-top: 1px solid var(--oac-border);
	flex-shrink: 0;
}

.oac-input {
	flex: 1 1 auto;
	min-height: 40px;
	max-height: 112px;
	padding: 9px 12px;
	border: 1px solid var(--oac-border);
	border-radius: 10px;
	background: var(--oac-bg);
	color: var(--oac-text);
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	resize: none;
	overflow-y: auto;
}

.oac-input:disabled {
	opacity: 0.65;
	cursor: not-allowed;
}

.oac-send-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: var(--oac-accent);
	color: var(--oac-accent-text);
	cursor: pointer;
	flex-shrink: 0;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.oac-send-btn:hover:not(:disabled) {
	background: var(--oac-accent-hover);
}

.oac-send-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.oac-branding {
	padding: 6px 14px;
	background: var(--oac-surface);
	border-top: 1px solid var(--oac-border);
	text-align: center;
	font-size: 11px;
	color: var(--oac-text-muted);
	flex-shrink: 0;
}

/* Device Visibility Rules */
@media (max-width: 767px) {
	.oac-chatbot.oac-hide-mobile {
		display: none !important;
	}
}

@media (min-width: 768px) {
	.oac-chatbot.oac-hide-desktop {
		display: none !important;
	}
}

@keyframes oac-bounce {
	0%, 80%, 100% {
		transform: translateY(0);
		opacity: 0.45;
	}
	40% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

@keyframes oac-fade-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Responsive Mobile Layout */
@media (max-width: 480px) {
	.oac-chatbot {
		right: 16px;
		bottom: 16px;
	}

	.oac-chatbot.oac-position-bottom-left {
		right: auto;
		left: 16px;
	}

	.oac-window,
	.oac-chatbot.oac-position-bottom-left .oac-window {
		right: 12px;
		left: 12px;
		bottom: 84px;
		width: auto;
		max-width: none;
		height: calc(100vh - 104px);
		max-height: none;
	}
}

/* Respect Reduced Motion */
@media (prefers-reduced-motion: reduce) {
	.oac-launcher,
	.oac-window,
	.oac-close-btn,
	.oac-send-btn,
	.oac-message {
		transition: none;
		animation: none;
	}

	.oac-messages {
		scroll-behavior: auto;
	}

	.oac-typing-dot {
		animation: none;
		opacity: 0.8;
	}
}
