{% extends "base.html" %}

{% block title %}{{ concept_scheme.pref_labels|lang(language) }} - PyST{% endblock %}

{% block page_header %}
<div class="flex justify-between items-center">
    <div>
        <h1>{{ concept_scheme.pref_labels|lang(language) }}</h1>
        <p style="color: var(--text-secondary)">Concept Scheme Details</p>
    </div>
    <div class="flex space-x-3">
        <a href="/web/concept_schemes/" class="inline-flex items-center px-4 py-2 border rounded-md shadow-sm text-sm font-medium" style="color: var(--text-color); background-color: var(--header-bg); border-color: var(--border-color)">
            <i class="fas fa-arrow-left mr-2"></i>Back to Schemes
        </a>
<!--
        <a href="/web/concept_scheme/create/" class="btn-primary opacity-50 cursor-not-allowed" aria-disabled="true">
            <i class="fas fa-plus mr-2"></i>Create New Scheme
        </a>
 -->
    </div>
</div>
{% endblock %}

{% block content %}
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
    <!-- Left Column: Concept List -->
    <div class="lg:col-span-2 space-y-6">
        <!-- Concept List -->
        <div class="card overflow-hidden">
            <div class="px-4 py-5 sm:px-6 border-b" style="border-color: var(--border-color); background-color: var(--nav-bg)">
                <h2 class="text-lg font-medium" style="color: var(--text-color)">Concepts</h2>
            </div>
            <div class="overflow-x-auto">
                <table class="min-w-full divide-y" style="border-color: var(--border-color)">
                    <thead style="background-color: var(--nav-bg)">
                        <tr>
                            <th scope="col" class="w-1/3 px-6 py-4 text-left text-xs font-medium uppercase tracking-wider" style="color: var(--text-secondary)">Label</th>
                            <th scope="col" class="w-2/3 px-6 py-4 text-left text-xs font-medium uppercase tracking-wider" style="color: var(--text-secondary)">Definition</th>
                            <th scope="col" class="w-24 px-6 py-4 text-right text-xs font-medium uppercase tracking-wider" style="color: var(--text-secondary)">Actions</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y" style="background-color: var(--header-bg); border-color: var(--border-color)">
                        {% for concept in concepts %}
                        <tr class="transition-colors hover-row">
                            <td class="px-6 py-4">
                                <a href="{{ concept.url }}">
                                    <div class="text-sm font-medium text-primary">
                                        {% if concept.pref_labels|lang(language) %}
                                            {{ concept.pref_labels|lang(language) }}
                                        {% else %}
                                            <span class="italic" style="color: var(--text-tertiary)">No concept label available</span>
                                        {% endif %}
                                    </div>
                                    {% if concept.notations %}
                                    <div class="text-xs mt-1" style="color: var(--text-secondary)">
                                        <i class="fas fa-hashtag mr-1"></i>{{ concept.notations[0]['@value'] }}
                                    </div>
                                    {% endif %}
                                </a>
                            </td>
                            <td class="px-6 py-4">
                                <a href="{{ concept.url }}">
                                    <div class="text-sm line-clamp-2" style="color: var(--text-secondary)">
                                        {% if concept.definitions|lang(language) %}
                                            {{ concept.definitions|lang(language)}}
                                        {% else %}
                                            <span class="italic" style="color: var(--text-tertiary)">No definition available</span>
                                        {% endif %}
                                    </div>
                                </a>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
                                <a href="{{ concept.url }}"
                                   class="text-primary hover:text-primary-hover inline-flex items-center">
                                    <i class="fas fa-eye mr-1"></i>View
                                </a>
                            </td>
                        </tr>
                        {% else %}
                        <tr>
                            <td colspan="3" class="px-6 py-4 text-sm text-center" style="color: var(--text-secondary)">
                                <div class="flex flex-col items-center py-8">
                                    <i class="fas fa-folder-open text-3xl mb-2" style="color: var(--text-tertiary)"></i>
                                    <p>No concepts found.</p>
                                </div>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- Right Column: Scheme Details -->
    <div class="lg:col-span-1">
        <div class="card">
            <div class="px-4 py-5 sm:px-6 border-b" style="border-color: var(--border-color); background-color: var(--nav-bg)">
                <h2 class="text-lg font-medium" style="color: var(--text-color)">Scheme Information</h2>
            </div>
            <div class="px-4 py-5 sm:p-6 space-y-4" style="background-color: var(--nav-bg)">
                <!-- IRI -->
                <div>
                    <h3 class="text-sm font-medium" style="color: var(--text-secondary)">IRI</h3>
                    <p class="mt-1 text-sm" style="color: var(--text-color)" title="{{ concept_scheme.id_ }}" id="cs_iri_clicker">{{ concept_scheme.id_|short_iri }} <i class="fas fa-copy mr-2" id="cs_iri_clicker_icon"></i></p>
                </div>

                <!-- Description -->
                <div>
                    <h3 class="text-sm font-medium" style="color: var(--text-secondary)">Description</h3>
                        <div class="mt-1 text-sm" style="color: var(--text-color)">
                            {% if concept_scheme.definitions|lang(language) %}
                                {{ concept_scheme.definitions|lang(language)}}
                            {% else %}
                                <span class="italic" style="color: var(--text-tertiary)">No description available</span>
                            {% endif %}
                        </div>
                </div>

                <!-- Creator -->
                {% if concept_scheme.creators %}
                <div>
                    <h3 class="text-sm font-medium" style="color: var(--text-color)">Creator</h3>
                    <div class="mt-1 text-sm" style="color: var(--text-color)">
                        {% for creator in concept_scheme.creators %}
                        <div><a href="{{ creator['@id'] }}">{{ creator['@id'] }}</a></div>
                        {% endfor %}
                    </div>
                </div>
                {% endif %}

                <!-- Version -->
                {% if concept_scheme.version %}
                <div>
                    <h3 class="text-sm font-medium" style="color: var(--text-secondary)">Version</h3>
                    <p class="mt-1 text-sm" style="color: var(--text-color)">{{ concept_scheme.version[0]['@value'] }}</p>
                </div>
                {% endif %}

                <!-- Created Date -->
                {% if concept_scheme.created %}
                <div>
                    <h3 class="text-sm font-medium" style="color: var(--text-secondary)">Created</h3>
                    <p class="mt-1 text-sm" style="color: var(--text-secondary)">{{ concept_scheme.created[0]['@value'] }}</p>
                </div>
                {% endif %}

                <!-- Last Modified Date -->
                {% if concept_scheme.extra['http://purl.org/dc/terms/modified'] %}
                <div>
                    <h3 class="text-sm font-medium" style="color: var(--text-secondary)">Last Modified</h3>
                    <p class="mt-1 text-sm" style="color: var(--text-secondary)">{{ concept_scheme.extra['http://purl.org/dc/terms/modified'][0]['@value'] }}</p>
                </div>
                {% endif %}

                <!-- Notation -->
                {% if concept_scheme.notations %}
                <div>
                    <h3 class="text-sm font-medium" style="color: var(--text-secondary)">Notation</h3>
                    <p class="mt-1 text-sm" style="color: var(--text-secondary)">{{ concept_scheme.notations[0]['@value'] }}</p>
                </div>
                {% endif %}
            </div>
        </div>
    </div>
</div>

<script>
document.getElementById('language').addEventListener('change', function(e) {
    window.location.href = e.target.value;
});

var iri_clicker = document.getElementById("cs_iri_clicker");
iri_clicker.onclick = function(){
    navigator.clipboard.writeText("{{ concept_scheme.id_ }}").then(this.querySelector('#cs_iri_clicker_icon').classList.replace("fa-copy", "fa-check"))
};
</script>
{% endblock %}
