<div class="row">
  <div class="col s12">
    <div class="card horizontal">
      <div class="card-image">
        <%= image_tag 'card-headers/document-mini.jpg' %>
      </div>
      <div class="card-stacked">
        <div class="card-content">
          <div class="card-title">
            <%= document.title || 'Untitled document' %><br />
            <span class="grey-text">by</span>
            <%= link_to document.user.name, document.user %>
          </div>

          <!--<p>Language: <%= analysis.language %></p>-->
          <ul class="browser-default">
            <li>This document:</li>
              <ul class="browser-default">
                <li>Originally created <%= time_ago_in_words document.created_at %> ago</li>
                <li>Last edited <%= time_ago_in_words document.updated_at %> ago</li>
              </ul>
            <li>This analysis:</li>
              <ul class="browser-default">
                <li>Took <%= distance_of_time_in_words((analysis.completed_at - analysis.created_at).round(1)) %> to complete</li>
                <li>Completed <%= time_ago_in_words analysis.completed_at %> ago</li>
              </ul>
          </ul>
        </div>
        <div class="card-action">
          <%= link_to edit_document_path(document), class: "#{Document.text_color}" do %>
            <i class="material-icons left"><%= Document.icon %></i>
            Edit document
          <% end %>
        </div>
      </div>
    </div>
  </div>
</div>

<% if analysis.created_at < document.updated_at %>
  <div class="row">
    <div class="col s12">
      <div class="card-panel red lighten-5">
        Heads up! <%= document.name %> was edited after this analysis was run; depending on how much it has changed, this analysis may now be out of date.
        You can delete this analysis by <%= link_to 'clicking here', destroy_analysis_document_path(document) %>. 
        You can then run another analysis on this document at any time.
      </div>
    </div>
  </div>
<% end %>