/**
 * Descomplicar® Crescimento Digital
 * https://descomplicar.pt
 */

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Desk-Moloni Module Routes
 * Defines routing for admin interface and API endpoints
 * 
 * @package    Desk-Moloni
 * @version    3.0.0
 * @author     Descomplicar Business Solutions
 */

// Admin Routes - Main Interface
$route['desk_moloni'] = 'desk_moloni/admin/index';
$route['desk_moloni/admin'] = 'desk_moloni/admin/index';
$route['desk_moloni/admin/index'] = 'desk_moloni/admin/index';

// Configuration Routes
$route['desk_moloni/admin/config'] = 'desk_moloni/admin/config';
$route['desk_moloni/admin/oauth_setup'] = 'desk_moloni/admin/oauth_setup';

// API Routes - OAuth
$route['desk_moloni/admin/oauth_authorize'] = 'desk_moloni/OAuthController/authorize';
$route['desk_moloni/admin/oauth_callback'] = 'desk_moloni/OAuthController/callback';

// API Routes - Status and Management
$route['desk_moloni/admin/get_status'] = 'desk_moloni/admin/get_status';
$route['desk_moloni/admin/test_connection'] = 'desk_moloni/admin/test_connection';
$route['desk_moloni/admin/reset_config'] = 'desk_moloni/admin/reset_config';
$route['desk_moloni/admin/export_config'] = 'desk_moloni/admin/export_config';
$route['desk_moloni/admin/manual_sync'] = 'desk_moloni/admin/manual_sync';

// Dashboard Routes
$route['desk_moloni/dashboard'] = 'desk_moloni/dashboard/index';
$route['desk_moloni/dashboard/index'] = 'desk_moloni/dashboard/index';
$route['desk_moloni/dashboard/analytics'] = 'desk_moloni/dashboard/get_analytics';
$route['desk_moloni/dashboard/realtime'] = 'desk_moloni/dashboard/get_realtime_status';
$route['desk_moloni/dashboard/trends'] = 'desk_moloni/dashboard/get_sync_trends';
$route['desk_moloni/dashboard/export'] = 'desk_moloni/dashboard/export_data';

// Queue Management Routes
$route['desk_moloni/queue'] = 'desk_moloni/queue/index';
$route['desk_moloni/queue/index'] = 'desk_moloni/queue/index';
$route['desk_moloni/queue/status'] = 'desk_moloni/queue/get_queue_status';
$route['desk_moloni/queue/add'] = 'desk_moloni/queue/add_task';
$route['desk_moloni/queue/cancel/(:num)'] = 'desk_moloni/queue/cancel_task/$1';
$route['desk_moloni/queue/retry/(:num)'] = 'desk_moloni/queue/retry_task/$1';
$route['desk_moloni/queue/bulk'] = 'desk_moloni/queue/bulk_operation';
$route['desk_moloni/queue/clear'] = 'desk_moloni/queue/clear_completed';
$route['desk_moloni/queue/toggle'] = 'desk_moloni/queue/toggle_processing';
$route['desk_moloni/queue/statistics'] = 'desk_moloni/queue/get_statistics';

// Mapping Management Routes
$route['desk_moloni/mapping'] = 'desk_moloni/mapping/index';
$route['desk_moloni/mapping/index'] = 'desk_moloni/mapping/index';
$route['desk_moloni/mapping/get'] = 'desk_moloni/mapping/get_mappings';
$route['desk_moloni/mapping/create'] = 'desk_moloni/mapping/create_mapping';
$route['desk_moloni/mapping/update/(:num)'] = 'desk_moloni/mapping/update_mapping/$1';
$route['desk_moloni/mapping/delete/(:num)'] = 'desk_moloni/mapping/delete_mapping/$1';
$route['desk_moloni/mapping/bulk'] = 'desk_moloni/mapping/bulk_operation';
$route['desk_moloni/mapping/discover'] = 'desk_moloni/mapping/auto_discover';
$route['desk_moloni/mapping/suggestions'] = 'desk_moloni/mapping/get_entity_suggestions';

// Sync Logs Routes
$route['desk_moloni/logs'] = 'desk_moloni/logs/index';
$route['desk_moloni/logs/index'] = 'desk_moloni/logs/index';
$route['desk_moloni/logs/get'] = 'desk_moloni/logs/get_logs';
$route['desk_moloni/logs/export'] = 'desk_moloni/logs/export_logs';
$route['desk_moloni/logs/clear'] = 'desk_moloni/logs/clear_logs';
$route['desk_moloni/logs/detail/(:num)'] = 'desk_moloni/logs/get_log_detail/$1';

// Client Portal Routes
$route['clients/desk_moloni'] = 'desk_moloni/clientportal/index';
$route['clients/desk_moloni/documents'] = 'desk_moloni/clientportal/get_invoices';
$route['clients/desk_moloni/download/(:num)'] = 'desk_moloni/clientportal/download_invoice/$1';

// API Endpoints for AJAX calls
$route['desk_moloni/api/sync/trigger'] = 'api/trigger_sync';
$route['desk_moloni/api/status/check'] = 'api/check_status';
$route['desk_moloni/api/oauth/refresh'] = 'api/refresh_oauth_token';

// Default controller routing
// Removed broad wildcard to avoid unintended routing collisions