<?xml version="1.0" encoding="UTF-8"?>
<!-- IIS/Windows Server Configuration for INGCO Website -->
<!-- This file should be placed in the public/ or dist/ folder after build -->
<configuration>
  <system.webServer>
    
    <!-- ============================================ -->
    <!-- Force HTTPS Redirect -->
    <!-- ============================================ -->
    <rewrite>
      <rules>
        <rule name="Force HTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
            <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
            <add input="{HTTP_HOST}" pattern="127\.0\.0\.1" negate="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
        </rule>
        
        <!-- SPA Routing (React Router) -->
        <rule name="React Router" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/index.html" />
        </rule>
      </rules>
    </rewrite>

    <!-- ============================================ -->
    <!-- Cache Control Headers -->
    <!-- ============================================ -->
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" />
    </staticContent>
    
    <httpProtocol>
      <customHeaders>
        <!-- HTML files - No cache -->
        <add name="Cache-Control" value="no-cache, no-store, must-revalidate" />
        <add name="Pragma" value="no-cache" />
        <add name="Expires" value="0" />
        
        <!-- Security Headers -->
        <add name="X-Content-Type-Options" value="nosniff" />
        <add name="X-XSS-Protection" value="1; mode=block" />
        <add name="X-Frame-Options" value="SAMEORIGIN" />
        <add name="Referrer-Policy" value="strict-origin-when-cross-origin" />
      </customHeaders>
    </httpProtocol>

    <!-- Remove ETags -->
    <httpProtocol>
      <customHeaders>
        <remove name="ETag" />
      </customHeaders>
    </httpProtocol>
    <outboundRules>
      <rule name="Remove ETag">
        <match serverVariable="RESPONSE_ETag" pattern=".+" />
        <action type="Rewrite" value="" />
      </rule>
    </outboundRules>

    <!-- URL Rewrite Module Configuration -->
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />
    
    <!-- MIME Types -->
    <staticContent>
      <mimeMap fileExtension=".json" mimeType="application/json" />
      <mimeMap fileExtension=".woff" mimeType="font/woff" />
      <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
    </staticContent>

  </system.webServer>
</configuration>

