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

/**
 * Super Admin Dashboard Controller
 */
class Dashboard extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('superadmin/Portal_model');
        $this->load->model('superadmin/Super_admin_model');
        $this->_check_super_admin();
    }

    private function _check_super_admin() {
        if ($this->session->userdata('super_admin_logged_in') !== TRUE) {
            redirect('superadmin/auth/login');
        }
    }

    public function index() {
        $data['title'] = 'Super Admin Dashboard';
        $data['current_page'] = 'dashboard';
        
        // Get dashboard stats
        $data['summary'] = $this->Portal_model->get_dashboard_summary();
        $data['portals'] = $this->Portal_model->get_all_with_stats();
        $data['recent_logs'] = $this->Super_admin_model->get_activity_logs(null, 10);
        
        $this->load->view('superadmin/layouts/header', $data);
        $this->load->view('superadmin/dashboard/index', $data);
        $this->load->view('superadmin/layouts/footer');
    }
}
