<?php include 'files/guardiankey.php'; ?>
<?php
// =================================================================
//        DATA BLOCK FOR FORM PRE-FILLING (Best Practice)
// =================================================================

// 1. Include the central business information file.
//    This creates the $client_info variable with all the data.
include __DIR__ . '/client-information.php';

// 2. Assign info to easy-to-use variables for this form.
//    Using English names for consistency with the database and array keys.
$client_name       = $client_info['name'] ?? '';
$business_name     = $client_info['business_name'] ?? '';
$phone             = $client_info['phone'] ?? '';
$whatsapp          = $client_info['whatsapp'] ?? '';
$email             = $client_info['email'] ?? '';
$website           = $client_info['website'] ?? '';
$operating_cities  = $client_info['operating_cities'] ?? '';
$value_proposition = $client_info['value_proposition'] ?? '';
$logo_url          = $client_info['logo_url'] ?? '';

// Social links come as an array, hence the '?? []' fallback.
$social_links      = $client_info['social_links'] ?? [];

// =================================================================
?>
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Creador De Publicaciones Sociales Con IAMarketing™ Powered By OrozCO</title>
    <meta name="description" content="Crea Posts Que Abordan El Problema, La Solución Y Tu Servicio">
    <meta name="robots" content="noindex, nofollow">

    <link rel="icon" type="image/png" href="img/favicon.png">
    <link rel="apple-touch-icon" href="img/apple-touch-icon.png">

    <?php include 'files/gtm-head.php'; ?>
    
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Barlow:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
    
    <script src="https://unpkg.com/lucide@latest"></script>
    <script src="https://unpkg.com/imask"></script>

    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="tools.css">
    <script src="files/header-manager.js"></script>

    <style>
        .step-header h2 {
            flex-direction: column;
            align-items: flex-start;
            justify-content: flex-start;
            text-align: left;
        }

        .step-header .step-number {
            font-size: 1.25rem;
            font-weight: 900;
            margin-right: 0;
            margin-bottom: 0.25rem;
            display: flex;
            align-items: center;
            color: var(--color-secondary);
            flex-shrink: 0;
            text-align: left;
        }
        .step-header .step-number i {
            margin-right: 0.5rem;
            font-size: 1.5rem;
        }

        .step-header .step-title {
            font-size: 1.4rem;
            font-weight: 900;
            color: #1e293b;
            line-height: 1.2;
            text-transform: uppercase;
            text-align: left;
            width: 100%;
        }

        @media (min-width: 768px) {
            .step-header h2 {
                flex-direction: row;
                align-items: center;
                justify-content: flex-start;
                text-align: left;
            }
            .step-header .step-number {
                font-size: 1.5rem;
                margin-right: 0.5rem;
                margin-bottom: 0;
                text-align: left;
            }
            .step-header .step-number i {
                font-size: 1.8rem;
            }
            .step-header .step-title {
                font-size: 1.5rem;
                width: auto;
                text-align: left;
            }
        }
    </style>
</head>
<body data-page-title="Creador De Publicaciones Sociales"
      data-page-subtitle="Crea Posts Que Abordan El Problema, La Solución Y Tu Servicio"
      data-page-icon="brain">

    <div id="toast-container" class="toast-container"></div>

    <?php include 'files/gtm-body.php'; ?>

