<?php
$company = $company ?? [];
$companyName = trim((string)($company['name'] ?? 'StoreApp'));
$companySubtitle = trim((string)($company['subtitle'] ?? ''));
$companyPhone = trim((string)($company['phone'] ?? ''));
$companyAddress = trim((string)($company['address'] ?? ''));
$logoPath = trim((string)($company['logo_path'] ?? ''));
$logoUrl = $logoPath !== '' ? asset(ltrim($logoPath, '/')) : asset('assets/img/techwaves-footer.png');
?>
<div class="login-split-page">
  <div class="login-split-card login-split-card--brand">
    <div class="login-brand-mark">
      <img src="<?= e($logoUrl) ?>" alt="<?= e($companyName) ?>">
    </div>
    <h1 class="login-brand-title"><?= e($companyName) ?></h1>
    <?php if ($companyPhone || $companyAddress || $companySubtitle): ?>
      <div class="login-brand-meta">
        <?php if ($companySubtitle): ?><div><?= e($companySubtitle) ?></div><?php endif; ?>
        <?php if ($companyPhone || $companyAddress): ?><div><?= e(trim($companyPhone . ($companyPhone && $companyAddress ? ' - ' : '') . $companyAddress)) ?></div><?php endif; ?>
      </div>
    <?php endif; ?>
    <div class="login-brand-copy">نظام مبيعات ومخزون جاهز لإدارة العملاء والموردين والمبيعات والمخزون من مكان واحد.</div>
  </div>

  <div class="login-split-card login-split-card--form">
    <h2 class="login-form-title">تسجيل الدخول</h2>
    <?php if (!empty($error)): ?>
      <div class="alert alert-danger"><?= e($error) ?></div>
    <?php endif; ?>
    <form method="post" class="login-form-shell">
      <?= csrf_field() ?>
      <div class="login-field">
        <span class="login-field__icon"><i class="fa-solid fa-user"></i></span>
        <input class="form-control" name="username" placeholder="اسم المستخدم" required>
      </div>
      <div class="login-field">
        <span class="login-field__icon"><i class="fa-solid fa-lock"></i></span>
        <input type="password" class="form-control" name="password" placeholder="كلمة المرور" required>
      </div>
      <button class="btn btn-primary login-submit">دخول</button>
    </form>
  </div>
</div>
