<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Cleaning Services Cost Calculator</title>
  <style>
    /* Scoped styles to prevent conflicts with existing site styles */
    .cleaning-calculator {
      max-width: 400px;
      margin: 20px auto;
      font-family: Arial, sans-serif;
      border: 1px solid #ccc;
      border-radius: 8px;
      padding: 16px;
      background-color: #f9f9f9;
    }
    .cleaning-calculator h2 {
      text-align: center;
      margin-bottom: 16px;
      color: #2C97DE;
    }
    .cleaning-calculator .service {
      margin-bottom: 12px;
      border-bottom: 1px solid #e0e0e0;
      padding-bottom: 12px;
    }
    .cleaning-calculator label {
      display: block;
      margin-bottom: 6px;
      font-weight: 600;
    }
    .cleaning-calculator select,
    .cleaning-calculator input {
      width: 100%;
      padding: 8px;
      margin-bottom: 10px;
      border-radius: 4px;
      border: 1px solid #ccc;
      box-sizing: border-box;
      font-size: 14px;
    }
    .cleaning-calculator button {
      width: 100%;
      padding: 10px;
      background-color: #28a745;
      color: #fff;
      border: none;
      border-radius: 4px;
      font-size: 16px;
      cursor: pointer;
    }
    .cleaning-calculator button:hover {
      background-color: #218838;
    }
    .cleaning-calculator #result {
      margin-top: 16px;
      text-align: center;
      display: none; /* Hidden until calculation is made */
      padding: 12px;
      border-top: 1px solid #e0e0e0;
    }
    .cleaning-calculator #estimatedPrice {
      font-weight: bold;
      font-size: 20px;
      color: #e74c3c;
      margin-bottom: 12px;
    }
    .cleaning-calculator .note {
      font-size: 12px;
      margin-bottom: 12px;
      font-style: italic;
      color: #555;
    }
    .cleaning-calculator .contact-btn {
      background-color: #007bff;
    }
    .cleaning-calculator .contact-btn:hover {
      background-color: #0056b3;
    }

    /* Responsive Design */
    @media (max-width: 480px) {
      .cleaning-calculator {
        padding: 12px;
      }
      .cleaning-calculator h2 {
        font-size: 18px;
      }
      .cleaning-calculator button {
        font-size: 14px;
      }
      .cleaning-calculator #estimatedPrice {
        font-size: 18px;
      }
    }
  </style>
</head>
<body>

<div class="cleaning-calculator">
  <h2>Cleaning Cost Calculator</h2>
  <p>Select the services you need and provide additional details to get an estimated price.</p>

  <!-- Service Selection -->
  <div class="service">
    <label for="serviceSelect">Select Cleaning Service:</label>
    <select id="serviceSelect">
      <option value="">-- Select a Service --</option>
      <option value="deepCleaning">End of Tenancy / Deep Cleaning / After Builders Cleaning</option>
      <option value="ovenCleaning">Oven Cleaning</option>
      <option value="carpetCleaning">Carpet Cleaning / Upholstery Cleaning</option>
      <option value="windowCleaning">Window Cleaning</option>
      <option value="oneOffCleaning">One-Off Cleaning</option>
    </select>
  </div>

  <!-- Additional Inputs for Specific Services -->
  <div id="additionalInputs"></div>

  <!-- Calculate Button -->
  <button id="calculateBtn">Calculate Estimate</button>

  <!-- Result Section (hidden by default) -->
  <div id="result">
    <p>Your estimated price is: <span id="estimatedPrice"></span></p>
    <p class="note">
      This is a preliminary estimate. You will receive an exact quote by contacting our representative.
    </p>
    <button id="contactBtn" class="contact-btn">Contact Us Now</button>
  </div>
</div>

