<?php
session_start();
include 'layouts/dbconn.php';
include 'layouts/session.php';

if (!isset($_SESSION['user_id'])) {
    header('Location: login.php');
    exit();
}

$msg = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Save settings to system_settings or dedicated table
    // Simulating save
    $_SESSION['success'] = "Privacy settings updated.";
    // If I had a real table, I'd update here. For now, visual feedback.
    $msg = '<div class="alert alert-success">Settings saved successfully.</div>';
}
?>
<?php include 'layouts/main.php'; ?>

<head>
    <?php includeFileWithVariables('layouts/title-meta.php', array('title' => 'Privacy Settings')); ?>
    <?php include 'layouts/head-css.php'; ?>
</head>

<body>
    <div id="layout-wrapper">
        <?php include 'layouts/menu.php'; ?>
        <div class="main-content">
            <div class="page-content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-12">
                            <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                <h4 class="mb-sm-0">Data Privacy & Security Settings</h4>
                            </div>
                        </div>
                    </div>

                    <?php echo $msg; ?>

                    <div class="row">
                        <div class="col-lg-8">
                            <div class="card">
                                <div class="card-body">
                                    <form method="POST">
                                        <h5 class="mb-3">Data Retention</h5>
                                        <div class="mb-3">
                                            <label class="form-label">Retain Inactive Patient Records (Years)</label>
                                            <input type="number" class="form-control" name="retention_years" value="10">
                                        </div>

                                        <h5 class="mb-3 mt-4">Access Logging</h5>
                                        <div class="form-check form-switch mb-2">
                                            <input class="form-check-input" type="checkbox" checked>
                                            <label class="form-check-label">Log all medical record views</label>
                                        </div>
                                        <div class="form-check form-switch mb-2">
                                            <input class="form-check-input" type="checkbox" checked>
                                            <label class="form-check-label">Log all export actions</label>
                                        </div>

                                        <h5 class="mb-3 mt-4">Patient Consent</h5>
                                        <div class="form-check form-switch mb-2">
                                            <input class="form-check-input" type="checkbox">
                                            <label class="form-check-label">Require explicit consent for SMS
                                                notifications</label>
                                        </div>

                                        <div class="mt-4">
                                            <button type="submit" class="btn btn-primary">Save Changes</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include 'layouts/footer.php'; ?>
        </div>
    </div>
    <?php include 'layouts/vendor-scripts.php'; ?>
</body>

</html>