<?php
$manufacturing_content = $manufacturing_content ?? [];

function mfg_icon($type) {
    $icons = [
        'arrow' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M13.2 5.3 20 12l-6.8 6.7-1.4-1.4 4.4-4.3H4v-2h12.2l-4.4-4.3 1.4-1.4Z"/></svg>',
        'building' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 21V3h10v4h8v14H3Zm2-2h2v-2H5v2Zm0-4h2v-2H5v2Zm0-4h2V9H5v2Zm0-4h2V5H5v2Zm4 12h2v-2H9v2Zm0-4h2v-2H9v2Zm0-4h2V9H9v2Zm0-4h2V5H9v2Zm4 12h6V9h-6v10Z"/></svg>',
        'vial' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 2h6v2h-1v5.2l4.4 7.6A3.5 3.5 0 0 1 15.4 22H8.6a3.5 3.5 0 0 1-3-5.2L10 9.2V4H9V2Z"/></svg>',
        'shield' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2 4 5.4v5.8c0 5 3.4 9.7 8 10.8 4.6-1.1 8-5.8 8-10.8V5.4L12 2Zm-1 13.4-3.4-3.4L9 10.6l2 2 4.4-4.4 1.4 1.4-5.8 5.8Z"/></svg>',
        'check' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9.2 16.2-4.2-4.2-1.4 1.4 5.6 5.6L21 7.2l-1.4-1.4L9.2 16.2Z"/></svg>',
        'search' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M10.8 4a6.8 6.8 0 1 0 0 13.6 6.8 6.8 0 0 0 0-13.6Zm5.6 10 4.1 4.1-1.4 1.4-4.1-4.1 1.4-1.4Z"/></svg>',
        'gear' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M19.4 13.5c.1-.5.1-1 .1-1.5s0-1-.1-1.5l2-1.5-2-3.5-2.4 1a8 8 0 0 0-2.6-1.5L14 2h-4l-.4 2.5A8 8 0 0 0 7 6L4.6 5 2.6 8.5l2 1.5c-.1.5-.1 1-.1 1.5s0 1 .1 1.5l-2 1.5 2 3.5 2.4-1a8 8 0 0 0 2.6 1.5L10 22h4l.4-2.5A8 8 0 0 0 17 18l2.4 1 2-3.5-2-1.5ZM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5Z"/></svg>',
        'lab' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 2h10v2h-1v5.4l4.6 7.9A3.1 3.1 0 0 1 18 22H6a3.1 3.1 0 0 1-2.6-4.7L8 9.4V4H7V2Zm3 8-4.9 8.3A1.1 1.1 0 0 0 6 20h12a1.1 1.1 0 0 0 .9-1.7L14 10h-4Z"/></svg>'
    ];

    return $icons[$type] ?? $icons['building'];
}

function mfg_icon_from_class($class) {
    $class = strtolower((string) $class);

    if (str_contains($class, 'vial') || str_contains($class, 'flask')) return 'vial';
    if (str_contains($class, 'shield') || str_contains($class, 'check')) return 'shield';
    if (str_contains($class, 'search') || str_contains($class, 'micro')) return 'search';
    if (str_contains($class, 'gear') || str_contains($class, 'cog')) return 'gear';
    if (str_contains($class, 'lab') || str_contains($class, 'book')) return 'lab';

    return 'building';
}
?>

<section class="manufacturing-hero section" aria-labelledby="manufacturingTitle">
    <div class="site-container manufacturing-hero-grid">
        <div class="manufacturing-copy">
            <nav class="breadcrumbs" aria-label="Breadcrumb">
                <a href="<?= $base_url ?>/">Home</a>
                <span class="separator">/</span>
                <span>Manufacturing</span>
            </nav>

            <span class="section-eyebrow">The Production Pillar</span>

            <h1 id="manufacturingTitle">
                Advanced WHO, GMP-certified <span>Sterile Manufacturer</span>
            </h1>

            <p class="manufacturing-lead">
                High-precision contract manufacturing delivering certified quality and global reliability.
            </p>

            <p>
                Sanjar Pharma LLP operates as a premier manufacturing center for Small Volume Parenteral injectables, offering comprehensive third-party and contract manufacturing services. Our facility in Himatnagar is strategically designed to handle large-scale qualitative and quantitative demands for domestic and international partners.
            </p>

            <div class="manufacturing-cert-row" aria-label="Sanjar Pharma manufacturing certifications">
                <img src="<?= $base_url ?>/assets/images/main/cer/who.webp" width="72" height="72" alt="WHO GMP certified" loading="eager" decoding="async">
                <img src="<?= $base_url ?>/assets/images/main/cer/gmp.webp" width="72" height="72" alt="GMP certified" loading="eager" decoding="async">
            </div>

            <a href="<?= $base_url ?>/contact" class="primary-button">
                Discuss Manufacturing Requirement
                <?= mfg_icon('arrow') ?>
            </a>
        </div>

        <div class="manufacturing-visual">
            <img
                src="<?= $base_url ?>/assets/images/about/abts1.webp"
                width="760"
                height="520"
                alt="Sanjar Pharma sterile injectable manufacturing plant"
                fetchpriority="high"
                loading="eager"
                decoding="async"
            >

            <div class="experience-badge card">
                <strong>SVP</strong>
                <span>Specialists</span>
            </div>
        </div>
    </div>
