import React from 'react';
import './ThemeSwitcher.css';

const MODES = [
  { value: 'light', label: '日间' },
  { value: 'dark', label: '夜间' },
  { value: 'auto', label: '自动' }
];
const BRANDS = ['#2F54EB', '#1677FF', '#722ED1', '#13C2C2', '#FA541C', '#EB2F96'];

export default function ThemeSwitcher({ mode = 'light', brand = '#2F54EB', onModeChange, onBrandChange }) {
  return (
    <div className="kole-themesw" role="radiogroup" aria-label="主题模式">
      {MODES.map((m) => (
        <div
          key={m.value}
          className={'kole-themesw-opt' + (mode === m.value ? ' is-active' : '')}
          role="radio"
          aria-checked={mode === m.value}
          tabIndex={0}
          onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && onModeChange && onModeChange(m.value)}
          onClick={() => onModeChange && onModeChange(m.value)}
        >
          <span className={'kole-themesw-dot ' + m.value} />
          {m.label}
        </div>
      ))}
      <div className="kole-themesw-colors">
        {BRANDS.map((c) => (
          <span
            key={c}
            className={'kole-themesw-color' + (brand === c ? ' is-active' : '')}
            style={{ background: c }}
            role="radio"
            aria-label={`品牌色 ${c}`}
            aria-checked={brand === c}
            tabIndex={0}
            onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && onBrandChange && onBrandChange(c)}
            onClick={() => onBrandChange && onBrandChange(c)}
          />
        ))}
      </div>
      <div className="kole-themesw-label">品牌色：{brand}（应用于 Kole 品牌令牌实时预览）</div>
    </div>
  );
}
