-- QR Stand Templates table for dynamic server-driven template engine
create table if not exists qr_stand_templates (
  id uuid primary key default gen_random_uuid(),
  key text not null unique,
  name text not null,
  category_name text,
  aspect_ratio text default '1/1',
  bg_type text default 'gradient',
  bg_image_url text,
  bg_gradient text,
  plaque_color text,
  border_accent text,
  accent_text text,
  header_text text,
  sub_text text,
  divider_color text,
  qr_config jsonb,
  layers jsonb,
  is_active boolean not null default true,
  created_at timestamptz not null default now(),
  updated_at timestamptz not null default now()
);

-- Public read access for mobile and web
alter table qr_stand_templates enable row level security;

create policy "Public read active templates"
  on qr_stand_templates for select
  using (is_active = true);

create policy "Admins can manage templates"
  on qr_stand_templates for all
  using (true);
