<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>NDUTH WiFi — Dashboard</title>
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      min-height: 100vh;
      background: linear-gradient(135deg, #0a2540 0%, #1a4a7a 50%, #0d3b6e 100%);
      font-family: 'Segoe UI', Arial, sans-serif;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    .card {
      background: white;
      border-radius: 20px;
      width: 100%;
      max-width: 440px;
      overflow: hidden;
      box-shadow: 0 24px 60px rgba(0,0,0,0.3);
    }

    .header {
      background: linear-gradient(135deg, #0a2540, #1a4a7a);
      padding: 24px 32px;
      text-align: center;
    }

    .header h1 { color: white; font-size: 17px; font-weight: 700; }
    .header p  { color: rgba(255,255,255,0.7); font-size: 12px; margin-top: 5px; }

    .status-bar {
      padding: 14px 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      font-weight: 700;
      font-size: 14px;
    }
    .status-bar.active  { background: #dcfce7; color: #15803d; }
    .status-bar.expired { background: #fee2e2; color: #b91c1c; }

    .body { padding: 24px 32px; }

    .greeting {
      font-size: 16px;
      color: #111827;
      font-weight: 600;
      margin-bottom: 4px;
    }
    .greeting-sub {
      font-size: 13px;
      color: #6b7280;
      margin-bottom: 22px;
    }

    /* Stats row */
    .stats-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
      margin-bottom: 22px;
    }

    .stat-box {
      background: #f8fafc;
      border: 1px solid #e2e8f0;
      border-radius: 12px;
      padding: 14px 16px;
      text-align: center;
    }

    .stat-box .stat-icon { font-size: 22px; margin-bottom: 6px; }
    .stat-box .stat-val  { font-size: 16px; font-weight: 800; color: #111; }
    .stat-box .stat-lbl  { font-size: 11px; color: #9ca3af; margin-top: 2px; }

    /* Info table */
    .info-row {
      display: flex;
      justify-content: space-between;
      padding: 11px 0;
      border-bottom: 1px solid #f3f4f6;
      font-size: 13px;
    }
    .info-row:last-child { border-bottom: none; }
    .info-row .lbl { color: #6b7280; }
    .info-row .val { color: #111; font-weight: 600; }

    .btn {
      display: block; width: 100%;
      padding: 13px;
      background: linear-gradient(135deg, #0a2540, #1a4a7a);
      color: white; border: none; border-radius: 12px;
      font-size: 14px; font-weight: 700; cursor: pointer;
      text-align: center; text-decoration: none;
      margin-top: 20px; transition: opacity 0.2s;
    }
    .btn:hover { opacity: 0.9; }

    .btn-outline {
      display: block; width: 100%;
      padding: 11px;
      background: transparent;
      color: #1a4a7a;
      border: 1.5px solid #1a4a7a;
      border-radius: 12px;
      font-size: 14px; font-weight: 600;
      text-align: center; text-decoration: none;
      margin-top: 10px; transition: all 0.2s;
    }
    .btn-outline:hover { background: #eff6ff; }

    .footer {
      background: #0a2540; padding: 12px 32px; text-align: center;
    }
    .footer p { color: rgba(255,255,255,0.5); font-size: 11px; }
  </style>
</head>
<body>
  <div class="card">
    <div class="header">
      <h1>🏥 NDUTH WiFi Portal</h1>
      <p>Niger Delta University Teaching Hospital</p>
    </div>

    {% if subscriber.payment_status == 'active' %}
      <div class="status-bar active">✅ &nbsp;Subscription Active — Connected</div>
    {% else %}
      <div class="status-bar expired">❌ &nbsp;Subscription Expired</div>
    {% endif %}

<div class="body">
    {% if subscriber.payment_status == 'active' %}
      <form method="POST" action="https://hotspot.collnetwork.net/login?fullname={{ subscriber.first_name|urlencode }}+{{ subscriber.surname|urlencode }}">
    <input type="hidden" name="username" value="{{ subscriber.email }}">
    <input type="hidden" name="password" value="{{ sub_plain_password }}">
    <button type="submit" class="btn">🚀 Resume Internet Access</button>
</form>
    {% else %}
        <a href="/nduth/register" class="btn" style="background: #dc2626;">
            🔄 &nbsp;Renew Now to Connect
        </a>
    {% endif %}
</div>

    <div class="body">
      <div class="greeting">Hello, {{ subscriber.first_name }} 👋</div>
      <div class="greeting-sub">Here's your subscription summary.</div>

      <div class="stats-row">
        <div class="stat-box">
          <div class="stat-icon">📅</div>
          <div class="stat-val">
            {% if subscriber.expiry_date %}
              {{ subscriber.expiry_date.strftime('%d %b') }}
            {% else %}
              —
            {% endif %}
          </div>
          <div class="stat-lbl">Expires</div>
        </div>
        <div class="stat-box">
          <div class="stat-icon">💰</div>
          <div class="stat-val">
            ₦{{ "{:,.0f}".format(site.amount_kobo / 100) }}
          </div>
          <div class="stat-lbl">Renewal Cost</div>
        </div>
      </div>

      <div class="info-row">
        <span class="lbl">Full Name</span>
        <span class="val">{{ subscriber.first_name }} {{ subscriber.surname }}</span>
      </div>
      <div class="info-row">
        <span class="lbl">Email</span>
        <span class="val">{{ subscriber.email }}</span>
      </div>
      <div class="info-row">
        <span class="lbl">Phone</span>
        <span class="val">{{ subscriber.phone or '—' }}</span>
      </div>
      {% if subscriber.last_payment %}
        <div class="info-row">
          <span class="lbl">Last Payment</span>
          <span class="val">{{ subscriber.last_payment.strftime('%d %b %Y') }}</span>
        </div>
      {% endif %}
      <div class="info-row">
        <span class="lbl">WiFi Username</span>
        <span class="val" style="font-family:monospace;font-size:12px;">
          {{ subscriber.email }}
        </span>
      </div>

      <a href="/nduth/register" class="btn">
        🔄 &nbsp;Renew Subscription
      </a>
      <a href="/nduth/forgot-password" class="btn-outline">
        🔑 &nbsp;Change Password
      </a>
    </div>

    <div class="footer">
      <p>Powered by Collnetwork Technology LTD &nbsp;·&nbsp; © 2026</p>
    </div>
  </div>
</body>
</html>
