<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}Inspection Reporting{% endblock %}</title>
    <!-- Tailwind CSS via CDN -->
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/daisyui/4.4.7/daisyui.css" rel="stylesheet" type="text/css" />
</head>
<body class="bg-gray-50">
    <header class="bg-white shadow-md">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between h-16">
                <div class="flex">
                    <div class="flex-shrink-0 flex items-center">
                        <span class="text-xl font-semibold text-gray-800">Inspection Reporting</span>
                    </div>
                </div>
                <div class="hidden md:block">
                    <div class="ml-10 flex items-baseline space-x-4">
                        {% if current_user.is_authenticated %}
                        <a href="{{ url_for('inspections.dashboard') }}" class="px-3 py-2 rounded-md text-sm font-medium {% if request.endpoint.startswith('inspections') %}bg-primary bg-opacity-10 text-primary{% else %}text-gray-500 hover:bg-gray-50 hover:text-gray-700{% endif %}">Dashboard</a>
                        <a href="{{ url_for('admin.users') }}" class="px-3 py-2 rounded-md text-sm font-medium {% if request.endpoint.startswith('admin') %}bg-primary bg-opacity-10 text-primary{% else %}text-gray-500 hover:bg-gray-50 hover:text-gray-700{% endif %}">Admin</a>
                        <a href="{{ url_for('auth.logout') }}" class="px-3 py-2 rounded-md text-sm font-medium text-gray-500 hover:bg-gray-50 hover:text-gray-700">Logout</a>
                        {% endif %}
                    </div>
                </div>
                <div class="flex items-center">
                    {% if current_user.is_authenticated %}
                    <span class="text-sm text-gray-600 mr-4">Logged in as {{ current_user.full_name }}</span>
                    {% endif %}
                </div>
            </div>
        </div>
    </header>

    <main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
        {% with messages = get_flashed_messages(with_categories=true) %}
          {% if messages %}
            {% for category, message in messages %}
              <div class="mb-4 p-4 rounded-lg {% if category == 'error' %}bg-red-50 border-red-200 text-red-700{% elif category == 'success' %}bg-green-50 border-green-200 text-green-700{% elif category == 'warning' %}bg-yellow-50 border-yellow-200 text-yellow-700{% else %}bg-blue-50 border-blue-200 text-blue-700{% endif %}">
                {{ message }}
              </div>
            {% endfor %}
          {% endif %}
        {% endwith %}

        {% block content %}{% endblock %}
    </main>

    <footer class="bg-white border-t border-gray-200">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
            <p class="text-center text-sm text-gray-500">&copy; {{ now().year }} Inspection Reporting System. All rights reserved.</p>
        </div>
    </footer>
</body>
</html>