<?php
// member/compliance-report.php - Professional DPA Compliance Report
require_once '../config.php';
requireLogin();

$userId = $_SESSION['user_id'];
$user = getUserById($userId);
$org = getUserOrganization($userId);
$pdo = getDBConnection();
$orgId = $org['id'] ?? 0;

// Get latest compliance score
$scoreData = null;
try {
    $stmt = $pdo->prepare("SELECT * FROM compliance_scores WHERE organization_id = ? ORDER BY assessment_date DESC LIMIT 1");
    $stmt->execute([$orgId]);
    $scoreData = $stmt->fetch(PDO::FETCH_ASSOC);
} catch (Exception $e) {}

// Redirect if no assessment
if (!$scoreData) {
    header('Location: compliance-assessment.php?msg=Please complete the assessment first');
    exit;
}

// Get detailed responses with categories
$detailedResponses = [];
try {
    $stmt = $pdo->prepare("SELECT cr.*, dq.category, dq.question, dq.kenya_dpa_reference, dq.weight, dq.guidance
                           FROM compliance_responses cr
                           JOIN dpa_questions dq ON cr.question_id = dq.id
                           WHERE cr.organization_id = ? AND cr.assessment_date = date('now')
                           ORDER BY dq.sort_order");
    $stmt->execute([$orgId]);
    $detailedResponses = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (Exception $e) {}

// Group by category
$categoryResults = [];
foreach ($detailedResponses as $resp) {
    $cat = $resp['category'];
    if (!isset($categoryResults[$cat])) {
        $categoryResults[$cat] = [
            'questions' => [],
            'total_earned' => 0,
            'total_max' => 0,
            'answered' => 0,
            'compliant' => 0,
            'partial' => 0,
            'non_compliant' => 0
        ];
    }
    $categoryResults[$cat]['questions'][] = $resp;
    $categoryResults[$cat]['total_earned'] += $resp['response_score'];
    $categoryResults[$cat]['total_max'] += (100 * ($resp['weight'] ?? 1));
    $categoryResults[$cat]['answered']++;
    
    if ($resp['response'] === 'yes' || $resp['response'] === 'not_applicable') {
        $categoryResults[$cat]['compliant']++;
    } elseif ($resp['response'] === 'partially' || $resp['response'] === 'in_progress') {
        $categoryResults[$cat]['partial']++;
    } else {
        $categoryResults[$cat]['non_compliant']++;
    }
}

// Calculate category percentages
foreach ($categoryResults as $cat => &$data) {
    $data['percentage'] = $data['total_max'] > 0 ? round(($data['total_earned'] / $data['total_max']) * 100) : 0;
}

// Get DPO details
$dpoDetails = null;
try {
    $stmt = $pdo->prepare("SELECT * FROM organization_dpo WHERE organization_id = ? AND status = 'active' LIMIT 1");
    $stmt->execute([$orgId]);
    $dpoDetails = $stmt->fetch(PDO::FETCH_ASSOC);
} catch (Exception $e) {}

// Get breach statistics
$breachStats = null;
try {
    $stmt = $pdo->prepare("SELECT COUNT(*) as total, 
                           SUM(CASE WHEN status NOT IN ('resolved', 'closed') THEN 1 ELSE 0 END) as open_count
                           FROM breach_reports WHERE organization_id = ?");
    $stmt->execute([$orgId]);
    $breachStats = $stmt->fetch(PDO::FETCH_ASSOC);
} catch (Exception $e) {}

// Get processor count
$processorCount = 0;
try {
    $stmt = $pdo->prepare("SELECT COUNT(*) as count FROM processor_assessments WHERE organization_id = ?");
    $stmt->execute([$orgId]);
    $processorCount = $stmt->fetch(PDO::FETCH_ASSOC)['count'] ?? 0;
} catch (Exception $e) {}

// Get website scan results
$websiteScan = null;
try {
    $stmt = $pdo->prepare("SELECT scan_data FROM website_scan_cache WHERE domain = ? ORDER BY scan_date DESC LIMIT 1");
    $stmt->execute([$org['website'] ?? '']);
    $scanRow = $stmt->fetch(PDO::FETCH_ASSOC);
    if ($scanRow) {
        $websiteScan = json_decode($scanRow['scan_data'], true);
    }
} catch (Exception $e) {}

// Generate findings and recommendations
$findings = [];
$recommendations = [];
$criticalFindings = [];
$positiveFindings = [];

foreach ($categoryResults as $cat => $data) {
    $pct = $data['percentage'];
    
    if ($pct < 40) {
        $criticalFindings[] = [
            'category' => $cat,
            'score' => $pct,
            'detail' => "Only {$data['compliant']} of {$data['answered']} requirements met. {$data['non_compliant']} critical gaps found.",
            'impact' => 'High risk of ODPC penalties and data breaches'
        ];
        $recommendations[] = [
            'priority' => 'Critical',
            'category' => $cat,
            'action' => "Immediate remediation required. Address all {$data['non_compliant']} non-compliant items within 30 days.",
            'timeline' => '30 days',
            'penalty_risk' => 'Up to KES 5,000,000 or 1% of annual turnover'
        ];
    } elseif ($pct < 60) {
        $findings[] = [
            'category' => $cat,
            'score' => $pct,
            'detail' => "{$data['compliant']} compliant, {$data['partial']} partial, {$data['non_compliant']} non-compliant out of {$data['answered']} requirements.",
            'impact' => 'Moderate risk - requires attention'
        ];
        $recommendations[] = [
            'priority' => 'High',
            'category' => $cat,
            'action' => "Address {$data['non_compliant']} non-compliant items and improve {$data['partial']} partial implementations.",
            'timeline' => '60 days',
            'penalty_risk' => 'Potential ODPC enforcement notice'
        ];
    } elseif ($pct < 80) {
        $findings[] = [
            'category' => $cat,
            'score' => $pct,
            'detail' => "{$data['compliant']} compliant, {$data['partial']} partial. Good progress but room for improvement.",
            'impact' => 'Low to moderate risk'
        ];
        $recommendations[] = [
            'priority' => 'Medium',
            'category' => $cat,
            'action' => "Continue improving. Focus on converting {$data['partial']} partial items to fully compliant.",
            'timeline' => '90 days',
            'penalty_risk' => 'Low immediate risk'
        ];
    } else {
        $positiveFindings[] = [
            'category' => $cat,
            'score' => $pct,
            'detail' => "{$data['compliant']} of {$data['answered']} requirements fully met. Strong compliance posture.",
            'impact' => 'Well protected'
        ];
    }
}

// Industry-specific recommendations
$industry = $org['industry'] ?? 'General';
$industrySpecific = [];
switch ($industry) {
    case 'Healthcare':
        $industrySpecific[] = "Ensure patient data encryption meets Ministry of Health standards in addition to DPA requirements.";
        $industrySpecific[] = "Implement audit trails for all access to patient health records.";
        $industrySpecific[] = "Review telehealth data processing agreements for cross-border data transfer compliance.";
        break;
    case 'Finance':
        $industrySpecific[] = "Align data protection measures with CBK cybersecurity guidelines and DPA requirements.";
        $industrySpecific[] = "Implement real-time fraud monitoring while ensuring data minimization principles.";
        $industrySpecific[] = "Review credit scoring algorithms for automated decision-making compliance under Section 34.";
        break;
    case 'Education':
        $industrySpecific[] = "Implement age verification and parental consent mechanisms for students under 18.";
        $industrySpecific[] = "Review online learning platforms for cross-border data transfer compliance.";
        $industrySpecific[] = "Ensure student data retention policies align with both DPA and education regulations.";
        break;
    case 'Technology':
        $industrySpecific[] = "Embed Privacy by Design in all product development lifecycles.";
        $industrySpecific[] = "Conduct DPIAs before launching new features that process personal data.";
        $industrySpecific[] = "Review API data sharing agreements with third-party developers.";
        break;
    default:
        $industrySpecific[] = "Register with ODPC as a Data Controller/Processor if not already done.";
        $industrySpecific[] = "Appoint a qualified Data Protection Officer as required by Section 24.";
        $industrySpecific[] = "Conduct annual data protection training for all staff handling personal data.";
}

$reportDate = date('F j, Y');
$reportRef = 'SG-DPA-' . date('Ymd') . '-' . strtoupper(substr($org['name'] ?? 'ORG', 0, 4));
$overallScore = $scoreData['overall_score'] ?? 0;
$riskLevel = $scoreData['risk_level'] ?? 'Not Assessed';

// Determine risk color
$riskColor = '#ef4444';
if ($riskLevel === 'Low') $riskColor = '#10b981';
elseif ($riskLevel === 'Medium') $riskColor = '#f59e0b';
elseif ($riskLevel === 'High') $riskColor = '#f97316';

// Get compliance rating
$rating = 'Non-Compliant';
$ratingClass = 'critical';
if ($overallScore >= 90) { $rating = 'Fully Compliant'; $ratingClass = 'excellent'; }
elseif ($overallScore >= 80) { $rating = 'Mostly Compliant'; $ratingClass = 'good'; }
elseif ($overallScore >= 60) { $rating = 'Partially Compliant'; $ratingClass = 'fair'; }
elseif ($overallScore >= 40) { $rating = 'Needs Improvement'; $ratingClass = 'poor'; }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DPA Compliance Report - <?php echo htmlspecialchars($org['name'] ?? 'Organization'); ?></title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary: #0f3b5c; --secondary: #2c7da0; --success: #10b981;
            --warning: #f59e0b; --danger: #ef4444; --dark: #1e293b;
            --gray: #64748b; --light: #f8fafc;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        
        body {
            font-family: 'Inter', -apple-system, sans-serif;
            background: #f1f5f9; color: var(--dark); line-height: 1.7;
            font-size: 12px;
        }
        
        /* Print Styles */
        @media print {
            body { background: white; font-size: 11px; }
            .no-print { display: none !important; }
            .page-break { page-break-before: always; }
            .report-container { box-shadow: none !important; max-width: 100% !important; margin: 0 !important; }
        }
        
        @media screen {
            .report-container { max-width: 1000px; margin: 20px auto; }
        }
        
        .report-container {
            background: white; box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        }
        
        /* Cover Page */
        .cover-page {
            background: linear-gradient(135deg, var(--primary) 0%, #0a2538 100%);
            color: white; padding: 60px 50px; text-align: center;
            min-height: 100vh; display: flex; flex-direction: column;
            justify-content: center; align-items: center; position: relative;
            overflow: hidden;
        }
        .cover-page::before {
            content: ''; position: absolute; top: -50%; right: -20%;
            width: 500px; height: 500px; background: radial-gradient(circle, rgba(255,255,255,0.05), transparent);
            border-radius: 50%;
        }
        .cover-page::after {
            content: ''; position: absolute; bottom: -10%; left: -10%;
            width: 300px; height: 300px; background: radial-gradient(circle, rgba(255,255,255,0.03), transparent);
            border-radius: 50%;
        }
        .cover-page * { position: relative; z-index: 1; }
        
        .cover-logo { font-size: 48px; margin-bottom: 20px; font-weight: 800; letter-spacing: -1px; }
        .cover-logo i { color: var(--success); margin-right: 10px; }
        .cover-title { font-size: 28px; font-weight: 700; margin-bottom: 10px; letter-spacing: -0.5px; }
        .cover-subtitle { font-size: 16px; opacity: 0.8; margin-bottom: 40px; }
        .cover-divider { width: 100px; height: 3px; background: var(--success); margin: 0 auto 30px; }
        .cover-org { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
        .cover-meta { font-size: 13px; opacity: 0.7; margin-bottom: 4px; }
        .cover-date { font-size: 14px; margin-top: 30px; opacity: 0.9; }
        .cover-ref { font-size: 11px; margin-top: 10px; opacity: 0.6; letter-spacing: 1px; text-transform: uppercase; }
        
        /* Score Banner */
        .score-banner {
            background: linear-gradient(135deg, <?php echo $riskColor; ?>15, <?php echo $riskColor; ?>05);
            border: 2px solid <?php echo $riskColor; ?>33;
            border-radius: 16px; padding: 30px; margin: 30px;
            text-align: center;
        }
        .score-big { font-size: 64px; font-weight: 800; color: <?php echo $riskColor; ?>; }
        .score-label { font-size: 14px; color: var(--gray); margin-top: 4px; }
        .score-rating { 
            display: inline-block; padding: 6px 20px; border-radius: 20px;
            font-weight: 600; font-size: 14px; margin-top: 10px;
        }
        .rating-excellent { background: rgba(16,185,129,0.15); color: #10b981; }
        .rating-good { background: rgba(16,185,129,0.1); color: #059669; }
        .rating-fair { background: rgba(245,158,11,0.15); color: #d97706; }
        .rating-poor { background: rgba(249,115,22,0.15); color: #ea580c; }
        .rating-critical { background: rgba(239,68,68,0.15); color: #dc2626; }
        
        /* Content Sections */
        .content-section { padding: 30px; }
        .section-title {
            font-size: 18px; font-weight: 700; color: var(--primary);
            border-bottom: 2px solid var(--secondary); padding-bottom: 10px;
            margin-bottom: 20px; display: flex; align-items: center; gap: 10px;
        }
        .section-title i { color: var(--secondary); }
        
        /* Info Grid */
        .info-grid {
            display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
            margin-bottom: 20px;
        }
        .info-item { padding: 14px; background: var(--light); border-radius: 8px; }
        .info-label { font-size: 10px; color: var(--gray); text-transform: uppercase; letter-spacing: 1px; }
        .info-value { font-size: 14px; font-weight: 600; margin-top: 4px; }
        
        /* Category Card */
        .category-card {
            border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 16px;
            overflow: hidden;
        }
        .category-header {
            padding: 14px 20px; display: flex; justify-content: space-between;
            align-items: center; background: var(--light); border-bottom: 1px solid #e2e8f0;
        }
        .category-name { font-weight: 600; font-size: 13px; }
        .category-score { font-weight: 700; font-size: 18px; }
        .category-body { padding: 16px 20px; }
        
        .question-row {
            display: flex; justify-content: space-between; align-items: center;
            padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 11px;
        }
        .question-row:last-child { border-bottom: none; }
        .question-text { flex: 1; }
        .question-status {
            padding: 3px 10px; border-radius: 12px; font-weight: 600; font-size: 10px;
            white-space: nowrap; margin-left: 10px;
        }
        .status-compliant { background: rgba(16,185,129,0.1); color: #10b981; }
        .status-partial { background: rgba(245,158,11,0.1); color: #f59e0b; }
        .status-noncompliant { background: rgba(239,68,68,0.1); color: #ef4444; }
        .status-na { background: rgba(100,116,139,0.1); color: #64748b; }
        
        /* Finding Card */
        .finding-card {
            padding: 16px; border-radius: 10px; margin-bottom: 12px;
            border-left: 4px solid;
        }
        .finding-critical { background: rgba(239,68,68,0.05); border-color: #ef4444; }
        .finding-warning { background: rgba(245,158,11,0.05); border-color: #f59e0b; }
        .finding-positive { background: rgba(16,185,129,0.05); border-color: #10b981; }
        .finding-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
        .finding-detail { font-size: 11px; color: var(--gray); }
        
        /* Recommendation */
        .recommendation-card {
            padding: 16px; border: 1px solid #e2e8f0; border-radius: 10px;
            margin-bottom: 12px;
        }
        .rec-priority {
            display: inline-block; padding: 3px 10px; border-radius: 12px;
            font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
        }
        .priority-critical { background: rgba(239,68,68,0.1); color: #ef4444; }
        .priority-high { background: rgba(245,158,11,0.1); color: #f59e0b; }
        .priority-medium { background: rgba(59,130,246,0.1); color: #3b82f6; }
        
        /* Website Scan Results */
        .scan-check {
            display: flex; align-items: center; gap: 12px; padding: 12px;
            border-radius: 8px; margin-bottom: 8px;
        }
        .scan-pass { background: rgba(16,185,129,0.05); border: 1px solid rgba(16,185,129,0.2); }
        .scan-warning { background: rgba(245,158,11,0.05); border: 1px solid rgba(245,158,11,0.2); }
        .scan-fail { background: rgba(239,68,68,0.05); border: 1px solid rgba(239,68,68,0.2); }
        .scan-icon { font-size: 24px; width: 40px; text-align: center; }
        
        /* Footer */
        .report-footer {
            background: var(--dark); color: white; padding: 30px;
            text-align: center; font-size: 11px;
        }
        .report-footer .contact { margin-top: 10px; opacity: 0.7; }
        
        /* Buttons */
        .btn {
            display: inline-flex; align-items: center; gap: 8px;
            padding: 12px 24px; border: none; border-radius: 10px;
            font-weight: 600; font-size: 14px; cursor: pointer;
            font-family: inherit; text-decoration: none; transition: all 0.2s;
        }
        .btn-primary { background: var(--primary); color: white; }
        .btn-success { background: var(--success); color: white; }
        .btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
        .btn-group { display: flex; gap: 12px; flex-wrap: wrap; padding: 20px 30px; justify-content: center; }
        
        /* Table of Contents */
        .toc { padding: 30px; background: var(--light); }
        .toc-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
        .toc-item { 
            display: flex; justify-content: space-between; padding: 8px 0;
            border-bottom: 1px dotted #cbd5e1; font-size: 12px;
        }
        
        /* Progress Bar */
        .mini-bar {
            height: 6px; background: #e2e8f0; border-radius: 3px;
            overflow: hidden; margin-top: 4px; width: 100px;
        }
        .mini-fill { height: 100%; border-radius: 3px; }
        
        @media (max-width: 768px) {
            .info-grid { grid-template-columns: 1fr; }
            .cover-page { padding: 30px 20px; }
            .cover-title { font-size: 22px; }
            .score-big { font-size: 48px; }
        }
    </style>
</head>
<body>
    <!-- Action Buttons (No Print) -->
    <div class="btn-group no-print" style="background: white; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; z-index: 100;">
        <button class="btn btn-primary" onclick="window.print()">
            <i class="fas fa-print"></i> Print / Save as PDF
        </button>
        <button class="btn btn-success" onclick="window.location.href='compliance-assessment.php'">
            <i class="fas fa-redo"></i> Re-assess
        </button>
        <a href="dashboard.php" class="btn" style="background: var(--secondary); color: white;">
            <i class="fas fa-tachometer-alt"></i> Dashboard
        </a>
    </div>
    
    <div class="report-container">
        
        <!-- ============================================= -->
        <!-- COVER PAGE -->
        <!-- ============================================= -->
        <div class="cover-page">
            <div class="cover-logo">
                <i class="fas fa-shield-alt"></i> Soul Guard
            </div>
            <div class="cover-divider"></div>
            <h1 class="cover-title">Data Protection Act Compliance Report</h1>
            <p class="cover-subtitle">Kenya Data Protection Act, 2019 - Comprehensive Assessment</p>
            
            <div style="margin-top: 40px;">
                <p class="cover-org"><?php echo htmlspecialchars(strtoupper($org['name'] ?? 'Organization')); ?></p>
                <?php if (!empty($org['industry'])): ?>
                    <p class="cover-meta">Industry: <?php echo htmlspecialchars($org['industry']); ?></p>
                <?php endif; ?>
                <?php if (!empty($org['registration_number'])): ?>
                    <p class="cover-meta">Reg. No: <?php echo htmlspecialchars($org['registration_number']); ?></p>
                <?php endif; ?>
                <?php if (!empty($org['website'])): ?>
                    <p class="cover-meta"><?php echo htmlspecialchars($org['website']); ?></p>
                <?php endif; ?>
            </div>
            
            <div style="margin-top: 60px;">
                <div class="score-big"><?php echo $overallScore; ?>%</div>
                <div class="score-label">Overall Compliance Score</div>
                <span class="score-rating rating-<?php echo $ratingClass; ?>">
                    <?php echo $rating; ?> - <?php echo $riskLevel; ?> Risk
                </span>
            </div>
            
            <p class="cover-date">Report Date: <?php echo $reportDate; ?></p>
            <p class="cover-ref">Reference: <?php echo $reportRef; ?></p>
            <p class="cover-meta" style="margin-top: 20px;">
                Prepared by: Christopher Khayere | Contact: 0799874578
            </p>
        </div>
        
        <!-- ============================================= -->
        <!-- TABLE OF CONTENTS -->
        <!-- ============================================= -->
        <div class="toc page-break">
            <h2 class="toc-title">Table of Contents</h2>
            <div class="toc-item"><span>1. Executive Summary</span><span>3</span></div>
            <div class="toc-item"><span>2. Organization Information</span><span>4</span></div>
            <div class="toc-item"><span>3. Compliance Score Overview</span><span>5</span></div>
            <div class="toc-item"><span>4. Category Breakdown</span><span>6</span></div>
            <div class="toc-item"><span>5. Detailed Findings</span><span>8</span></div>
            <div class="toc-item"><span>6. Website Compliance Scan</span><span>10</span></div>
            <div class="toc-item"><span>7. Recommendations</span><span>11</span></div>
            <div class="toc-item"><span>8. Industry-Specific Guidance</span><span>13</span></div>
            <div class="toc-item"><span>9. Next Steps & Timeline</span><span>14</span></div>
        </div>
        
        <!-- ============================================= -->
        <!-- 1. EXECUTIVE SUMMARY -->
        <!-- ============================================= -->
        <div class="content-section page-break">
            <h2 class="section-title"><i class="fas fa-file-alt"></i> 1. Executive Summary</h2>
            
            <p style="margin-bottom: 16px; font-size: 13px;">
                This report presents the findings of a comprehensive Data Protection Act (DPA) compliance assessment 
                conducted for <strong><?php echo htmlspecialchars($org['name'] ?? 'the organization'); ?></strong> 
                based on the <strong>Kenya Data Protection Act, 2019</strong> and guidelines issued by the 
                Office of the Data Protection Commissioner (ODPC).
            </p>
            
            <div class="score-banner" style="margin: 20px 0;">
                <table style="width: 100%; text-align: center;">
                    <tr>
                        <td>
                            <div style="font-size: 36px; font-weight: 800; color: <?php echo $riskColor; ?>;"><?php echo $overallScore; ?>%</div>
                            <div style="font-size: 11px; color: var(--gray);">Overall Score</div>
                        </td>
                        <td>
                            <div style="font-size: 36px; font-weight: 800; color: <?php echo $riskColor; ?>;"><?php echo $riskLevel; ?></div>
                            <div style="font-size: 11px; color: var(--gray);">Risk Level</div>
                        </td>
                        <td>
                            <div style="font-size: 36px; font-weight: 800; color: var(--secondary);"><?php echo count($detailedResponses); ?></div>
                            <div style="font-size: 11px; color: var(--gray);">Requirements Assessed</div>
                        </td>
                        <td>
                            <div style="font-size: 36px; font-weight: 800; color: var(--secondary);"><?php echo count($categoryResults); ?></div>
                            <div style="font-size: 11px; color: var(--gray);">Categories Evaluated</div>
                        </td>
                    </tr>
                </table>
            </div>
            
            <p style="font-size: 13px;">
                <strong>Assessment Scope:</strong> This assessment covered <?php echo count($categoryResults); ?> key areas of the Kenya Data Protection Act, 
                including consent management, data subject rights, security measures, breach management, processor management, 
                and ODPC registration requirements.
            </p>
            
            <?php if ($overallScore < 40): ?>
                <div class="finding-card finding-critical" style="margin-top: 16px;">
                    <div class="finding-title">⚠️ Critical Compliance Gap Identified</div>
                    <div class="finding-detail">
                        Your organization's compliance score of <?php echo $overallScore; ?>% indicates significant gaps in data protection practices. 
                        Immediate action is required to address non-compliance and mitigate the risk of ODPC penalties, 
                        which can include fines up to KES 5,000,000 or 1% of annual turnover.
                    </div>
                </div>
            <?php elseif ($overallScore < 60): ?>
                <div class="finding-card finding-warning" style="margin-top: 16px;">
                    <div class="finding-title">⚠️ Significant Improvements Required</div>
                    <div class="finding-detail">
                        Your organization has established some data protection measures but several key areas require attention. 
                        Prioritize addressing critical gaps to reduce regulatory risk.
                    </div>
                </div>
            <?php else: ?>
                <div class="finding-card finding-positive" style="margin-top: 16px;">
                    <div class="finding-title">✅ Good Compliance Foundation</div>
                    <div class="finding-detail">
                        Your organization demonstrates a solid understanding of data protection requirements. 
                        Continue monitoring and improving to maintain compliance as regulations evolve.
                    </div>
                </div>
            <?php endif; ?>
        </div>
        
        <!-- ============================================= -->
        <!-- 2. ORGANIZATION INFORMATION -->
        <!-- ============================================= -->
        <div class="content-section page-break">
            <h2 class="section-title"><i class="fas fa-building"></i> 2. Organization Information</h2>
            
            <div class="info-grid">
                <div class="info-item">
                    <div class="info-label">Organization Name</div>
                    <div class="info-value"><?php echo htmlspecialchars($org['name'] ?? 'Not provided'); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Industry / Sector</div>
                    <div class="info-value"><?php echo htmlspecialchars($org['industry'] ?? 'Not specified'); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Registration Number</div>
                    <div class="info-value"><?php echo htmlspecialchars($org['registration_number'] ?? 'Not registered'); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Website</div>
                    <div class="info-value"><?php echo htmlspecialchars($org['website'] ?? 'Not provided'); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Organization Size</div>
                    <div class="info-value"><?php echo htmlspecialchars($org['size'] ?? 'Not specified'); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Data Protection Officer</div>
                    <div class="info-value">
                        <?php if ($dpoDetails): ?>
                            <?php echo htmlspecialchars($dpoDetails['name']); ?><br>
                            <small style="color: var(--gray);"><?php echo htmlspecialchars($dpoDetails['email']); ?></small>
                        <?php else: ?>
                            <span style="color: #ef4444;">Not appointed</span>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="info-item">
                    <div class="info-label">Assessment Date</div>
                    <div class="info-value"><?php echo $reportDate; ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Next Assessment Due</div>
                    <div class="info-value"><?php echo date('F j, Y', strtotime('+3 months')); ?></div>
                </div>
            </div>
            
            <div class="info-grid" style="margin-top: 16px;">
                <div class="info-item">
                    <div class="info-label">Total DPIAs Completed</div>
                    <div class="info-value"><?php 
                        try {
                            $stmt = $pdo->prepare("SELECT COUNT(*) as count FROM dpia_records WHERE organization_id = ?");
                            $stmt->execute([$orgId]);
                            echo $stmt->fetch(PDO::FETCH_ASSOC)['count'] ?? 0;
                        } catch (Exception $e) { echo '0'; }
                    ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Open Breach Reports</div>
                    <div class="info-value" style="color: <?php echo ($breachStats['open_count'] ?? 0) > 0 ? '#ef4444' : '#10b981'; ?>;">
                        <?php echo $breachStats['open_count'] ?? 0; ?>
                    </div>
                </div>
                <div class="info-item">
                    <div class="info-label">Data Processors</div>
                    <div class="info-value"><?php echo $processorCount; ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Report Reference</div>
                    <div class="info-value" style="font-size: 11px;"><?php echo $reportRef; ?></div>
                </div>
            </div>
        </div>
        
        <!-- ============================================= -->
        <!-- 3. COMPLIANCE SCORE OVERVIEW -->
        <!-- ============================================= -->
        <div class="content-section page-break">
            <h2 class="section-title"><i class="fas fa-chart-pie"></i> 3. Compliance Score Overview</h2>
            
            <div class="score-banner" style="margin: 0 0 20px 0;">
                <div class="score-big"><?php echo $overallScore; ?>%</div>
                <div class="score-label">Overall Compliance Score</div>
                <span class="score-rating rating-<?php echo $ratingClass; ?>"><?php echo $rating; ?></span>
            </div>
            
            <!-- Score Breakdown Table -->
            <table style="width: 100%; border-collapse: collapse; margin-top: 20px;">
                <thead>
                    <tr style="background: var(--light);">
                        <th style="padding: 12px; text-align: left; border-bottom: 2px solid #e2e8f0;">Score Component</th>
                        <th style="padding: 12px; text-align: center; border-bottom: 2px solid #e2e8f0;">Score</th>
                        <th style="padding: 12px; text-align: center; border-bottom: 2px solid #e2e8f0;">Max</th>
                        <th style="padding: 12px; text-align: center; border-bottom: 2px solid #e2e8f0;">Status</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td style="padding: 10px 12px; border-bottom: 1px solid #f1f5f9;">DPIA & Legal Basis</td>
                        <td style="padding: 10px 12px; text-align: center; font-weight: 600;"><?php echo $scoreData['dpia_score'] ?? 0; ?></td>
                        <td style="padding: 10px 12px; text-align: center; color: var(--gray);">25</td>
                        <td style="padding: 10px 12px; text-align: center;">
                            <?php $s = $scoreData['dpia_score'] ?? 0; ?>
                            <span style="color: <?php echo $s >= 20 ? '#10b981' : ($s >= 15 ? '#f59e0b' : '#ef4444'); ?>; font-weight: 600;">
                                <?php echo $s >= 20 ? 'Good' : ($s >= 15 ? 'Fair' : 'Poor'); ?>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 10px 12px; border-bottom: 1px solid #f1f5f9;">Breach Readiness</td>
                        <td style="padding: 10px 12px; text-align: center; font-weight: 600;"><?php echo $scoreData['breach_readiness_score'] ?? 0; ?></td>
                        <td style="padding: 10px 12px; text-align: center; color: var(--gray);">25</td>
                        <td style="padding: 10px 12px; text-align: center;">
                            <?php $s = $scoreData['breach_readiness_score'] ?? 0; ?>
                            <span style="color: <?php echo $s >= 20 ? '#10b981' : ($s >= 15 ? '#f59e0b' : '#ef4444'); ?>; font-weight: 600;">
                                <?php echo $s >= 20 ? 'Good' : ($s >= 15 ? 'Fair' : 'Poor'); ?>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 10px 12px; border-bottom: 1px solid #f1f5f9;">Processor Management</td>
                        <td style="padding: 10px 12px; text-align: center; font-weight: 600;"><?php echo $scoreData['processor_management_score'] ?? 0; ?></td>
                        <td style="padding: 10px 12px; text-align: center; color: var(--gray);">25</td>
                        <td style="padding: 10px 12px; text-align: center;">
                            <?php $s = $scoreData['processor_management_score'] ?? 0; ?>
                            <span style="color: <?php echo $s >= 20 ? '#10b981' : ($s >= 15 ? '#f59e0b' : '#ef4444'); ?>; font-weight: 600;">
                                <?php echo $s >= 20 ? 'Good' : ($s >= 15 ? 'Fair' : 'Poor'); ?>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 10px 12px; border-bottom: 1px solid #f1f5f9;">ODPC Alignment</td>
                        <td style="padding: 10px 12px; text-align: center; font-weight: 600;"><?php echo $scoreData['odpc_alignment_score'] ?? 0; ?></td>
                        <td style="padding: 10px 12px; text-align: center; color: var(--gray);">25</td>
                        <td style="padding: 10px 12px; text-align: center;">
                            <?php $s = $scoreData['odpc_alignment_score'] ?? 0; ?>
                            <span style="color: <?php echo $s >= 20 ? '#10b981' : ($s >= 15 ? '#f59e0b' : '#ef4444'); ?>; font-weight: 600;">
                                <?php echo $s >= 20 ? 'Good' : ($s >= 15 ? 'Fair' : 'Poor'); ?>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding: 10px 12px; font-weight: 600;">Data Protection Measures</td>
                        <td style="padding: 10px 12px; text-align: center; font-weight: 600;"><?php echo $scoreData['data_protection_score'] ?? 0; ?></td>
                        <td style="padding: 10px 12px; text-align: center; color: var(--gray);">25</td>
                        <td style="padding: 10px 12px; text-align: center;">
                            <?php $s = $scoreData['data_protection_score'] ?? 0; ?>
                            <span style="color: <?php echo $s >= 20 ? '#10b981' : ($s >= 15 ? '#f59e0b' : '#ef4444'); ?>; font-weight: 600;">
                                <?php echo $s >= 20 ? 'Good' : ($s >= 15 ? 'Fair' : 'Poor'); ?>
                            </span>
                        </td>
                    </tr>
                    <tr style="background: var(--light); font-weight: 700;">
                        <td style="padding: 12px; font-size: 14px;">OVERALL</td>
                        <td style="padding: 12px; text-align: center; font-size: 16px; color: <?php echo $riskColor; ?>;"><?php echo $overallScore; ?></td>
                        <td style="padding: 12px; text-align: center; color: var(--gray);">100</td>
                        <td style="padding: 12px; text-align: center;">
                            <span style="color: <?php echo $riskColor; ?>; font-weight: 700;"><?php echo $riskLevel; ?> Risk</span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        
        <!-- ============================================= -->
        <!-- 4. CATEGORY BREAKDOWN -->
        <!-- ============================================= -->
        <div class="content-section page-break">
            <h2 class="section-title"><i class="fas fa-list-alt"></i> 4. Category Breakdown</h2>
            
            <?php foreach ($categoryResults as $cat => $data): 
                $catColor = '#10b981';
                if ($data['percentage'] < 40) $catColor = '#ef4444';
                elseif ($data['percentage'] < 60) $catColor = '#f59e0b';
                elseif ($data['percentage'] < 80) $catColor = '#f97316';
            ?>
            <div class="category-card">
                <div class="category-header">
                    <div>
                        <div class="category-name"><?php echo htmlspecialchars($cat); ?></div>
                        <div style="font-size: 10px; color: var(--gray);">
                            <?php echo $data['answered']; ?> questions | 
                            Compliant: <?php echo $data['compliant']; ?> | 
                            Partial: <?php echo $data['partial']; ?> | 
                            Non-Compliant: <?php echo $data['non_compliant']; ?>
                        </div>
                    </div>
                    <div class="category-score" style="color: <?php echo $catColor; ?>;">
                        <?php echo $data['percentage']; ?>%
                    </div>
                </div>
                <div class="category-body">
                    <?php foreach ($data['questions'] as $q): 
                        $statusClass = 'status-noncompliant';
                        $statusLabel = 'Non-Compliant';
                        if ($q['response'] === 'yes' || $q['response'] === 'not_applicable') {
                            $statusClass = 'status-compliant';
                            $statusLabel = ($q['response'] === 'yes') ? 'Compliant' : 'N/A';
                        } elseif ($q['response'] === 'partially') {
                            $statusClass = 'status-partial';
                            $statusLabel = 'Partially';
                        } elseif ($q['response'] === 'in_progress') {
                            $statusClass = 'status-partial';
                            $statusLabel = 'In Progress';
                        }
                    ?>
                    <div class="question-row">
                        <span class="question-text"><?php echo htmlspecialchars($q['question']); ?></span>
                        <span class="question-status <?php echo $statusClass; ?>"><?php echo $statusLabel; ?></span>
                    </div>
                    <?php endforeach; ?>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
        
        <!-- ============================================= -->
        <!-- 5. DETAILED FINDINGS -->
        <!-- ============================================= -->
        <div class="content-section page-break">
            <h2 class="section-title"><i class="fas fa-search"></i> 5. Detailed Findings</h2>
            
            <?php if (!empty($criticalFindings)): ?>
                <h3 style="color: #ef4444; margin-bottom: 12px;">🔴 Critical Findings</h3>
                <?php foreach ($criticalFindings as $finding): ?>
                <div class="finding-card finding-critical">
                    <div class="finding-title"><?php echo htmlspecialchars($finding['category']); ?> - Score: <?php echo $finding['score']; ?>%</div>
                    <div class="finding-detail"><?php echo $finding['detail']; ?></div>
                    <div style="font-size: 10px; color: #ef4444; margin-top: 4px;">Impact: <?php echo $finding['impact']; ?></div>
                </div>
                <?php endforeach; ?>
            <?php endif; ?>
            
            <?php if (!empty($findings)): ?>
                <h3 style="color: #f59e0b; margin: 16px 0 12px;">🟡 Areas Requiring Attention</h3>
                <?php foreach ($findings as $finding): ?>
                <div class="finding-card finding-warning">
                    <div class="finding-title"><?php echo htmlspecialchars($finding['category']); ?> - Score: <?php echo $finding['score']; ?>%</div>
                    <div class="finding-detail"><?php echo $finding['detail']; ?></div>
                    <div style="font-size: 10px; color: #f59e0b; margin-top: 4px;">Impact: <?php echo $finding['impact']; ?></div>
                </div>
                <?php endforeach; ?>
            <?php endif; ?>
            
            <?php if (!empty($positiveFindings)): ?>
                <h3 style="color: #10b981; margin: 16px 0 12px;">🟢 Positive Findings</h3>
                <?php foreach ($positiveFindings as $finding): ?>
                <div class="finding-card finding-positive">
                    <div class="finding-title"><?php echo htmlspecialchars($finding['category']); ?> - Score: <?php echo $finding['score']; ?>%</div>
                    <div class="finding-detail"><?php echo $finding['detail']; ?></div>
                </div>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
        
        <!-- ============================================= -->
        <!-- 6. WEBSITE COMPLIANCE SCAN -->
        <!-- ============================================= -->
        <?php if ($websiteScan): ?>
        <div class="content-section page-break">
            <h2 class="section-title"><i class="fas fa-globe"></i> 6. Website Compliance Scan</h2>
            
            <p style="margin-bottom: 16px; font-size: 12px; color: var(--gray);">
                Automated scan performed on <strong><?php echo htmlspecialchars($websiteScan['domain']); ?></strong> 
                on <?php echo $websiteScan['scan_date'] ?? 'N/A'; ?>
            </p>
            
            <div class="score-banner" style="margin: 0 0 16px 0; padding: 20px;">
                <div style="font-size: 36px; font-weight: 800; color: <?php echo ($websiteScan['overall_website_score'] ?? 0) >= 80 ? '#10b981' : (($websiteScan['overall_website_score'] ?? 0) >= 50 ? '#f59e0b' : '#ef4444'); ?>;">
                    <?php echo $websiteScan['overall_website_score'] ?? 0; ?>%
                </div>
                <div style="font-size: 12px; color: var(--gray);">Website Compliance Score</div>
                <div style="font-size: 14px; font-weight: 600; margin-top: 4px;"><?php echo $websiteScan['overall_status'] ?? 'Unknown'; ?></div>
            </div>
            
            <?php 
            $scanChecks = $websiteScan['checks'] ?? [];
            foreach ($scanChecks as $key => $check): 
                $scanClass = 'scan-' . ($check['status'] ?? 'fail');
                $scanIcon = ($check['status'] === 'pass') ? 'check-circle' : (($check['status'] === 'warning') ? 'exclamation-triangle' : 'times-circle');
            ?>
            <div class="scan-check <?php echo $scanClass; ?>">
                <div class="scan-icon" style="color: <?php echo $check['status'] === 'pass' ? '#10b981' : ($check['status'] === 'warning' ? '#f59e0b' : '#ef4444'); ?>;">
                    <i class="fas fa-<?php echo $scanIcon; ?>"></i>
                </div>
                <div style="flex: 1;">
                    <strong><?php echo htmlspecialchars($check['label'] ?? ''); ?></strong>
                    <div style="font-size: 11px; color: var(--gray);"><?php echo htmlspecialchars($check['finding'] ?? ''); ?></div>
                    <?php if (!empty($check['recommendation'])): ?>
                        <div style="font-size: 10px; color: #ef4444; margin-top: 2px;">⚠️ <?php echo htmlspecialchars($check['recommendation']); ?></div>
                    <?php endif; ?>
                </div>
                <div style="font-weight: 700; font-size: 16px; color: <?php echo $check['status'] === 'pass' ? '#10b981' : ($check['status'] === 'warning' ? '#f59e0b' : '#ef4444'); ?>;">
                    <?php echo $check['score'] ?? 0; ?>%
                </div>
            </div>
            <?php endforeach; ?>
        </div>
        <?php endif; ?>
        
        <!-- ============================================= -->
        <!-- 7. RECOMMENDATIONS -->
        <!-- ============================================= -->
        <div class="content-section page-break">
            <h2 class="section-title"><i class="fas fa-lightbulb"></i> 7. Recommendations & Action Plan</h2>
            
            <p style="font-size: 12px; color: var(--gray); margin-bottom: 20px;">
                Based on the findings of this assessment, the following prioritized recommendations are provided 
                to improve your organization's compliance with the Kenya Data Protection Act, 2019.
            </p>
            
            <?php foreach ($recommendations as $rec): ?>
            <div class="recommendation-card">
                <div style="display: flex; justify-content: space-between; align-items: start; margin-bottom: 8px;">
                    <span class="rec-priority priority-<?php echo strtolower($rec['priority']); ?>">
                        <?php echo $rec['priority']; ?> Priority
                    </span>
                    <span style="font-size: 11px; color: var(--gray);">
                        Timeline: <?php echo $rec['timeline']; ?>
                    </span>
                </div>
                <div style="font-weight: 600; margin-bottom: 4px;"><?php echo htmlspecialchars($rec['category']); ?></div>
                <div style="font-size: 12px;"><?php echo $rec['action']; ?></div>
                <?php if (isset($rec['penalty_risk'])): ?>
                    <div style="font-size: 10px; color: #ef4444; margin-top: 6px;">
                        ⚠️ Penalty Risk: <?php echo $rec['penalty_risk']; ?>
                    </div>
                <?php endif; ?>
            </div>
            <?php endforeach; ?>
        </div>
        
        <!-- ============================================= -->
        <!-- 8. INDUSTRY-SPECIFIC GUIDANCE -->
        <!-- ============================================= -->
        <div class="content-section page-break">
            <h2 class="section-title"><i class="fas fa-industry"></i> 8. Industry-Specific Guidance</h2>
            
            <p style="font-size: 12px; color: var(--gray); margin-bottom: 16px;">
                As a <strong><?php echo htmlspecialchars($industry); ?></strong> organization, 
                the following sector-specific recommendations apply in addition to general DPA requirements:
            </p>
            
            <?php foreach ($industrySpecific as $guidance): ?>
            <div class="recommendation-card">
                <div style="font-size: 12px;">✅ <?php echo $guidance; ?></div>
            </div>
            <?php endforeach; ?>
        </div>
        
        <!-- ============================================= -->
        <!-- 9. NEXT STEPS -->
        <!-- ============================================= -->
        <div class="content-section">
            <h2 class="section-title"><i class="fas fa-forward"></i> 9. Next Steps & Timeline</h2>
            
            <table style="width: 100%; border-collapse: collapse;">
                <thead>
                    <tr style="background: var(--light);">
                        <th style="padding: 12px; text-align: left; border-bottom: 2px solid #e2e8f0;">Action</th>
                        <th style="padding: 12px; text-align: center; border-bottom: 2px solid #e2e8f0;">Priority</th>
                        <th style="padding: 12px; text-align: center; border-bottom: 2px solid #e2e8f0;">Deadline</th>
                        <th style="padding: 12px; text-align: center; border-bottom: 2px solid #e2e8f0;">Status</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td style="padding: 10px 12px; border-bottom: 1px solid #f1f5f9;">Address critical compliance gaps</td>
                        <td style="padding: 10px 12px; text-align: center;"><span class="rec-priority priority-critical">Critical</span></td>
                        <td style="padding: 10px 12px; text-align: center;">30 days</td>
                        <td style="padding: 10px 12px; text-align: center; color: #ef4444;">⚠️ Pending</td>
                    </tr>
                    <tr>
                        <td style="padding: 10px 12px; border-bottom: 1px solid #f1f5f9;">Register with ODPC (if not registered)</td>
                        <td style="padding: 10px 12px; text-align: center;"><span class="rec-priority priority-high">High</span></td>
                        <td style="padding: 10px 12px; text-align: center;">60 days</td>
                        <td style="padding: 10px 12px; text-align: center; color: #f59e0b;">📋 Required</td>
                    </tr>
                    <tr>
                        <td style="padding: 10px 12px; border-bottom: 1px solid #f1f5f9;">Appoint/confirm Data Protection Officer</td>
                        <td style="padding: 10px 12px; text-align: center;"><span class="rec-priority priority-high">High</span></td>
                        <td style="padding: 10px 12px; text-align: center;">60 days</td>
                        <td style="padding: 10px 12px; text-align: center; color: #f59e0b;">📋 Required</td>
                    </tr>
                    <tr>
                        <td style="padding: 10px 12px; border-bottom: 1px solid #f1f5f9;">Implement staff data protection training</td>
                        <td style="padding: 10px 12px; text-align: center;"><span class="rec-priority priority-medium">Medium</span></td>
                        <td style="padding: 10px 12px; text-align: center;">90 days</td>
                        <td style="padding: 10px 12px; text-align: center; color: #3b82f6;">📝 Planned</td>
                    </tr>
                    <tr>
                        <td style="padding: 10px 12px; border-bottom: 1px solid #f1f5f9;">Conduct next compliance assessment</td>
                        <td style="padding: 10px 12px; text-align: center;"><span class="rec-priority priority-medium">Medium</span></td>
                        <td style="padding: 10px 12px; text-align: center;"><?php echo date('F j, Y', strtotime('+3 months')); ?></td>
                        <td style="padding: 10px 12px; text-align: center; color: #3b82f6;">📅 Scheduled</td>
                    </tr>
                </tbody>
            </table>
        </div>
        
        <!-- ============================================= -->
        <!-- FOOTER -->
        <!-- ============================================= -->
        <div class="report-footer">
            <p><strong>Soul Guard - Data Protection Compliance System</strong></p>
            <p>This report was generated automatically based on the responses provided during the DPA compliance self-assessment.</p>
            <p style="margin-top: 8px;">The findings and recommendations are based on the Kenya Data Protection Act, 2019 and ODPC guidelines.</p>
            
            <div class="contact">
                <p><strong>Assessment Conducted by:</strong> Christopher Khayere</p>
                <p><strong>Contact:</strong> 0799874578</p>
                <p><strong>Report Reference:</strong> <?php echo $reportRef; ?></p>
                <p><strong>Date:</strong> <?php echo $reportDate; ?></p>
            </div>
            
            <p style="margin-top: 16px; font-size: 10px; opacity: 0.5;">
                Disclaimer: This report is generated based on self-reported information and automated assessments. 
                It does not constitute legal advice. Organizations should consult qualified legal professionals 
                for specific compliance guidance. Soul Guard is not liable for any decisions made based on this report.
            </p>
            
            <p style="margin-top: 20px; font-size: 18px; font-weight: 700; opacity: 0.8;">
                <i class="fas fa-shield-alt"></i> Soul Guard
            </p>
        </div>
        
    </div>
    
    <!-- Bottom action buttons -->
    <div class="btn-group no-print" style="margin: 20px 0 40px;">
        <button class="btn btn-primary" onclick="window.print()">
            <i class="fas fa-print"></i> Print / Save as PDF
        </button>
        <button class="btn btn-success" onclick="window.location.href='compliance-assessment.php'">
            <i class="fas fa-redo"></i> Re-assess
        </button>
        <a href="dashboard.php" class="btn" style="background: var(--secondary); color: white;">
            <i class="fas fa-tachometer-alt"></i> Dashboard
        </a>
    </div>
    
    <script>
        // Auto-print reminder
        console.log('📄 Compliance Report Ready');
        console.log('📊 Overall Score: <?php echo $overallScore; ?>%');
        console.log('🏷️ Risk Level: <?php echo $riskLevel; ?>');
        console.log('💡 Tip: Press Ctrl+P (or Cmd+P on Mac) to save as PDF');
    </script>
</body>
</html>