{% set lang = request.cookies.get('panel_lang', 'es') %}
{% set is_admin = username == 'nickpons666' %}
<!DOCTYPE html>
<html lang="{{ lang }}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ "Dashboard - Bots de Traducción" | translate(lang) }}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container-fluid">
            <a class="navbar-brand" href="/dashboard">
                <i class="bi bi-translate"></i> {{ "Bots de Traducción" | translate(lang) }}
            </a>
            
            <div class="d-flex align-items-center">
                <div class="dropdown me-3">
                    <button class="btn btn-outline-light btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown">
                        <i class="bi bi-translate"></i>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-end">
                        <li><a class="dropdown-item {{ 'active' if lang == 'es' }}" href="/set-lang/es">Español</a></li>
                        <li><a class="dropdown-item {{ 'active' if lang == 'en' }}" href="/set-lang/en">English</a></li>
                        <li><a class="dropdown-item {{ 'active' if lang == 'pt' }}" href="/set-lang/pt">Português</a></li>
                    </ul>
                </div>
                <a href="/logout" class="btn btn-outline-light btn-sm">{{ "Cerrar Sesión" | translate(lang) }}</a>
            </div>
        </div>
    </nav>

    <div class="container mt-5">
        <h2 class="mb-4">📊 {{ "Dashboard" | translate(lang) }}</h2>
        
        <div class="row">
            <div class="col-md-4">
                <div class="card text-white bg-primary mb-3">
                    <div class="card-body">
                        <h5 class="card-title"><i class="bi bi-gear"></i> {{ "Configuración" | translate(lang) }}</h5>
                        <p class="card-text">{{ "Configurar tokens de bots y parámetros del sistema" | translate(lang) }}</p>
                        <a href="/config" class="btn btn-light btn-sm">{{ "Configurar" | translate(lang) }}</a>
                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
                <div class="card text-white bg-success mb-3">
                    <div class="card-body">
                        <h5 class="card-title"><i class="bi bi-globe"></i> {{ "Idiomas" | translate(lang) }}</h5>
                        <p class="card-text">{{ "Administrar idiomas disponibles" | translate(lang) }}</p>
                        <a href="/languages" class="btn btn-light btn-sm">{{ "Administrar" | translate(lang) }}</a>
                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
                <div class="card text-white bg-info mb-3">
                    <div class="card-body">
                        <h5 class="card-title"><i class="bi bi-emoji-smile"></i> {{ "Bienvenida" | translate(lang) }}</h5>
                        <p class="card-text">{{ "Configurar mensaje de bienvenida" | translate(lang) }}</p>
                        <a href="/welcome" class="btn btn-light btn-sm">{{ "Configurar" | translate(lang) }}</a>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="row">
            <div class="col-md-4">
                <div class="card text-white bg-dark mb-3">
                    <div class="card-body">
                        <h5 class="card-title"><i class="bi bi-people"></i> {{ "Administradores" | translate(lang) }}</h5>
                        <p class="card-text">{{ "Gestionar usuarios del panel web" | translate(lang) }}</p>
                        <a href="/admins" class="btn btn-light btn-sm">{{ "Gestionar" | translate(lang) }}</a>
                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
                <div class="card text-white bg-warning mb-3">
                    <div class="card-body">
                        <h5 class="card-title"><i class="bi bi-hash"></i> {{ "Canales de Discord" | translate(lang) }}</h5>
                        <p class="card-text">{{ "Administrar canales habilitados para traducción" | translate(lang) }}</p>
                        <a href="/discord-channels" class="btn btn-dark btn-sm">{{ "Administrar" | translate(lang) }}</a>
                    </div>
                </div>
            </div>
        </div>

        <div class="card mt-4">
            <div class="card-header">
                <h5 class="mb-0">📋 {{ "Estado de Configuración" | translate(lang) }}</h5>
            </div>
            <div class="card-body">
                <table class="table table-striped">
                    <tr>
                        <th>{{ "Token Discord" | translate(lang) }}</th>
                        <td>{{ '✅ Configurado' | translate(lang) if config.discord.token and config.discord.token != 'TU_DISCORD_BOT_TOKEN' else '❌ No configurado' | translate(lang) }}</td>
                    </tr>
                    <tr>
                        <th>{{ "Token Telegram" | translate(lang) }}</th>
                        <td>{{ '✅ Configurado' | translate(lang) if config.telegram.token and config.telegram.token != 'TU_TELEGRAM_BOT_TOKEN' else '❌ No configurado' | translate(lang) }}</td>
                    </tr>
                    <tr>
                        <th>{{ "LibreTranslate URL" | translate(lang) }}</th>
                        <td>{{ config.libretranslate.url if is_admin else '********' if config.libretranslate.url else '❌ No configurado' | translate(lang) }}</td>
                    </tr>
                    <tr>
                        <th>{{ "Idiomas activos" | translate(lang) }}</th>
                        <td>{{ config.languages.enabled|length }} {{ "idiomas" | translate(lang) }}</td>
                    </tr>
                    <tr>
                        <th>{{ "Tipo de Base de Datos" | translate(lang) }}</th>
                        <td>{{ config.database.type|upper }}</td>
                    </tr>
                    {% if config.database.type == 'mysql' %}
                    <tr>
                        <th>{{ "Host MySQL" | translate(lang) }}</th>
                        <td>{{ config.database.host ~ ':' ~ config.database.port if is_admin else '********' }}</td>
                    </tr>
                    <tr>
                        <th>{{ "Base de Datos" | translate(lang) }}</th>
                        <td>{{ config.database.name if is_admin else '********' }}</td>
                    </tr>
                    <tr>
                        <th>{{ "Usuario MySQL" | translate(lang) }}</th>
                        <td>{{ config.database.user if is_admin else '********' }}</td>
                    </tr>
                    {% else %}
                    <tr>
                        <th>{{ "Ruta SQLite" | translate(lang) }}</th>
                        <td>{{ config.database.path if is_admin else '********' }}</td>
                    </tr>
                    {% endif %}
                </table>
            </div>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
