<?php
define('VS_INCLUDED',true);
require_once 'includes/config.php';
$page_title='İletişim';
// AJAX
if($_SERVER['REQUEST_METHOD']==='POST'&&isset($_SERVER['HTTP_X_REQUESTED_WITH'])){
  header('Content-Type:application/json');
  $name=clean($_POST['name']??''); $email=clean($_POST['email']??'');
  $subject=clean($_POST['subject']??''); $message=clean($_POST['message']??'');
  if(!$name||!$email||!$message){echo json_encode(['success'=>false,'message'=>'Lütfen zorunlu alanları doldurun.']);exit;}
  if(!filter_var($email,FILTER_VALIDATE_EMAIL)){echo json_encode(['success'=>false,'message'=>'Geçerli bir e-posta adresi girin.']);exit;}
  try{
    db()->prepare("INSERT INTO vs_messages(name,email,subject,message)VALUES(?,?,?,?)")->execute([$name,$email,$subject,$message]);
    echo json_encode(['success'=>true,'message'=>'Mesajınız alındı. En kısa sürede dönüş yapacağız.']);
  }catch(Exception $e){echo json_encode(['success'=>false,'message'=>'Teknik hata. Lütfen tekrar deneyin.']);}
  exit;
}
$urun=$_GET['urun']??'';
include 'includes/header.php';
?>

<div class="phero">
  <div class="phero-inner">
    <span class="eyebrow">İletişim</span>
    <h1 class="phero-h">Bize<br>Ulaşın</h1>
    <p class="phero-p">Teklif, bilgi veya işbirliği için ekibimizle iletişime geçin. Size 24 saat içinde dönüş yapacağız.</p>
  </div>
  <div class="phero-num">?</div>
</div>

<div class="cstrip" data-sr>
  <div class="cstrip-inner">
    <a href="tel:<?=clean(setting('contact_phone','+903120000000'))?>" class="cstrip-item">
      <div class="cstrip-ico"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.5 19.5 0 014.69 13a19.79 19.79 0 01-3.07-8.67A2 2 0 013.6 2h3a2 2 0 012 1.72 12.84 12.84 0 00.7 2.81 2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7A2 2 0 0122 16.92z"/></svg></div>
      <div><div class="cstrip-lbl">Telefon</div><div class="cstrip-val"><?=clean(setting('contact_phone','+90 312 000 00 00'))?></div></div>
    </a>
    <a href="mailto:<?=clean(setting('contact_email','info@volkersavunma.com'))?>" class="cstrip-item">
      <div class="cstrip-ico"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></svg></div>
      <div><div class="cstrip-lbl">E-Posta</div><div class="cstrip-val"><?=clean(setting('contact_email','info@volkersavunma.com'))?></div></div>
    </a>
    <div class="cstrip-item">
      <div class="cstrip-ico"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0118 0z"/><circle cx="12" cy="10" r="3"/></svg></div>
      <div><div class="cstrip-lbl">Adres</div><div class="cstrip-val"><?=clean(setting('contact_address','Ankara, Türkiye'))?></div></div>
    </div>
  </div>
</div>

<section class="section" style="background:var(--ink2);">
  <div class="wrap">
    <div class="contact-layout" data-sr>
      <div class="contact-side">
        <span class="eyebrow">İletişim Formu</span>
        <h2 style="font-size:clamp(28px,4vw,44px);margin-bottom:12px;">Mesaj Gönderin</h2>
        <p style="font-size:14px;color:var(--white3);line-height:1.75;margin-bottom:40px;">En kısa sürede size dönüş yapacağız. Acil talepler için doğrudan telefonu tercih edin.</p>
        <div class="ci-item"><div class="ci-ico"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.5 19.5 0 014.69 13a19.79 19.79 0 01-3.07-8.67A2 2 0 013.6 2h3a2 2 0 012 1.72 12.84 12.84 0 00.7 2.81 2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7A2 2 0 0122 16.92z"/></svg></div><div><div class="ci-lbl">Telefon</div><div class="ci-val"><?=clean(setting('contact_phone','+90 312 000 00 00'))?></div></div></div>
        <div class="ci-item"><div class="ci-ico"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></svg></div><div><div class="ci-lbl">E-Posta</div><div class="ci-val"><?=clean(setting('contact_email','info@volkersavunma.com'))?></div></div></div>
        <div class="ci-item"><div class="ci-ico"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0118 0z"/><circle cx="12" cy="10" r="3"/></svg></div><div><div class="ci-lbl">Adres</div><div class="ci-val"><?=clean(setting('contact_address','Ankara, Türkiye'))?></div></div></div>
      </div>

      <div class="contact-form">
        <div id="falert" class="alert" style="display:none;"></div>
        <form class="vf" id="cform" novalidate>
          <?php if($urun): ?>
          <input type="hidden" name="subject" value="Teklif talebi: <?=clean($urun)?>">
          <div style="background:var(--red-low);border:1px solid var(--rule-r);padding:14px 18px;margin-bottom:4px;">
            <span style="font-family:var(--mono);font-size:10px;letter-spacing:.12em;color:var(--red);">ÜRÜN TALEBİ: <?=clean($urun)?></span>
          </div>
          <?php endif; ?>
          <div class="vf-row">
            <div class="vf-grp"><label class="vf-lbl">Ad Soyad *</label><input class="vf-inp" type="text" name="name" required placeholder="Adınız Soyadınız"></div>
            <div class="vf-grp"><label class="vf-lbl">E-Posta *</label><input class="vf-inp" type="email" name="email" required placeholder="ornek@firma.com"></div>
          </div>
          <div class="vf-row">
            <div class="vf-grp"><label class="vf-lbl">Telefon</label><input class="vf-inp" type="tel" name="phone" placeholder="+90 5XX XXX XX XX"></div>
            <div class="vf-grp"><label class="vf-lbl">Şirket</label><input class="vf-inp" type="text" name="company" placeholder="Şirket adı"></div>
          </div>
          <?php if(!$urun): ?>
          <div class="vf-grp"><label class="vf-lbl">Konu</label><input class="vf-inp" type="text" name="subject" placeholder="Mesajınızın konusu"></div>
          <?php endif; ?>
          <div class="vf-grp"><label class="vf-lbl">Mesaj *</label><textarea class="vf-txt" name="message" required placeholder="Taleplerinizi, sorularınızı veya notlarınızı buraya yazın..." style="min-height:150px;"></textarea></div>
          <button type="submit" class="btn btn-primary btn-lg submit-btn" style="align-self:flex-start;">
            Mesaj Gönder
            <span class="btn-arrow"><svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path d="M5 12h14M12 5l7 7-7 7"/></svg></span>
          </button>
        </form>
      </div>
    </div>
  </div>
</section>

<?php include 'includes/footer.php'; ?>
