<?php
session_start();

// Clear any existing problematic token data
if (isset($_SESSION['csrf_token']) && !is_array($_SESSION['csrf_token'])) {
    unset($_SESSION['csrf_token']);
}
require_once dirname(__DIR__) . '/../secure-config/classes/CSRFTokenManager.php';
$csrfToken = CSRFTokenManager::getToken();
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <!-- ==================================================
       ⚡️ إعدادات أساسية
  ================================================== -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0">
  <title>Contact Us | ALASDQAA SECURITY AND SAFETY EQUIP. FIX.</title>
  
  <!-- ==================================================
       ✅ بيانات تحسين محركات البحث (SEO)
  ================================================== -->
  <meta name="description" content="ALASDQAA - Leading fire protection systems company in UAE since 2009. Expert installation, maintenance & inspection of fire alarms, sprinklers, suppression systems in Sharjah.">
  <meta name="keywords" content="fire protection UAE, fire safety systems Sharjah, fire alarm installation, fire suppression systems, emergency lighting, fire extinguishers, AMC maintenance">
  <meta name="author" content="ALASDQAA Security and Safety Equipment">
  <meta name="robots" content="index, follow">
  
  <!-- ==================================================
       ✅ توافق مع المتصفحات
  ================================================== -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  
  <!-- ==================================================
       📌 عنوان أساسي للموقع (Canonical)
  ================================================== -->
  <link rel="canonical" href="https://alasdqaa.com/en/contact.php">

  <!-- ==================================================
       ⚡️ تحسين الأداء (preload - preconnect - dns-prefetch)
  ================================================== -->
  <!-- Preload للموارد المهمة -->
  <link rel="preload" href="/css/style.css" as="style">
  <link rel="preload" href="/images/logo.png" as="image">
  <link rel="preload" href="/plugins/bootstrap/bootstrap.min.css" as="style">
  
  <!-- DNS Prefetch للموارد الخارجية -->
  <link rel="dns-prefetch" href="//cdnjs.cloudflare.com">
  <link rel="dns-prefetch" href="//fonts.googleapis.com">
  
  <!-- Preconnect لتقليل زمن الاتصال -->
  <link rel="preconnect" href="https://cdnjs.cloudflare.com">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  
  <!-- 📌 hreflang -->
  <link rel="alternate" hreflang="en" href="https://alasdqaa.com/en/">
  <link rel="alternate" hreflang="ar" href="https://alasdqaa.com/ar/">
  <link rel="alternate" hreflang="x-default" href="https://alasdqaa.com/">

  <!-- 🌎 Local SEO -->
  <meta name="geo.region" content="AE-SH">
  <meta name="geo.placename" content="Sharjah">
  <meta name="geo.position" content="25.3463;55.4209">
  <meta name="ICBM" content="25.3463, 55.4209">
  
  <!-- ==================================================
       📱 مشاركة غنية (Open Graph & Twitter Cards)
  ================================================== -->
  <!-- Open Graph -->
  <meta property="og:title" content="ALASDQAA Fire Protection Systems | UAE">
  <meta property="og:description" content="Professional fire protection services in UAE since 2009. Expert team for fire safety systems installation and maintenance.">
  <meta property="og:image" content="https://alasdqaa.com/images/og-image.jpg">
  <meta property="og:url" content="https://alasdqaa.com">
  <meta property="og:type" content="website">
  <meta property="og:site_name" content="ALASDQAA">
  
  <!-- Twitter Cards -->
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:title" content="ALASDQAA Fire Protection Systems">
  <meta name="twitter:description" content="Leading fire protection services in UAE">
  <meta name="twitter:image" content="https://alasdqaa.com/images/twitter-image.jpg">

  <!-- ==================================================
       🌟 أيقونات الموقع
  ================================================== -->
  <link rel="icon" type="image/png" href="/images/favicon.png">
  <link rel="apple-touch-icon" href="/images/apple-touch-icon.png">
  <meta name="theme-color" content="#0a1c28"> <!-- لون شريط العنوان في الجوال -->

  <!-- ==================================================
       🎨 ملفات CSS
  ================================================== -->
  <!-- Bootstrap -->
  <link rel="stylesheet" href="/plugins/bootstrap/bootstrap.min.css">
  <!-- FontAwesome -->
  <link rel="stylesheet" href="/plugins/fontawesome/css/all.min.css">
  <!-- Animation -->
  <link rel="stylesheet" href="/plugins/animate-css/animate.css">
  <!-- Slick Carousel -->
  <link rel="stylesheet" href="/plugins/slick/slick.css">
  <link rel="stylesheet" href="/plugins/slick/slick-theme.css">
  <!-- Colorbox -->
  <link rel="stylesheet" href="/plugins/colorbox/colorbox.css">
  <!-- Template styles -->
  <link rel="stylesheet" href="/css/style.css">
  
  <!-- Include reCAPTCHA script -->
  <script src="https://www.google.com/recaptcha/api.js" async defer></script>
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="/css/atlas-2026.css?v=20261121" media="all">
<link rel="stylesheet" href="/css/nova-2026.css?v=20261121-2">
</head>
<body>
<div class="body-inner" id="main-content">

  <!-- Top Bar -->
  <a class="evo-skip" href="#main-content">Skip to content</a>
