{% extends "base.html" %}
{% block title %}Export — Battery Tracker{% endblock %}

{% block content %}
<h1 style="margin-bottom:1.25rem;">Export Data</h1>

<div class="card" style="margin-bottom:1rem;">
  <h2 style="margin-bottom:0.5rem;">Full Export</h2>
  <p style="color:var(--text-muted,#6b7280);margin-bottom:1rem;">
    Download your complete dataset — batteries, devices, charge logs, capacity tests, and percentage history.
  </p>
  <div style="display:flex;gap:0.75rem;flex-wrap:wrap;">
    <a href="{{ url_for('export_csv_zip') }}" class="btn btn-primary">Download All CSVs (.zip)</a>
    <a href="{{ url_for('export_json') }}" class="btn btn-secondary">Download JSON</a>
  </div>
</div>

<div class="card">
  <h2 style="margin-bottom:0.5rem;">Individual CSV Files</h2>
  <p style="color:var(--text-muted,#6b7280);margin-bottom:1rem;">Download a single table at a time.</p>
  <table style="border-collapse:collapse;width:100%;">
    <tbody>
      <tr>
        <td style="padding:0.4rem 0.75rem 0.4rem 0;">
          <a href="{{ url_for('export_batteries_csv') }}" class="btn btn-sm btn-secondary">batteries.csv</a>
        </td>
        <td style="padding:0.4rem 0;color:var(--text-muted,#6b7280);font-size:0.9rem;">
          All batteries with device name
        </td>
      </tr>
      <tr>
        <td style="padding:0.4rem 0.75rem 0.4rem 0;">
          <a href="{{ url_for('export_devices_csv') }}" class="btn btn-sm btn-secondary">devices.csv</a>
        </td>
        <td style="padding:0.4rem 0;color:var(--text-muted,#6b7280);font-size:0.9rem;">
          All devices with installed battery count
        </td>
      </tr>
      <tr>
        <td style="padding:0.4rem 0.75rem 0.4rem 0;">
          <a href="{{ url_for('export_charge_logs_csv') }}" class="btn btn-sm btn-secondary">charge-logs.csv</a>
        </td>
        <td style="padding:0.4rem 0;color:var(--text-muted,#6b7280);font-size:0.9rem;">
          All charge log entries with battery label
        </td>
      </tr>
      <tr>
        <td style="padding:0.4rem 0.75rem 0.4rem 0;">
          <a href="{{ url_for('export_capacity_tests_csv') }}" class="btn btn-sm btn-secondary">capacity-tests.csv</a>
        </td>
        <td style="padding:0.4rem 0;color:var(--text-muted,#6b7280);font-size:0.9rem;">
          All capacity test results with battery label
        </td>
      </tr>
      <tr>
        <td style="padding:0.4rem 0.75rem 0.4rem 0;">
          <a href="{{ url_for('export_pct_logs_csv') }}" class="btn btn-sm btn-secondary">pct-logs.csv</a>
        </td>
        <td style="padding:0.4rem 0;color:var(--text-muted,#6b7280);font-size:0.9rem;">
          Battery percentage history
        </td>
      </tr>
    </tbody>
  </table>
</div>

<div style="margin-top:0.75rem;">
  <a href="{{ url_for('import_page') }}" class="btn btn-secondary">Import JSON</a>
</div>
{% endblock %}