<div class="relative min-h-screen md:flex">

    <div id="sidebar-overlay" class="fixed inset-0 bg-black bg-opacity-50 z-30 hidden md:hidden"></div>
    <div id="task-panel-overlay" class="off-canvas-overlay"></div> 
    
    <?php include 'ia-menu.php'; ?>

    <main class="flex-1 overflow-y-auto">
        <header class="bg-white shadow-sm p-4 flex justify-between items-center sticky top-0 z-20">
            <button id="mobile-menu-button" class="md:hidden text-gray-600 hover:text-gray-800">
                <i data-lucide="menu" class="w-6 h-6"></i>
            </button>
            <div class="page-header-container">
                <h2 id="page-title"></h2>
                <p id="page-subtitle"></p>
            </div>
        </header>

        <div id="content-area" class="p-4 md:p-8">
            <section id="social-post-creator" class="dashboard-section">
                <div class="grid grid-cols-1 lg:grid-cols-5 gap-8">

                    <div class="lg:col-span-3">
                        <form id="social-post-form" class="space-y-8 bg-white p-8 rounded-xl shadow-md">
                            <input type="hidden" name="value_proposition" value="<?php echo htmlspecialchars($value_proposition); ?>">
                            <div>
                                <div class="step-header">
                                    <h2 class="text-2xl font-black pb-0 mb-0 flex items-center uppercase">
                                        <span class="step-number"> <i data-lucide="briefcase" class="mr-3 text-[var(--color-secondary)]"></i>
                                            PASO 1:
                                        </span>
                                        <span class="step-title"> Contexto de tu Negocio
                                        </span>
                                    </h2>
                                    <p class="step-subtitle uppercase">Completa la información para personalizar tus publicaciones</p>
                                </div>
                                <div class="border-b border-gray-200 pb-4 mb-6"></div>

                                <div class="space-y-6">
                                    <div>
                                        <label for="business_name" class="block font-bold capitalize text-gray-700 mb-2 text-lg">Nombre De Tu Negocio</label>
                                        <input type="text" id="business_name" name="business_name" class="w-full p-3 bg-gray-50 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-highlight)]" placeholder="Ej: Local Garden" value="<?php echo htmlspecialchars($business_name); ?>">
                                    </div>
                                    <div>
                                        <label for="website_url" class="block font-bold capitalize text-gray-700 mb-2 text-lg">Tu Página Web O Perfil Social (Opcional)</label>
                                        <input type="text" id="website_url" class="w-full p-3 bg-gray-50 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-highlight)]" placeholder="Ej: LocalGarden.com" value="<?php echo htmlspecialchars($website); ?>">
                                    </div>
                                    <div>
                                        <label for="phone_whatsapp" class="block font-bold capitalize text-gray-700 mb-2 text-lg">Tu Teléfono / WhatsApp</label>
                                        <input type="text" id="phone_whatsapp" class="w-full p-3 bg-gray-50 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-highlight)]" placeholder="Ej: (555) 123-4567" value="<?php echo htmlspecialchars($phone); ?>">
                                    </div>
                                    <div>
                                        <label for="service_zone" class="block font-bold capitalize text-gray-700 mb-2 text-lg">Zona Geográfica De Servicio (Opcional)</label>
                                        <input type="text" id="service_zone" placeholder="Ej: Seattle, WA" class="w-full p-3 bg-gray-50 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-highlight)]" value="<?php echo htmlspecialchars($operating_cities); ?>">
                                    </div>
                                </div>
                            </div>

                            <div class="pt-8">
                                <div class="step-header">
                                    <h2 class="text-2xl font-black pb-0 mb-0 flex items-center uppercase">
                                        <span class="step-number"> <i data-lucide="lightbulb" class="mr-3 text-[var(--color-secondary)]"></i>
                                            PASO 2:
                                        </span>
                                        <span class="step-title"> El Corazón de tu Mensaje
                                        </span>
                                    </h2>
                                    <p class="step-subtitle uppercase">Define el problema que resuelves y para quién lo haces</p>
                                </div>
                                <div class="border-b border-gray-200 pb-4 mb-6"></div>

                                <div class="space-y-6">
                                    <div>
                                        <label for="product_service_description_simplified" class="block font-bold capitalize text-gray-700 mb-2 text-lg">Describe Tu Producto o Servicio:</label>
                                        <textarea id="product_service_description_simplified" placeholder="Ej: Mantenimiento De Jardines Para Hogares Y Oficinas" class="w-full p-3 bg-gray-50 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-highlight)]" rows="6" required></textarea>
                                    </div>
                                    <div>
                                        <label for="client_description_simplified" class="block font-bold capitalize text-gray-700 mb-2 text-lg">Describe A Tu Cliente Ideal:</label>
                                        <textarea id="client_description_simplified" placeholder="Ej: Familias Ocupadas Y Empresas En El Área De Miami" class="w-full p-3 bg-gray-50 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-highlight)]" rows="6" required></textarea>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="lg:col-span-2 space-y-8">
                        <img src="img/VideoLeccion.png" alt="VideoLeccion - IAMarketing">
                        <div class="w-full">
                                <div class="bg-black/40 rounded-xl ring-1 ring-white/10 overflow-hidden">
                                    <div class="relative w-full" style="padding-bottom: 56.25%;">
                                        <video class="absolute top-0 left-0 w-full h-full object-cover" id="videoPlayer" controls controlslist="nodownload fullscreen" preload="metadata">
                                            <source src="https://samplelib.com/lib/preview/mp4/sample-5s.mp4" type="video/mp4">
                                            TU NAVEGADOR NO SOPORTA LA ETIQUETA DE VIDEO
                                        </video>
                                        <div id="playOverlay" class="absolute inset-0 flex justify-center items-center cursor-pointer group">
                                            <img src="img/VideoLeccion-IAMarketing.jpg" alt="VideoLeccion - IAMarketing" class="absolute inset-0 w-full h-full object-cover">
                                            <div class="absolute inset-0 w-full h-full bg-black/40 transition-colors group-hover:bg-black/60"></div>
                                            <i data-lucide="play" class="relative w-16 h-16 text-white opacity-80 group-hover:opacity-100 transition-opacity"></i>
                                        </div>
                                    </div>
                                    <div class="p-4 text-white/90 text-sm flex items-center justify-between">
                                        <span class="inline-flex items-center gap-2">
                                            <i data-lucide="play-circle" class="w-4 h-4"></i> Video De Introducción A La Plataforma SiteFlowCMS
                                        </span>
                                        <span class="inline-flex items-center gap-2">
                                            <i data-lucide="clock" class="w-4 h-4"></i> 2–3 min
                                        </span>
                                    </div>
                                </div>
                            </div>
                        <div class="bg-white text-brand-dark p-6 md:p-8 rounded-xl shadow-md">
                            <div class="step-header">
                                    <h2 class="text-2xl font-black pb-0 mb-0 flex items-center uppercase justify-center md:justify-start">
                                        <i data-lucide="book-open" class="mr-3 text-[var(--color-highlight)]"></i>
                                        <span class="step-title">INSTRUCCIONES IMPORTANTES</span>
                                    </h2>
                                     <p class="step-subtitle text-center md:text-left uppercase">REVISA ESTOS PUNTOS DETALLADAMENTE</p>
                                </div>
                            <div class="border-b border-gray-200 pb-4 mb-6"></div>
                            <ul class="space-y-4 text-gray-700">
                                <li class="instructions-list-item"><span class="icon-wrapper"><i data-lucide="file-edit"></i></span><div><strong class="text-brand-dark uppercase">SÉ DESCRIPTIVO:</strong> Cuanto más detalles des sobre tu oferta y tus clientes, mejores y más relevantes serán las publicaciones.</div></li>
                                <li class="instructions-list-item"><span class="icon-wrapper"><i data-lucide="scan"></i></span><div><strong class="text-brand-dark uppercase">ANALIZA TUS POSTS:</strong> La herramienta creará posts en español e inglés con un enfoque estratégico.</div></li>
                                <li class="instructions-list-item"><span class="icon-wrapper"><i data-lucide="link"></i></span><div><strong class="text-brand-dark uppercase">HASHTAGS Y LLAMADOS A LA ACCIÓN:</strong> Cada post vendrá con sugerencias de hashtags y CTAs listos para usarse.</div></li>
                                <li class="instructions-list-item"><span class="icon-wrapper"><i data-lucide="copy"></i></span><div><strong class="text-brand-dark uppercase">COPIA Y PUBLICA:</strong> Elige el post que más te guste, cópialo con un clic y súbelo directamente a tus redes sociales.</div></li>
                            </ul>
                        </div>
                    </div>

                    <div class="lg:col-span-5 bg-white p-6 md:p-8 rounded-xl shadow-md mt-6">
                        <div class="step-header">
                            <h2 class="text-2xl font-black pb-0 mb-0 flex items-center uppercase">
                                <span class="step-number"> <i data-lucide="share-2" class="mr-3 text-[var(--color-secondary)]"></i>
                                    PASO 3:
                                </span>
                                <span class="step-title">
                                    GENERA PUBLICACIONES QUE CONECTEN
                                </span>
                            </h2>
                            <p class="step-subtitle text-center md:text-left uppercase">Obtén contenido estratégico y atractivo para publicar en tus redes sociales</p>
                        </div>
                        <div class="border-b border-gray-200 pb-4 mb-6"></div>
                        <div class="flex flex-col md:flex-row items-center md:justify-between gap-4">
                            <p class="text-lg text-center md:text-left text-gray-700 md:flex-1 md:pr-4 mb-0">Para crear publicaciones que atraigan clientes potenciales, <strong>es importante</strong> que definas el problema que tu servicio resuelve. Con esos datos, nuestra Inteligencia Artificial <strong>IA Marketing</strong> creará tus <strong>Publicaciones Sociales</strong>, para que abordes el problema, ofrezcas la solución y presentes tu servicio de manera persuasiva</p>
                        <div class="flex flex-col items-center">
                            <i data-lucide="brain" class="w-12 h-12 text-[var(--color-primary)] mb-2"></i>
                             <button id="generateBtn" type="submit" form="social-post-form" class="w-full md:w-auto bg-[var(--color-highlight)] text-[var(--color-primary)] font-bold py-4 px-6 rounded-lg hover:scale-105 transition-transform shadow-lg text-lg flex items-center justify-center gap-2 uppercase">
                               <span id="btn-text">GENERAR CON IA MARKETING</span>
                               <i data-lucide="mouse-pointer-click" class="w-6 h-6 animate-bounce"></i>
                               <div id="loader-container" class="hidden ml-3"></div>
                             </button>
                        </div>
                         </div>
                    </div>

                    <div id="result-container" class="lg:col-span-5 mt-8"></div>
                </div>
            </section>
        </div>
    </main>
