
<?php $__env->startSection('title', 'Profile'); ?>
<?php $__env->startSection('sub_layout'); ?>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" />

    <style>
        :root {
            --primary: #e53935;
            --bg: #f5f5f5;
            --blue: #1976d2;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: var(--bg);
        }

        .topbar {
            background: var(--primary);
            color: #fff;
            padding: 12px 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }

        .topbar .back {
            position: absolute;
            left: 18px;
            cursor: pointer;
            font-size: 18px;
            display: flex;
            align-items: center;
        }

        .topbar-title {
            font-weight: 600;
        }

        .page {
            max-width: 900px;
            margin: 18px auto 30px;
            padding: 0 12px;
        }

        .card {
            background: #fff;
            border-radius: 16px;
            padding: 16px 18px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, .06);
            margin-bottom: 14px;
        }

        .header-card {
            background: var(--primary);
            color: #fff;
            border-radius: 16px;
            padding: 20px 18px;
            margin-bottom: 14px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .avatar {
            height: 48px;
            width: 48px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 22px;
            margin-bottom: 8px;
        }

        .user-name {
            font-weight: 600;
            font-size: 17px;
        }

        .user-phone {
            font-size: 13px;
            opacity: .9;
        }

        .balance-label {
            font-size: 13px;
            margin-bottom: 4px;
            text-align: right;
            opacity: .9;
        }

        .balance-val {
            font-size: 18px;
            font-weight: 700;
            text-align: right;
        }

        .row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0;
            border-bottom: 1px solid #f1f1f1;
            font-size: 14px;
        }

        .row:last-child {
            border-bottom: none;
        }

        .row-label {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .row-label i {
            font-size: 15px;
            color: var(--primary);
        }

        .row-value {
            font-weight: 500;
        }

        /* নিচের ৩টা বাটন */
        .actions {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 10px;
            margin-top: 16px;
            margin-bottom: 16px;
        }

        .action-btn {
            flex: 1;
            min-width: 90px;
            max-width: 160px;
            border-radius: 999px;
            padding: 9px 14px;
            font-size: 14px;
            font-weight: 600;
            border: 1px solid var(--primary);
            background: #fff;
            color: var(--primary);
            cursor: pointer;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            white-space: nowrap;
        }

        .action-btn i {
            font-size: 14px;
        }

        .action-btn:hover {
            background: var(--primary);
            color: #fff;
        }

        .logout-btn {
            width: 100%;
            border: none;
            border-radius: 999px;
            padding: 14px;
            font-size: 16px;
            font-weight: 600;
            background: var(--primary);
            color: #fff;
            cursor: pointer;
            margin-top: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .avatar {
            height: 48px;
            width: 48px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 22px;
            margin-bottom: 8px;
            overflow: hidden;
            /* নতুন */
        }

        .avatar img {
            width: 100%;
            /* নতুন */
            height: 100%;
            /* নতুন */
            object-fit: cover;
            /* নতুন */
            display: block;
            /* নতুন */
        }

        /* ছোট স্ক্রিনে রেসপনসিভ */
        @media (max-width:480px) {
            .actions {
                flex-direction: column;
                align-items: stretch;
            }

            .action-btn {
                max-width: 100%;
                width: 100%;
            }
        }
    </style>

    <?php
        $user = auth()->user();
        $loanLimit = auth()->user()->loan_limit;
        $activeLoansCount = \App\Models\Loan::where('user_id', $user->id)->where('status', 'running')->count();
        $totalWithdrawn = \App\Models\WithdrawRequest::where('user_id', $user->id)->where('status', 'approved')->sum('amount');
    ?>

    <div class="page">
        <div class="header-card">
            <div>
                <div class="avatar">
                    <?php if($user->avatar): ?>
                        <img src="<?php echo e(asset('storage/' . $user->avatar)); ?>" alt="<?php echo e($user->name); ?>">
                    <?php else: ?>
                        <?php echo e(strtoupper(substr($user->name, 0, 1))); ?>

                    <?php endif; ?>
                </div>
                <div class="user-name"><?php echo e($user->name); ?></div>
                <div class="user-phone"><?php echo e($user->phone); ?></div>
            </div>
            <div>
                <div class="balance-label">ব্যালেন্স</div>
                <div class="balance-val">
                    ৳ <?php echo e(number_format($user->balance ?? 0, 2)); ?> BDT
                </div>
            </div>
        </div>


        <div class="card">
            <div class="row">
                <div class="row-label">
                    <i class="fa-solid fa-coins"></i>
                    <span>লোন লিমিট</span>
                </div>
                <div class="row-value"><?php echo e(number_format($loanLimit)); ?> BDT</div>
            </div>
            <div class="row">
                <div class="row-label">
                    <i class="fa-solid fa-money-bill-transfer"></i>
                    <span>ক্যাশ আউট</span>
                </div>
                <div class="row-value"><?php echo e(number_format($user->balance ?? 0, 2)); ?> BDT</div>
            </div>
            <div class="row">
                <div class="row-label">
                    <i class="fa-solid fa-arrow-down-long"></i>
                    <span>উত্তোলন ব্যালেন্স</span>
                </div>
                <div class="row-value"><?php echo e(number_format($totalWithdrawn, 2)); ?> BDT</div>
            </div>
            <div class="row">
                <div class="row-label">
                    <i class="fa-solid fa-list-check"></i>
                    <span>অ্যাক্টিভ লোন</span>
                </div>
                <div class="row-value"><?php echo e($activeLoansCount); ?> টি লোন</div>
            </div>
        </div>

        
        <div class="actions">
            <a href="<?php echo e(route('profile.photo.edit')); ?>" class="action-btn">
                <i class="fa-regular fa-image"></i>
                <span>Photo</span>
            </a>
            <a href="<?php echo e(route('profile.password.edit')); ?>" class="action-btn">
                <i class="fa-solid fa-lock"></i>
                <span>Password</span>
            </a>
            <a href="<?php echo e(route('profile.info.edit')); ?>" class="action-btn">
                <i class="fa-regular fa-user"></i>
                <span>Info</span>
            </a>
        </div>

        <form action="<?php echo e(route('logout')); ?>" method="POST">
            <?php echo csrf_field(); ?>
            <button type="submit" class="logout-btn">
                <i class="fa-solid fa-arrow-right-from-bracket"></i>
                <span>লগ আউট</span>
            </button>
        </form>
    </div>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('frontend.layout_2', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/ecareba2/loan.rkmotorsbike.top/resources/views/frontend/profile/index.blade.php ENDPATH**/ ?>