<div class="evo-progress" aria-hidden="true"></div>
<div class="evo-top"><div class="container"><div class="evo-top__left"><span><i class="fas fa-map-marker-alt"></i> Sharjah, United Arab Emirates</span><span><i class="fas fa-clock"></i> Sat–Thu · 8:00 AM – 5:00 PM</span></div><div class="evo-top__right"><span class="evo-top__indicator">Safety solutions across the UAE</span><a href="tel:+97165435113" dir="ltr"><i class="fas fa-phone"></i> +971 6 543 5113</a></div></div></div>
<header class="evo-header" id="site-header">
  <div class="container evo-nav">
    <a href="/en/" class="evo-logo" aria-label="ALASDQAA"><img src="/images/logo.png" alt="ALASDQAA" width="174" height="65" decoding="async"></a>
    <nav aria-label="Main navigation"><ul class="evo-links" id="evo-navigation">
    <li><a href="/en/" >Home</a></li>
    <li><a href="/en/about.html" >About us</a></li>
    <li class="evo-has-drop"><button class="" type="button" aria-expanded="false" aria-haspopup="true" aria-controls="evo-services-menu">Services <i class="fas fa-chevron-down" aria-hidden="true"></i></button>
      <ul class="evo-drop" id="evo-services-menu"><li><a href="/en/services.html"><i class="fas fa-layer-group"></i>All services</a></li><li><a href="/en/fire-alarm.html" ><i class="fas fa-bell"></i>Fire alarm systems</a></li><li><a href="/en/fire-suppression.html" ><i class="fas fa-fire-extinguisher"></i>Fire suppression systems</a></li><li><a href="/en/fire-sprinklers.html" ><i class="fas fa-tint"></i>Fire sprinkler systems</a></li><li><a href="/en/fire-pump.html" ><i class="fas fa-tachometer-alt"></i>Fire pump systems</a></li><li><a href="/en/fire-hose-reel.html" ><i class="fas fa-water"></i>Fire hose reels</a></li><li><a href="/en/fire-extinguishers.html" ><i class="fas fa-fire-extinguisher"></i>Fire extinguishers</a></li><li><a href="/en/emergency-light.html" ><i class="fas fa-lightbulb"></i>Emergency lighting</a></li><li><a href="/en/voice-evacuation.html" ><i class="fas fa-bullhorn"></i>Voice evacuation</a></li><li><a href="/en/maintenance.html" ><i class="fas fa-tools"></i>Maintenance &amp; AMC</a></li><li><a href="/en/inspections.html" ><i class="fas fa-clipboard-check"></i>Inspections &amp; testing</a></li><li><a href="/en/drawing.html" ><i class="fas fa-ruler-combined"></i>Design &amp; approvals</a></li></ul>
    </li>
    <li><a href="/en/products.html" >Products</a></li>
    <li><a href="/en/faq.html" >FAQ</a></li>
    <li><a href="/en/contact.php" aria-current="page">Contact</a></li>
    </ul></nav>
    <div class="evo-actions"><div class="evo-lang" aria-label="Language">
    <a href="/ar/contact.php" hreflang="ar" lang="ar" >AR</a><a href="/en/contact.php" hreflang="en" lang="en" class="is-active" aria-current="true">EN</a></div>
    <button class="evo-icon-btn evo-theme-toggle" type="button" aria-pressed="false" aria-label="Toggle color theme"><i class="fas fa-moon"></i></button>
    <a class="evo-btn" href="/en/contact.php">Request a quote <i class="fas fa-external-link-alt" aria-hidden="true"></i></a>
    <button class="evo-icon-btn evo-menu-toggle" type="button" aria-label="Open navigation menu" aria-expanded="false" aria-controls="evo-navigation"><i class="fas fa-bars"></i></button>
    </div>
  </div>
