<?php
/**
 * Template 1: Standard Minimal (Classic Wine Header & White Canvas)
 */
$safe_emp_no      = (string)($card['employee_no'] ?? 'N/A');
$safe_name        = (string)($card['name'] ?? '');
$safe_designation = (string)($card['designation'] ?? 'STAFF MEMBER');
$safe_expiry      = (string)($card['expiry_date'] ?? '');
?>
<div class="cr80-card bg-white rounded-xl shadow-lg border border-slate-300 flex flex-col justify-between overflow-hidden text-center relative">
    
    <!-- Logo Header -->
    <div class="bg-white pt-4 pb-1 px-3 flex items-center justify-center min-h-[0.7in]">
        <?php if (file_exists($company_logo) || filter_var($company_logo, FILTER_VALIDATE_URL)): ?>
            <img src="<?= htmlspecialchars((string)$company_logo); ?>" alt="Company Logo" class="h-10 max-w-[1.8in] object-contain">
        <?php else: ?>
            <h2 class="text-xs font-black tracking-tight text-[#8B1936]">
                <?= htmlspecialchars(ucwords(strtolower((string)$company_name))); ?>
            </h2>
        <?php endif; ?>
    </div>

    <!-- Main Details -->
    <div class="flex-1 flex flex-col items-center justify-center px-2 py-1 space-y-2">
        
        <!-- Circular Photo -->
        <div class="w-28 h-28 rounded-full bg-stone-50 border-[2px] border-[#8B1936] flex items-center justify-center text-xl font-black text-[#8B1936] shadow-sm overflow-hidden shrink-0">
            <?php if ($avatarPhoto): ?>
                <img src="<?= $avatarPhoto; ?>" alt="<?= htmlspecialchars($safe_name); ?>" class="w-full h-full object-cover">
            <?php else: ?>
                <?= htmlspecialchars((string)($initials ?? 'EE')); ?>
            <?php endif; ?>
        </div>

        <!-- Name & Title -->
        <div class="px-1">
            <h3 class="text-[13px] font-black text-[#8B1936] leading-tight tracking-tight">
                <?= htmlspecialchars(ucwords(strtolower($safe_name))); ?>
            </h3>
            <p class="text-[8.5px] font-bold text-[#595660] uppercase tracking-wider mt-0.5">
                <?= htmlspecialchars($safe_designation); ?>
            </p>
        </div>

        <!-- Employee Pill -->
        <div class="bg-stone-100 px-3 py-1 rounded-lg border border-slate-200/60 shadow-2xs">
            <p class="text-[8.5px] font-mono font-bold text-slate-700 tracking-wider">
                EMP: <?= htmlspecialchars($safe_emp_no); ?>
            </p>
        </div>

    </div>

    <!-- Expiry Footer -->
    <div class="bg-[#54525a] text-white py-1.5 px-3 flex justify-between items-center text-[8px] font-sans font-semibold">
        <span class="text-slate-200">Valid Until:</span>
        <span class="text-white font-bold">
            <?= !empty($safe_expiry) ? date('M Y', strtotime($safe_expiry)) : 'N/A'; ?>
        </span>
    </div>
</div>