<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Invitation to {{ invitation.company.name }}</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background-color: white;
            border-radius: 8px;
            padding: 40px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        .header {
            text-align: center;
            margin-bottom: 30px;
        }
        .logo {
            font-size: 48px;
            margin-bottom: 10px;
        }
        h1 {
            color: #667eea;
            font-size: 24px;
            margin: 0;
        }
        .content {
            margin-bottom: 30px;
        }
        .invitation-box {
            background-color: #f8f9fa;
            border-left: 4px solid #667eea;
            padding: 20px;
            margin: 20px 0;
        }
        .cta-button {
            display: inline-block;
            padding: 14px 30px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            text-decoration: none;
            border-radius: 8px;
            font-weight: 600;
            margin: 20px 0;
        }
        .details {
            background-color: #f8f9fa;
            padding: 20px;
            border-radius: 8px;
            margin: 20px 0;
        }
        .details-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
        }
        .details-label {
            font-weight: 600;
            color: #6b7280;
        }
        .footer {
            text-align: center;
            color: #6b7280;
            font-size: 14px;
            margin-top: 40px;
            padding-top: 20px;
            border-top: 1px solid #e5e7eb;
        }
        .custom-message {
            background-color: #ede9fe;
            border-left: 4px solid #5b21b6;
            padding: 15px;
            margin: 20px 0;
            font-style: italic;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="logo">📨</div>
            <h1>You're Invited to Join {{ invitation.company.name }}!</h1>
        </div>
        
        <div class="content">
            <p>Hello,</p>
            
            <p><strong>{{ sender.username }}</strong> has invited you to join <strong>{{ invitation.company.name }}</strong> on {{ g.branding.app_name }}.</p>
            
            {% if custom_message %}
            <div class="custom-message">
                <strong>Personal message from {{ sender.username }}:</strong><br>
                {{ custom_message }}
            </div>
            {% endif %}
            
            <div class="invitation-box">
                <h3 style="margin-top: 0;">Your Invitation Details:</h3>
                <div class="details-item">
                    <span class="details-label">Company:</span>
                    <span>{{ invitation.company.name }}</span>
                </div>
                <div class="details-item">
                    <span class="details-label">Role:</span>
                    <span>{{ invitation.role }}</span>
                </div>
                <div class="details-item">
                    <span class="details-label">Invited by:</span>
                    <span>{{ sender.username }}</span>
                </div>
                <div class="details-item">
                    <span class="details-label">Expires:</span>
                    <span>{{ invitation.expires_at.strftime('%B %d, %Y') }}</span>
                </div>
            </div>
            
            <div style="text-align: center;">
                <a href="{{ invitation_url }}" class="cta-button">Accept Invitation</a>
                <p style="font-size: 14px; color: #6b7280;">
                    Or copy and paste this link:<br>
                    <code style="background: #f3f4f6; padding: 5px; border-radius: 4px;">{{ invitation_url }}</code>
                </p>
            </div>
            
            <div class="details">
                <h3 style="margin-top: 0;">What happens next?</h3>
                <ul style="margin: 0; padding-left: 20px;">
                    <li>Click the link above to accept the invitation</li>
                    <li>Create your account with a username and password</li>
                    <li>You'll automatically join {{ invitation.company.name }}</li>
                    <li>Start tracking your time and collaborating with your team!</li>
                </ul>
            </div>
        </div>
        
        <div class="footer">
            <p>This invitation will expire on <strong>{{ invitation.expires_at.strftime('%B %d, %Y') }}</strong>.</p>
            <p>If you didn't expect this invitation, you can safely ignore this email.</p>
            <p>&copy; {{ g.branding.app_name }} - Time Tracking Made Simple</p>
        </div>
    </div>
</body>
</html>