export const ADMISSION_REQUEST_TEMPLATE = ({
  itemType,
  universityName,
  itemName,
  itemLocation,
  userInfo,
  isFallback = false,
  originalUniversityName,
  fallbackReason
}: {
  itemType: string;
  universityName: string;
  itemName: string;
  itemLocation: string;
  userInfo: { name: string; phone: string; email: string };
  isFallback?: boolean;
  originalUniversityName?: string;
  fallbackReason?: string;
}) => {
  return `
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>New Admission Request</title>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
        :root {
            --primary: #0B6D76;
            --secondary: #0f766e;
            --accent: #f59e0b;
            --dark: #1e293b;
            --light: #f8fafc;
        }
        body {
            font-family: 'Inter', sans-serif;
            background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
            margin: 0;
            padding: 20px;
            line-height: 1.6;
        }
        .email-container {
            max-width: 600px;
            margin: 0 auto;
            background: white;
            border-radius: 16px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        .email-header {
            padding: 30px 0;
            text-align: center;
            background: ${isFallback ? 'linear-gradient(135deg, #f59e0b 0%, #d97706 100%)' : 'linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%)'};
        }
        .logo-container {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
        }
        .logo-image {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            object-fit: contain;
        }
        .logo-text {
            font-size: 20px;
            font-weight: 700;
            background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-fill-color: transparent;
        }
        .email-body {
            padding: 30px;
            color: var(--dark);
        }
        h1 {
            color: ${isFallback ? '#d97706' : 'var(--primary)'};
            font-size: 24px;
            margin-bottom: 16px;
            font-weight: 700;
            line-height: 1.2;
        }
        p {
            font-size: 14px;
            line-height: 1.6;
            color: #475569;
            margin-bottom: 16px;
        }
        .request-details {
            background: #f0fdf4;
            border-left: 4px solid var(--primary);
            padding: 16px;
            margin: 16px 0;
            border-radius: 8px;
        }
        .fallback-warning {
            background: #fef3c7;
            border-left: 4px solid #f59e0b;
            padding: 16px;
            margin: 16px 0;
            border-radius: 8px;
        }
        .student-info {
            background: #eff6ff;
            border-left: 4px solid var(--secondary);
            padding: 16px;
            margin: 16px 0;
            border-radius: 8px;
        }
        .info-grid {
            display: grid;
            gap: 8px;
        }
        .info-item {
            display: flex;
            justify-content: space-between;
            padding: 4px 0;
            border-bottom: 1px solid rgba(0,0,0,0.05);
        }
        .info-label {
            font-weight: 600;
            color: #374151;
        }
        .info-value {
            color: #6b7280;
        }
        .email-footer {
            background: var(--dark);
            padding: 16px;
            text-align: center;
            font-size: 12px;
            color: rgba(255, 255, 255, 0.8);
        }
        @media (max-width: 640px) {
            .email-body { padding: 20px; }
            h1 { font-size: 20px; }
            .logo-container {
                flex-direction: column;
                gap: 8px;
            }
            .logo-text {
                font-size: 18px;
            }
        }
    </style>
</head>
<body>
    <div class="email-container">
        <div class="email-header">
            <div class="logo-container">
                <!-- Logo Image -->
                <img src="https://universitiespage.com/assets/logo.png" class="logo-image" alt="UniversitiesPage Logo">
                
                <!-- Site Name -->
                <div class="logo-text">
                    Universities Page
                </div>
            </div>
        </div>
        <div class="email-body">
            ${isFallback ? `
            <div class="fallback-warning">
                <h3 style="color: #d97706; margin-top: 0; font-size: 16px;">⚠️ IMPORTANT: ${fallbackReason ? 'Email Delivery Failed' : 'University Email Not Found'}</h3>
                <p style="font-size: 13px; margin-bottom: 8px;">
                    ${fallbackReason 
                        ? `This admission request could not be sent to the university directly: ${fallbackReason}`
                        : 'This admission request could not be sent to the university directly because their email address was not found in our system.'
                    }
                </p>
                <p style="font-size: 13px; margin: 0;"><strong>Original University:</strong> ${originalUniversityName || universityName}</p>
            </div>
            ` : ''}
            
            <h1>🎓 New Admission Request</h1>
            <p>Dear ${isFallback ? 'Support Team' : 'Admissions Team'},</p>
            <p>A prospective student has submitted an admission request ${isFallback ? 'for the institution above' : 'for your institution'} through Universities Page.</p>
            
            <div class="request-details">
                <h3 style="color: var(--primary); margin-top: 0; font-size: 16px;">Request Details:</h3>
                <div class="info-grid">
                    <div class="info-item">
                        <span class="info-label">Institution:</span>
                        <span class="info-value">${universityName}</span>
                    </div>
                    <div class="info-item">
                        <span class="info-label">Request Type:</span>
                        <span class="info-value">Admission Information</span>
                    </div>
                    ${itemLocation ? `
                    <div class="info-item">
                        <span class="info-label">Location:</span>
                        <span class="info-value">${itemLocation}</span>
                    </div>
                    ` : ''}
                    <div class="info-item">
                        <span class="info-label">Request Date:</span>
                        <span class="info-value">${new Date().toLocaleDateString('en-US', { 
                            year: 'numeric', 
                            month: 'long', 
                            day: 'numeric',
                            timeZone: 'Asia/Karachi'
                        })}</span>
                    </div>
                </div>
            </div>

            <div class="student-info">
                <h3 style="color: var(--secondary); margin-top: 0; font-size: 16px;">Student Information:</h3>
                <div class="info-grid">
                    <div class="info-item">
                        <span class="info-label">Name:</span>
                        <span class="info-value">${userInfo.name}</span>
                    </div>
                    <div class="info-item">
                        <span class="info-label">Phone:</span>
                        <span class="info-value">${userInfo.phone}</span>
                    </div>
                    <div class="info-item">
                        <span class="info-label">Email:</span>
                        <span class="info-value">${userInfo.email}</span>
                    </div>
                </div>
            </div>

            ${isFallback ? `
            <div class="fallback-warning">
                <h4 style="color: #d97706; margin-top: 0; font-size: 14px;">Action Required:</h4>
                <p style="font-size: 13px; margin: 0;">Please manually forward this request to the appropriate university or contact the student to provide alternative contact information.</p>
            </div>
            ` : `
            <p><strong>Next Steps:</strong></p>
            <ul style="margin: 10px 0; padding-left: 20px; font-size: 13px;">
                <li>Please contact the student within 24-48 hours</li>
                <li>Provide detailed information about admission requirements</li>
                <li>Share application deadlines and procedures</li>
                <li>Offer to schedule a consultation if needed</li>
            </ul>
            `}

            <p style="margin-top: 20px; font-size: 13px;">This request was generated through our platform. Please ensure timely follow-up to provide excellent student service.</p>
            
            <p style="margin-top: 24px; font-size: 13px;">Best Regards,<br>
                <strong>Universities Page Team</strong><br>
                <a href="mailto:info@universitiespage.com" style="color: var(--primary); text-decoration: none;">info@universitiespage.com</a><br>
                <a href="https://www.universitiespage.com" style="color: var(--primary); text-decoration: none;">www.universitiespage.com</a>
            </p>
        </div>
        <div class="email-footer">
            <p style="margin: 0;">© ${new Date().getFullYear()} Universities Page. All rights reserved.</p>
        </div>
    </div>
</body>
</html>`;
};