</header>
<div class="evo-backdrop" aria-hidden="true"></div>
<section class="evo-page-intro" aria-labelledby="evo-page-title" style="--intro-photo:url('/images/slider-main/bg5.jpg')"><div class="container evo-page-intro__inner" data-page-number="06">
 <nav class="evo-page-intro__breadcrumbs" aria-label="Breadcrumb"><a href="/en/">Home</a><i class="fas fa-chevron-right" aria-hidden="true"></i><span aria-current="page">Contact us</span></nav>
 <h1 id="evo-page-title">Contact us</h1><p>Talk to our team about your project or service requirements.</p><i class="fas fa-envelope evo-page-intro__marker" aria-hidden="true"></i>
 </div></section>
<div class="nova-signal" aria-label="Our capabilities"><div class="nova-signal__track" aria-hidden="true"><div class="nova-signal__group"><span>FIRE SYSTEM ENGINEERING</span><span>DESIGN &amp; INSTALLATION</span><span>INSPECTION &amp; TESTING</span><span>AMC MAINTENANCE</span><span>LIFE SAFETY</span><span>INTEGRATED PROTECTION</span></div><div class="nova-signal__group"><span>FIRE SYSTEM ENGINEERING</span><span>DESIGN &amp; INSTALLATION</span><span>INSPECTION &amp; TESTING</span><span>AMC MAINTENANCE</span><span>LIFE SAFETY</span><span>INTEGRATED PROTECTION</span></div></div></div>

    <!-- END HEADER -->

  <!-- Contact Section -->
  <section id="main-container" class="main-container py-5">
    <div class="container">
      <div class="row">
        <div class="col-lg-8">
          <div class="contact-content">
            <h3 class="contact-title mb-4">We'd Love to Hear From You</h3>
            <p class="mb-4">Ready to protect your facility with professional fire safety solutions? Our expert team is here to help you with all your fire protection needs. Contact us today for a consultation and discover how we can enhance your safety systems.</p>
            
            <!-- Contact Form -->
            <form id="contact-form" class="contact-form" action="send_email.php?confirm=true" method="post" role="form">
             <input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken, ENT_QUOTES, 'UTF-8'); ?>">
              <div class="error-container"></div>
              <div class="success-message" style="display: none;">Message sent successfully.</div>
              
              <div class="row">
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="name">Full Name *</label>
                    <input class="form-control" name="name" id="name" type="text" required autocomplete="name">
                  </div>
                </div>
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="email">Email Address *</label>
                    <input class="form-control" name="email" id="email" type="email" required autocomplete="email">
                  </div>
                </div>
              </div>
              
              <div class="row">
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="phone">Phone Number *</label>
                    <input class="form-control" name="phone" id="phone" type="tel" pattern="[0-9]{8,15}" maxlength="15" required autocomplete="tel">
                  </div>
                </div>
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="subject">Subject *</label>
                    <input class="form-control" name="subject" id="subject" type="text" required autocomplete="off">
                  </div>
                </div>
              </div>
              
              <div class="form-group">
                <label for="service">Service Interest</label>
                <select class="form-control" name="service" id="service">
                  <option value="">Select a service</option>
                  <option value="fire-alarm">Fire Alarm Systems</option>
                  <option value="emergency-light">Emergency & Exit Lights</option>
                  <option value="fire-extinguishers">Fire Extinguishers</option>
                  <option value="fire-sprinklers">Fire Sprinklers</option>
                  <option value="fire-pump">Fire Pump Systems</option>
                  <option value="fire-hose-reel">Fire Hose Reel</option>
                  <option value="fire-suppression">Fire Suppression</option>
                  <option value="voice-evacuation">Voice Evacuation Systems</option>
                  <option value="maintenance">Annual Maintenance Contract</option>
                  <option value="inspections">Inspections</option>
                  <option value="drawing">Drawing</option>
                  <option value="other">Other</option>
                </select>
              </div>
              
              <div class="form-group">
                <label for="message">Message *</label>
                <textarea class="form-control" name="message" id="message" rows="6" required placeholder="Tell us about your fire safety requirements..."></textarea>
              </div>
              
              <?php
               include dirname(__DIR__) . '/../secure-config/config.php';
               $site_key = ConfigManager::get('recaptcha.site_key');
               echo '<div class="g-recaptcha" data-sitekey="' . htmlspecialchars($site_key) . '"></div>';
              ?>
              
              <div class="form-submit mt-4">
                <button class="btn btn-primary btn-lg" type="submit">
                  <i class="fas fa-paper-plane mr-2"></i>Send Message
                </button>
              </div>
            </form>
            
      <!-- Google Map -->
      <div class="row mt-5">
        <div class="col-12">
          <h3 class="section-title text-center mb-4">Find Our Location</h3>
          <div class="map-container">
            <iframe 
              src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d14428.955239855242!2d55.4222764!3d25.2961794!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3e5f5f3e9ce67d23%3A0xcddc7505af1c53f5!2sALASDQAA%20SECURITY%20AND%20SAFETY%20EQUIP.%20FIX.!5e0!3m2!1sen!2sae!4v1706990527356!5m2!1sen!2sae" 
              width="100%" 
              height="400" 
              style="border:0; border-radius: 10px;" 
              allowfullscreen="" 
              loading="lazy" 
              referrerpolicy="no-referrer-when-downgrade">
            </iframe>
          </div>
        </div>
      </div>

          </div>
        </div>

        <div class="col-lg-4">
          <div class="sidebar">
            <!-- Contact Info Widget -->
            <div class="widget widget-contact-info">
              <div class="widget-title">
                <h4>Contact Information</h4>
              </div>
              <div class="contact-info-list">
                <div class="contact-item">
                  <i class="fas fa-map-marker-alt"></i>
                  <div>
                    <h5>Visit Our Office</h5>
                    <p>Fourth Industrial St, Industrial Area 10, Sharjah, UAE</p>
                  </div>
                </div>
                <div class="contact-item">
                  <i class="fas fa-phone"></i>
                  <div>
                    <h5>Call Us</h5>
                    <p>(+971) 6 543 5113</p>
                    <p>(+971) 55 848 4363</p>
                  </div>
                </div>
                <div class="contact-item">
                  <i class="fas fa-envelope"></i>
                  <div>
                    <h5>Email Us</h5>
                    <p>info@alasdqaa.com</p>
                  </div>
                </div>
                <div class="contact-item">
                  <i class="fas fa-clock"></i>
                  <div>
                    <h5>Working Hours</h5>
                    <p>Saturday - Thursday: 8:00 AM - 5:00 PM</p>
                    <p>Friday: Closed</p>
                  </div>
                </div>
              </div>
            </div>

            <!-- Services Widget -->
            <div class="widget widget-services">
              <div class="widget-title">
                <h4>Our Services</h4>
              </div>
              <ul class="services-list">
                <li><a href="/en/services.html">Drawing</a></li>                            
                <li><a href="/en/inspections.html">Inspections</a></li>
                <li><a href="/en/maintenance.html">Annual Maintenance Contract (AMC)</a></li>                            
                <li><a href="/en/fire-alarm.html">Fire Alarm systems</a></li>
                <li><a href="/en/voice-evacuation.html">Voice Evacuation Systems</a></li>
                <li><a href="/en/emergency-light.html">Emergency Light & Exit Light</a></li>
                <li><a href="/en/fire-suppression.html">Fire Suppression</a></li>
                <li><a href="/en/fire-pump.html">Fire Pump</a></li> 
                <li><a href="/en/fire-hose-reel.html">Fire Hose Reel</a></li>
                <li><a href="/en/fire-sprinklers.html">Fire Sprinklers</a></li>
                <li><a href="/en/fire-extinguishers.html">Fire Extinguishers</a></li>
              </ul>
            </div>
          </div>
        </div>
      </div>

      <!-- Contact Features -->
      <div class="row mt-5">
        <div class="col-12">
          <h3 class="section-title text-center mb-5">Why Choose ALASDQAA?</h3>
        </div>
        
        <div class="col-md-3 col-sm-6 mb-4">
          <div class="feature-box">
            <i class="fas fa-award fa-3x text-primary mb-3"></i>
            <h5>15+ Years Experience</h5>
            <p>Serving UAE since 2009 with professional fire safety solutions</p>
          </div>
        </div>
        
        <div class="col-md-3 col-sm-6 mb-4">
          <div class="feature-box">
            <i class="fas fa-certificate fa-3x text-primary mb-3"></i>
            <h5>Certified Engineers</h5>
            <p>Licensed professionals with UAE Civil Defense certifications</p>
          </div>
        </div>
        
        <div class="col-md-3 col-sm-6 mb-4">
          <div class="feature-box">
            <i class="fas fa-clock fa-3x text-primary mb-3"></i>
            <h5>24/7 Support</h5>
            <p>Round-the-clock emergency support for critical situations</p>
          </div>
        </div>
        
        <div class="col-md-3 col-sm-6 mb-4">
          <div class="feature-box">
            <i class="fas fa-shield-alt fa-3x text-primary mb-3"></i>
            <h5>Quality Assurance</h5>
            <p>All work meets international standards and local regulations</p>
          </div>
        </div>
      </div>
    </div>
  </section>

  <!-- Call to Action -->
  <section class="call-to-action-box no-padding">
    <div class="container">
      <div class="action-style-box">
        <div class="row align-items-center">
          <div class="col-md-8 text-center text-md-left">
            <h3 class="action-title">Ready to enhance your fire safety systems?</h3>
            <p class="action-subtitle">Contact us today for a free consultation and quote</p>
          </div>
          <div class="col-md-4 text-center text-md-right mt-3 mt-md-0">
            <a class="btn btn-dark btn-lg" href="tel:+971654355113">
              <i class="fas fa-phone mr-2"></i>Call Now
            </a>
          </div>
        </div>
      </div>
    </div>
  </section>

  <!-- Footer -->
  <footer class="evo-footer" id="site-footer" role="contentinfo">
