<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%
  // SEO defaults
  const _host = typeof currentHost !== 'undefined' ? currentHost : (typeof mainDomain !== 'undefined' ? mainDomain : 'crm.sahm-ye.com');
  const _siteName = typeof siteName !== 'undefined' ? siteName : 'Artal CRM';
  const _description = typeof description !== 'undefined' ? description : 'نظام CRM احترافي لإدارة عملاء شركتك ومتابعة فريق المبيعات';
  const _url = typeof pageUrl !== 'undefined' ? pageUrl : ('https://' + _host);
  const _ogImage = typeof ogImage !== 'undefined' ? ogImage : ('https://' + _host + '/images/og-default.png');
  const _pageTitle = typeof pageTitle !== 'undefined' ? pageTitle : 'الرئيسية';
  const _fullTitle = _pageTitle.includes(_siteName) ? _pageTitle : (_pageTitle + ' — ' + _siteName);
%>
<title><%= _fullTitle %></title>
<meta name="description" content="<%= _description %>">
<link rel="canonical" href="<%= _url %>">
<meta name="robots" content="index, follow">
<meta name="language" content="Arabic">
<meta name="theme-color" content="#1a3c6e">

<!-- Open Graph -->
<meta property="og:type" content="website">
<meta property="og:title" content="<%= _fullTitle %>">
<meta property="og:description" content="<%= _description %>">
<meta property="og:url" content="<%= _url %>">
<meta property="og:image" content="<%= _ogImage %>">
<meta property="og:locale" content="ar_SA">
<meta property="og:site_name" content="<%= _siteName %>">

<!-- Twitter Cards -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="<%= _fullTitle %>">
<meta name="twitter:description" content="<%= _description %>">
<meta name="twitter:image" content="<%= _ogImage %>">

<!-- PWA -->
<link rel="manifest" href="/manifest.json">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="<%= _siteName %>">

<!-- Icons -->
<link rel="icon" type="image/png" href="/images/icon.png">
<link rel="apple-touch-icon" href="/images/icon.png">

<!-- Schema.org JSON-LD -->
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "<%= _siteName %>",
  "url": "https://<%= _host %>",
  "logo": "<%= _ogImage %>",
  "description": "<%= _description %>",
  "address": { "@type": "PostalAddress", "addressCountry": "SA" }
}
</script>
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "SoftwareApplication",
  "name": "<%= _siteName %>",
  "applicationCategory": "BusinessApplication",
  "operatingSystem": "Web Browser",
  "url": "https://<%= _host %>",
  "inLanguage": "ar",
  "offers": { "@type": "Offer", "price": "0", "priceCurrency": "SAR", "description": "فترة تجريبية مجانية" }
}
</script>

<!-- Fonts (preconnect for performance) -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Symbols+Rounded" rel="stylesheet">

<!-- Analytics (يتفعّل تلقائياً عند ضبط env vars) -->
<% if (typeof gaTrackingId !== 'undefined' && gaTrackingId) { %>
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= gaTrackingId %>"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', '<%= gaTrackingId %>', { anonymize_ip: true });
</script>
<% } %>
<% if (typeof clarityId !== 'undefined' && clarityId) { %>
<script>
  (function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
  t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
  y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window,document,"clarity","script","<%= clarityId %>");
</script>
<% } %>
<style>
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; color: #1a1a2e; line-height: 1.7; }
  body { background: #fafbfc; min-height: 100vh; display: flex; flex-direction: column; }
  .nav { position: sticky; top: 0; background: rgba(255,255,255,0.92); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(0,0,0,0.06); z-index: 100; }
  .nav-inner { max-width: 1200px; margin: 0 auto; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; }
  .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; color: #1a3c6e; text-decoration: none; }
  .logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, #4f6bed, #1a3c6e); border-radius: 9px; display: flex; align-items: center; justify-content: center; color: white; }
  .nav-actions { display: flex; gap: 10px; align-items: center; }
  .btn { padding: 10px 20px; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; border: none; transition: all 0.2s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; font-family: inherit; }
  .btn-primary { background: linear-gradient(135deg, #4f6bed, #1a3c6e); color: white; box-shadow: 0 3px 10px rgba(79,107,237,0.3); }
  .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(79,107,237,0.45); }
  .btn-ghost { background: transparent; color: #1a3c6e; }
  .btn-ghost:hover { background: #f0f3f9; }
  .container { flex: 1; max-width: 880px; margin: 0 auto; padding: 50px 24px 30px; width: 100%; }
  .page-header { text-align: center; margin-bottom: 40px; }
  .page-header h1 { font-size: 36px; color: #0f1a30; margin-bottom: 8px; letter-spacing: -0.5px; }
  .page-header p { color: #64748b; font-size: 16px; }
  .last-updated { display: inline-block; margin-top: 12px; padding: 4px 12px; background: #f1f5f9; border-radius: 100px; font-size: 13px; color: #475569; }
  .content { background: white; border-radius: 16px; padding: 40px 36px; box-shadow: 0 2px 10px rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.04); }
  .content h2 { font-size: 21px; color: #0f1a30; margin: 30px 0 14px; padding-bottom: 8px; border-bottom: 2px solid #f1f5f9; }
  .content h2:first-child { margin-top: 0; }
  .content h3 { font-size: 16px; color: #1e293b; margin: 20px 0 10px; }
  .content p { color: #374151; margin-bottom: 14px; }
  .content ul, .content ol { margin: 12px 0 16px; padding-right: 24px; color: #374151; }
  .content li { margin-bottom: 6px; }
  .content a { color: #4f6bed; text-decoration: none; }
  .content a:hover { text-decoration: underline; }
  .content strong { color: #0f1a30; }
  .info-box { background: #f0f9ff; border-right: 3px solid #0ea5e9; padding: 14px 18px; border-radius: 8px; margin: 18px 0; font-size: 14px; color: #0c4a6e; }
  footer { background: #0f172a; color: #cbd5e1; padding: 40px 24px 24px; margin-top: 60px; }
  .footer-inner { max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; }
  @media (max-width: 768px) { .footer-inner { grid-template-columns: 1fr 1fr; } }
  .footer-col h4 { color: white; font-size: 15px; margin-bottom: 12px; font-weight: 600; }
  .footer-col a { color: #cbd5e1; text-decoration: none; display: block; padding: 4px 0; font-size: 14px; transition: color 0.15s; }
  .footer-col a:hover { color: white; }
  .footer-brand { font-size: 16px; font-weight: 700; color: white; margin-bottom: 10px; }
  .footer-brand-desc { font-size: 14px; color: #94a3b8; line-height: 1.6; }
  .footer-bottom { max-width: 1200px; margin: 30px auto 0; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.1); text-align: center; font-size: 13px; color: #94a3b8; }
  .footer-social { display: flex; gap: 8px; margin-top: 12px; }
  .footer-social a { width: 36px; height: 36px; background: rgba(255,255,255,0.08); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
  .footer-social a:hover { background: rgba(255,255,255,0.15); }
</style>
