<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>QualityFlow - Endline</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap" rel="stylesheet">
    
    <style>
        body {
            font-family: 'Roboto', sans-serif;
            background-color: #f5f6f8; /* Light gray background */
        }
        
        /* Main card styling */
        .main-card {
            max-width: 750px;
            margin: 4rem auto;
            border: none;
            box-shadow: 0 10px 40px rgba(0,0,0,0.06); /* Soft shadow like the design */
            border-radius: 12px;
        }
        
        /* Select dropdown styling */
        .select-production {
            background-color: #fafbfc;
            border: 1px solid #e1e4e8;
            color: #6a737d;
            border-radius: 6px;
        }
        .select-production:focus {
            border-color: #2b4cc4;
            box-shadow: 0 0 0 0.25rem rgba(43, 76, 196, 0.1);
        }
        
        /* Inner profile container styling */
        .profile-container {
            background-color: #f4f6fb;
            border: 1px solid #e2e6f0;
            border-radius: 12px;
            padding: 2.5rem 2rem;
            margin-top: 1.5rem;
        }
        
        /* Circular profile image with blue ring */
        .profile-image-wrapper {
            width: 140px;
            height: 140px;
            border-radius: 50%;
            border: 4px solid #2b4cc4;
            padding: 4px; /* Space between border and image (creates the white gap) */
            background-color: white;
            box-shadow: 0 4px 12px rgba(0,0,0,0.08); /* slight shadow under avatar */
        }
        
        .profile-image {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            object-fit: cover;
        }
        
        /* Badges styling */
        .badge-verified {
            background-color: #ecfdf3;
            color: #12b76a;
            border: 1px solid #d1fadf;
            font-weight: 700;
            font-size: 0.65rem;
            letter-spacing: 0.5px;
            text-transform: uppercase;
        }
        
        .badge-grade {
            background-color: #eff4ff;
            color: #2b4cc4;
            border: 1px solid #d1e0ff;
            font-weight: 700;
            font-size: 0.65rem;
            letter-spacing: 0.5px;
            text-transform: uppercase;
        }
        
        .badge-dept {
            background-color: #f8f9fa;
            color: #6c757d;
            border: 1px solid #e9ecef;
            font-weight: 700;
            font-size: 0.65rem;
            letter-spacing: 0.5px;
            text-transform: uppercase;
        }
        
        /* Start Inspection Button */
        .btn-start-inspection {
            background-color: #2b4cc4;
            color: white;
            font-weight: 600;
            padding: 0.8rem 2rem;
            border-radius: 8px;
            border: none;
            box-shadow: 0 4px 10px rgba(43, 76, 196, 0.2);
            transition: all 0.2s;
            font-size: 1rem;
        }
        
        .btn-start-inspection:hover {
            background-color: #223c9e;
            color: white;
            transform: translateY(-1px);
            box-shadow: 0 6px 15px rgba(43, 76, 196, 0.3);
        }
        
        /* Rescan ID text */
        .wrong-profile-text {
            font-size: 0.65rem;
            color: #8c98a4;
            font-weight: 700;
            letter-spacing: 0.5px;
        }

        /* Custom Dropdown Styling */
        .custom-select-btn {
            background-color: #fafbfc !important;
            border: 1px solid #e1e4e8;
            color: #495057;
            border-radius: 6px;
            width: 100%;
            height: 3.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .custom-dropdown-menu {
            position: absolute;
            top: 100%;
            left: 0;
            width: 100%;
            margin-top: 5px;
            background-color: white;
            border: 1px solid #e2e6f0;
            border-radius: 8px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.08);
            z-index: 1000;
            display: none;
        }
        
        .custom-dropdown-menu.show {
            display: block;
        }

        .grid-container {
            display: grid;
            grid-template-columns: repeat(6, 1fr); /* Default for mobile/smaller screens */
            gap: 8px;
            max-height: 250px;
            overflow-y: auto;
        }
        
        @media (min-width: 768px) {
            .grid-container {
                grid-template-columns: repeat(10, 1fr); /* 10 columns for desktop */
            }
        }

        .line-item {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: #f5f6f8;
            border-radius: 4px;
            font-size: 0.85rem;
            font-weight: 600;
            color: #6a737d;
            cursor: pointer;
            user-select: none;
            transition: all 0.2s;
        }

        .line-item:hover {
            background-color: #e2e6f0;
        }

        .line-item.selected {
            background-color: #2b4cc4;
            color: white;
        }

        .dropdown-footer {
            border-top: 1px solid #e2e6f0;
            padding: 1rem;
            background-color: #fcfcfd;
            border-bottom-left-radius: 8px;
            border-bottom-right-radius: 8px;
        }

        .selected-count {
            font-size: 0.70rem;
            font-weight: 700;
            color: #6c757d;
            letter-spacing: 0.8px;
            text-transform: uppercase;
        }

        .clear-all-btn {
            font-size: 0.70rem;
            font-weight: 800;
            color: #24292e;
            padding: 0;
            letter-spacing: 0.8px;
            text-transform: uppercase;
        }
        
        .clear-all-btn:hover {
            color: #2b4cc4;
        }

        .top-badge {
            background-color: #2b4cc4;
            color: white;
            border-radius: 20px;
            padding: 0.4rem 1rem;
            font-size: 0.75rem;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            text-transform: uppercase;
            box-shadow: 0 4px 6px rgba(43, 76, 196, 0.2);
        }

        /* Hide specific navbar elements for this view */
        #navScanNext, 
        #linedisplaydiv {
            display: none !important;
        }

        .line-card{
cursor:pointer;
transition:0.3s;
border-radius:10px;
}

