<?php
session_start(); 
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

$db_host = 'localhost';
$db_user = 'u427625983_schoolinmycity';
$db_pass = 'K#$%^tfvgyt657guvgGG';
$db_name = 'u427625983_schoolinmycity';

$success_message = '';
$error_message   = '';
$form_errors     = [];

if (isset($_SESSION['cp_success'])) {
    $success_message = $_SESSION['cp_success'];
    unset($_SESSION['cp_success']);
}

function getDB($db_host, $db_user, $db_pass, $db_name) {
    $conn = new mysqli($db_host, $db_user, $db_pass, $db_name);
    if ($conn->connect_error) return null;
    $conn->set_charset('utf8mb4');
    return $conn;
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $conference_name    = trim($_POST['conference_name']    ?? '');
    $conference_city    = trim($_POST['conference_city']    ?? '');
    $conference_country = trim($_POST['conference_country'] ?? '');
    $conference_website = trim($_POST['conference_website'] ?? '');
    $organizer_name     = trim($_POST['organizer_name']     ?? '');
    $organizer_email    = trim($_POST['organizer_email']    ?? '');
    $organizer_phone    = trim($_POST['organizer_phone']    ?? '');
    $expected_papers    = intval($_POST['expected_papers']  ?? 0);
    $special_requests   = trim($_POST['special_requests']   ?? '');
    $date_start_raw     = trim($_POST['conference_date_start'] ?? '');
    $date_end_raw       = trim($_POST['conference_date_end']   ?? '');
    $pub_date_raw       = trim($_POST['preferred_pub_date']    ?? '');
    $agreed_terms       = isset($_POST['agree_terms']) ? 1 : 0;

    if (empty($conference_name))    $form_errors['conference_name']    = 'Conference name is required.';
    if (empty($conference_city))    $form_errors['conference_city']    = 'Conference city is required.';
    if (empty($conference_country)) $form_errors['conference_country'] = 'Please select a country.';
    if (empty($conference_website)) $form_errors['conference_website'] = 'Conference website is required.';
    if (empty($organizer_name))     $form_errors['organizer_name']     = "Organizer's name is required.";
    if (empty($organizer_email))    $form_errors['organizer_email']    = "Organizer's email is required.";
    elseif (!filter_var($organizer_email, FILTER_VALIDATE_EMAIL))
        $form_errors['organizer_email'] = 'Please enter a valid email address.';
    if (!empty($conference_website) && !filter_var($conference_website, FILTER_VALIDATE_URL))
        $form_errors['conference_website'] = 'Please enter a valid URL (include https://).';
    if (!$agreed_terms)
        $form_errors['agree_terms'] = 'You must agree to the terms and conditions.';

    $parseDate = function($val) {
        if (!$val) return null;
        foreach (['Y-m-d','m/d/Y','d/m/Y'] as $fmt) {
            $d = DateTime::createFromFormat($fmt, $val);
            if ($d) return $d->format('Y-m-d');
        }
        return null;
    };
    $conference_date_start = $parseDate($date_start_raw);
    $conference_date_end   = $parseDate($date_end_raw);
    $preferred_pub_date    = $parseDate($pub_date_raw);

    if (empty($form_errors)) {
        $conn = getDB($db_host, $db_user, $db_pass, $db_name);
        if (!$conn) {
            $error_message = 'Database connection failed. Please try again later.';
        } else {
            $inquiry_id  = 'CP-' . date('Y') . '-' . strtoupper(substr(uniqid(), -6));
            $phone_val   = $organizer_phone ?: null;
            $papers_val  = $expected_papers ?: null;
            $special_val = $special_requests ?: null;

            $stmt = $conn->prepare(
                "INSERT INTO conference_proceedings
                 (inquiry_id, conference_name, conference_date_start, conference_date_end,
                  conference_city, conference_country, conference_website,
                  organizer_name, organizer_email, organizer_phone,
                  expected_papers, preferred_pub_date, special_requests)
                 VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"
            );

            if (!$stmt) {
                $error_message = 'DB prepare error: ' . $conn->error;
            } else {
                $stmt->bind_param('ssssssssssiss',
                    $inquiry_id, $conference_name, $conference_date_start, $conference_date_end,
                    $conference_city, $conference_country, $conference_website,
                    $organizer_name, $organizer_email, $phone_val,
                    $papers_val, $preferred_pub_date, $special_val
                );
                if ($stmt->execute()) {
                    $_SESSION['cp_success'] = 'Your inquiry has been submitted successfully! Your reference ID is <strong>' . htmlspecialchars($inquiry_id) . '</strong>. Our team will contact you shortly.';
                    $stmt->close();
                    $conn->close();
                    header('Location: ' . $_SERVER['PHP_SELF']);
                    exit;
                } else {
                    $error_message = 'Failed to save. Please try again. (' . $stmt->error . ')';
                }
                $stmt->close();
            }
            $conn->close();
        }
    }
}