<div class="container evo-footer__top"><div><a class="evo-footer__logo" href="/en/"><img src="/images/footer-logo.png" loading="lazy" alt="ALASDQAA" width="155" height="60"></a><h3>Built for safety. Ready for life.</h3><p>Design, supply, installation, inspection and maintenance of integrated fire protection systems across the UAE. Serving customers since 2009.</p></div>
<div><h3>Quick links</h3><ul><li><a href="/en/">Home</a></li><li><a href="/en/about.html">About us</a></li><li><a href="/en/services.html">Our services</a></li><li><a href="/en/products.html">Products</a></li><li><a href="/en/faq.html">Frequently asked questions</a></li><li><a href="/en/contact.php">Contact us</a></li></ul></div>
<div><h3>Safety solutions</h3><ul><li><a href="/en/fire-alarm.html">Fire alarm systems</a></li><li><a href="/en/fire-suppression.html">Fire suppression systems</a></li><li><a href="/en/fire-sprinklers.html">Fire sprinkler systems</a></li><li><a href="/en/fire-pump.html">Fire pump systems</a></li><li><a href="/en/maintenance.html">Maintenance &amp; AMC</a></li><li><a href="/en/inspections.html">Inspections &amp; testing</a></li></ul></div>
<div><h3>Get in touch</h3><ul class="evo-footer__contact"><li><i class="fas fa-map-marker-alt"></i><span>Sharjah, United Arab Emirates<p>Fourth Industrial St, Industrial Area 10</p></span></li><li><i class="fas fa-phone"></i><span dir="ltr"><a href="tel:+97165435113">+971 6 543 5113</a><br><a href="tel:+971558484363">+971 55 848 4363</a></span></li><li><i class="fas fa-envelope"></i><a href="mailto:info@alasdqaa.com">info@alasdqaa.com</a></li><li><i class="fas fa-clock"></i>Sat–Thu · 8:00 AM – 5:00 PM</li></ul></div></div>
<div class="evo-footer__bottom"><div class="container"><p>© <span data-evo-year>2026</span> ALASDQAA. All rights reserved.</p><div><a href="/ar/" hreflang="ar">العربية</a><a href="/en/" hreflang="en">English</a></div></div></div>
</footer>
<div class="evo-float-actions"><a class="evo-float-call" href="tel:+97165435113" aria-label="Call us" title="Call us"><i class="fas fa-phone"></i></a><button type="button" class="evo-to-top" aria-label="Back to top" title="Back to top"><i class="fas fa-chevron-up"></i></button></div><!-- Footer end -->
    <!-- END FOOTER -->

  <!-- initialize jQuery Library -->
  <script src="/plugins/jQuery/jquery.min.js" defer></script>
  <!-- Bootstrap -->
  <script src="/plugins/bootstrap/bootstrap.min.js" defer></script>
  <!-- Slick Carousel -->
  <script src="/plugins/slick/slick.min.js" defer></script>
  <script src="/plugins/slick/slick-animation.min.js" defer></script>
  <!-- Color box -->
  <script src="/plugins/colorbox/jquery.colorbox.js" defer></script>
  <!-- shuffle -->
  <script src="/plugins/shuffle/shuffle.min.js" defer></script>
  <!-- Google Map Plugin-->
  <script src="/plugins/google-map/map.js" defer></script>
  <!-- Template custom -->
  <script src="/js/script.js" defer></script>
  
