<div class="container-fluid">
    <h1 class="h3 mb-4 text-gray-800">Input Data Suhu dan Kelembapan</h1>

    <?php if (isset($_GET['message'])): ?>
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            <?php
                switch ($_GET['message']) {
                    case 'input_success':
                        echo "Data suhu dan kelembapan berhasil ditambahkan.";
                        break;
                }
            ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    <?php endif; ?>
    <?php if (isset($_GET['error'])): ?>
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            <?php
                switch ($_GET['error']) {
                    case 'empty_fields':
                        echo "Suhu dan kelembapan tidak boleh kosong.";
                        break;
                    case 'invalid_data':
                        echo "Input suhu dan kelembapan harus berupa angka.";
                        break;
                    case 'save_failed':
                        echo "Gagal menyimpan data. Silakan coba lagi.";
                        break;
                }
            ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    <?php endif; ?>

    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">Form Input</h6>
        </div>
        <div class="card-body">
            <form action="?page=room_temperature_add_reading" method="POST">
                <div class="mb-3">
                    <label for="temperature" class="form-label">Suhu (°C)</label>
                    <input type="number" step="0.1" class="form-control" id="temperature" name="temperature" required>
                </div>
                <div class="mb-3">
                    <label for="humidity" class="form-label">Kelembapan (%)</label>
                    <input type="number" step="0.1" class="form-control" id="humidity" name="humidity" required>
                </div>
                <button type="submit" class="btn btn-primary">Simpan Data</button>
            </form>
        </div>
    </div>
</div>