function val($key, $default = '') {
    return htmlspecialchars($_POST[$key] ?? $default);
}

$page_title = "Conference Proceedings - Communeglobal";
include 'include/header.php';

$countries = ["Afghanistan","Albania","Algeria","Andorra","Angola","Antigua and Barbuda",
"Argentina","Armenia","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh",
"Barbados","Belarus","Belgium","Belize","Benin","Bhutan","Bolivia","Bosnia and Herzegovina",
"Botswana","Brazil","Brunei","Bulgaria","Burkina Faso","Burundi","Cabo Verde","Cambodia",
"Cameroon","Canada","Central African Republic","Chad","Chile","China","Colombia","Comoros",
"Congo, DR","Congo, Republic","Costa Rica","Côte d'Ivoire","Croatia","Cuba","Cyprus",
"Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor","Ecuador",
"Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Eswatini","Ethiopia","Fiji",
"Finland","France","Gabon","Gambia","Georgia","Germany","Ghana","Greece","Grenada",
"Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hungary","Iceland",
"India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Jamaica","Japan","Jordan",
"Kazakhstan","Kenya","Kiribati","Korea, North","Korea, South","Kosovo","Kuwait","Kyrgyzstan",
"Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg",
"Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania",
"Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Montenegro","Morocco",
"Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","New Zealand","Nicaragua",
"Niger","Nigeria","North Macedonia","Norway","Oman","Pakistan","Palau","Panama",
"Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Qatar","Romania",
"Russia","Rwanda","Saint Kitts and Nevis","Saint Lucia","Saint Vincent","Samoa","San Marino",
"Sao Tome and Principe","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone",
"Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","Spain",
"Sri Lanka","Sudan","Suriname","Sweden","Switzerland","Syria","Taiwan","Tajikistan",
"Tanzania","Thailand","Togo","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan",
"Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States",
"Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Yemen","Zambia","Zimbabwe"];
?>

<style>
.cp-wrap *,.cp-wrap *::before,.cp-wrap *::after{box-sizing:border-box}
.cp-wrap{
  --cp-primary:#1a4fa0;--cp-pdark:#0e3270;--cp-plight:#3a6ec8;
  --cp-red:#e84545;--cp-green:#1ab782;--cp-gold:#f5c518;
  --cp-bg:#f0f4fb;--cp-card:#fff;--cp-border:#d6dff0;
  --cp-text:#1a2340;--cp-muted:#6b7a99;
  --cp-shadow:0 4px 24px rgba(26,79,160,.10);
  --cp-shadowlg:0 12px 40px rgba(26,79,160,.16);
  --cp-r:14px;--cp-rs:8px;
  background:var(--cp-bg);color:var(--cp-text);
  font-family:'Inter',sans-serif;line-height:1.6;
}

