<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <link rel="icon" type="image/x-icon" href="logo.png">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes">
    <title>CSV Viewer by Badhesh Chauhan</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.1/papaparse.min.js"></script>
    <script defer data-domain="tools.badheshchauhan.com"
        src="https://getanalyzr.vercel.app/tracking-script.js"></script>
    <style>
        #searchInput {
            width: 90%;
            padding: 10px;
            border: none;
            border-radius: 25px;
            background-image: linear-gradient(to right, #FF6B6B, #1E90FF);
            color: #fff;
            font-size: 20px;
            box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.2);
            outline: none;
            transition: background-image 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
            margin-bottom: 10px;
        }

        #searchInput:hover,
        #searchBtn:hover {
            background-image: linear-gradient(to right, #a89ba2, #44515e);
            box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.3);

        }

        #searchInput:focus {
            background-image: linear-gradient(to right, #a5979f, #555759);
            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.4);
        }



        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f5f5;
            color: #333;
        }

        .container {
            max-width: 90%;
            margin: 20px auto;
            padding: 20px;
            background-color: #475a9a;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            color: #efeaea;
        }


        @media (max-width: 768px) {
            .container {
                padding: 15px;
            }

            th,
            td {
                padding: 6px;
                /* Further reduce padding on small screens */
                font-size: 0.8rem;
            }
        }

        .delete-icon {
            cursor: pointer;
            color: red;
            margin-left: 5px;
            display: none;
        }

        th:hover .delete-icon,
        td:hover .delete-icon {
            display: inline;
        }

        .delete-icon:hover {
            color: rgb(228, 17, 17);
        }


        .table-container {
            margin: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            overflow: auto;
            max-height: 570px;
            position: relative;
            border-radius: 20px;
        }

        .custom-table {
            width: 100%;
            border-collapse: collapse;
            border-spacing: 0;
            background-color: white;
            font-family: Arial, sans-serif;
            border-radius: 30px;
        }

        .custom-table thead th {
            position: sticky;
            top: 0;
            z-index: 2;
            background-color: #f8f9fa;
            border-bottom: 2px solid #e9ecef;
            box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
        }

        .custom-table th {
            padding: 12px 16px;
            text-align: left;
            font-weight: 600;
            color: #343a40;
            text-transform: uppercase;
            font-size: 14px;
        }

        .custom-table td {
            padding: 12px 16px;
            border-bottom: 1px solid #e9ecef;
            /*color: #c5d6e7; */
        }

        .custom-table tbody tr:nth-child(odd):hover,
        .custom-table tbody tr:nth-child(even):hover {
            background-color: #db5353;
            transition: background-color 0.2s ease;
        }

        .custom-table tbody tr:nth-child(even) {
            background-color: #dbe7e7;
        }

        @media (max-width: 768px) {
            .table-container {
                max-height: 400px;
                /* Adjusted for mobile */
            }

            .custom-table th,
            .custom-table td {
                padding: 8px 12px;
                font-size: 14px;
            }
        }

        .table-container::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        .table-container::-webkit-scrollbar-track {
            background: #f1f1f1;
        }

        .table-container::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 4px;
        }

        .table-container::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
    </style>
</head>

<body>
    <div class="container">
        <h2>CSV Viewer</h2>
        <div class="input-group mb-3 ">
            <label class="input-group-text">Upload CSV File</label>
            <input type="file" id="csvFile" class="input-group-text" accept=".csv" multiple>
        </div>
    </div>
    <div id="table-container" style="display:none;">
        <center>
            <button type="button" class="btn btn-success download-button  btn-block" id='csv'
                onclick="tableToCSV('csv')"><span class="glyphicon glyphicon-download-alt"></span> CSV</button>
            <button type="button" class="btn btn-success download-button  btn-block" id='xlsx'
                onclick="tableToCSV('xlsx')"><span class="glyphicon glyphicon-download-alt"></span> XLSX</button>
            <button type="button" class="btn btn-success download-button  btn-block" id='copy'
                onclick="tableToCSV('copy')"><span class="glyphicon glyphicon-copy"></span> COPY ALL</button>
            <button type="button" class="btn btn-warning btn-block" id='resetColumns' onclick="resetTable()">Reset
                columns</button><br /><br />
            <input type="text" id="searchInput" placeholder="Search Data in Table Example">
        </center>
    </div>
    <div class="table-container">
        <table id="csvTable" style="display:none;" class=" custom-table table-bordered border-primary table-responsive">
            <thead class="table-success">
                <tr id="headerRow"></tr>
            </thead>
            <tbody id="tableBody"></tbody>
        </table>
    </div>
    <script src="script/csvview.js"></script>

</body>

</html>