<?php
require_once 'config.php';
$pageTitle = "Kontak - Travelica Agency";
$activePage = 'kontak';
$extraCSS = '<link rel="stylesheet" href="assets/css/kontak.css" />';
$waAdmins = get_wa_admins();
include 'includes/header.php';
?>

  <!-- ============================================================
     CONTACT HERO
============================================================ -->
  <section class="contact-hero">
    <div class="contact-hero-overlay"></div>
    <div class="contact-hero-content">
      <h1>Hubungi Kami</h1>
      <p>Tim Travelica Agency siap membantu merencanakan liburan impian Anda.</p>
    </div>
  </section>

  <!-- ============================================================
     CONTACT SECTION
============================================================ -->
  <section class="contact-section">
    <div class="contact-container">
      
      <!-- Contact Info Box -->
      <div class="contact-info-card">
        <h3>Informasi Kontak</h3>
        <ul class="contact-info-list">
          
          <li class="ci-item">
            <div class="ci-icon">
              <!-- Location Icon -->
              <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
                <circle cx="12" cy="10" r="3"></circle>
              </svg>
            </div>
            <div class="ci-text">
              <h4>Alamat Kantor</h4>
              <p>
                <?php 
                  $rawAddr = htmlspecialchars(get_setting('address', "Jl. Jenderal Sudirman No.Kav 21\nJakarta Selatan, DKI Jakarta 12920"));
                  echo preg_replace('/(\(?APPOINTMENT ONLY\)?)/i', '<span class="ci-appointment-tag">$1</span>', nl2br($rawAddr));
                ?>
              </p>
            </div>
          </li>

          <li class="ci-item ci-item-wa">
            <div class="ci-icon">
              <!-- Phone Icon -->
              <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"></path>
              </svg>
            </div>
            <div class="ci-text">
              <h4>Telepon / WhatsApp</h4>
              <div class="ci-wa-btn-container">
                <?php foreach ($waAdmins as $adm): 
                  $btnTitle = $adm['name'];
                  if (stripos($btnTitle, 'ADMIN 1') !== false || stripos($btnTitle, 'ADMIN 2') !== false) {
                    $btnTitle = str_ireplace(['ADMIN 1', 'ADMIN 2'], 'ADMIN WHATSAPP', $btnTitle);
                  } elseif (stripos($btnTitle, 'ADMIN WHATSAPP') === false && stripos($btnTitle, 'ADMIN') === false) {
                    $btnTitle = 'ADMIN WHATSAPP (' . strtoupper($btnTitle) . ')';
                  }
                ?>
                  <a href="https://wa.me/<?= htmlspecialchars($adm['clean']) ?>" target="_blank" rel="noopener noreferrer" class="ci-wa-card">
                    <span class="ci-wa-title"><?= htmlspecialchars($btnTitle) ?></span>
                    <span class="ci-wa-dots">
                      <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
                        <circle cx="12" cy="5" r="2"></circle>
                        <circle cx="12" cy="12" r="2"></circle>
                        <circle cx="12" cy="19" r="2"></circle>
                      </svg>
                    </span>
                  </a>
                <?php endforeach; ?>
              </div>
            </div>
          </li>

          <li class="ci-item">
            <div class="ci-icon">
              <!-- Email Icon -->
              <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                <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"></path>
                <polyline points="22,6 12,13 2,6"></polyline>
              </svg>
            </div>
            <div class="ci-text">
              <h4>Email</h4>
              <p><a href="<?= get_email_link() ?>" style="color:inherit;text-decoration:none;"><?= htmlspecialchars(get_setting('email', 'info@travelica.id')) ?></a></p>
            </div>
          </li>
          
        </ul>
      </div>

      <!-- Google Maps Embed (Dynamic from Settings) -->
      <div class="contact-map-wrapper">
        <?= get_maps_embed_html() ?>
      </div>

    </div>
  </section>

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