</div>

<script>
// Contact Form Handler
document.addEventListener('DOMContentLoaded', function() {
    const contactForm = document.getElementById('contact-form');
    const errorContainer = document.querySelector('.error-container');
    const successMessage = document.querySelector('.success-message');
    const submitButton = contactForm.querySelector('button[type="submit"]');
    const originalButtonText = submitButton.innerHTML;

    // إضافة حماية إضافية للنموذج
    contactForm.addEventListener('submit', function(e) {
        e.preventDefault();
        
        // Clear previous messages
        errorContainer.innerHTML = '';
        errorContainer.style.display = 'none';
        successMessage.style.display = 'none';
        
        // التحقق من الحقول المطلوبة
        const requiredFields = ['name', 'email', 'phone', 'subject', 'message'];
        let hasErrors = false;
        
        requiredFields.forEach(field => {
            const input = document.getElementById(field);
            if (!input.value.trim()) {
                input.style.borderColor = '#dc3545';
                hasErrors = true;
            } else {
                input.style.borderColor = '#28a745';
            }
        });
        
        // التحقق من البريد الإلكتروني
        const emailInput = document.getElementById('email');
        const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
        if (emailInput.value.trim() && !emailRegex.test(emailInput.value)) {
            emailInput.style.borderColor = '#dc3545';
            hasErrors = true;
        }
        
        // التحقق من رقم الهاتف: فقط أرقام وطول من 8 إلى 15 مثلاً
        const phoneInput = document.getElementById('phone');
        const phoneRegex = /^[0-9]{8,15}$/;
        if (phoneInput.value.trim() && !phoneRegex.test(phoneInput.value.trim())) {
            phoneInput.style.borderColor = '#dc3545';
            hasErrors = true;
        }
        
        // التحقق من reCAPTCHA
        if (typeof grecaptcha !== 'undefined') {
            const recaptchaResponse = grecaptcha.getResponse();
            if (!recaptchaResponse) {
                showError('Please complete the reCAPTCHA verification.');
                return;
            }
        }
        
        if (hasErrors) {
            showError('Please fill in all required fields correctly.');
            return;
        }
        
        // Show loading state
        submitButton.disabled = true;
        submitButton.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i>Sending...';
        
        // Prepare form data
        const formData = new FormData(contactForm);
        
        // إضافة معلومات إضافية للأمان
        formData.append('timestamp', Date.now());
        formData.append('timezone', Intl.DateTimeFormat().resolvedOptions().timeZone);
        
        // Send AJAX request
        fetch('send_email.php', {
            method: 'POST',
            body: formData,
            headers: {
                'X-Requested-With': 'XMLHttpRequest'
            }
        })
        .then(response => {
            if (!response.ok) {
                throw new Error('Network response was not ok');
            }
            return response.json();
        })
        .then(data => {
            if (data.success) {
                showSuccess(data.message);
                contactForm.reset();
                resetFormStyles();
                
                // Reset reCAPTCHA
                if (typeof grecaptcha !== 'undefined') {
                    grecaptcha.reset();
                }
                
                // Auto-hide success message after 10 seconds
                setTimeout(() => {
                    successMessage.style.display = 'none';
                }, 10000);
                
            } else {
                showError(data.message);
                
                // Reset reCAPTCHA
                if (typeof grecaptcha !== 'undefined') {
                    grecaptcha.reset();
                }
            }
        })
        .catch(error => {
            console.error('Error:', error);
            showError('An error occurred. Please try again later.');
            
            // Reset reCAPTCHA
            if (typeof grecaptcha !== 'undefined') {
                grecaptcha.reset();
            }
        })
        .finally(() => {
            // Reset button state
            submitButton.disabled = false;
            submitButton.innerHTML = originalButtonText;
        });
    });
    
    // دوال مساعدة
    function showError(message) {
        errorContainer.innerHTML = '<i class="fas fa-exclamation-triangle mr-2"></i>' + message;
        errorContainer.style.display = 'block';
        errorContainer.style.color = '#721c24';
        errorContainer.style.backgroundColor = '#f8d7da';
        errorContainer.style.border = '1px solid #f5c6cb';
        errorContainer.style.borderRadius = '4px';
        errorContainer.style.padding = '10px 15px';
        errorContainer.style.marginBottom = '20px';
        
        errorContainer.scrollIntoView({ behavior: 'smooth', block: 'center' });
    }
    
    function showSuccess(message) {
        successMessage.innerHTML = '<i class="fas fa-check-circle mr-2"></i>' + message;
        successMessage.style.display = 'block';
        successMessage.style.color = '#155724';
        successMessage.style.backgroundColor = '#d4edda';
        successMessage.style.border = '1px solid #c3e6cb';
        successMessage.style.borderRadius = '4px';
        successMessage.style.padding = '10px 15px';
        successMessage.style.marginBottom = '20px';
        
        successMessage.scrollIntoView({ behavior: 'smooth', block: 'center' });
    }
    
    function resetFormStyles() {
        const inputs = contactForm.querySelectorAll('input, textarea, select');
        inputs.forEach(input => {
            input.style.borderColor = '';
        });
    }
    
    // التحقق من الحقول في الوقت الفعلي
    const inputs = contactForm.querySelectorAll('input[required], textarea[required]');
    inputs.forEach(input => {
        input.addEventListener('blur', function() {
            if (this.value.trim() === '') {
                this.style.borderColor = '#dc3545';
            } else {
                this.style.borderColor = '#28a745';
            }
        });
        
        input.addEventListener('input', function() {
            if (this.value.trim() !== '') {
                this.style.borderColor = '#28a745';
            }
        });
    });
    
    // التحقق من البريد الإلكتروني
    const emailField = document.getElementById('email');
    if (emailField) {
        emailField.addEventListener('blur', function() {
            const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
            if (this.value.trim() !== '' && !emailRegex.test(this.value)) {
                this.style.borderColor = '#dc3545';
            } else if (this.value.trim() !== '') {
                this.style.borderColor = '#28a745';
            }
        });
    }
    
    // منع إرسال النموذج عند الضغط على Enter في الحقول
    contactForm.addEventListener('keypress', function(e) {
        if (e.key === 'Enter' && e.target.tagName !== 'TEXTAREA') {
            e.preventDefault();
        }
    });
});

