<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>LuxBot</title>
<style>
:root{
--bg:#f6f6f6;
--card:#ffffff;
--panel:#fbfbfb;
--text:#111;
--muted:#666;
--border:#e6e6e6;
--ok:#1a7f37;
--err:#b42318;
--btn:#111;
--btn2:#444;
--userBubble:#111;
--userText:#fff;
--botBubble:#f8f8f8;
--botText:#111;
--sidebarW:270px;
--shadow:0 10px 30px rgba(0,0,0,.08);
}
*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; }
body{
font-family: Arial, sans-serif;
background:var(--bg);
color:var(--text);
overflow:hidden;
}
.appWrap{
width:100%;
height:100dvh;
padding:14px;
}
.card{
width:100%;
height:100%;
background:var(--card);
border:1px solid var(--border);
border-radius:18px;
box-shadow:var(--shadow);
overflow:hidden;
display:flex;
min-height:0;
min-width:0;
}
.sidebar{
width:var(--sidebarW);
min-width:var(--sidebarW);
border-right:1px solid var(--border);
background:var(--panel);
display:flex;
flex-direction:column;
min-height:0;
}
.sidebarHead{
padding:16px 14px 12px;
border-bottom:1px solid var(--border);
display:flex;
flex-direction:column;
gap:10px;
}
.brandTitle{
font-size:22px;
font-weight:700;
margin:0;
line-height:1.1;
}
.brandSub{
font-size:12px;
color:var(--muted);
}
.sideBtn{
width:100%;
border:none;
background:var(--btn);
color:#fff;
border-radius:12px;
padding:11px 12px;
font-size:14px;
cursor:pointer;
text-align:left;
text-decoration:none;
}
.chatList{
flex:1 1 auto;
min-height:0;
overflow:auto;
padding:10px;
display:flex;
flex-direction:column;
gap:8px;
}
.chatItem{
width:100%;
border:1px solid var(--border);
background:#fff;
border-radius:12px;
padding:10px 12px;
cursor:pointer;
text-align:left;
display:flex;
flex-direction:column;
gap:4px;
}
.chatItem.active{
border-color:#cfcfcf;
background:#f4f4f4;
}
.chatItemTitle{
font-size:14px;
font-weight:600;
color:var(--text);
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
.chatItemMeta{
font-size:11px;
color:var(--muted);
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
.main{
flex:1 1 auto;
min-width:0;
min-height:0;
display:flex;
flex-direction:column;
background:#fff;
}
.topBar{
border-bottom:1px solid var(--border);
padding:12px 14px 10px;
display:flex;
flex-direction:column;
gap:8px;
flex:0 0 auto;
}
.topRow{
display:flex;
align-items:flex-start;
justify-content:space-between;
gap:10px;
min-width:0;
}
.leftTop{
display:flex;
align-items:flex-start;
gap:8px;
min-width:0;
flex-wrap:wrap;
}
.mobileMenuBtn,
.backBtn{
display:none;
border:none;
background:#fff;
border:1px solid var(--border);
color:var(--text);
border-radius:10px;
padding:9px 11px;
font-size:14px;
cursor:pointer;
}
.titleBlock{
min-width:0;
}
.mainTitle{
margin:0;
font-size:22px;
line-height:1.1;
}
.mainSub{
margin-top:2px;
font-size:12px;
color:var(--muted);
}
.topActions{
display:flex;
align-items:center;
gap:8px;
flex-wrap:wrap;
justify-content:flex-end;
}
.statusLine{
font-size:13px;
color:var(--ok);
}
.miniBtn{
border:none;
background:var(--btn2);
color:#fff;
border-radius:10px;
padding:10px 12px;
font-size:13px;
cursor:pointer;
}
.helperLine{
font-size:12px;
color:var(--muted);
line-height:1.35;
}
.pillRow{
display:flex;
flex-wrap:wrap;
gap:6px;
margin-top:2px;
}
.pill{
border:1px solid var(--border);
background:#fff;
border-radius:999px;
padding:6px 10px;
font-size:12px;
cursor:pointer;
user-select:none;
line-height:1.2;
transition:all .15s ease;
}
.pill:hover{
background:#f4f4f4;
}
.chatShell{
flex:1 1 auto;
min-height:0;
display:flex;
flex-direction:column;
}
.chatThread{
flex:1 1 auto;
min-height:0;
overflow:auto;
padding:16px;
display:flex;
flex-direction:column;
gap:12px;
scroll-behavior:smooth;
-webkit-overflow-scrolling:touch;
overscroll-behavior:contain;
background:#fcfcfc;
}
.welcomeCard{
max-width:720px;
border:1px solid var(--border);
background:#fff;
border-radius:16px;
padding:18px;
line-height:1.5;
}
.welcomeTitle{
font-size:20px;
font-weight:700;
margin:0 0 8px;
}
.welcomeText{
font-size:14px;
color:var(--text);
margin:0 0 10px;
}
.welcomeList{
font-size:14px;
color:var(--muted);
line-height:1.6;
margin:0;
padding-left:18px;
}
.messageRow{
display:flex;
width:100%;
}
.messageRow.user{ justify-content:flex-end; }
.messageRow.bot{ justify-content:flex-start; }
.bubbleWrap{
max-width:min(82%, 760px);
display:flex;
flex-direction:column;
gap:5px;
}
.messageLabel{
font-size:11px;
color:var(--muted);
padding:0 4px;
}
.bubble{
border-radius:18px;
padding:13px 15px;
line-height:1.5;
white-space:pre-wrap;
word-wrap:break-word;
overflow-wrap:anywhere;
font-size:14px;
}
.messageRow.user .bubble{
background:var(--userBubble);
color:var(--userText);
border-bottom-right-radius:6px;
}
.messageRow.bot .bubble{
background:var(--botBubble);
color:var(--botText);
border:1px solid var(--border);
border-bottom-left-radius:6px;
}
.composer{
border-top:1px solid var(--border);
background:#fff;
padding:12px;
display:flex;
flex-direction:column;
gap:8px;
flex:0 0 auto;
padding-bottom:calc(12px + env(safe-area-inset-bottom));
}
.composerTop{
display:flex;
gap:10px;
align-items:flex-end;
}
textarea{
width:100%;
padding:13px 14px;
border-radius:14px;
border:1px solid #ddd;
font-size:15px;
outline:none;
background:#fff;
min-height:56px;
max-height:160px;
resize:none;
font-family:Arial, sans-serif;
overflow:auto;
}
.sendBtn{
min-width:96px;
height:50px;
border:none;
background:var(--btn);
color:#fff;
border-radius:12px;
padding:0 14px;
cursor:pointer;
flex:0 0 auto;
}
.sendBtn:disabled,
.miniBtn:disabled,
.sideBtn:disabled,
.mobileMenuBtn:disabled,
.backBtn:disabled{
opacity:.65;
cursor:not-allowed;
}
.composerMeta{
display:flex;
justify-content:space-between;
gap:12px;
flex-wrap:wrap;
align-items:center;
}
.helperText,
.aiStatus{
font-size:12px;
color:var(--muted);
line-height:1.35;
}
.typing{
display:inline-flex;
align-items:center;
gap:4px;
}
.typingDot{
width:6px;
height:6px;
border-radius:50%;
background:#999;
display:inline-block;
animation:bounce 1.2s infinite ease-in-out;
}
.typingDot:nth-child(2){ animation-delay:.15s; }
.typingDot:nth-child(3){ animation-delay:.3s; }
@keyframes bounce{
0%,80%,100%{ transform:scale(.7); opacity:.5; }
40%{ transform:scale(1); opacity:1; }
}
.hide{ display:none !important; }
.notice{
border:1px solid var(--border);
background:#fff;
border-radius:12px;
padding:14px;
margin:18px;
}
.noticeTitle{
font-weight:900;
font-size:16px;
margin-bottom:6px;
}
.msg{ margin-top:10px; font-size:13px; line-height:1.35; }
.muted{ color:var(--muted); }
.tiny{ font-size:12px; }
.mobileDrawer{
position:fixed;
inset:0;
background:rgba(0,0,0,.35);
z-index:50;
display:none;
}
.mobileDrawer.open{
display:block;
}
.mobileDrawerPanel{
width:min(86vw, 320px);
height:100%;
background:#fff;
border-right:1px solid var(--border);
box-shadow:var(--shadow);
display:flex;
flex-direction:column;
}
.mobileDrawerHead{
padding:14px;
border-bottom:1px solid var(--border);
display:flex;
align-items:center;
justify-content:space-between;
gap:10px;
}
.closeBtn{
border:none;
background:#fff;
border:1px solid var(--border);
color:var(--text);
border-radius:10px;
padding:8px 10px;
cursor:pointer;
}
@media (max-width: 900px){
.sidebar{
display:none;
}
.mobileMenuBtn,
.backBtn{
display:inline-flex;
}
.appWrap{
padding:0;
height:100dvh;
}
.card{
border-radius:0;
border:none;
box-shadow:none;
}
}
@media (max-width: 700px){
.topBar{
padding:10px 10px 8px;
}
.topRow{
flex-direction:column;
align-items:stretch;
gap:8px;
}
.leftTop{
width:100%;
justify-content:flex-start;
}
.topActions{
width:100%;
justify-content:space-between;
}
.mainTitle{
font-size:20px;
}
.chatThread{
padding:10px;
}
.bubbleWrap{
max-width:92%;
}
.composer{
padding:10px;
padding-bottom:calc(10px + env(safe-area-inset-bottom));
}
.composerTop{
flex-direction:column;
align-items:stretch;
}
.sendBtn{
width:100%;
height:46px;
}
textarea{
min-height:52px;
font-size:16px;
}
.welcomeCard{
padding:14px;
}
.welcomeTitle{
font-size:18px;
}
}
</style>
</head>
<body>
<div class="appWrap">
<div class="card">
<aside class="sidebar">
<div class="sidebarHead">
<div>
<div class="brandTitle">LuxBot</div>
<div class="brandSub" id="sidebarSub">Premium Members Area</div>
</div>
<button id="newChatSideBtn" class="sideBtn" type="button">+ New Chat</button>
</div>
<div class="chatList" id="chatList"></div>
</aside>
<main class="main">
<div id="loadingView">
<div class="msg muted" style="margin:16px;">Loading LuxBot…</div>
<div class="msg muted tiny" id="debugLine" style="margin:0 16px 16px;"></div>
</div>
<div id="signinView" class="hide">
<div class="notice">
<div class="noticeTitle">Sign in required 🔐</div>
<div class="msg muted">
Please open LuxBot from inside your member dashboard so you’re signed in.
</div>
<a class="sideBtn" href="https://luxlifewealthaccelerator.com/" target="_blank" rel="noopener" style="display:inline-flex; justify-content:center; margin-top:12px;">
Open Dashboard
</a>
<div class="msg muted tiny">
If you’re already signed in, refresh this page.
</div>
</div>
</div>
<div id="appView" class="hide" style="display:flex; flex-direction:column; min-height:0; flex:1 1 auto;">
<div class="topBar">
<div class="topRow">
<div class="leftTop">
<button id="backBtn" class="backBtn" type="button">Back</button>
<button id="mobileMenuBtn" class="mobileMenuBtn" type="button">Chats</button>
<div class="titleBlock">
<h1 class="mainTitle">LuxBot</h1>
<div class="mainSub" id="subtitle">Premium Members Area</div>
</div>
</div>
<div class="topActions">
<div class="statusLine" id="okLine">✅ LuxBot ready.</div>
<button id="newChatBtn" type="button" class="miniBtn">New Chat</button>
</div>
</div>
<div class="helperLine">
Ask for hooks, posts, captions, stories, scripts, emails, or rewrites. LuxBot remembers the current thread.
</div>
<div class="pillRow" id="pillRow"></div>
</div>
<div class="chatShell">
<div class="chatThread" id="chatThread"></div>
<div class="composer">
<div class="composerTop">
<textarea id="prompt" placeholder="Message LuxBot..."></textarea>
<button id="askBtn" type="button" class="sendBtn">Send</button>
</div>
<div class="composerMeta">
<div class="helperText">
Best prompt formula: <b>topic + tone + format + CTA</b>. Press <b>Ctrl/Cmd + Enter</b> to send.
</div>
<div class="aiStatus" id="aiStatus"></div>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
<div class="mobileDrawer" id="mobileDrawer">
<div class="mobileDrawerPanel">
<div class="mobileDrawerHead">
<div>
<div class="brandTitle" style="font-size:20px;">LuxBot</div>
<div class="brandSub">Your chats</div>
</div>
<button id="closeDrawerBtn" class="closeBtn" type="button">Close</button>
</div>
<div style="padding:12px; border-bottom:1px solid var(--border);">
<button id="newChatDrawerBtn" class="sideBtn" type="button">+ New Chat</button>
</div>
<div class="chatList" id="chatListMobile"></div>
</div>
</div>
<script type="module">
import { createClient } from "https://esm.sh/@supabase/supabase-js@2";
const SUPABASE_URL = "https://rseumxkzgnhsqvjfhuku.supabase.co";
const SUPABASE_ANON_KEY = "YOUR_ANON_KEY_HERE";
const ASSISTANT_ENDPOINT_URL = "https://rseumxkzgnhsqvjfhuku.supabase.co/functions/v1/rapid-handler";
const PROFILE_TABLE = "Premium";
const params = new URLSearchParams(window.location.search);
const emailFromUrl = (params.get("email") || "").trim().toLowerCase();
function isValidEmail(email) {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}
const emailAccessMode = isValidEmail(emailFromUrl);
const el = (id) => document.getElementById(id);
const show = (id) => el(id).classList.remove("hide");
const hide = (id) => el(id).classList.add("hide");
const setDebug = (msg) => el("debugLine").textContent = msg || "";
const supa = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
auth: {
persistSession: true,
autoRefreshToken: true,
detectSessionInUrl: true,
storageKey: "lwa_auth_session"
}
});
window.addEventListener("DOMContentLoaded", async () => {
show("loadingView");
hide("signinView");
hide("appView");
setDebug(emailAccessMode ? "Email mode detected: " + emailFromUrl : "No email detected.");
if (emailAccessMode) {
hide("loadingView");
show("appView");
el("okLine").textContent = "✅ LuxBot ready.";
}
});
</script>
</body>
</html>