-- =============================================================================
-- متجر النخبة الرقمي — قاعدة البيانات الكاملة (PostgreSQL)
-- شغّل هذا الملف في phpPgAdmin أو من ترمنال cPanel:
--   psql -U username -d database_name -f DEPLOY_SQL.sql
-- =============================================================================

-- ============================== 1) الجداول ==============================

CREATE TABLE IF NOT EXISTS "user_groups" (
  "id" serial PRIMARY KEY,
  "name" text NOT NULL,
  "color" text DEFAULT '#0d7a6f',
  "profit_percent" double precision DEFAULT 0 NOT NULL,
  "is_vip" boolean DEFAULT false NOT NULL,
  "is_default" boolean DEFAULT false NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "users" (
  "id" serial PRIMARY KEY,
  "name" text NOT NULL,
  "email" text,
  "phone" text,
  "password_hash" text NOT NULL,
  "balance" double precision DEFAULT 0 NOT NULL,
  "group_id" integer REFERENCES "user_groups"("id"),
  "agent_code" text,
  "status" text DEFAULT 'active' NOT NULL,
  "avatar" text,
  "pin_hash" text,
  "two_fa_secret" text,
  "two_fa_enabled" boolean DEFAULT false NOT NULL,
  "notify_on_execution" boolean DEFAULT true NOT NULL,
  "allowed_ips" text,
  "custom_profits" jsonb DEFAULT '[]'::jsonb,
  "ip" text,
  "banned_reason" text,
  "last_active_at" timestamp with time zone DEFAULT now() NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "users_email_idx" ON "users" ("email");
CREATE INDEX IF NOT EXISTS "users_group_idx" ON "users" ("group_id");

CREATE TABLE IF NOT EXISTS "admins" (
  "id" serial PRIMARY KEY,
  "username" text NOT NULL,
  "name" text NOT NULL,
  "password_hash" text NOT NULL,
  "role" text DEFAULT 'staff' NOT NULL,
  "permissions" jsonb DEFAULT '[]'::jsonb,
  "avatar" text,
  "telegram" text,
  "pin_hash" text,
  "two_fa_secret" text,
  "two_fa_enabled" boolean DEFAULT false NOT NULL,
  "recovery_codes" jsonb DEFAULT '[]'::jsonb,
  "dashboard_style" text DEFAULT 'classic' NOT NULL,
  "notif_prefs" jsonb DEFAULT '{"orders":true,"deposits":true,"complaints":true,"viaTelegram":false,"viaEmail":false}'::jsonb,
  "theme" text DEFAULT 'light' NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS "admins_username_idx" ON "admins" ("username");

CREATE TABLE IF NOT EXISTS "sessions" (
  "id" serial PRIMARY KEY,
  "token_hash" text NOT NULL,
  "kind" text DEFAULT 'admin' NOT NULL,
  "ref_id" integer NOT NULL,
  "device" text,
  "ip" text,
  "status" text DEFAULT 'active' NOT NULL,
  "last_seen_at" timestamp with time zone DEFAULT now() NOT NULL,
  "expires_at" timestamp with time zone NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "sessions_token_idx" ON "sessions" ("token_hash");
CREATE INDEX IF NOT EXISTS "sessions_ref_idx" ON "sessions" ("kind", "ref_id");

CREATE TABLE IF NOT EXISTS "permissions" (
  "key" text PRIMARY KEY,
  "label" text NOT NULL,
  "section" text NOT NULL
);

CREATE TABLE IF NOT EXISTS "categories" (
  "id" serial PRIMARY KEY,
  "name" text NOT NULL,
  "parent_id" integer,
  "image" text,
  "icon" text,
  "sort" integer DEFAULT 0 NOT NULL,
  "active" boolean DEFAULT true NOT NULL,
  "profit_percent" double precision DEFAULT 0 NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "providers" (
  "id" serial PRIMARY KEY,
  "name" text NOT NULL,
  "api_url" text NOT NULL,
  "api_key_enc" text NOT NULL,
  "kind" text DEFAULT 'smm' NOT NULL,
  "active" boolean DEFAULT true NOT NULL,
  "services_count" integer DEFAULT 0 NOT NULL,
  "last_sync_at" timestamp with time zone,
  "last_sync_status" text DEFAULT 'idle' NOT NULL,
  "last_error" text,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "provider_services" (
  "id" serial PRIMARY KEY,
  "provider_id" integer NOT NULL REFERENCES "providers"("id"),
  "ext_id" text NOT NULL,
  "name" text NOT NULL,
  "category" text,
  "price" double precision DEFAULT 0 NOT NULL,
  "min" integer DEFAULT 1 NOT NULL,
  "max" integer DEFAULT 100000 NOT NULL
);
CREATE INDEX IF NOT EXISTS "psvc_provider_idx" ON "provider_services" ("provider_id");

CREATE TABLE IF NOT EXISTS "services" (
  "id" serial PRIMARY KEY,
  "name" text NOT NULL,
  "description" text,
  "category_id" integer REFERENCES "categories"("id"),
  "image" text,
  "kind" text DEFAULT 'internal' NOT NULL,
  "base_price" double precision DEFAULT 0 NOT NULL,
  "price" double precision DEFAULT 0 NOT NULL,
  "profit_percent" double precision DEFAULT 0 NOT NULL,
  "provider_id" integer REFERENCES "providers"("id"),
  "provider_service_id" text,
  "min_qty" integer DEFAULT 1 NOT NULL,
  "max_qty" integer DEFAULT 1000000 NOT NULL,
  "sort" integer DEFAULT 0 NOT NULL,
  "active" boolean DEFAULT true NOT NULL,
  "pinned" boolean DEFAULT false NOT NULL,
  "pinned_sort" integer DEFAULT 0 NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "services_cat_idx" ON "services" ("category_id");
CREATE INDEX IF NOT EXISTS "services_provider_idx" ON "services" ("provider_id");

CREATE TABLE IF NOT EXISTS "inventory_items" (
  "id" serial PRIMARY KEY,
  "service_id" integer NOT NULL REFERENCES "services"("id"),
  "code" text NOT NULL,
  "status" text DEFAULT 'available' NOT NULL,
  "sold_order_id" integer,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "inv_service_idx" ON "inventory_items" ("service_id");
CREATE INDEX IF NOT EXISTS "inv_status_idx" ON "inventory_items" ("status");

CREATE TABLE IF NOT EXISTS "currencies" (
  "id" serial PRIMARY KEY,
  "code" text NOT NULL,
  "name" text NOT NULL,
  "symbol" text NOT NULL,
  "rate" double precision DEFAULT 1 NOT NULL,
  "is_base" boolean DEFAULT false NOT NULL,
  "active" boolean DEFAULT true NOT NULL
);

CREATE TABLE IF NOT EXISTS "orders" (
  "id" serial PRIMARY KEY,
  "user_id" integer NOT NULL REFERENCES "users"("id"),
  "service_id" integer REFERENCES "services"("id"),
  "link" text,
  "qty" integer DEFAULT 1 NOT NULL,
  "charge" double precision DEFAULT 0 NOT NULL,
  "profit" double precision DEFAULT 0 NOT NULL,
  "currency_id" integer REFERENCES "currencies"("id"),
  "kind" text DEFAULT 'internal' NOT NULL,
  "provider_order_id" text,
  "status" text DEFAULT 'pending' NOT NULL,
  "note" text,
  "manager_note" text,
  "timeline" jsonb DEFAULT '[]'::jsonb,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL,
  "updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "orders_user_idx" ON "orders" ("user_id");
CREATE INDEX IF NOT EXISTS "orders_status_idx" ON "orders" ("status");
CREATE INDEX IF NOT EXISTS "orders_created_idx" ON "orders" ("created_at");

CREATE TABLE IF NOT EXISTS "deposits" (
  "id" serial PRIMARY KEY,
  "user_id" integer NOT NULL REFERENCES "users"("id"),
  "amount" double precision DEFAULT 0 NOT NULL,
  "method" text DEFAULT 'manual' NOT NULL,
  "bank_id" integer,
  "receipt" text,
  "reference" text,
  "status" text DEFAULT 'pending' NOT NULL,
  "note" text,
  "decided_at" timestamp with time zone,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "deposits_status_idx" ON "deposits" ("status");

CREATE TABLE IF NOT EXISTS "transactions" (
  "id" serial PRIMARY KEY,
  "user_id" integer NOT NULL REFERENCES "users"("id"),
  "type" text NOT NULL,
  "amount" double precision DEFAULT 0 NOT NULL,
  "balance_after" double precision DEFAULT 0 NOT NULL,
  "ref" text,
  "note" text,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "tx_user_idx" ON "transactions" ("user_id");

CREATE TABLE IF NOT EXISTS "transfers" (
  "id" serial PRIMARY KEY,
  "from_user_id" integer NOT NULL REFERENCES "users"("id"),
  "to_user_id" integer NOT NULL REFERENCES "users"("id"),
  "amount" double precision DEFAULT 0 NOT NULL,
  "status" text DEFAULT 'completed' NOT NULL,
  "note" text,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "banks" (
  "id" serial PRIMARY KEY,
  "name" text NOT NULL,
  "holder" text,
  "number" text,
  "kind" text DEFAULT 'bank' NOT NULL,
  "image" text,
  "qr" text,
  "active" boolean DEFAULT true NOT NULL,
  "sort" integer DEFAULT 0 NOT NULL
);

CREATE TABLE IF NOT EXISTS "recharge_codes" (
  "id" serial PRIMARY KEY,
  "code" text NOT NULL,
  "amount" double precision DEFAULT 0 NOT NULL,
  "batch" text NOT NULL,
  "used_by_id" integer REFERENCES "users"("id"),
  "used_at" timestamp with time zone,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS "codes_code_idx" ON "recharge_codes" ("code");

CREATE TABLE IF NOT EXISTS "kyc_requests" (
  "id" serial PRIMARY KEY,
  "user_id" integer NOT NULL REFERENCES "users"("id"),
  "full_name" text NOT NULL,
  "doc_type" text DEFAULT 'id' NOT NULL,
  "doc_number" text,
  "doc_image" text,
  "selfie_image" text,
  "status" text DEFAULT 'pending' NOT NULL,
  "reviewed_by_id" integer,
  "review_note" text,
  "decided_at" timestamp with time zone,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "kyc_status_idx" ON "kyc_requests" ("status");

CREATE TABLE IF NOT EXISTS "complaints" (
  "id" serial PRIMARY KEY,
  "user_id" integer NOT NULL REFERENCES "users"("id"),
  "order_id" integer REFERENCES "orders"("id"),
  "subject" text NOT NULL,
  "body" text,
  "status" text DEFAULT 'open' NOT NULL,
  "reply" text,
  "resolved_at" timestamp with time zone,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "agents" (
  "id" serial PRIMARY KEY,
  "name" text NOT NULL,
  "phone" text,
  "email" text,
  "referral_code" text NOT NULL,
  "commission_percent" double precision DEFAULT 5 NOT NULL,
  "balance" double precision DEFAULT 0 NOT NULL,
  "active" boolean DEFAULT true NOT NULL,
  "listed" boolean DEFAULT true NOT NULL,
  "payment_account" text,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS "agents_code_idx" ON "agents" ("referral_code");

CREATE TABLE IF NOT EXISTS "countries" (
  "id" serial PRIMARY KEY,
  "name" text NOT NULL,
  "flag" text,
  "phone_code" text NOT NULL,
  "active" boolean DEFAULT true NOT NULL,
  "sort" integer DEFAULT 0 NOT NULL
);

CREATE TABLE IF NOT EXISTS "profit_rules" (
  "id" serial PRIMARY KEY,
  "scope" text NOT NULL,
  "category_id" integer,
  "service_id" integer,
  "group_id" integer,
  "user_id" integer,
  "profit_type" text DEFAULT 'percent' NOT NULL,
  "value" double precision DEFAULT 0 NOT NULL,
  "active" boolean DEFAULT true NOT NULL,
  "note" text,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "notifications" (
  "id" serial PRIMARY KEY,
  "channel" text DEFAULT 'app' NOT NULL,
  "audience" text DEFAULT 'all' NOT NULL,
  "target_ids" jsonb DEFAULT '[]'::jsonb,
  "title" text NOT NULL,
  "body" text,
  "status" text DEFAULT 'sent' NOT NULL,
  "error" text,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "email_logs" (
  "id" serial PRIMARY KEY,
  "to_addr" text NOT NULL,
  "subject" text NOT NULL,
  "status" text DEFAULT 'sent' NOT NULL,
  "error" text,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "announcements" (
  "id" serial PRIMARY KEY,
  "title" text NOT NULL,
  "body" text,
  "audience" text DEFAULT 'all' NOT NULL,
  "target_ids" jsonb DEFAULT '[]'::jsonb,
  "active" boolean DEFAULT true NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "banners" (
  "id" serial PRIMARY KEY,
  "image" text,
  "title" text,
  "link" text,
  "sort" integer DEFAULT 0 NOT NULL,
  "active" boolean DEFAULT true NOT NULL
);

CREATE TABLE IF NOT EXISTS "settings" (
  "key" text PRIMARY KEY,
  "value" jsonb NOT NULL
);

CREATE TABLE IF NOT EXISTS "api_keys" (
  "id" serial PRIMARY KEY,
  "user_id" integer NOT NULL REFERENCES "users"("id"),
  "name" text DEFAULT 'main' NOT NULL,
  "key_hash" text NOT NULL,
  "prefix" text NOT NULL,
  "allowed_ips" text,
  "active" boolean DEFAULT true NOT NULL,
  "last_used_at" timestamp with time zone,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "api_logs" (
  "id" serial PRIMARY KEY,
  "user_id" integer,
  "method" text NOT NULL,
  "path" text NOT NULL,
  "status" integer NOT NULL,
  "ip" text,
  "duration_ms" integer,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "security_logs" (
  "id" serial PRIMARY KEY,
  "event" text NOT NULL,
  "actor" text,
  "ip" text,
  "meta" jsonb DEFAULT '{}'::jsonb,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "audit_logs" (
  "id" serial PRIMARY KEY,
  "admin_id" integer,
  "admin_name" text,
  "action" text NOT NULL,
  "entity" text,
  "entity_id" text,
  "meta" jsonb DEFAULT '{}'::jsonb,
  "ip" text,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "ip_blacklist" (
  "id" serial PRIMARY KEY,
  "ip" text NOT NULL,
  "reason" text,
  "created_by_id" integer,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "competitions" (
  "id" serial PRIMARY KEY,
  "name" text NOT NULL,
  "kind" text DEFAULT 'purchase' NOT NULL,
  "prize" text,
  "starts_at" timestamp with time zone,
  "ends_at" timestamp with time zone,
  "active" boolean DEFAULT true NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "competition_entries" (
  "id" serial PRIMARY KEY,
  "competition_id" integer NOT NULL REFERENCES "competitions"("id"),
  "user_id" integer NOT NULL REFERENCES "users"("id"),
  "points" double precision DEFAULT 0 NOT NULL,
  "detail" text,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "entries_comp_idx" ON "competition_entries" ("competition_id");

CREATE TABLE IF NOT EXISTS "backups" (
  "id" serial PRIMARY KEY,
  "filename" text NOT NULL,
  "size_bytes" integer DEFAULT 0 NOT NULL,
  "kind" text DEFAULT 'manual' NOT NULL,
  "sent_to_telegram" boolean DEFAULT false NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

CREATE TABLE IF NOT EXISTS "assistant_messages" (
  "id" serial PRIMARY KEY,
  "user_id" integer,
  "role" text DEFAULT 'user' NOT NULL,
  "content" text NOT NULL,
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
);

-- ============================== 2) البيانات الأساسية ==============================

-- المدير الرئيسي (username: admin  password: admin123)
INSERT INTO "admins" ("username", "name", "password_hash", "role") VALUES
  ('admin', 'مدير النظام', '$2a$10$hHmC3jI0mFP/PxYd9E5MRuEPZKGRJZOxKuIYjOVWmZDcTFn/PDXbG', 'owner')
ON CONFLICT (username) DO NOTHING;

-- المجموعات الافتراضية
INSERT INTO "user_groups" ("name", "color", "profit_percent", "is_default") VALUES
  ('العملاء العاديون', '#0d7a6f', 10, true),
  ('كبار العملاء VIP', '#e89a2b', 5, false),
  ('الموزعون', '#3b82c4', 3, false)
ON CONFLICT DO NOTHING;

-- العملة الأساسية
INSERT INTO "currencies" ("code", "name", "symbol", "rate", "is_base", "active") VALUES
  ('USD', 'دولار أمريكي', '$', 1, true, true),
  ('TRY', 'ليرة تركية', '₺', 38.5, false, true),
  ('SYP', 'ليرة سورية', 'ل.س', 13200, false, true)
ON CONFLICT DO NOTHING;

-- الإعدادات الافتراضية
INSERT INTO "settings" ("key", "value") VALUES
  ('general', '{"siteName":"متجر النخبة الرقمي","tabTitle":"متجر النخبة — خدمات رقمية","siteUrl":"","logo":"","marquee":"🔥 خصومات وعروض يومية — تسليم فوري — دعم على مدار الساعة","about":"منصة رقمية موثوقة لبيع خدمات السوشيال ميديا والبطاقات الرقمية.","terms":"باستخدام المنصة أنت توافق على شروط الاستخدام.","socials":[]}'::jsonb),
  ('system', '{"globalProfitPercent":10,"baseCurrency":"USD","registrationOpen":true,"maintenance":false,"complaintsAllowed":true,"hideOutOfStock":true,"approveNewAccounts":false,"apiAccess":true,"autoDepositWaitMin":30,"syrianAutoPay":true,"secondaryCurrency":false,"idleLockMinutes":15}'::jsonb),
  ('security', '{"customerPinRequired":false,"customer2fa":false,"adminPinRequired":false,"admin2faForce":false,"idleLockMinutes":15,"apiLogEnabled":true}'::jsonb),
  ('seo', '{"seoTitle":"متجر النخبة الرقمي","seoDesc":"خدمات رقمية بتسليم فوري","keywords":"متجر,خدمات,رقمية","indexingAllowed":true,"analyticsCode":""}'::jsonb),
  ('notifications', '{"whatsappAdmins":[],"telegramCustomerBot":"","telegramAdminBots":[],"webPushEnabled":false}'::jsonb),
  ('assistant', '{"enabled":false,"provider":"openai","apiKey":"","baseUrl":"https://api.openai.com/v1","model":"gpt-4o-mini","name":"المساعد","welcome":"أهلًا بك! كيف أخدمك؟","primaryColor":"#0d7a6f","bubbleColor":"#e89a2b","maxPerDay":20}'::jsonb),
  ('pwa', '{"appName":"متجر النخبة","themeColor":"#0d7a6f","bgColor":"#0a1210","icon":"","adminLockPin":""}'::jsonb),
  ('design', '{"template":"default","primary":"#0d7a6f","secondary":"#e89a2b","gradient":true,"radius":14,"cardStyle":"bordered","gridCols":4,"headerStyle":"solid","fontScale":1,"bottomBarColor":"#0d7a6f","sidebarItems":[{"label":"الرئيسية","icon":"home"},{"label":"الخدمات","icon":"grid"},{"label":"طلباتي","icon":"list"},{"label":"محفظتي","icon":"wallet"}]}'::jsonb),
  ('backup', '{"schedule":"daily","keep":7,"lastAuto":null}'::jsonb)
ON CONFLICT (key) DO NOTHING;

-- الصلاحيات
INSERT INTO "permissions" ("key", "label", "section") VALUES
  ('dashboard','لوحة التحكم','عام'),
  ('orders','الطلبات','العمليات'),
  ('deposits','الإيداعات','العمليات'),
  ('transfers','التحويلات','العمليات'),
  ('complaints','الاعتراضات','العمليات'),
  ('users','المستخدمون','الأعضاء'),
  ('groups','المجموعات','الأعضاء'),
  ('kyc','تحقق الهوية','الأعضاء'),
  ('agents','الوكلاء','الأعضاء'),
  ('admins','إدارة المشرفين','الأعضاء'),
  ('categories','التصنيفات','المتجر'),
  ('services','الخدمات','المتجر'),
  ('pinned','الخدمات المثبتة','المتجر'),
  ('inventory','المخزون الرقمي','المتجر'),
  ('providers','المزودون','المتجر'),
  ('profits','تخصيص الأرباح','المالية'),
  ('banks','البنوك والمحافظ','المالية'),
  ('currencies','العملات','المالية'),
  ('codes','أكواد الشحن','المالية'),
  ('reports','الجرد والتقارير','المالية'),
  ('notifications','الإشعارات','المنصة'),
  ('assistant','المساعد الذكي','المنصة'),
  ('alerts','التنبيهات','المنصة'),
  ('competitions','المسابقات','المنصة'),
  ('countries','الدول','المنصة'),
  ('design','تصميم المتجر','الإعدادات'),
  ('pwa','تطبيقات الهاتف','الإعدادات'),
  ('settings','الإعدادات العامة','الإعدادات'),
  ('system','إعدادات النظام','الإعدادات'),
  ('security','الحماية والأمان','الإعدادات'),
  ('seo','تحسين SEO','الإعدادات'),
  ('monitoring','المراقبة والنسخ','الإعدادات'),
  ('audit','سجل العمليات','الإعدادات')
ON CONFLICT (key) DO NOTHING;

-- التصنيفات الأساسية
INSERT INTO "categories" ("name", "icon", "sort", "profit_percent") VALUES
  ('سوشيال ميديا', '📱', 1, 10),
  ('ألعاب وبطاقات', '🎮', 2, 12),
  ('اشتراكات رقمية', '💎', 3, 8)
ON CONFLICT DO NOTHING;

-- طرق الدفع الافتراضية
INSERT INTO "banks" ("name", "holder", "number", "kind", "sort", "active") VALUES
  ('شام كاش', 'إدارة المتجر', '0931 000 000', 'sham', 1, true),
  ('سيريتل كاش', 'إدارة المتجر', '0944 000 000', 'syriatel', 2, true),
  ('USDT (TRC20)', 'Treasury', 'TXyZ...', 'usdt', 3, true)
ON CONFLICT DO NOTHING;

-- =============================================================================
-- انتهى الملف. الآن يمكنك تسجيل الدخول بـ:
--   المستخدم: admin
--   كلمة المرور: admin123
-- =============================================================================
