<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Product | OpenSurvey</title>
    <link rel="icon" type="image/png" sizes="32x32" href="/images/dot_logo.png">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css"/>

    <link rel="stylesheet" href="/css/style.css">

    <style>
        #globalTopBtn {
            position: fixed;
            right: 20px;
            bottom: 20px;
            width: 48px;
            height: 48px;
            border-radius: 50%;
            border: none;
            background: linear-gradient(135deg, #4e8aee, #1f5fb8);
            color: #ffffff;
            box-shadow: 0 10px 20px rgba(31, 95, 184, 0.35);
            display: none;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 1050;
            transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
        }

        #globalTopBtn:hover {
            transform: translateY(-2px);
            box-shadow: 0 14px 24px rgba(31, 95, 184, 0.45);
        }

        #globalTopBtn:focus-visible {
            outline: 2px solid #cbdcff;
            outline-offset: 2px;
        }

        .dynamic-status-toast {
            position: fixed;
            top: 88px;
            right: 20px;
            z-index: 1080;
            min-width: 280px;
            max-width: 420px;
        }
    </style>
</head>

<body>
    <div>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">

  <style>
    .top-bar {
      background: linear-gradient(90deg, rgba(24, 27, 45, 0.95), rgba(24, 27, 45, 0.9));
      color: #f8f9fc;
      font-size: 0.9rem;
      letter-spacing: 0.02em;
      border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    .top-bar__container {
      padding: 0.4rem 0;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 1rem;
      flex-wrap: wrap;
    }
    .top-bar__left,
    .top-bar__right {
      display: flex;
      align-items: center;
      gap: 1.25rem;
      flex-wrap: wrap;
    }
    .top-bar__contact {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      background: rgba(255, 255, 255, 0.05);
      padding: 0.3rem 0.75rem;
      border-radius: 999px;
    }
    .top-bar__contact i {
      color: #60a5fa;
    }
    .top-bar__link {
      color: inherit;
      text-decoration: none;
      transition: color 0.2s ease, opacity 0.2s ease;
    }
    .top-bar__link:hover {
      color: #60a5fa;
      opacity: 0.9;
    }
    .top-bar__social {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      margin-left: 0.75rem;
    }
    .top-bar__social a {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.08);
      color: #f8f9fc;
      transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
    }
    .top-bar__social a:hover {
      transform: translateY(-2px);
      background: #60a5fa;
      color: #0b173d;
    }
    .top-bar__cta-group .btn {
      border-radius: 999px;
      font-weight: 600;
      padding: 0.35rem 0.95rem;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .top-bar__cta-group .btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 8px 16px rgba(96, 165, 250, 0.25);
    }
    .top-bar__divider {
      width: 1px;
      height: 18px;
      background: rgba(255, 255, 255, 0.12);
    }

    @media (max-width: 991px) {
      .top-bar__container {
        justify-content: center;
        text-align: center;
      }
      .top-bar__left,
      .top-bar__right {
        justify-content: center;
      }
      .top-bar__social {
        margin-left: 0;
      }
    }
  </style>

  <div class="top-bar">
    <div class="container top-bar__container">
      <div class="top-bar__left">
        <div class="top-bar__contact">
          <i class="bi bi-telephone"></i>
          <span>+88 01715 010905</span>
        </div>
        <div class="top-bar__contact">
          <i class="bi bi-envelope"></i>
          <a href="mailto:info@sebaghor.com" class="top-bar__link">info@sebaghor.com</a>
        </div>
        <span class="top-bar__divider d-none d-lg-inline-block"></span>
        <div class="top-bar__social">
          <a href="#" aria-label="Facebook"><i class="bi bi-facebook"></i></a>
          <a href="#" aria-label="Twitter"><i class="bi bi-twitter"></i></a>
          <a href="#" aria-label="LinkedIn"><i class="bi bi-linkedin"></i></a>
          <a href="#" aria-label="Instagram"><i class="bi bi-instagram"></i></a>
          <a href="#" aria-label="YouTube"><i class="bi bi-youtube"></i></a>
        </div>
      </div>

      <div class="top-bar__right top-bar__cta-group">
        <button type="button"
                class="btn btn-success btn-sm live-chat-premium"
                data-bs-toggle="modal"
                
                data-bs-target="#chatModal">
          <i class="bi bi-chat-left-text me-1"></i>
          Live Chat
        </button>
        <a href="https://thedotservices.org/registration?source=dotservice&clientCode=0000&moduleCode=00"
           target="_blank"
           class="btn btn-primary btn-sm px-3">
          Register
        </a>
        <a href="https://thedotservices.org/?source=dotservice&clientCode=0000&moduleCode=00"
           target="_blank"
           class="top-bar__link fw-semibold">
          Login
        </a>
      </div>
    </div>
  </div>

  <nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm" style="padding:0.15rem 0 !important;">
    <div class="container">
      <a class="navbar-brand" href="/">
        <img src="/images/dot_logo.png" alt="Logo" class="img-fluid" width="60"/>
      </a>

      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
              aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav ms-auto align-items-lg-center">
          <li class="nav-item mx-2">

            <a class="nav-link fw-semibold"
               href="/HOME_DOT">HOME</a>

            

            
          </li>
          <li class="nav-item mx-2  dropdown">

            

            <a class="nav-link dropdown-toggle fw-semibold"
               href="#"
               id="navbarDropdown"
               role="button"
               data-bs-toggle="dropdown"
               aria-expanded="false">About Us</a>

            <ul class="dropdown-menu shadow-sm border-0 rounded-2"
                aria-labelledby="navbarDropdown">
              <li>
                <a class="dropdown-item py-2"
                   href="/dwMgnt">Our Management</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwTalent">Our Talents</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwSkill">Our Skills</a>
              </li>
            </ul>
          </li>
          <li class="nav-item mx-2  dropdown">

            

            <a class="nav-link dropdown-toggle fw-semibold"
               href="#"
               id="navbarDropdown"
               role="button"
               data-bs-toggle="dropdown"
               aria-expanded="false">Products</a>

            <ul class="dropdown-menu shadow-sm border-0 rounded-2"
                aria-labelledby="navbarDropdown">
              <li>
                <a class="dropdown-item py-2"
                   href="/dwCRM">Customer Relationship Management</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwAccount">Financial Accounting</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwERP">Manufacturing ERP Solution</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwHospital">Hospital Management System</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwPRD">Production Monitoring System</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwINV">Inventory Management System</a>
              </li>
            </ul>
          </li>
          <li class="nav-item mx-2  dropdown">

            

            <a class="nav-link dropdown-toggle fw-semibold"
               href="#"
               id="navbarDropdown"
               role="button"
               data-bs-toggle="dropdown"
               aria-expanded="false">Services</a>

            <ul class="dropdown-menu shadow-sm border-0 rounded-2"
                aria-labelledby="navbarDropdown">
              <li>
                <a class="dropdown-item py-2"
                   href="/dwWeb">Web/Portal/eCommerce Development</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwDM">Digital Marketing</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwMail">Bulk Mail Services</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwAI">AI Integration</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwRE">Reverse Engineering</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwContent">Content Writing</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwScrap">Targeted Data Collection</a>
              </li>
            </ul>
          </li>
          <li class="nav-item mx-2  dropdown">

            

            <a class="nav-link dropdown-toggle fw-semibold"
               href="#"
               id="navbarDropdown"
               role="button"
               data-bs-toggle="dropdown"
               aria-expanded="false">Clients</a>

            <ul class="dropdown-menu shadow-sm border-0 rounded-2"
                aria-labelledby="navbarDropdown">
              <li>
                <a class="dropdown-item py-2"
                   href="/dwPartner">Our Partner</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwAffiliation">Our Affiliation</a>
              </li>
            </ul>
          </li>
          <li class="nav-item mx-2  dropdown">

            

            <a class="nav-link dropdown-toggle fw-semibold"
               href="#"
               id="navbarDropdown"
               role="button"
               data-bs-toggle="dropdown"
               aria-expanded="false">Career</a>

            <ul class="dropdown-menu shadow-sm border-0 rounded-2"
                aria-labelledby="navbarDropdown">
              <li>
                <a class="dropdown-item py-2"
                   href="/dwIntern">Internship</a>
              </li>
              <li>
                <a class="dropdown-item py-2"
                   href="/dwVacancy">Curremt Openings</a>
              </li>
            </ul>
          </li>
          <li class="nav-item mx-2">

            <a class="nav-link fw-semibold"
               href="/dwContact">Contact Us</a>

            

            
          </li>
        </ul>
      </div>
    </div>
  </nav>

  <div class="modal fade" id="chatModal" tabindex="-1" aria-labelledby="chatModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
      <div class="modal-content border-0 shadow-lg">
        <div class="modal-header bg-success text-white">
          <h5 class="modal-title" id="chatModalLabel"><i class="bi bi-chat-dots me-2"></i>Send us a Message</h5>
          <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body p-4">
          <form id="chatForm">
            <div class="mb-3">
              <label for="chatName" class="form-label fw-semibold">Your Name</label>
              <input type="text" id="chatName" class="form-control" placeholder="Enter your name" required>
            </div>
            <div class="mb-3">
              <label for="chatEmail" class="form-label fw-semibold">Email</label>
              <input type="email" id="chatEmail" class="form-control" placeholder="Enter your email" required>
            </div>
            <div class="mb-3">
              <label for="chatMessage" class="form-label fw-semibold">Message</label>
              <textarea id="chatMessage" class="form-control" rows="3" placeholder="Type your message here..." required></textarea>
            </div>
            <div class="text-end">
              <button type="button" id="sendChatBtn" class="btn btn-success px-4">
                <i class="bi bi-send"></i> Send Message
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>

  <style>
    .navbar-brand img {
      max-height: 52px;
      width: auto;
    }
    .navbar .container {
      padding-top: 0.35rem;
      padding-bottom: 0.35rem;
    }
    .navbar-nav .nav-link {
      color: #111;
      font-weight: 500;
      padding: 0.35rem 0.75rem;
      line-height: 1.2;
    }
    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link.active {
      color: #0056b3;
    }

    @media (min-width: 992px) {
      .navbar .dropdown-menu {
        display: none;
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
        transition: all 0.25s ease;
      }
      .navbar .dropdown:hover .dropdown-menu {
        display: block;
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
      }
      .navbar .dropdown-toggle::after {
        transition: transform 0.2s ease;
      }
      .navbar .dropdown:hover .dropdown-toggle::after {
        transform: rotate(180deg);
      }
    }

    .live-chat-premium {
      background-color: #198754;
      color: #fff;
      border: none;
      transition: all 0.3s ease-in-out;
      animation: premiumPulse 1.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
      position: relative;
      z-index: 1;
    }
    @keyframes premiumPulse {
      0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.5);
      }
      50% {
        transform: scale(1.045);
        box-shadow:
          0 0 18px 6px rgba(25, 135, 84, 0.35),
          0 0 28px 12px rgba(128, 255, 128, 0.25);
      }
    }
    .live-chat-premium:hover {
      transform: scale(1.05);
      box-shadow:
        0 0 20px 8px rgba(25, 135, 84, 0.45),
        0 0 35px 15px rgba(144, 255, 144, 0.3);
    }
  </style>

  <script>
    document.addEventListener("DOMContentLoaded", function () {
      if (window.innerWidth < 992) {
        document.querySelectorAll('.navbar .dropdown').forEach(function (dropdown) {
          dropdown.addEventListener('hidden.bs.dropdown', function () {
            this.querySelectorAll('.submenu').forEach(function (submenu) {
              submenu.classList.remove('show');
            });
          });
        });
      }

      document.getElementById("sendChatBtn").addEventListener("click", async function() {
        const name = document.getElementById("chatName").value.trim();
        const email = document.getElementById("chatEmail").value.trim();
        const message = document.getElementById("chatMessage").value.trim();

        if (!name || !email || !message) {
          alert("Please fill out all fields before sending.");
          return;
        }

        try {
          const res = await fetch("/send-chat-message", {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({ name, email, message })
          });
          const data = await res.json();

          if (data.status === 200) {
            alert("Message sent successfully!");
            document.getElementById("chatForm").reset();
            const modal = bootstrap.Modal.getInstance(document.getElementById("chatModal"));
            modal.hide();
          } else {
            alert("Failed: " + (data.message || "Please try again."));
          }
        } catch (err) {
          alert("Error sending message. Please try later.");
        }
      });
    });
  </script>
