<?php
session_start();
require_once 'config/database.php';
require_once 'includes/auth.php';
require_once 'includes/functions.php';
require_once 'includes/translation.php';
require_once 'includes/page_permissions_helper.php';

if (!isset($_SESSION['user_id'])) {
    redirect('login.php');
}

// Set current page for permissions
$currentPage = 'reports_center';

// reports_center accessible to all logged-in users
// PagePermissions::requirePageAccess($currentPage);

$page_title = __('reports_center_page');
include 'includes/header.php';
?>

<style>
.report-card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    height: 100%;
}

.report-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.report-card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
}

.report-card-body {
    padding: 25px;
}

.report-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.9;
}

.report-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    transition: all 0.3s;
}

.report-btn:hover {
    transform: scale(1.05);
}

.section-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 30px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 3px solid #667eea;
}

.card-blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.card-green { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.card-orange { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.card-purple { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.card-red { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.card-teal { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }
</style>

<div class="container-fluid px-3 px-md-4">

    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h1 class="h3 mb-0">
                <i class="fas fa-folder-open"></i> <?php echo __('reports_center_page'); ?>
            </h1>
            <p class="text-muted mb-0"><?php echo __('all_reports_in_one_place'); ?></p>
        </div>
        <div class="d-flex flex-wrap gap-2">
            <?php if (PagePermissions::hasPermission($currentPage, 'export_comprehensive_excel')): ?>
            <button type="button" class="btn btn-success" onclick="exportComprehensiveReport()">
                <i class="fas fa-file-excel"></i> <span class="d-none d-sm-inline"><?php echo __('export_comprehensive_report'); ?></span><span class="d-sm-none"><?php echo __('export'); ?></span>
            </button>
            <?php endif; ?>
            
            <a href="index.php" class="btn btn-secondary">
                <i class="fas fa-arrow-<?php echo Translation::getDirection() == 'rtl' ? 'right' : 'left'; ?>"></i> <span class="d-none d-sm-inline"><?php echo __('back_to_home'); ?></span>
            </a>
        </div>
    </div>

    <!-- التقارير الطبية -->
    <h2 class="section-title">📋 <?php echo __('medical_reports'); ?></h2>
    <div class="row mb-4">
        <div class="col-md-4 col-sm-6 mb-3">
            <div class="report-card">
                <div class="report-card-header card-blue">
                    <div class="report-icon">
                        <i class="fas fa-file-medical"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('clinical_pharmacy_intervention_report'); ?></h5>
                    <small>Clinical Pharmacy Intervention</small>
                </div>
                <div class="report-card-body">
                    <p><?php echo __('clinical_pharmacy_intervention_desc'); ?></p>
                    <a href="clinical_pharmacy_intervention.php" class="btn btn-primary report-btn">
                        <i class="fas fa-plus"></i> <?php echo __('add_new_report'); ?>
                    </a>
                    <a href="reports.php" class="btn btn-outline-primary report-btn mt-2">
                        <i class="fas fa-list"></i> <?php echo __('view_all_reports'); ?>
                    </a>
                </div>
            </div>
        </div>

        <div class="col-md-4 col-sm-6 mb-3">
            <div class="report-card">
                <div class="report-card-header card-green">
                    <div class="report-icon">
                        <i class="fas fa-tablets"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('key_performance_indicators'); ?></h5>
                    <small>Key Performance Indicators</small>
                </div>
                <div class="report-card-body">
                    <p><?php echo __('kpi_desc'); ?></p>
                    <a href="key_performance_indicators.php" class="btn btn-success report-btn">
                        <i class="fas fa-chart-line"></i> <?php echo __('view_indicators'); ?>
                    </a>
                </div>
            </div>
        </div>

        <div class="col-md-4 col-sm-6 mb-3">
            <div class="report-card">
                <div class="report-card-header card-orange">
                    <div class="report-icon">
                        <i class="fas fa-table"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('monitoring_table'); ?></h5>
                    <small>Monitoring Table</small>
                </div>
                <div class="report-card-body">
                    <p><?php echo __('monitoring_table_desc'); ?></p>
                    <a href="monitoring_management.php" class="btn btn-warning report-btn">
                        <i class="fas fa-eye"></i> <?php echo __('open_monitoring_table'); ?>
                    </a>
                </div>
            </div>
        </div>
    </div>

    <!-- تقارير الأقسام -->
    <h2 class="section-title">🏥 <?php echo __('departments_reports'); ?></h2>
    <div class="row mb-4">
        <div class="col-md-3 col-sm-6 mb-3">
            <div class="report-card">
                <div class="report-card-header card-purple">
                    <div class="report-icon">
                        <i class="fas fa-hospital"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('icu_team_report'); ?></h5>
                    <small>ICU Report</small>
                </div>
                <div class="report-card-body">
                    <a href="icu_management.php" class="btn btn-info report-btn">
                        <i class="fas fa-hospital-alt"></i> <?php echo __('open_report'); ?>
                    </a>
                </div>
            </div>
        </div>

        <div class="col-md-3 col-sm-6 mb-3">
            <div class="report-card">
                <div class="report-card-header card-red">
                    <div class="report-icon">
                        <i class="fas fa-baby"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('nursery_team_report'); ?></h5>
                    <small>Nursery Report</small>
                </div>
                <div class="report-card-body">
                    <a href="nursery_management.php" class="btn btn-danger report-btn">
                        <i class="fas fa-baby-carriage"></i> <?php echo __('open_report'); ?>
                    </a>
                </div>
            </div>
        </div>

        <div class="col-md-3 col-sm-6 mb-3">
            <div class="report-card">
                <div class="report-card-header card-teal">
                    <div class="report-icon">
                        <i class="fas fa-procedures"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('medication_dispensed_operations'); ?></h5>
                    <small>Medication Dispensed</small>
                </div>
                <div class="report-card-body">
                    <a href="medication_dispensed_per_operation.php" class="btn btn-dark report-btn">
                        <i class="fas fa-syringe"></i> <?php echo __('open_record'); ?>
                    </a>
                </div>
            </div>
        </div>

        <div class="col-md-3 col-sm-6 mb-3">
            <div class="report-card">
                <div class="report-card-header card-blue">
                    <div class="report-icon">
                        <i class="fas fa-pills"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('comprehensive_pharmacy_form'); ?></h5>
                    <small>Comprehensive Pharmacy Form</small>
                </div>
                <div class="report-card-body">
                    <a href="pharmacy_internal_reports_management.php" class="btn btn-primary report-btn">
                        <i class="fas fa-prescription-bottle"></i> <?php echo __('open_form'); ?>
                    </a>
                </div>
            </div>
        </div>
    </div>

    <!-- تقارير العمليات -->
    <h2 class="section-title">⚙️ <?php echo __('operations_team_reports'); ?></h2>
    <div class="row mb-4">
        <div class="col-md-6 mb-3">
            <div class="report-card">
                <div class="report-card-header card-green">
                    <div class="report-icon">
                        <i class="fas fa-edit"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('operations_data_entry'); ?></h5>
                    <small>Operations Data Entry</small>
                </div>
                <div class="report-card-body">
                    <p><?php echo __('operations_data_entry_desc'); ?></p>
                    <a href="operations_management.php" class="btn btn-success report-btn">
                        <i class="fas fa-plus-circle"></i> <?php echo __('enter_new_data'); ?>
                    </a>
                </div>
            </div>
        </div>

        <div class="col-md-6 mb-3">
            <div class="report-card">
                <div class="report-card-header card-orange">
                    <div class="report-icon">
                        <i class="fas fa-clipboard-check"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('operations_team_report'); ?></h5>
                    <small>Operations Team Report</small>
                </div>
                <div class="report-card-body">
                    <p><?php echo __('operations_team_report_desc'); ?></p>
                    <a href="operations_team_report.php" class="btn btn-warning report-btn">
                        <i class="fas fa-list-alt"></i> <?php echo __('view_reports'); ?>
                    </a>
                </div>
            </div>
        </div>
    </div>

    <!-- الإحصائيات والتقارير -->
    <h2 class="section-title">📊 <?php echo __('statistics_analytics'); ?></h2>
    <div class="row mb-4">
        <div class="col-md-12 mb-3">
            <div class="report-card">
                <div class="report-card-header card-purple">
                    <div class="report-icon">
                        <i class="fas fa-chart-bar"></i>
                    </div>
                    <h5 class="mb-0"><?php echo __('system_reports_statistics'); ?></h5>
                    <small>System Reports & Statistics</small>
                </div>
                <div class="report-card-body">
                    <p><?php echo __('system_reports_statistics_desc'); ?></p>
                    <a href="antibiotic_management_reports.php" class="btn btn-info report-btn">
                        <i class="fas fa-chart-pie"></i> <?php echo __('view_statistics'); ?>
                    </a>
                </div>
            </div>
        </div>
    </div>

</div> <!-- End container-fluid -->

<?php include 'includes/footer.php'; ?>

