{% extends "base.html" %}
{% block title %}Bulk Import File Areas — {{ config.BBS_NAME }}{% endblock %}

{% block content %}
<div class="bbs-header">
    <h1><i class="bi bi-upload"></i> Bulk Import File Areas</h1>
</div>

<a href="{{ url_for('admin.file_areas_admin') }}" class="btn btn-primary btn-sm mb-3">
    <i class="bi bi-arrow-left"></i> Back to File Areas
</a>

<div class="card">
    <div class="card-header"><i class="bi bi-list-ul"></i> Import from Backbone File or Echolist</div>
    <div class="card-body">
        <p style="font-size:0.9rem; color:#00cc00;">
            One area per line. Both forms are accepted:
        </p>
        <pre style="background:#001100; border:1px solid #006600; padding:0.5rem; font-size:0.8rem; color:#0c0;">FILES_GAMES     Game files
TQW_FILES       - TQW File Echo         (FidoNet backbone style)</pre>
        <p style="font-size:0.85rem; color:#888;">
            Lines starting with <code>;</code> or <code>#</code> are skipped.
            Leading <code>-</code> on the description is stripped automatically,
            so <code>FILEBONE.NA</code>-style files import cleanly. Storage
            paths aren't set — edit each area afterwards to point at a
            directory, or leave blank for queue-only.
        </p>
        <form method="post" enctype="multipart/form-data">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">

            <div class="mb-3">
                <label class="form-label">Network (optional — leave blank for local-only)</label>
                <select name="network_id" class="form-control">
                    <option value="">— local —</option>
                    {% for n in networks %}
                    <option value="{{ n.id }}">{{ n.name }} ({{ n.network_type }})</option>
                    {% endfor %}
                </select>
            </div>

            <div class="mb-3">
                <label class="form-label">Upload a backbone file (FILEBONE.NA, .lst, .txt)</label>
                <input type="file" name="backbone_file" class="form-control"
                       accept=".na,.txt,.lst,.echo">
            </div>

            <div class="mb-3">
                <label class="form-label">Or paste the list (TAG  [- ] Display Name)</label>
                <textarea name="echolist" rows="18" class="form-control"
                          style="font-family:'Courier New',monospace; font-size:0.85rem;"
                          placeholder="TQW_FILES       - TQW File Echo&#10;FILES_GAMES     Game files"></textarea>
            </div>

            <div class="form-check mb-3">
                <input type="checkbox" name="is_subscribed" value="1"
                       class="form-check-input" id="is_subscribed">
                <label class="form-check-label small" for="is_subscribed">
                    Mark imported areas as subscribed (uncheck for backbone
                    catalog imports — you can subscribe individually later)
                </label>
            </div>

            <div class="d-flex justify-content-between">
                <a href="{{ url_for('admin.file_areas_admin') }}" class="btn btn-primary">
                    <i class="bi bi-x-circle"></i> Cancel
                </a>
                <button type="submit" class="btn btn-primary">
                    <i class="bi bi-upload"></i> Import Areas
                </button>
            </div>
        </form>
    </div>
</div>
{% endblock %}
