<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>

<div class="d-flex justify-content-between align-items-start mb-3">
    <h1 class="h3 mb-0"><?= esc($account->company_name) ?></h1>
    <a href="<?= site_url('corporate-accounts/' . $account->id . '/edit') ?>" class="btn btn-outline-secondary">Edit</a>
</div>

<div class="row">
    <div class="col-md-5 mb-3">
        <div class="card shadow-sm">
            <div class="card-body">
                <h2 class="h6">Contact</h2>
                <dl class="row mb-0 small">
                    <dt class="col-5">Contact</dt><dd class="col-7"><?= esc($account->contact_name ?: '—') ?></dd>
                    <dt class="col-5">Phone</dt><dd class="col-7"><?= esc($account->phone ?: '—') ?></dd>
                    <dt class="col-5">Email</dt><dd class="col-7"><?= esc($account->email ?: '—') ?></dd>
                    <dt class="col-5">Billing Address</dt><dd class="col-7"><?= nl2br(esc($account->billing_address ?: '—')) ?></dd>
                    <dt class="col-5">Negotiated Rate</dt><dd class="col-7"><?= $ratePlan ? esc($ratePlan->name) . ' (' . ($ratePlan->adjustment_type === 'flat' ? format_money($ratePlan->adjustment_value) : $ratePlan->adjustment_value . '%') . ')' : '— standard pricing' ?></dd>
                </dl>
            </div>
        </div>
    </div>
    <div class="col-md-7 mb-3">
        <div class="card shadow-sm">
            <div class="card-body">
                <h2 class="h6">Monthly Statement</h2>
                <form action="<?= site_url('corporate-accounts/' . $account->id . '/statement') ?>" method="get" class="d-flex gap-2" target="_blank">
                    <input type="month" class="form-control" name="month" value="<?= esc($thisMonth) ?>" style="max-width: 200px;">
                    <button type="submit" class="btn btn-primary">Download PDF Statement</button>
                </form>
                <p class="text-muted small mt-2 mb-0">Aggregates every charge on a folio tagged to this account, dated within the selected month.</p>
            </div>
        </div>
    </div>
</div>

<?= $this->endSection() ?>
