-- Migration 060: Per-section visibility and tier policy
-- Allows individual sections within a tab to be shown/hidden/locked/disabled
-- and gated behind a minimum user tier.

CREATE TABLE IF NOT EXISTS ftt_tab_section_policy (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    tab_id VARCHAR(64) NOT NULL,
    section_id VARCHAR(128) NOT NULL,
    section_label VARCHAR(128) NOT NULL DEFAULT '',
    visibility ENUM('show','hide','lock','disabled') NOT NULL DEFAULT 'show',
    min_tier ENUM('trial','user','pro','admin','developer') NOT NULL DEFAULT 'trial',
    message_content TEXT NULL,
    allow_override_for_developer_admin TINYINT(1) NOT NULL DEFAULT 1,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY uk_section_policy (tab_id, section_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Seed: Network tab sections
INSERT IGNORE INTO ftt_tab_section_policy (tab_id, section_id, section_label, visibility, min_tier) VALUES
  ('networkTab', 'networkOverview',        'Network Overview',         'show', 'trial'),
  ('networkTab', 'networkInterfaces',      'Network Interfaces',       'show', 'trial'),
  ('networkTab', 'wifiConnection',         'Wifi Connection Info',     'show', 'trial'),
  ('networkTab', 'networkCapabilities',    'Network Capabilities',     'show', 'trial'),
  ('networkTab', 'dnsServers',             'DNS Servers',              'show', 'trial'),
  ('networkTab', 'vpnIspLocation',         'VPN / ISP / Location',     'show', 'trial'),
  ('networkTab', 'networkQrCode',          'Network QR Code',          'show', 'trial');
