{% extends "base.html" %}
{% block title %}{{ peer.name }} — BBS Directory{% endblock %}

{% block content %}
<div class="container my-4" style="max-width:640px;">
  <a href="{{ url_for('peers.index', tab='local') }}" class="btn btn-link ps-0 mb-2">
    <i class="bi bi-arrow-left"></i> Back to Directory
  </a>

  <div class="card shadow-sm">
    <div class="card-body">
      <h4 class="card-title mb-1">{{ peer.name }}</h4>
      {% if peer.location %}
      <p class="text-muted small mb-2"><i class="bi bi-geo-alt"></i> {{ peer.location }}</p>
      {% endif %}
      {% if peer.description %}
      <p class="mb-3">{{ peer.description }}</p>
      {% endif %}

      <dl class="row mb-3">
        <dt class="col-sm-4">Telnet</dt>
        <dd class="col-sm-8">
          <code>{{ peer.hostname }}{% if peer.telnet_port and peer.telnet_port != 23 %}:{{ peer.telnet_port }}{% endif %}</code>
        </dd>
        {% if peer.web_url %}
        <dt class="col-sm-4">Web</dt>
        <dd class="col-sm-8"><a href="{{ peer.web_url }}" target="_blank" rel="noopener">{{ peer.web_url }}</a></dd>
        {% endif %}
        {% if peer.software %}
        <dt class="col-sm-4">Software</dt>
        <dd class="col-sm-8">{{ peer.software }}</dd>
        {% endif %}
        {% if peer.ftn_address %}
        <dt class="col-sm-4">FTN Address</dt>
        <dd class="col-sm-8"><code>{{ peer.ftn_address }}</code></dd>
        {% endif %}
      </dl>

      <div class="d-flex gap-2 flex-wrap">
        <a href="telnet://{{ peer.hostname }}{% if peer.telnet_port and peer.telnet_port != 23 %}:{{ peer.telnet_port }}{% endif %}"
           class="btn btn-primary">
          <i class="bi bi-terminal-fill"></i> Connect via Telnet
        </a>
        {% if peer.web_url %}
        <a href="{{ peer.web_url }}" target="_blank" rel="noopener" class="btn btn-outline-info">
          <i class="bi bi-box-arrow-up-right"></i> Visit Web
        </a>
        {% endif %}
        {% if peer.ftn_address %}
        <a href="{{ url_for('telegram.send') }}?to_address={{ peer.ftn_address|urlencode }}"
           class="btn btn-outline-warning">
          <i class="bi bi-lightning"></i> Send Telegram
        </a>
        {% endif %}
      </div>
    </div>
  </div>
</div>
{% endblock %}
