<!-- Button to Trigger Password Strength Analysis -->
<div class="bitbyte-buttons">
  <a id="showPasswordInputBtn" class="btn call-btn">
    Hover or Click to Check Password Strength
  </a>
</div>

<!-- Popup Container (Hidden Initially) -->
<div id="passwordPopup" class="popup-container">
  <div class="popup-content">
    <button class="close-btn" onclick="closePopup()">X</button>
    <h3>Password Strength Analyzer</h3>
    <input type="password" id="passwordInput" placeholder="Enter your password..." oninput="analyzePassword()" />
    <div id="results" class="result-box"></div>
  </div>
</div>

<!-- Load zxcvbn Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/zxcvbn/4.4.2/zxcvbn.js"></script>

<!-- Custom CSS -->
<style>
  body {
    font-family: Arial, sans-serif;
    background-color: white;
    color: #333;
  }

  /* Button Layout */
  .bitbyte-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .btn {
    padding: 12px 25px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    color: white;
    transition: all 0.3s ease;
  }

  /* Call Us Button */
  .call-btn {
    background-color: #0073e6;
  }

  .call-btn:hover::after {
    content: "  📞 +91 9980 43751";
  }

  .call-btn:hover {
    background-color: #005bb5;
  }

  /* Popup Container - Initially hidden */
  .popup-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* semi-transparent background */
    justify-content: center;
    align-items: center;
  }

  /* Popup Content */
  .popup-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
  }

  /* Close Button */
  .close-btn {
    background-color: red;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 18px;
  }

  /* Input and Result Box Styling */
  input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
  }

  .result-box {
    font-size: 14px;
    line-height: 1.6;
    margin-top: 20px;
    background: #f9f9f9;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #ddd;
    white-space: pre-wrap;
  }
</style>

<!-- Custom JS -->
<script>
  // Show popup when button is clicked
  document.getElementById('showPasswordInputBtn').addEventListener('click', function() {
    document.getElementById('passwordPopup').style.display = 'flex';
  });

  // Close the popup
  function closePopup() {
    document.getElementById('passwordPopup').style.display = 'none';
  }

  // Function to analyze password strength using zxcvbn
  function analyzePassword() {
    const password = document.getElementById('passwordInput').value;
    if (!password) {
      document.getElementById('results').innerText = '';
      return;
    }

    const result = zxcvbn(password);

    const scoreDescriptions = [
      'Too guessable (very weak)',
      'Very guessable (weak)',
      'Somewhat guessable (fair)',
      'Safely unguessable (good)',
      'Very unguessable (strong)'
    ];

    const output = `
🧠 Estimated Guesses: ${result.guesses}
🔢 Guesses Log10: ${result.guesses_log10.toFixed(2)}

📈 Score: ${result.score} (${scoreDescriptions[result.score]})

💬 Feedback:
  • Warning: ${result.feedback.warning || 'None'}
  • Suggestions: ${(result.feedback.suggestions || []).join(', ') || 'None'}

⚙️ Calculation Time: ${result.calc_time} ms
    `;

    document.getElementById('results').innerText = output;
  }
</script>
