Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions apps/web/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
<!doctype html>
<html lang="en">
<html lang="en" data-theme="dark">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Second Opinion: a spoken second opinion and family approval before risky payments through Alexa+." />
<meta name="description" content="Second Opinion — Zero-trust payment guard for Alexa+. Deterministic risk engine, family quorum approval, and MCP server protecting elders from financial fraud." />
<meta name="color-scheme" content="light dark" />
<title>Second Opinion — Enterprise Payment Guard for Alexa+</title>
<meta name="theme-color" content="#0a0f1e" media="(prefers-color-scheme: dark)" />
<meta name="theme-color" content="#f8fafc" media="(prefers-color-scheme: light)" />
<meta property="og:title" content="Second Opinion — Enterprise Payment Guard for Alexa+" />
<meta property="og:description" content="Zero-trust voice payment protection powered by deterministic rules, family quorum, and MCP." />
<title>Second Opinion — Enterprise Payment Guard · Alexa+</title>

<!-- Google Fonts: Inter (body) + Cal Sans (headings via local fallback) -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300..800;1,300..800&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet" />
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%232457d6'/%3E%3Cpath d='M16 6l8 3v6c0 5-3.4 8.6-8 11-4.6-2.4-8-6-8-11V9z' fill='white'/%3E%3C/svg%3E" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap"
rel="stylesheet"
/>

<!-- Favicon: Premium Shield Logo -->
<link
rel="icon"
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%234f8ef7'/%3E%3Cstop offset='100%25' stop-color='%232563eb'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='40' height='40' rx='10' fill='url(%23g)'/%3E%3Cpath d='M20 8L10 12v7c0 6 4.5 10.5 10 13 5.5-2.5 10-7 10-13v-7z' fill='white' opacity='0.95'/%3E%3Cpath d='M16 19l2.5 2.5L25 15' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E"
/>
</head>
<body>
<div id="root"></div>
Expand Down
250 changes: 169 additions & 81 deletions apps/web/src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,56 @@
import { useEffect, useState, type ReactNode } from 'react';
import { useCallback, useEffect, useState, type ReactNode } from 'react';
import { NavLink } from 'react-router-dom';
import { api } from '../api';
import { useAppState } from '../hooks/useAppState';
import { IconActivity, IconServer, IconShieldCheck } from './icons';
import { IconActivity, IconMoon, IconServer } from './icons';

/* ---------------------------------------------------------------
Theme management — toggles [data-theme] on <html>
---------------------------------------------------------------- */
type Theme = 'dark' | 'light';

function getInitialTheme(): Theme {
try {
const stored = localStorage.getItem('so-theme') as Theme | null;
if (stored === 'dark' || stored === 'light') return stored;
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
} catch {
return 'dark';
}
}

function applyTheme(t: Theme) {
document.documentElement.setAttribute('data-theme', t);
try { localStorage.setItem('so-theme', t); } catch { /* ignore */ }
}

function useTheme(): [Theme, () => void] {
const [theme, setTheme] = useState<Theme>(getInitialTheme);

useEffect(() => { applyTheme(theme); }, [theme]);

const toggle = useCallback(() => {
setTheme((t) => (t === 'dark' ? 'light' : 'dark'));
}, []);

return [theme, toggle];
}