/* Hero */
.cp-hero{background:linear-gradient(135deg,#0e3270 0%,#1a4fa0 45%,#2563c8 100%);overflow:hidden;position:relative}
.cp-hero-overlay{position:absolute;inset:0;background:url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none'%3E%3Cg fill='%23fff' fill-opacity='.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")}
.cp-hero-inner{position:relative;z-index:1;max-width:1200px;margin:0 auto;padding:56px 32px 48px;display:flex;align-items:center;justify-content:space-between;gap:40px;flex-wrap:wrap}
.cp-hero-text h1{font-family:'Poppins',sans-serif;font-size:clamp(2rem,4vw,3rem);font-weight:800;color:#fff;line-height:1.2;margin:0 0 12px}
.cp-hero-text h1 span{color:#f5c518}
.cp-hero-text p{color:rgba(255,255,255,.82);font-size:1.1rem;max-width:560px;line-height:1.7;margin:0}
.cp-badges{display:flex;flex-wrap:wrap;gap:10px;margin-top:24px}
.cp-badge{background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.2);color:#fff;padding:6px 16px;border-radius:30px;font-size:.82rem;font-weight:500;display:inline-flex;align-items:center;gap:6px}
.cp-badge svg{width:14px;height:14px;fill:none;stroke:#f5c518;stroke-width:2}
.cp-stats{display:flex;gap:24px;flex-wrap:wrap}
.cp-stat{text-align:center;background:rgba(255,255,255,.1);border:1px solid rgba(255,255,255,.15);padding:20px 28px;border-radius:12px}
.cp-stat-num{font-family:'Poppins',sans-serif;font-size:2rem;font-weight:800;color:#f5c518;display:block}
.cp-stat-lbl{color:rgba(255,255,255,.8);font-size:.8rem;font-weight:500}

/* Benefits strip */
.cp-strip{background:#0e3270}
.cp-strip-inner{max-width:1200px;margin:0 auto;padding:0 32px;display:flex;overflow-x:auto}
.cp-benefit{display:flex;align-items:center;gap:10px;padding:16px 28px;border-right:1px solid rgba(255,255,255,.1);white-space:nowrap;color:rgba(255,255,255,.9);font-size:.87rem;font-weight:500;flex-shrink:0}
.cp-benefit:last-child{border-right:none}
.cp-bico{width:28px;height:28px;background:rgba(245,197,24,.15);border-radius:50%;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.cp-bico svg{width:14px;height:14px;stroke:#f5c518;fill:none;stroke-width:2}

/* ── MAIN BODY & LAYOUT ── */
.cp-body{max-width:1200px;margin:0 auto;padding:40px 24px 60px}

/* nsidebar 25% | form 75% */
.cp-main-layout{
  display:grid;
  grid-template-columns:25% 1fr;
  gap:24px;
  align-items:start;
}
/* Contain nsidebar inside its grid cell — prevents overflow/overlap */
.cp-main-layout > div:first-child{
  min-width:0;
  width:100%;
  overflow:visible;
  position:relative;
}
/* Force form column to not bleed left */
.cp-main-layout > div:last-child{
  min-width:0;
  width:100%;
}
/* Override any fixed/absolute positioning nsidebar may apply to itself */
.cp-main-layout > div:first-child > *{
  position:relative !important;
  width:100% !important;
  max-width:100% !important;
  left:auto !important;
  right:auto !important;
}
@media(max-width:960px){
  .cp-main-layout{grid-template-columns:1fr}
}

/* Form card */
.cp-fcard{background:var(--cp-card);border:1px solid var(--cp-border);border-radius:var(--cp-r);box-shadow:var(--cp-shadowlg);overflow:hidden}
.cp-fhead{background:linear-gradient(135deg,var(--cp-primary) 0%,var(--cp-plight) 100%);padding:24px 28px}
.cp-fhead h3{font-family:'Poppins',sans-serif;color:#fff;font-size:1.25rem;font-weight:700;margin:0 0 4px}
.cp-fhead p{color:rgba(255,255,255,.8);font-size:.85rem;margin:0}
.cp-fbody{padding:28px}

/* Alerts */
.cp-alert{padding:16px 20px;border-radius:var(--cp-rs);font-size:.9rem;line-height:1.5;margin-bottom:20px;border-left:4px solid;display:flex;gap:12px;align-items:flex-start}
.cp-alert-ok{background:#f0fdf7;border-color:var(--cp-green);color:#0d6b46}
.cp-alert-err{background:#fff5f5;border-color:var(--cp-red);color:#b91c1c}
.cp-alert-ico{font-size:1.2rem;flex-shrink:0}

/* Section labels */
.cp-slbl{display:flex;align-items:center;gap:8px;font-weight:700;font-size:.78rem;text-transform:uppercase;letter-spacing:.08em;color:var(--cp-primary);margin:22px 0 14px;padding-bottom:8px;border-bottom:2px solid #e8f0fe}
.cp-slbl:first-child{margin-top:0}
.cp-slbl svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:2}

/* Fields */
.cp-field{margin-bottom:16px}
.cp-field label{display:block;font-size:.82rem;font-weight:600;color:var(--cp-text);margin-bottom:6px}
.cp-req{color:var(--cp-red);margin-left:2px}
.cp-field input[type=text],
.cp-field input[type=email],
.cp-field input[type=tel],
.cp-field input[type=url],
.cp-field input[type=date],
.cp-field input[type=number],
.cp-field select,
.cp-field textarea{
  width:100%;padding:10px 14px;border:1.5px solid var(--cp-border);
  border-radius:var(--cp-rs);font-family:'Inter',sans-serif;font-size:.92rem;
  color:var(--cp-text);background:#fafbff;transition:border-color .2s,box-shadow .2s;outline:none
}
.cp-field input:focus,.cp-field select:focus,.cp-field textarea:focus{border-color:var(--cp-primary);background:#fff;box-shadow:0 0 0 3px rgba(26,79,160,.12)}
.cp-field textarea{resize:vertical;min-height:90px}
.cp-emsg{color:var(--cp-red);font-size:.78rem;margin-top:4px;display:none}
.cp-field.cp-has-err input,.cp-field.cp-has-err select,.cp-field.cp-has-err textarea{border-color:var(--cp-red);background:#fff8f8}
.cp-field.cp-has-err .cp-emsg{display:block}
.cp-hint{font-size:.75rem;color:var(--cp-muted);margin-top:4px}
.cp-row{display:grid;grid-template-columns:1fr 1fr;gap:14px}
@media(max-width:480px){.cp-row{grid-template-columns:1fr}}
.cp-dpair{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.cp-dsub{font-size:.72rem;color:var(--cp-muted);margin-top:3px}
.cp-char{font-size:.74rem;color:var(--cp-muted);text-align:right;margin-top:3px}

/* Select arrow */
.cp-selwrap{position:relative}
.cp-selwrap::after{content:'';position:absolute;right:14px;top:50%;transform:translateY(-50%);width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid var(--cp-muted);pointer-events:none}
.cp-selwrap select{appearance:none;-webkit-appearance:none;padding-right:36px}

/* Terms */
.cp-terms-wrap{display:flex;align-items:flex-start;gap:10px;padding:14px;background:#f0f4fa;border-radius:var(--cp-rs);border:1.5px solid var(--cp-border);margin-bottom:4px}
.cp-terms-wrap input[type=checkbox]{width:18px;height:18px;flex-shrink:0;margin-top:2px;accent-color:var(--cp-primary);cursor:pointer}
.cp-terms-wrap label{font-size:.84rem;color:var(--cp-muted);cursor:pointer;font-weight:400;text-transform:none;letter-spacing:0}
.cp-terms-wrap label a{color:var(--cp-primary);font-weight:600;text-decoration:none}
.cp-field.cp-has-err .cp-terms-wrap{border-color:var(--cp-red);background:#fff5f5}

/* Submit button */
.cp-btn-submit{display:block;width:100%;padding:14px;background:linear-gradient(135deg,var(--cp-primary) 0%,var(--cp-plight) 100%);color:#fff;border:none;border-radius:var(--cp-rs);font-family:'Poppins',sans-serif;font-size:1rem;font-weight:700;cursor:pointer;letter-spacing:.3px;transition:transform .15s,box-shadow .15s,opacity .15s;box-shadow:0 4px 16px rgba(26,79,160,.35)}
.cp-btn-submit:hover{transform:translateY(-2px);box-shadow:0 8px 24px rgba(26,79,160,.4);opacity:.92}
.cp-req-note{font-size:.76rem;color:var(--cp-muted);text-align:center;margin-top:12px}

/* Contact & info cards */
.cp-contact-card{background:var(--cp-card);border:1px solid var(--cp-border);border-radius:var(--cp-r);padding:20px;margin-top:20px;display:flex;align-items:center;gap:14px}
.cp-contact-ico{width:44px;height:44px;background:#e8f0fe;border-radius:10px;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.cp-contact-ico svg{width:22px;height:22px;stroke:var(--cp-primary);fill:none;stroke-width:2}
.cp-contact-card p{font-size:.82rem;color:var(--cp-muted);margin:0}
.cp-contact-card strong{display:block;color:var(--cp-primary);font-size:.88rem}
.cp-info-card{background:linear-gradient(135deg,#0e3270 0%,#1a4fa0 100%);border-radius:var(--cp-r);padding:24px;color:#fff;margin-top:20px}
.cp-info-card h4{font-family:'Poppins',sans-serif;font-size:1rem;margin:0 0 14px;color:#f5c518}
.cp-info-card ul{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:10px}
.cp-info-card ul li{display:flex;align-items:center;gap:10px;font-size:.87rem;color:rgba(255,255,255,.9)}
.cp-info-card ul li svg{width:16px;height:16px;stroke:#f5c518;fill:none;stroke-width:2;flex-shrink:0}

@media(max-width:768px){
  .cp-hero-inner{padding:36px 20px 32px}
  .cp-stats{justify-content:center}
  .cp-body{padding:24px 16px 40px}
  .cp-fbody{padding:20px}
}
@media(max-width:520px){
  .cp-hero-text h1{font-size:1.7rem}
  .cp-stat{padding:14px 18px}
  .cp-stat-num{font-size:1.5rem}
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">

<div class="cp-wrap">

<!-- HERO -->
<div class="cp-hero">
  <div class="cp-hero-overlay"></div>
  <div class="cp-hero-inner">
    <div class="cp-hero-text">
      <h1>Publish Your Conference<br><span>Proceedings With Us</span></h1>
      <p>Enhance the reach and impact of your conference by partnering with Communeglobal to publish your proceedings online with a global audience.</p>
      <div class="cp-badges">
        <span class="cp-badge"><svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg> Open Access</span>
        <span class="cp-badge"><svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg> DOI for Every Article</span>
        <span class="cp-badge"><svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg> Global Indexing</span>
        <span class="cp-badge"><svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg> Fast Publication</span>
      </div>
    </div>
    <div class="cp-stats">
      <div class="cp-stat"><span class="cp-stat-num">500+</span><span class="cp-stat-lbl">Conferences Published</span></div>
      <div class="cp-stat"><span class="cp-stat-num">50+</span><span class="cp-stat-lbl">Countries Reached</span></div>
      <div class="cp-stat"><span class="cp-stat-num">10K+</span><span class="cp-stat-lbl">Articles Published</span></div>
    </div>
  </div>
</div>

<!-- BENEFITS STRIP -->
<div class="cp-strip">
  <div class="cp-strip-inner">
    <div class="cp-benefit"><div class="cp-bico"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 8v4l3 3"/></svg></div> Quick Turnaround</div>
    <div class="cp-benefit"><div class="cp-bico"><svg viewBox="0 0 24 24"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/></svg></div> Indexed in Major Databases</div>
    <div class="cp-benefit"><div class="cp-bico"><svg viewBox="0 0 24 24"><path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/></svg></div> Rigorous Quality Review</div>
    <div class="cp-benefit"><div class="cp-bico"><svg viewBox="0 0 24 24"><path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z"/></svg></div> Dedicated Landing Page</div>
    <div class="cp-benefit"><div class="cp-bico"><svg viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg></div> Publication Certificate</div>
  </div>
</div>

<!-- MAIN BODY -->
<div class="cp-body">
  <div class="cp-main-layout">

    <!-- LEFT COLUMN: nsidebar (25%) -->
    <div>
      <?php include __DIR__ . '/include/nsidebar.php'; ?>
    </div>

    <!-- RIGHT COLUMN: Form (75%) -->
    <div>
      <div class="cp-fcard">
        <div class="cp-fhead">
          <h3>Conference Proceedings Inquiry</h3>
          <p>Fill out the form below and our team will respond promptly.</p>
        </div>
        <div class="cp-fbody">

          <?php if ($success_message): ?>
          <div class="cp-alert cp-alert-ok">
            <span class="cp-alert-ico">&#x2705;</span>
            <div><?= $success_message ?></div>
          </div>
          <?php endif; ?>

          <?php if ($error_message): ?>
          <div class="cp-alert cp-alert-err">
            <span class="cp-alert-ico">&#x26A0;&#xFE0F;</span>
            <div><?= htmlspecialchars($error_message) ?></div>
          </div>
          <?php endif; ?>

          <?php if (!$success_message): ?>
          <form method="POST" action="" novalidate>

            <!-- Conference Details -->
            <div class="cp-slbl">
              <svg viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>
              Conference Details
            </div>

            <div class="cp-field <?= isset($form_errors['conference_name']) ? 'cp-has-err' : '' ?>">
              <label>Conference Name <span class="cp-req">*</span></label>
              <input type="text" name="conference_name" placeholder="Full name of your conference" maxlength="255" value="<?= val('conference_name') ?>">
              <div class="cp-emsg"><?= $form_errors['conference_name'] ?? '' ?></div>
            </div>

            <div class="cp-field">
              <label>Conference Dates</label>
              <div class="cp-dpair">
                <div>
                  <input type="date" name="conference_date_start" value="<?= val('conference_date_start') ?>">
                  <div class="cp-dsub">Start Date</div>
                </div>
                <div>
                  <input type="date" name="conference_date_end" value="<?= val('conference_date_end') ?>">
                  <div class="cp-dsub">End Date</div>
                </div>
              </div>
            </div>

            <div class="cp-row">
              <div class="cp-field <?= isset($form_errors['conference_city']) ? 'cp-has-err' : '' ?>">
                <label>Conference City <span class="cp-req">*</span></label>
                <input type="text" name="conference_city" placeholder="e.g. Kuala Lumpur" maxlength="100" value="<?= val('conference_city') ?>">
                <div class="cp-emsg"><?= $form_errors['conference_city'] ?? '' ?></div>
              </div>
              <div class="cp-field <?= isset($form_errors['conference_country']) ? 'cp-has-err' : '' ?>">
                <label>Country <span class="cp-req">*</span></label>
                <div class="cp-selwrap">
                  <select name="conference_country">
                    <option value="">Select country</option>
                    <?php foreach($countries as $c): ?>
                    <option value="<?= htmlspecialchars($c) ?>" <?= (($_POST['conference_country'] ?? '') === $c) ? 'selected' : '' ?>><?= htmlspecialchars($c) ?></option>
                    <?php endforeach; ?>
                  </select>
                </div>
                <div class="cp-emsg"><?= $form_errors['conference_country'] ?? '' ?></div>
              </div>
            </div>

            <div class="cp-field <?= isset($form_errors['conference_website']) ? 'cp-has-err' : '' ?>">
              <label>Conference Website <span class="cp-req">*</span></label>
              <input type="url" name="conference_website" placeholder="https://yourconference.com" value="<?= val('conference_website') ?>">
              <div class="cp-emsg"><?= $form_errors['conference_website'] ?? '' ?></div>
            </div>

            <!-- Organizer Information -->
            <div class="cp-slbl">
              <svg viewBox="0 0 24 24"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
              Organizer Information
            </div>

            <div class="cp-field <?= isset($form_errors['organizer_name']) ? 'cp-has-err' : '' ?>">
              <label>Organizer's Name <span class="cp-req">*</span></label>
              <input type="text" name="organizer_name" placeholder="Primary contact person" maxlength="255" value="<?= val('organizer_name') ?>">
              <div class="cp-emsg"><?= $form_errors['organizer_name'] ?? '' ?></div>
            </div>

            <div class="cp-field <?= isset($form_errors['organizer_email']) ? 'cp-has-err' : '' ?>">
              <label>Organizer's Email <span class="cp-req">*</span></label>
              <input type="email" name="organizer_email" placeholder="email@yourorg.com" value="<?= val('organizer_email') ?>">
              <div class="cp-emsg"><?= $form_errors['organizer_email'] ?? '' ?></div>
            </div>

            <div class="cp-field">
              <label>Organizer's Phone</label>
              <input type="tel" name="organizer_phone" placeholder="+1 (555) 000-0000" value="<?= val('organizer_phone') ?>">
            </div>

            <!-- Publication Details -->
            <div class="cp-slbl">
              <svg viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg>
              Publication Details
            </div>

            <div class="cp-row">
              <div class="cp-field">
                <label>Expected Papers</label>
                <input type="number" name="expected_papers" placeholder="e.g. 30" min="1" max="500" value="<?= val('expected_papers') ?>">
                <div class="cp-hint">Estimated number</div>
              </div>
              <div class="cp-field <?= isset($form_errors['preferred_pub_date']) ? 'cp-has-err' : '' ?>">
                <label>Preferred Pub. Date</label>
                <input type="date" name="preferred_pub_date" value="<?= val('preferred_pub_date') ?>">
                <div class="cp-emsg"><?= $form_errors['preferred_pub_date'] ?? '' ?></div>
              </div>
            </div>

            <!-- Additional Info -->
            <div class="cp-slbl">
              <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
              Additional Information
            </div>

            <div class="cp-field">
              <label>Special Requests or Notes</label>
              <textarea name="special_requests" id="cpTextarea" placeholder="Any additional information or special requests..." maxlength="2000"><?= val('special_requests') ?></textarea>
              <div class="cp-char"><span id="cpCharCount">0</span> / 2000</div>
            </div>

            <!-- Terms -->
            <div class="cp-field <?= isset($form_errors['agree_terms']) ? 'cp-has-err' : '' ?>">
              <div class="cp-terms-wrap">
                <input type="checkbox" name="agree_terms" id="cpTerms" value="1" <?= isset($_POST['agree_terms']) ? 'checked' : '' ?>>
                <label for="cpTerms">I agree to the <a href="#" target="_blank">Terms &amp; Conditions</a> and consent to being contacted by the Communeglobal editorial team regarding my submission.</label>
              </div>
              <div class="cp-emsg"><?= $form_errors['agree_terms'] ?? '' ?></div>
            </div>

            <button type="submit" class="cp-btn-submit">Submit Inquiry &rarr;</button>
            <p class="cp-req-note"><span style="color:var(--cp-red)">*</span> Fields marked with an asterisk are required.</p>

          </form>
          <?php endif; ?>

        </div>
      </div>

      <div class="cp-contact-card">
        <div class="cp-contact-ico"><svg 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><p>Prefer to email us directly?</p><strong>editorialoffice@communeglobal.com</strong></div>
      </div>

      <div class="cp-info-card">
        <h4>&#x1F4CB; What Happens Next?</h4>
        <ul>
          <li><svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg> Our team reviews your submission within 24-48 hours</li>
          <li><svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg> We send a detailed publishing proposal</li>
          <li><svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg> Agreement and onboarding process begins</li>
          <li><svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg> Authors submit papers via our system</li>
          <li><svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg> Proceedings go live with DOI &amp; certificates</li>
        </ul>
      </div>

    </div><!-- /right col -->

  </div><!-- /cp-main-layout -->
  
  
</div><!-- /cp-body -->
</div><!-- /cp-wrap -->

<script>
(function() {
  var ta = document.getElementById('cpTextarea');
  var cc = document.getElementById('cpCharCount');
  if (ta && cc) {
    cc.textContent = ta.value.length;
    ta.addEventListener('input', function() { cc.textContent = ta.value.length; });
  }
})();
</script>

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