{% extends "base.html" %}

{% block title %}Dashboard{% endblock %}

{% block content %}
<div class="max-w-4xl mx-auto">
    <h1 class="text-2xl font-bold text-white mb-6">Willkommen, {{ session.linkedin_name or session.customer_name or 'Mitarbeiter' }}!</h1>

    <div>
    <!-- Company Info Banner -->
    {% if session.company_name %}
    <div class="bg-brand-highlight/10 border border-brand-highlight/30 rounded-xl p-6 mb-8">
        <div class="flex items-center gap-4">
            <div class="w-12 h-12 bg-brand-highlight rounded-lg flex items-center justify-center">
                <svg class="w-6 h-6 text-brand-bg-dark" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/>
                </svg>
            </div>
            <div>
                <p class="text-gray-400 text-sm">Du bist Mitarbeiter von</p>
                <p class="text-xl font-bold text-brand-highlight">{{ session.company_name }}</p>
            </div>
        </div>
    </div>
    {% endif %}

    <!-- Stats Cards -->
    <div class="grid md:grid-cols-3 gap-6 mb-8">
        <!-- Posts Card -->
        <div class="card-bg border rounded-xl p-6">
            <div class="flex items-center gap-4">
                <div class="w-12 h-12 bg-brand-highlight/20 rounded-lg flex items-center justify-center">
                    <svg class="w-6 h-6 text-brand-highlight" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
                    </svg>
                </div>
                <div>
                    <p class="text-3xl font-bold text-white">{{ posts_count or 0 }}</p>
                    <p class="text-gray-400 text-sm">Erstellte Posts</p>
                </div>
            </div>
        </div>

        <!-- Pending Posts Card -->
        <div class="card-bg border rounded-xl p-6">
            <div class="flex items-center gap-4">
                <div class="w-12 h-12 bg-yellow-500/20 rounded-lg flex items-center justify-center">
                    <svg class="w-6 h-6 text-yellow-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
                    </svg>
                </div>
                <div>
                    <p class="text-3xl font-bold text-white">{{ pending_posts or 0 }}</p>
                    <p class="text-gray-400 text-sm">Ausstehend</p>
                </div>
            </div>
        </div>

        <!-- Approved Posts Card -->
        <div class="card-bg border rounded-xl p-6">
            <div class="flex items-center gap-4">
                <div class="w-12 h-12 bg-green-500/20 rounded-lg flex items-center justify-center">
                    <svg class="w-6 h-6 text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
                    </svg>
                </div>
                <div>
                    <p class="text-3xl font-bold text-white">{{ approved_posts or 0 }}</p>
                    <p class="text-gray-400 text-sm">Genehmigt</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Quick Actions -->
    <div class="card-bg border rounded-xl p-6 mb-8">
        <h2 class="text-lg font-semibold text-white mb-4">Schnellzugriff</h2>
        <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-4">
            <a href="/research" class="flex items-center gap-3 p-4 bg-brand-bg-dark rounded-lg hover:bg-brand-bg-light transition-colors">
                <div class="w-10 h-10 bg-brand-highlight/20 rounded-lg flex items-center justify-center">
                    <svg class="w-5 h-5 text-brand-highlight" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
                    </svg>
                </div>
                <div>
                    <p class="text-white font-medium">Research Topics</p>
                    <p class="text-gray-400 text-sm">Themen recherchieren</p>
                </div>
            </a>
            <a href="/create" class="flex items-center gap-3 p-4 bg-brand-bg-dark rounded-lg hover:bg-brand-bg-light transition-colors">
                <div class="w-10 h-10 bg-brand-highlight/20 rounded-lg flex items-center justify-center">
                    <svg class="w-5 h-5 text-brand-highlight" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
                    </svg>
                </div>
                <div>
                    <p class="text-white font-medium">Neuer Post</p>
                    <p class="text-gray-400 text-sm">KI-generiert</p>
                </div>
            </a>
            <a href="/employee/strategy" class="flex items-center gap-3 p-4 bg-brand-bg-dark rounded-lg hover:bg-brand-bg-light transition-colors">
                <div class="w-10 h-10 bg-brand-highlight/20 rounded-lg flex items-center justify-center">
                    <svg class="w-5 h-5 text-brand-highlight" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"/>
                    </svg>
                </div>
                <div>
                    <p class="text-white font-medium">Strategie</p>
                    <p class="text-gray-400 text-sm">Profil-Analyse</p>
                </div>
            </a>
        </div>
    </div>

    <!-- Recent Posts -->
    {% if recent_posts and recent_posts|length > 0 %}
    <div class="card-bg border rounded-xl p-6">
        <div class="flex items-center justify-between mb-4">
            <h2 class="text-lg font-semibold text-white">Letzte Posts</h2>
            <a href="/posts" class="text-brand-highlight text-sm hover:underline">Alle anzeigen</a>
        </div>
        <div class="space-y-3">
            {% for post in recent_posts[:5] %}
            <div class="flex items-start gap-3 p-3 bg-brand-bg-dark rounded-lg">
                <div class="flex-1">
                    <p class="text-white text-sm line-clamp-2">{{ post.post_content[:150] }}{% if post.post_content|length > 150 %}...{% endif %}</p>
                    <p class="text-gray-500 text-xs mt-1">{{ post.created_at.strftime('%d.%m.%Y') }}</p>
                </div>
                <span class="text-xs px-2 py-1 rounded {% if post.status == 'approved' %}bg-green-500/20 text-green-400{% elif post.status == 'rejected' %}bg-red-500/20 text-red-400{% else %}bg-yellow-500/20 text-yellow-400{% endif %}">
                    {% if post.status == 'approved' %}Genehmigt{% elif post.status == 'rejected' %}Abgelehnt{% else %}Ausstehend{% endif %}
                </span>
            </div>
            {% endfor %}
        </div>
    </div>
    {% else %}
    <div class="card-bg border rounded-xl p-6 text-center">
        <div class="w-16 h-16 bg-gray-600/30 rounded-full flex items-center justify-center mx-auto mb-4">
            <svg class="w-8 h-8 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
            </svg>
        </div>
        <p class="text-gray-400">Noch keine Posts erstellt</p>
        <a href="/create" class="inline-block mt-4 text-brand-highlight hover:underline">Ersten Post erstellen</a>
    </div>
    {% endif %}
    </div>
</div>
{% endblock %}
