{"id":2214,"date":"2026-05-26T20:29:36","date_gmt":"2026-05-26T23:29:36","guid":{"rendered":"https:\/\/ucachamaquinarias.com.ar\/wp\/?page_id=2214"},"modified":"2026-05-27T09:15:56","modified_gmt":"2026-05-27T12:15:56","slug":"catalogo-ful-v1-1","status":"publish","type":"page","link":"https:\/\/ucachamaquinarias.com.ar\/wp\/catalogo-ful-v1-1\/","title":{"rendered":"Catalogo full v1.1"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"es\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Cat\u00e1logo de Maquinarias Agr\u00edcolas &#8211; Ing. Alejandro Pagliero<\/title>\n    <script src=\"https:\/\/cdn.tailwindcss.com\"><\/script>\n    <script src=\"https:\/\/unpkg.com\/lucide@latest\"><\/script>\n    <script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/xlsx\/0.18.5\/xlsx.full.min.js\"><\/script>\n    <script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/jspdf\/2.5.1\/jspdf.umd.min.js\"><\/script>\n    \n    <style>\n        @media print {\n            @page { margin: 0; } \n            body { \n                padding: 1cm 1.5cm !important; \n                -webkit-print-color-adjust: exact !important; \n                print-color-adjust: exact !important; \n                background-color: white !important;\n                font-family: Arial, sans-serif !important;\n            }\n            .product-card { \n                break-inside: avoid; \n                page-break-inside: avoid; \n                border: 1px solid #d1d5db !important;\n                border-radius: 12px !important;\n                box-shadow: none !important;\n                background-color: white !important;\n                margin-bottom: 0 !important;\n            }\n            .product-image-container {\n                height: 200px !important; \n                background-color: #f3f4f6 !important;\n                border-bottom: 1px solid #e5e7eb !important;\n                border-radius: 12px 12px 0 0 !important;\n            }\n            .product-image-container img, .product-image-container video {\n                object-fit: cover !important;\n            }\n            .print-hidden, .backdrop-blur-md, button { display: none !important; }\n            \n            .print-grid {\n                display: grid !important;\n                grid-template-columns: repeat(2, 1fr) !important;\n                gap: 20px !important;\n            }\n        }\n        \/* Custom scrollbar for categories *\/\n        .scrollbar-hide::-webkit-scrollbar { display: none; }\n        .scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }\n    <\/style>\n<\/head>\n<body class=\"bg-gray-50 text-gray-800 font-sans min-h-screen flex flex-col selection:bg-blue-200 selection:text-blue-900\">\n\n    <header class=\"bg-gradient-to-r from-blue-900 to-blue-800 text-white shadow-lg sticky top-0 z-10 print:shadow-none print:relative print:rounded-2xl print:mb-4\">\n        <div class=\"max-w-7xl mx-auto px-4 py-4 sm:px-6 lg:px-8\">\n            <div class=\"flex flex-col md:flex-row justify-between items-center gap-4\">\n                <div class=\"flex items-center gap-4\">\n                    <div class=\"bg-white\/10 p-2.5 rounded-xl backdrop-blur-sm\">\n                        <i data-lucide=\"tractor\" class=\"h-8 w-8 text-blue-100\"><\/i>\n                    <\/div>\n                    <div>\n                        <h1 class=\"text-2xl font-extrabold tracking-tight leading-tight drop-shadow-sm\">Cat\u00e1logo de Maquinarias Agr\u00edcolas<\/h1>\n                        <p class=\"text-blue-200 font-semibold text-sm tracking-wide print:text-blue-100\">Ing. Alejandro Pagliero<\/p>\n                    <\/div>\n                <\/div>\n                \n                <div class=\"flex flex-wrap items-center gap-4 text-sm print:hidden\">\n                    <label class=\"flex items-center gap-2 cursor-pointer bg-red-600\/90 hover:bg-red-500 px-4 py-2 rounded-xl transition-all duration-300 shadow-sm hover:shadow-md border border-red-500\/30\" id=\"adminToggleContainer\">\n                        <span id=\"adminIconWrapper\"><i data-lucide=\"shield-alert\" class=\"w-4 h-4 text-white\"><\/i><\/span>\n                        <input type=\"checkbox\" class=\"hidden\" id=\"adminToggle\">\n                        <span id=\"adminToggleText\" class=\"font-bold tracking-wide\">Modo Admin: OFF<\/span>\n                    <\/label>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/header>\n\n    <main class=\"max-w-7xl mx-auto px-4 py-8 sm:px-6 lg:px-8 flex-grow print:p-0 print:m-0\">\n        \n        <div class=\"hidden print:flex justify-between items-end mb-6 pb-2 border-b-2 border-gray-200\">\n            <div class=\"text-gray-600 font-medium\">\n                <p>Cotizaci\u00f3n \/ Opciones de Cat\u00e1logo<\/p>\n            <\/div>\n            <div class=\"text-right text-sm text-gray-600 font-medium\">\n                <p>Generado el: <span id=\"printDate\"><\/span><\/p>\n            <\/div>\n        <\/div>\n\n        <!-- BUSCADOR Y FILTROS PREMIUM -->\n        <div class=\"flex flex-col md:flex-row gap-3 justify-between items-center mb-4 print:hidden\">\n            <!-- Search -->\n            <div class=\"relative w-full md:w-1\/3 lg:w-1\/3 group\">\n                <div class=\"absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none\">\n                    <i data-lucide=\"search\" class=\"h-4 w-4 text-gray-400 group-focus-within:text-blue-500 transition-colors\"><\/i>\n                <\/div>\n                <input type=\"text\" id=\"searchInput\" placeholder=\"Buscar maquinaria...\" class=\"w-full pl-10 pr-4 py-2 bg-white border border-gray-200 rounded-full shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm transition-all duration-300\">\n            <\/div>\n            \n            <!-- Controls -->\n            <div class=\"flex flex-wrap items-center gap-2 w-full md:w-auto justify-start md:justify-end\">\n                <!-- Select All -->\n                <button id=\"selectAllBtn\" class=\"flex items-center gap-1.5 px-4 py-2 bg-white border border-gray-200 rounded-full text-sm font-medium text-gray-600 hover:bg-gray-50 hover:text-blue-600 transition-all shadow-sm whitespace-nowrap\">\n                    <i data-lucide=\"check-square\" class=\"w-4 h-4\"><\/i>\n                    <span id=\"selectAllText\">Seleccionar Todos<\/span>\n                <\/button>\n\n                <!-- Condicion (Stock vs A Convenir) -->\n                <div class=\"relative\">\n                    <select id=\"conditionSelect\" class=\"appearance-none pl-9 pr-8 py-2 bg-white border border-gray-200 rounded-full text-sm font-medium text-gray-600 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all shadow-sm cursor-pointer whitespace-nowrap\">\n                        <option value=\"all\">Stock y A Convenir<\/option>\n                        <option value=\"stock\">Solo en Stock<\/option>\n                        <option value=\"convenir\">Solo A Convenir<\/option>\n                    <\/select>\n                    <i data-lucide=\"package\" class=\"absolute left-3 top-1\/2 transform -translate-y-1\/2 w-4 h-4 text-gray-400 pointer-events-none\"><\/i>\n                    <i data-lucide=\"chevron-down\" class=\"absolute right-3 top-1\/2 transform -translate-y-1\/2 w-4 h-4 text-gray-400 pointer-events-none\"><\/i>\n                <\/div>\n\n                <!-- Sort -->\n                <div class=\"relative\">\n                    <select id=\"sortSelect\" class=\"appearance-none pl-9 pr-8 py-2 bg-white border border-gray-200 rounded-full text-sm font-medium text-gray-600 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all shadow-sm cursor-pointer whitespace-nowrap\">\n                        <option value=\"default\">Orden<\/option>\n                        <option value=\"price_asc\">Menor a Mayor $<\/option>\n                        <option value=\"price_desc\">Mayor a Menor $<\/option>\n                    <\/select>\n                    <i data-lucide=\"arrow-up-down\" class=\"absolute left-3 top-1\/2 transform -translate-y-1\/2 w-4 h-4 text-gray-400 pointer-events-none\"><\/i>\n                    <i data-lucide=\"chevron-down\" class=\"absolute right-3 top-1\/2 transform -translate-y-1\/2 w-4 h-4 text-gray-400 pointer-events-none\"><\/i>\n                <\/div>\n\n                <!-- Include Sold Toggle (SOLO ADMIN - Oculto por defecto) -->\n                <label id=\"soldToggleContainer\" class=\"hidden items-center gap-2 px-4 py-2 bg-white border border-gray-200 rounded-full text-sm font-medium text-gray-600 hover:bg-gray-50 cursor-pointer transition-all shadow-sm whitespace-nowrap\">\n                    <div class=\"relative flex items-center\">\n                        <input type=\"checkbox\" id=\"includeSoldToggle\" class=\"sr-only peer\">\n                        <div class=\"w-8 h-4 bg-gray-200 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-blue-600\"><\/div>\n                    <\/div>\n                    Vendidos\n                <\/label>\n            <\/div>\n        <\/div>\n\n        <!-- CATEGOR\u00cdAS (APP DOCK CON ICONOS UNIFORMES Y TOOLTIPS) -->\n        <div class=\"flex justify-start md:justify-center flex-wrap gap-4 mb-8 print:hidden pt-10 pb-4 px-2\" id=\"categoryFilters\">\n            <div class=\"relative group\">\n                <button onclick=\"setCategory('Todas')\" data-cat=\"Todas\" class=\"cat-btn w-14 h-14 flex items-center justify-center rounded-2xl border-2 border-blue-600 bg-blue-600 text-white transition-all shadow-md hover:-translate-y-1\">\n                    <i data-lucide=\"layout-grid\" class=\"w-6 h-6\"><\/i>\n                <\/button>\n                <div class=\"absolute -top-10 left-1\/2 transform -translate-x-1\/2 bg-gray-900 text-white text-[11px] font-bold px-3 py-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none whitespace-nowrap z-20 shadow-xl\">\n                    Todas\n                    <div class=\"absolute -bottom-1 left-1\/2 transform -translate-x-1\/2 w-2 h-2 bg-gray-900 rotate-45\"><\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"relative group\">\n                <button onclick=\"setCategory('Tractores')\" data-cat=\"Tractores\" class=\"cat-btn w-14 h-14 flex items-center justify-center rounded-2xl border border-gray-200 bg-white text-gray-500 hover:text-blue-600 hover:border-blue-300 hover:bg-blue-50 transition-all shadow-sm hover:shadow-md hover:-translate-y-1\">\n                    <i data-lucide=\"tractor\" class=\"w-6 h-6\"><\/i>\n                <\/button>\n                <div class=\"absolute -top-10 left-1\/2 transform -translate-x-1\/2 bg-gray-900 text-white text-[11px] font-bold px-3 py-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none whitespace-nowrap z-20 shadow-xl\">\n                    Tractores\n                    <div class=\"absolute -bottom-1 left-1\/2 transform -translate-x-1\/2 w-2 h-2 bg-gray-900 rotate-45\"><\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"relative group\">\n                <button onclick=\"setCategory('Sembradoras')\" data-cat=\"Sembradoras\" class=\"cat-btn w-14 h-14 flex items-center justify-center rounded-2xl border border-gray-200 bg-white text-gray-500 hover:text-blue-600 hover:border-blue-300 hover:bg-blue-50 transition-all shadow-sm hover:shadow-md hover:-translate-y-1\">\n                    <i data-lucide=\"sprout\" class=\"w-6 h-6\"><\/i>\n                <\/button>\n                <div class=\"absolute -top-10 left-1\/2 transform -translate-x-1\/2 bg-gray-900 text-white text-[11px] font-bold px-3 py-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none whitespace-nowrap z-20 shadow-xl\">\n                    Sembradoras\n                    <div class=\"absolute -bottom-1 left-1\/2 transform -translate-x-1\/2 w-2 h-2 bg-gray-900 rotate-45\"><\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"relative group\">\n                <button onclick=\"setCategory('Tolvas')\" data-cat=\"Tolvas\" class=\"cat-btn w-14 h-14 flex items-center justify-center rounded-2xl border border-gray-200 bg-white text-gray-500 hover:text-blue-600 hover:border-blue-300 hover:bg-blue-50 transition-all shadow-sm hover:shadow-md hover:-translate-y-1\">\n                    <i data-lucide=\"truck\" class=\"w-6 h-6\"><\/i>\n                <\/button>\n                <div class=\"absolute -top-10 left-1\/2 transform -translate-x-1\/2 bg-gray-900 text-white text-[11px] font-bold px-3 py-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none whitespace-nowrap z-20 shadow-xl\">\n                    Tolvas y Acoplados\n                    <div class=\"absolute -bottom-1 left-1\/2 transform -translate-x-1\/2 w-2 h-2 bg-gray-900 rotate-45\"><\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"relative group\">\n                <button onclick=\"setCategory('Forraje')\" data-cat=\"Forraje\" class=\"cat-btn w-14 h-14 flex items-center justify-center rounded-2xl border border-gray-200 bg-white text-gray-500 hover:text-blue-600 hover:border-blue-300 hover:bg-blue-50 transition-all shadow-sm hover:shadow-md hover:-translate-y-1\">\n                    <i data-lucide=\"wheat\" class=\"w-6 h-6\"><\/i>\n                <\/button>\n                <div class=\"absolute -top-10 left-1\/2 transform -translate-x-1\/2 bg-gray-900 text-white text-[11px] font-bold px-3 py-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none whitespace-nowrap z-20 shadow-xl\">\n                    Forraje y Ganader\u00eda\n                    <div class=\"absolute -bottom-1 left-1\/2 transform -translate-x-1\/2 w-2 h-2 bg-gray-900 rotate-45\"><\/div>\n                <\/div>\n            <\/div>\n            \n            <div class=\"relative group\">\n                <button onclick=\"setCategory('Implementos')\" data-cat=\"Implementos\" class=\"cat-btn w-14 h-14 flex items-center justify-center rounded-2xl border border-gray-200 bg-white text-gray-500 hover:text-blue-600 hover:border-blue-300 hover:bg-blue-50 transition-all shadow-sm hover:shadow-md hover:-translate-y-1\">\n                    <i data-lucide=\"settings-2\" class=\"w-6 h-6\"><\/i>\n                <\/button>\n                <div class=\"absolute -top-10 left-1\/2 transform -translate-x-1\/2 bg-gray-900 text-white text-[11px] font-bold px-3 py-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none whitespace-nowrap z-20 shadow-xl\">\n                    Implementos \/ Otros\n                    <div class=\"absolute -bottom-1 left-1\/2 transform -translate-x-1\/2 w-2 h-2 bg-gray-900 rotate-45\"><\/div>\n                <\/div>\n            <\/div>\n        <\/div>\n\n        <div id=\"adminNotification\" class=\"hidden mb-8 bg-red-50 border border-red-100 p-5 rounded-2xl shadow-sm print:hidden\">\n            <div class=\"flex items-start\">\n                <div class=\"bg-red-100 p-2 rounded-lg mr-4 flex-shrink-0\"><i data-lucide=\"shield-check\" class=\"h-6 w-6 text-red-600\"><\/i><\/div>\n                <div>\n                    <h3 class=\"text-base font-bold text-red-900\">Modo Administrador Activado<\/h3>\n                    <p class=\"text-sm text-red-700 mt-1 leading-relaxed\">Est\u00e1s viendo los precios internos. <strong>El p\u00fablico general solo ve la foto y el nombre de la m\u00e1quina.<\/strong> Al generar PDF o compartir m\u00faltiples en este modo, ir\u00e1n con precio.<\/p>\n                <\/div>\n            <\/div>\n        <\/div>\n\n        <div id=\"loadingIndicator\" class=\"py-16 text-center text-gray-500 hidden print:hidden\">\n            <i data-lucide=\"loader-2\" class=\"h-10 w-10 mx-auto text-blue-500 mb-4 animate-spin\"><\/i>\n            <p class=\"text-base font-medium text-gray-600\">Sincronizando cat\u00e1logo con el servidor&#8230;<\/p>\n        <\/div>\n\n        <!-- Banner de M\u00e1quina \u00danica -->\n        <div id=\"singleItemBanner\" class=\"hidden mb-6 bg-blue-50 border border-blue-200 p-4 rounded-2xl flex flex-col sm:flex-row justify-between items-center gap-4 print:hidden\">\n            <div>\n                <h3 class=\"text-blue-800 font-extrabold text-lg\">Viendo una m\u00e1quina en espec\u00edfico<\/h3>\n                <p class=\"text-sm text-blue-600 font-medium mt-1\">Se te ha compartido este enlace directo.<\/p>\n            <\/div>\n            <a href=\"?\" class=\"bg-blue-600 hover:bg-blue-700 text-white px-5 py-2.5 rounded-xl font-bold text-sm transition-all shadow-sm flex items-center gap-2 w-full sm:w-auto justify-center hover:-translate-y-0.5\">\n                <i data-lucide=\"list\" class=\"w-4 h-4\"><\/i> Ver todo el cat\u00e1logo\n            <\/a>\n        <\/div>\n\n        <div id=\"productGrid\" class=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 print-grid\">\n            <!-- La cuadr\u00edcula se llena con JS -->\n        <\/div>\n\n        <div id=\"paginationContainer\" class=\"flex justify-center items-center gap-4 mt-10 mb-4 print:hidden\">\n            <!-- Paginaci\u00f3n se llena con JS -->\n        <\/div>\n\n    <\/main>\n\n    <footer id=\"adminFooter\" class=\"bg-gray-900 text-gray-400 text-sm py-6 text-center mt-auto print:hidden shadow-inner border-t border-gray-800\">\n        <p>Sincronizaci\u00f3n autom\u00e1tica activa <strong class=\"text-green-400 tracking-wide\">\ud83d\udfe2 Online<\/strong><\/p>\n    <\/footer>\n\n    <div id=\"floatingActions\" class=\"fixed bottom-8 left-1\/2 transform -translate-x-1\/2 flex gap-4 z-40 hidden print:hidden\">\n        <button onclick=\"shareSelection()\" class=\"bg-blue-600 hover:bg-blue-500 text-white px-5 md:px-6 py-3 rounded-full shadow-2xl font-bold flex items-center gap-2 transition-all hover:-translate-y-1 ring-4 ring-white\/50 backdrop-blur-sm\">\n            <i data-lucide=\"share-2\" class=\"w-5 h-5\"><\/i>\n            <span class=\"text-sm md:text-base\">Enviar Opciones<\/span>\n        <\/button>\n        <button onclick=\"generateSelectedPDF()\" class=\"bg-red-600 hover:bg-red-500 text-white px-5 md:px-6 py-3 rounded-full shadow-2xl font-bold flex items-center gap-2 transition-all hover:-translate-y-1 ring-4 ring-white\/50 backdrop-blur-sm\">\n            <i data-lucide=\"file-text\" class=\"w-5 h-5\"><\/i>\n            <span class=\"text-sm md:text-base\">Cat\u00e1logo (<span id=\"pdfCount\">0<\/span>)<\/span>\n        <\/button>\n    <\/div>\n\n    <!-- MODAL GALER\u00cdA MULTIMEDIA (FOTOS Y VIDEOS) -->\n    <div id=\"imageModal\" class=\"fixed inset-0 z-[100] hidden bg-black\/95 flex items-center justify-center p-4 backdrop-blur-md transition-opacity duration-300 print:hidden\">\n        <button onclick=\"closeImageModal()\" class=\"absolute top-6 right-6 text-white\/70 hover:text-white bg-white\/10 hover:bg-white\/20 p-3 rounded-full transition-all backdrop-blur-sm z-[110]\"><i data-lucide=\"x\" class=\"w-6 h-6\"><\/i><\/button>\n        \n        <button id=\"modalPrevBtn\" onclick=\"prevModalImage(event)\" class=\"absolute left-4 md:left-8 top-1\/2 transform -translate-y-1\/2 text-white\/70 hover:text-white bg-white\/10 hover:bg-white\/20 p-3 rounded-full transition-all backdrop-blur-sm hidden z-[110]\">\n            <i data-lucide=\"chevron-left\" class=\"w-6 h-6\"><\/i>\n        <\/button>\n        <button id=\"modalNextBtn\" onclick=\"nextModalImage(event)\" class=\"absolute right-4 md:right-8 top-1\/2 transform -translate-y-1\/2 text-white\/70 hover:text-white bg-white\/10 hover:bg-white\/20 p-3 rounded-full transition-all backdrop-blur-sm hidden z-[110]\">\n            <i data-lucide=\"chevron-right\" class=\"w-6 h-6\"><\/i>\n        <\/button>\n\n        <div class=\"relative max-w-6xl w-full h-full flex flex-col items-center justify-center\">\n            <div id=\"modalMediaContainer\" class=\"flex items-center justify-center w-full h-[80vh]\"><\/div>\n            <div class=\"flex flex-col sm:flex-row items-center gap-4 mt-6\">\n                <p id=\"modalTitle\" class=\"text-white text-xl font-bold text-center px-4 tracking-wide\"><\/p>\n                <span id=\"modalCounter\" class=\"bg-white\/20 text-white px-3 py-1 rounded-full text-sm font-bold hidden backdrop-blur-sm\"><\/span>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <div id=\"passwordModal\" class=\"fixed inset-0 z-[200] hidden bg-gray-900\/60 flex items-center justify-center p-4 backdrop-blur-sm transition-opacity print:hidden\">\n        <div class=\"bg-white rounded-3xl shadow-2xl p-8 w-full max-w-sm transform transition-all scale-100\">\n            <div class=\"flex justify-center mb-6\"><div class=\"bg-blue-50 p-4 rounded-full\"><i data-lucide=\"lock\" class=\"w-8 h-8 text-blue-600\"><\/i><\/div><\/div>\n            <h3 class=\"text-xl font-extrabold text-gray-900 mb-2 text-center\">Acceso Restringido<\/h3>\n            <p class=\"text-sm text-gray-500 mb-6 text-center\">Ingresa la clave para ver precios y datos internos.<\/p>\n            <input type=\"password\" id=\"adminPasswordInput\" class=\"w-full px-5 py-3 border border-gray-200 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500 mb-6 bg-gray-50 transition-all font-medium text-center tracking-widest text-lg\" placeholder=\"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\">\n            <div class=\"flex justify-end gap-3\">\n                <button onclick=\"closePasswordModal()\" class=\"flex-1 px-4 py-2.5 text-gray-600 bg-gray-100 hover:bg-gray-200 rounded-xl transition-colors font-bold\">Cancelar<\/button>\n                <button onclick=\"verifyPassword()\" class=\"flex-1 px-4 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-xl transition-colors font-bold shadow-md shadow-blue-500\/30\">Ingresar<\/button>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <div id=\"toast\" class=\"fixed bottom-6 right-6 bg-gray-900\/95 text-white px-6 py-4 rounded-2xl shadow-2xl transform transition-all duration-300 translate-y-24 opacity-0 z-[300] flex items-center gap-3 backdrop-blur-md border border-gray-800 print:hidden\">\n        <i data-lucide=\"check-circle-2\" class=\"text-green-400 w-5 h-5\"><\/i><span id=\"toastMsg\" class=\"font-medium tracking-wide text-sm\"><\/span>\n    <\/div>\n\n    <script>\n        const dateObj = new Date();\n        document.getElementById('printDate').textContent = dateObj.toLocaleDateString('es-AR');\n\n        let appData = [];\n        let state = { \n            searchTerm: '', \n            isAdmin: false, \n            includeSold: false, \n            sortBy: 'default',\n            conditionFilter: 'all', \n            selectedItems: new Set(),\n            currentPage: 1,      \n            itemsPerPage: 12,\n            activeCategory: 'Todas'\n        };\n        let toastTimeout;\n\n        const CATEGORIES = {\n            'Todas': [],\n            'Tractores': ['tractor', 'tractores'],\n            'Sembradoras': ['sembradora', 'sembradoras'],\n            'Tolvas': ['tolva', 'acoplado', 'mixer', 'racionador', 'carro', 'silera', 'extractor', 'embolsadora', 'descargadora', 'batan'],\n            'Forraje': ['moledora', 'desmalezadora', 'rotoenfardadora', 'enfardadora', 'segadora', 'rastrillo', 'baima', 'picadora', 'hileradora', 'enrolladora'],\n            'Implementos': ['pala', 'chimango', 'escardillo', 'rastra', 'pulverizadora', 'fertilizadora', 'cargadora', 'cinta', 'niveladora', 'hoyadora', 'disco', 'rolo', 'tanque']\n        };\n\n        let activeModalId = null;\n        let currentGallery = [];\n        let currentGalleryIndex = 0;\n\n        const urlParams = new URLSearchParams(window.location.search);\n        const singleMachineId = urlParams.get('id');\n\n        const searchInput = document.getElementById('searchInput');\n        const includeSoldToggle = document.getElementById('includeSoldToggle');\n        const sortSelect = document.getElementById('sortSelect');\n        const conditionSelect = document.getElementById('conditionSelect');\n        const selectAllBtn = document.getElementById('selectAllBtn');\n        const selectAllText = document.getElementById('selectAllText');\n        const adminToggleContainer = document.getElementById('adminToggleContainer');\n        const adminToggle = document.getElementById('adminToggle');\n        const adminToggleText = document.getElementById('adminToggleText');\n        const adminNotification = document.getElementById('adminNotification');\n        const productGrid = document.getElementById('productGrid');\n        const paginationContainer = document.getElementById('paginationContainer'); \n        const loadingIndicator = document.getElementById('loadingIndicator');\n        const toast = document.getElementById('toast');\n        const toastMsg = document.getElementById('toastMsg');\n        \n        const imageModal = document.getElementById('imageModal');\n        const modalTitle = document.getElementById('modalTitle');\n        const modalPrevBtn = document.getElementById('modalPrevBtn');\n        const modalNextBtn = document.getElementById('modalNextBtn');\n        const modalCounter = document.getElementById('modalCounter');\n\n        const passwordModal = document.getElementById('passwordModal');\n        const adminPasswordInput = document.getElementById('adminPasswordInput');\n        const floatingActions = document.getElementById('floatingActions');\n        const pdfCount = document.getElementById('pdfCount');\n\n        const escapeHTML = (str) => {\n            if (str === null || str === undefined) return '';\n            return String(str).replace(\/&\/g, '&amp;').replace(\/<\/g, '&lt;').replace(\/>\/g, '&gt;').replace(\/\"\/g, '&quot;').replace(\/'\/g, '&#039;');\n        };\n\n        const formatCurrency = (value, currency = 'ARS') => {\n            if (!value) return currency === 'USD' ? 'U$D 0' : '$ 0';\n            return new Intl.NumberFormat('es-AR', { style: 'currency', currency: currency, maximumFractionDigits: 0 }).format(value);\n        };\n\n        const showToast = (message) => {\n            clearTimeout(toastTimeout);\n            toastMsg.textContent = message;\n            toast.classList.remove('translate-y-24', 'opacity-0');\n            toastTimeout = setTimeout(() => { toast.classList.add('translate-y-24', 'opacity-0'); }, 4000);\n        };\n\n        window.toggleSelection = (encId) => { \n            const id = decodeURIComponent(encId);\n            state.selectedItems.has(id) ? state.selectedItems.delete(id) : state.selectedItems.add(id); \n            render(); \n        };\n\n        window.goToPage = (pageNumber) => {\n            state.currentPage = pageNumber;\n            render();\n            window.scrollTo({ top: 0, behavior: 'smooth' });\n        };\n\n        window.setCategory = (cat) => {\n            state.activeCategory = cat;\n            state.currentPage = 1;\n\n            document.querySelectorAll('.cat-btn').forEach(btn => {\n                if (btn.getAttribute('data-cat') === cat) {\n                    btn.classList.remove('bg-white', 'text-gray-500', 'border-gray-200', 'hover:border-blue-300', 'hover:bg-blue-50', 'hover:text-blue-600');\n                    btn.classList.add('bg-blue-600', 'text-white', 'border-blue-600', 'border-2');\n                } else {\n                    btn.classList.remove('bg-blue-600', 'text-white', 'border-blue-600', 'border-2');\n                    btn.classList.add('bg-white', 'text-gray-500', 'border-gray-200', 'hover:border-blue-300', 'hover:bg-blue-50', 'hover:text-blue-600');\n                }\n            });\n            render();\n        };\n\n        const getFilteredData = () => {\n            return appData.filter(item => {\n                if (singleMachineId && String(item.id) !== singleMachineId) return false;\n\n                const safeName = (item.name || '').toLowerCase();\n                const safeId = (item.id || '').toString();\n                const safeSearch = state.searchTerm.toLowerCase();\n                \n                const matchesSearch = safeName.includes(safeSearch) || safeId.includes(safeSearch);\n                const matchesStatus = state.includeSold ? true : (item.status === 'DISPONIBLE');\n                \n                if (state.conditionFilter === 'stock' && item.isToAgree) return false;\n                if (state.conditionFilter === 'convenir' && !item.isToAgree) return false;\n\n                let matchesCategory = true;\n                if (state.activeCategory !== 'Todas') {\n                    const keywords = CATEGORIES[state.activeCategory] || [];\n                    matchesCategory = keywords.some(kw => safeName.includes(kw));\n                    \n                    if (state.activeCategory === 'Implementos' && !matchesCategory) {\n                        const otherKeywords = [\n                            ...CATEGORIES['Tractores'], ...CATEGORIES['Sembradoras'], \n                            ...CATEGORIES['Tolvas'], ...CATEGORIES['Forraje']\n                        ];\n                        const belongsToOther = otherKeywords.some(kw => safeName.includes(kw));\n                        if (!belongsToOther) matchesCategory = true; \n                    }\n                }\n\n                return matchesSearch && matchesStatus && matchesCategory;\n            });\n        };\n\n        \/\/ --- GALER\u00cdA CON SOPORTE PARA VIDEO ---\n        window.openImageModal = (encId, encName) => { \n            const id = decodeURIComponent(encId);\n            const name = decodeURIComponent(encName);\n            \n            activeModalId = id; \n            modalTitle.textContent = name; \n            imageModal.classList.remove('hidden'); \n            document.body.style.overflow = 'hidden'; \n            \n            currentGallery = [{ type: 'image', src: `\/maquinarias\/${id}.jpg`, originalIndex: 0 }];\n            currentGalleryIndex = 0;\n            renderModalGallery();\n\n            for (let i = 1; i <= 10; i++) {\n                let imgUrl = `\/maquinarias\/${id}.${i}.jpg`;\n                let img = new Image();\n                img.onload = () => {\n                    if (activeModalId === id && !currentGallery.some(m => m.src === imgUrl)) {\n                        currentGallery.push({ type: 'image', src: imgUrl, originalIndex: i });\n                        currentGallery.sort((a, b) => a.originalIndex - b.originalIndex);\n                        renderModalGallery(); \n                    }\n                };\n                img.src = imgUrl; \n\n                let vidUrl = `\/maquinarias\/${id}.${i}.mp4`;\n                let vid = document.createElement('video');\n                vid.onloadedmetadata = () => {\n                    if (activeModalId === id && !currentGallery.some(m => m.src === vidUrl)) {\n                        currentGallery.push({ type: 'video', src: vidUrl, originalIndex: i });\n                        currentGallery.sort((a, b) => a.originalIndex - b.originalIndex);\n                        renderModalGallery(); \n                    }\n                };\n                vid.src = vidUrl;\n            }\n            try { lucide.createIcons(); } catch(e){} \n        };\n\n        window.nextModalImage = (e) => {\n            if(e) e.stopPropagation();\n            if (currentGallery.length <= 1) return;\n            currentGalleryIndex = (currentGalleryIndex + 1) % currentGallery.length;\n            renderModalGallery();\n        };\n\n        window.prevModalImage = (e) => {\n            if(e) e.stopPropagation();\n            if (currentGallery.length <= 1) return;\n            currentGalleryIndex = (currentGalleryIndex - 1 + currentGallery.length) % currentGallery.length;\n            renderModalGallery();\n        };\n\n        function renderModalGallery() {\n            const container = document.getElementById('modalMediaContainer');\n            container.innerHTML = '';\n            const media = currentGallery[currentGalleryIndex];\n            \n            if (media) {\n                if (media.type === 'video') {\n                    const v = document.createElement('video');\n                    v.src = media.src;\n                    v.controls = true;\n                    v.autoplay = true;\n                    v.playsInline = true;\n                    v.className = \"max-h-[80vh] max-w-full object-contain rounded-2xl shadow-2xl ring-1 ring-white\/10 transition-all duration-300\";\n                    container.appendChild(v);\n                } else {\n                    const i = document.createElement('img');\n                    i.src = media.src;\n                    i.className = \"max-h-[80vh] max-w-full object-contain rounded-2xl shadow-2xl ring-1 ring-white\/10 transition-all duration-300\";\n                    container.appendChild(i);\n                }\n            }\n            \n            if (currentGallery.length > 1) {\n                modalPrevBtn.classList.remove('hidden');\n                modalNextBtn.classList.remove('hidden');\n                modalCounter.classList.remove('hidden');\n                modalCounter.textContent = `${currentGalleryIndex + 1} \/ ${currentGallery.length}`;\n            } else {\n                modalPrevBtn.classList.add('hidden');\n                modalNextBtn.classList.add('hidden');\n                modalCounter.classList.add('hidden');\n            }\n        }\n\n        window.closeImageModal = () => { \n            activeModalId = null; \n            imageModal.classList.add('hidden'); \n            document.body.style.overflow = 'auto'; \n            setTimeout(() => { document.getElementById('modalMediaContainer').innerHTML = ''; }, 300); \n        };\n        \n        imageModal.addEventListener('click', (e) => { \n            if (e.target === imageModal || (e.target.parentElement === imageModal && e.target.tagName !== 'BUTTON')) {\n                closeImageModal(); \n            }\n        });\n        \n        document.addEventListener('keydown', (e) => { \n            if (!imageModal.classList.contains('hidden')) {\n                if (e.key === 'Escape') closeImageModal();\n                if (e.key === 'ArrowRight') nextModalImage();\n                if (e.key === 'ArrowLeft') prevModalImage();\n            }\n        });\n\n        \/\/ --- GENERADOR DE CAT\u00c1LOGO (M\u00daLTIPLE SIN PRECIOS) ---\n        window.generateSelectedPDF = async () => {\n            if (state.selectedItems.size === 0) return;\n            showToast(\"Generando Cat\u00e1logo PDF, aguard\u00e1 un momento...\");\n            const itemsToPrint = appData.filter(item => state.selectedItems.has(item.id));\n            const { jsPDF } = window.jspdf;\n            const pdf = new jsPDF({ orientation: \"portrait\", unit: \"px\", format: [1240, 1754] });\n            let logoImg = null;\n            try {\n                logoImg = await new Promise((resolve, reject) => {\n                    const l = new Image(); l.crossOrigin = \"Anonymous\";\n                    l.onload = () => resolve(l); l.onerror = () => reject();\n                    l.src = `\/logo.jpg`;\n                });\n            } catch(e) {}\n\n            for (let i = 0; i < itemsToPrint.length; i++) {\n                const item = itemsToPrint[i];\n                const id = item.id;\n                if (i > 0) pdf.addPage();\n                const canvas = document.createElement('canvas');\n                canvas.width = 1240; canvas.height = 1754;\n                const ctx = canvas.getContext('2d');\n                ctx.fillStyle = '#ffffff'; ctx.fillRect(0, 0, canvas.width, canvas.height);\n\n                try {\n                    let img = null;\n                    try {\n                        img = await new Promise((resolve, reject) => {\n                            const imgObj = new Image(); imgObj.crossOrigin = \"Anonymous\";\n                            imgObj.onload = () => resolve(imgObj); imgObj.onerror = () => reject();\n                            imgObj.src = `\/maquinarias\/${id}.jpg`;\n                        });\n                    } catch(e) {}\n\n                    ctx.fillStyle = '#f8fafc'; ctx.fillRect(0, 0, canvas.width, 250);\n                    ctx.fillStyle = '#2563eb'; ctx.fillRect(0, 250, canvas.width, 10);\n\n                    if (logoImg) {\n                        const logoH = 150;\n                        const logoW = logoImg.width * (logoH \/ logoImg.height);\n                        ctx.drawImage(logoImg, 80, 50, logoW, logoH);\n                    } else {\n                        ctx.fillStyle = '#1e3a8a'; ctx.font = 'bold 60px Arial'; ctx.textAlign = 'left';\n                        ctx.fillText('UCACHA MAQUINARIAS', 80, 120);\n                        ctx.fillStyle = '#64748b'; ctx.font = '30px Arial';\n                        ctx.fillText('Ing. Alejandro Pagliero', 80, 170);\n                    }\n\n                    ctx.textAlign = 'right'; ctx.fillStyle = '#1e293b'; ctx.font = 'bold 50px Arial';\n                    ctx.fillText('CAT\u00c1LOGO', 1160, 110);\n                    ctx.fillStyle = '#64748b'; ctx.font = '30px Arial';\n                    const dateStr = new Date().toLocaleDateString('es-AR');\n                    ctx.fillText(`Fecha: ${dateStr}`, 1160, 160);\n                    ctx.fillText(`C\u00f3d. Referencia: #${id}`, 1160, 200);\n\n                    ctx.textAlign = 'left'; ctx.fillStyle = '#0f172a'; ctx.font = 'bold 55px Arial';\n                    const words = item.name.split(' ');\n                    let line = ''; let lineY = 350;\n                    for(let n = 0; n < words.length; n++) {\n                        const testLine = line + words[n] + ' ';\n                        if (ctx.measureText(testLine).width > 1080 && n > 0) {\n                            ctx.fillText(line, 80, lineY);\n                            line = words[n] + ' '; lineY += 70;\n                        } else { line = testLine; }\n                    }\n                    ctx.fillText(line, 80, lineY);\n\n                    const imgY = lineY + 60; const imgH = 950; const imgW = 1080;\n                    ctx.fillStyle = '#f1f5f9'; ctx.fillRect(80, imgY, imgW, imgH);\n                    if (img) {\n                        const scale = Math.min(imgW \/ img.width, imgH \/ img.height);\n                        const w = img.width * scale; const h = img.height * scale;\n                        const x = 80 + (imgW - w) \/ 2; const y = imgY + (imgH - h) \/ 2;\n                        ctx.drawImage(img, x, y, w, h);\n                    }\n                    ctx.strokeStyle = '#e2e8f0'; ctx.lineWidth = 2; ctx.strokeRect(80, imgY, imgW, imgH);\n\n                    ctx.fillStyle = '#1e293b'; ctx.fillRect(0, 1554, canvas.width, 200);\n                    ctx.fillStyle = '#f8fafc'; ctx.font = 'bold 35px Arial'; ctx.textAlign = 'center';\n                    ctx.fillText('Ucacha Maquinarias - Ucacha, C\u00f3rdoba', canvas.width \/ 2, 1630);\n                    ctx.font = '28px Arial'; ctx.fillStyle = '#94a3b8';\n                    ctx.fillText('Tel \/ WhatsApp: 3535 084 927 | Web: ucachamaquinarias.com.ar', canvas.width \/ 2, 1680);\n\n                    const pdfData = canvas.toDataURL('image\/jpeg', 0.8);\n                    pdf.addImage(pdfData, 'JPEG', 0, 0, 1240, 1754);\n                } catch (err) { console.error(\"Error al renderizar p\u00e1gina de PDF:\", err); }\n            }\n            pdf.save(`Catalogo_Ucacha_Maquinarias.pdf`);\n            showToast(\"\u00a1Cat\u00e1logo PDF descargado exitosamente!\");\n        };\n\n        \/\/ --- GENERADOR DE PRESUPUESTO PDF FORMAL (INDIVIDUAL - ADMIN) ---\n        window.generatePDF = async (encId) => {\n            const id = decodeURIComponent(encId);\n            const item = appData.find(i => String(i.id) === id);\n            if (!item) return;\n            showToast(\"Generando Presupuesto Formal (PDF)...\");\n\n            const canvas = document.createElement('canvas');\n            canvas.width = 1240; canvas.height = 1754;\n            const ctx = canvas.getContext('2d');\n            ctx.fillStyle = '#ffffff'; ctx.fillRect(0, 0, canvas.width, canvas.height);\n\n            try {\n                const img = await new Promise((resolve, reject) => {\n                    const i = new Image(); i.crossOrigin = \"Anonymous\";\n                    i.onload = () => resolve(i); i.onerror = () => reject();\n                    i.src = `\/maquinarias\/${id}.jpg`;\n                });\n\n                let logoImg = null;\n                try {\n                    logoImg = await new Promise((resolve, reject) => {\n                        const l = new Image(); l.crossOrigin = \"Anonymous\";\n                        l.onload = () => resolve(l); l.onerror = () => reject();\n                        l.src = `\/logo.jpg`;\n                    });\n                } catch(e) {}\n\n                ctx.fillStyle = '#f8fafc'; ctx.fillRect(0, 0, canvas.width, 250);\n                ctx.fillStyle = '#2563eb'; ctx.fillRect(0, 250, canvas.width, 10);\n\n                if (logoImg) {\n                    const logoH = 150;\n                    const logoW = logoImg.width * (logoH \/ logoImg.height);\n                    ctx.drawImage(logoImg, 80, 50, logoW, logoH);\n                } else {\n                    ctx.fillStyle = '#1e3a8a'; ctx.font = 'bold 60px Arial'; ctx.textAlign = 'left';\n                    ctx.fillText('UCACHA MAQUINARIAS', 80, 120);\n                    ctx.fillStyle = '#64748b'; ctx.font = '30px Arial';\n                    ctx.fillText('Ing. Alejandro Pagliero', 80, 170);\n                }\n\n                ctx.textAlign = 'right'; ctx.fillStyle = '#1e293b'; ctx.font = 'bold 50px Arial';\n                ctx.fillText('PRESUPUESTO', 1160, 110);\n                ctx.fillStyle = '#64748b'; ctx.font = '30px Arial';\n                const dateStr = new Date().toLocaleDateString('es-AR');\n                ctx.fillText(`Fecha: ${dateStr}`, 1160, 160);\n                ctx.fillText(`C\u00f3d. Referencia: #${id}`, 1160, 200);\n\n                ctx.textAlign = 'left'; ctx.fillStyle = '#0f172a'; ctx.font = 'bold 55px Arial';\n                const words = item.name.split(' ');\n                let line = ''; let lineY = 350;\n                for(let n = 0; n < words.length; n++) {\n                    const testLine = line + words[n] + ' ';\n                    if (ctx.measureText(testLine).width > 1080 && n > 0) {\n                        ctx.fillText(line, 80, lineY);\n                        line = words[n] + ' '; lineY += 70;\n                    } else { line = testLine; }\n                }\n                ctx.fillText(line, 80, lineY);\n\n                const imgY = lineY + 60; const imgH = 600; const imgW = 1080;\n                const scale = Math.min(imgW \/ img.width, imgH \/ img.height);\n                const w = img.width * scale; const h = img.height * scale;\n                const x = 80 + (imgW - w) \/ 2; const y = imgY + (imgH - h) \/ 2;\n                \n                ctx.fillStyle = '#f1f5f9'; ctx.fillRect(80, imgY, imgW, imgH);\n                ctx.drawImage(img, x, y, w, h);\n                ctx.strokeStyle = '#e2e8f0'; ctx.lineWidth = 2; ctx.strokeRect(80, imgY, imgW, imgH);\n\n                const boxY = imgY + imgH + 80;\n                ctx.fillStyle = '#f0fdf4'; ctx.fillRect(80, boxY, 1080, 200);\n                ctx.strokeStyle = '#bbf7d0'; ctx.lineWidth = 4; ctx.strokeRect(80, boxY, 1080, 200);\n\n                ctx.fillStyle = '#166534'; ctx.font = 'bold 40px Arial';\n                ctx.fillText('INVERSI\u00d3N ESTIMADA', 120, boxY + 70);\n\n                const priceText = item.priceUsd > 0 ? new Intl.NumberFormat('es-AR', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(item.priceUsd) : 'Consultar';\n                ctx.font = 'bold 80px Arial'; ctx.fillText(priceText, 120, boxY + 155);\n\n                if (item.finance > 0) {\n                    ctx.textAlign = 'right'; ctx.fillStyle = '#1e40af'; ctx.font = 'bold 35px Arial';\n                    ctx.fillText('Opci\u00f3n Financiada:', 1120, boxY + 80);\n                    ctx.font = 'bold 55px Arial';\n                    ctx.fillText(new Intl.NumberFormat('es-AR', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(item.finance), 1120, boxY + 155);\n                    ctx.textAlign = 'left';\n                }\n\n                if (item.details && item.details.trim() !== \"\") {\n                    ctx.fillStyle = '#334155'; ctx.font = 'bold 35px Arial';\n                    ctx.fillText('Observaciones Generales:', 80, boxY + 280);\n                    ctx.font = '30px Arial'; ctx.fillStyle = '#475569';\n                    ctx.fillText(item.details.substring(0, 150), 80, boxY + 330);\n                }\n\n                ctx.fillStyle = '#1e293b'; ctx.fillRect(0, 1554, canvas.width, 200);\n                ctx.fillStyle = '#f8fafc'; ctx.font = 'bold 35px Arial'; ctx.textAlign = 'center';\n                ctx.fillText('Ucacha Maquinarias - Ucacha, C\u00f3rdoba', canvas.width \/ 2, 1630);\n                ctx.font = '28px Arial'; ctx.fillStyle = '#94a3b8';\n                ctx.fillText('Tel \/ WhatsApp: 3535 084 927 | Web: ucachamaquinarias.com.ar', canvas.width \/ 2, 1680);\n\n                const pdfData = canvas.toDataURL('image\/jpeg', 0.8);\n                const { jsPDF } = window.jspdf;\n                const pdf = new jsPDF({ orientation: \"portrait\", unit: \"px\", format: [1240, 1754] });\n                pdf.addImage(pdfData, 'JPEG', 0, 0, 1240, 1754);\n                pdf.save(`Presupuesto_${id}.pdf`);\n\n                showToast(\"\u00a1Presupuesto PDF descargado exitosamente!\");\n            } catch (err) {\n                console.error(err);\n                showToast(\"Error al generar PDF. Verifique la imagen.\");\n            }\n        };\n\n        \/\/ --- FLYER INSTAGRAM ---\n        window.generateFlyer = async (encId, encName, priceUsd) => {\n            const id = decodeURIComponent(encId);\n            const name = decodeURIComponent(encName);\n            const item = appData.find(i => String(i.id) === id);\n            const estadoText = item && item.isToAgree ? \"A CONVENIR\" : \"DISPONIBLE\";\n\n            showToast(\"Generando flyer con logo, aguard\u00e1 un segundo...\");\n\n            const canvas = document.createElement('canvas');\n            canvas.width = 1080; canvas.height = 1080;\n            const ctx = canvas.getContext('2d');\n            ctx.fillStyle = '#ffffff'; ctx.fillRect(0, 0, 1080, 1080);\n\n            try {\n                const img = await new Promise((resolve, reject) => {\n                    const i = new Image(); i.crossOrigin = \"Anonymous\";\n                    i.onload = () => resolve(i); i.onerror = () => reject(new Error(\"Error imagen.\"));\n                    i.src = `\/maquinarias\/${id}.jpg`;\n                });\n\n                let logoImg = null;\n                try {\n                    logoImg = await new Promise((resolve, reject) => {\n                        const l = new Image(); l.crossOrigin = \"Anonymous\";\n                        l.onload = () => resolve(l); l.onerror = () => reject();\n                        l.src = `\/logo.jpg`;\n                    });\n                } catch(e) {}\n\n                if (logoImg) {\n                    const logoH = 120;\n                    const logoW = logoImg.width * (logoH \/ logoImg.height);\n                    ctx.drawImage(logoImg, 540 - logoW\/2, 30, logoW, logoH);\n                } else {\n                    ctx.textAlign = 'center'; ctx.fillStyle = '#fde047'; ctx.fillRect(340, 30, 400, 60);\n                    ctx.fillStyle = '#000000'; ctx.font = 'bold 50px Arial, sans-serif'; ctx.fillText('UCACHA', 540, 75);\n                    ctx.fillStyle = '#16a34a'; ctx.font = 'bold 40px Arial, sans-serif'; ctx.fillText('MAQUINARIAS', 540, 125);\n                }\n\n                ctx.fillStyle = item && item.isToAgree ? '#4f46e5' : '#16a34a'; \n                ctx.font = 'bold 32px Arial, sans-serif'; ctx.textAlign = 'center';\n                ctx.fillText(`\u2705 M\u00c1QUINA ${estadoText}`, 540, 185);\n\n                const imgY = 220, imgH = 530, imgW = 1080;\n                const scale = Math.min(imgW \/ img.width, imgH \/ img.height);\n                const w = img.width * scale; const h = img.height * scale;\n                const x = (imgW - w) \/ 2; const y = imgY + (imgH - h) \/ 2;\n                ctx.drawImage(img, x, y, w, h);\n\n                ctx.fillStyle = '#f8fafc'; ctx.fillRect(0, 750, 1080, 330);\n                ctx.fillStyle = item && item.isToAgree ? '#4f46e5' : '#16a34a'; ctx.fillRect(0, 750, 1080, 8);\n                ctx.fillStyle = '#111827'; ctx.font = 'bold 45px Arial, sans-serif';\n                \n                const words = name.split(' ');\n                let line = '', lineY = 820;\n                for(let n = 0; n < words.length; n++) {\n                    const testLine = line + words[n] + ' ';\n                    const metrics = ctx.measureText(testLine);\n                    if (metrics.width > 960 && n > 0) {\n                        ctx.fillText(line, 540, lineY);\n                        line = words[n] + ' '; lineY += 55;\n                    } else { line = testLine; }\n                }\n                ctx.fillText(line, 540, lineY);\n\n                const priceText = priceUsd > 0 ? new Intl.NumberFormat('es-AR', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(priceUsd) : 'Consultar';\n                ctx.fillStyle = item && item.isToAgree ? '#4f46e5' : '#16a34a'; ctx.font = '900 65px Arial, sans-serif';\n                ctx.fillText(priceText, 540, lineY + 80);\n\n                ctx.fillStyle = '#4b5563'; ctx.font = 'bold 36px Arial, sans-serif';\n                ctx.fillText(`\ud83d\udcf1 WhatsApp: 3535 084 927`, 540, lineY + 155);\n                ctx.font = '24px Arial, sans-serif'; ctx.fillStyle = '#6b7280';\n                ctx.fillText(`\ud83d\udd16 C\u00f3d: ${id} | \ud83d\udcbb ucachamaquinarias.com.ar`, 540, lineY + 205);\n\n                const dataUrl = canvas.toDataURL('image\/jpeg', 0.9);\n                const link = document.createElement('a');\n                link.download = `Ucacha_Flyer_${id}.jpg`;\n                link.href = dataUrl; link.click();\n                showToast(\"\u00a1Flyer descargado exitosamente!\");\n            } catch (err) { showToast(\"No se encontr\u00f3 la foto para crear el Flyer.\"); }\n        };\n\n        window.deleteProduct = (encId) => {\n            const id = decodeURIComponent(encId);\n            if (confirm(`\u00bfOcultar maquinaria C\u00f3d: ${id} de esta vista?`)) {\n                appData = appData.filter(item => item.id !== id);\n                state.selectedItems.delete(id);\n                render();\n                showToast('Maquinaria ocultada temporalmente.');\n            }\n        };\n\n        window.shareSelection = () => {\n            if (state.selectedItems.size === 0) return;\n            let text = `\u00a1Hola! Te comparto estas opciones de maquinaria:\\n\\n`;\n            const itemsToShare = appData.filter(item => state.selectedItems.has(item.id));\n            itemsToShare.forEach((item) => {\n                const estadoText = item.isToAgree ? \"A Convenir\" : \"Disponible\";\n                text += `\ud83d\ude9c *${item.name}* (C\u00f3d: ${item.id} - ${estadoText})\\n`;\n                if (state.isAdmin && item.priceUsd) text += `\ud83d\udcb5 Precio: USD ${item.priceUsd}\\n`;\n                text += `\\n`;\n            });\n            text += `\u00bfTe interesa alguna? Avisame y te paso fotos o detalles.`;\n            window.open(`https:\/\/wa.me\/?text=${encodeURIComponent(text)}`, '_blank');\n        };\n\n        window.copyForMarketplace = (encId, encName, priceUsd) => {\n            const id = decodeURIComponent(encId); const name = decodeURIComponent(encName);\n            const item = appData.find(i => String(i.id) === id);\n            const estadoText = item && item.isToAgree ? \"A Convenir (Por Pedido)\" : \"Disponible F\u00edsicamente\";\n            const text = `\ud83d\ude9c VENDO: ${name}\\n\u2705 Estado: ${estadoText}\\n\ud83d\udcb5 Precio: USD ${priceUsd}\\n\ud83d\udd16 C\u00f3d: ${id}\\n\ud83d\udc64 Ing. Alejandro Pagliero\\n\ud83d\udce9 Env\u00edame un mensaje.\\n#MaquinariaAgricola`;\n            const textArea = document.createElement(\"textarea\"); textArea.value = text; document.body.appendChild(textArea); textArea.select();\n            try { document.execCommand('copy'); showToast('\u00a1Texto copiado para Marketplace!'); } catch (err) {}\n            document.body.removeChild(textArea);\n        };\n\n        window.shareDirectLink = (encId, encName) => {\n            const id = decodeURIComponent(encId); const name = decodeURIComponent(encName);\n            const item = appData.find(i => String(i.id) === id);\n            const estadoText = item && item.isToAgree ? \"A Convenir (Por Pedido)\" : \"Disponible F\u00edsicamente\";\n            const link = window.location.origin + window.location.pathname + '?id=' + encodeURIComponent(id);\n            const text = `\u00a1Hola! Te comparto esta maquinaria que te puede interesar:\\n\\n\ud83d\ude9c *${name}*\\n\ud83d\udd16 C\u00f3d: ${id}\\n\ud83d\udccc Estado: ${estadoText}\\n\\n\ud83d\udc49 Pod\u00e9s ver fotos, videos y detalles entrando a este enlace directo:\\n${link}\\n\\nIng. Alejandro Pagliero`;\n            window.open(`https:\/\/wa.me\/?text=${encodeURIComponent(text)}`, '_blank');\n        };\n\n        \/\/ --- RENDERIZADO PRINCIPAL ---\n        const render = () => {\n            let filteredData = getFilteredData();\n\n            const singleItemBanner = document.getElementById('singleItemBanner');\n            if (singleMachineId) {\n                singleItemBanner.classList.remove('hidden');\n                document.getElementById('categoryFilters').style.display = 'none';\n                paginationContainer.style.display = 'none';\n            } else {\n                singleItemBanner.classList.add('hidden');\n                document.getElementById('categoryFilters').style.display = 'flex';\n                paginationContainer.style.display = 'flex';\n            }\n\n            if (state.sortBy === 'price_asc') filteredData.sort((a, b) => (a.priceUsd || 0) - (b.priceUsd || 0));\n            else if (state.sortBy === 'price_desc') filteredData.sort((a, b) => (b.priceUsd || 0) - (a.priceUsd || 0));\n\n            adminToggleText.textContent = state.isAdmin ? 'Modo Admin: ON' : 'Modo Admin: OFF';\n            if (state.isAdmin) {\n                adminNotification.classList.remove('hidden');\n                adminToggleContainer.classList.replace('bg-red-600\/90', 'bg-green-600');\n                adminToggleContainer.classList.replace('hover:bg-red-500', 'hover:bg-green-500');\n                adminToggleContainer.classList.replace('border-red-500\/30', 'border-green-500\/30');\n                document.getElementById('adminIconWrapper').innerHTML = '<i data-lucide=\"unlock\" class=\"w-4 h-4 text-white\"><\/i>';\n                \n                document.getElementById('soldToggleContainer').classList.remove('hidden');\n                document.getElementById('soldToggleContainer').classList.add('flex');\n            } else {\n                adminNotification.classList.add('hidden');\n                adminToggleContainer.classList.replace('bg-green-600', 'bg-red-600\/90');\n                adminToggleContainer.classList.replace('hover:bg-green-500', 'hover:bg-red-500');\n                adminToggleContainer.classList.replace('border-green-500\/30', 'border-red-500\/30');\n                document.getElementById('adminIconWrapper').innerHTML = '<i data-lucide=\"shield-alert\" class=\"w-4 h-4 text-white\"><\/i>';\n                \n                document.getElementById('soldToggleContainer').classList.remove('flex');\n                document.getElementById('soldToggleContainer').classList.add('hidden');\n            }\n\n            if (state.selectedItems.size > 0) { \n                floatingActions.classList.remove('hidden'); \n                pdfCount.textContent = state.selectedItems.size; \n            } else { \n                floatingActions.classList.add('hidden'); \n            }\n\n            const allSelected = filteredData.length > 0 && filteredData.every(item => state.selectedItems.has(item.id));\n            if(allSelected) {\n                selectAllText.textContent = \"Deseleccionar Todos\";\n            } else {\n                selectAllText.textContent = \"Seleccionar Todos\";\n            }\n\n            const totalPages = Math.ceil(filteredData.length \/ state.itemsPerPage);\n            if (state.currentPage > totalPages) state.currentPage = totalPages || 1;\n            \n            const startIndex = (state.currentPage - 1) * state.itemsPerPage;\n            const paginatedData = filteredData.slice(startIndex, startIndex + state.itemsPerPage);\n\n            let paginationHTML = '';\n            if (totalPages > 1) {\n                paginationHTML += `<button onclick=\"goToPage(${state.currentPage - 1})\" class=\"px-5 py-2.5 rounded-xl bg-white border border-gray-200 text-gray-700 font-bold disabled:opacity-50 hover:bg-blue-50 transition-colors shadow-sm\" ${state.currentPage === 1 ? 'disabled' : ''}>Anterior<\/button>`;\n                paginationHTML += `<span class=\"text-gray-600 font-medium px-4\">P\u00e1gina <span class=\"font-bold text-gray-900\">${state.currentPage}<\/span> de ${totalPages}<\/span>`;\n                paginationHTML += `<button onclick=\"goToPage(${state.currentPage + 1})\" class=\"px-5 py-2.5 rounded-xl bg-white border border-gray-200 text-gray-700 font-bold disabled:opacity-50 hover:bg-blue-50 transition-colors shadow-sm\" ${state.currentPage === totalPages ? 'disabled' : ''}>Siguiente<\/button>`;\n            }\n            paginationContainer.innerHTML = paginationHTML;\n\n            if (filteredData.length === 0) {\n                productGrid.innerHTML = `\n                    <div class=\"col-span-full py-20 text-center text-gray-400 print:hidden\">\n                        <i data-lucide=\"tractor\" class=\"h-16 w-16 mx-auto mb-4 opacity-30\"><\/i>\n                        <p class=\"text-xl font-medium text-gray-500\">No se encontraron maquinarias.<\/p>\n                    <\/div>`;\n            } else {\n                productGrid.innerHTML = paginatedData.map(item => {\n                    const isSelected = state.selectedItems.has(item.id);\n                    const printVisibilityClass = (state.selectedItems.size > 0 && !isSelected) ? 'print:hidden' : 'print:flex';\n                    \n                    const safeId = escapeHTML(item.id);\n                    const safeName = escapeHTML(item.name);\n                    const safeStatus = escapeHTML(item.status);\n                    \n                    const encId = encodeURIComponent(item.id).replace(\/'\/g, \"%27\");\n                    const encName = encodeURIComponent(item.name).replace(\/'\/g, \"%27\");\n                    \n                    return `\n                    <div class=\"product-card bg-white rounded-2xl shadow-sm hover:shadow-md border border-gray-100 overflow-hidden flex flex-col relative group transition-all duration-300 ${printVisibilityClass} ${isSelected ? 'ring-2 ring-blue-500 bg-blue-50\/30' : ''}\">\n                        \n                        <div class=\"absolute top-3 left-3 z-30 print:hidden\">\n                            <label class=\"cursor-pointer\">\n                                <input type=\"checkbox\" class=\"peer sr-only\" ${isSelected ? 'checked' : ''} onclick=\"event.stopPropagation(); toggleSelection('${encId}')\" \/>\n                                <div class=\"w-6 h-6 rounded-md bg-white\/90 border-2 border-gray-300 peer-checked:bg-blue-600 peer-checked:border-blue-600 backdrop-blur-sm transition-all flex items-center justify-center shadow-sm hover:border-blue-400\">\n                                    <i data-lucide=\"check\" class=\"w-4 h-4 text-white opacity-0 peer-checked:opacity-100 transition-opacity\"><\/i>\n                                <\/div>\n                            <\/label>\n                        <\/div>\n\n                        <div class=\"product-image-container bg-gray-50 h-64 w-full relative flex items-center justify-center text-gray-300 overflow-hidden cursor-pointer group\/image border-b border-gray-100\" onclick=\"openImageModal('${encId}', '${encName}')\">\n                            <i data-lucide=\"image\" class=\"w-12 h-12 opacity-20 absolute z-0 print:hidden\"><\/i>\n                            \n                            <div class=\"absolute inset-0 bg-black\/0 group-hover\/image:bg-black\/20 transition-all duration-300 z-10 flex items-center justify-center opacity-0 group-hover\/image:opacity-100 print:hidden backdrop-blur-[1px]\">\n                                <span class=\"bg-white\/95 text-gray-800 px-4 py-2 rounded-full font-bold text-sm shadow-lg flex items-center gap-2 transform translate-y-4 group-hover\/image:translate-y-0 transition-all\">\n                                    <i data-lucide=\"zoom-in\" class=\"w-4 h-4 text-blue-600\"><\/i> Ver Galer\u00eda\n                                <\/span>\n                            <\/div>\n\n                            <img decoding=\"async\" src=\"\/maquinarias\/${encodeURIComponent(item.id)}.jpg\" alt=\"${safeName}\" class=\"object-cover w-full h-full absolute inset-0 z-0 bg-white transition-transform duration-700 group-hover\/image:scale-105\" onerror=\"this.style.display='none';\" \/>\n                            \n                            ${item.isToAgree ? `\n                            <div class=\"absolute top-3 left-1\/2 transform -translate-x-1\/2 bg-indigo-600\/95 text-white px-3 py-1.5 rounded-full text-[10px] font-bold tracking-wider z-20 backdrop-blur-sm shadow-md flex items-center gap-1.5 print:bg-indigo-100 print:text-indigo-800 print:border print:border-indigo-300\">\n                                <i data-lucide=\"sparkles\" class=\"w-3.5 h-3.5\"><\/i> A CONVENIR\n                            <\/div>` : ''}\n\n                            ${state.isAdmin ? `\n                            <div class=\"absolute bottom-3 right-3 bg-gray-900\/80 text-white px-2.5 py-1 rounded-md text-[11px] font-bold tracking-wider z-20 print:hidden backdrop-blur-sm shadow-sm\">\n                                C\u00f3d: ${safeId}\n                            <\/div>` : ''}\n                        <\/div>\n                        \n                        <div class=\"absolute top-3 right-3 flex flex-col gap-2 z-20 print:hidden\">\n                            ${!state.isAdmin ? `\n                            <button onclick=\"event.stopPropagation(); shareDirectLink('${encId}', '${encName}')\" class=\"bg-white\/90 hover:bg-blue-600 text-gray-600 hover:text-white p-2 rounded-xl shadow-sm transition-all transform hover:-translate-y-1 backdrop-blur-md border border-gray-200\/50\" title=\"Compartir enlace directo a esta m\u00e1quina\">\n                                <i data-lucide=\"share-2\" class=\"w-4 h-4\"><\/i>\n                            <\/button>\n                            <a href=\"https:\/\/wa.me\/?text=${encodeURIComponent(`Hola Alejandro! Me interesa esta maquinaria:\\n*${item.name}*\\nC\u00f3d: ${item.id}\\n\u00bfPodr\u00edas darme precio y detalles?`)}\" target=\"_blank\" class=\"bg-white\/90 hover:bg-green-500 text-gray-600 hover:text-white p-2 rounded-xl shadow-sm transition-all transform hover:-translate-y-1 backdrop-blur-md border border-gray-200\/50\" onclick=\"event.stopPropagation()\" title=\"Consultar por WhatsApp\">\n                                <i data-lucide=\"message-circle\" class=\"w-4 h-4\"><\/i>\n                            <\/a>\n                            ` : `\n                            <button onclick=\"event.stopPropagation(); shareDirectLink('${encId}', '${encName}')\" class=\"bg-white\/90 hover:bg-blue-600 text-gray-600 hover:text-white p-2 rounded-xl shadow-sm transition-all transform hover:-translate-y-1 backdrop-blur-md border border-gray-200\/50\" title=\"Compartir enlace directo al cliente\">\n                                <i data-lucide=\"share-2\" class=\"w-4 h-4\"><\/i>\n                            <\/button>\n                            \n                            <a href=\"https:\/\/wa.me\/?text=${encodeURIComponent(`Hola Alejandro! Consulta:\\n*${item.name}*\\nC\u00f3d: ${item.id}\\nPrecio: USD ${item.priceUsd}`)}\" target=\"_blank\" class=\"bg-white\/90 hover:bg-green-500 text-gray-600 hover:text-white p-2 rounded-xl shadow-sm transition-all transform hover:-translate-y-1 backdrop-blur-md border border-gray-200\/50\" onclick=\"event.stopPropagation()\" title=\"WhatsApp\">\n                                <i data-lucide=\"message-circle\" class=\"w-4 h-4\"><\/i>\n                            <\/a>\n                            \n                            <button onclick=\"event.stopPropagation(); generatePDF('${encId}')\" class=\"bg-white\/90 hover:bg-red-500 text-gray-600 hover:text-white p-2 rounded-xl shadow-sm transition-all transform hover:-translate-y-1 backdrop-blur-md border border-gray-200\/50\" title=\"Descargar Presupuesto PDF Formal\">\n                                <i data-lucide=\"file-text\" class=\"w-4 h-4\"><\/i>\n                            <\/button>\n\n                            <button onclick=\"event.stopPropagation(); generateFlyer('${encId}', '${encName}', ${item.priceUsd})\" class=\"bg-white\/90 hover:bg-emerald-500 text-gray-600 hover:text-white p-2 rounded-xl shadow-sm transition-all transform hover:-translate-y-1 backdrop-blur-md border border-gray-200\/50\" title=\"Descargar Flyer para Instagram\/WhatsApp\">\n                                <i data-lucide=\"image-down\" class=\"w-4 h-4\"><\/i>\n                            <\/button>\n\n                            <button onclick=\"event.stopPropagation(); copyForMarketplace('${encId}', '${encName}', ${item.priceUsd})\" class=\"bg-white\/90 hover:bg-gray-800 text-gray-600 hover:text-white p-2 rounded-xl shadow-sm transition-all transform hover:-translate-y-1 backdrop-blur-md border border-gray-200\/50\" title=\"Copiar texto para Marketplace\">\n                                <i data-lucide=\"copy\" class=\"w-4 h-4\"><\/i>\n                            <\/button>\n                            `}\n                        <\/div>\n\n                        <div class=\"p-5 flex-1 flex flex-col ${!state.isAdmin ? 'items-center justify-center' : ''} print:p-4\">\n                            \n                            ${state.isAdmin ? `\n                            <div class=\"flex justify-between items-center mb-3\">\n                                <span class=\"inline-flex items-center px-2.5 py-1 rounded-md text-[10px] font-bold bg-gray-100 text-gray-600 border border-gray-200 tracking-wide uppercase\">\n                                    C\u00f3d: ${safeId}\n                                <\/span>\n                                <div class=\"flex gap-1.5\">\n                                    ${item.isToAgree \n                                        ? `<span class=\"px-2 py-1 rounded-md text-[10px] uppercase tracking-wide font-bold text-indigo-700 bg-indigo-50 border border-indigo-200\">A Convenir<\/span>`\n                                        : `<span class=\"px-2 py-1 rounded-md text-[10px] uppercase tracking-wide font-bold text-blue-700 bg-blue-50 border border-blue-200\">En Stock<\/span>`\n                                    }\n                                    ${safeStatus === 'DISPONIBLE' \n                                        ? `<span class=\"px-2 py-1 rounded-md text-[10px] uppercase tracking-wide font-bold text-green-700 bg-green-50 border border-green-200\">Disponible<\/span>`\n                                        : `<span class=\"px-2 py-1 rounded-md text-[10px] uppercase tracking-wide font-bold text-red-700 bg-red-50 border border-red-200\">Vendido<\/span>`\n                                    }\n                                <\/div>\n                            <\/div>\n                            ` : ''}\n\n                            <h3 class=\"text-lg font-bold text-gray-800 leading-tight ${state.isAdmin ? 'mb-4 flex-1 line-clamp-2' : 'text-center'} print:text-lg\">\n                                ${safeName}\n                            <\/h3>\n\n                            ${state.isAdmin ? `\n                            <div class=\"space-y-1 mb-5 print:mb-2 border-t border-gray-100 pt-4\">\n                                <div class=\"flex items-baseline text-gray-900 gap-1.5\">\n                                    <span class=\"text-2xl font-black text-green-600 print:text-2xl tracking-tight\">${formatCurrency(item.priceUsd, 'USD')}<\/span>\n                                <\/div>\n                                <div class=\"inline-block bg-gray-50 text-gray-500 text-[11px] font-semibold px-2 py-0.5 rounded-md border border-gray-200\">\n                                    ${formatCurrency(item.priceArs, 'ARS')}\n                                <\/div>\n                            <\/div>\n                            \n                            ${item.finance > 0 ? `\n                            <div class=\"bg-blue-50\/50 border border-blue-100 rounded-xl p-3 flex items-center justify-between mt-auto mb-4 print:border-gray-300 print:bg-transparent print:p-2\">\n                                <div class=\"flex items-center text-blue-700 text-[11px] uppercase tracking-wide font-bold print:text-gray-800\"><i data-lucide=\"calendar-days\" class=\"w-3.5 h-3.5 mr-1.5\"><\/i> 4 Cheques<\/div>\n                                <div class=\"text-blue-700 font-black text-sm print:text-gray-900\">${formatCurrency(item.finance, 'USD')}<\/div>\n                            <\/div>` : '<div class=\"mt-auto mb-4\"><\/div>'}\n                            \n                            <div class=\"bg-gray-50\/80 rounded-xl p-3.5 border border-gray-200 print:hidden relative mt-2\">\n                                <div class=\"flex justify-between items-center mb-2\">\n                                    <p class=\"text-[11px] font-extrabold text-gray-500 uppercase tracking-wider flex items-center gap-1.5\"><i data-lucide=\"lock\" class=\"w-3.5 h-3.5\"><\/i> Info Interna<\/p>\n                                    <button onclick=\"deleteProduct('${encId}')\" class=\"text-gray-400 hover:text-red-600 transition-colors\" title=\"Ocultar de la vista\">\n                                        <i data-lucide=\"eye-off\" class=\"w-4 h-4\"><\/i>\n                                    <\/button>\n                                <\/div>\n                                <div class=\"flex justify-between items-end mb-1\">\n                                    <span class=\"text-gray-500 text-xs font-medium\">Costo L\u00edmite:<\/span>\n                                    <span class=\"font-bold text-gray-800 text-sm\">${formatCurrency(item.priceLimit, 'USD')}<\/span>\n                                <\/div>\n                                ${item.details ? `<div class=\"text-[11px] text-gray-500 mt-2 bg-white p-2 rounded border border-gray-100 italic leading-relaxed\">${escapeHTML(item.details)}<\/div>` : ''}\n                            <\/div>\n                            ` : ''}\n                        <\/div>\n                    <\/div>\n                    `;\n                }).join('');\n            }\n\n            try { lucide.createIcons(); } catch(e){}\n        };\n\n        searchInput.addEventListener('input', (e) => { state.searchTerm = e.target.value; state.currentPage = 1; render(); });\n        includeSoldToggle.addEventListener('change', (e) => { state.includeSold = e.target.checked; state.currentPage = 1; render(); });\n        sortSelect.addEventListener('change', (e) => { state.sortBy = e.target.value; state.currentPage = 1; render(); });\n        conditionSelect.addEventListener('change', (e) => { state.conditionFilter = e.target.value; state.currentPage = 1; render(); });\n\n        selectAllBtn.addEventListener('click', () => {\n            let filteredData = getFilteredData();\n            const allSelected = filteredData.length > 0 && filteredData.every(item => state.selectedItems.has(item.id));\n            if (allSelected) filteredData.forEach(item => state.selectedItems.delete(item.id));\n            else filteredData.forEach(item => state.selectedItems.add(item.id));\n            render();\n        });\n\n        adminToggleContainer.addEventListener('click', (e) => {\n            e.preventDefault(); \n            if (!state.isAdmin) {\n                passwordModal.classList.remove('hidden');\n                adminPasswordInput.value = '';\n                setTimeout(() => adminPasswordInput.focus(), 100);\n            } else {\n                state.isAdmin = false;\n                adminToggle.checked = false;\n                state.selectedItems.clear(); \n                state.currentPage = 1;\n                state.includeSold = false;\n                document.getElementById('includeSoldToggle').checked = false;\n                render();\n                showToast('Modo p\u00fablico activado');\n            }\n        });\n\n        window.closePasswordModal = () => passwordModal.classList.add('hidden');\n        window.verifyPassword = () => {\n            if (adminPasswordInput.value.toLowerCase() === \"jorge\") {\n                state.isAdmin = true;\n                adminToggle.checked = true;\n                closePasswordModal();\n                state.currentPage = 1;\n                render();\n                showToast('Modo administrador activado');\n            } else {\n                showToast('Clave incorrecta');\n                adminPasswordInput.value = '';\n                adminPasswordInput.focus();\n            }\n        };\n\n        adminPasswordInput.addEventListener('keydown', (e) => {\n            if (e.key === 'Enter') verifyPassword();\n            if (e.key === 'Escape') closePasswordModal();\n        });\n\n        const loadCentralExcel = async () => {\n            productGrid.innerHTML = '';\n            loadingIndicator.classList.remove('hidden');\n\n            try {\n                const url = '\/maquinarias\/datos.xlsx?t=' + new Date().getTime();\n                const response = await fetch(url, { cache: 'no-store' });\n                if (!response.ok) throw new Error('Archivo no encontrado');\n\n                const arrayBuffer = await response.arrayBuffer();\n                const data = new Uint8Array(arrayBuffer);\n                const workbook = XLSX.read(data, { type: 'array' });\n                const firstSheetName = workbook.SheetNames[0];\n                const worksheet = workbook.Sheets[firstSheetName];\n                const rows = XLSX.utils.sheet_to_json(worksheet, { header: 1 });\n                \n                const parsedData = [];\n                for (let i = 0; i < rows.length; i++) {\n                    const row = rows[i];\n                    if (!row || row.length < 2) continue;\n\n                    const id = String(row[0] || '').trim();\n                    const name = String(row[1] || '').trim();\n                    if (!id || !name || isNaN(Number(id))) continue;\n\n                    \/\/ LEER COLUMNA G PARA DETERMINAR ESTADO Y DISPONIBILIDAD\n                    const colG = String(row[6] || '').toUpperCase();\n                    \n                    const isToAgree = colG.includes('CONVENIR');\n                    const isSold = colG.includes('VENDID') || colG.includes('CANJEADO');\n                    const detailsVal = String(row[6] || '');\n\n                    parsedData.push({\n                        id: id,\n                        name: name,\n                        priceArs: parseFloat(row[2]) || 0,\n                        priceUsd: parseFloat(row[3]) || 0,\n                        priceLimit: parseFloat(row[4]) || 0,\n                        finance: parseFloat(row[5]) || 0,\n                        status: isSold ? 'VENDIDO' : 'DISPONIBLE',\n                        isToAgree: isToAgree,\n                        details: detailsVal\n                    });\n                }\n                \n                if (parsedData.length > 0) appData = parsedData;\n                else throw new Error('Archivo vac\u00edo o con formato distinto');\n\n            } catch (error) {\n                console.log(\"Cargando datos de prueba por falta de servidor real.\");\n                appData = [\n                    { id: \"1\", name: \"PALA CARGADORA ARRASTRE 1,5 MTS\", priceArs: 4000000, priceUsd: 2797, priceLimit: 3600000, finance: 4000000, status: \"DISPONIBLE\", isToAgree: false, details: \"\" },\n                    { id: \"2\", name: \"DESMALEZADORA E HILERADO BAIMA 3 MTS\", priceArs: 9500000, priceUsd: 6643, priceLimit: 9025000, finance: 9500000, status: \"VENDIDO\", isToAgree: false, details: \"VENDIDA A $10M\" },\n                    { id: \"3\", name: \"MOLEDORA ROLLO\", priceArs: 5000000, priceUsd: 3496, priceLimit: 4750000, finance: 5000000, status: \"VENDIDO\", isToAgree: false, details: \"CANJEADO\" },\n                    { id: \"4\", name: 'CHIMANGO 160\" MOTOR EXPLOSI\u00d3N', priceArs: 2000000, priceUsd: 1398, priceLimit: 1900000, finance: 2000000, status: \"DISPONIBLE\", isToAgree: false, details: \"Tiene detalles de pintura\" },\n                    { id: \"5\", name: 'TRACTOR NUEVO A PEDIR', priceArs: 0, priceUsd: 15000, priceLimit: 14000, finance: 0, status: \"DISPONIBLE\", isToAgree: true, details: \"Entrega a 30 d\u00edas\" }\n                ];\n            } finally {\n                loadingIndicator.classList.add('hidden');\n                render();\n            }\n        };\n\n        loadCentralExcel();\n    <\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Cat\u00e1logo de Maquinarias Agr\u00edcolas &#8211; Ing. Alejandro Pagliero Cat\u00e1logo de Maquinarias Agr\u00edcolas Ing. Alejandro Pagliero Modo Admin: OFF Cotizaci\u00f3n \/ Opciones de Cat\u00e1logo Generado el: Seleccionar Todos Stock y A &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2214","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ucachamaquinarias.com.ar\/wp\/wp-json\/wp\/v2\/pages\/2214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ucachamaquinarias.com.ar\/wp\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ucachamaquinarias.com.ar\/wp\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ucachamaquinarias.com.ar\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ucachamaquinarias.com.ar\/wp\/wp-json\/wp\/v2\/comments?post=2214"}],"version-history":[{"count":8,"href":"https:\/\/ucachamaquinarias.com.ar\/wp\/wp-json\/wp\/v2\/pages\/2214\/revisions"}],"predecessor-version":[{"id":2225,"href":"https:\/\/ucachamaquinarias.com.ar\/wp\/wp-json\/wp\/v2\/pages\/2214\/revisions\/2225"}],"wp:attachment":[{"href":"https:\/\/ucachamaquinarias.com.ar\/wp\/wp-json\/wp\/v2\/media?parent=2214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}