import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

# --- ✉️ إعداد معلومات SMTP ---
smtp_server = "mail.thesecuremail.net"
smtp_port = 465
smtp_user = "Mostafa.Rizk@future-group.com"
smtp_password = "NnyzxrO412#"

# --- ✉️ إعداد الإيميل ---
msg = MIMEMultipart()
msg["From"] = smtp_user
msg["To"] = "quality@future-group.com"
msg["Subject"] = "✅ Script Completed - Quality Logs Available"

# نص الرسالة
html_body = """
<html>
<head>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            color: #333;
        }
        .container {
            width: 80%;
            margin: auto;
            padding: 20px;
        }
        .header {
            background-color: #28a745;
            color: white;
            padding: 15px;
            text-align: center;
            font-size: 22px;
            font-weight: bold;
            border-radius: 5px 5px 0 0;
        }
        .content {
            padding: 25px;
            background-color: #f9f9f9;
            border-radius: 0 0 5px 5px;
        }
        .success-icon {
            font-size: 48px;
            text-align: center;
            margin: 20px 0;
        }
        .button {
            display: inline-block;
            padding: 12px 30px;
            background-color: #0073e6;
            color: white;
            text-decoration: none;
            border-radius: 5px;
            font-weight: bold;
            margin: 20px 0;
        }
        .button:hover {
            background-color: #005bb5;
        }
        .info-box {
            background-color: #e7f3ff;
            border-left: 4px solid #0073e6;
            padding: 15px;
            margin: 15px 0;
        }
        .footer {
            margin-top: 20px;
            padding: 10px;
            background-color: #28a745;
            color: white;
            text-align: center;
            font-size: 14px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">✅ Script Execution Completed</div>
        <div class="content">
            <div class="success-icon">✅</div>
            <p>Hello Quality Team 👋,</p>
            <p>The automated script has completed successfully!</p>

            <div class="info-box">
                <strong>📊 You can now view the logs:</strong><br>
                <p style="margin-top: 10px;">
                    <a href="https://quality.kalamcxapp.site/zoho_quality/viewer.php" class="button">
                        🔍 View Quality Logs
                    </a>
                </p>
            </div>

            <p>Click the button above to access the quality logs viewer and review the results.</p>
            <p class="note" style="color: #666; font-size: 12px; margin-top: 20px;">
                ⚠️ This is an automated message – please do not reply.
            </p>
        </div>
        <div class="footer">Best Regards,<br>Automated Mail</div>
    </div>
</body>
</html>
"""

msg.attach(MIMEText(html_body, "html"))


try:
    server = smtplib.SMTP_SSL(smtp_server, smtp_port)
    server.login(smtp_user, smtp_password)
    server.sendmail(smtp_user, ["quality@future-group.com"], msg.as_string())
    server.quit()
    print("✅ Quality Team.")
except Exception as e:
    print(f"❌ Not: {e}")
