{% load i18n %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE }}" dir="{% if LANGUAGE_CODE == 'ar' %}rtl{% else %}ltr{% endif %}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% trans "Observation Submitted" %} - Al Hammadi</title>
    
    <!-- Bootstrap CSS -->
    {% if LANGUAGE_CODE == 'ar' %}
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.rtl.min.css" rel="stylesheet">
    {% else %}
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    {% endif %}
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
    
    <!-- Arabic Font -->
    <link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap" rel="stylesheet">
    
    <style>
        {% if LANGUAGE_CODE == 'ar' %}
        body {
            font-family: 'Tajawal', sans-serif;
        }
        {% endif %}
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }
        .success-container {
            background: white;
            border-radius: 16px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            padding: 50px;
            max-width: 600px;
            text-align: center;
        }
        .success-icon {
            width: 100px;
            height: 100px;
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 30px;
            animation: pulse 2s infinite;
        }
        .success-icon i {
            font-size: 50px;
            color: white;
        }
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
        .tracking-code {
            background: #f8f9fa;
            border: 2px dashed #667eea;
            border-radius: 12px;
            padding: 20px;
            margin: 30px 0;
        }
        .tracking-code h3 {
            font-family: 'Courier New', monospace;
            font-size: 2rem;
            color: #667eea;
            margin-bottom: 5px;
            letter-spacing: 2px;
        }
        .copy-btn {
            background: #667eea;
            border: none;
            padding: 8px 20px;
            border-radius: 6px;
            color: white;
            cursor: pointer;
            transition: all 0.2s;
        }
        .copy-btn:hover {
            background: #5a6fd6;
        }
        .copy-btn.copied {
            background: #28a745;
        }
        .info-card {
            background: #e8f4fd;
            border-radius: 8px;
            padding: 15px;
            margin-top: 20px;
            text-align: {% if LANGUAGE_CODE == 'ar' %}right{% else %}left{% endif %};
        }
        .info-card i {
            color: #0056b3;
        }
        .language-switcher {
            position: absolute;
            top: 20px;
            {% if LANGUAGE_CODE == 'ar' %}
            left: 20px;
            {% else %}
            right: 20px;
            {% endif %}
        }
        .language-switcher .btn {
            background: rgba(255,255,255,0.9);
            border: none;
            padding: 8px 16px;
            border-radius: 20px;
            font-weight: 500;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            transition: all 0.2s;
        }
        .language-switcher .btn:hover {
            background: white;
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(0,0,0,0.15);
        }
        .language-switcher .dropdown-menu {
            min-width: 120px;
            border-radius: 10px;
            box-shadow: 0 5px 20px rgba(0,0,0,0.15);
        }
        .language-switcher .dropdown-item {
            padding: 10px 20px;
        }
        .language-switcher .dropdown-item:hover {
            background: #f0f3ff;
        }
        .language-switcher .dropdown-item.active {
            background: #667eea;
            color: white;
        }
    </style>
</head>
<body>
    <!-- Language Switcher -->
    <div class="language-switcher">
        <div class="dropdown">
            <button class="btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                <i class="bi bi-globe me-1"></i>
                {% if LANGUAGE_CODE == 'ar' %}العربية{% else %}English{% endif %}
            </button>
            <ul class="dropdown-menu dropdown-menu-end">
                <li>
                    <form action="{% url 'set_language' %}" method="post">
                        {% csrf_token %}
                        <input type="hidden" name="language" value="en">
                        <input type="hidden" name="next" value="{{ request.path }}">
                        <button type="submit" class="dropdown-item {% if LANGUAGE_CODE == 'en' %}active{% endif %}">
                            <span class="me-2">🇬🇧</span> English
                        </button>
                    </form>
                </li>
                <li>
                    <form action="{% url 'set_language' %}" method="post">
                        {% csrf_token %}
                        <input type="hidden" name="language" value="ar">
                        <input type="hidden" name="next" value="{{ request.path }}">
                        <button type="submit" class="dropdown-item {% if LANGUAGE_CODE == 'ar' %}active{% endif %}">
                            <span class="me-2">🇸🇦</span> العربية
                        </button>
                    </form>
                </li>
            </ul>
        </div>
    </div>

    <div class="success-container">
        <!-- Success Icon -->
        <div class="success-icon">
            <i class="bi bi-check-lg"></i>
        </div>
        
        <!-- Title -->
        <h1 class="mb-3">{% trans "Thank You!" %}</h1>
        <p class="text-muted lead">
            {% trans "Your observation has been submitted successfully." %}
        </p>
        
        <!-- Tracking Code -->
        <div class="tracking-code">
            <p class="text-muted mb-2">{% trans "Your Tracking Code" %}</p>
            <h3 id="trackingCode">{{ tracking_code }}</h3>
            <button class="copy-btn mt-2" onclick="copyTrackingCode()">
                <i class="bi bi-clipboard me-1"></i>
                <span id="copyText">{% trans "Copy Code" %}</span>
            </button>
        </div>
        
        <!-- Info -->
        <div class="info-card">
            <p class="mb-2">
                <i class="bi bi-info-circle me-2"></i>
                <strong>{% trans "Important" %}</strong>
            </p>
            <ul class="mb-0 small">
                <li>{% trans "Save this tracking code to check the status of your observation." %}</li>
                <li>{% trans "Our team will review your observation and take appropriate action." %}</li>
                <li>{% trans "You can track your observation status anytime using the tracking code." %}</li>
            </ul>
        </div>
        
        <!-- Observation Summary -->
        <div class="mt-4 text-start">
            <h6 class="text-muted mb-3">{% trans "Observation Summary" %}</h6>
            <table class="table table-sm">
                <tr>
                    <td class="text-muted">{% trans "Category" %}</td>
                    <td>{{ observation.category.name|default:"Not specified" }}</td>
                </tr>
                <tr>
                    <td class="text-muted">{% trans "Severity" %}</td>
                    <td>
                        <span class="badge bg-{{ observation.get_severity_color }}">
                            {{ observation.get_severity_display }}
                        </span>
                    </td>
                </tr>
                <tr>
                    <td class="text-muted">{% trans "Status" %}</td>
                    <td>
                        <span class="badge bg-{{ observation.get_status_color }}">
                            {{ observation.get_status_display }}
                        </span>
                    </td>
                </tr>
                <tr>
                    <td class="text-muted">{% trans "Submitted" %}</td>
                    <td>{{ observation.created_at|date:"M d, Y H:i" }}</td>
                </tr>
            </table>
        </div>
        
        <!-- Actions -->
        <div class="mt-4 d-flex gap-3 justify-content-center">
            <a href="{% url 'observations:observation_track' %}?tracking_code={{ tracking_code }}" 
               class="btn btn-outline-primary">
                <i class="bi bi-search me-1"></i>{% trans "Track Status" %}
            </a>
            <a href="{% url 'observations:observation_create_public' %}" class="btn btn-primary">
                <i class="bi bi-plus-circle me-1"></i>{% trans "Submit Another" %}
            </a>
        </div>
    </div>
    
    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        function copyTrackingCode() {
            const code = document.getElementById('trackingCode').textContent;
            navigator.clipboard.writeText(code).then(() => {
                const btn = document.querySelector('.copy-btn');
                const text = document.getElementById('copyText');
                btn.classList.add('copied');
                text.textContent = '{% trans "Copied!" %}';
                
                setTimeout(() => {
                    btn.classList.remove('copied');
                    text.textContent = '{% trans "Copy Code" %}';
                }, 2000);
            });
        }
    </script>
</body>
</html>
