<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Payment Successful</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Roboto', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #333;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }
        .payment-container {
            text-align: center;
            background-color: #fff;
            padding: 50px;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            max-width: 500px;
            width: 90%;
            position: relative;
        }
        .success-icon {
            font-size: 5rem;
            color: #00b894;
            margin-bottom: 30px;
            animation: checkmarkAnimation 1.5s ease-out;
        }
        
        @keyframes checkmarkAnimation {
            0% {
                transform: scale(0) rotate(-180deg);
                opacity: 0;
            }
            50% {
                transform: scale(1.2) rotate(0deg);
                opacity: 1;
            }
            70% {
                transform: scale(0.9) rotate(0deg);
            }
            100% {
                transform: scale(1) rotate(0deg);
                opacity: 1;
            }
        }
        
        .payment-title {
            font-size: 2.5rem;
            margin-bottom: 20px;
            color: #333;
            font-weight: 700;
        }
        
        .payment-message {
            font-size: 1.2rem;
            line-height: 1.6;
            margin-bottom: 30px;
            color: #666;
            font-weight: 400;
        }
        
        .advance-notice {
            background-color: #e3f2fd;
            padding: 15px;
            border-radius: 8px;
            margin-top: 20px;
            border-left: 4px solid #2196f3;
        }
        
        .contact-section {
            background-color: #f8f9fa;
            padding: 20px;
            border-radius: 10px;
            margin-top: 30px;
            text-align: left;
        }
        
        .contact-section h3 {
            margin: 0 0 10px 0;
            color: #333;
            font-size: 1.3rem;
            font-weight: 600;
        }
        
        .contact-section > p {
            margin: 0 0 15px 0;
            color: #666;
            font-size: 0.95rem;
        }
        
        .contact-details {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        
        .contact-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 5px 0;
            border-bottom: 1px solid #e9ecef;
        }
        
        .contact-row:last-child {
            border-bottom: none;
        }
        
        .contact-label {
            font-weight: 500;
            color: #495057;
            flex-shrink: 0;
        }
        
        .contact-value {
            font-weight: 400;
            color: #6c757d;
            text-align: right;
        }
        
        .contact-value a {
            color: #007bff;
            text-decoration: none;
        }
        
        .contact-value a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="payment-container">
        <div class="success-icon">✓</div>
        {% if reference_doc %}
            <h1 class="payment-title">
                {% if company_doc and company_doc.company_name %}
                    {{ company_doc.company_name }}
                {% else %}
                    Payment Received
                {% endif %}
            </h1>
            {% if reference_doc.doctype == "Sales Order" %}
                <p class="payment-message">
                    {% if reference_doc.customer %}
                        Thank you {{ reference_doc.customer }} for your advance payment!
                    {% else %}
                        Thank you for your advance payment!
                    {% endif %}
                </p>
                <div class="advance-notice">
                    <p>The remaining balance will be invoiced once the project is complete.</p>
                </div>
            {% else %}
                <p class="payment-message">
                    {% if reference_doc.customer %}
                        Thank you {{ reference_doc.customer }} for your payment!
                    {% else %}
                        Thank you for your payment!
                    {% endif %}
                </p>
            {% endif %}

            {% if company_doc %}
            <div class="contact-section">
                <h3>Have Questions?</h3>
                <p>We're here to help! Contact us if you need assistance.</p>
                <div class="contact-details">
                    {% if company_doc.company_name %}
                        <div class="contact-row">
                            <span class="contact-label">Company:</span>
                            <span class="contact-value">{{ company_doc.company_name }}</span>
                        </div>
                    {% endif %}
                    
                    {% if company_doc.phone_no %}
                        <div class="contact-row">
                            <span class="contact-label">Phone:</span>
                            <span class="contact-value">{{ company_doc.phone_no }}</span>
                        </div>
                    {% endif %}
                    
                    {% if company_doc.email %}
                        <div class="contact-row">
                            <span class="contact-label">Email:</span>
                            <span class="contact-value"><a href="mailto:{{ company_doc.email }}">{{ company_doc.email }}</a></span>
                        </div>
                    {% endif %}
                    
                    {% if company_doc.website %}
                        <div class="contact-row">
                            <span class="contact-label">Website:</span>
                            <span class="contact-value"><a href="{{ company_doc.website }}" target="_blank">{{ company_doc.website }}</a></span>
                        </div>
                    {% endif %}
                </div>
            </div>
            {% endif %}
        {% else %}
            <h1 class="payment-title">Payment Received</h1>
            <p class="payment-message">Thank you for your payment!</p>
        {% endif %}
    </div>
</body>
</html>
