{% 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>{{ "Configuración - 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="/dashboard" class="btn btn-outline-light btn-sm me-2">{{ "Dashboard" | translate(lang) }}</a>
                <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">⚙️ {{ "Configuración" | translate(lang) }}</h2>
        
        <div class="alert alert-info">
            <i class="bi bi-info-circle"></i> {{ "La configuración se lee desde las variables de entorno de Docker." | translate(lang) }}
        </div>
        
        <div class="row">
            <div class="col-md-6">
                <div class="card mb-4">
                    <div class="card-header">
                        <h5 class="mb-0"><i class="bi bi-discord"></i> {{ "Tokens de Bots" | translate(lang) }}</h5>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label class="form-label">{{ "Token de Discord" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.discord.token if is_admin else '****************************************' }}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">{{ "Token de Telegram" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.telegram.token if is_admin else '****************************************' }}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">{{ "URL de LibreTranslate" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.libretranslate.url if is_admin else '****************************************' }}" readonly>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="col-md-6">
                <div class="card mb-4">
                    <div class="card-header">
                        <h5 class="mb-0"><i class="bi bi-globe"></i> {{ "Panel Web" | translate(lang) }}</h5>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label class="form-label">{{ "Usuario admin" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.web.admin_username }}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">{{ "Host" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.web.host }}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">{{ "Puerto" | translate(lang) }}</label>
                            <input type="number" class="form-control" 
                                   value="{{ config.web.port }}" readonly>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-6">
                <div class="card mb-4">
                    <div class="card-header">
                        <h5 class="mb-0"><i class="bi bi-database"></i> {{ "Base de Datos" | translate(lang) }}</h5>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label class="form-label">{{ "Tipo de Base de Datos" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.database.type|upper }}" readonly>
                        </div>
                        
                        {% if config.database.type == 'mysql' %}
                        <div class="mb-3">
                            <label class="form-label">{{ "Host MySQL" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.database.host if is_admin else '****************************************' }}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">{{ "Puerto MySQL" | translate(lang) }}</label>
                            <input type="number" class="form-control" 
                                   value="{{ config.database.port if is_admin else '****************************************' }}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">{{ "Usuario MySQL" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.database.user if is_admin else '****************************************' }}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">{{ "Nombre de Base de Datos" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.database.name if is_admin else '****************************************' }}" readonly>
                        </div>
                        {% else %}
                        <div class="mb-3">
                            <label class="form-label">{{ "Ruta de la base de datos" | translate(lang) }}</label>
                            <input type="text" class="form-control" 
                                   value="{{ config.database.path if is_admin else '****************************************' }}" readonly>
                        </div>
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
