/**
 * AI Bot Floating Chat Widget Styles
 *
 * UpperMatch branded design. Uses CSS custom property --aibot-brand
 * for the primary brand color (set dynamically from admin settings).
 *
 * @package AIBot
 * @since 2.0.0
 */

/* ==========================================================================
   Container & Positioning
   ========================================================================== */

#aibot-widget-container {
	--aibot-brand: #1e73be;
	--aibot-brand-dark: color-mix(in srgb, var(--aibot-brand) 80%, black);
	--aibot-bg: #ffffff;
	--aibot-msg-bot-bg: #f0f2f5;
	--aibot-msg-user-bg: var(--aibot-brand);
	--aibot-msg-user-text: #ffffff;
	--aibot-text: #1a1a1a;
	--aibot-text-muted: #6b7280;
	--aibot-border: #e5e7eb;
	--aibot-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
	--aibot-radius: 16px;
	--aibot-font-size: 14px;
	--aibot-offset-x: 20px;
	--aibot-offset-y: 20px;
	--aibot-panel-width: 380px;
	--aibot-panel-height: 520px;

	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	font-size: var(--aibot-font-size);
	line-height: 1.5;
	color: var(--aibot-text);
}

#aibot-widget-container * {
	box-sizing: border-box;
}

/* Position variants */
.aibot-pos-bottom-right {
	bottom: var(--aibot-offset-y);
	right: var(--aibot-offset-x);
}

.aibot-pos-bottom-left {
	bottom: var(--aibot-offset-y);
	left: var(--aibot-offset-x);
}

/* ==========================================================================
   FAB (Floating Action Button)
   ========================================================================== */

#aibot-fab {
	width: var(--aibot-fab-size, 56px);
	height: var(--aibot-fab-size, 56px);
	min-width: var(--aibot-fab-size, 56px);
	min-height: var(--aibot-fab-size, 56px);
	border-radius: 50%;
	-webkit-mask-image: radial-gradient(circle, #fff 100%, transparent 100%);
	background: var(--aibot-fab-bg, var(--aibot-brand));
	color: #ffffff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
	transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
	position: relative;
	outline: none;
	overflow: hidden;
}

#aibot-fab:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#aibot-fab:active {
	transform: scale(0.96);
}

#aibot-fab.aibot-fab-open {
	background: var(--aibot-fab-bg-dark, var(--aibot-brand-dark));
}

/* Custom image icon inside FAB */
#aibot-fab img {
	width: calc(100% - var(--aibot-icon-padding, 0px) * 2);
	height: calc(100% - var(--aibot-icon-padding, 0px) * 2);
	object-fit: var(--aibot-icon-fit, contain);
	pointer-events: none;
	border-radius: 50%;
}

/* Custom SVG icon inside FAB */
#aibot-fab svg {
	pointer-events: none;
}

/* Unread badge */
.aibot-unread-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	width: 14px;
	height: 14px;
	background: #ef4444;
	border-radius: 50%;
	border: 2px solid #ffffff;
	animation: aibot-pulse 2s infinite;
}

@keyframes aibot-pulse {
	0%, 100% { opacity: 1; transform: scale(1); }
	50% { opacity: 0.7; transform: scale(1.15); }
}

/* ==========================================================================
   Chat Panel
   ========================================================================== */

#aibot-chat-panel {
	position: absolute;
	bottom: calc(var(--aibot-fab-size, 56px) + 16px);
	right: 0;
	width: var(--aibot-panel-width);
	height: var(--aibot-panel-height);
	background: var(--aibot-bg);
	border-radius: var(--aibot-radius);
	box-shadow: var(--aibot-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: aibot-slideUp 0.25s ease-out;
}

.aibot-pos-bottom-left #aibot-chat-panel {
	right: auto;
	left: 0;
}

@keyframes aibot-slideUp {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ==========================================================================
   Header
   ========================================================================== */

.aibot-header {
	background: linear-gradient(135deg, var(--aibot-brand), var(--aibot-brand-dark));
	color: #ffffff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.aibot-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.aibot-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.aibot-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.aibot-bot-name {
	font-weight: 600;
	font-size: 15px;
}

.aibot-status {
	font-size: 12px;
	opacity: 0.85;
	display: flex;
	align-items: center;
	gap: 4px;
}

.aibot-status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	display: inline-block;
}

.aibot-close {
	background: none;
	border: none;
	color: #ffffff;
	font-size: 24px;
	cursor: pointer;
	padding: 0 4px;
	line-height: 1;
	opacity: 0.8;
	transition: opacity 0.15s;
}

.aibot-close:hover {
	opacity: 1;
}

/* ==========================================================================
   Messages Area
   ========================================================================== */

.aibot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

/* Scrollbar styling */
.aibot-messages::-webkit-scrollbar {
	width: 5px;
}
.aibot-messages::-webkit-scrollbar-track {
	background: transparent;
}
.aibot-messages::-webkit-scrollbar-thumb {
	background: var(--aibot-border);
	border-radius: 3px;
}

