<?php
/**
 * Page Compétences
 */

$pageTitle = 'Compétences';
$pageDescription = 'Mes compétences techniques en développement web : langages, frameworks et outils.';
$currentPage = 'competences';

// Récupérer le comptage des technologies
$techCount = getProjectCountByTech();

// Catégoriser les technologies
$categories = [
    'Frontend' => [
        'icon' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"/>',
        'techs' => ['HTML', 'CSS', 'JavaScript', 'TypeScript', 'React', 'Vue.js', 'Tailwind CSS', 'Bootstrap', 'SASS']
    ],
    'Backend' => [
        'icon' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"/>',
        'techs' => ['PHP', 'Node.js', 'Python', 'Laravel', 'Express', 'Symfony']
    ],
    'Base de données' => [
        'icon' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"/>',
        'techs' => ['MySQL', 'PostgreSQL', 'MongoDB', 'SQLite', 'Redis']
    ],
    'DevOps & Outils' => [
        'icon' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>',
        'techs' => ['Git', 'Docker', 'Linux', 'Nginx', 'Apache', 'CI/CD']
    ],
];

include_template('header', compact('pageTitle', 'pageDescription'));
include_template('navbar', compact('currentPage'));
?>

<main>
    <section class="section">
        <div class="container-content">
            <div class="section-header">
                <h1 class="section-title">Compétences</h1>
                <p class="section-subtitle">
                    Technologies que j'utilise au quotidien, liées à mes projets réels.
                </p>
            </div>

            <!-- Technologies par catégorie -->
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8 lg:gap-12">
                <?php foreach ($categories as $category => $data): ?>
                    <div class="card">
                        <div class="card-body">
                            <div class="flex items-center gap-3 mb-6">
                                <div class="w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center">
                                    <svg class="w-5 h-5 text-primary" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <?= $data['icon'] ?>
                                    </svg>
                                </div>
                                <h2 class="text-xl font-semibold text-text-primary"><?= htmlspecialchars($category) ?></h2>
                            </div>

                            <div class="flex flex-wrap gap-3">
                                <?php foreach ($data['techs'] as $tech): ?>
                                    <?php $count = $techCount[$tech] ?? 0; ?>
                                    <?php if ($count > 0): ?>
                                        <span class="group flex items-center gap-2 px-4 py-2 bg-surface-alt rounded-lg border border-transparent hover:border-primary/30 transition-colors cursor-default"
                                              title="<?= $count ?> projet<?= $count > 1 ? 's' : '' ?>">
                                            <span class="font-medium text-text-primary">
                                                <?= htmlspecialchars($tech) ?>
                                            </span>
                                            <span class="text-xs px-2 py-0.5 bg-primary/20 text-primary rounded-full">
                                                <?= $count ?>
                                            </span>
                                        </span>
                                    <?php else: ?>
                                        <span class="flex items-center gap-2 px-4 py-2 bg-surface-alt/50 rounded-lg text-text-secondary">
                                            <?= htmlspecialchars($tech) ?>
                                        </span>
                                    <?php endif; ?>
                                <?php endforeach; ?>
                            </div>
                        </div>
                    </div>
                <?php endforeach; ?>
            </div>
        </div>
    </section>

    <!-- Section Outils Démontrables (Story 4.2) -->
    <?php
    // Outils démontrables avec preuves vérifiables
    $demonstrableTools = [
        [
            'name' => 'GitHub',
            'icon' => 'github',
            'url' => 'https://github.com/skycel',
            'description' => 'Historique de commits et projets publics'
        ],
        [
            'name' => 'VS Code',
            'icon' => 'vscode',
            'url' => null,
            'description' => 'Éditeur principal, visible dans le code source'
        ],
        [
            'name' => 'Figma',
            'icon' => 'figma',
            'url' => null,
            'description' => 'Maquettes et prototypes de projets'
        ],
        [
            'name' => 'Docker',
            'icon' => 'docker',
            'url' => null,
            'description' => 'Conteneurisation des environnements'
        ],
        [
            'name' => 'Linux',
            'icon' => 'linux',
            'url' => null,
            'description' => 'Administration serveur et développement'
        ],
    ];

    // Autres outils utilisés régulièrement
    $otherTools = [
        ['name' => 'Photoshop', 'context' => 'Retouche d\'images et création graphique'],
        ['name' => 'Insomnia', 'context' => 'Test d\'APIs REST et GraphQL'],
        ['name' => 'DBeaver', 'context' => 'Administration de bases de données'],
        ['name' => 'FileZilla', 'context' => 'Transfert FTP/SFTP'],
        ['name' => 'Notion', 'context' => 'Organisation et documentation'],
        ['name' => 'Trello', 'context' => 'Gestion de projet Kanban'],
    ];
    ?>

    <section class="section bg-surface">
        <div class="container-content">
            <div class="section-header">
                <h2 class="section-title">Outils Démontrables</h2>
                <p class="section-subtitle">
                    Outils accompagnés de preuves vérifiables ou visibles dans mes projets.
                </p>
            </div>

            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
                <?php foreach ($demonstrableTools as $tool): ?>
                    <?php if ($tool['url']): ?>
                        <a href="<?= htmlspecialchars($tool['url']) ?>"
                           target="_blank"
                           rel="noopener"
                           class="card group hover:border-primary/30 transition-colors">
                            <div class="card-body flex items-start gap-4">
                                <div class="w-12 h-12 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0 text-primary">
                                    <?= getToolIcon($tool['icon']) ?>
                                </div>
                                <div class="flex-grow">
                                    <h3 class="font-semibold text-text-primary group-hover:text-primary transition-colors flex items-center gap-2">
                                        <?= htmlspecialchars($tool['name']) ?>
                                        <svg class="w-4 h-4 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/>
                                        </svg>
                                    </h3>
                                    <p class="text-sm text-text-secondary mt-1">
                                        <?= htmlspecialchars($tool['description']) ?>
                                    </p>
                                </div>
                            </div>
                        </a>
                    <?php else: ?>
                        <div class="card">
                            <div class="card-body flex items-start gap-4">
                                <div class="w-12 h-12 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0 text-primary">
                                    <?= getToolIcon($tool['icon']) ?>
                                </div>
                                <div class="flex-grow">
                                    <h3 class="font-semibold text-text-primary">
                                        <?= htmlspecialchars($tool['name']) ?>
                                    </h3>
                                    <p class="text-sm text-text-secondary mt-1">
                                        <?= htmlspecialchars($tool['description']) ?>
                                    </p>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>
                <?php endforeach; ?>
            </div>
        </div>
    </section>

    <!-- Section Autres Outils -->
    <section class="section">
        <div class="container-content">
            <div class="section-header">
                <h2 class="section-title">Autres Outils</h2>
                <p class="section-subtitle">
                    Outils utilisés régulièrement dans mes projets.
                </p>
            </div>

            <div class="flex flex-wrap gap-3">
                <?php foreach ($otherTools as $tool): ?>
                    <span class="group relative px-4 py-2 bg-surface-alt rounded-lg text-text-secondary cursor-help border border-transparent hover:border-border transition-colors">
                        <?= htmlspecialchars($tool['name']) ?>
                        <!-- Tooltip -->
                        <span class="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-2 bg-surface-light text-text-primary text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap shadow-lg z-10">
                            <?= htmlspecialchars($tool['context']) ?>
                        </span>
                    </span>
                <?php endforeach; ?>
            </div>
        </div>
    </section>
</main>

<?php include_template('footer'); ?>
