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

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

{% block content %}
<div class="container px-4 mx-auto sm:px-6 lg:px-8">
    <!-- Manufacturer Header -->
    <div class="mb-8">
        <h1 class="text-4xl font-bold text-gray-900 dark:text-white mb-4">{{ manufacturer.name }}</h1>
        
        {% if manufacturer.description %}
        <div class="prose dark:prose-invert max-w-none mb-6">
            <p class="text-lg text-gray-600 dark:text-gray-400">{{ manufacturer.description }}</p>
        </div>
        {% endif %}
        
        <!-- Manufacturer Details -->
        <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
            {% if manufacturer.founded_year %}
            <div class="bg-white dark:bg-gray-800 rounded-lg p-4 shadow-xs">
                <h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">Founded</h3>
                <p class="text-lg font-semibold text-gray-900 dark:text-white">{{ manufacturer.founded_year }}</p>
            </div>
            {% endif %}
            
            {% if manufacturer.headquarters %}
            <div class="bg-white dark:bg-gray-800 rounded-lg p-4 shadow-xs">
                <h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">Headquarters</h3>
                <p class="text-lg font-semibold text-gray-900 dark:text-white">{{ manufacturer.headquarters }}</p>
            </div>
            {% endif %}
            
            <div class="bg-white dark:bg-gray-800 rounded-lg p-4 shadow-xs">
                <h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">Rides Manufactured</h3>
                <p class="text-lg font-semibold text-gray-900 dark:text-white">{{ rides.count }}</p>
            </div>
        </div>
    </div>

    <!-- Rides Section -->
    {% if rides %}
    <div class="mb-8">
        <h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">Rides Manufactured</h2>
        <div class="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
            {% for ride in rides %}
            <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md overflow-hidden">
                {% if ride.main_image %}
                <img src="{{ ride.main_image.url }}" alt="{{ ride.name }}" class="w-full h-48 object-cover">
                {% endif %}
                
                <div class="p-6">
                    <h3 class="text-xl font-semibold text-gray-900 dark:text-white mb-2">
                        <a href="{% url 'rides:ride_detail' ride.slug %}" class="hover:text-blue-600 dark:hover:text-blue-400">
                            {{ ride.name }}
                        </a>
                    </h3>
                    
                    {% if ride.park %}
                    <p class="text-gray-600 dark:text-gray-400 mb-2">
                        <a href="{% url 'parks:park_detail' ride.park.slug %}" class="hover:text-blue-600 dark:hover:text-blue-400">
                            {{ ride.park.name }}
                        </a>
                    </p>
                    {% endif %}
                    
                    <div class="text-sm text-gray-500 dark:text-gray-500">
                        {% if ride.ride_type %}
                        <p class="mb-1">{{ ride.ride_type }}</p>
                        {% endif %}
                        
                        {% if ride.opened_date %}
                        <p>Opened {{ ride.opened_date|date:"Y" }}</p>
                        {% endif %}
                    </div>
                </div>
            </div>
            {% endfor %}
        </div>
    </div>
    {% else %}
    <div class="mb-8">
        <h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">Rides Manufactured</h2>
        <div class="bg-gray-50 dark:bg-gray-800 rounded-lg p-8 text-center">
            <p class="text-gray-500 dark:text-gray-400">No rides currently manufactured by this company.</p>
        </div>
    </div>
    {% endif %}

    <!-- Additional Information -->
    {% if manufacturer.website %}
    <div class="mb-8">
        <h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-4">Links</h2>
        <div class="bg-white dark:bg-gray-800 rounded-lg p-6 shadow-xs">
            <a href="{{ manufacturer.website }}" target="_blank" rel="noopener noreferrer" 
               class="inline-flex items-center text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300">
                Official Website
                <svg class="w-4 h-4 ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
                </svg>
            </a>
        </div>
    </div>
    {% endif %}
</div>
{% endblock %}