<?php ob_start(); ?>

<div class="content-header">
    <h2><?= __('admin.nav.consent') ?></h2>
    <p style="color:#6b7280;margin-top:.25rem;font-size:.9rem">
        <?= __('admin.consent.subtitle') ?>
    </p>
</div>

<form method="POST" action="/admin/consent/save" class="admin-form">
    <?= $csrf->field() ?>

    <div class="form-grid">
        <div class="form-main">

            <!-- Status ──────────────────────────────────────────────────── -->
            <div class="form-card">
                <h4><?= __('admin.consent.enable') ?></h4>
                <div class="form-group">
                    <label class="form-checkbox-label">
                        <input type="hidden" name="consent_enabled" value="0">
                        <input type="checkbox" id="consent_enabled" name="consent_enabled" value="1"
                               <?= ($settings['consent_enabled'] ?? '0') === '1' ? 'checked' : '' ?>>
                        <?= __('admin.consent.enable_label') ?>
                    </label>
                    <small class="form-hint">
                        <?= __('admin.consent.enable_hint') ?>
                    </small>
                </div>
            </div>

            <!-- Banner-Texte ─────────────────────────────────────────────── -->
            <div class="form-card">
                <h4><?= __('admin.consent.texts') ?></h4>
                <div class="form-group">
                    <label for="consent_title"><?= __('admin.consent.banner_title') ?></label>
                    <input type="text" id="consent_title" name="consent_title"
                           value="<?= e($settings['consent_title'] ?? 'Datenschutz & Cookies') ?>">
                </div>
                <div class="form-group">
                    <label for="consent_text"><?= __('admin.consent.banner_text') ?></label>
                    <textarea id="consent_text" name="consent_text" rows="3"><?= e($settings['consent_text'] ?? '') ?></textarea>
                    <small class="form-hint"><?= __('admin.consent.banner_text_hint') ?></small>
                </div>
            </div>

            <!-- Button-Beschriftungen ───────────────────────────────────── -->
            <div class="form-card">
                <h4><?= __('admin.consent.buttons') ?></h4>
                <div class="form-group">
                    <label for="consent_accept_label"><?= __('admin.consent.accept_all') ?></label>
                    <input type="text" id="consent_accept_label" name="consent_accept_label"
                           value="<?= e($settings['consent_accept_label'] ?? 'Alle akzeptieren') ?>">
                </div>
                <div class="form-group">
                    <label for="consent_reject_label"><?= __('admin.consent.reject_all') ?></label>
                    <input type="text" id="consent_reject_label" name="consent_reject_label"
                           value="<?= e($settings['consent_reject_label'] ?? 'Nur notwendige') ?>">
                </div>
                <div class="form-group">
                    <label for="consent_settings_label"><?= __('admin.consent.settings_btn') ?></label>
                    <input type="text" id="consent_settings_label" name="consent_settings_label"
                           value="<?= e($settings['consent_settings_label'] ?? 'Einstellungen') ?>">
                </div>
                <div class="form-group">
                    <label for="consent_save_label"><?= __('admin.consent.save_selection') ?></label>
                    <input type="text" id="consent_save_label" name="consent_save_label"
                           value="<?= e($settings['consent_save_label'] ?? 'Auswahl speichern') ?>">
                </div>
            </div>

            <!-- Kategorien ──────────────────────────────────────────────── -->
            <div class="form-card">
                <h4><?= __('admin.consent.categories') ?></h4>
                <p style="font-size:.85rem;color:#6b7280;margin-bottom:1rem">
                    <?= __('admin.consent.categories_hint') ?>
                </p>
                <div class="form-group">
                    <label for="consent_cat_necessary_label"><?= __('admin.consent.necessary_label') ?></label>
                    <input type="text" id="consent_cat_necessary_label" name="consent_cat_necessary_label"
                           value="<?= e($settings['consent_cat_necessary_label'] ?? 'Technisch notwendig') ?>">
                </div>
                <div class="form-group">
                    <label for="consent_cat_necessary_desc"><?= __('admin.consent.necessary_desc') ?></label>
                    <textarea id="consent_cat_necessary_desc" name="consent_cat_necessary_desc" rows="2"><?= e($settings['consent_cat_necessary_desc'] ?? '') ?></textarea>
                </div>
                <div class="form-group">
                    <label for="consent_cat_functional_label"><?= __('admin.consent.functional_label') ?></label>
                    <input type="text" id="consent_cat_functional_label" name="consent_cat_functional_label"
                           value="<?= e($settings['consent_cat_functional_label'] ?? 'Funktional') ?>">
                </div>
                <div class="form-group">
                    <label for="consent_cat_functional_desc"><?= __('admin.consent.functional_desc') ?></label>
                    <textarea id="consent_cat_functional_desc" name="consent_cat_functional_desc" rows="2"><?= e($settings['consent_cat_functional_desc'] ?? '') ?></textarea>
                </div>
            </div>

        </div><!-- /.form-main -->

        <div class="form-sidebar">

            <!-- Datenschutz-Link ──────────────────────────────────────────── -->
            <div class="form-card">
                <h4><?= __('admin.consent.privacy_link') ?></h4>
                <div class="form-group">
                    <label for="consent_privacy_url"><?= __('admin.consent.privacy_url') ?></label>
                    <input type="text" id="consent_privacy_url" name="consent_privacy_url"
                           value="<?= e($settings['consent_privacy_url'] ?? '/datenschutz') ?>"
                           placeholder="/datenschutz">
                </div>
                <div class="form-group">
                    <label for="consent_privacy_label"><?= __('admin.consent.privacy_text') ?></label>
                    <input type="text" id="consent_privacy_label" name="consent_privacy_label"
                           value="<?= e($settings['consent_privacy_label'] ?? 'Datenschutzerklärung') ?>">
                </div>
            </div>

            <!-- Darstellung ──────────────────────────────────────────────── -->
            <div class="form-card">
                <h4><?= __('admin.consent.display') ?></h4>
                <div class="form-group">
                    <label class="form-checkbox-label">
                        <input type="hidden" name="consent_show_logo" value="0">
                        <input type="checkbox" name="consent_show_logo" value="1"
                               <?= ($settings['consent_show_logo'] ?? '0') === '1' ? 'checked' : '' ?>>
                        <?= __('admin.consent.show_logo') ?>
                    </label>
                    <small class="form-hint"><?= __('admin.consent.show_logo_hint') ?></small>
                </div>
            </div>

            <!-- Cookie & Wiederöffnen ─────────────────────────────────────── -->
            <div class="form-card">
                <h4><?= __('admin.consent.cookie') ?></h4>
                <div class="form-group">
                    <label for="consent_cookie_name"><?= __('admin.consent.cookie_name') ?></label>
                    <input type="text" id="consent_cookie_name" name="consent_cookie_name"
                           value="<?= e($settings['consent_cookie_name'] ?? 'iw_consent') ?>">
                    <small class="form-hint"><?= __('admin.consent.cookie_name_hint') ?></small>
                </div>
                <div class="form-group">
                    <label for="consent_cookie_days"><?= __('admin.consent.cookie_days') ?></label>
                    <input type="number" id="consent_cookie_days" name="consent_cookie_days"
                           value="<?= e($settings['consent_cookie_days'] ?? '365') ?>" min="1" max="730">
                </div>
                <div class="form-group">
                    <label class="form-checkbox-label">
                        <input type="hidden" name="consent_show_reopen" value="0">
                        <input type="checkbox" name="consent_show_reopen" value="1"
                               <?= ($settings['consent_show_reopen'] ?? '1') === '1' ? 'checked' : '' ?>>
                        <?= __('admin.consent.show_reopen') ?>
                    </label>
                </div>
                <div class="form-group">
                    <label for="consent_reopen_label"><?= __('admin.consent.reopen_text') ?></label>
                    <input type="text" id="consent_reopen_label" name="consent_reopen_label"
                           value="<?= e($settings['consent_reopen_label'] ?? 'Cookie-Einstellungen') ?>">
                </div>
            </div>

            <button type="submit" class="btn btn-primary btn-full"><?= __('admin.consent.save') ?></button>
        </div><!-- /.form-sidebar -->

    </div><!-- /.form-grid -->
</form>

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