<?php $pageTitle = t('preferences'); ?>
<div class="page-header">
    <div class="page-header-left">
        <h1 class="page-title"><?= t('preferences') ?></h1>
    </div>
</div>

<?php if (!empty($success)): ?>
<div class="alert alert-success"><?= Helper::e($success) ?></div>
<?php endif; ?>
<?php if (!empty($errors)): ?>
<div class="alert alert-error"><?php foreach ($errors as $e): ?><div><?= Helper::e($e) ?></div><?php endforeach; ?></div>
<?php endif; ?>

<div class="settings-grid">
<div class="settings-col">
    <div class="card">
        <div class="card-header"><h2 class="card-title"><?= t('preferred_project_view') ?></h2></div>
        <div class="card-body">
            <p class="text-muted" style="margin-bottom:1rem;font-size:.9rem">
                <?= t('preferred_view_hint') ?>
            </p>
            <form method="POST">
                <?= Helper::csrf() ?>
                <input type="hidden" name="action" value="update_preferences">
                <div class="form-group">
                    <label class="form-label"><?= t('default_view') ?></label>
                    <select name="preferred_view" class="form-select">
                        <option value="kanban" <?= ($user['preferred_view'] ?? 'kanban') === 'kanban' ? 'selected' : '' ?>>Kanban</option>
                        <option value="list"   <?= ($user['preferred_view'] ?? '') === 'list'   ? 'selected' : '' ?>><?= t('list') ?></option>
                        <option value="gantt"  <?= ($user['preferred_view'] ?? '') === 'gantt'  ? 'selected' : '' ?>>Gantt</option>
                    </select>
                </div>
                <button type="submit" class="btn btn-primary"><?= t('save') ?></button>
            </form>
        </div>
    </div>
</div>
<div class="settings-col">
    <?php PluginManager::fire('settings_preferences_extra', ['user' => $user]); ?>
</div>
</div>
