<!-- @dsCard group="桌面端" viewport="1100x640" name="桌面端 UI Kit" subtitle="识别浮层 · 托盘菜单 · 设置 · 登录购买 — 可交互，Light/Dark" -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dudu 桌面端 UI Kit</title>
<link rel="stylesheet" href="../../styles.css">
<script src="https://unpkg.com/react@18.3.1/umd/react.development.js" integrity="sha384-hD6/rw4ppMLGNu3tX5cjIb+uRZ7UkRJ6BPkLpg4hAu/6onKUg4lLsHAs9EBPT82L" crossorigin="anonymous"></script>
<script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.development.js" integrity="sha384-u6aeetuaXnQ38mYT8rp6sbXaQe3NL9t+IBXmnYxwkUI2Hw4bsp2Wvmx4yRQF1uAm" crossorigin="anonymous"></script>
<script src="https://unpkg.com/@babel/standalone@7.29.0/babel.min.js" integrity="sha384-m08KidiNqLdpJqLq95G/LEi8Qvjl/xUYll3QILypMoQ65QorJ9Lvtp2RXYGBFj1y" crossorigin="anonymous"></script>
<script src="../../_ds_bundle.js"></script>
<style>
  html, body { margin: 0; height: 100%; }
  body { font-family: var(--font-sans); }
  #root { height: 100%; }
  @keyframes dd-caret { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
  @keyframes dd-rise { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translate(-50%, -22px); } }
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel" src="./DesktopShared.jsx"></script>
<script type="text/babel" src="./OverlayDemo.jsx"></script>
<script type="text/babel" src="./SettingsTray.jsx"></script>
<script type="text/babel" src="./LoginPurchase.jsx"></script>
<script type="text/babel">
const TABS = [
  ['overlay', '识别浮层'],
  ['tray', '托盘菜单'],
  ['settings', '设置'],
  ['account', '登录 / 购买'],
];

function DesktopKit() {
  const [tab, setTab] = React.useState('overlay');
  const [theme, setTheme] = React.useState('system'); // system | light | dark
  const [systemDark, setSystemDark] = React.useState(
    window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
  );
  React.useEffect(() => {
    const mq = window.matchMedia('(prefers-color-scheme: dark)');
    const fn = (e) => setSystemDark(e.matches);
    mq.addEventListener('change', fn);
    return () => mq.removeEventListener('change', fn);
  }, []);
  const dark = theme === 'dark' || (theme === 'system' && systemDark);

  return (
    <div data-theme={dark ? 'dark' : undefined} style={{
      height: '100%', display: 'flex', flexDirection: 'column',
      background: 'var(--bg-app)', transition: 'background var(--dur-base) var(--ease-out)',
    }}>
      {/* 顶栏 */}
      <div style={{
        display: 'flex', alignItems: 'center', gap: 16, padding: '12px 20px',
        borderBottom: '1px solid var(--border-1)', background: 'var(--surface-card)',
      }}>
        <span style={{ display: 'inline-flex', alignItems: 'center', gap: 9, color: 'var(--text-1)' }}>
          <span style={{ color: 'var(--accent)', display: 'inline-flex' }}><DuduLogo size={22} /></span>
          <span style={{ fontWeight: 'var(--weight-semibold)', fontSize: 'var(--text-base)', letterSpacing: 'var(--tracking-wide)' }}>dudu</span>
          <span style={{ fontSize: 'var(--text-sm)', color: 'var(--text-3)', whiteSpace: 'nowrap' }}>桌面端 · Mac / Windows</span>
        </span>

        <div style={{ display: 'flex', gap: 4, marginLeft: 18 }}>
          {TABS.map(([key, label]) => (
            <button key={key} type="button" onClick={() => setTab(key)} style={{
              height: 30, padding: '0 14px', borderRadius: 'var(--radius-full)', border: 'none', cursor: 'pointer', whiteSpace: 'nowrap',
              fontFamily: 'var(--font-sans)', fontSize: 'var(--text-sm)',
              fontWeight: tab === key ? 'var(--weight-medium)' : 'var(--weight-regular)',
              background: tab === key ? 'var(--accent-soft)' : 'transparent',
              color: tab === key ? 'var(--accent-text)' : 'var(--text-2)',
              transition: 'background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out)',
            }}>{label}</button>
          ))}
        </div>

        <button type="button" onClick={() => setTheme(dark ? 'light' : 'dark')} aria-label="切换深浅模式" style={{
          marginLeft: 'auto', width: 32, height: 32, borderRadius: 'var(--radius-sm)',
          border: '1px solid var(--border-1)', background: 'var(--surface-card)', color: 'var(--text-2)',
          display: 'inline-flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer',
        }}>
          {dark ? <DuIcons.Sun size={15} /> : <DuIcons.Moon size={15} />}
        </button>
      </div>

      {/* 舞台 */}
      <div style={{ flex: 1, display: 'flex', padding: 28, overflow: 'auto' }}>
        <div style={{ margin: 'auto' }}>
          {tab === 'overlay' && <OverlayDemo />}
          {tab === 'tray' && (
            <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: 10 }}>
              <span style={{ display: 'inline-flex', alignItems: 'center', gap: 6, color: 'var(--text-2)', fontSize: 'var(--text-sm)', paddingRight: 12, whiteSpace: 'nowrap' }}>
                <DuduLogo size={15} /> 菜单栏图标 ▾
              </span>
              <TrayMenu />
            </div>
          )}
          {tab === 'settings' && <SettingsWindow theme={theme} onThemeChange={setTheme} />}
          {tab === 'account' && <LoginPurchaseWindow />}
        </div>
      </div>
    </div>
  );
}

ReactDOM.createRoot(document.getElementById('root')).render(<DesktopKit />);
</script>
</body>
</html>