</div>

    <div class="container-fluid px-0 mt-3 mb-0" style="overflow:hidden;">
        <iframe
            id="dynamicContentFrame"
            style="width:100%; min-height:80vh; border:none; border-radius:10px; background:white; display:block;"
            title="Dynamic Content"
            sandbox="allow-scripts allow-same-origin allow-popups allow-forms allow-top-navigation-by-user-activation"
            scrolling="no">
        </iframe>
    </div>

    <button type="button" id="globalTopBtn" aria-label="Scroll to top">
        <i class="fas fa-arrow-up"></i>
    </button>

    <!-- … Common Footer -->
    <footer class="site-footer mt-5">
  <style>
    .site-footer {
      background: linear-gradient(115deg, #4e8aee, #3d73d5);
      color: #ffffff;
      padding: 1rem 0.75rem;
      box-shadow: inset 0 5px 12px rgba(8, 24, 68, 0.08);
    }
    .site-footer .container {
      max-width: 1080px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1.25rem;
      flex-wrap: wrap;
    }
    .site-footer__contact {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.35rem 0.85rem;
      background: rgba(255, 255, 255, 0.15);
      border-radius: 999px;
      font-weight: 600;
      letter-spacing: 0.01em;
      color: inherit;
      text-decoration: none;
      transition: background 0.2s ease, transform 0.2s ease;
    }
    .site-footer__contact:hover {
      background: rgba(255, 255, 255, 0.22);
      transform: translateY(-1px);
    }
    .site-footer__contact i {
      font-size: 0.9rem;
    }
    .site-footer__divider {
      width: 1px;
      height: 18px;
      background: rgba(255, 255, 255, 0.25);
    }
    .site-footer__copy {
      font-size: 0.78rem;
      opacity: 0.88;
      margin: 0;
      letter-spacing: 0.01em;
    }
    .site-footer__nav {
      display: inline-flex;
      gap: 1rem;
      flex-wrap: wrap;
      font-size: 0.78rem;
      opacity: 0.9;
    }
    .site-footer__nav a {
      color: inherit;
      text-decoration: none;
      transition: opacity 0.2s ease;
    }
    .site-footer__nav a:hover {
      opacity: 1;
    }
  </style>

  <div class="container">
    <div class="d-flex align-items-center gap-2">
      <a href="mailto:info@dotbd.tech" class="site-footer__contact">
        <i class="bi bi-envelope-at-fill"></i>
        info@dotbd.tech
      </a>
      <span class="site-footer__divider d-none d-md-inline-block"></span>
    </div>

    <nav class="site-footer__nav">
      <a href="/about">About</a>
      <a href="/contact">Contact</a>
      <a href="/privacy">Privacy</a>
    </nav>

    <p class="site-footer__copy">
      &copy; 2025 <span class="fw-semibold">DOT-BD</span>. All rights reserved.
    </p>
  </div>
</footer>

    <div class="toast-container dynamic-status-toast">
        <div id="dynamicStatusToast" class="toast align-items-center border-0" role="status" aria-live="polite" aria-atomic="true">
            <div class="d-flex">
                <div id="dynamicStatusToastBody" class="toast-body fw-semibold"></div>
                <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', () => {
            const frame = document.getElementById('dynamicContentFrame');
            const topBtn = document.getElementById('globalTopBtn');
            const statusToastEl = document.getElementById('dynamicStatusToast');
            const statusToastBody = document.getElementById('dynamicStatusToastBody');
            const statusToast = statusToastEl ? bootstrap.Toast.getOrCreateInstance(statusToastEl, {
                delay: 4500
            }) : null;
            const embeddedStyleId = 'dynamic-content-overrides';

            const injectEmbeddedStyles = (doc) => {
                if (!doc || doc.getElementById(embeddedStyleId)) {
                    return;
                }

                const style = doc.createElement('style');
                style.id = embeddedStyleId;
                style.textContent = `
                    .dynamic-content-list {
                        list-style: none !important;
                        margin: 1rem 0 !important;
                        padding: 0 !important;
                        display: grid;
                        grid-template-columns: minmax(0, 1fr) !important;
                        gap: 0.9rem;
                        width: 100%;
                    }

                    .dynamic-content-list li {
                        list-style: none !important;
                        position: relative;
                        margin: 0 !important;
                        padding: 0 0 0 1.5rem !important;
                        color: #1f2937;
                        font-size: 1rem;
                        line-height: 1.65;
                    }

                    .dynamic-content-list li::marker {
                        content: "" !important;
                    }

                    .dynamic-content-list li::before {
                        content: "" !important;
                        position: absolute;
                        top: 0.78em;
                        left: 0;
                        width: 0.5rem;
                        height: 0.5rem;
                        border-radius: 999px;
                        background: linear-gradient(135deg, #ec4899, #db2777);
                        box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.14);
                        transform: translateY(-50%);
                    }

                    .dynamic-content-list.feature-steps {
                        list-style: decimal !important;
                        padding-left: 1.5rem !important;
                    }

                    .dynamic-content-list.feature-steps li {
                        display: list-item !important;
                        list-style: decimal !important;
                        padding-left: 0.25rem !important;
                    }

                    .dynamic-content-list.feature-steps li::marker {
                        content: normal !important;
                        color: #1f5fb8;
                        font-weight: 700;
                    }

                    .dynamic-content-list.feature-steps li::before {
                        content: none !important;
                        display: none !important;
                    }

                    .card-content .card-title-display {
                        display: block;
                        font-size: 0.95rem;
                        line-height: 1.35;
                    }

                    .card-content .card-ui-code {
                        display: block;
                        margin-top: 0.2rem;
                        font-size: 0.78rem;
                        line-height: 1.3;
                        color: #4b5563;
                    }

                    .card .card-image-preview {
                        cursor: zoom-in;
                    }

                    .image-preview-header {
                        margin-bottom: 0.75rem;
                    }

                    .image-preview-header h3 {
                        margin: 0 0 0.25rem;
                    }

                    .image-preview-header span {
                        display: block;
                        color: #4b5563;
                        font-size: 0.85rem;
                    }

                    .image-preview-stage {
                        overflow: auto;
                        max-height: calc(100vh - 230px);
                        text-align: center;
                        background: #f8fafc;
                        border: 1px solid #e5e7eb;
                        border-radius: 8px;
                        padding: 1rem;
                    }

                    .dynamic-content-list + p,
                    .dynamic-content-list + h1,
                    .dynamic-content-list + h2,
                    .dynamic-content-list + h3,
                    .dynamic-content-list + h4,
                    .dynamic-content-list + h5,
                    .dynamic-content-list + h6 {
                        margin-top: 1.75rem !important;
                    }
                `;
                doc.head?.appendChild(style);
            };

            const decorateExistingLists = (doc) => {
                doc.querySelectorAll('ul, ol').forEach((list) => {
                    if (
                        list.closest('.navbar, .dropdown-menu, .breadcrumb, .pagination, .list-group')
                    ) {
                        return;
                    }
                    list.classList.add('dynamic-content-list');
                });
            };

            const normalizeOrphanListItems = (doc) => {
                const orphanItems = Array.from(doc.body?.querySelectorAll('li') || []).filter((item) => {
                    const parentTag = item.parentElement?.tagName;
                    return parentTag !== 'UL' && parentTag !== 'OL';
                });

                orphanItems.forEach((item) => {
                    if (!item.isConnected || item.parentElement?.tagName === 'UL' || item.parentElement?.tagName === 'OL') {
                        return;
                    }

                    const wrapper = doc.createElement('ul');
                    wrapper.className = 'dynamic-content-list';
                    item.parentNode?.insertBefore(wrapper, item);

                    let current = item;
                    while (
                        current &&
                        current.parentElement &&
                        current.parentElement.tagName !== 'UL' &&
                        current.parentElement.tagName !== 'OL' &&
                        current.tagName === 'LI'
                    ) {
                        const next = current.nextElementSibling;
                        wrapper.appendChild(current);
                        current = next;
                    }
                });
            };

            const normalizeEmbeddedDocument = (doc) => {
                if (!doc?.body) {
                    return;
                }

                normalizeOrphanListItems(doc);
                decorateExistingLists(doc);
                injectEmbeddedStyles(doc);
            };

            const wireEmbeddedNavigation = (doc) => {
                if (!doc || doc.__topNavigationBound) {
                    return;
                }

                doc.__topNavigationBound = true;
                doc.addEventListener('click', (event) => {
                    const link = event.target.closest('a[href]');
                    if (!link) {
                        return;
                    }

                    const href = link.getAttribute('href')?.trim();
                    if (!href || href.startsWith('#') || link.hasAttribute('download')) {
                        return;
                    }

                    const target = (link.getAttribute('target') || '').toLowerCase();
                    if (target && target !== '_self') {
                        return;
                    }

                    let url;
                    try {
                        url = new URL(href, window.location.href);
                    } catch (error) {
                        return;
                    }

                    const protocol = url.protocol.toLowerCase();
                    if (protocol === 'mailto:' || protocol === 'tel:' || protocol === 'javascript:') {
                        return;
                    }

                    if (url.origin === window.location.origin) {
                        event.preventDefault();
                        window.location.href = url.href;
                    }
                });
            };

            const toggleTopBtn = () => {
                if (!topBtn) {
                    return;
                }
                const shouldShow = window.scrollY > 300;
                topBtn.style.display = shouldShow ? 'flex' : 'none';
                topBtn.style.opacity = shouldShow ? '1' : '0';
            };

            const showGlobalStatus = (status, message) => {
                if (!statusToastEl || !statusToastBody || !statusToast || !message) {
                    return;
                }

                statusToastEl.classList.remove('text-bg-success', 'text-bg-danger', 'text-bg-warning', 'text-bg-info');
                const tone = ['success', 'danger', 'warning', 'info'].includes(status) ? status : 'info';
                statusToastEl.classList.add(`text-bg-${tone}`);
                statusToastBody.textContent = message;
                statusToast.show();
            };

            if (topBtn) {
                topBtn.addEventListener('click', () => {
                    window.scrollTo({ top: 0, behavior: 'smooth' });
                });
            }

            if (!frame) {
                return;
            }

            window.addEventListener('message', (event) => {
                if (event.source !== frame.contentWindow) {
                    return;
                }

                const payload = event.data;
                if (!payload || payload.type !== 'dynamic-form-status') {
                    return;
                }

                showGlobalStatus(payload.status, payload.message);
            });

            let observer;
            let resizeObserver;
            let sizingScheduled = false;

            const scheduleApplySizing = () => {
                if (sizingScheduled) {
                    return;
                }

                sizingScheduled = true;
                window.requestAnimationFrame(() => {
                    sizingScheduled = false;
                    applySizing();
                });
            };

            const applySizing = () => {
                try {
                    const doc = frame.contentDocument || frame.contentWindow?.document;
                    if (!doc) {
                        return;
                    }
                    if (doc.documentElement) {
                        if (doc.documentElement.style.overflow !== 'hidden') {
                            doc.documentElement.style.overflow = 'hidden';
                        }
                    }
                    if (doc.body) {
                        if (doc.body.style.overflow !== 'hidden') {
                            doc.body.style.overflow = 'hidden';
                        }
                        if (doc.body.style.margin !== '0px' && doc.body.style.margin !== '0') {
                            doc.body.style.margin = '0';
                        }
                        // Remove per-template scroll buttons to avoid duplicates
                        const embeddedTopBtn = doc.getElementById('topBtn');
                        if (embeddedTopBtn) {
                            embeddedTopBtn.remove();
                        }
                    }
                    normalizeEmbeddedDocument(doc);
                    wireEmbeddedNavigation(doc);
                    const height = Math.max(
                        doc.body?.scrollHeight || 0,
                        doc.documentElement?.scrollHeight || 0
                    );
                    const nextHeight = `${height}px`;
                    if (height && frame.style.height !== nextHeight) {
                        frame.style.height = nextHeight;
                    }
                } catch (error) {
                    // Access issues shouldn't occur with srcdoc; ignore gracefully.
                }
            };

            frame.addEventListener('load', () => {
                scheduleApplySizing();
                try {
                    const doc = frame.contentDocument || frame.contentWindow?.document;
                    if (!doc || !doc.body) {
                        return;
                    }
                    observer?.disconnect();
                    resizeObserver?.disconnect();

                    observer = new MutationObserver(() => scheduleApplySizing());
                    observer.observe(doc.body, { childList: true, subtree: true, characterData: true });

                    if (window.ResizeObserver) {
                        resizeObserver = new ResizeObserver(() => scheduleApplySizing());
                        resizeObserver.observe(doc.body);
                        if (doc.documentElement) {
                            resizeObserver.observe(doc.documentElement);
                        }
                    }

                    doc.addEventListener('load', scheduleApplySizing, true);
                    doc.addEventListener('error', scheduleApplySizing, true);
                } catch (error) {
                    // Ignore observer issues
                }
            });

            window.addEventListener('resize', scheduleApplySizing);
            window.addEventListener('scroll', toggleTopBtn, { passive: true });
            toggleTopBtn();
        });
    </script>
</body>
</html>
