<!DOCTYPE html>
<html lang="vi">

<head>
    <?php require_once('head.php');?>
    <title>Chỉnh sửa đơn | Admin UI</title>
    <?php require_once('nav.php');?>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;600;700&display=swap" rel="stylesheet">
    <style>
        :root { --primary-color: #6366f1; }
        body { font-family: 'Plus Jakarta Sans', sans-serif !important; background-color: #f8fafc; color: #1e293b; }
        
        .main-card { background: rgba(255, 255, 255, 0.9); border-radius: 24px; border: 1px solid rgba(226, 232, 240, 0.8); backdrop-filter: blur(10px); }
        .form-label { font-weight: 600; font-size: 0.85rem; color: #64748b; margin-bottom: 8px; display: block; }
        .input-modern { border-radius: 16px; border: 1.5px solid #e2e8f0; padding: 14px 20px; transition: all 0.3s; background: #fdfdfd; }
        .input-modern:focus { border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15); }
        
        .btn-save { background: var(--primary-color); color: #fff; border-radius: 16px; padding: 14px 32px; font-weight: 700; transition: 0.3s; }
        .btn-save:hover { background: #4f46e5; box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3); }
        
        .status-badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 12px; font-weight: 600; font-size: 0.85rem; }
    </style>
</head>

<?php
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$api_logo = $ketnoi->query("SELECT * FROM `ls_logo` WHERE `id` = '$id' ")->fetch_array();

if (isset($_POST["submit"])) {
    $stmt = $ketnoi->prepare("UPDATE `ls_logo` SET `username` = ?, `name` = ?, `logo_output` = ?, `status` = ? WHERE `id` = ?");
    $stmt->bind_param("ssssi", $_POST['username'], $_POST['name'], $_POST['logo_output'], $_POST['status'], $id);
    if($stmt->execute()) {
        echo '<script>Swal.fire({icon:"success", title:"Đã lưu!", text:"Cập nhật thành công", showConfirmButton:false, timer:1500}).then(()=>{location.href="lsmuadomain.php"});</script>';
    }
}
?>

<body class="hold-transition sidebar-mini layout-fixed">
    <div class="wrapper">
        <div class="content-wrapper bg-transparent border-0">
            <section class="content p-4">
                <div class="container-fluid">
                    <div class="row justify-content-center">
                        <div class="col-lg-10">
                            <div class="d-flex justify-content-between align-items-center mb-4">
                                <div>
                                    <h2 class="font-weight-bold">Chỉnh sửa chi tiết</h2>
                                    <p class="text-muted">Cập nhật thông tin logo cho khách hàng ID: #<?=$id;?></p>
                                </div>
                                <a href="lsmuadomain.php" class="btn btn-outline-secondary rounded-pill">Quay lại danh sách</a>
                            </div>

                            <div class="main-card p-4 p-md-5">
                                <form method="post">
                                    <div class="row">
                                        <div class="col-md-6 mb-4">
                                            <label class="form-label">USERNAME KHÁCH HÀNG</label>
                                            <input type="text" class="form-control input-modern" name="username" value="<?=$api_logo['username'];?>">
                                        </div>
                                        <div class="col-md-6 mb-4">
                                            <label class="form-label">TÊN MIỀN / THƯƠNG HIỆU</label>
                                            <input type="text" class="form-control input-modern" name="name" value="<?=$api_logo['name'];?>">
                                        </div>
                                    </div>
                                    
                                    <div class="mb-4">
                                        <label class="form-label">LINK OUTPUT LOGO</label>
                                        <textarea class="form-control input-modern" name="logo_output" rows="4"><?=$api_logo['logo_output'];?></textarea>
                                    </div>

                                    <div class="mb-5">
                                        <label class="form-label">TRẠNG THÁI ĐƠN HÀNG</label>
                                        <select class="form-control input-modern" name="status">
                                            <option value="hoantat" <?=$api_logo['status']=='hoantat'?'selected':''?>>✅ Đã hoàn thành</option>
                                            <option value="xuly" <?=$api_logo['status']=='xuly'?'selected':''?>>⏳ Đang xử lý</option>
                                        </select>
                                    </div>

                                    <button type="submit" name="submit" class="btn btn-save w-100">
                                        <i class="fas fa-check-circle mr-2"></i> CẬP NHẬT THAY ĐỔI
                                    </button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
    <?php require_once('foot.php');?>
</body>
</html>