Compare commits

..

2 Commits

Author SHA1 Message Date
Matteo Rosati
c97739d096 add better styling 2026-01-20 12:13:08 +01:00
Matteo Rosati
f5bafd1117 fix host 2026-01-20 12:12:59 +01:00
3 changed files with 562 additions and 31 deletions

View File

@@ -1,37 +1,532 @@
textarea {
width: 100%;
height: 80px;
/* ===== CSS Variables ===== */
:root {
--primary-color: #6366f1;
--primary-hover: #4f46e5;
--primary-light: #818cf8;
--secondary-color: #8b5cf6;
--accent-color: #06b6d4;
--success-color: #10b981;
--background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--glass-bg: rgba(255, 255, 255, 0.95);
--glass-border: rgba(255, 255, 255, 0.2);
--text-primary: #1f2937;
--text-secondary: #6b7280;
--text-light: #9ca3af;
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
--border-radius-sm: 8px;
--border-radius-md: 12px;
--border-radius-lg: 16px;
--border-radius-xl: 24px;
--transition-fast: 0.15s ease;
--transition-normal: 0.3s ease;
--transition-slow: 0.5s ease;
}
#messages {
/* ===== Reset & Base Styles ===== */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: var(--background-gradient);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
color: var(--text-primary);
line-height: 1.6;
}
/* ===== App Container ===== */
.app-container {
width: 100%;
max-width: 900px;
height: 90vh;
max-height: 800px;
background: var(--glass-bg);
backdrop-filter: blur(20px);
border-radius: var(--border-radius-xl);
box-shadow: var(--shadow-xl);
display: flex;
flex-direction: column;
gap: 10px;
padding: 20px;
overflow: hidden;
border: 1px solid var(--glass-border);
animation: fadeInUp 0.6s ease-out;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* ===== Header ===== */
.chat-header {
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
padding: 20px 24px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: var(--shadow-md);
z-index: 10;
}
.header-content {
display: flex;
align-items: center;
gap: 12px;
}
.logo-icon {
width: 40px;
height: 40px;
background: rgba(255, 255, 255, 0.2);
border-radius: var(--border-radius-md);
display: flex;
align-items: center;
justify-content: center;
color: white;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%,
100% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
}
.header-title {
font-size: 1.5rem;
font-weight: 700;
color: white;
letter-spacing: -0.5px;
}
.header-status {
display: flex;
align-items: center;
gap: 8px;
background: rgba(255, 255, 255, 0.15);
padding: 6px 12px;
border-radius: 20px;
}
.status-dot {
width: 8px;
height: 8px;
background: var(--success-color);
border-radius: 50%;
animation: blink 1.5s infinite;
}
@keyframes blink {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.status-text {
color: white;
font-size: 0.875rem;
font-weight: 500;
}
/* ===== Main Content ===== */
.chat-main {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}
/* ===== Welcome Section ===== */
.welcome-section {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px 20px;
text-align: center;
animation: fadeIn 0.8s ease-out;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.welcome-icon {
width: 80px;
height: 80px;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: white;
margin-bottom: 24px;
box-shadow: var(--shadow-lg);
animation: float 3s ease-in-out infinite;
}
@keyframes float {
0%,
100% {
transform: translateY(0);
}
50% {
transform: translateY(-10px);
}
}
.welcome-title {
font-size: 2rem;
font-weight: 700;
color: var(--text-primary);
margin-bottom: 8px;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.welcome-subtitle {
font-size: 1.125rem;
color: var(--text-secondary);
margin-bottom: 32px;
max-width: 500px;
}
.sample-question {
background: white;
padding: 20px 24px;
border-radius: var(--border-radius-lg);
box-shadow: var(--shadow-md);
max-width: 600px;
border-left: 4px solid var(--primary-color);
transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}
.sample-question:hover {
transform: translateY(-2px);
box-shadow: var(--shadow-lg);
}
.sample-label {
display: block;
font-size: 0.75rem;
font-weight: 600;
color: var(--primary-color);
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: 8px;
}
.sample-text {
font-size: 1rem;
color: var(--text-primary);
font-style: italic;
}
/* ===== Messages Container ===== */
.messages-container {
flex: 1;
display: flex;
flex-direction: column;
gap: 16px;
padding: 24px;
overflow-y: auto;
scroll-behavior: smooth;
}
.messages-container::-webkit-scrollbar {
width: 6px;
}
.messages-container::-webkit-scrollbar-track {
background: transparent;
}
.messages-container::-webkit-scrollbar-thumb {
background: var(--text-light);
border-radius: 3px;
}
.messages-container::-webkit-scrollbar-thumb:hover {
background: var(--text-secondary);
}
/* ===== Message Styles ===== */
.message {
max-width: 70%;
padding: 10px 15px;
border-radius: 15px;
font-family: sans-serif;
line-height: 1.4;
max-width: 75%;
padding: 14px 18px;
border-radius: var(--border-radius-lg);
font-size: 0.95rem;
line-height: 1.6;
animation: messageSlide 0.3s ease-out;
word-wrap: break-word;
}
@keyframes messageSlide {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.sent {
max-width: 70%;
background-color: lightgreen;
padding: 10px 15px;
border-radius: 15px;
font-family: sans-serif;
line-height: 1.4;
align-self: flex-end;
border-bottom-right-radius: 2px;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
color: white;
border-bottom-right-radius: 4px;
box-shadow: var(--shadow-md);
}
.sent a {
color: white;
text-decoration: underline;
}
.received {
align-self: flex-start;
background-color: #e5e5ea;
color: black;
border-bottom-left-radius: 2px;
background: white;
color: var(--text-primary);
border-bottom-left-radius: 4px;
box-shadow: var(--shadow-sm);
border: 1px solid rgba(0, 0, 0, 0.05);
}
.received a {
color: var(--primary-color);
text-decoration: none;
}
.received a:hover {
text-decoration: underline;
}
/* ===== Footer ===== */
.chat-footer {
background: white;
padding: 20px 24px;
border-top: 1px solid rgba(0, 0, 0, 0.05);
box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}
.input-wrapper {
display: flex;
gap: 12px;
align-items: flex-end;
background: var(--background-gradient);
padding: 6px;
border-radius: var(--border-radius-lg);
box-shadow: var(--shadow-md);
transition: box-shadow var(--transition-normal);
}
.input-wrapper:focus-within {
box-shadow: var(--shadow-lg);
}
.message-input {
flex: 1;
background: white;
border: none;
border-radius: var(--border-radius-md);
padding: 14px 16px;
font-size: 1rem;
font-family: inherit;
color: var(--text-primary);
resize: none;
outline: none;
min-height: 50px;
max-height: 150px;
transition: box-shadow var(--transition-fast);
}
.message-input::placeholder {
color: var(--text-light);
}
.message-input:focus {
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.send-button {
width: 50px;
height: 50px;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
border: none;
border-radius: var(--border-radius-md);
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all var(--transition-normal);
box-shadow: var(--shadow-md);
flex-shrink: 0;
}
.send-button:hover {
transform: scale(1.05);
box-shadow: var(--shadow-lg);
}
.send-button:active {
transform: scale(0.95);
}
.send-button:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
}
.footer-hint {
text-align: center;
font-size: 0.75rem;
color: var(--text-light);
margin-top: 12px;
}
/* ===== Responsive Design ===== */
@media (max-width: 768px) {
body {
padding: 10px;
}
.app-container {
height: 95vh;
max-height: none;
border-radius: var(--border-radius-lg);
}
.chat-header {
padding: 16px 20px;
}
.header-title {
font-size: 1.25rem;
}
.welcome-section {
padding: 30px 16px;
}
.welcome-icon {
width: 64px;
height: 64px;
}
.welcome-title {
font-size: 1.5rem;
}
.welcome-subtitle {
font-size: 1rem;
}
.sample-question {
padding: 16px 20px;
}
.messages-container {
padding: 16px;
gap: 12px;
}
.message {
max-width: 85%;
padding: 12px 14px;
font-size: 0.9rem;
}
.chat-footer {
padding: 16px 20px;
}
.message-input {
padding: 12px 14px;
font-size: 0.95rem;
}
.send-button {
width: 46px;
height: 46px;
}
}
@media (max-width: 480px) {
.header-status {
display: none;
}
.message {
max-width: 90%;
}
.sample-question {
padding: 14px 16px;
}
.sample-text {
font-size: 0.9rem;
}
}
/* ===== Loading Animation ===== */
@keyframes shimmer {
0% {
background-position: -200% 0;
}
100% {
background-position: 200% 0;
}
}
.loading-message {
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
background-size: 200% 100%;
animation: shimmer 1.5s infinite;
}

View File

@@ -1,8 +1,7 @@
(($) => {
const isSecure = location.protocol === "https:";
const port = location.port ? `:${location.port}` : "";
var ws = new WebSocket(
`ws${isSecure ? "s" : ""}://${location.host}${port}/ws`,
`ws${isSecure ? "s" : ""}://${location.host}/ws`,
);
const input = $("#message");
const messages = $("#messages");

View File

@@ -4,19 +4,56 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/css/main.css">
<title>Document</title>
<title>AI Chat Assistant</title>
</head>
<body>
<h1>Chat</h1>
<p>Come si calcola la massa magra? dammi una spiegazione dettagliata</p>
<div class="app-container">
<header class="chat-header">
<div class="header-content">
<div class="logo-icon">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 6C13.66 6 15 7.34 15 9C15 10.66 13.66 12 12 12C10.34 12 9 10.66 9 9C9 7.34 10.34 6 12 6ZM12 19.2C9.5 19.2 7.29 17.92 6 15.98C6.03 13.99 10 12.9 12 12.9C13.99 12.9 17.97 13.99 18 15.98C16.71 17.92 14.5 19.2 12 19.2Z" fill="currentColor"/>
</svg>
</div>
<h1 class="header-title">AI Chat Assistant</h1>
</div>
<div class="header-status">
<span class="status-dot"></span>
<span class="status-text">Online</span>
</div>
</header>
<div>
<textarea name="" id="message"></textarea>
<input id="button" type="button" value="Send">
<main class="chat-main">
<div class="welcome-section">
<div class="welcome-icon">
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20 2H4C2.9 2 2 2.9 2 4V22L6 18H20C21.1 18 22 17.1 22 16V4C22 2.9 21.1 2 20 2ZM20 16H6L4 18V4H20V16Z" fill="currentColor"/>
</svg>
</div>
<h2 class="welcome-title">Welcome to AI Chat</h2>
<p class="welcome-subtitle">Ask me anything and I'll help you find answers</p>
<div class="sample-question">
<span class="sample-label">Example question:</span>
<p class="sample-text">Come si calcola la massa magra? dammi una spiegazione dettagliata</p>
</div>
</div>
<div id="messages" class="messages-container"></div>
</main>
<footer class="chat-footer">
<div class="input-wrapper">
<textarea id="message" class="message-input" placeholder="Type your message here..." rows="1"></textarea>
<button id="button" class="send-button">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" fill="currentColor"/>
</svg>
</button>
</div>
<p class="footer-hint">Press Enter to send, Shift+Enter for new line</p>
</footer>
</div>
<div id="messages"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="/static/js/main.js"></script>