<?php
include 'koneksi.php';
include 'header_pelanggan.php'; // Pastikan header sudah ada untuk pelanggan

$query = "SELECT id_servis, nama_servis, deskripsi, harga FROM tbl_servis";
$result = mysqli_query($koneksi, $query);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Daftar Servis</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 900px;
            margin: 20px auto;
            padding: 20px;
            background-color: white;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
        }
        h2 {
            text-align: center;
            color: #4CAF50;
        }
        .service-card {
            display: flex;
            flex-direction: column;
            margin-bottom: 20px;
            padding: 15px;
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .service-card h3 {
            margin: 0;
            color: #333;
            font-size: 20px;
        }
        .service-card p {
            font-size: 14px;
            color: #666;
            margin: 5px 0;
        }
        .service-card .price {
            font-size: 16px;
            font-weight: bold;
            color: #009688;
            margin-top: 10px;
        }
        .service-card button {
            margin-top: 15px;
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        .service-card button:hover {
            background-color: #45a049;
        }
        hr {
            border: 1px solid #ddd;
        }
    </style>
</head>
<body>

    <div class="container">
        <h2>Daftar Servis</h2>
        <?php while ($row = mysqli_fetch_assoc($result)) { ?>
            <div class="service-card">
                <h3><?= $row['nama_servis']; ?></h3>
                <p><?= $row['deskripsi']; ?></p>
                <p class="price">Harga: Rp<?= number_format($row['harga'], 0, ',', '.'); ?></p>
                <form action="form_pesan.php" method="POST">
                    <input type="hidden" name="id_servis" value="<?= $row['id_servis']; ?>">
                    <button type="submit">Pesan Sekarang</button>
                </form>
            </div>
            <hr>
        <?php } ?>
    </div>

</body>
</html>
