<?php
require "vendor/autoload.php";
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

if($_SERVER['REQUEST_METHOD'] === 'POST'){
    $name = $_POST['name'] ?? '';
  
    $email = $_POST['email'] ?? '';
    $phone = $_POST['phone'] ?? '';
    $message = $_POST['message'] ?? '';

    $mailer = new PHPMailer(true);
    try {
     $mailer->isSMTP();
        $mailer->Host = 'mail.alpha.atomlogic.in';
        $mailer->SMTPAuth = true;
        $mailer->Username = 'alphauser@alpha.atomlogic.in';
        $mailer->Password = ';?-)HC}tem,]dL2f';
        $mailer->SMTPSecure = 'ssl';
        $mailer->Port = 465;

          $mailer->setFrom('alphauser@alpha.atomlogic.in', 'Mind-Relax');
        $mailer->addAddress('info@mindrelax.com', 'Mind-Relax');
        $mailer->isHTML(true);
        $mailer->Subject = 'New Enquiry Request';
        $mailer->Body = "<p> Name: $name</p> <p>Email: $email</p><p>Phone: $phone</p><p>Message: $message</p>";

        $mailer->send();

    echo '<div class="outer" id="outer" style="
    /* Full screen overlay */
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
    background: rgba(0, 0, 0, 0.8); /* Slightly darker overlay for emphasis */
    display: flex; justify-content: center; align-items: center; 
    z-index: 9999; 
    font-family: Arial, sans-serif;
    overflow-y: auto; /* Important for very small screens/keyboards */
    padding: 20px 0;
    box-sizing: border-box;">
    
    <div class="popup_success" style="
        /* Popup Container */
        background: #ffffff; 
        padding: 50px 30px; /* Increased Padding for bigger visual box */
        border-radius: 16px; 
        text-align: center; 
        width: 95%; /* Increased width percentage for better use of mobile screen */
        max-width: 450px; /* Slightly increased max width for larger phones/tablets */
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35); /* More pronounced shadow */
        
        /* Subtle Entrance Animation */
        transform: scale(0.95);
        opacity: 0;
        animation: fadeIn 0.5s forwards;
    ">
        
        <div style="margin-bottom: 25px;">
            <span style="
                display: inline-block;
                background: #1747a6;
                color: #fff;
                border-radius: 50%;
                width: 70px; height: 70px; /* Enlarged Icon */
                line-height: 70px; 
                font-size: 36px; /* Enlarged Icon Font */
                margin-bottom: 15px;
            ">
                &#10003;
            </span>
            <h3 style="color: #333; font-size: 28px; /* Larger Heading */
                       margin-top: 0; margin-bottom: 10px; font-weight: 700;">
                Message Sent!
            </h3>
        </div>
        
        <p style="color: #555; margin-bottom: 35px; line-height: 1.6; /* Increased line-height for better flow */
                  font-size: 17px; /* Larger Body Text */">
            Thank you, **' . htmlspecialchars($name) . '**, for reaching out! Your enquiry request has been sent successfully. We will get back to you shortly.
        </p>

        <div style="display: flex; flex-direction: column; gap: 12px;"> 
            
            <a href="index" class="ok_btn" style="
                /* Primary Action Button */
                display: block; 
                background: #1747a6; 
                color: #fff; 
                padding: 14px 25px; /* Bigger button padding */
                border-radius: 10px; /* Slightly more rounded */
                text-decoration: none;
                font-size: 17px; /* Larger button text */
                font-weight: 700;
                transition: background 0.3s;
            ">
                Go to Homepage
            </a>

       
            
        </div>
    </div>
    
    <style>
        @keyframes fadeIn {
            to {
                opacity: 1;
                transform: scale(1);
            }
        }
    </style>
</div>';

    } catch(Exception $e){
        echo "Error: Email sending failed: ".$mailer->ErrorInfo;
    }
}
?>