// حماية إضافية ضد البوتات
(function() {
    // إضافة حقل خفي للكشف عن البوتات
    const form = document.getElementById('contact-form');
    if (form) {
        const honeypot = document.createElement('input');
        honeypot.type = 'text';
        honeypot.name = 'website';
        honeypot.style.display = 'none';
        honeypot.setAttribute('tabindex', '-1');
        honeypot.setAttribute('autocomplete', 'off');
        form.appendChild(honeypot);
    }
})();

// تحديث التوكن كل 45 دقيقة
setInterval(function() {
    fetch('refresh_csrf_token.php', {
        method: 'POST',
        headers: {
            'X-Requested-With': 'XMLHttpRequest'
        }
    })
    .then(response => response.json())
    .then(data => {
        if (data.success) {
            document.querySelector('input[name="csrf_token"]').value = data.token;
        }
    });
}, 45 * 60 * 1000);

// تأكيد وجود التوكن قبل الإرسال
document.getElementById('contact-form').addEventListener('submit', function(e) {
    const token = document.querySelector('input[name="csrf_token"]').value;
    if (!token) {
        e.preventDefault();
        alert('Security token expired. Please refresh the page and try again.');
    }
});
</script>

<script src="/js/atlas-2026.js?v=20261121" defer></script>
<script src="/js/nova-2026.js?v=20261121-2" defer></script>
</body>
</html>