<section class="report-toolbar">
    <div>
        <p class="eyebrow"><?= e(trans('common.administrator')) ?></p>
        <h1><?= e(trans('admin.areas_heading')) ?></h1>
        <p class="support-copy"><?= e(trans('admin.areas_copy')) ?></p>
    </div>
</section>

<section class="card table-card admin-section-stack">
    <form method="get" action="<?= e(base_url('/admin/areas')) ?>" class="inline-form-grid filter-grid">
        <label>
            <span><?= e(trans('common.ui_language')) ?></span>
            <select name="lang">
                <?php foreach ($languages as $languageCode => $languageLabel): ?>
                    <option value="<?= e($languageCode) ?>" <?= current_locale() === $languageCode ? 'selected' : '' ?>><?= e($languageLabel) ?></option>
                <?php endforeach; ?>
            </select>
        </label>
        <label class="wide-field">
            <span><?= e(trans('admin.filter_search')) ?></span>
            <input type="text" name="search" value="<?= e($filters['search']) ?>" placeholder="<?= e(trans('admin.areas_search_placeholder')) ?>">
        </label>
        <div class="filter-actions">
            <button class="ghost-button" type="submit"><?= e(trans('common.apply')) ?></button>
        </div>
    </form>

    <div class="table-wrap">
        <table>
            <thead>
                <tr>
                    <th><?= e(trans('common.area')) ?></th>
                    <th><?= e(trans('common.description')) ?></th>
                    <th><?= e(trans('common.actions')) ?></th>
                </tr>
            </thead>
            <tbody>
                <?php if ($items === []): ?>
                    <tr><td colspan="3"><?= e(trans('admin.areas_empty')) ?></td></tr>
                <?php endif; ?>
                <?php foreach ($items as $item): ?>
                    <tr>
                        <td>
                            <strong><?= e($item['area_code']) ?></strong><br>
                            <?= e($item['name']) ?>
                        </td>
                        <td><?= e($item['description']) ?></td>
                        <td class="actions-cell">
                            <a class="text-link" href="<?= e(base_url('/admin/areas/edit?area=' . urlencode($item['area_code']))) ?>"><?= e(trans('common.edit')) ?></a>
                        </td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</section>