{% extends 'base/base.html' %}
{% load static %}

{% block title %}{{ designer.name }} - ThrillWiki{% endblock %}

{% block content %}
<div class="container px-4 mx-auto">
    <!-- Header -->
    <div class="grid grid-cols-1 gap-6 mb-8 lg:grid-cols-3">
        <!-- Designer Info -->
        <div class="lg:col-span-2">
            <div class="p-6 bg-white rounded-lg shadow dark:bg-gray-800">
                <h1 class="mb-2 text-3xl font-bold text-gray-900 dark:text-white">{{ designer.name }}</h1>
                {% if designer.description %}
                    <div class="mt-4 prose dark:prose-invert max-w-none">
                        {{ designer.description|linebreaks }}
                    </div>
                {% endif %}
            </div>
        </div>

        <!-- Stats Card -->
        <div class="lg:col-span-1">
            <div class="p-6 bg-white rounded-lg shadow dark:bg-gray-800">
                <h2 class="mb-4 text-xl font-semibold text-gray-900 dark:text-white">Quick Stats</h2>
                <dl class="grid grid-cols-2 gap-4">
                    <div>
                        <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Total Rides</dt>
                        <dd class="mt-1 text-3xl font-semibold text-blue-600 dark:text-blue-400">{{ stats.total_rides }}</dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Roller Coasters</dt>
                        <dd class="mt-1 text-3xl font-semibold text-blue-600 dark:text-blue-400">{{ stats.total_coasters }}</dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Parks</dt>
                        <dd class="mt-1 text-3xl font-semibold text-blue-600 dark:text-blue-400">{{ stats.total_parks }}</dd>
                    </div>
                    <div>
                        <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Countries</dt>
                        <dd class="mt-1 text-3xl font-semibold text-blue-600 dark:text-blue-400">{{ stats.total_countries }}</dd>
                    </div>
                </dl>
                {% if designer.website %}
                    <div class="mt-6">
                        <a href="{{ designer.website }}" target="_blank" rel="noopener noreferrer" 
                           class="inline-flex items-center text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300">
                            <i class="mr-2 fas fa-external-link-alt"></i>
                            Visit Website
                        </a>
                    </div>
                {% endif %}
            </div>
        </div>
    </div>

    <!-- Rides List -->
    <div class="p-6 bg-white rounded-lg shadow dark:bg-gray-800">
        <h2 class="mb-6 text-2xl font-semibold text-gray-900 dark:text-white">Designed Rides</h2>
        
        {% if rides %}
            <div class="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
                {% for ride in rides %}
                    <div class="p-4 transition-shadow rounded-lg bg-gray-50 hover:shadow-md dark:bg-gray-700/50">
                        <div class="flex items-start justify-between">
                            <div>
                                <h3 class="text-lg font-semibold text-gray-900 dark:text-white">
                                    <a href="{% url 'parks:rides:ride_detail' park_slug=ride.park.slug ride_slug=ride.slug %}"
                                       class="hover:text-blue-600 dark:hover:text-blue-400">
                                        {{ ride.name }}
                                    </a>
                                </h3>
                                <p class="text-sm text-gray-600 dark:text-gray-400">
                                    at <a href="{% url 'parks:park_detail' ride.park.slug %}"
                                         class="text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300">
                                        {{ ride.park.name }}
                                    </a>
                                </p>
                            </div>
                            <span class="px-2 py-1 text-xs font-medium text-blue-800 bg-blue-100 rounded-full dark:bg-blue-700 dark:text-blue-50">
                                {{ ride.get_category_display }}
                            </span>
                        </div>
                        
                        <div class="grid grid-cols-2 gap-4 mt-4">
                            {% if ride.opening_date %}
                                <div>
                                    <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Opened</dt>
                                    <dd class="text-gray-900 dark:text-white">{{ ride.opening_date }}</dd>
                                </div>
                            {% endif %}
                            {% if ride.manufacturer %}
                                <div>
                                    <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Manufacturer</dt>
                                    <dd class="text-gray-900 dark:text-white">{{ ride.manufacturer.name }}</dd>
                                </div>
                            {% endif %}
                            {% if ride.category == 'RC' and ride.coaster_stats %}
                                {% if ride.coaster_stats.height_ft %}
                                    <div>
                                        <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Height</dt>
                                        <dd class="text-gray-900 dark:text-white">{{ ride.coaster_stats.height_ft }} ft</dd>
                                    </div>
                                {% endif %}
                                {% if ride.coaster_stats.speed_mph %}
                                    <div>
                                        <dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Speed</dt>
                                        <dd class="text-gray-900 dark:text-white">{{ ride.coaster_stats.speed_mph }} mph</dd>
                                    </div>
                                {% endif %}
                            {% endif %}
                        </div>
                    </div>
                {% endfor %}
            </div>
        {% else %}
            <p class="text-gray-500 dark:text-gray-400">No rides found.</p>
        {% endif %}
    </div>
</div>
{% endblock %}
