<style>
    @media  print {
        body { -webkit-print-color-adjust: exact; }
        .print-btn { display: none !important; }

        thead { display: table-header-group; } 
        thead { display: table-header-group; }   /* repeat header */
        tfoot { display: table-footer-group; }   /* repeat footer */ 
        tr { page-break-inside: avoid; }         /* prevent row split */
    }

    body {
        margin: 0 auto;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        background: black;
        line-height: 1.2;
        font-size: 15px;
    }

    .print-container {
        position: relative;
        margin: 0 auto;
        width: 210mm;
        min-height: 297mm;
        padding: 10mm 15mm;
        background: white;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }

    .header-section {
        width: calc(100% + 30mm);
        height: 138px;
        margin: -10mm -15mm 20px -15mm;
        background-image: url('<?php echo e(url('Invoiceheader2.png')); ?>');
        background-size: 100% 100%;
        background-repeat: no-repeat;
        background-position: top center;
        filter: contrast(130%);
    }

    .watermark {
        position: fixed;
        top: 50%; left: 50%;
        width: 600px; height: 600px;
        opacity: 0.05;
        transform: translate(-50%, -50%);
        background-image: url('<?php echo e(url('header1.png')); ?>');
        background-size: contain;
        background-repeat: no-repeat;
        z-index: 0;
    }

    h2 {
        text-align: center;
        margin-bottom: 10px;
        text-transform: uppercase;
        font-size: 20px;
        position: relative;
        z-index: 2;
    }

    .detail-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
        margin: 5px 0 15px;
        position: relative;
        z-index: 2;
    }

    .detail-item {
        display: flex;
        justify-content: space-between;
        padding: 3px 0;
        border-bottom: 1px solid #ddd;
        font-size: 14px;
    }

    .payments-wrapper { flex: 1; z-index: 2; }
    table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 15px; }
    table th, table td { border: 1px solid #000; padding: 5px; }
    table th { background: #f1f1f1; }

    .signature-container {
        display: flex;
        justify-content: space-between;
        margin-top: 2rem;
        width: 100%;
        page-break-inside: avoid;
    }

    .footer-print {
        text-align: right;
        color: green;
        font-size: 11px;
        margin-top: 50px;
    }
</style>

<div class="container text-center mt-3 mb-4 print-btn">
    <form action="<?php echo e(route('investors.statement', $investor->id)); ?>" method="GET" class="row justify-content-center g-3">
        <div class="col-auto">
            <label for="from" class="col-form-label fw-bold">From:</label>
        </div>
        <div class="col-auto">
            <input type="month" id="from" name="from" class="form-control"
                value="<?php echo e($from ?? ''); ?>" required>
        </div>
        <div class="col-auto">
            <label for="to" class="col-form-label fw-bold">To:</label>
        </div>
        <div class="col-auto">
            <input type="month" id="to" name="to" class="form-control"
                value="<?php echo e($to ?? ''); ?>" required>
        </div>
        <div class="col-auto">
            <button type="submit" class="btn btn-primary">Filter</button>
            <a href="<?php echo e(route('investors.statement', $investor->id)); ?>"  type="submit" class="btn btn-secondary">Reset</a>
        </div>
    </form>

    <?php if($from && $to): ?>
        <div class="mt-2">
            <span class="badge bg-success">
                Showing results from <strong><?php echo e(\Carbon\Carbon::parse($from)->format('F Y')); ?></strong> 
                to <strong><?php echo e(\Carbon\Carbon::parse($to)->format('F Y')); ?></strong>
            </span>
        </div>
    <?php endif; ?>
</div>


<div class="print-container">
    <div class="header-section"></div>
    <div class="watermark"></div>

    <h2>Investor Statement</h2>

    <div class="detail-grid">
        <div>
            <h3>Investor Info</h3>
            <div class="detail-item"><span>Name:</span><strong><?php echo e($investor->name); ?></strong></div>
            <div class="detail-item"><span>Father Name:</span><strong><?php echo e($investor->father_name); ?></strong></div>
            <div class="detail-item"><span>CNIC:</span><strong><?php echo e($investor->cnic); ?></strong></div>
            <div class="detail-item"><span>Address:</span><strong><?php echo e($investor->address); ?></strong></div>
        </div>

        <div>
            <h3>Summary</h3>
            <div class="detail-item"><span>Total INVEST:</span><strong><?php echo e(number_format($totalIn)); ?></strong></div>
            <div class="detail-item"><span>Total RETURN:</span><strong><?php echo e(number_format($totalOut)); ?></strong></div>
            <div class="detail-item"><span>Total Purchase:</span><strong><?php echo e(number_format($totalpurchase)); ?></strong></div>
            <div class="detail-item"><span>Balance:</span><strong><?php echo e(number_format($balance)); ?></strong></div>
        </div>
    </div>
    
    <!-- <?php if($from && $to): ?>
    <center>
        <div class="mt-2" style=" font-size: 12px; margin-bottom: 0px;">
            <span class="badge bg-success">
                Showing results from <strong><?php echo e(\Carbon\Carbon::parse($from.'-01')->format('F Y')); ?></strong> 
                to <strong><?php echo e(\Carbon\Carbon::parse($to.'-01')->format('F Y')); ?></strong>
            </span>
        </div>
    </center>
    <?php endif; ?> -->

    <!-- Transactions Table -->
    <div class="payments-wrapper" style="margin-top: -10px;">
        <table>
            <thead>
                <tr>
                    <td colspan="4" style="text-align:center; font-weight:bold; background:#235849; color: white; height: 25px;">
                        Transactions <?php if($from && $to): ?> from <strong><?php echo e(\Carbon\Carbon::parse($from.'-01')->format('F Y')); ?></strong> 
                        to <strong><?php echo e(\Carbon\Carbon::parse($to.'-01')->format('F Y')); ?></strong><?php endif; ?>
                    </td>
                </tr>
                <tr>
                    <th>Date</th>
                    <th>Type</th>
                    <th>Amount</th>
                    <th>Remarks</th>
                </tr>
            </thead>
            <tbody>
            <?php $__currentLoopData = $investments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr>
                <td><?php echo e($t->date); ?></td>
                <td>
                    <?php if($t->type == 'in'): ?>
                        <i class="fa fa-money" style="color:green;"></i>
                    <?php elseif($t->type == 'out'): ?>
                        <i class="fa fa-money" style="color:red;"></i>
                    <?php elseif($t->type == 'car'): ?>
                        <i class="fa fa-car" style="color:blue;"></i>
                    <?php endif; ?>
                </td>
                <td><?php echo e(number_format($t->amount)); ?></td>
                <td>
                    <?php if($t->type == 'car'): ?>
                        <?php echo e($t->make_remarks); ?> / <?php echo e($t->model_remarks); ?> / <?php echo e($t->varient_remarks); ?> / <?php echo e($t->color_remarks); ?> / <?php echo e($t->reg_remarks); ?>

                    <?php else: ?>
                        <?php echo e($t->remarks); ?>

                    <?php endif; ?>
                </td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

            </tbody>
            <tfoot>
                <tr>
                    <td colspan="4" class="footer-print">
                        Printed By: <?php echo e(Auth::user()->name); ?>

                        Printed on: <?php echo e(\Carbon\Carbon::now()->format('d-m-Y H:i')); ?>

                    </td>
                </tr>
            </tfoot>
        </table>
    </div>

    <!-- Signatures -->
    <div class="signature-container">
        <p class="signature">Investor Signature _________________ <br> Name : <?php echo e($investor->name); ?></p>
        <p class="signature">Authorized Signature _________________</p>
    </div>
</div>

<button onclick="window.print()" class="print-btn">Print</button>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/laravel-app12/resources/views/investors/statement.blade.php ENDPATH**/ ?>