{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Attribute Extraction</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/source-sans-3@5.0.12/index.css"
        integrity="sha256-tXJfXfp6Ewt1ilPzLDtQnJV4hclT9XuaZUKyUvmyr+Q=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/overlayscrollbars@2.3.0/styles/overlayscrollbars.min.css"
        integrity="sha256-dSokZseQNT08wYEWiz5iLI8QPlKxG+TswNRD8k35cpg=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.min.css"
        integrity="sha256-Qsx5lrStHZyR9REqhUF8iQt73X06c8LGIUPzpOhwRrI=" crossorigin="anonymous">
  <link rel="stylesheet" href="{% static './css/adminlte.css' %}">
  <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="{% static './css/select2-bootstrap4.min.css' %}">
  <link rel="stylesheet" href="{% static 'css/custom.css' %}">
  <link rel="stylesheet" href="{% static 'css/attr-extraction.css' %}">
  <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>


</head>
<body class="layout-fixed sidebar-expand-lg sidebar-mini app-loaded sidebar-collapse">
  <div class="app-wrapper"> <!--begin::Header-->
    {% include 'header.html' %}
    {% include 'sidebar.html' %}
    <main class="app-main"> <!--begin::App Content Header-->
      <div class="app-content-header"> <!--begin::Container-->
          <div class="container-fluid"> <!--begin::Row-->
            <!-- Full Page Loader -->
            <div id="full-page-loader" style="display: none;">
                <div class="loader-overlay">
                    <div class="spinner-border text-light" role="status">
                        <!-- <span class="sr-only">Loading...</span> -->
                    </div>
                </div>
            </div>
              <div class="row">
                  <div class="col-sm-6">
                      <h3 class="mb-0">⛏️ Attribute Extraction
                            &nbsp;<span><a href="./../media/examples/actual_product_list.xlsx"    title="Example file" download><i class="bi bi-download"></i></a></span>
                      </h3>
                  </div>
                  <div class="col-sm-6">
                      <ol class="breadcrumb float-sm-end">
                          <li class="breadcrumb-item"><a href="{% url 'file-upload' %}">Home</a></li>
                          <li class="breadcrumb-item active" aria-current="page"><a href="{% url 'generate-video' %}"></a>
                              ⛏️ Attribute Extraction</a>
                          </li>
                      </ol>
                  </div>
              </div> <!--end::Row-->
          </div> <!--end::Container-->
      </div>
      <div class="app-content-header"> <!--begin::Container-->
          <div class="container-fluid "> <!--begin::Row-->
            <!-- attr -->
                <div class="container">
                    <header class="hero">
                    <div class="title">
                        <div class="title-logo" aria-hidden="true">
                        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                            <path d="M5 12c0-3.866 3.134-7 7-7 2.7 0 5.06 1.486 6.3 3.69L12 12l-6.3 3.69C3.74 13.486 5 10.7 5 12z" fill="white" fill-opacity=".95"/>
                            <path d="M12 12l6.3-3.69C20.26 10.514 19 13.3 19 12c0 3.866-3.134 7-7 7-2.7 0-5.06-1.486-6.3-3.69L12 12z" fill="#9FECE2"/>
                        </svg>
                        </div>
                        <div>
                        <h1>Product Inventory</h1>
                        </div>
                    </div>
                    <div class="actions">
                        <!-- Checkbox: Extract Additional -->
                        <div class="form-check me-3"  style="padding: 10px;">
                            <input class="form-check-input" checked type="checkbox" id="extract_additional" name="extract_additional">
                            <label class="form-check-label" for="extract_additional">
                               &nbsp; Extract Additional
                            </label>
                        </div>

                        <!-- Checkbox: Process Image -->
                        <div class="form-check me-3" style="padding: 10px;">
                            <input class="form-check-input" checked type="checkbox" id="process_image" name="process_image">
                            <label class="form-check-label" for="process_image">
                               &nbsp; Process Image
                            </label>
                        </div>
                        <!-- <input type="checkbox" id="extract_additional" name="extract_additional"/>
                        <input type="checkbox" id="process_image" name="process_image"/> -->
                        <button id="btnSubmit" class="btn btn-primary">Submit</button>
                        <button id="btnReset" class="btn btn-secondary">Reset</button>
                        <button id="btnSelectAll" class="btn btn-primary">Select all</button>
                        <!-- Upload trigger button -->
                        <button id="btnUpload" type="button"
                                class="btn btn-info"
                                data-bs-toggle="modal"
                                data-bs-target="#uploadModal">
                                Upload
                        </button>
                    </div>
                    </header>

                    <div class="grid">
                    <section class="card" id="api-summary" style="display: none;">
                        <div class="card-header">
                        <h2>API Summary</h2>
                        </div>
                        <div class="card-body">
                        <div class="summary">
                            <div class="stat"><div class="label">Total products</div><div class="value" id="statTotal">0</div></div>
                            <div class="stat"><div class="label">Successful</div><div class="value" id="statOk">0</div></div>
                            <div class="stat"><div class="label">Failed</div><div class="value" id="statKo">0</div></div>
                        </div>
                        </div>
                    </section>    
                    <section class="card">
                        <div class="card-header">
                        <h2>Products</h2>
                        <div class="toolbar">
                            <span class="pill" id="selectionInfo">No products selected</span>
                            <div class="seg" role="tablist" aria-label="Layout toggle">
                                <button id="btnCards" class="active" role="tab" aria-selected="true">Cards</button>
                                <button id="btnTable" role="tab" aria-selected="false">Table</button>
                            </div>
                            
                        </div>
                        <div><p>Select multiple :<select id="mandatory-attributes" name="mandatoryAttributes[]" aria-labelledby="select a attribute for which multiple data required" multiple="multiple" style="width: 100%;"></select></p></div>
                        <div>
                            <label for="thresholdRange">Threshold:</label>
                            <input type="range" id="thresholdRange" min="0" max="1" step="0.01" value="0.2">
                            <span id="thresholdValue">0.2</span>
                        </div>
                        </div>
                        <div class="card-body">
                        <!-- Cards layout container -->
                        <div id="cardsContainer" class="list" aria-live="polite"></div>
                        <!-- Table layout container -->
                         <!-- table-wrap  -->
                        <div id="tableContainer" class="table-responsive" style="display:none" aria-live="polite"></div>
                        <!-- Pagination bar -->
                        <div id="paginationBar" class="pagination-bar" aria-label="Pagination" style="display: none;"></div>
                        </div>
                    </section>

                    
                    </div>

                      

                    <!-- <footer> -->
                    <!-- <small>Tip: Select products and click <strong>Submit</strong>—attributes render inline under each selected product. Toggle <strong>Cards</strong>/<strong>Table</strong> views.</small> -->
                    <!-- </footer> -->
                </div>
                
                <!-- Upload Modal (Bootstrap) -->
                <div class="modal fade" id="uploadModal" tabindex="-1" aria-labelledby="uploadTitle" aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered modal-lg">
                    <div class="modal-content">

                    <div class="modal-header">
                        <h5 class="modal-title" id="uploadTitle">Upload files</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>

                    <div class="modal-body">
                        <!-- Drag & drop + file picker -->
                        <div id="dropzone" class="dropzone rounded-3" tabindex="0">
                        <strong>Drag & drop</strong> files here or
                        <label for="uploadFiles" class="text-primary text-decoration-underline" style="cursor:pointer;">browse</label>
                        <input id="uploadFiles" type="file" multiple class="d-none" />
                        <div id="fileInfo" class="file-info mt-2">No files selected.</div>
                        </div>

                        <!-- Progress bar (Bootstrap) -->
                        <div class="progress mt-3" role="progressbar" aria-label="Upload progress" aria-valuemin="0" aria-valuemax="100">
                        <div id="uploadBar" class="progress-bar" style="width: 0%"></div>
                        </div>

                        <!-- Status -->
                        <div id="uploadStatus" class="mt-2 text-secondary"></div>
                    </div>

                    <div class="modal-footer">
                        <button type="button" id="uploadCancel" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                        <button type="button" id="uploadStart" class="btn btn-success">Start upload</button>
                    </div>

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

            <!-- attr -->
          </div>
      </div>
    </main>


    {% include 'footer.html' %}
    
  </div>

  
    <script src="https://cdn.jsdelivr.net/npm/overlayscrollbars@2.3.0/browser/overlayscrollbars.browser.es6.min.js"
        ></script>
    <!--end::Third Party Plugin(OverlayScrollbars)--><!--begin::Required Plugin(popperjs for Bootstrap 5)-->
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"
        ></script>
    <!--end::Required Plugin(popperjs for Bootstrap 5)--><!--begin::Required Plugin(Bootstrap 5)-->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.min.js"
        ></script>
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
    <!--end::Required Plugin(Bootstrap 5)--><!--begin::Required Plugin(AdminLTE)-->
    <script src="{% static './js/adminlte.js' %}"></script>
    
    <script>
        // $(document).ready(function() {
        //     // Your jQuery code here, e.g.,
        //     $('#full-page-loader').show();  
        // });
        const SELECTOR_SIDEBAR_WRAPPER = ".sidebar-wrapper";
        const Default = {
            scrollbarTheme: "os-theme-light",
            scrollbarAutoHide: "leave",
            scrollbarClickScroll: true,
        };
        document.addEventListener("DOMContentLoaded", function () {
            const sidebarWrapper = document.querySelector(SELECTOR_SIDEBAR_WRAPPER);
            if (
                sidebarWrapper &&
                typeof OverlayScrollbarsGlobal?.OverlayScrollbars !== "undefined"
            ) {
                OverlayScrollbarsGlobal.OverlayScrollbars(sidebarWrapper, {
                    scrollbars: {
                        theme: Default.scrollbarTheme,
                        autoHide: Default.scrollbarAutoHide,
                        clickScroll: Default.scrollbarClickScroll,
                    },
                });
            }
        });
        $('#mandatory-attributes').select2({
            placeholder: 'Select mandatory attributes',
            allowClear: true,
            width: '200px' // or 'resolve' if dynamically sized
        });

        // In your Javascript (external .js resource or <script> tag)
        // $(document).ready(function() {
        //     // jQuery('#mandatory-attributes').select2();
        // });
    </script> 
    <script src="{% static 'js/attr-extraction.js' %}"></script>
    
</body>
</html>