-- 010_plugins_watermark.sql: Screen Watermark plugin (水印管理)

CREATE TABLE IF NOT EXISTS watermark_config (
    id              INTEGER PRIMARY KEY AUTOINCREMENT,
    target_type     TEXT NOT NULL DEFAULT 'global' CHECK(target_type IN ('global', 'group', 'device')),
    target_id       TEXT,
    content         TEXT NOT NULL DEFAULT '公司名称 | {username} | {date}',
    font_size       INTEGER NOT NULL DEFAULT 14,
    opacity         REAL NOT NULL DEFAULT 0.15,
    color           TEXT NOT NULL DEFAULT '#808080',
    angle           INTEGER NOT NULL DEFAULT -30,
    enabled         INTEGER NOT NULL DEFAULT 1,
    updated_at      TEXT NOT NULL DEFAULT (datetime('now'))
);

-- Plugin enable/disable state per device group
CREATE TABLE IF NOT EXISTS plugin_state (
    id              INTEGER PRIMARY KEY AUTOINCREMENT,
    plugin_name     TEXT NOT NULL UNIQUE CHECK(plugin_name IN (
        'web_filter', 'usage_timer', 'software_blocker',
        'popup_blocker', 'usb_file_audit', 'watermark'
    )),
    enabled         INTEGER NOT NULL DEFAULT 0,
    target_type     TEXT NOT NULL DEFAULT 'global',
    target_id       TEXT,
    updated_at      TEXT NOT NULL DEFAULT (datetime('now'))
);
