{{--
# ────────────── lee_gwena ──────────────
# Code by: ashley_gwena
# Created: 2026-03-12
# Notes: GL account detail with balance preview
# ───────────────────────────────────────
--}}
@extends('layouts.master')

@section('title', 'GL Account Details')

@section('content')
<div class="container py-4">
    <div class="d-flex justify-content-between align-items-center mb-3">
        <div>
            <h1 class="h3 mb-1">{{ $account->account_code }} - {{ $account->account_name }}</h1>
            <p class="text-muted mb-0">Account detail and balance preview.</p>
        </div>
        <div class="d-flex gap-2">
            <a href="{{ route('gl-accounts.edit', $account) }}" class="btn btn-outline-primary">Edit</a>
            <a href="{{ route('gl-accounts.index') }}" class="btn btn-outline-secondary">Back</a>
        </div>
    </div>

    <div class="row g-3">
        <div class="col-md-4">
            <div class="card p-3">
                <div class="text-muted">Current Balance</div>
                <div class="h4">{{ number_format($metrics['current_balance'] ?? 0, 2) }}</div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card p-3">
                <div class="text-muted">Transaction Count</div>
                <div class="h4">{{ $metrics['transaction_count'] ?? 0 }}</div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card p-3">
                <div class="text-muted">Last Transaction Date</div>
                <div class="h4">{{ $metrics['last_transaction_date'] ?? 'N/A' }}</div>
            </div>
        </div>
    </div>

    <div class="card p-4 mt-4">
        <h2 class="h5">Account Details</h2>
        <div class="row g-3">
            <div class="col-md-6"><strong>Type:</strong> {{ $account->accountType?->name ?? 'N/A' }}</div>
            <div class="col-md-6"><strong>Financial Category:</strong> {{ $account->financial_category ?? 'N/A' }}</div>
            <div class="col-md-6"><strong>Status:</strong> {{ $account->is_active ? 'Active' : 'Inactive' }}</div>
            <div class="col-md-6"><strong>Trust Account:</strong> {{ $account->is_trust_account ? 'Yes' : 'No' }}</div>
            <div class="col-md-6"><strong>Business Account:</strong> {{ $account->is_business ? 'Yes' : 'No' }}</div>
        </div>
    </div>

    <div class="card p-4 mt-4">
        <h2 class="h5">Audit Trail</h2>
        <div class="row g-3">
            <div class="col-md-6"><strong>Created At:</strong> {{ $account->created_at }}</div>
            <div class="col-md-6"><strong>Updated At:</strong> {{ $account->updated_at }}</div>
            <div class="col-md-6"><strong>Created By:</strong> {{ $createdByName ?? 'N/A' }}</div>
            <div class="col-md-6"><strong>Updated By:</strong> {{ $updatedByName ?? 'N/A' }}</div>
        </div>
    </div>
</div>
@endsection


