<!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;
        }
    </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">
                
                <!-- Line Selector Component -->
                <div class="mb-4 position-relative" id="lineSelectorComponent">
                    
                    <!-- Selected Badges Area -->
                    <div id="selectedBadgesContainer" class="d-flex flex-wrap gap-2 mb-3">
                        <!-- Badges will be injected here via JS -->
                    </div>

                    <!-- Dropdown Toggle Button -->
                    <button class="form-select form-select-lg text-start shadow-none custom-select-btn" type="button" id="dropdownToggleBtn">
                        <span id="selectPlaceholder">Select Production Lines...</span>
                    </button>

                    <!-- Custom Dropdown Menu -->
                    <div class="custom-dropdown-menu" id="customDropdownMenu">
                        <div class="grid-container p-3">
                            <!-- Generate Numbers 1 to 60 -->
                            <?php for($i = 1; $i <= 60; $i++): ?>
                                <div class="line-item" data-value="<?php echo e($i); ?>"><?php echo e($i); ?></div>
                            <?php endfor; ?>
                        </div>
                        
                        <!-- Dropdown Footer -->
                        <div class="dropdown-footer d-flex justify-content-between align-items-center">
                            <span class="selected-count" id="selectedCountText">0 SELECTED</span>
                            <button type="button" class="btn btn-link clear-all-btn text-decoration-none shadow-none" id="clearAllBtn">CLEAR ALL</button>
                        </div>
                    </div>
                </div>

                <!-- Inner Profile Details Layout -->
                <div class="profile-container d-flex flex-column flex-md-row align-items-center justify-content-center gap-4 gap-md-5 mx-0 mx-md-2">
                    
                    <!-- Avatar Area -->
                    <div class="profile-image-wrapper flex-shrink-0">
                        <img src="https://images.unsplash.com/photo-1542601906990-b4d3fb778b09?ixlib=rb-4.0.3&auto=format&fit=crop&w=300&q=80" alt="Jane Doe Profile" class="profile-image">
                    </div>

                    <!-- User Actions -->
                    <div class="d-flex flex-column align-items-center align-items-md-start w-100" style="max-width: 350px;">
                        
                        <h2 class="fw-bold mb-3 text-dark fs-3 letter-spacing-tight">JANE DOE</h2>
                        
                        <!-- Badges/Tags Region -->
                        <div class="d-flex flex-wrap gap-2 justify-content-center justify-content-md-start mb-4">
                            <span class="badge badge-verified rounded-pill px-3 py-2">
                                VERIFIED CHECKER
                            </span>
                            <span class="badge badge-grade rounded-pill px-3 py-2">
                                GRADE A+
                            </span>
                            <span class="badge badge-dept rounded-pill px-3 py-2">
                                DEPT: FINISHING
                            </span>
                        </div>

                        <!-- CTA Action Area -->
                        <button id="startInspectionBtn" type="button" class="btn btn-start-inspection w-100 mb-3 d-flex align-items-center justify-content-center gap-2">
                            <i class="bi bi-box-arrow-in-right fs-5"></i>
                            START INSPECTION
                        </button>

                        <div class="text-center w-100 mt-2">
                            <span class="wrong-profile-text">WRONG PROFILE? RESCAN ID CARD</span>
                        </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() {
            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 C:\projects\endline_laravel\Endline\resources\views/Quality/Endline.blade.php ENDPATH**/ ?>