<?php
require_once __DIR__ . '/../shared/bootstrap.php';

// El bootstrap.php ya maneja la autenticación y carga $userData
// $userData está disponible globalmente a través de JWTAuth::getUserData() si se necesita de nuevo
?>
<!DOCTYPE html>
<html lang="<?php echo $userData->idioma ?? 'es'; ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo __('discord_dashboard_title'); ?></title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --discord-color: #5865F2;
            --discord-dark: #4752C4;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: linear-gradient(135deg, var(--discord-color) 0%, var(--discord-dark) 100%);
            min-height: 100vh;
            padding: 20px;
        }
        
        .header {
            background: white;
            border-radius: 15px;
            padding: 20px 30px;
            margin-bottom: 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
        }
        
        .header h1 {
            color: var(--discord-color);
            font-size: 24px;
        }
        
        .btn-back {
            background: #6c757d;
            color: white;
            padding: 10px 20px;
            border-radius: 8px;
            text-decoration: none;
            transition: transform 0.2s;
        }
        
        .btn-back:hover {
            transform: translateY(-2px);
        }
        
        .container {
            max-width: 1400px;
            margin: 0 auto;
        }
        
        .modules-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 20px;
        }
        
        .module-card {
            background: white;
            border-radius: 15px;
            padding: 30px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            transition: all 0.3s;
            cursor: pointer;
            text-decoration: none;
            color: inherit;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        
        .module-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        }
        
        .module-icon {
            font-size: 48px;
            margin-bottom: 15px;
            color: var(--discord-color);
        }
        
        .module-title {
            font-size: 18px;
            font-weight: 700;
            margin-bottom: 10px;
            text-align: center;
            color: #333;
        }
        
        .module-description {
            font-size: 14px;
            color: #666;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>💬 <?php echo __('discord_dashboard_header'); ?></h1>
        <a href="/index.php" class="btn-back">← <?php echo __('back_to_main_dashboard'); ?></a>
    </div>
    
    <div class="container">
        <div class="modules-grid">
            <?php if (hasPermission('manage_templates', 'discord')): ?>
            <a href="/discord/views/templates/list.php" class="module-card">
                <div class="module-icon"><i class="fas fa-file-alt"></i></div>
                <div class="module-title"><?php echo __('templates_module_title'); ?></div>
                <div class="module-description"><?php echo __('templates_module_description'); ?></div>
            </a>
            <?php endif; ?>
            
            <?php if (hasPermission('send_messages', 'discord')): ?>
            <a href="/discord/views/messages/create.php" class="module-card">
                <div class="module-icon"><i class="fas fa-paper-plane"></i></div>
                <div class="module-title"><?php echo __('create_message_module_title'); ?></div>
                <div class="module-description"><?php echo __('create_message_module_description'); ?></div>
            </a>
            <?php endif; ?>
            
            <?php if (hasPermission('view_sent_messages', 'discord')): ?>
            <a href="/discord/views/messages/sent.php" class="module-card">
                <div class="module-icon"><i class="fas fa-history"></i></div>
                <div class="module-title"><?php echo __('sent_messages_module_title'); ?></div>
                <div class="module-description"><?php echo __('sent_messages_module_description'); ?></div>
            </a>
            <?php endif; ?>
            
            <?php if (hasPermission('manage_recipients', 'discord')): ?>
            <a href="/discord/views/recipients/list.php" class="module-card">
                <div class="module-icon"><i class="fas fa-users"></i></div>
                <div class="module-title"><?php echo __('recipients_module_title'); ?></div>
                <div class="module-description"><?php echo __('recipients_module_description'); ?></div>
            </a>
            <?php endif; ?>
            
            <?php if (hasPermission('manage_commands', 'discord')): ?>
            <a href="/discord/views/commands/list.php" class="module-card">
                <div class="module-icon"><i class="fas fa-terminal"></i></div>
                <div class="module-title"><?php echo __('commands_module_title'); ?></div>
                <div class="module-description"><?php echo __('commands_module_description'); ?></div>
            </a>
            <?php endif; ?>
            
            <?php if (hasPermission('manage_welcome', 'discord')): ?>
            <a href="/discord/views/welcome/config.php" class="module-card">
                <div class="module-icon"><i class="fas fa-handshake"></i></div>
                <div class="module-title"><?php echo __('welcome_message_module_title'); ?></div>
                <div class="module-description"><?php echo __('welcome_message_module_description'); ?></div>
            </a>
            <?php endif; ?>
            
            <?php if (hasPermission('view_logs', 'discord')): ?>
            <a href="/discord/views/logs/list.php" class="module-card">
                <div class="module-icon"><i class="fas fa-list-alt"></i></div>
                <div class="module-title"><?php echo __('system_logs_module_title'); ?></div>
                <div class="module-description"><?php echo __('system_logs_module_description'); ?></div>
            </a>
            <?php endif; ?>
            
            <?php if (hasPermission('view_gallery')): ?>
            <a href="/gallery/index.php" class="module-card">
                <div class="module-icon"><i class="fas fa-images"></i></div>
                <div class="module-title"><?php echo __('gallery_module_title'); ?></div>
                <div class="module-description"><?php echo __('gallery_module_description'); ?></div>
            </a>
            <?php endif; ?>
            
            <?php if (hasPermission('manage_languages')): ?>
            <a href="/shared/languages/manager.php" class="module-card">
                <div class="module-icon"><i class="fas fa-language"></i></div>
                <div class="module-title"><?php echo __('languages_module_title'); ?></div>
                <div class="module-description"><?php echo __('languages_module_description'); ?></div>
            </a>
            <?php endif; ?>
            
            <?php if (hasPermission('test_connection', 'discord')): ?>
            <a href="/discord/test_connection.php" class="module-card">
                <div class="module-icon"><i class="fas fa-plug"></i></div>
                <div class="module-title"><?php echo __('connection_test_module_title'); ?></div>
                <div class="module-description"><?php echo __('connection_test_module_description'); ?></div>
            </a>
            <?php endif; ?>

            <?php if (hasPermission('view_logs', 'discord')): ?>
            <a href="/discord/views/features.php" class="module-card">
                <div class="module-icon"><i class="fas fa-robot"></i></div>
                <div class="module-title">Funciones del Bot</div>
                <div class="module-description">Documentación de las funciones automáticas y comandos del bot.</div>
            </a>
            <?php endif; ?>
        </div>
    </div>
</body>
</html>
