<?php
/**
 * ITSWEBER CMS – Site Notice Settings
 *
 * Admin page for configuring the global announcement bar.
 *
 * @author    Benny Weber (ITSWEBER)
 * @copyright © ITSWEBER – www.itsweber.de
 *
 * @var array $config  Site notice configuration
 * @var object $csrf   CSRF instance
 */
ob_start();
?>

<?php admin_content_header(__('admin.site_notice.title'), 'megaphone', [], __('admin.site_notice.description')); ?>

<form method="POST" action="/admin/settings/site-notice" class="admin-form">
    <?= $csrf->field() ?>

    <div class="form-card">
        <div class="form-group">
            <label>
                <input type="hidden" name="active" value="0">
                <input type="checkbox" name="active" value="1" <?= !empty($config['active']) ? 'checked' : '' ?>>
                <?= __('admin.site_notice.active') ?>
            </label>
            <small class="form-hint"><?= __('admin.site_notice.active_hint') ?></small>
        </div>

        <div class="form-group">
            <label><?= __('admin.site_notice.text_label') ?></label>
            <textarea name="text" rows="3" placeholder="<?= e(__('admin.site_notice.text_placeholder')) ?>"><?= e($config['text'] ?? '') ?></textarea>
        </div>

        <div style="display:grid;grid-template-columns:1fr 1fr;gap:1rem 1.5rem;">
            <div class="form-group" style="margin:0;">
                <label><?= __('admin.site_notice.variant') ?></label>
                <select name="variant">
                    <option value="info"    <?= ($config['variant'] ?? 'info') === 'info'    ? 'selected' : '' ?>><?= __('admin.site_notice.variant_info') ?></option>
                    <option value="success" <?= ($config['variant'] ?? '') === 'success' ? 'selected' : '' ?>><?= __('admin.site_notice.variant_success') ?></option>
                    <option value="warning" <?= ($config['variant'] ?? '') === 'warning' ? 'selected' : '' ?>><?= __('admin.site_notice.variant_warning') ?></option>
                    <option value="danger"  <?= ($config['variant'] ?? '') === 'danger'  ? 'selected' : '' ?>><?= __('admin.site_notice.variant_danger') ?></option>
                </select>
            </div>

            <div class="form-group" style="margin:0;">
                <label><?= __('admin.site_notice.position') ?></label>
                <select name="position">
                    <option value="after_header"  <?= ($config['position'] ?? 'after_header') === 'after_header'  ? 'selected' : '' ?>><?= __('admin.site_notice.position_after_header') ?></option>
                    <option value="before_footer" <?= ($config['position'] ?? '') === 'before_footer' ? 'selected' : '' ?>><?= __('admin.site_notice.position_before_footer') ?></option>
                </select>
            </div>

            <div class="form-group" style="margin:0;">
                <label><?= __('admin.site_notice.link_url') ?></label>
                <input type="text" name="link_url" value="<?= e($config['link_url'] ?? '') ?>"
                       placeholder="https://example.com oder /seite">
            </div>

            <div class="form-group" style="margin:0;">
                <label><?= __('admin.site_notice.link_label') ?></label>
                <input type="text" name="link_label" value="<?= e($config['link_label'] ?? '') ?>"
                       placeholder="<?= e(__('admin.site_notice.link_label_placeholder')) ?>">
            </div>

            <div class="form-group" style="margin:0;">
                <label><?= __('admin.site_notice.dismiss') ?></label>
                <select name="dismiss">
                    <option value="session"   <?= ($config['dismiss'] ?? 'session') === 'session'   ? 'selected' : '' ?>><?= __('admin.site_notice.dismiss_session') ?></option>
                    <option value="permanent" <?= ($config['dismiss'] ?? '') === 'permanent' ? 'selected' : '' ?>><?= __('admin.site_notice.dismiss_permanent') ?></option>
                    <option value="none"      <?= ($config['dismiss'] ?? '') === 'none'      ? 'selected' : '' ?>><?= __('admin.site_notice.dismiss_none') ?></option>
                </select>
            </div>
        </div>
    </div>

    <div style="margin-top:1rem;">
        <button type="submit" class="btn btn-primary"><?= __('admin.common.save') ?></button>
    </div>
</form>

<?php
$content = ob_get_clean();
include dirname(__DIR__) . '/layouts/admin.php';
?>
