• Kontakt

<!-- Formularz kontaktowy Sekrety Natury -->
<style>
.contact-card{max-width:760px;margin:20px auto;padding:22px;border:1px solid #e6e6e6;border-radius:8px;font-family:Arial, sans-serif;background:#fff;}
.contact-card h2{margin-top:0}
.form-row{display:flex;gap:12px;flex-wrap:wrap}
.form-group{flex:1 1 240px;display:flex;flex-direction:column;margin-bottom:10px}
label{font-size:14px;margin-bottom:6px}
input[type="text"], input[type="email"], input[type="tel"], textarea, select{
padding:10px;border:1px solid #ddd;border-radius:6px;font-size:14px;
}
textarea{min-height:120px;resize:vertical}
.small-note{font-size:12px;color:#666;margin-top:6px}
.submit-row{display:flex;align-items:center;gap:12px;margin-top:12px}
.btn{background:#1E3D32;color:#fff;padding:10px 16px;border-radius:6px;border:none;cursor:pointer}
.btn:disabled{opacity:0.6;cursor:not-allowed}
.consent{font-size:13px;color:#333}
.error{color:#b00020;font-size:13px}
/* ukryty honeypot */
.hp{position:absolute;left:-10000px;top:auto;overflow:hidden;height:0;width:0}
</style>

<div class="contact-card" id="contact-card">
<h2>Kontakt — Sekrety Natury</h2>
<p class="small-note">Masz pytanie o produkt, zamówienie lub współpracę? Napisz do nas.</p>

<form id="contactForm" method="post" action="/kontakt/submit">
<div class="form-row">
<div class="form-group">
<label for="name">Imię i nazwisko *</label>
<input type="text" id="name" name="name" required maxlength="120" />
</div>

<div class="form-group">
<label for="email">E-mail *</label>
<input type="email" id="email" name="email" required maxlength="150" />
</div>

<div class="form-group">
<label for="phone">Telefon (opcjonalnie)</label>
<input type="tel" id="phone" name="phone" maxlength="30" />
</div>
</div>

<div class="form-row">
<div class="form-group" style="flex:2 1 100%">
<label for="subject">Temat *</label>
<input type="text" id="subject" name="subject" required maxlength="150" />
</div>
</div>

<div class="form-row">
<div class="form-group" style="flex:1 1 100%">
<label for="message">Treść wiadomości *</label>
<textarea id="message" name="message" required maxlength="5000"></textarea>
</div>
</div>

<div class="hp" aria-hidden="true">
<!-- Honeypot: ludzie nie wypełniają, boty często tak -->
<label for="company_hp">Jeśli jesteś człowiekiem, pozostaw to pole puste</label>
<input type="text" id="company_hp" name="company_hp" />
</div>

<div>
<label class="consent">
<input type="checkbox" id="consent" name="consent" required />
Wyrażam zgodę na przetwarzanie moich danych osobowych przez Jana Górkę Karma Food (os. Piastów 19, 31-623 Kraków) w celu obsługi zapytania przesłanego przez formularz. Zapoznałem(-am) się z Polityką Prywatności. Mam prawo do cofnięcia zgody w dowolnym momencie.
</label>
</div>

<div class="submit-row">
<button class="btn" type="submit" id="submitBtn">Wyślij wiadomość</button>
<div id="formMsg" class="small-note"></div>
</div>

<div id="formError" class="error" role="alert" style="display:none"></div>
</form>
</div>

<script>
(function(){
const form = document.getElementById('contactForm');
const btn = document.getElementById('submitBtn');
const msg = document.getElementById('formMsg');
const err = document.getElementById('formError');

form.addEventListener('submit', async function(e){
e.preventDefault();
err.style.display = 'none';
btn.disabled = true;
msg.textContent = 'Wysyłanie...';

// prosty frontendowy honeypot check
if(document.getElementById('company_hp').value.trim() !== '') {
// prawdopodobny bot — zatrzymujemy
msg.textContent = '';
err.style.display = 'block';
err.textContent = 'Wystąpił błąd. Spróbuj ponownie.';
btn.disabled = false;
return;
}

// Zbierz dane
const data = {
name: form.name.value.trim(),
email: form.email.value.trim(),
phone: form.phone.value.trim(),
subject: form.subject.value.trim(),
message: form.message.value.trim(),
consent: form.consent.checked ? 'on' : ''
};

// Prosty fetch do endpointu — wymaga obsługi po stronie serwera
try {
const res = await fetch(form.action, {
method: 'POST',
headers: {'Content-Type':'application/json'},
body: JSON.stringify(data)
});
if(res.ok){
msg.textContent = 'Dziękujemy — wiadomość została wysłana.';
form.reset();
} else {
const json = await res.json().catch(()=>null);
err.style.display = 'block';
err.textContent = json && json.error ? json.error : 'Wystąpił błąd podczas wysyłania. Spróbuj później.';
}
} catch (e) {
err.style.display = 'block';
err.textContent = 'Błąd połączenia. Sprawdź połączenie i spróbuj ponownie.';
} finally {
btn.disabled = false;
msg.textContent = '';
}
});
})();
</script>www.sekrety-natury.pl