<?php
/**
 * Gestionnaire des ressources (CSS/JS) - Version Atomique
 */

if ( ! defined( 'ABSPATH' ) ) exit;

if ( ! class_exists( 'Avision_Assets' ) ) {

    class Avision_Assets {

        public function enqueue_scripts() {
            wp_enqueue_style( 'avision-google-fonts', 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap', array(), null );

            $styles = array(
                'avision-base'   => 'assets/css/main.css',
                'avision-nav'    => 'assets/css/nav.css',
                'avision-header' => 'assets/css/header.css',
                'avision-score'  => 'assets/css/score.css',
                'avision-levels' => 'assets/css/levels.css',
                'avision-chat'   => 'assets/css/chat.css',
            );

            foreach ( $styles as $handle => $rel_path ) {
                if ( file_exists( AVISION_PATH . $rel_path ) ) {
                    wp_enqueue_style( $handle, AVISION_URL . $rel_path, array(), AVISION_VERSION );
                }
            }

            if ( file_exists( AVISION_PATH . 'assets/js/main.js' ) ) {
                wp_enqueue_script( 'avision-app', AVISION_URL . 'assets/js/main.js', array( 'jquery' ), AVISION_VERSION, true );
                wp_localize_script( 'avision-app', 'avisionSettings', array(
                    'ajaxUrl'  => admin_url( 'admin-ajax.php' ),
                    'nonce'    => wp_create_nonce( 'avision_nonce' ),
                    'is_admin' => is_user_logged_in() && current_user_can( 'manage_options' ),
                ));
            }
        }
    }
}
