{#
/**
 * @file
 * Template for Content X dense table view.
 *
 * Available variables:
 * - nodes: Array of node data.
 */
#}

{% if nodes %}
  <table class="content-x-dense-table">
    <thead>
      <tr>
        <th class="content-x-dense-th content-x-dense-th--actions"></th>
        <th class="content-x-dense-th content-x-dense-th--title">{{ 'Title'|t }}</th>
        <th class="content-x-dense-th content-x-dense-th--type">{{ 'Type'|t }}</th>
        {% if show_spaces_column %}
          <th class="content-x-dense-th content-x-dense-th--spaces">{{ 'Spaces'|t }}</th>
        {% endif %}
        <th class="content-x-dense-th content-x-dense-th--status">{{ 'Status'|t }}</th>
        <th class="content-x-dense-th content-x-dense-th--lang">{{ 'Lang'|t }}</th>
        <th class="content-x-dense-th content-x-dense-th--author">{{ 'Author'|t }}</th>
        <th class="content-x-dense-th content-x-dense-th--date">{{ 'Updated'|t }}</th>
      </tr>
    </thead>
    <tbody>
      {% for node in nodes %}
        <tr class="content-x-dense-row{% if not node.status %} content-x-dense-row--unpublished{% endif %}">
          <td class="content-x-dense-td content-x-dense-td--actions">
            {% if node.preview_url %}
              <a href="{{ node.preview_url }}" class="content-x-dense-action" title="{{ 'Visual Editor'|t }}">
                <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                  <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
                  <circle cx="12" cy="12" r="3"></circle>
                </svg>
              </a>
            {% endif %}
            <a href="{{ node.edit_url }}?destination={{ destination|default('/nodehive/admin/content') }}" class="content-x-dense-action" title="{{ 'Edit'|t }}">
              <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
              </svg>
            </a>
            {% if node.frontend_url %}
              <a href="{{ node.frontend_url }}" class="content-x-dense-action" title="{{ 'Open on website'|t }}" target="_blank">
                <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                  <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
                  <polyline points="15 3 21 3 21 9"></polyline>
                  <line x1="10" y1="14" x2="21" y2="3"></line>
                </svg>
              </a>
            {% endif %}
          </td>
          <td class="content-x-dense-td content-x-dense-td--title">
            <a href="{{ path('entity.node.canonical', {'node': node.id}) }}" class="content-x-dense-link">{{ node.title }}</a>
          </td>
          <td class="content-x-dense-td content-x-dense-td--type">{{ node.type }}</td>
          {% if show_spaces_column %}
            <td class="content-x-dense-td content-x-dense-td--spaces">
              {% if node_spaces[node.id] is defined %}
                {% for space in node_spaces[node.id] %}
                  <a href="{{ space.url }}" class="content-x-dense-space-link">{{ space.label }}</a>{% if not loop.last %}, {% endif %}
                {% endfor %}
              {% endif %}
            </td>
          {% endif %}
          <td class="content-x-dense-td content-x-dense-td--status">
            {% if node.status %}
              <span class="content-x-dense-status content-x-dense-status--published" title="{{ 'Published'|t }}"></span>
            {% else %}
              <span class="content-x-dense-status content-x-dense-status--draft" title="{{ 'Draft'|t }}"></span>
            {% endif %}
          </td>
          <td class="content-x-dense-td content-x-dense-td--lang">
            {% for translation in node.translations %}
              {% if translation.exists %}
                <a href="{{ translation.edit_url }}?destination={{ destination|default('/nodehive/admin/content') }}"
                   class="content-x-dense-lang{% if not translation.status %} content-x-dense-lang--draft{% endif %}"
                   title="{{ translation.language }}">{{ translation.langcode|upper }}</a>
              {% else %}
                <a href="{{ translation.add_url }}?destination={{ destination|default('/nodehive/admin/content') }}"
                   class="content-x-dense-lang content-x-dense-lang--missing"
                   title="{{ 'Add @language'|t({'@language': translation.language}) }}">{{ translation.langcode|upper }}</a>
              {% endif %}
            {% endfor %}
          </td>
          <td class="content-x-dense-td content-x-dense-td--author">{{ node.author }}</td>
          <td class="content-x-dense-td content-x-dense-td--date" title="{{ node.changed|format_date('medium') }}">{{ node.changed_ago }} {{ 'ago'|t }}</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% else %}
  <div class="content-x-empty-state">
    <div class="content-x-empty-icon">
      <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
        <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path>
        <polyline points="13 2 13 9 20 9"></polyline>
      </svg>
    </div>
    <h3 class="content-x-empty-title">{{ 'No content found'|t }}</h3>
    <p class="content-x-empty-text">{{ 'Try adjusting your filters or create new content.'|t }}</p>
  </div>
{% endif %}
