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

{% block title %}{% trans "Home" %} | EduPlatform{% endblock %}

{% block content %}
<section class="hero-section">
    <div class="container">
        <div class="row align-items-center">
            <div class="col-lg-6">
                <h1 class="display-4 fw-bold mb-4">
                    {% if LANGUAGE_CODE == 'ar' %}
                    تعلم من أفضل المعلمين في أي وقت وأي مكان
                    {% else %}
                    Learn from the best teachers anytime, anywhere
                    {% endif %}
                </h1>
                <p class="lead mb-5 text-muted">
                    {% if LANGUAGE_CODE == 'ar' %}
                    منصة تعليمية متكاملة تدعم الطلاب والمعلمين مع دروس حية ومصادر تعليمية متميزة.
                    {% else %}
                    A comprehensive educational platform supporting students and teachers with live classes and premium educational resources.
                    {% endif %}
                </p>
                <div class="d-flex gap-3">
                    <a href="#levels-section" class="btn btn-primary btn-lg px-5">{% trans "Get Started" %}</a>
                    <a href="#" class="btn btn-outline-secondary btn-lg px-5">{% trans "Learn More" %}</a>
                </div>
            </div>
            <div class="col-lg-6 d-none d-lg-block">
                <div class="position-relative">
                    <div style="width: 400px; height: 400px; background: var(--primary-color); border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; opacity: 0.1; position: absolute; top: -50px; left: 50px;"></div>
                    <div style="width: 300px; height: 300px; background: var(--secondary-color); border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; opacity: 0.1; position: absolute; bottom: -50px; right: 50px;"></div>
                    <div class="glass-card text-center position-relative z-1">
                        <h3 class="fw-bold mb-3">{% trans "Ready to start?" %}</h3>
                        <p>{% trans "Join thousands of students learning today." %}</p>
                        <div class="avatar-group d-flex justify-content-center mt-4">
                            <div style="width: 40px; height: 40px; border-radius: 50%; background: #ccc; border: 2px solid #fff; margin-left: -10px;"></div>
                            <div style="width: 40px; height: 40px; border-radius: 50%; background: #ddd; border: 2px solid #fff; margin-left: -10px;"></div>
                            <div style="width: 40px; height: 40px; border-radius: 50%; background: #eee; border: 2px solid #fff; margin-left: -10px;"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<section id="levels-section" class="subjects-section py-5">
    <div class="container">
        <div class="text-center mb-5">
            <h2 class="fw-bold">{% trans "Our Educational Programs" %}</h2>
            <p class="text-muted">{% trans "Explore subjects tailored for each educational level." %}</p>
        </div>

        {% for level in levels %}
        <div class="mb-5">
            <div class="d-flex align-items-center mb-4">
                <div class="p-2 rounded-3 bg-primary text-white me-3" style="width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;">
                    {{ forloop.counter }}
                </div>
                <h3 class="fw-bold mb-0">
                    {% if LANGUAGE_CODE == 'ar' %}{{ level.name_ar }}{% else %}{{ level.name_en }}{% endif %}
                </h3>
                <hr class="flex-grow-1 ms-4 d-none d-md-block opacity-10">
            </div>

            <div class="row g-4">
                {% for subject in level.subjects.all %}
                <div class="col-md-6 col-lg-4">
                    <div class="glass-card h-100 p-0 overflow-hidden shadow-sm">
                        <div style="height: 180px; background: {% cycle '#E3F2FD' '#F3E5F5' '#E8F5E9' %}; display: flex; align-items: center; justify-content: center;">
                            {% if subject.image %}
                            <img src="{{ subject.image.url }}" class="img-fluid" alt="{{ subject.name_en }}">
                            {% else %}
                            <span class="display-2" style="opacity: 0.2;">📚</span>
                            {% endif %}
                        </div>
                        <div class="p-4">
                            <h4 class="fw-bold mb-3">
                                {% if LANGUAGE_CODE == 'ar' %}{{ subject.name_ar }}{% else %}{{ subject.name_en }}{% endif %}
                            </h4>
                            <p class="text-muted small mb-4">
                                {% if LANGUAGE_CODE == 'ar' %}{{ subject.description_ar|truncatewords:15 }}{% else %}{{ subject.description_en|truncatewords:15 }}{% endif %}
                            </p>
                            <div class="d-flex justify-content-between align-items-center">
                                <span class="h5 fw-bold mb-0 text-primary">${{ subject.price }}</span>
                                <a href="{% url 'subject_detail' subject.pk %}" class="btn btn-primary btn-sm">{% trans "Subscribe" %}</a>
                            </div>
                        </div>
                    </div>
                </div>
                {% empty %}
                <div class="col-12">
                    <div class="alert alert-light border-0 text-center py-4">
                        {% trans "No subjects available for this level yet." %}
                    </div>
                </div>
                {% endfor %}
            </div>
        </div>
        {% endfor %}
    </div>
</section>

<section class="features-section py-5 bg-white">
    <div class="container">
        <div class="row text-center g-4">
            <div class="col-md-4">
                <div class="p-4">
                    <div class="mb-3 text-primary h1">🎥</div>
                    <h5 class="fw-bold">{% trans "Live Classes" %}</h5>
                    <p class="text-muted">{% trans "Join interactive sessions via Google Meet." %}</p>
                </div>
            </div>
            <div class="col-md-4">
                <div class="p-4">
                    <div class="mb-3 text-primary h1">📁</div>
                    <h5 class="fw-bold">{% trans "Resources" %}</h5>
                    <p class="text-muted">{% trans "Access course materials on Google Drive." %}</p>
                </div>
            </div>
            <div class="col-md-4">
                <div class="p-4">
                    <div class="mb-3 text-primary h1">💳</div>
                    <h5 class="fw-bold">{% trans "Easy Payments" %}</h5>
                    <p class="text-muted">{% trans "Secure payments with Thawani gateway." %}</p>
                </div>
            </div>
        </div>
    </div>
</section>
{% endblock %}