.line-card:hover{
transform:scale(1.05);
background:#f5f5f5;
}

.line-selected{
border:3px solid #28a745;
background:#e8f8ec;
}
    </style>
</head>
<body>

    <!-- Injecting the navigation bar blade components -->
    <?php echo $__env->make('Quality.Endline_nav', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <!-- Main Content Application Region -->
    <div class="container px-3">
        <div class="card main-card">
            <div class="card-body p-4 p-md-5">

                <div class="container-fluid mt-4">

<div class="text-center mb-4">
    <h3 class="fw-bold">Endline Inspection - Checker Login</h3>
</div>

<div class="row g-3">

<?php $__currentLoopData = $lines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $line): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

<div class="col-md-3">

<div class="card line-card shadow-sm"
     data-group="<?php echo e($line->group_name); ?>"
     data-cc="<?php echo e($line->cc_no); ?>"
     data-line="<?php echo e($line->allocated_line_id); ?>">

<div class="card-body text-center">

<h5 class="fw-bold text-primary">
Group : <?php echo e($line->group_name); ?>

</h5>

<p class="mb-1">
CC : <b><?php echo e($line->cc_no); ?></b>
</p>

<p class="mb-0">
Line No : <b><?php echo e($line->allocated_line_id); ?></b>
</p>

</div>

</div>

</div>

<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

</div>

<hr>

<div class="row justify-content-center mt-4">

<div class="col-md-4 text-center">

<h5>Selected Line</h5>

<div class="alert alert-success" id="selectedLine">
Please Select Line
</div>

<input type="text"
id="checker_scan"
class="form-control text-center"
placeholder="Scan Checker ID Card"
autofocus>

</div>

</div>

</div>
                
                

            </div>
        </div>
    </div>

    <!-- External Script Dependencies (jQuery & Bootstrap) -->
    <!-- jQuery Core -->
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <!-- Bootstrap 5 JS with Popper.js -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        $(document).ready(function() {

        var selectedLine = '';

$('.line-card').click(function(){

$('.line-card').removeClass('line-selected');

$(this).addClass('line-selected');

var group = $(this).data('group');
var cc = $(this).data('cc');
var line = $(this).data('line');

selectedLine = line;

$('#selectedLine').html(
"Group : "+group+" | CC : "+cc+" | Line : "+line
);

});
            console.log("Endline interface initialized.");

            // Custom Dropdown Logic
            const $dropdownMenu = $('#customDropdownMenu');
            const $toggleBtn = $('#dropdownToggleBtn');
            const $selectPlaceholder = $('#selectPlaceholder');
            const $badgesContainer = $('#selectedBadgesContainer');
            const $selectedCountText = $('#selectedCountText');
            
            // Array to store selected line numbers
            let selectedLines = [];

            // Toggle dropdown
            $toggleBtn.on('click', function(e) {
                e.stopPropagation();
                $dropdownMenu.toggleClass('show');
            });

            // Prevent closing when clicking inside dropdown menu
            $dropdownMenu.on('click', function(e) {
                e.stopPropagation();
            });

            // Close dropdown when clicking outside
            $(document).on('click', function() {
                $dropdownMenu.removeClass('show');
            });

            // Handle line item selection click
            $('.line-item').on('click', function() {
                const value = $(this).data('value');
                const $this = $(this);

                if ($this.hasClass('selected')) {
                    // Deselect
                    $this.removeClass('selected');
                    selectedLines = selectedLines.filter(line => line !== value);
                } else {
                    // Select
                    $this.addClass('selected');
                    selectedLines.push(value);
                    // Optional sorting if you want the tags sorted sequentially (ascending)
                    selectedLines.sort((a, b) => a - b);
                }
                
                updateUI();
            });

            // Handle Clear All action
            $('#clearAllBtn').on('click', function() {
                $('.line-item').removeClass('selected');
                selectedLines = [];
                updateUI();
            });

            // Function to update Badges & UI Text
            function updateUI() {
                // Clear the badges area
                $badgesContainer.empty();
                
                if (selectedLines.length > 0) {
                    $selectPlaceholder.text(`${selectedLines.length} Lines Selected`);
                    
                    selectedLines.forEach(function(line) {
                        $badgesContainer.append(`
                            <div class="top-badge">
                                LINE ${line}
                            </div>
                        `);
                    });
                    
                    $selectedCountText.text(`${selectedLines.length} SELECTED`);
                } else {
                    $selectPlaceholder.text('Select Production Lines...');
                    $selectedCountText.text('0 SELECTED');
                }}
            // Start Inspection click action
            $('#startInspectionBtn').on('click', function() {
                window.location.href = "<?php echo e(route('endlinetablepage')); ?>";
            });
        });
    </script>
</body>
</html>
<?php /**PATH D:\xampp\htdocs\Endline\resources\views/Quality/Endline.blade.php ENDPATH**/ ?>