</section>

<?php if (!empty($manufacturing_content['features'])): ?>
<section class="facility-section section section-surface" aria-labelledby="facilityTitle">
    <div class="site-container">
        <div class="section-head centered-head">
            <div>
                <span class="section-eyebrow">Facility Capabilities</span>
                <h2 id="facilityTitle" class="section-title">World-Class Manufacturing Environment</h2>
                <p>Designed with modern pharmaceutical infrastructure and regulatory-compliant sterile production systems.</p>
            </div>
        </div>

        <div class="facility-grid">
            <?php foreach ($manufacturing_content['features'] as $feature): ?>
                <article class="facility-card card card-pad card-hover">
                    <span class="icon-box-brand">
                        <?= mfg_icon(mfg_icon_from_class($feature['icon'] ?? '')) ?>
                    </span>

                    <h3><?= htmlspecialchars($feature['title'], ENT_QUOTES, 'UTF-8') ?></h3>
                    <p><?= htmlspecialchars($feature['description'], ENT_QUOTES, 'UTF-8') ?></p>
                </article>
            <?php endforeach; ?>
        </div>
    </div>
</section>
<?php endif; ?>

<?php if (!empty($manufacturing_content['gallery'])): ?>
<section class="facility-gallery-section section" aria-labelledby="galleryTitle">
    <div class="site-container">
        <div class="section-head centered-head">
            <div>
                <span class="section-eyebrow">Facility Overview</span>
                <h2 id="galleryTitle" class="section-title">Manufacturing Infrastructure</h2>
            </div>
        </div>

        <div class="gallery-grid">
            <?php foreach ($manufacturing_content['gallery'] as $image): ?>
                <article class="gallery-card">
                    <img
                        src="<?= $base_url . htmlspecialchars($image['image'], ENT_QUOTES, 'UTF-8') ?>"
                        width="520"
                        height="340"
                        alt="<?= htmlspecialchars($image['title'], ENT_QUOTES, 'UTF-8') ?>"
                        loading="lazy"
                        decoding="async"
                    >

                    <div class="gallery-overlay">
                        <h3><?= htmlspecialchars($image['title'], ENT_QUOTES, 'UTF-8') ?></h3>
                    </div>
                </article>
            <?php endforeach; ?>
        </div>
    </div>
</section>
<?php endif; ?>

<section class="manufacturing-compliance-section section section-surface" aria-labelledby="complianceTitle">
    <div class="site-container compliance-grid">
        <div class="compliance-copy">
            <span class="section-eyebrow">Regulatory Excellence</span>

            <h2 id="complianceTitle">
                Quality Control & Compliance Systems
            </h2>

            <p>
                Every stage of manufacturing follows strict pharmaceutical quality protocols with dedicated QC, QA, microbiology, and validation systems.
            </p>

            <?php if (!empty($manufacturing_content['compliance'])): ?>
                <div class="compliance-list">
                    <?php foreach ($manufacturing_content['compliance'] as $item): ?>
                        <article class="compliance-item">
                            <span class="icon-sq">
                                <?= mfg_icon(mfg_icon_from_class($item['icon'] ?? '')) ?>
                            </span>

                            <div>
                                <h3><?= htmlspecialchars($item['title'], ENT_QUOTES, 'UTF-8') ?></h3>
                                <p><?= htmlspecialchars($item['description'], ENT_QUOTES, 'UTF-8') ?></p>
                            </div>
                        </article>
                    <?php endforeach; ?>
                </div>
            <?php endif; ?>
        </div>

        <div class="compliance-visual-grid">
            <img
                src="<?= $base_url ?>/assets/images/about/abts2.webp"
                width="520"
                height="620"
                alt="Sanjar Pharma quality control laboratory"
                loading="lazy"
                decoding="async"
            >

            <img
                src="<?= $base_url ?>/assets/images/about/abts3.webp"
                width="520"
                height="620"
                alt="Sanjar Pharma sterile filling line"
                loading="lazy"
                decoding="async"
            >
        </div>
    </div>
