package controllers

import "github.com/gofiber/fiber/v2"

func AdminApiSpec(c *fiber.Ctx) error {
	spec := fiber.Map{
		"api":     "U-Site Admin API v2",
		"version": "1.0",
		"base":    "/api/v2",
		"auth":    "Header Authorization: Bearer <ADMIN_API_KEY> o X-API-Key: <ADMIN_API_KEY>",
		"formato": "JSON. GETs con paginación aceptan ?page=1&search=texto. Respuestas: {items, total, totalPages, page} o el objeto directo.",
		"modulos": []fiber.Map{
			{
				"nombre": "Usuarios",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/users", "desc": "Listar usuarios del sistema"},
					{"method": "GET", "path": "/api/v2/users/:id", "desc": "Detalle de un usuario"},
					{"method": "POST", "path": "/api/v2/users", "desc": "Crear usuario", "body": "nombre_usuario, email, password, role_id"},
					{"method": "PUT", "path": "/api/v2/users/:id", "desc": "Actualizar usuario"},
					{"method": "DELETE", "path": "/api/v2/users/:id", "desc": "Eliminar usuario"},
				},
			},
			{
				"nombre": "Roles",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/roles", "desc": "Listar roles"},
					{"method": "POST", "path": "/api/v2/roles", "desc": "Crear rol"},
					{"method": "PUT", "path": "/api/v2/roles/:id", "desc": "Actualizar rol"},
					{"method": "DELETE", "path": "/api/v2/roles/:id", "desc": "Eliminar rol"},
				},
			},
			{
				"nombre": "Módulos",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/modules", "desc": "Listar módulos"},
					{"method": "POST", "path": "/api/v2/modules", "desc": "Crear módulo"},
					{"method": "PUT", "path": "/api/v2/modules/:id", "desc": "Actualizar módulo"},
					{"method": "DELETE", "path": "/api/v2/modules/:id", "desc": "Eliminar módulo"},
				},
			},
			{
				"nombre": "Submódulos",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/submodules", "desc": "Listar submódulos"},
					{"method": "POST", "path": "/api/v2/submodules", "desc": "Crear submódulo"},
					{"method": "PUT", "path": "/api/v2/submodules/:id", "desc": "Actualizar submódulo"},
					{"method": "DELETE", "path": "/api/v2/submodules/:id", "desc": "Eliminar submódulo"},
				},
			},
			{
				"nombre": "Servidores",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/servidores", "desc": "Listar servidores"},
					{"method": "POST", "path": "/api/v2/servidores", "desc": "Crear servidor"},
					{"method": "PUT", "path": "/api/v2/servidores/:id", "desc": "Actualizar servidor"},
					{"method": "DELETE", "path": "/api/v2/servidores/:id", "desc": "Eliminar servidor"},
					{"method": "GET", "path": "/api/v2/servidores/:id/dashboard", "desc": "Dashboard de un servidor"},
					{"method": "GET", "path": "/api/v2/servidores/:id/metricas-history", "desc": "Historial de métricas"},
				},
			},
			{
				"nombre": "Proveedores de servidor",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/prov-servidores", "desc": "Listar proveedores"},
					{"method": "POST", "path": "/api/v2/prov-servidores", "desc": "Crear proveedor"},
					{"method": "PUT", "path": "/api/v2/prov-servidores/:id", "desc": "Actualizar proveedor"},
					{"method": "DELETE", "path": "/api/v2/prov-servidores/:id", "desc": "Eliminar proveedor"},
				},
			},
			{
				"nombre": "Tipos de servidor",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/tipos-servidor", "desc": "Listar tipos"},
					{"method": "POST", "path": "/api/v2/tipos-servidor", "desc": "Crear tipo"},
					{"method": "PUT", "path": "/api/v2/tipos-servidor/:id", "desc": "Actualizar tipo"},
					{"method": "DELETE", "path": "/api/v2/tipos-servidor/:id", "desc": "Eliminar tipo"},
				},
			},
			{
				"nombre": "Tipos de DB",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/tipos-db", "desc": "Listar tipos DB"},
					{"method": "POST", "path": "/api/v2/tipos-db", "desc": "Crear tipo DB"},
					{"method": "PUT", "path": "/api/v2/tipos-db/:id", "desc": "Actualizar tipo DB"},
					{"method": "DELETE", "path": "/api/v2/tipos-db/:id", "desc": "Eliminar tipo DB"},
				},
			},
			{
				"nombre": "Conexiones SSH",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/conexiones-ssh", "desc": "Listar conexiones SSH"},
					{"method": "POST", "path": "/api/v2/conexiones-ssh", "desc": "Crear conexión SSH"},
					{"method": "PUT", "path": "/api/v2/conexiones-ssh/:id", "desc": "Actualizar conexión SSH"},
					{"method": "DELETE", "path": "/api/v2/conexiones-ssh/:id", "desc": "Eliminar conexión SSH"},
				},
			},
			{
				"nombre": "Conexiones DB",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/conexiones-db", "desc": "Listar conexiones DB"},
					{"method": "GET", "path": "/api/v2/conexiones-db/select", "desc": "Select de conexiones DB (filtrable por ?servidor_id=)"},
					{"method": "POST", "path": "/api/v2/conexiones-db", "desc": "Crear conexión DB"},
					{"method": "PUT", "path": "/api/v2/conexiones-db/:id", "desc": "Actualizar conexión DB"},
					{"method": "DELETE", "path": "/api/v2/conexiones-db/:id", "desc": "Eliminar conexión DB"},
				},
			},
			{
				"nombre": "Clientes",
				"desc":   "Clientes de la empresa (tabla clientes). Usados en contratos, cuentas por cobrar, portal.",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/clientes", "desc": "Listar clientes. Query: ?page=1&limit=10&search=texto"},
					{"method": "GET", "path": "/api/v2/clientes/select", "desc": "Clientes activos para select/dropdown"},
					{"method": "POST", "path": "/api/v2/clientes", "desc": "Crear cliente", "body": "nombre, empresa, email, email_cc, telefono, documento, notas"},
					{"method": "PUT", "path": "/api/v2/clientes/:id", "desc": "Actualizar cliente"},
					{"method": "DELETE", "path": "/api/v2/clientes/:id", "desc": "Eliminar cliente"},
					{"method": "GET", "path": "/api/v2/clientes/:clienteID/documentos", "desc": "Documentos del cliente"},
					{"method": "POST", "path": "/api/v2/clientes/:clienteID/documentos", "desc": "Subir documentos (multipart)"},
					{"method": "DELETE", "path": "/api/v2/clientes/:clienteID/documentos/:docID", "desc": "Eliminar documento"},
					{"method": "GET", "path": "/api/v2/clientes/:clienteID/documentos/:docID/download", "desc": "Descargar documento"},
				},
			},
			{
				"nombre": "Servicios",
				"desc":   "Tipos de servicio ofrecidos (hosting, dominio, desarrollo, etc.)",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/servicios", "desc": "Listar servicios"},
					{"method": "GET", "path": "/api/v2/servicios/select", "desc": "Servicios activos para select"},
					{"method": "POST", "path": "/api/v2/servicios", "desc": "Crear servicio"},
					{"method": "PUT", "path": "/api/v2/servicios/:id", "desc": "Actualizar servicio"},
					{"method": "DELETE", "path": "/api/v2/servicios/:id", "desc": "Eliminar servicio"},
				},
			},
			{
				"nombre": "Contratos",
				"desc":   "Contratos de servicio con clientes. Tienen ciclo de renovación y notificaciones automáticas.",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/contratos", "desc": "Listar contratos. Query: ?page=1&search=&estado=&servicio_id="},
					{"method": "POST", "path": "/api/v2/contratos", "desc": "Crear contrato"},
					{"method": "PUT", "path": "/api/v2/contratos/:id", "desc": "Actualizar contrato"},
					{"method": "DELETE", "path": "/api/v2/contratos/:id", "desc": "Eliminar contrato"},
					{"method": "POST", "path": "/api/v2/contratos/:id/renovar", "desc": "Renovar contrato"},
					{"method": "POST", "path": "/api/v2/contratos/:id/enviar-correo", "desc": "Enviar correo de notificación"},
					{"method": "GET", "path": "/api/v2/contratos/:id/historial", "desc": "Historial del contrato"},
					{"method": "POST", "path": "/api/v2/contratos/:id/verificar-pago", "desc": "Verificar pago Bold"},
					{"method": "POST", "path": "/api/v2/contratos/:id/marcar-pagado", "desc": "Marcar pago manual"},
					{"method": "POST", "path": "/api/v2/contratos/:id/generar-documento", "desc": "Genera el PDF del contrato (cláusulas estándar) desde la plantilla activa tipo 'contrato'"},
				},
			},
			{
				"nombre": "Plantillas de correo",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/plantillas-correo", "desc": "Listar plantillas"},
					{"method": "POST", "path": "/api/v2/plantillas-correo", "desc": "Crear plantilla"},
					{"method": "PUT", "path": "/api/v2/plantillas-correo/:id", "desc": "Actualizar plantilla"},
					{"method": "DELETE", "path": "/api/v2/plantillas-correo/:id", "desc": "Eliminar plantilla"},
					{"method": "GET", "path": "/api/v2/plantillas-correo/:id/preview", "desc": "Vista previa"},
				},
			},
			{
				"nombre": "Reglas de notificación",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/reglas-notificacion", "desc": "Listar reglas"},
					{"method": "POST", "path": "/api/v2/reglas-notificacion", "desc": "Crear regla"},
					{"method": "PUT", "path": "/api/v2/reglas-notificacion/:id", "desc": "Actualizar regla"},
					{"method": "DELETE", "path": "/api/v2/reglas-notificacion/:id", "desc": "Eliminar regla"},
				},
			},
			{
				"nombre": "Historial de notificaciones",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/historial-notificaciones", "desc": "Listar historial"},
					{"method": "POST", "path": "/api/v2/historial-notificaciones/:id/reenviar", "desc": "Reenviar notificación"},
				},
			},
			{
				"nombre": "SMTP Config",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/smtp-config", "desc": "Ver configuración SMTP"},
					{"method": "POST", "path": "/api/v2/smtp-config", "desc": "Guardar configuración SMTP"},
				},
			},
			{
				"nombre": "Tareas (Kanban)",
				"desc":   "Tablero de tareas con estados: pendiente, en_progreso, completada, cancelada",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/tareas", "desc": "Listar tareas. Query: ?estado=&asignado_a=&search="},
					{"method": "GET", "path": "/api/v2/tareas/usuarios", "desc": "Usuarios del sistema para asignar"},
					{"method": "POST", "path": "/api/v2/tareas", "desc": "Crear tarea"},
					{"method": "GET", "path": "/api/v2/tareas/:id", "desc": "Detalle de tarea con comentarios"},
					{"method": "PUT", "path": "/api/v2/tareas/:id", "desc": "Actualizar tarea"},
					{"method": "PUT", "path": "/api/v2/tareas/:id/estado", "desc": "Cambiar estado", "body": "estado"},
					{"method": "DELETE", "path": "/api/v2/tareas/:id", "desc": "Eliminar tarea"},
					{"method": "POST", "path": "/api/v2/tareas/:id/comentario", "desc": "Agregar comentario"},
				},
			},
			{
				"nombre": "Monitor de URLs",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/url-monitors", "desc": "Listar monitores"},
					{"method": "POST", "path": "/api/v2/url-monitors", "desc": "Crear monitor"},
					{"method": "PUT", "path": "/api/v2/url-monitors/:id", "desc": "Actualizar monitor"},
					{"method": "DELETE", "path": "/api/v2/url-monitors/:id", "desc": "Eliminar monitor"},
					{"method": "POST", "path": "/api/v2/url-monitors/:id/check", "desc": "Chequear ahora"},
					{"method": "GET", "path": "/api/v2/url-monitors/:id/logs", "desc": "Logs del monitor"},
				},
			},
			{
				"nombre": "Proyectos",
				"desc":   "Proyectos del portal de clientes. Contienen fases, avances, entregables, tickets y documentos.",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/proyectos", "desc": "Listar proyectos"},
					{"method": "POST", "path": "/api/v2/proyectos", "desc": "Crear proyecto"},
					{"method": "PUT", "path": "/api/v2/proyectos/:id", "desc": "Actualizar proyecto"},
					{"method": "DELETE", "path": "/api/v2/proyectos/:id", "desc": "Eliminar proyecto"},
					{"method": "GET", "path": "/api/v2/proyectos/:id/fases", "desc": "Listar fases"},
					{"method": "POST", "path": "/api/v2/proyectos/:id/fases", "desc": "Crear fase"},
					{"method": "PUT", "path": "/api/v2/proyectos/:id/fases/:faseID", "desc": "Actualizar fase"},
					{"method": "DELETE", "path": "/api/v2/proyectos/:id/fases/:faseID", "desc": "Eliminar fase"},
					{"method": "GET", "path": "/api/v2/proyectos/:id/avances", "desc": "Listar avances"},
					{"method": "POST", "path": "/api/v2/proyectos/:id/avances", "desc": "Crear avance"},
					{"method": "PUT", "path": "/api/v2/proyectos/:id/avances/:avID", "desc": "Actualizar avance"},
					{"method": "DELETE", "path": "/api/v2/proyectos/:id/avances/:avID", "desc": "Eliminar avance"},
					{"method": "GET", "path": "/api/v2/proyectos/:id/entregables", "desc": "Listar entregables"},
					{"method": "POST", "path": "/api/v2/proyectos/:id/entregables", "desc": "Subir entregable"},
					{"method": "DELETE", "path": "/api/v2/proyectos/:id/entregables/:entID", "desc": "Eliminar entregable"},
					{"method": "GET", "path": "/api/v2/proyectos/:id/entregables/:entID/download", "desc": "Descargar entregable"},
					{"method": "GET", "path": "/api/v2/proyectos/:id/tickets", "desc": "Listar tickets del proyecto"},
					{"method": "PUT", "path": "/api/v2/proyectos/:id/tickets/:ticketID/estado", "desc": "Cambiar estado ticket"},
					{"method": "POST", "path": "/api/v2/proyectos/:id/tickets/:ticketID/mensaje", "desc": "Responder ticket"},
					{"method": "GET", "path": "/api/v2/proyectos/:id/documentos", "desc": "Listar documentos"},
					{"method": "POST", "path": "/api/v2/proyectos/:id/documentos", "desc": "Subir documento"},
					{"method": "DELETE", "path": "/api/v2/proyectos/:id/documentos/:docID", "desc": "Eliminar documento"},
					{"method": "GET", "path": "/api/v2/proyectos/:id/documentos/:docID/download", "desc": "Descargar documento"},
				},
			},
			{
				"nombre": "Portal de Usuarios",
				"desc":   "Usuarios del portal de clientes (login externo). Tienen accesos vinculados a clientes.",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/portal-usuarios", "desc": "Listar usuarios portal"},
					{"method": "GET", "path": "/api/v2/portal-usuarios/:id", "desc": "Detalle usuario portal"},
					{"method": "POST", "path": "/api/v2/portal-usuarios", "desc": "Crear usuario portal"},
					{"method": "PUT", "path": "/api/v2/portal-usuarios/:id", "desc": "Actualizar usuario portal"},
					{"method": "DELETE", "path": "/api/v2/portal-usuarios/:id", "desc": "Eliminar usuario portal"},
					{"method": "POST", "path": "/api/v2/portal-usuarios/:id/acceso", "desc": "Agregar acceso a cliente"},
					{"method": "DELETE", "path": "/api/v2/portal-usuarios/:id/acceso/:clienteID", "desc": "Quitar acceso a cliente"},
					{"method": "POST", "path": "/api/v2/portal-usuarios/:id/send-credentials", "desc": "Enviar credenciales por correo"},
				},
			},
			{
				"nombre": "Facturas",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/facturas", "desc": "Listar facturas"},
					{"method": "POST", "path": "/api/v2/facturas", "desc": "Crear factura"},
					{"method": "PUT", "path": "/api/v2/facturas/:id", "desc": "Actualizar factura"},
					{"method": "DELETE", "path": "/api/v2/facturas/:id", "desc": "Eliminar factura"},
					{"method": "POST", "path": "/api/v2/facturas/:id/upload-pdf", "desc": "Subir PDF de factura"},
					{"method": "GET", "path": "/api/v2/facturas/:id/download", "desc": "Descargar PDF factura"},
				},
			},
			{
				"nombre": "Tickets (global)",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/tickets", "desc": "Listar todos los tickets"},
					{"method": "PUT", "path": "/api/v2/tickets/:ticketID/estado", "desc": "Cambiar estado"},
					{"method": "POST", "path": "/api/v2/tickets/:ticketID/mensaje", "desc": "Responder ticket"},
				},
			},
			{
				"nombre": "Contabilidad",
				"desc":   "Sistema contable: transacciones (ingresos/egresos), cuentas, entidades, cuentas por cobrar/pagar, consolidados.",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/contabilidad/dashboard", "desc": "Dashboard. Query: ?mes=7&anio=2026"},
					{"method": "GET", "path": "/api/v2/contabilidad/consolidado", "desc": "Calcular consolidado mensual. Query: ?mes=&anio="},
					{"method": "GET", "path": "/api/v2/contabilidad/consolidados", "desc": "Listar consolidados. Query: ?anio="},
					{"method": "GET", "path": "/api/v2/contabilidad/transacciones", "desc": "Listar transacciones. Query: ?page=&search=&tipo=ingreso|egreso&mes=&anio="},
					{"method": "POST", "path": "/api/v2/contabilidad/transacciones", "desc": "Crear transacción", "body": "fecha, tipo, descripcion, valor, cuenta_id, entidad_id, forma_pago, estado, notas"},
					{"method": "PUT", "path": "/api/v2/contabilidad/transacciones/:id", "desc": "Actualizar transacción"},
					{"method": "DELETE", "path": "/api/v2/contabilidad/transacciones/:id", "desc": "Eliminar transacción"},
					{"method": "GET", "path": "/api/v2/contabilidad/cuentas", "desc": "Listar categorías contables"},
					{"method": "GET", "path": "/api/v2/contabilidad/cuentas/select", "desc": "Categorías activas para select"},
					{"method": "POST", "path": "/api/v2/contabilidad/cuentas", "desc": "Crear categoría", "body": "codigo, nombre, tipo(ingreso|egreso), color"},
					{"method": "PUT", "path": "/api/v2/contabilidad/cuentas/:id", "desc": "Actualizar categoría"},
					{"method": "DELETE", "path": "/api/v2/contabilidad/cuentas/:id", "desc": "Eliminar categoría"},
					{"method": "GET", "path": "/api/v2/contabilidad/entidades", "desc": "Listar entidades contables"},
					{"method": "GET", "path": "/api/v2/contabilidad/entidades/select", "desc": "Entidades activas para select"},
					{"method": "POST", "path": "/api/v2/contabilidad/entidades", "desc": "Crear entidad", "body": "nombre, tipo(cliente|proveedor|ambos), documento, email, telefono"},
					{"method": "PUT", "path": "/api/v2/contabilidad/entidades/:id", "desc": "Actualizar entidad"},
					{"method": "DELETE", "path": "/api/v2/contabilidad/entidades/:id", "desc": "Eliminar entidad"},
					{"method": "GET", "path": "/api/v2/contabilidad/cuentas-cobro", "desc": "Listar cuentas por cobrar. Query: ?page=&search=&estado="},
					{"method": "POST", "path": "/api/v2/contabilidad/cuentas-cobro", "desc": "Crear cuenta por cobrar", "body": "cliente_id, descripcion, valor, fecha, fecha_vencimiento, notas"},
					{"method": "PUT", "path": "/api/v2/contabilidad/cuentas-cobro/:id", "desc": "Actualizar cuenta por cobrar"},
					{"method": "DELETE", "path": "/api/v2/contabilidad/cuentas-cobro/:id", "desc": "Eliminar cuenta por cobrar"},
					{"method": "POST", "path": "/api/v2/contabilidad/cuentas-cobro/:id/generar-documento", "desc": "Genera el PDF de solicitud de cuenta de cobro desde la plantilla activa tipo 'cuenta_cobro'"},
					{"method": "GET", "path": "/api/v2/contabilidad/cuentas-pagar", "desc": "Listar cuentas por pagar. Query: ?page=&search=&estado="},
					{"method": "POST", "path": "/api/v2/contabilidad/cuentas-pagar", "desc": "Crear cuenta por pagar", "body": "entidad_id, descripcion, valor, fecha, vencimiento, notas"},
					{"method": "PUT", "path": "/api/v2/contabilidad/cuentas-pagar/:id", "desc": "Actualizar cuenta por pagar"},
					{"method": "POST", "path": "/api/v2/contabilidad/cuentas-pagar/:id/pagar", "desc": "Marcar como pagada", "body": "fecha_pago"},
					{"method": "DELETE", "path": "/api/v2/contabilidad/cuentas-pagar/:id", "desc": "Eliminar cuenta por pagar"},
				},
			},
			{
				"nombre": "Productos SaaS",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/saas", "desc": "Listar productos SaaS"},
					{"method": "POST", "path": "/api/v2/saas", "desc": "Crear producto"},
					{"method": "PUT", "path": "/api/v2/saas/:id", "desc": "Actualizar producto"},
					{"method": "DELETE", "path": "/api/v2/saas/:id", "desc": "Eliminar producto"},
					{"method": "GET", "path": "/api/v2/saas/:id/health", "desc": "Health check del producto"},
				},
			},
			{
				"nombre": "Integraciones SaaS (dispatcher)",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/saas-api", "desc": "Listar configs de integración"},
					{"method": "POST", "path": "/api/v2/saas-api", "desc": "Crear config"},
					{"method": "PUT", "path": "/api/v2/saas-api/:id", "desc": "Actualizar config"},
					{"method": "DELETE", "path": "/api/v2/saas-api/:id", "desc": "Eliminar config"},
					{"method": "GET", "path": "/api/v2/saas-api/logs", "desc": "Logs de despacho"},
				},
			},
			{
				"nombre": "Documentación",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/doc/categorias", "desc": "Listar categorías de docs"},
					{"method": "POST", "path": "/api/v2/doc/categorias", "desc": "Crear categoría"},
					{"method": "PUT", "path": "/api/v2/doc/categorias/:id", "desc": "Actualizar categoría"},
					{"method": "DELETE", "path": "/api/v2/doc/categorias/:id", "desc": "Eliminar categoría"},
					{"method": "GET", "path": "/api/v2/doc/paginas", "desc": "Listar páginas de docs"},
					{"method": "GET", "path": "/api/v2/doc/paginas/:id", "desc": "Detalle de página"},
					{"method": "POST", "path": "/api/v2/doc/paginas", "desc": "Crear página"},
					{"method": "PUT", "path": "/api/v2/doc/paginas/:id", "desc": "Actualizar página"},
					{"method": "DELETE", "path": "/api/v2/doc/paginas/:id", "desc": "Eliminar página"},
				},
			},
			{
				"nombre": "Configuraciones de IA",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/ai-config", "desc": "Listar configs de IA"},
					{"method": "GET", "path": "/api/v2/ai-config/select", "desc": "Configs activas para select"},
					{"method": "POST", "path": "/api/v2/ai-config", "desc": "Crear config IA"},
					{"method": "PUT", "path": "/api/v2/ai-config/:id", "desc": "Actualizar config"},
					{"method": "DELETE", "path": "/api/v2/ai-config/:id", "desc": "Eliminar config"},
					{"method": "GET", "path": "/api/v2/ai-config/:id/test", "desc": "Probar config"},
				},
			},
			{
				"nombre": "OSS API (almacenamiento)",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/oss-api", "desc": "Listar configs de almacenamiento"},
					{"method": "GET", "path": "/api/v2/oss-api/active", "desc": "Configs activas"},
					{"method": "POST", "path": "/api/v2/oss-api", "desc": "Crear config"},
					{"method": "PUT", "path": "/api/v2/oss-api/:id", "desc": "Actualizar config"},
					{"method": "DELETE", "path": "/api/v2/oss-api/:id", "desc": "Eliminar config"},
					{"method": "GET", "path": "/api/v2/oss-api/browser", "desc": "Explorar archivos. Query: ?prefix=&config_id="},
					{"method": "GET", "path": "/api/v2/oss-api/browser/url", "desc": "URL firmada para descarga"},
					{"method": "POST", "path": "/api/v2/oss-api/browser/upload", "desc": "Subir archivo"},
					{"method": "DELETE", "path": "/api/v2/oss-api/browser/object", "desc": "Eliminar archivo"},
				},
			},
			{
				"nombre": "Telegram",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/telegram", "desc": "Listar configs de Telegram"},
					{"method": "POST", "path": "/api/v2/telegram", "desc": "Crear config"},
					{"method": "PUT", "path": "/api/v2/telegram/:id", "desc": "Actualizar config"},
					{"method": "DELETE", "path": "/api/v2/telegram/:id", "desc": "Eliminar config"},
					{"method": "POST", "path": "/api/v2/telegram/:id/test", "desc": "Enviar test"},
					{"method": "POST", "path": "/api/v2/telegram/send", "desc": "Enviar notificación Telegram", "body": "config_id, message"},
					{"method": "GET", "path": "/api/v2/telegram/logs", "desc": "Logs de envíos"},
				},
			},
			{
				"nombre": "Notificaciones config",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/notif-config", "desc": "Configs de notificaciones por evento"},
					{"method": "POST", "path": "/api/v2/notif-config", "desc": "Guardar config"},
					{"method": "GET", "path": "/api/v2/servidor-alerta-config", "desc": "Umbrales de alerta de servidores"},
					{"method": "POST", "path": "/api/v2/servidor-alerta-config", "desc": "Guardar umbrales"},
				},
			},
			{
				"nombre": "Partner Recursos y Comunicados",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/partner-recursos", "desc": "Listar recursos partner"},
					{"method": "POST", "path": "/api/v2/partner-recursos", "desc": "Crear recurso"},
					{"method": "PUT", "path": "/api/v2/partner-recursos/:id", "desc": "Actualizar recurso"},
					{"method": "DELETE", "path": "/api/v2/partner-recursos/:id", "desc": "Eliminar recurso"},
					{"method": "GET", "path": "/api/v2/partner-comunicados", "desc": "Listar comunicados"},
					{"method": "POST", "path": "/api/v2/partner-comunicados", "desc": "Crear comunicado"},
					{"method": "PUT", "path": "/api/v2/partner-comunicados/:id", "desc": "Actualizar comunicado"},
					{"method": "DELETE", "path": "/api/v2/partner-comunicados/:id", "desc": "Eliminar comunicado"},
				},
			},
			{
				"nombre": "USITE Shield",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/shield", "desc": "Ver config Shield"},
					{"method": "POST", "path": "/api/v2/shield", "desc": "Guardar config"},
					{"method": "GET", "path": "/api/v2/shield/health", "desc": "Health check"},
					{"method": "GET", "path": "/api/v2/shield/logs", "desc": "Logs de Shield"},
					{"method": "GET", "path": "/api/v2/shield/logs/stats", "desc": "Estadísticas de logs"},
					{"method": "GET", "path": "/api/v2/shield/review-requests", "desc": "Solicitudes de revisión"},
					{"method": "PUT", "path": "/api/v2/shield/review-requests/:id/approve", "desc": "Aprobar solicitud"},
					{"method": "PUT", "path": "/api/v2/shield/review-requests/:id/reject", "desc": "Rechazar solicitud"},
					{"method": "GET", "path": "/api/v2/shield/whitelist", "desc": "Whitelist"},
					{"method": "POST", "path": "/api/v2/shield/whitelist", "desc": "Agregar a whitelist"},
					{"method": "DELETE", "path": "/api/v2/shield/whitelist/:domain", "desc": "Quitar de whitelist"},
					{"method": "GET", "path": "/api/v2/shield/blacklist", "desc": "Blacklist"},
					{"method": "POST", "path": "/api/v2/shield/blacklist", "desc": "Agregar a blacklist"},
					{"method": "DELETE", "path": "/api/v2/shield/blacklist/:domain", "desc": "Quitar de blacklist"},
				},
			},
			{
				"nombre": "WebSMS (LabsMobile)",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/websms/config", "desc": "Ver config WebSMS"},
					{"method": "POST", "path": "/api/v2/websms/save", "desc": "Guardar config"},
					{"method": "POST", "path": "/api/v2/websms/test", "desc": "Enviar SMS de prueba"},
					{"method": "GET", "path": "/api/v2/websms/logs", "desc": "Logs de envíos"},
				},
			},
			{
				"nombre": "Pasarelas de pago",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/pasarelas/bold/config", "desc": "Config Bold"},
					{"method": "POST", "path": "/api/v2/pasarelas/bold/save", "desc": "Guardar config Bold"},
					{"method": "GET", "path": "/api/v2/pasarelas/bold/logs", "desc": "Logs de webhooks Bold"},
					{"method": "GET", "path": "/api/v2/pasarelas/dlocal/config", "desc": "Config dLocal"},
					{"method": "POST", "path": "/api/v2/pasarelas/dlocal/save", "desc": "Guardar config dLocal"},
					{"method": "GET", "path": "/api/v2/pasarelas/dlocal/logs", "desc": "Logs de pagos dLocal"},
					{"method": "GET", "path": "/api/v2/pasarelas/paypal/config", "desc": "Config PayPal"},
					{"method": "POST", "path": "/api/v2/pasarelas/paypal/save", "desc": "Guardar config PayPal"},
				},
			},
			{
				"nombre": "Query Runner",
				"desc":   "Ejecutar queries SQL directamente contra las conexiones DB configuradas.",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/query-runner/connections", "desc": "Listar conexiones disponibles"},
					{"method": "GET", "path": "/api/v2/query-runner/databases", "desc": "Listar databases. Query: ?connection_id="},
					{"method": "GET", "path": "/api/v2/query-runner/tables", "desc": "Listar tablas. Query: ?connection_id=&database="},
					{"method": "GET", "path": "/api/v2/query-runner/test", "desc": "Probar conexión. Query: ?connection_id="},
					{"method": "POST", "path": "/api/v2/query-runner/run", "desc": "Ejecutar query", "body": "connection_id, database, query"},
					{"method": "GET", "path": "/api/v2/query-runner/history", "desc": "Historial de queries"},
					{"method": "GET", "path": "/api/v2/query-runner/columns", "desc": "Columnas de tabla. Query: ?connection_id=&database=&table="},
				},
			},
			{
				"nombre": "Hostinger",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/hostinger/vps", "desc": "Listar VPS Hostinger"},
					{"method": "GET", "path": "/api/v2/hostinger/domains", "desc": "Listar dominios"},
					{"method": "GET", "path": "/api/v2/hostinger/dns/:domain", "desc": "Registros DNS de un dominio"},
					{"method": "GET", "path": "/api/v2/hostinger/orders", "desc": "Listar órdenes"},
					{"method": "GET", "path": "/api/v2/hostinger/hosting", "desc": "Listar hosting"},
				},
			},
			{
				"nombre": "Cloudflare",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/cloudflare/zones", "desc": "Listar zonas"},
					{"method": "GET", "path": "/api/v2/cloudflare/zones/:zone_id/dns", "desc": "Registros DNS de una zona"},
					{"method": "POST", "path": "/api/v2/cloudflare/zones/:zone_id/dns", "desc": "Crear registro DNS"},
					{"method": "PUT", "path": "/api/v2/cloudflare/zones/:zone_id/dns/:record_id", "desc": "Actualizar registro DNS"},
					{"method": "DELETE", "path": "/api/v2/cloudflare/zones/:zone_id/dns/:record_id", "desc": "Eliminar registro DNS"},
				},
			},
			{
				"nombre": "Coolify",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/coolify/apps", "desc": "Listar aplicaciones"},
					{"method": "GET", "path": "/api/v2/coolify/apps/:uuid", "desc": "Detalle aplicación"},
					{"method": "GET", "path": "/api/v2/coolify/apps/:uuid/start", "desc": "Iniciar app"},
					{"method": "GET", "path": "/api/v2/coolify/apps/:uuid/stop", "desc": "Detener app"},
					{"method": "GET", "path": "/api/v2/coolify/apps/:uuid/restart", "desc": "Reiniciar app"},
					{"method": "POST", "path": "/api/v2/coolify/apps/:uuid/deploy", "desc": "Desplegar app"},
					{"method": "GET", "path": "/api/v2/coolify/servers", "desc": "Listar servidores Coolify"},
					{"method": "GET", "path": "/api/v2/coolify/servers/:uuid", "desc": "Detalle servidor"},
					{"method": "GET", "path": "/api/v2/coolify/servers/:uuid/resources", "desc": "Recursos del servidor"},
					{"method": "GET", "path": "/api/v2/coolify/services", "desc": "Listar servicios"},
					{"method": "GET", "path": "/api/v2/coolify/databases", "desc": "Listar databases"},
					{"method": "GET", "path": "/api/v2/coolify/projects", "desc": "Listar proyectos Coolify"},
					{"method": "GET", "path": "/api/v2/coolify/deployments", "desc": "Listar deployments"},
				},
			},
			{
				"nombre": "VCard API",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/vcard-api/config", "desc": "Ver config VCard API"},
					{"method": "GET", "path": "/api/v2/vcard-api/usuarios", "desc": "Listar usuarios VCard"},
					{"method": "GET", "path": "/api/v2/vcard-api/usuarios/:id", "desc": "Detalle usuario"},
					{"method": "GET", "path": "/api/v2/vcard-api/vcards", "desc": "Listar vcards"},
					{"method": "GET", "path": "/api/v2/vcard-api/planes", "desc": "Listar planes"},
					{"method": "GET", "path": "/api/v2/vcard-api/pagos", "desc": "Listar pagos"},
					{"method": "GET", "path": "/api/v2/vcard-api/miniwebs", "desc": "Listar miniwebs"},
				},
			},
			{
				"nombre": "Automatización IA: Plantillas de documento",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/plantillas-documento", "desc": "Listar plantillas. Query: ?tipo=cotizacion|contrato|acta|cuenta_cobro&search="},
					{"method": "GET", "path": "/api/v2/plantillas-documento/:id", "desc": "Detalle de una plantilla"},
					{"method": "POST", "path": "/api/v2/plantillas-documento", "desc": "Crear plantilla", "body": "tipo, nombre, contenido_html, version, activa"},
					{"method": "PUT", "path": "/api/v2/plantillas-documento/:id", "desc": "Actualizar plantilla"},
					{"method": "DELETE", "path": "/api/v2/plantillas-documento/:id", "desc": "Eliminar plantilla"},
				},
			},
			{
				"nombre": "Automatización IA: Tarifas",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/tarifas", "desc": "Listar tarifas. Query: ?categoria=hora_servicio|licencia|vm_azure|margen|otro&search="},
					{"method": "POST", "path": "/api/v2/tarifas", "desc": "Crear tarifa", "body": "categoria, nombre, valor, moneda, unidad, notas"},
					{"method": "PUT", "path": "/api/v2/tarifas/:id", "desc": "Actualizar tarifa"},
					{"method": "DELETE", "path": "/api/v2/tarifas/:id", "desc": "Eliminar tarifa"},
				},
			},
			{
				"nombre": "Automatización IA: Arquitecturas",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/arquitecturas", "desc": "Listar patrones de arquitectura de referencia. Query: ?search=&solo_referencias=true"},
					{"method": "POST", "path": "/api/v2/arquitecturas", "desc": "Genera el PDF de una propuesta técnica ya redactada", "body": "requerimiento, propuesta, nombre, cliente_id, guardar_como_referencia"},
				},
			},
			{
				"nombre": "Automatización IA: Cotizaciones",
				"endpoints": []fiber.Map{
					{"method": "POST", "path": "/api/v2/cotizaciones", "desc": "Genera el PDF de una cotización desde la plantilla activa. Consultar /api/v2/tarifas antes para calcular los items", "body": "cliente_id, alcance, tipo_proyecto, items: [{descripcion, cantidad, valor_unitario, unidad}]"},
				},
			},
			{
				"nombre": "Automatización IA: Historial de documentos generados",
				"endpoints": []fiber.Map{
					{"method": "GET", "path": "/api/v2/documentos-generados", "desc": "Historial de documentos generados. Query: ?tipo=&cliente_id="},
					{"method": "GET", "path": "/api/v2/documentos-generados/:id/download", "desc": "Descargar el PDF generado"},
				},
			},
		},
	}
	return c.JSON(spec)
}
