<turbo-stream action="update" target="modal"><template><!-- app/views/quote_templates/_terms_modal.html.erb -->
<turbo-frame id="modal">
  <script>
    // Create modal outside of the page flow
    const modalHtml = `
      <div id="termsModalOverlay" style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 99999; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 1rem;" onclick="closeTermsModal(event)">
        <div style="background: white; border-radius: 1rem; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); max-width: 64rem; width: 100%; max-height: 90vh; overflow: hidden;" onclick="event.stopPropagation()">
          <!-- Modal Header -->
          <div style="background: #374151; color: white; padding: 1.5rem; display: flex; justify-content: space-between; align-items: center;">
            <h3 style="font-size: 1.25rem; font-weight: 600; margin: 0;">Terms and Conditions</h3>
            <button onclick="closeTermsModal()" style="color: white; background: none; border: none; cursor: pointer; padding: 0.5rem; border-radius: 0.25rem; transition: color 0.2s; display: flex; align-items: center; justify-content: center; margin: -0.5rem -0.5rem -0.5rem 0;" onmouseover="this.style.color='#d1d5db'" onmouseout="this.style.color='white'">
              <svg style="width: 1.5rem; height: 1.5rem;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
              </svg>
            </button>
          </div>
          
          <!-- Modal Content -->
          <div style="padding: 1.5rem; overflow-y: auto; max-height: calc(90vh - 140px);">
            <div style="color: #374151; line-height: 1.625; white-space: pre-line;"><div class="trix-content">
  <div>By accepting this quote, you agree to the following terms and conditions.<br><strong>Quote Validity</strong>: This quote is valid until the expiry date stipulated above. However, please be aware that EXAMPLE has the right to change or cancel it at any time.<br><strong>Quote Confirmation and Availability</strong>: The issuance of this quote does not constitute EXAMPLE acceptance or guarantee of availability. Our availability is confirmed only upon your acceptance of this quote and payment of the commitment fee if applicable.</div><div><strong>Commitment Fee</strong>: EXAMPLE may require a $1,000 commitment fee (plus GST) when you accept this quote. This fee is non-refundable and covers the cost of preparing the quote and guarantees EXAMPLE availability for your function. This amount will be deducted from the final invoice. EXAMPLE may waive this for smaller orders.</div><div><strong>Payment</strong>: In most cases, you'll be invoiced prior to your event, or delivery of our goods. If EXAMPLE agrees to invoice you afterwards, full payment is required within five working days from the invoice's date, or unless otherwise agreed by EXAMPLE.</div><div><strong>Allergens:</strong> You acknowledge that we make every effort to ensure the safety and integrity of our food; however, allergen ingredients are present in our kitchen. Please inform us of any dietary requirements your guests may have, so we can ensure their needs are met with care and attention.<br><strong>Cancellations</strong>: Cancellation fees depend on how much notice you provide: no charge for over ten working days notice; 50% of the total quote value for 3-10 working days notice; 80% for 2 working days; and 100% for 1 working day or less. The commitment fee is non-refundable.</div><div><strong>Force Majeure</strong>: Exceptions apply to the cancellation clause for unforeseen circumstances like natural disasters, war, or Health regulations (where your event cannot legally proceed). In such cases, you'll be charged 33% of the quote if you cancel with less than three working days notice.</div><div><strong>Final Details</strong>: Final guest numbers and menu choices must be confirmed at least ten working days before the event. EXAMPLE will be happy to accommodate small changes to guest numbers and menu selections, but these will likely result in updated pricing and may incur a $100 administration fee. Material changes will need to be agreed upon by EXAMPLE and will require a new updated agreement and pricing.</div><div><strong>Cost Increases:</strong> If unforeseen costs come up, EXAMPLE may need to adjust your quote. If you don't agree with the changes, you are entitled to cancel the contract and receive a refund of any commitment fee paid.</div><div><strong>Order Changes After Payment</strong>: If you change your order after paying, EXAMPLE will create a new invoice for the difference, or arrange a refund. Refunds are at EXAMPLE discretion.</div><div><strong>Beverage Service</strong>: If your quote includes beverage service charged "on consumption", meaning you only pay for your guests actually consume, you agree there is a minimum charge of $1,000 + GST, regardless of actual consumption.</div><div><strong>Post-Event Charges</strong>: EXAMPLE may charge additional costs after your event for lost equipment or damages, extra beverages, or extra staffing costs.</div><div><strong>Equipment Care</strong>: You're responsible for any damage or loss to EXAMPLE equipment. You can't dispute the condition or quantity of returned equipment if you're not present during its return.</div><div><strong>Equipment Bond</strong>: Sometimes, a bond payment may be required. If a bond is required, it will be included in this quote.<br><strong>Continuity</strong>: These terms and conditions will remain binding and effective on you under all circumstances, including any changes in shareholding, management, or transfer of ownership of EXAMPLE.</div><div><strong>Late Payment</strong>: If you don't pay on time, EXAMPLE may charge 15% interest per month. Any costs from a debt collection company will be added to your invoice.<br><strong>Photos: </strong>Product photos displayed on our website or in our quotes are for illustrative purposes only and may not represent the actual product.</div><div><strong>Disputes</strong>: If there are any issues with the catering or equipment, you still need to pay the full invoice and then discuss any claims with EXAMPLE.</div><div><br></div>
</div>
</div>
          </div>
          
          <!-- Modal Footer -->
          <div style="background: #f9fafb; padding: 1.5rem; border-top: 1px solid #e5e7eb; display: flex; justify-content: flex-end;">
            <button onclick="closeTermsModal()" style="padding: 0.5rem 1.5rem; background: #374151; color: white; border: none; border-radius: 0.5rem; cursor: pointer; font-weight: 500; transition: background-color 0.2s;" onmouseover="this.style.backgroundColor='#1f2937'" onmouseout="this.style.backgroundColor='#374151'">
              Close
            </button>
          </div>
        </div>
      </div>
    `;
    
    // Append to body to ensure it's on top
    document.body.insertAdjacentHTML('beforeend', modalHtml);
    
    // Prevent body scroll
    document.body.style.overflow = 'hidden';
    
    // Close modal function
    window.closeTermsModal = function(event) {
      // If event is passed and it's not a background click, return
      if (event && event.target !== event.currentTarget) return;
      
      // Remove modal from body
      const modal = document.getElementById('termsModalOverlay');
      if (modal) {
        modal.remove();
      }
      
      // Clear the turbo frame
      document.getElementById('modal').innerHTML = '';
      
      // Re-enable body scroll
      document.body.style.overflow = 'auto';
      
      // Remove event listener
      document.removeEventListener('keydown', handleEscapeKey);
    }

    // Close modal with Escape key
    function handleEscapeKey(e) {
      if (e.key === 'Escape') {
        closeTermsModal();
      }
    }
    document.addEventListener('keydown', handleEscapeKey);
  </script>
</turbo-frame></template></turbo-stream>