{% load static %}

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Osina</title>

    <link rel="stylesheet" type="text/css" href='{% static "dist/output.css" %}'>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>


<body class="font-poppinsLight">
    <div id="hiddenContent">
        <h1 class="text-secondosiblue text-2xl font-semibold text-center mb-4">Points</h1>

        <div class="flex flex-col gap-5">
            {% for point in points %}
            <p class="pointId" data-point-id="{{ point.id }}" style="display: none;">{{ point.id }}</p>
            <div class="w-full flex flex-col gap-1 
            {% if point.status == 'Completed' %}
                bg-green-700
            {% elif point.status == 'Working On' %}
                    bg-orange-500
            {% elif point.status == 'Paused' %}
                    bg-red-500
            {% else %}
                    bg-slate-700
            {% endif %}
             bg-opacity-50 rounded-md shadow-md p-3">
                <div class="w-full flex justify-between items-end pb-2 border-b border-gray-200">
                    <div class="w-[380px]">
                        {% if point.status == 'Completed' %}
                        <p class="text-white line-through">{{point.text}}</p>
                        {% else %}
                        <p class="text-white">{{point.text}}</p>
                        {% endif %}
                    </div>
                    <div class="flex justify-end items-center gap-2">
                        {% if point.status == 'Not Completed' or point.status == 'Paused' and not point.status == 'Completed' %}
                        <a href="{% url 'mark_point_working_on' point.id task.id %}">
                            <button
                                class="w-[40px] h-[40px] rounded-full bg-transparent shadow-md text-white border border-white flex justify-center items-center hover:scale-105 transition-transform duration-300"
                                id="startPointButton">
                                <i class="fa fa-play"></i>
                            </button>
                        </a> 
                        {% endif %}

                        {% if point.status == 'Working On' and not point.status == 'Completed'  %}
                        <a href="{% url 'mark_point_paused' point.id task.id %}">
                            <button
                                class="w-[40px] h-[40px] rounded-full bg-transparent shadow-md text-white border border-white justify-center items-center hover:scale-105 transition-transform duration-300"
                                id="pausePointButton">
                                <i class="fa fa-pause"></i>
                            </button>
                        </a>
                        {% endif %}

                        {% if not point.status == 'Completed' and not point.status == 'Paused' %}
                        <a href="{% url 'mark_point_completed' point.id task.id %}">
                            <button
                                class="w-[40px] h-[40px] rounded-full bg-transparent shadow-md text-white border border-white flex justify-center items-center hover:scale-105 transition-transform duration-300">
                                <i class="fa fa-check"></i>
                            </button>
                        </a>
                        {% endif %}


                        {% if point.status == 'Completed' %}
                        <button
                            class="w-[40px] h-[40px] rounded-full bg-transparent shadow-md text-white border border-white flex justify-center items-center opacity-30 cursor-default">
                            <i class="fa fa-check"></i>
                        </button>
                        {% endif %} 

                        {% if not point.status == 'Completed' %}
                        <form method="post" action="{% url 'deletepointmodal' point.id task.id %}">
                            {% csrf_token %}
                            <button type="submit"
                                class="w-[40px] h-[40px] bg-transparent border border-white rounded-full text-white flex justify-center items-center shadow-md hover:scale-105 transition-transform duration-300">
                                <i class="fa fa-trash"></i>
                            </button>
                        </form>
                        {% endif %}
                    </div>
                </div>

                <div class="flex justify-between items-center gap-3 pt-2">
                    <div class="text-white text-sm">
                        <p>Total Time:
                            <span class="font-semibold pointTotalTime">
                                <span class="hours">{{ point.total_activity_time.0 }}</span> hours,
                                <span class="minutes">{{ point.total_activity_time.1 }}</span> minutes,
                                <span class="seconds">{{ point.total_activity_time.2 }}</span> seconds
                            </span>
                        </p>
                    </div>

                    <div class="w-fit py-1 px-2 bg-white text-slate-700 text-xs rounded-md shadow-md">
                        {% if point.status == 'Completed' %}
                        <p class="text-green-700 opacity-50">Completed</p>
                        {% elif point.status == 'Working On' %}
                        <p class="text-orange-500 opacity-50">Working On</p>
                        {% elif point.status == 'Paused' %}
                        <p class="text-red-500 opacity-50">Paused</p>
                        {% else %}
                        <p class="text-slate-700 opacity-50">Created</p>
                        {% endif %}
                    </div>
                </div>
            </div>            
            {% endfor %}
        </div>
    </div>    
</body>

</html>