<?php
require_once '../config/db.php';
require_once 'layout.php';

header('Content-Type: text/html; charset=utf-8');

renderAdminSidebar('gamification');
?>

<!-- Header -->
<div class="flex justify-between items-center mb-8">
    <div>
        <h2 class="text-3xl font-bold text-white tracking-tight">Gamification & XP</h2>
        <p class="text-gray-400 mt-1">Configura misiones, niveles, ruleta y recompensas por referidos.</p>
    </div>
    <div class="flex gap-4">
        <button class="bg-brand-600 hover:bg-brand-700 text-white font-bold py-2 px-6 rounded-xl flex items-center gap-2 shadow-lg shadow-brand-500/20 transition hover:scale-105 transform duration-200">
            <i class="fas fa-save"></i> Guardar Todo
        </button>
    </div>
</div>

<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
    <!-- Ruleta Diaria -->
    <div class="bg-dark-800 rounded-2xl border border-dark-700 p-6 shadow-xl">
        <h3 class="text-xl font-bold text-white flex items-center gap-2 mb-4">
            <i class="fas fa-dharmachakra text-yellow-400"></i> Ruleta Diaria
        </h3>
        <p class="text-gray-400 text-sm mb-4">Configura los premios y probabilidades (Próximamente conexión base de datos).</p>
        
        <div class="space-y-4">
            <div class="p-4 bg-dark-900 border border-dark-700 rounded-xl flex justify-between items-center">
                <span class="text-white font-bold">Premio Máximo</span>
                <input type="number" value="1000" class="w-32 bg-dark-800 border border-dark-600 rounded-lg px-3 py-2 text-white">
            </div>
            <div class="p-4 bg-dark-900 border border-dark-700 rounded-xl flex justify-between items-center">
                <span class="text-white font-bold">Probabilidad Premio Máximo (%)</span>
                <input type="number" value="1" class="w-32 bg-dark-800 border border-dark-600 rounded-lg px-3 py-2 text-white">
            </div>
            <div class="flex items-center gap-2 pt-2">
                <input type="checkbox" checked class="w-4 h-4 accent-brand-500">
                <label class="text-gray-300">Activar Ruleta Diaria</label>
            </div>
        </div>
    </div>

    <!-- Referidos -->
    <div class="bg-dark-800 rounded-2xl border border-dark-700 p-6 shadow-xl">
        <h3 class="text-xl font-bold text-white flex items-center gap-2 mb-4">
            <i class="fas fa-users text-blue-400"></i> Sistema de Referidos
        </h3>
        <p class="text-gray-400 text-sm mb-4">Establece la recompensa que se envía cuando alguien usa un código.</p>
        
        <div class="space-y-4">
            <div class="p-4 bg-dark-900 border border-dark-700 rounded-xl">
                <label class="block text-sm text-gray-400 mb-2">Recompensa para el Creador del Código (💎)</label>
                <input type="number" value="100" class="w-full bg-dark-800 border border-dark-600 rounded-lg px-4 py-3 text-white">
            </div>
            <div class="p-4 bg-dark-900 border border-dark-700 rounded-xl">
                <label class="block text-sm text-gray-400 mb-2">Recompensa para el Nuevo Usuario (💎)</label>
                <input type="number" value="100" class="w-full bg-dark-800 border border-dark-600 rounded-lg px-4 py-3 text-white">
            </div>
        </div>
    </div>

    <!-- Misiones -->
    <div class="bg-dark-800 rounded-2xl border border-dark-700 p-6 shadow-xl lg:col-span-2">
        <div class="flex justify-between items-center mb-4">
            <h3 class="text-xl font-bold text-white flex items-center gap-2">
                <i class="fas fa-list-check text-green-400"></i> Misiones Activas
            </h3>
            <button class="bg-dark-700 hover:bg-dark-600 text-white text-sm font-bold py-2 px-4 rounded-xl transition">
                + Añadir Misión
            </button>
        </div>
        
        <table class="w-full text-left text-sm text-gray-400">
            <thead class="bg-dark-900 text-gray-200">
                <tr>
                    <th class="px-4 py-3 rounded-tl-xl">Misión</th>
                    <th class="px-4 py-3">Tipo de Acción</th>
                    <th class="px-4 py-3">Meta</th>
                    <th class="px-4 py-3 text-yellow-400">Recompensa 💎</th>
                    <th class="px-4 py-3 text-right rounded-tr-xl">Estado</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-dark-700">
                <tr class="hover:bg-dark-700/50">
                    <td class="px-4 py-3 text-white font-bold">Envía 5 mensajes</td>
                    <td class="px-4 py-3">send_message</td>
                    <td class="px-4 py-3">5</td>
                    <td class="px-4 py-3 text-yellow-500 font-bold">10</td>
                    <td class="px-4 py-3 text-right"><span class="px-2 py-1 bg-green-500/20 text-green-400 rounded-lg text-xs font-bold uppercase">Activa</span></td>
                </tr>
                <tr class="hover:bg-dark-700/50">
                    <td class="px-4 py-3 text-white font-bold">Haz una videollamada</td>
                    <td class="px-4 py-3">video_call</td>
                    <td class="px-4 py-3">1</td>
                    <td class="px-4 py-3 text-yellow-500 font-bold">20</td>
                    <td class="px-4 py-3 text-right"><span class="px-2 py-1 bg-green-500/20 text-green-400 rounded-lg text-xs font-bold uppercase">Activa</span></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

<?php renderAdminFooter(); ?>
