<?php
header('Content-Type: text/html; charset=utf-8');
$cfg = require __DIR__.'/../config/config.php';
$msg='';
if($_SERVER['REQUEST_METHOD']==='POST'){
  try{
    $pdo=new PDO("mysql:host={$cfg['db_host']};charset=utf8mb4",$cfg['db_user'],$cfg['db_pass'],[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);
    $sql=file_get_contents(__DIR__.'/../../database/schema.sql');
    $pdo->exec($sql);
    $msg='Installation completed. Admin: admin@sadaka.local / admin123. Please delete install.php after setup.';
  }catch(Throwable $e){$msg='Error: '.htmlspecialchars($e->getMessage());}
}
?><!doctype html><html lang="bn"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Sadaka Installer</title><style>body{font-family:system-ui;background:#f5f6fa;padding:30px}.card{max-width:650px;margin:auto;background:white;padding:28px;border-radius:24px;box-shadow:0 10px 35px #0001}button{background:#b71c1c;color:white;border:0;padding:14px 22px;border-radius:14px;font-weight:700}</style><div class="card"><h1>Sadaka Blood API Installer</h1><p>config/config.php এ database credentials দিন, তারপর Install চাপুন।</p><?php if($msg):?><p><b><?=$msg?></b></p><?php endif;?><form method="post"><button>Install Database</button></form></div></html>
