<%= render HeaderComponent.new(title: "E-Mail") %>

<%= render MainSimpleComponent.new do %>
  <section>
    <p class="mb-6">
      Send and receive electronic mail.
    </p>
  </section>
  <section data-controller="modal" data-action="keydown.esc->modal#close">
    <h3>Your E-Mail Address</h3>
    <p data-controller="clipboard" class="flex gap-1 sm:w-2/5">
      <input type="text" id="user_address" class="grow"
             value=<%= current_user.address %> disabled="disabled"
             data-clipboard-target="source" />
      <button id="copy-user-address" class="btn-md btn-icon btn-outline shrink-0"
              data-clipboard-target="trigger" data-action="clipboard#copy"
              title="Copy to clipboard">
        <span class="content-initial">
          <%= render partial: "icons/copy", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
        </span>
        <span class="content-active hidden">
          <%= render partial: "icons/check", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
        </span>
      </button>
      <button class="btn-md btn-icon btn-outline shrink-0 w-auto"
              data-action="click->modal#open" title="Show QR code">
          <%= render partial: "icons/qr_code", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
      </button>
    </p>
    <%= render QrCodeModalComponent.new(qr_content: current_user.address) %>
  </section>
  <section>
    <h3>E-Mail Password</h3>
    <p>
      Your email password is different from your main account password. You can
      reset your email password in the
      <%= link_to "email settings", setting_path(:email), class: "ks-text-link" %>.
    </p>
  </section>
  <section>
    <h3>Recommended Apps</h3>
    <div data-controller="tabs"
         data-tabs-active-tab-class="-mb-px border-gray-200 border-l border-t border-r rounded-t text-indigo-600 hover:text-indigo-600"
         data-tabs-inactive-tab-class="text-gray-500 hover:text-gray-700"
         class="mb-12">
      <select data-action="tabs#change" data-tabs-target="select"
              class="block w-full mb-8 sm:hidden">
        <optgroup label="Mobile">
          <option>Android</option>
        </optgroup>
        <optgroup label="Desktop">
          <option>Linux</option>
          <option>Windows</option>
          <option>macOS</option>
        </optgroup>
      </select>
      <ul class="hidden sm:flex list-reset mb-8 border-gray-200 border-b">
        <li class="mr-2" data-tabs-target="tab" data-action="click->tabs#change:prevent">
          <a href="#" class="bg-white inline-block py-2 px-4 font-semibold no-underline">
            Android
          </a>
        </li>
        <li class="mr-2" data-tabs-target="tab" data-action="click->tabs#change:prevent">
          <a href="#" class="bg-white inline-block py-2 px-4 font-semibold no-underline">
            Linux
          </a>
        </li>
        <li class="mr-2" data-tabs-target="tab" data-action="click->tabs#change:prevent">
          <a href="#" class="bg-white inline-block py-2 px-4 font-semibold no-underline">
            Windows
          </a>
        </li>
        <li class="mr-2" data-tabs-target="tab" data-action="click->tabs#change:prevent">
          <a href="#" class="bg-white inline-block py-2 px-4 font-semibold no-underline">
            macOS
          </a>
        </li>
      </ul>

      <div id="apps-android" class="hidden grid grid-cols-1 gap-6"
           data-tabs-target="panel">
        <%= render AppInfoComponent.new(
          name: "K-9 Mail",
          description: "Soon to become Thunderbird Mobile",
          icon_path: "/img/logos/icon_k9-mail.png",
          links: [
            ["Website", "https://k9mail.app"],
            ["Google Play", "https://play.google.com/store/apps/details?id=com.fsck.k9"],
            ["F-Droid", "https://f-droid.org/en/packages/com.fsck.k9/"],
          ]
        ) %>
      </div>
      <div id="apps-linux" class="hidden grid grid-cols-1 gap-6"
           data-tabs-target="panel">
        <%= render AppInfoComponent.new(
          name: "Thunderbird",
          description: "The most popular open-source email app",
          icon_path: "/img/logos/icon_thunderbird.png",
          links: [
            ["Website", "https://www.thunderbird.net"]
          ]
        ) %>
      </div>
      <div id="apps-windows" class="hidden grid grid-cols-1 gap-6"
           data-tabs-target="panel">
        <%= render AppInfoComponent.new(
          name: "Thunderbird",
          description: "The most popular open-source email app",
          icon_path: "/img/logos/icon_thunderbird.png",
          links: [
            ["Website", "https://www.thunderbird.net"]
          ]
        ) %>
      </div>
      <div id="apps-mac" class="hidden grid grid-cols-1 gap-6"
           data-tabs-target="panel">
        <%= render AppInfoComponent.new(
          name: "Thunderbird",
          description: "The most popular open-source email app",
          icon_path: "/img/logos/icon_thunderbird.png",
          links: [
            ["Website", "https://www.thunderbird.net"]
          ]
        ) %>
      </div>
    </div>
  </section>
<% end %>