</section>

<section class="manufacturing-cta-section section-sm" aria-labelledby="manufacturingCtaTitle">
    <div class="site-container">
        <div class="manufacturing-cta-card card">
            <div>
                <span class="section-eyebrow">Contract Manufacturing</span>
                <h2 id="manufacturingCtaTitle">Need a reliable sterile injectable manufacturing partner?</h2>
                <p>Connect with Sanjar Pharma for certified, scalable and quality-led manufacturing support.</p>
            </div>

            <a href="<?= $base_url ?>/contact" class="primary-button">
                Send Enquiry
                <?= mfg_icon('arrow') ?>
            </a>
        </div>
    </div>
</section>

<style>
.manufacturing-hero {
  overflow: hidden;
  background: var(--body-bg);
}

.manufacturing-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
}

.manufacturing-copy h1 {
  margin-bottom: 1rem;
}

.manufacturing-copy h1 span {
  color: var(--primary);
}

.manufacturing-lead {
  color: var(--primary);
  font-size: clamp(1rem, 0.7vw + 0.95rem, 1.3rem);
  font-weight: 700;
}

.manufacturing-cert-row {
  display: flex;
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.manufacturing-cert-row img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.manufacturing-visual {
  position: relative;
  min-height: 390px;
}

.manufacturing-visual > img {
  width: 100%;
  height: 390px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.experience-badge {
  position: absolute;
  left: 1.25rem;
  bottom: 1.25rem;
  min-width: 140px;
  padding: 1rem 1.25rem;
}

.experience-badge strong {
  display: block;
  color: var(--heading);
  font-size: 1.75rem;
  line-height: 1;
}

.experience-badge span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.centered-head {
  justify-content: center;
  text-align: center;
}

.centered-head p {
  max-width: 800px;
  margin-inline: auto;
}

.facility-grid,
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.facility-card h3 {
  margin-bottom: 0.65rem;
  font-size: 1rem;
}

.facility-card p {
  margin: 0;
  font-size: 0.92rem;
}

.icon-box-brand {
  width: 50px;
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  border-radius: var(--radius-sm);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
}

.icon-box-brand svg,
.icon-sq svg,
.primary-button svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.gallery-card {
  position: relative;
  height: 250px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal);
}

.gallery-card:hover img {
  transform: scale(1.04);
}

.gallery-overlay {
  position: absolute;
  inset: auto 0 0;
  padding: 4rem 1.25rem 1.25rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.86));
  transition: padding var(--transition-normal);
}

.gallery-card:hover .gallery-overlay {
  padding-bottom: 1.55rem;
}

.gallery-overlay h3 {
  margin: 0;
  color: #fff;
  font-size: 1rem;
}

.compliance-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
}

.compliance-copy h2 {
  margin-bottom: 1rem;
}

.compliance-list {
  display: grid;
  gap: 1.2rem;
  margin-top: 1.5rem;
}

.compliance-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.icon-sq {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
}

.compliance-item h3 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.compliance-item p {
  margin: 0;
  font-size: 0.92rem;
}

.compliance-visual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: center;
}

.compliance-visual-grid img {
  width: 100%;
  height: 430px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.compliance-visual-grid img:nth-child(2) {
  margin-top: 3rem;
}

.manufacturing-cta-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: clamp(1.5rem, 3vw, 3rem);
  overflow: hidden;
  background:
    radial-gradient(circle at right top, color-mix(in srgb, var(--primary) 16%, transparent), transparent 35%),
    var(--surface);
}

.manufacturing-cta-card h2 {
  max-width: 720px;
  margin-bottom: 0.65rem;
  font-size: clamp(1.45rem, 2vw, 2.6rem);
}

.manufacturing-cta-card p {
  margin: 0;
}

@media (max-width: 1180px) {
  .facility-grid,
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 991px) {
  .manufacturing-hero-grid,
  .compliance-grid {
    grid-template-columns: 1fr;
  }

  .manufacturing-visual,
  .manufacturing-visual > img {
    min-height: auto;
    height: auto;
  }

  .manufacturing-visual > img {
    aspect-ratio: 4 / 3;
  }

  .manufacturing-cta-card {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 575px) {
  .facility-grid,
  .gallery-grid,
  .compliance-visual-grid {
    grid-template-columns: 1fr;
  }

  .gallery-card {
    height: 220px;
  }

  .experience-badge {
    position: static;
    margin-top: 1rem;
  }

  .compliance-visual-grid img {
    height: 260px;
  }

  .compliance-visual-grid img:nth-child(2) {
    margin-top: 0;
  }
}
</style>