<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Invoice - <?php echo e($invoice->invoice_no); ?></title>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Montserrat:wght@700;800&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary: #6A1B9A;
            --secondary: #8E24AA;
            --accent: #FFD54F;
            --text-dark: #1A1A1A;
            --text-gray: #64748B;
        }
        @page { size: A4 portrait; margin: 10mm; }
        body {
            font-family: 'Poppins', sans-serif;
            margin: 0; padding: 0;
            font-size: 13px;
            color: var(--text-dark);
            background: #fff;
        }
        .invoice-box {
            max-width: 800px;
            margin: auto;
            padding: 40px;
            border: 1px solid #E2E8F0;
            background: #fff;
            box-shadow: 0 10px 30px rgba(0,0,0,0.05);
        }
        
        /* Header table styling */
        .header-table { width: 100%; border-bottom: 3px solid var(--primary); padding-bottom: 20px; margin-bottom: 30px; }
        
        .company-name {
            font-family: 'Montserrat', sans-serif;
            font-size: 36px;
            color: var(--primary);
            margin: 0 0 5px 0;
            letter-spacing: 1px;
            text-transform: uppercase;
        }
        .tagline {
            font-size: 14px;
            font-weight: 600;
            color: var(--accent);
            background: var(--primary);
            display: inline-block;
            padding: 4px 12px;
            border-radius: 20px;
            margin-bottom: 10px;
            letter-spacing: 0.5px;
        }
        .company-address { font-size: 12px; color: var(--text-gray); line-height: 1.6; }
        
        .invoice-title {
            font-family: 'Montserrat', sans-serif;
            font-size: 42px;
            color: #F1F5F9;
            margin: 0;
            text-align: right;
            text-transform: uppercase;
            letter-spacing: 2px;
            -webkit-text-stroke: 1px #CBD5E1;
        }
        .invoice-meta { margin-top: 15px; text-align: right; }
        .invoice-meta p { margin: 4px 0; font-size: 14px; }
        .invoice-meta strong { color: var(--primary); }

        /* Customer Box */
        .customer-box {
            background: #F8FAFC;
            border-left: 4px solid var(--primary);
            padding: 20px;
            border-radius: 0 8px 8px 0;
            margin-bottom: 30px;
        }
        .customer-box h3 { margin: 0 0 10px 0; color: var(--primary); font-size: 15px; text-transform: uppercase; }
        .customer-box p { margin: 4px 0; line-height: 1.5; color: #334155; font-size: 14px; }

        /* Items Table */
        .items-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 30px;
        }
        .items-table th {
            background: var(--primary);
            color: white;
            padding: 12px;
            text-align: left;
            font-weight: 600;
            font-size: 13px;
            text-transform: uppercase;
            -webkit-print-color-adjust: exact;
        }
        .items-table td {
            padding: 12px;
            border-bottom: 1px solid #E2E8F0;
            color: #334155;
        }
        .items-table tr:nth-child(even) td { background-color: #F8FAFC; -webkit-print-color-adjust: exact; }
        .text-right { text-align: right; }
        .text-center { text-align: center; }

        /* Totals */
        .totals-table { width: 300px; float: right; border-collapse: collapse; margin-bottom: 40px; }
        .totals-table td { padding: 10px; border-bottom: 1px solid #F1F5F9; color: #334155; text-align: right;}
        .totals-table .grand-total td {
            background: var(--primary);
            color: white !important;
            font-size: 18px;
            font-weight: 700;
            border: none;
            -webkit-print-color-adjust: exact;
        }

        /* Footer */
        .footer {
            clear: both;
            margin-top: 50px;
            padding-top: 20px;
            border-top: 2px solid #E2E8F0;
            width: 100%;
        }
        .footer-note { float: left; font-weight: 600; color: var(--primary); font-size: 15px; font-style: italic; }
        .signature-box { float: right; text-align: center; width: 200px; }
        .signature-line { border-top: 1px solid #1A1A1A; margin-bottom: 8px; padding-top: 5px; font-weight: 600; color: var(--text-dark); }

        @media print {
            .no-print { display: none; }
            .invoice-box { border: none; padding: 0; box-shadow: none; max-width: 100%; }
            body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
        }
        
        /* Floating Print Buttons */
        .print-actions { text-align: center; margin-bottom: 20px; }
        .btn-print { background: var(--primary); color: white; border: none; padding: 10px 25px; border-radius: 20px; font-weight: 600; cursor: pointer; margin: 0 10px; font-family: 'Poppins'; }
        .btn-close { background: #E2E8F0; color: #334155; border: none; padding: 10px 25px; border-radius: 20px; font-weight: 600; cursor: pointer; margin: 0 10px; font-family: 'Poppins'; }
    </style>
</head>
<body onload="window.print()">
    <div class="no-print print-actions">
        <button onclick="window.print()" class="btn-print">Print Invoice</button>
        <button onclick="window.close()" class="btn-close">Close Window</button>
    </div>

    <div class="invoice-box">
        <!-- Header Section -->
        <table class="header-table" cellpadding="0" cellspacing="0">
            <tr>
                <td width="60%" valign="top">
                    <h1 class="company-name">RIYASRI SILKS</h1>
                    <div class="tagline">Mrs. of High Class Fancy Sarees</div>
                    <div class="company-address">
                        107/B, Gandhi Nagar, Salem Main Road,<br>
                        Elampillai – 637502, Salem, Tamil Nadu.<br>
                        <strong>Phone:</strong> 9244443777, 9244441999
                    </div>
                </td>
                <td width="40%" valign="top">
                    <h2 class="invoice-title">INVOICE</h2>
                    <div class="invoice-meta">
                        <p><strong>Invoice No:</strong> #<?php echo e($invoice->invoice_no); ?></p>
                        <p><strong>Date:</strong> <?php echo e($invoice->invoice_date->format('d M, Y')); ?></p>
                    </div>
                </td>
            </tr>
        </table>

        <!-- Customer Section -->
        <div class="customer-box">
            <h3>Billed To:</h3>
            <p><strong><?php echo e($invoice->customer->customer_name); ?></strong></p>
            <p><?php echo e($invoice->customer->address1); ?>

               <?php if($invoice->customer->address2): ?>, <?php echo e($invoice->customer->address2); ?> <?php endif; ?>
            </p>
            <p><?php echo e($invoice->customer->city); ?>, <?php echo e($invoice->customer->state); ?> - <?php echo e($invoice->customer->pincode); ?></p>
            <p><strong>Mobile:</strong> <?php echo e($invoice->customer->mobile); ?></p>
            <?php if($invoice->customer->gst_number): ?><p><strong>GSTIN:</strong> <?php echo e($invoice->customer->gst_number); ?></p><?php endif; ?>
        </div>

        <!-- Items -->
        <table class="items-table" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th width="5%" class="text-center">#</th>
                    <th width="45%">Item Description</th>
                    <th width="15%" class="text-center">Qty</th>
                    <th width="15%" class="text-right">Rate</th>
                    <th width="20%" class="text-right">Amount</th>
                </tr>
            </thead>
            <tbody>
                <?php $__currentLoopData = $invoice->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td class="text-center"><?php echo e($index + 1); ?></td>
                    <td><strong><?php echo e($item->product_name); ?></strong></td>
                    <td class="text-center"><?php echo e(number_format($item->qty, 2)); ?></td>
                    <td class="text-right">₹<?php echo e(number_format($item->rate, 2)); ?></td>
                    <td class="text-right font-weight-bold">₹<?php echo e(number_format($item->amount, 2)); ?></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
        </table>

        <!-- Totals Section -->
        <table class="totals-table" cellpadding="0" cellspacing="0">
            <tr>
                <td>Sub Total:</td>
                <td>₹<?php echo e(number_format($invoice->subtotal, 2)); ?></td>
            </tr>
            <?php if($invoice->discount > 0): ?>
            <tr>
                <td>Discount:</td>
                <td style="color: #E53935;">- ₹<?php echo e(number_format($invoice->discount, 2)); ?></td>
            </tr>
            <?php endif; ?>
            <tr class="grand-total">
                <td>Grand Total:</td>
                <td>₹<?php echo e(number_format($invoice->grand_total, 2)); ?></td>
            </tr>
        </table>

        <!-- Footer -->
        <div class="footer">
            <div class="footer-note">Thank You, Visit Again!</div>
            <div class="signature-box">
                <div class="signature-line">Authorized Signature</div>
                <div style="font-size: 11px; color: var(--text-gray);">For Riyasri Silks</div>
            </div>
        </div>
    </div>
</body>
</html>
<?php /**PATH E:\xampp\htdocs\riya\resources\views/invoices/print.blade.php ENDPATH**/ ?>