/* ---------------------------------------------------------------
MCP / Live health pill
---------------------------------------------------------------- */
function StatusDot({ ok }: { ok: boolean | null }) {
const color = ok === null ? 'var(--muted)' : ok ? 'var(--ok)' : 'var(--danger)';
const c = ok === null ? 'var(--muted)' : ok ? 'var(--ok)' : 'var(--danger)';
return (
<span
aria-hidden="true"
style={{
display: 'inline-block',
width: 7,
height: 7,
width: 6,
height: 6,
borderRadius: '50%',
background: color,
boxShadow: ok ? `0 0 6px ${color}` : 'none',
background: c,
boxShadow: ok ? `0 0 6px ${c}` : 'none',
flexShrink: 0,
}}
/>
Expand All @@ -28,106 +63,159 @@ function HealthPill() {

useEffect(() => {
let alive = true;
const probe = () => api.health().then((h) => alive && setMcp(h.mcp)).catch(() => alive && setMcp(false));
const probe = () =>
api.health().then((h) => alive && setMcp(h.mcp)).catch(() => alive && setMcp(false));
void probe();
const t = setInterval(probe, 8000);
return () => {
alive = false;
clearInterval(t);
};
return () => { alive = false; clearInterval(t); };
}, []);

const pillStyle = (active: boolean | null, type: 'mcp' | 'live') => ({
display: 'flex',
alignItems: 'center',
gap: 5,
padding: '4px 10px',
borderRadius: 'var(--radius-full)',
background: 'var(--surface-2)',
border: '1px solid var(--border)',
fontSize: '0.72rem',
fontWeight: 700,
color: active
? type === 'mcp' ? 'var(--ok)' : 'var(--info)'
: active === false ? 'var(--danger)' : 'var(--muted)',
transition: 'all var(--transition-fast)',
whiteSpace: 'nowrap' as const,
});

return (
<div
className="row"
aria-label="System status"
style={{ gap: 'var(--space-2)', fontSize: 'var(--text-xs)', fontWeight: 600 }}
>
<span
className="row"
style={{
gap: 6,
padding: '5px 10px',
borderRadius: 'var(--radius-full)',
background: 'var(--surface-2)',
border: '1px solid var(--border)',
color: mcp ? 'var(--ok)' : mcp === false ? 'var(--danger)' : 'var(--muted)',
}}
>
<IconServer size={12} aria-hidden="true" />
<div className="row" aria-label="System status" style={{ gap: 6 }}>
<span style={pillStyle(mcp, 'mcp')}>
<IconServer size={11} aria-hidden="true" />
<StatusDot ok={mcp} />
{mcp === null ? 'Checking…' : mcp ? 'MCP server connected' : 'MCP server unreachable'}
{mcp === null ? 'Connecting…' : mcp ? 'MCP online' : 'MCP offline'}
</span>

<span
className="row"
style={{
gap: 6,
padding: '5px 10px',
borderRadius: 'var(--radius-full)',
background: 'var(--surface-2)',
border: '1px solid var(--border)',
color: live ? 'var(--info)' : 'var(--muted)',
}}
>
<IconActivity size={12} aria-hidden="true" />
<span style={pillStyle(live ? true : null, 'live')}>
<IconActivity size={11} aria-hidden="true" />
<StatusDot ok={live ? true : null} />
{live ? 'Live' : 'Offline'}
{live ? 'Live' : 'Idle'}
</span>
</div>
);
}

/* ---------------------------------------------------------------
SVG Logo — Premium shield + checkmark
---------------------------------------------------------------- */
function Logo({ size = 36 }: { size?: number }) {
return (
<svg
width={size}
height={size}
viewBox="0 0 40 40"
fill="none"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
className="brand-logo"
>
<defs>
<linearGradient id="logo-grad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stopColor="#6b8eff" />
<stop offset="100%" stopColor="#4361ee" />
</linearGradient>
<linearGradient id="logo-shine" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stopColor="rgba(255,255,255,0.25)" />
<stop offset="100%" stopColor="rgba(255,255,255,0)" />
</linearGradient>
<filter id="logo-glow">
<feGaussianBlur stdDeviation="1.5" result="blur" />
<feMerge><feMergeNode in="blur" /><feMergeNode in="SourceGraphic" /></feMerge>
</filter>
</defs>
{/* Background rounded rect */}
<rect width="40" height="40" rx="10" fill="url(#logo-grad)" />
{/* Shine overlay */}
<rect width="40" height="40" rx="10" fill="url(#logo-shine)" />
{/* Shield */}
<path
d="M20 8L10.5 12v7.5c0 5.8 4.1 10.2 9.5 12.5 5.4-2.3 9.5-6.7 9.5-12.5V12L20 8z"
fill="white"
opacity="0.95"
filter="url(#logo-glow)"
/>
{/* Checkmark */}
<path
d="M16 20.5l2.7 2.7 5.8-6"
stroke="#4361ee"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
}

/* ---------------------------------------------------------------
Sun icon (for light mode button)
---------------------------------------------------------------- */
function SunIcon({ size = 16 }: { size?: number }) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="5" />
<line x1="12" y1="1" x2="12" y2="3" />
<line x1="12" y1="21" x2="12" y2="23" />
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64" />
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78" />
<line x1="1" y1="12" x2="3" y2="12" />
<line x1="21" y1="12" x2="23" y2="12" />
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36" />
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22" />
</svg>
);
}

/* ---------------------------------------------------------------
Layout Shell
---------------------------------------------------------------- */
export function Layout({ children }: { children: ReactNode }) {
const [theme, toggleTheme] = useTheme();

return (
<>
<a href="#main" className="sr-only">
Skip to content
</a>
<a href="#main" className="sr-only">Skip to content</a>

<header className="app-header">
<NavLink to="/demo" className="brand" aria-label="Second Opinion home">
<span
aria-hidden="true"
style={{
width: 34,
height: 34,
borderRadius: 10,
background: 'linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
boxShadow: '0 2px 8px rgba(37,99,235,0.35)',
}}
>
<IconShieldCheck size={18} style={{ color: '#fff', strokeWidth: '2' }} aria-hidden="true" />
</span>
<div style={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
<span style={{ lineHeight: 1.15, letterSpacing: '-0.02em' }}>Second Opinion</span>
<span
style={{
fontSize: '0.65rem',
fontWeight: 600,
color: 'var(--muted)',
letterSpacing: '0.06em',
textTransform: 'uppercase',
}}
>
Payment Guard · Alexa+
</span>
{/* Logo + Brand */}
<NavLink to="/" className="brand" aria-label="Second Opinion — home">
<Logo size={36} />
<div className="brand-text">
<span className="brand-name">Second Opinion</span>
<span className="brand-sub">Payment Guard · Alexa+</span>
</div>
</NavLink>

<nav className="nav" aria-label="Main">
{/* Top navigation */}
<nav className="nav" aria-label="Main navigation">
<NavLink to="/" end>Overview</NavLink>
<NavLink to="/demo">Live demo</NavLink>
<NavLink to="/family">Family console</NavLink>
<NavLink to="/demo">Simulator</NavLink>
<NavLink to="/family">Family Console</NavLink>
</nav>

<div className="right">
{/* Right-side actions */}
<div className="header-actions">
<HealthPill />

<button
type="button"
className="theme-toggle"
onClick={toggleTheme}
aria-label={theme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
title={theme === 'dark' ? 'Light mode' : 'Dark mode'}
>
{theme === 'dark' ? <SunIcon size={15} /> : <IconMoon size={15} />}
</button>
</div>
</header>

<div id="main">{children}</div>
</>
);
Expand Down
11 changes: 11 additions & 0 deletions apps/web/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export function IconShieldCheck(p: IconProps) {
);
}

export function IconSave(p: IconProps) {
return (
<Svg {...p}>
<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" />
<polyline points="17 21 17 13 7 13 7 21" />
<polyline points="7 3 7 8 15 8" />
</Svg>
);
}


export function IconMic(p: IconProps) {
return (
<Svg {...p}>
Expand Down
Loading
Loading