446 lines
13 KiB
PHP
446 lines
13 KiB
PHP
@push('css')
|
|
<style>
|
|
/* Message Styling */
|
|
.message {
|
|
padding: 8px;
|
|
margin: 5px 0;
|
|
border-radius: 10px;
|
|
max-width: 100%;
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
/* User Message (Blue with transparency) */
|
|
.user-message {
|
|
background-color: rgba(0, 123, 255, 0.2);
|
|
/* Blue with 70% opacity */
|
|
color: black;
|
|
text-align: right;
|
|
align-self: flex-end;
|
|
}
|
|
|
|
/* Bot Message (vz-primary with transparency) */
|
|
.bot-message {
|
|
background-color: rgba(var(--vz-primary-rgb), 0.2);
|
|
/* Assuming var(--vz-primary-rgb) holds RGB value */
|
|
color: black;
|
|
text-align: left;
|
|
align-self: flex-start;
|
|
}
|
|
|
|
/* Floating Chatbot Button */
|
|
#chatbot-toggle {
|
|
position: fixed;
|
|
bottom: 45px;
|
|
right: 38px;
|
|
width: 60px;
|
|
height: 60px;
|
|
background-color: var(--vz-primary);
|
|
/* Using CSS variable */
|
|
color: white;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 24px;
|
|
cursor: pointer;
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
|
transition: all 0.3s ease-in-out;
|
|
z-index: 1000;
|
|
/* Ensure it's above other elements */
|
|
}
|
|
|
|
/* Chatbot Container */
|
|
#chatbot-container {
|
|
position: fixed;
|
|
bottom: 42px;
|
|
right: 36px;
|
|
width: 320px;
|
|
padding: 0px;
|
|
background: white;
|
|
border: 1px solid #ccc;
|
|
border-radius: 10px;
|
|
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
|
font-family: Arial, sans-serif;
|
|
display: none;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
z-index: 1000;
|
|
/* Ensure it floats above the content */
|
|
}
|
|
|
|
/* Chatbot Header */
|
|
#chatbot-header {
|
|
background-color: var(--vz-primary);
|
|
color: white;
|
|
padding: 10px;
|
|
text-align: center;
|
|
font-size: 16px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
/* Close Button */
|
|
#chatbot-close {
|
|
font-size: 20px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
/* Chatbot Body */
|
|
#chatbot-body {
|
|
height: 250px;
|
|
overflow-y: auto;
|
|
padding: 10px;
|
|
}
|
|
|
|
/* Input and Send Button Styling */
|
|
#chatbot-input-container {
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
width: 100%;
|
|
margin-top: 10px;
|
|
padding: 5px;
|
|
}
|
|
|
|
#chatbot-input {
|
|
width: 100%;
|
|
padding: 10px;
|
|
border: 1px solid #ccc;
|
|
border-radius: 20px;
|
|
outline: none;
|
|
font-size: 14px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
#chatbot-send {
|
|
position: absolute;
|
|
right: 10px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
background-color: transparent;
|
|
border: none;
|
|
color: var(--vz-primary);
|
|
font-size: 18px;
|
|
cursor: pointer;
|
|
z-index: 10;
|
|
}
|
|
</style>
|
|
@endpush
|
|
|
|
|
|
<style>
|
|
/* floating buttons container */
|
|
.floating-social {
|
|
position: fixed;
|
|
bottom: 210px;
|
|
right: 45px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 16px;
|
|
z-index: 9999;
|
|
|
|
|
|
}
|
|
|
|
/* each circular button */
|
|
.floating-social .btn-circle {
|
|
width: 48px;
|
|
height: 48px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 24px;
|
|
color: #fff;
|
|
/* white icon */
|
|
text-decoration: none;
|
|
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
/* brand backgrounds */
|
|
.btn-whatsapp {
|
|
background: #25D366;
|
|
}
|
|
|
|
.btn-facebook {
|
|
background: #1877F2;
|
|
}
|
|
</style>
|
|
|
|
<style>
|
|
.glowing-animation {
|
|
background-color: #F98D1E;
|
|
box-shadow: 0 0 10px rgba(249, 141, 30, 0.5),
|
|
0 0 20px rgba(249, 141, 30, 0.4),
|
|
0 0 30px rgba(249, 141, 30, 0.3);
|
|
animation: pulseGlow 2s ease-in-out infinite;
|
|
border-radius: 50%;
|
|
transition: transform 0.3s ease;
|
|
}
|
|
|
|
/* .glowing-animation:hover {
|
|
transform: scale(1.1);
|
|
} */
|
|
|
|
@keyframes pulseGlow {
|
|
|
|
0%,
|
|
100% {
|
|
box-shadow: 0 0 10px rgba(249, 141, 30, 0.4),
|
|
0 0 20px rgba(249, 141, 30, 0.3),
|
|
0 0 30px rgba(249, 141, 30, 0.2);
|
|
}
|
|
|
|
50% {
|
|
box-shadow: 0 0 20px rgba(249, 141, 30, 0.6),
|
|
0 0 30px rgba(249, 141, 30, 0.5),
|
|
0 0 40px rgba(249, 141, 30, 0.4);
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<div class="floating-social">
|
|
<a href="https://{{ ltrim(setting('whatsapp'), 'https://') }}" target="_blank" class="btn-circle btn-whatsapp">
|
|
<i class="fab fa-whatsapp"></i>
|
|
</a>
|
|
|
|
|
|
<!-- Chatbot Floating Button -->
|
|
<div id="chatbot-toggle" class="glowing-animation">
|
|
<i class="ri-message-2-fill" style="font-size: 30px; color: white;"></i>
|
|
</div>
|
|
|
|
<!-- Chatbot UI -->
|
|
<div id="chatbot-container" style="z-index: 9999">
|
|
<div id="chatbot-header">
|
|
Chatbot
|
|
<span id="chatbot-close">×</span>
|
|
</div>
|
|
<div id="chatbot-body"></div>
|
|
<div id="chatbot-input-container">
|
|
<input type="text" id="chatbot-input" placeholder="Ask me something...">
|
|
<button id="chatbot-send">
|
|
<i class="ri-send-plane-2-fill"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Styles -->
|
|
@push('css')
|
|
<style>
|
|
/* Floating Button */
|
|
#chatbot-toggle {
|
|
position: fixed;
|
|
bottom: 45px;
|
|
right: 38px;
|
|
width: 60px;
|
|
height: 60px;
|
|
background-color: var(--vz-primary);
|
|
color: white;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
|
z-index: 1000;
|
|
}
|
|
|
|
/* Chat Container */
|
|
#chatbot-container {
|
|
position: fixed;
|
|
bottom: 42px;
|
|
right: 36px;
|
|
width: 340px;
|
|
height: 400px;
|
|
background: #fff;
|
|
border: 1px solid #ccc;
|
|
border-radius: 14px;
|
|
box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.25);
|
|
font-family: 'Segoe UI', sans-serif;
|
|
display: none;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
z-index: 1000;
|
|
}
|
|
|
|
#chatbot-header {
|
|
background-color: var(--vz-primary);
|
|
color: white;
|
|
padding: 12px 16px;
|
|
font-size: 16px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
font-weight: bold;
|
|
}
|
|
|
|
#chatbot-body {
|
|
flex: 1;
|
|
padding: 12px;
|
|
overflow-y: auto;
|
|
background: #f9f9f9;
|
|
display: flex;
|
|
flex-direction: column;
|
|
scroll-behavior: smooth;
|
|
}
|
|
|
|
.message {
|
|
position: relative;
|
|
padding: 10px 16px;
|
|
margin: 6px 0;
|
|
border-radius: 20px;
|
|
max-width: 80%;
|
|
font-size: 14px;
|
|
line-height: 1.4;
|
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.user-message {
|
|
background-color: rgba(0, 123, 255, 0.15);
|
|
color: black;
|
|
align-self: flex-end;
|
|
margin-left: auto;
|
|
border-bottom-right-radius: 0;
|
|
}
|
|
|
|
.bot-message {
|
|
background-color: rgba(var(--vz-primary-rgb), 0.15);
|
|
color: black;
|
|
align-self: flex-start;
|
|
margin-right: auto;
|
|
border-bottom-left-radius: 0;
|
|
}
|
|
|
|
.typing-indicator {
|
|
font-style: italic;
|
|
font-size: 13px;
|
|
color: #888;
|
|
margin-top: 5px;
|
|
margin-left: 5px;
|
|
}
|
|
|
|
#chatbot-input-container {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 10px;
|
|
border-top: 1px solid #eee;
|
|
background: #fff;
|
|
}
|
|
|
|
#chatbot-input {
|
|
flex: 1;
|
|
padding: 10px 15px;
|
|
border: 1px solid #ccc;
|
|
border-radius: 30px;
|
|
font-size: 14px;
|
|
outline: none;
|
|
margin-right: 8px;
|
|
}
|
|
|
|
#chatbot-send {
|
|
background: var(--vz-primary);
|
|
border: none;
|
|
border-radius: 50%;
|
|
width: 36px;
|
|
height: 36px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: white;
|
|
font-size: 18px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.floating-social {
|
|
position: fixed;
|
|
bottom: 210px;
|
|
right: 45px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 16px;
|
|
z-index: 9999;
|
|
}
|
|
|
|
.floating-social .btn-circle {
|
|
width: 48px;
|
|
height: 48px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 24px;
|
|
color: #fff;
|
|
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
.btn-whatsapp {
|
|
background: #25D366;
|
|
}
|
|
</style>
|
|
@endpush
|
|
|
|
<!-- Scripts -->
|
|
@push('js')
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#chatbot-toggle').click(function() {
|
|
$('#chatbot-container').fadeIn();
|
|
$(this).hide();
|
|
});
|
|
|
|
$('#chatbot-close').click(function() {
|
|
$('#chatbot-container').fadeOut();
|
|
$('#chatbot-toggle').show();
|
|
});
|
|
|
|
$('#chatbot-send').click(sendMessage);
|
|
$('#chatbot-input').keypress(function(e) {
|
|
if (e.which == 13) sendMessage();
|
|
});
|
|
|
|
function sendMessage() {
|
|
const input = $('#chatbot-input');
|
|
const body = $('#chatbot-body');
|
|
const message = input.val().trim();
|
|
|
|
if (message === '') return;
|
|
|
|
body.append('<div class="message user-message">You: ' + message + '</div>');
|
|
input.val('');
|
|
body.append('<div class="typing-indicator" id="typing">Bot is typing...</div>');
|
|
scrollToBottom();
|
|
|
|
$.ajax({
|
|
url: '{{ route('chatbot.query') }}',
|
|
type: 'POST',
|
|
data: {
|
|
message: message,
|
|
_token: '{{ csrf_token() }}'
|
|
},
|
|
success: function(response) {
|
|
$('#typing').remove();
|
|
body.append('<div class="message bot-message">Bot: ' + response.reply +
|
|
'</div>');
|
|
scrollToBottom();
|
|
},
|
|
error: function() {
|
|
$('#typing').remove();
|
|
body.append(
|
|
'<div class="message bot-message">Bot: Sorry, something went wrong.</div>'
|
|
);
|
|
scrollToBottom();
|
|
}
|
|
});
|
|
}
|
|
|
|
function scrollToBottom() {
|
|
const body = $('#chatbot-body');
|
|
body.scrollTop(body[0].scrollHeight);
|
|
}
|
|
});
|
|
</script>
|
|
@endpush
|