</div>

<script type="module">
// --- CARGA DOMCONTENT ---
document.addEventListener('DOMContentLoaded', function() {
    lucide.createIcons();
    
    // MENU MOBILE
    const mobileMenuButton = document.getElementById('mobile-menu-button');
    const sidebar = document.getElementById('sidebar');
    const sidebarOverlay = document.getElementById('sidebar-overlay');

    mobileMenuButton.addEventListener('click', () => {
        sidebar.classList.toggle('-translate-x-full');
        sidebarOverlay.classList.toggle('hidden');
    });

    sidebarOverlay.addEventListener('click', () => {
        sidebar.classList.add('-translate-x-full');
        sidebarOverlay.classList.add('hidden');
    });

    // --- NOTIFICACIONES TOAST 
    const urlParams = new URLSearchParams(window.location.search);
    const notificationType = urlParams.get('notification_type');
    const notificationMessage = urlParams.get('notification_message');

    if (notificationType && notificationMessage) {
        if (typeof showToast === 'function') {
            showToast(notificationMessage, notificationType);
        } else {
            console.error("showToast function is not defined. Toast notification might not display.");
        }
    }
    
    // VIDEO PLAYER
    const playOverlay = document.getElementById('playOverlay');
    const videoPlayer = document.getElementById('videoPlayer');
    
    playOverlay.addEventListener('click', () => {
        playOverlay.style.display = 'none';
        videoPlayer.play();
    });
    
     // MASCARA DEL TELEFONO
    const phoneInput = document.getElementById('phone_whatsapp');
    if (phoneInput) {
        IMask(phoneInput, { mask: '(000) 000-0000' });
    }

    // --- Lógica del Generador ---
    const form = document.getElementById('social-post-form');
    const resultContainer = document.getElementById('result-container');
    const generateBtn = document.getElementById('generateBtn');
    const btnText = document.getElementById('btn-text');
    const loaderContainer = document.getElementById('loader-container');

    function setProcessingState(isProcessing) {
        if (isProcessing) {
            loaderContainer.innerHTML = '<div class="w-6 h-6 border-4 border-t-transparent border-[var(--color-primary)] rounded-full animate-spin"></div>';
            loaderContainer.classList.remove('hidden');
            generateBtn.disabled = true;
            generateBtn.classList.add('opacity-50', 'cursor-not-allowed');
            resultContainer.innerHTML = '';
            resultContainer.style.opacity = '0';

            const messages = ["Contactando Con OrozCO IA...", "Analizando Tu Negocio...", "Redactando Publicaciones...", "Afinando El Contenido...", "¡Listas Para Publicar!"];
            let messageIndex = 0;
            btnText.textContent = messages[messageIndex];

            window.loadingInterval = setInterval(() => {
                messageIndex = (messageIndex + 1) % messages.length;
                btnText.textContent = messages[messageIndex];
            }, 2500);

        } else {
            if (window.loadingInterval) {
                clearInterval(window.loadingInterval);
            }
            btnText.textContent = 'Generar Publicaciones Sociales';
            loaderContainer.classList.add('hidden');
            generateBtn.disabled = false;
            generateBtn.classList.remove('opacity-50', 'cursor-not-allowed');
            resultContainer.style.opacity = '1';
        }
    }


    form.addEventListener('submit', async function(event) {
        event.preventDefault();
        
        const requiredInputs = form.querySelectorAll('[required]');
        let allValid = true;
        requiredInputs.forEach(input => {
            if (!input.value.trim()) {
                allValid = false;
                input.classList.add('border-red-500');
            } else {
                 input.classList.remove('border-red-500');
            }
        });
        if (!allValid) {
            if (typeof showToast === 'function') {
                showToast('Por favor, completa todos los campos obligatorios.', 'error');
            }
            return;
        }

        setProcessingState(true);

        const formData = {
            business_name: document.getElementById('business_name').value,
            website_url: document.getElementById('website_url').value,
            phone_whatsapp: document.getElementById('phone_whatsapp').value,
            service_zone: document.getElementById('service_zone').value,
            product_service_description_simplified: document.getElementById('product_service_description_simplified').value,
            client_description_simplified: document.getElementById('client_description_simplified').value
        };

        try {
            const response = await fetch('api/api-creador-de-publicaciones-sociales.php', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify(formData)
            });

            if (!response.ok) {
                const errorData = await response.json();
                throw new Error(errorData.error || `El servidor respondió con un error ${response.status}.`);
            }

            const data = await response.json();
            if(data.error) {
                throw new Error(data.error);
            }
            displayResult(data.posts);
            showToast('¡Publicaciones generadas con éxito!', 'success');

        } catch (error) {
            let errorMessage = "No se pudieron generar las publicaciones. Por favor, revisa los datos e inténtalo de nuevo.";

            try {
                const jsonStartIndex = error.message.indexOf('{');
                if (jsonStartIndex !== -1) {
                    const errorJsonString = error.message.substring(jsonStartIndex);
                    const errorDetails = JSON.parse(errorJsonString);
                    if (errorDetails.error && errorDetails.error.code === 503) {
                        errorMessage = "LO SENTIMOS En Este Momento, Nuestra Inteligencia Artificial Está Saturada. Por favor, Inténtalo De Nuevo En Unos Minutos.";
                    } else {
                        errorMessage += ` Detalles: ${error.message}`;
                    }
                } else {
                    errorMessage += ` Detalles: ${error.message}`;
                }
            } catch (parseError) {
                errorMessage += ` Detalles: ${error.message}`;
            }

            resultContainer.innerHTML = `<div class="bg-red-100 text-center p-4 text-red-700 rounded-lg border border-red-300"><p><strong>Error:</strong> ${errorMessage}</p></div>`;
            resultContainer.style.opacity = '1';
            showToast(errorMessage, 'error');
        } finally {
            setProcessingState(false);
        }
    });

    function displayResult(posts) {
        let allPostsHtml = '';
        posts.forEach((post, index) => {
            const postTitle = (post.type === 'problem') ? 'Enfocada En El Problema' :
                               (post.type === 'solution') ? 'Enfocada En La Solución/Deseo' :
                               (post.type === 'service') ? 'Enfocada En El Servicio/Beneficios' :
                               'Publicación General';
            const postIcon = (post.type === 'problem') ? 'alert-triangle' :
                             (post.type === 'solution') ? 'star' :
                             (post.type === 'service') ? 'badge-check' :
                             'megaphone';
            const postIconColor = (post.type === 'problem') ? 'text-red-500' :
                                  (post.type === 'solution') ? 'text-yellow-500' :
                                  (post.type === 'service') ? 'text-green-500' :
                                  'text-gray-500';

            const formattedEsHashtags = (post.es_hashtags || []).map(tag => `#${tag}`).join(' ');
            const formattedEnHashtags = (post.en_hashtags || []).map(tag => `#${tag}`).join(' ');

            const full_es_text = `${post.es_copy}\n\n${formattedEsHashtags}`;
            const full_en_text = `${post.en_copy}\n\n${formattedEnHashtags}`;

            allPostsHtml += `
                <div class="bg-white p-6 rounded-xl shadow-lg mb-8">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <i data-lucide="${postIcon}" class="${postIconColor} mr-3"></i>Publicación ${index + 1}: ${postTitle}
                    </h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-4">
                        <div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
                            <div class="flex justify-between items-center mb-3">
                                <h4 class="text-lg font-semibold text-gray-700">🇪🇸 Español</h4>
                                <button class="btn-copy" data-copy-text="${encodeURIComponent(full_es_text)}">
                                    <i data-lucide="copy"></i><span class="copy-text">Copiar</span>
                                </button>
                            </div>
                            <div class="space-y-3">
                                <p class="text-gray-800 leading-relaxed whitespace-pre-wrap">${post.es_copy.replace(/\n/g, '<br>')}</p>
                                <p class="text-sm text-[var(--color-secondary)] font-medium">${formattedEsHashtags}</p>
                            </div>
                        </div>
                        <div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
                            <div class="flex justify-between items-center mb-3">
                                <h4 class="text-lg font-semibold text-gray-700">🇺🇸 English</h4>
                                <button class="btn-copy" data-copy-text="${encodeURIComponent(full_en_text)}">
                                     <i data-lucide="copy"></i><span class="copy-text">Copy</span>
                                </button>
                            </div>
                            <div class="space-y-3">
                                <p class="text-gray-800 leading-relaxed whitespace-pre-wrap">${post.en_copy.replace(/\n/g, '<br>')}</p>
                                <p class="text-sm text-[var(--color-primary)] font-medium">${formattedEnHashtags}</p>
                            </div>
                        </div>
                    </div>
                </div>
            `;
        });

        resultContainer.innerHTML = `<div class="ai-response p-6 md:p-8 rounded-xl shadow-md">${allPostsHtml}</div>`;
        lucide.createIcons();
        setTimeout(() => { resultContainer.style.opacity = '1'; resultContainer.style.transform = 'scale(1)'; }, 100);

        resultContainer.querySelectorAll('.btn-copy').forEach(button => {
            button.addEventListener('click', function() {
                const textToCopy = decodeURIComponent(this.dataset.copyText);
                navigator.clipboard.writeText(textToCopy).then(() => {
                    const buttonContent = this;
                    const originalHTML = buttonContent.innerHTML;
                    buttonContent.innerHTML = '<i data-lucide="check"></i><span class="copy-text">Copiado!</span>';
                    lucide.createIcons();
                    buttonContent.classList.add('copied');
                    showToast('Publicación copiada al portapapeles.', 'success');
                    setTimeout(() => {
                        buttonContent.innerHTML = originalHTML;
                        buttonContent.classList.remove('copied');
                        lucide.createIcons({ nodes: [buttonContent] });
                    }, 2000);
                }).catch(err => {
                    console.error('Error al copiar el texto: ', err);
                    showToast('Error al copiar el texto.', 'error');
                });
            });
        });
    }
});
</script>

</body>
</html>