<?php
$pId = is_array($project) ? ($project['id'] ?? 0) : ($project->id ?? 0);
$pName = is_array($project) ? ($project['name'] ?? '') : ($project->name ?? '');
$pStatus = is_array($project) ? ($project['status'] ?? 'draft') : ($project->status ?? 'draft');
$pClient = is_array($project) ? ($project['client_name'] ?? 'Client') : ($project->client_name ?? 'Client');
$pValue = is_array($project) ? ($project['project_value'] ?? 0) : ($project->project_value ?? 0);
$pCurrency = is_array($project) ? ($project['currency'] ?? DEFAULT_CURRENCY) : ($project->currency ?? DEFAULT_CURRENCY);
$pOrgName = is_array($project) ? ($project['org_name'] ?? null) : ($project->org_name ?? null);
?>
<div class="card project-card">
    <div class="status-bar status-<?= htmlspecialchars($pStatus) ?>"></div>
    <div class="card-body">
        <div class="d-flex justify-between align-center mb-2">
            <h3 class="card-title text-truncate">
                <a href="<?= APP_URL ?>/projects/<?= $pId ?>" class="text-dark fw-600"><?= htmlspecialchars($pName) ?></a>
            </h3>
            <span class="badge badge-<?= htmlspecialchars($pStatus) ?>"><?= htmlspecialchars($pStatus) ?></span>
        </div>
        <p class="text-sm text-muted mb-3">
            <?= htmlspecialchars($pClient) ?>
            <?php if (!empty($isPlatformView) && $pOrgName): ?>
                &bull; <span class="text-xs">org: <?= htmlspecialchars($pOrgName) ?></span>
            <?php endif; ?>
        </p>

        <div class="mb-3">
            <div class="text-lg fw-700"><?= formatCurrency((float)$pValue, $pCurrency) ?></div>
            <div class="text-xs text-muted">Project Value</div>
        </div>

        <div class="d-flex align-center justify-between mt-3 pt-3 border-top">
            <a href="<?= APP_URL ?>/projects/<?= $pId ?>/edit" class="btn btn-sm btn-ghost"><i class="fas fa-edit"></i> Edit</a>
            <a href="<?= APP_URL ?>/projects/<?= $pId ?>" class="btn btn-sm btn-outline-primary">View Details <i class="fas fa-arrow-right"></i></a>
        </div>
    </div>
</div>
