import React from 'react';

/**
 * docsIcons.jsx — самописные SVG-иконки для вики Рублокса.
 *
 * Единый стиль: viewBox 24×24, обводка currentColor, stroke-width 1.8,
 * скруглённые концы. Цвет наследуется от текста родителя.
 * Эмодзи в интерфейсе не используем — только эти иконки.
 *
 * Использование:  <DocIcon name="rocket" size={32} />
 */

const S = {
    fill: 'none',
    stroke: 'currentColor',
    strokeWidth: 1.8,
    strokeLinecap: 'round',
    strokeLinejoin: 'round',
};
const F = { fill: 'currentColor', stroke: 'none' };

const ICONS = {
    // ── разделы вики ──────────────────────────────────────────
    users: () => (
        <>
            <circle cx="9" cy="8" r="3.2" {...S} />
            <path d="M3.5 19c0-3 2.5-5 5.5-5s5.5 2 5.5 5" {...S} />
            <circle cx="16.5" cy="9" r="2.4" {...S} />
            <path d="M15 14.2c2.6.2 4.7 2 4.7 4.8" {...S} />
        </>
    ),
    rocket: () => (
        <>
            <path d="M12 3c3.4 1.7 5.4 5 5.4 9l-2.2 2.3H8.8L6.6 12C6.6 8 8.6 4.7 12 3Z" {...S} />
            <circle cx="12" cy="9" r="1.7" {...S} />
            <path d="M9 17c-1 .6-1.7 1.9-1.8 4 2.1-.1 3.4-.8 4-1.8M15 17c1 .6 1.7 1.9 1.8 4-2.1-.1-3.4-.8-4-1.8" {...S} />
        </>
    ),
    cube: () => (
        <>
            <path d="M12 3 21 8v8l-9 5-9-5V8l9-5Z" {...S} />
            <path d="M3 8l9 5 9-5M12 13v8" {...S} />
        </>
    ),
    window: () => (
        <>
            <rect x="3" y="4" width="18" height="16" rx="2.5" {...S} />
            <path d="M3 9h18M7 6.5h.01M10 6.5h.01" {...S} />
        </>
    ),
    code: () => (
        <>
            <path d="M9 8l-4 4 4 4M15 8l4 4-4 4" {...S} />
            <path d="M13 5l-2 14" {...S} />
        </>
    ),
    run: () => (
        <>
            <circle cx="14" cy="5" r="2" {...S} />
            <path d="M12.5 9 9 11l1 4M12.5 9l3 2 .5 4M9 11l-3 1M10 15l-2 5M15.5 15l1.5 5" {...S} />
        </>
    ),
    target: () => (
        <>
            <circle cx="12" cy="12" r="8" {...S} />
            <circle cx="12" cy="12" r="4.2" {...S} />
            <circle cx="12" cy="12" r="1.1" {...F} />
        </>
    ),
    gear: () => (
        <>
            <circle cx="12" cy="12" r="3" {...S} />
            <path d="M12 2.5v3M12 18.5v3M21.5 12h-3M5.5 12h-3M19 5l-2.1 2.1M7.1 16.9 5 19M19 19l-2.1-2.1M7.1 7.1 5 5" {...S} />
        </>
    ),
    book: () => (
        <>
            <path d="M5 4h11a2 2 0 0 1 2 2v14H7a2 2 0 0 1-2-2V4Z" {...S} />
            <path d="M5 18a2 2 0 0 1 2-2h11" {...S} />
            <path d="M9 8h6M9 11h5" {...S} />
        </>
    ),
    glossary: () => (
        <>
            <path d="M4 5h16v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5Z" {...S} />
            <path d="M8 9h8M8 12h8M8 15h5" {...S} />
        </>
    ),
    bug: () => (
        <>
            <rect x="8" y="8" width="8" height="10" rx="4" {...S} />
            <path d="M8 12H4M8 15H4.5M16 12h4M16 15h3.5M9 8l-1.5-2.5M15 8l1.5-2.5M12 18v3" {...S} />
        </>
    ),

    // ── общие ─────────────────────────────────────────────────
    wiki: () => (
        <>
            <path d="M4 5.5A2.5 2.5 0 0 1 6.5 3H20v15H6.5A2.5 2.5 0 0 0 4 20.5V5.5Z" {...S} />
            <path d="M4 20.5A2.5 2.5 0 0 1 6.5 18H20v3H6.5A2.5 2.5 0 0 1 4 20.5Z" {...S} />
        </>
    ),
    gamepad: () => (
        <>
            <path d="M7 8h10a4 4 0 0 1 4 4v.6c0 2-1.2 3.9-3.4 3.9-1.5 0-2.1-1-3-2.2-.4-.5-.9-.8-1.6-.8h-2c-.7 0-1.2.3-1.6.8-.9 1.2-1.5 2.2-3 2.2C3.7 16.5 2.5 14.6 2.5 12.6V12a4 4 0 0 1 4-4Z" {...S} />
            <path d="M7.5 11v2.4M6.3 12.2h2.4" {...S} />
            <circle cx="15.7" cy="11.4" r="1" {...F} />
            <circle cx="17.6" cy="13.2" r="1" {...F} />
        </>
    ),
    lightbulb: () => (
        <>
            <path d="M9 17a5.5 5.5 0 1 1 6 0c-.6.4-1 1-1 1.7V19h-4v-.3c0-.7-.4-1.3-1-1.7Z" {...S} />
            <path d="M9.5 21h5M10 19h4" {...S} />
        </>
    ),
    pin: () => (
        <>
            <path d="M9 3h6l-1 6 3 3v2H7v-2l3-3-1-6Z" {...S} />
            <path d="M12 14v7" {...S} />
        </>
    ),
    globeIcon: () => (
        <>
            <circle cx="12" cy="12" r="8.5" {...S} />
            <path d="M3.5 12h17M12 3.5c2.5 2.4 2.5 14.6 0 17M12 3.5c-2.5 2.4-2.5 14.6 0 17" {...S} />
        </>
    ),

    // ── иконки для 50 игр ─────────────────────────────────────
    coin: () => (
        <>
            <circle cx="12" cy="12" r="8" {...S} />
            <circle cx="12" cy="12" r="4.5" {...S} />
            <path d="M12 9.5v5" {...S} />
        </>
    ),
    jump: () => (
        <>
            <circle cx="12" cy="5" r="2" {...S} />
            <path d="M12 7.5v5M12 12.5l-3 4M12 12.5l3 4M9 9.5 6 8M15 9.5 18 8" {...S} />
            <path d="M5 21h14" {...S} />
        </>
    ),
    hole: () => (
        <>
            <ellipse cx="12" cy="15" rx="8" ry="4" {...S} />
            <path d="M6 14c1-3 3.5-5 6-5s5 2 6 5" {...S} />
        </>
    ),
    door: () => (
        <>
            <rect x="6" y="3" width="12" height="18" rx="1" {...S} />
            <circle cx="14.5" cy="12" r="1" {...F} />
        </>
    ),
    maze: () => (
        <>
            <rect x="3.5" y="3.5" width="17" height="17" rx="1.5" {...S} />
            <path d="M3.5 9h6v6h6M14.5 3.5v6M9.5 20.5v-5.5" {...S} />
        </>
    ),
    palette: () => (
        <>
            <path d="M12 3a9 9 0 0 0 0 18c1.4 0 1.8-1 1.4-1.9-.5-1 .2-2.1 1.3-2.1H17a4 4 0 0 0 4-4c0-5-4-10-9-10Z" {...S} />
            <circle cx="8" cy="11" r="1" {...F} />
            <circle cx="12" cy="8" r="1" {...F} />
            <circle cx="16" cy="11" r="1" {...F} />
        </>
    ),
    box: () => (
        <>
            <path d="M12 3 20 7v10l-8 4-8-4V7l8-4Z" {...S} />
            <path d="M4 7l8 4 8-4M12 11v10" {...S} />
        </>
    ),
    flag: () => (
        <>
            <path d="M6 3v18" {...S} />
            <path d="M6 4h11l-2 3.5L17 11H6V4Z" {...S} />
        </>
    ),
    light: () => (
        <>
            <rect x="9" y="3" width="6" height="16" rx="3" {...S} />
            <circle cx="12" cy="7" r="1.3" {...F} />
            <circle cx="12" cy="15" r="1.3" {...F} />
            <path d="M9 21h6" {...S} />
        </>
    ),
    spring: () => (
        <>
            <path d="M7 21h10M8 17h8" {...S} />
            <path d="M9 17c-1-1.5-1-3 0-4.5s1-3 0-4.5M15 17c1-1.5 1-3 0-4.5s-1-3 0-4.5" {...S} />
            <path d="M9 3.5h6" {...S} />
        </>
    ),
    sound: () => (
        <>
            <path d="M4 9.5h3.5L13 5v14L7.5 14.5H4v-5Z" {...S} />
            <path d="M16 9.5a3.5 3.5 0 0 1 0 5M18.5 7a7 7 0 0 1 0 10" {...S} />
        </>
    ),
    keypad: () => (
        <>
            <rect x="4" y="3" width="16" height="18" rx="2" {...S} />
            <path d="M8 8h.01M12 8h.01M16 8h.01M8 12h.01M12 12h.01M16 12h.01M8 16h8" {...S} />
        </>
    ),
    trader: () => (
        <>
            <circle cx="12" cy="7" r="3" {...S} />
            <path d="M6 20a6 6 0 0 1 12 0" {...S} />
            <path d="M9 13l-2 2M15 13l2 2" {...S} />
        </>
    ),
    star: () => (
        <path d="M12 3.5l2.5 5.4 5.9.6-4.4 4 1.2 5.8-5.2-3-5.2 3 1.2-5.8-4.4-4 5.9-.6L12 3.5Z" {...S} />
    ),
    crosshair: () => (
        <>
            <circle cx="12" cy="12" r="8" {...S} />
            <path d="M12 2.5v4M12 17.5v4M2.5 12h4M17.5 12h4" {...S} />
        </>
    ),
    lava: () => (
        <>
            <path d="M3 16h18M3 16c1.5-2 3-2 4.5 0s3 2 4.5 0 3-2 4.5 0 3 2 4.5 0" {...S} />
            <path d="M12 3c.4 2.5-1.7 3.3-1.7 5.8a1.7 1.7 0 0 0 3.4 0c0-.7-.3-1.2-.3-1.2 1.5.8 2.6 2.3 2.6 4.4" {...S} />
        </>
    ),
    key: () => (
        <>
            <circle cx="8" cy="8" r="4" {...S} />
            <path d="M11 11l8 8M16 16l2-2M18 18l2-2" {...S} />
        </>
    ),
    swing: () => (
        <>
            <path d="M5 4h14M12 4v8" {...S} />
            <rect x="8" y="12" width="8" height="3" rx="1" {...S} />
            <path d="M9 12l-1 8M15 12l1 8" {...S} />
        </>
    ),
    elevator: () => (
        <>
            <rect x="6" y="3" width="12" height="18" rx="1.5" {...S} />
            <path d="M12 8l-2.5 3h5L12 8ZM12 16l-2.5-3h5L12 16Z" {...F} />
        </>
    ),
    tag: () => (
        <>
            <path d="M3 12V5a2 2 0 0 1 2-2h7l9 9-9 9-9-9Z" {...S} />
            <circle cx="8.5" cy="8.5" r="1.5" {...S} />
        </>
    ),
    chase: () => (
        <>
            <circle cx="7" cy="6" r="2.2" {...S} />
            <path d="M7 8.5v5M7 13.5l-2 5M7 13.5l2 4M5 10.5 3 9M9 10.5l2-1" {...S} />
            <path d="M16 11l4 1-4 1" {...S} />
            <circle cx="19" cy="6" r="2" {...S} />
        </>
    ),
    warning: () => (
        <>
            <path d="M12 4 21 19H3L12 4Z" {...S} />
            <path d="M12 10v4" {...S} />
            <circle cx="12" cy="16.6" r="0.5" {...F} />
        </>
    ),
    lever: () => (
        <>
            <rect x="4" y="14" width="16" height="6" rx="1.5" {...S} />
            <circle cx="9" cy="17" r="1.2" {...F} />
            <circle cx="15" cy="17" r="1.2" {...F} />
            <path d="M9 14V8M15 14v-4" {...S} />
        </>
    ),
    bridge: () => (
        <>
            <path d="M3 9c0 5 4 9 9 9s9-4 9-9" {...S} />
            <path d="M3 9h18M7 9.6v4M12 9.8v6M17 9.6v4" {...S} />
        </>
    ),
    camera: () => (
        <>
            <rect x="3" y="7" width="14" height="11" rx="2" {...S} />
            <path d="M17 11l4-2.5v9L17 14" {...S} />
            <circle cx="9" cy="12.5" r="2.5" {...S} />
        </>
    ),
    magnet: () => (
        <>
            <path d="M6 3v8a6 6 0 0 0 12 0V3" {...S} />
            <path d="M6 8h4M14 8h4" {...S} />
        </>
    ),
    doubleArrow: () => (
        <>
            <path d="M12 3l-5 6h10l-5-6ZM12 12l-5 6h10l-5-6Z" {...S} />
        </>
    ),
    ghost: () => (
        <>
            <path d="M5 20v-9a7 7 0 0 1 14 0v9l-2.3-1.6L14.3 20 12 18.4 9.7 20l-2.4-1.6L5 20Z" {...S} />
            <circle cx="9.5" cy="10.5" r="1" {...F} />
            <circle cx="14.5" cy="10.5" r="1" {...F} />
        </>
    ),
    cart: () => (
        <>
            <path d="M3 4h2.5l2.2 10.5a1 1 0 0 0 1 .8h7.6a1 1 0 0 0 1-.8L19 7H6" {...S} />
            <circle cx="9.5" cy="19" r="1.3" {...S} />
            <circle cx="16.5" cy="19" r="1.3" {...S} />
        </>
    ),
    scroll: () => (
        <>
            <path d="M6 4h11a2 2 0 0 1 2 2v11a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V6" {...S} />
            <path d="M4 6a2 2 0 0 1 4 0v11M9 9h7M9 12h7M9 15h4" {...S} />
        </>
    ),
    shield: () => (
        <>
            <path d="M12 3 5 6v6c0 4.5 3 7.5 7 9 4-1.5 7-4.5 7-9V6l-7-3Z" {...S} />
            <path d="M9 12l2 2 4-4" {...S} />
        </>
    ),
    cloud: () => (
        <>
            <path d="M7 18a4 4 0 0 1 0-8 5 5 0 0 1 9.6-1.3A3.5 3.5 0 0 1 17.5 18H7z" {...S} />
        </>
    ),
    car: () => (
        <>
            <path d="M3 14l1.8-5a2 2 0 0 1 1.9-1.4h8.6A2 2 0 0 1 19 9l1.8 5M3 14h18M3 14v3.5h2.5V14M21 14v3.5h-2.5V14" {...S} />
            <circle cx="7.5" cy="14" r="1.6" {...S} />
            <circle cx="16.5" cy="14" r="1.6" {...S} />
        </>
    ),
    boss: () => (
        <>
            <path d="M5 18V9l3 2 4-6 4 6 3-2v9H5Z" {...S} />
            <path d="M5 20.5h14" {...S} />
            <circle cx="9.5" cy="13.5" r="0.9" {...F} />
            <circle cx="14.5" cy="13.5" r="0.9" {...F} />
        </>
    ),
    plant: () => (
        <>
            <path d="M12 21v-9" {...S} />
            <path d="M12 12c0-3-2-5-5-5 0 3 2 5 5 5ZM12 12c0-3 2-5 5-5 0 3-2 5-5 5Z" {...S} />
            <path d="M8 21h8" {...S} />
        </>
    ),
    hide: () => (
        <>
            <path d="M3 12s3.5-6 9-6c1.4 0 2.7.4 3.8 1M21 12s-3.5 6-9 6c-1.4 0-2.7-.4-3.8-1" {...S} />
            <path d="M9.5 9.5a3.5 3.5 0 0 0 5 5M4 4l16 16" {...S} />
        </>
    ),
    puzzle: () => (
        <path d="M10 4h4v2.2a1.5 1.5 0 1 0 3 0V4h3v3.5h-2.2a1.5 1.5 0 1 0 0 3H20v3.5h-3v-2.2a1.5 1.5 0 1 0-3 0V17h-4v-2.5H7.8a1.5 1.5 0 1 0 0-3H10V8H7.8a1.5 1.5 0 1 1 0-3H10V4Z" {...S} />
    ),
    obstacle: () => (
        <>
            <rect x="3.5" y="10" width="17" height="5" rx="1" {...S} />
            <path d="M6 10 9 15M11 10 14 15M16 10 19 15M5 10V8h14v2M5 15v2h14v-2" {...S} />
        </>
    ),
    music: () => (
        <>
            <path d="M9 18V6l10-2v12" {...S} />
            <circle cx="6" cy="18" r="3" {...S} />
            <circle cx="16" cy="16" r="3" {...S} />
        </>
    ),
    tower: () => (
        <>
            <path d="M7 21V9h10v12M7 9 9 5h6l2 4" {...S} />
            <path d="M10 21v-5h4v5M9 9h6M9 13h6" {...S} />
        </>
    ),
    zombie: () => (
        <>
            <rect x="6" y="3" width="12" height="11" rx="1.5" {...S} />
            <path d="M9 14v7M15 14v7M6 8H4l1 4M18 8h2l-1 4" {...S} />
            <path d="M9.5 8h.01M14.5 8h.01M10 11h4" {...S} />
        </>
    ),
    map: () => (
        <>
            <path d="M9 4 4 6v14l5-2 6 2 5-2V4l-5 2-6-2Z" {...S} />
            <path d="M9 4v14M15 6v14" {...S} />
        </>
    ),
    village: () => (
        <>
            <path d="M3 20V11l4-3 4 3v9M13 20v-7l4-3 4 3v7" {...S} />
            <path d="M3 20h18M6 20v-4h2v4M16 20v-3h2v3" {...S} />
        </>
    ),
    castle: () => (
        <>
            <path d="M4 21V8l2 2V6l2 2V5l2 2 2-2v3l2-2v4l2-2v13" {...S} />
            <path d="M4 21h12M9 21v-4h3v4" {...S} />
        </>
    ),
    gun: () => (
        <>
            <path d="M3 8h13v4h-3l-1 3H8l-1-3H3V8Z" {...S} />
            <path d="M16 8h5v3h-3M7 12v3" {...S} />
        </>
    ),
    click: () => (
        <>
            <path d="M9 4v8M9 8H4M9 8l5 1.5L9 11l3 4-2 1-3-4-2 3V8Z" {...S} />
        </>
    ),
    sparkles: () => (
        <>
            <path d="M12 4l1.6 4.4L18 10l-4.4 1.6L12 16l-1.6-4.4L6 10l4.4-1.6L12 4Z" {...S} />
            <path d="M18.5 14.5l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7.7-1.8Z" {...S} />
        </>
    ),
    trophy: () => (
        <>
            <path d="M7 4h10v4a5 5 0 0 1-10 0V4Z" {...S} />
            <path d="M7 6H4.5v1.5A3 3 0 0 0 7.5 10M17 6h2.5v1.5A3 3 0 0 1 16.5 10" {...S} />
            <path d="M12 13v3M9 20h6M10 20c0-1.5.5-2.5 2-2.5s2 1 2 2.5" {...S} />
        </>
    ),
    clock: () => (
        <>
            <circle cx="12" cy="12" r="9" {...S} />
            <path d="M12 7v5l3.5 2" {...S} />
        </>
    ),
};

export default function DocIcon({ name, size = 24, className = '' }) {
    const render = ICONS[name];
    if (!render) {
        // фолбэк — точка, чтобы было видно отсутствие иконки
        return (
            <svg width={size} height={size} viewBox="0 0 24 24" className={className} aria-hidden="true">
                <circle cx="12" cy="12" r="2.5" {...F} />
            </svg>
        );
    }
    return (
        <svg
            width={size}
            height={size}
            viewBox="0 0 24 24"
            className={className}
            role="img"
            aria-hidden="true"
        >
            {render()}
        </svg>
    );
}