<!-- JavaScript: Inline for convenience -->
<script>
  // Wait for the DOM to load
  document.addEventListener('DOMContentLoaded', function() {
    // Get references to elements
    const serviceSelect = document.getElementById('serviceSelect');
    const additionalInputs = document.getElementById('additionalInputs');
    const calculateBtn = document.getElementById('calculateBtn');
    const resultDiv = document.getElementById('result');
    const estimatedPrice = document.getElementById('estimatedPrice');
    const contactBtn = document.getElementById('contactBtn');

    // Service pricing data
    const serviceData = {
      deepCleaning: {
        name: "End of Tenancy / Deep Cleaning / After Builders Cleaning",
        basePrice: 89,
        // Additional parameters can be added here
        params: [
          {
            label: "Property Size (Bedrooms)",
            id: "bedrooms",
            type: "number",
            min: 1,
            step: 1,
            placeholder: "Enter number of bedrooms",
            multiplier: 20 // £20 per bedroom
          },
          {
            label: "Property Condition",
            id: "condition",
            type: "select",
            options: [
              { value: "standard", text: "Standard" },
              { value: "dirty", text: "Dirty (+£30)" }
            ],
            multiplier: {
              standard: 0,
              dirty: 30
            }
          }
        ]
      },
      ovenCleaning: {
        name: "Oven Cleaning",
        basePrice: 49,
        params: []
      },
      carpetCleaning: {
        name: "Carpet Cleaning / Upholstery Cleaning",
        basePrice: 55,
        params: [
          {
            label: "Number of Rooms",
            id: "carpetRooms",
            type: "number",
            min: 1,
            step: 1,
            placeholder: "Enter number of rooms",
            multiplier: 15 // £15 per room
          }
        ]
      },
      windowCleaning: {
        name: "Window Cleaning",
        basePrice: 49,
        params: [
          {
            label: "Number of Windows",
            id: "windows",
            type: "number",
            min: 1,
            step: 1,
            placeholder: "Enter number of windows",
            multiplier: 5 // £5 per window
          }
        ]
      },
      oneOffCleaning: {
        name: "One-Off Cleaning",
        basePrice: 16, // per hour
        params: [
          {
            label: "Number of Hours",
            id: "hours",
            type: "number",
            min: 1,
            step: 1,
            placeholder: "Enter number of hours",
            multiplier: 1 // direct multiplication
          }
        ]
      }
    };

    // Function to create additional input fields based on selected service
    function renderAdditionalInputs(serviceKey) {
      additionalInputs.innerHTML = ''; // Clear previous inputs

      if (!serviceKey || !serviceData[serviceKey].params.length) {
        return;
      }

      serviceData[serviceKey].params.forEach(param => {
        const label = document.createElement('label');
        label.setAttribute('for', param.id);
        label.textContent = param.label;

        let input;
        if (param.type === 'select') {
          input = document.createElement('select');
          input.id = param.id;
          param.options.forEach(option => {
            const opt = document.createElement('option');
            opt.value = option.value;
            opt.textContent = option.text;
            input.appendChild(opt);
          });
        } else {
          input = document.createElement('input');
          input.type = param.type;
          input.id = param.id;
          input.min = param.min;
          input.step = param.step;
          input.placeholder = param.placeholder;
        }

        additionalInputs.appendChild(label);
        additionalInputs.appendChild(input);
      });
    }

    // Event listener for service selection change
    serviceSelect.addEventListener('change', function() {
      renderAdditionalInputs(this.value);
      resultDiv.style.display = 'none'; // Hide result when changing service
    });

    // Handle calculation
    calculateBtn.addEventListener('click', function() {
      const selectedServiceKey = serviceSelect.value;

      if (!selectedServiceKey) {
        alert("Please select a cleaning service.");
        return;
      }

      const service = serviceData[selectedServiceKey];
      let price = service.basePrice;

      // Calculate additional costs based on parameters
      service.params.forEach(param => {
        const element = document.getElementById(param.id);
        if (param.type === 'number') {
          const value = parseInt(element.value, 10) || 0;
          price += param.multiplier * value;
        } else if (param.type === 'select') {
          const value = element.value;
          if (typeof param.multiplier === 'object') {
            price += param.multiplier[value] || 0;
          }
        }
      });

      // If service is One-Off Cleaning, multiply by hours
      if (selectedServiceKey === 'oneOffCleaning') {
        const hours = parseInt(document.getElementById('hours').value, 10) || 1;
        price = service.basePrice * hours;
      }

      // Display result
      estimatedPrice.textContent = '£' + price;
      resultDiv.style.display = 'block';
      // Scroll to result
      resultDiv.scrollIntoView({ behavior: 'smooth' });
    });

    // Contact button redirects to phone call
    contactBtn.addEventListener('click', function() {
      // Вы можете изменить эту ссылку для открытия формы обратной связи или электронной почты
      window.location.href = 'tel:+441616762888';
    });
  });
</script>

</body>
</html>