/* Message bubbles */
.aibot-msg {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 14px;
	word-wrap: break-word;
	overflow-wrap: break-word;
	animation: aibot-fadeIn 0.2s ease-out;
}

@keyframes aibot-fadeIn {
	from { opacity: 0; transform: translateY(4px); }
	to { opacity: 1; transform: translateY(0); }
}

.aibot-msg-bot {
	align-self: flex-start;
	background: var(--aibot-msg-bot-bg);
	color: var(--aibot-text);
	border-bottom-left-radius: 4px;
}

.aibot-msg-user {
	align-self: flex-end;
	background: var(--aibot-msg-user-bg);
	color: var(--aibot-msg-user-text);
	border-bottom-right-radius: 4px;
}

/* Bot message HTML content styling */
.aibot-msg-bot p {
	margin: 0 0 8px 0;
}

.aibot-msg-bot p:last-child {
	margin-bottom: 0;
}

.aibot-msg-bot a {
	color: var(--aibot-brand);
	text-decoration: underline;
}

.aibot-msg-bot ul,
.aibot-msg-bot ol {
	margin: 4px 0;
	padding-left: 20px;
}

.aibot-msg-bot strong {
	font-weight: 600;
}

.aibot-msg-bot em {
	font-style: italic;
	color: var(--aibot-text-muted);
}

/* ==========================================================================
   Typing Indicator
   ========================================================================== */

.aibot-typing {
	align-self: flex-start;
	background: var(--aibot-msg-bot-bg);
	padding: 12px 18px;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	display: flex;
	gap: 5px;
	align-items: center;
}

.aibot-typing span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--aibot-text-muted);
	animation: aibot-bounce 1.4s infinite ease-in-out;
}

.aibot-typing span:nth-child(1) { animation-delay: 0s; }
.aibot-typing span:nth-child(2) { animation-delay: 0.16s; }
.aibot-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes aibot-bounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
	40% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   CTA Banner
   ========================================================================== */

.aibot-cta-banner {
	background: linear-gradient(135deg, #fbbf24, #f59e0b);
	color: #1a1a1a;
	padding: 10px 14px;
	border-radius: 10px;
	font-size: 13px;
	text-align: center;
	animation: aibot-fadeIn 0.3s ease-out;
}

.aibot-cta-banner a {
	color: #1a1a1a;
	font-weight: 600;
	text-decoration: underline;
}

.aibot-cta-banner a:hover {
	color: #000000;
}

/* ==========================================================================
   Gate Overlay
   ========================================================================== */

.aibot-gate-overlay {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	top: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	backdrop-filter: blur(2px);
}

.aibot-gate-content {
	background: #ffffff;
	border-radius: 16px;
	padding: 28px 24px;
	text-align: center;
	max-width: 300px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.aibot-gate-content h3 {
	margin: 0 0 8px 0;
	font-size: 18px;
	font-weight: 700;
	color: var(--aibot-text);
}

.aibot-gate-content p {
	margin: 0 0 20px 0;
	color: var(--aibot-text-muted);
	font-size: 14px;
}

.aibot-gate-btn {
	display: block;
	background: var(--aibot-brand);
	color: #ffffff;
	text-decoration: none;
	padding: 12px 24px;
	border-radius: 8px;
	font-weight: 600;
	font-size: 15px;
	transition: background 0.15s;
	margin-bottom: 12px;
}

.aibot-gate-btn:hover {
	background: var(--aibot-brand-dark);
	color: #ffffff;
	text-decoration: none;
}

.aibot-gate-dismiss {
	background: none;
	border: none;
	color: var(--aibot-text-muted);
	cursor: pointer;
	font-size: 13px;
	padding: 4px;
}

.aibot-gate-dismiss:hover {
	color: var(--aibot-text);
}

/* ==========================================================================
   Input Area
   ========================================================================== */

.aibot-input-area {
	padding: 12px 16px;
	border-top: 1px solid var(--aibot-border);
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex-shrink: 0;
	background: var(--aibot-bg);
}

.aibot-textarea {
	flex: 1;
	border: 1px solid var(--aibot-border);
	border-radius: 10px;
	padding: 8px 12px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	resize: none;
	outline: none;
	max-height: 120px;
	overflow-y: auto;
	transition: border-color 0.15s;
}

.aibot-textarea:focus {
	border-color: var(--aibot-brand);
}

.aibot-textarea::placeholder {
	color: var(--aibot-text-muted);
}

.aibot-send-btn {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--aibot-brand);
	color: #ffffff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s, transform 0.1s;
}

.aibot-send-btn:hover {
	background: var(--aibot-brand-dark);
}

.aibot-send-btn:active {
	transform: scale(0.92);
}

/* ==========================================================================
   Utility
   ========================================================================== */

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

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */

@media (max-width: 768px) {
	#aibot-chat-panel {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		border-radius: 0;
		z-index: 1000000;
	}

	#aibot-fab {
		bottom: 16px;
		right: 16px;
		position: fixed;
	}

	.aibot-pos-bottom-left #aibot-fab {
		right: auto;
		left: 16px;
	}
}
