// About page — version, license, project links, and the registered
// company line. Standard libadwaita About-style content but inline
// in the main window's tab stack rather than a modal AdwAboutWindow,
// so users get one consistent navigation pattern across all four
// pages.

using Gtk 4.0;
using Adw 1;

template $ZbplAboutPage: Adw.Bin {
  child: Adw.PreferencesPage {
    Adw.PreferencesGroup {
      Adw.ActionRow {
        title: _("Print Platform Pro Browser Print");
        subtitle: _("Linux agent that lets web apps print to USB and network Zebra printers — wire-compatible with the official Browser Print on Mac and Windows.");
      }
    }

    Adw.PreferencesGroup license_group {
      title: _("Licensing");
      description: _("This installation runs on a per-machine subscription. Without an active subscription or trial, printing is disabled but the rest of the agent (calibration, diagnostics, allowlist) keeps working.");

      Adw.ActionRow license_status_row {
        title: _("Status");
        subtitle: _("Checking…");

        [suffix]
        Gtk.Label license_status_pill {
          label: "—";
          valign: center;
          styles ["caption", "pill", "dim-label"]
        }
      }

      Adw.ActionRow license_key_row {
        title: _("License key");
        subtitle: _("Not yet issued");
        styles ["property"]

        [suffix]
        Gtk.Button copy_key_button {
          icon-name: "edit-copy-symbolic";
          tooltip-text: _("Copy license key to clipboard");
          valign: center;
          styles ["flat"]
        }
      }

      Adw.ActionRow license_period_row {
        title: _("Renews / expires");
        subtitle: _("—");
        styles ["property"]
      }

      Adw.ActionRow {
        title: _("Actions");
        subtitle: _("Apply a license key emailed to you, refresh status from the server, or open the purchase page.");

        [suffix]
        Gtk.Box {
          spacing: 6;
          valign: center;

          Gtk.Button refresh_license_button {
            label: _("Refresh");
            valign: center;
          }

          Gtk.Button enter_license_button {
            label: _("Enter key…");
            valign: center;
          }

          Gtk.Button subscribe_button {
            label: _("Subscribe — $10/month");
            valign: center;
            styles ["suggested-action"]
          }
        }
      }
    }

    Adw.PreferencesGroup {
      title: _("Version");

      Adw.ActionRow agent_version_row {
        title: _("Agent");
        subtitle: "—";
        styles ["property"]
      }

      Adw.ActionRow ui_version_row {
        title: _("UI");
        subtitle: "—";
        styles ["property"]
      }
    }

    Adw.PreferencesGroup {
      title: _("Project");

      Adw.ActionRow downloads_row {
        title: _("Downloads");
        subtitle: "downloads.printplatformpro.com";
        activatable: true;

        [suffix]
        Gtk.Image {
          icon-name: "adw-external-link-symbolic";
        }
      }

      Adw.ActionRow protocol_row {
        title: _("Protocol reference");
        subtitle: "printplatformpro.com/docs/browser-print-agent";
        activatable: true;

        [suffix]
        Gtk.Image {
          icon-name: "adw-external-link-symbolic";
        }
      }

      Adw.ActionRow {
        title: _("Licence");
        subtitle: "MIT";
        styles ["property"]
      }
    }

    Adw.PreferencesGroup {
      title: _("Diagnostics");
      description: _("Every ZPL packet sent through the agent (HTTP + D-Bus) is recorded as one JSON line in a rolling log file. Useful for auditing what a web app actually sent the printer.");

      Adw.ActionRow {
        title: _("Download ZPL history");
        subtitle: _("Save the JSONL log to a chosen file. The agent keeps the latest ~10 MB plus one rotated archive.");
        activatable-widget: download_logs_button;

        [suffix]
        Gtk.Button download_logs_button {
          label: _("Download…");
          valign: center;
          styles ["suggested-action"]
        }
      }
    }

    Adw.PreferencesGroup {
      title: _("Published by");

      Adw.ActionRow {
        title: _("Unified Retail Services Ltd");
        // Pango markup parses `&` — escape so the ampersand renders.
        subtitle: "Registered in England &amp; Wales — Company number 15752391";
        styles ["property"]
      }
    }
  };
}
