{% extends "CHRISTMAS/default.html" %}

{% block title %}
<title>Shop</title>
{% endblock %}

{% block subHeader %}
<div class="relative max-w-screen-2xl mx-auto px-4 py-4 grid grid-cols-12 rounded-t">
		<div class="absolute top-0 left-0 w-full h-full bg-gradient-to-t from-gray-300 to-gray-200 dark:bg-none dark:bg-gray-800 rounded-t sub-header-shadow dark:border-b dark:border-gray-700 sub-header"></div>
		<div class="relative col-span-full flex items-center">
		<div>
			<h1 class="font-bold text-xl font-heading leading-normal mb-0">
				Shop
			</h1>
			<small class="block text-gray-700 dark:text-gray-400">
				Stir drama. Earn coins.
			</small>
		</div>
		<ul class="ml-auto flex space-x-5 mb-0">
			<li>
				<strong class="text-lg md:text-2xl">
					{{v.coins}}
				</strong>
				<small class="text-gray-700 dark:text-gray-400">your balance</small>
			</li>
			<li>
				<strong class="text-lg md:text-2xl">
					{{v.coins_spent}}
				</strong>
				<small class="text-gray-700 dark:text-gray-400">spent by you</small>
			</li>
			<li>
				<strong class="text-lg md:text-2xl">
					{{sales}}
				</strong>
				<small class="text-gray-700 dark:text-gray-400">total sales</small>
			</li>
		</ul>
	</div>
</div>
{% endblock %}

{% block content %}
<div class="col-span-full">
	{% if error %}
	<div class="alert alert-danger alert-dismissible fade show my-3" role="alert">
		<i class="fas fa-exclamation-circle my-auto"></i>
		<span>
			{{error}}
		</span>
		<button type="button" class="close" data-dismiss="alert" aria-label="Close">
			<span aria-hidden="true"><i class="far fa-times"></i></span>
		</button>
	</div>
	{% endif %}
	{% if msg %}
	<div class="alert alert-success alert-dismissible fade show my-3" role="alert">
		<i class="fas fa-check-circle my-auto" aria-hidden="true"></i>
		<span>
			{{msg}}
		</span>
		<button type="button" class="close" data-dismiss="alert" aria-label="Close">
			<span aria-hidden="true"><i class="far fa-times"></i></span>
		</button>
	</div>
	{% endif %}

	<!-- <img src="/assets/CHRISTMAS/images/shop.webp" width="50%"/> -->

	<!-- This example requires Tailwind CSS v2.0+ -->
	<div class="flex flex-col">
		<div class="-mx-4 overflow-x-auto">
			<div class="align-middle inline-block min-w-full">
				<div class="flex flex-col bg-gray-200 rounded-b-xl overflow-hidden">
					<table class="min-w-full">
						<thead class="bg-gradient-to-t from-gray-200 to-gray-100">
							<tr>
								<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-700 uppercase tracking-wider">
									Item
								</th>
								<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-700 uppercase tracking-wider">
									Description
								</th>
								<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-700 uppercase tracking-wider">
									Price
								</th>
								<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-700 uppercase tracking-wider">
									Owned
								</th>
								<th scope="col" class="relative px-6 py-3">
									<span class="sr-only">Buy</span>
								</th>
							</tr>
						</thead>
						<tbody class="bg-gray-100 divide-y divide-gray-300">
							{% for a in awards %}
							<tr class="shadow-inset-t-white-05 {% if awards.index(a) % 2 != 0 %}bg-gray-200{% endif %}">
								<td class="px-6 py-4 whitespace-nowrap">
									<div class="flex items-center">
										<div class="flex items-center justify-center flex-shrink-0 h-10 w-10">
											<i class="{{a['icon']}} {{a['color']}} fa-fw text-lg"></i>
										</div>
										<div class="ml-4">
											<div class="text-base font-bold text-black">
												{{a['title']}}
											</div>
											<div class="text-sm text-gray-500 capitalize">{{a['kind']}}</div>
										</div>
									</div>
								</td>
								<td class="px-6 py-4">
									<div class="text-sm text-gray-700">{{a['description']}}</div>
								</td>
								<td class="px-6 py-4 whitespace-nowrap">
									<span class="inline-flex items-center px-1 py-0.5 text-xs text-yellow-900 text-shadow-light bg-yellow-400 font-bold leading-5 rounded">
										<img src="https://i.ibb.co/xFgG6yf/Coinfixed.gif" class="h-[10px] w-[14px] object-contain mr-1" alt="dramacoin icon"/>
										{{a['price']}}
									</span>
								</td>
								<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
									{{a['owned']}}
								</td>
								{% set kind = a['kind'] %}
								<td class="px-6 py-4 whitespace-nowrap flex justify-end text-sm">
									<button class="block px-4 py-2 bg-gradient-to-t from-green-700 to-green-600 hover:from-green-600 hover:to-green-700 active:shadow-inner border border-green-900 rounded-md text-shadow-t shadow-inset-t-white-10 text-sm font-bold text-gray-100 focus:text-gray-500 focus:outline-none {% if v.coins < a['price'] %}disabled{% endif %}" onclick="post_toast('/buy/{{kind}}')">
										Buy
									</button>
									{% if v.procoins and a['price'] < 3600 %}
									<button class="ml-2 block px-4 py-2 bg-gradient-to-t from-yellow-600 to-yellow-500 hover:from-yellow-500 hover:to-yellow-600 active:shadow-inner border border-gray-900 rounded-md text-shadow-t shadow-inset-t-white-10 text-sm font-bold text-yellow-900 focus:text-yellow-500 focus:outline-none {% if v.procoins < a['price'] %}disabled{% endif %}" onclick="post_toast('/buy/{{kind}}?mb=true')">
										Buy with MarseyBux
									</button>
									{% endif %}
								</td>
							</tr>
							{% endfor %}
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>

</div>
{% endblock %}

{% block scripts %}
<style>
	@media (max-width: 768px) {
		.table th {
			padding-left: 0.3rem !important;
			padding-right: 0.3rem !important;
		}
		.table td {
			padding-left: 0.3rem !important;
			padding-right: 0.3rem !important;
			font-size: 0.9rem;
		}
		.marseybux {
			font-size: 0.7rem !important;
		}
	}

	.tooltip-inner {
		font-size: 1.5rem;
		max-width: 300px;
	}
</style>
{% endblock %}
