<?php
$lang = $current_lang ?? 'en';
$isRtl = $is_rtl ?? false;
?>
<!DOCTYPE html>
<html lang="<?php echo $lang; ?>" dir="<?php echo $isRtl ? 'rtl' : 'ltr'; ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $title ?? 'Contact | Global ERP'; ?></title>
    <link rel="icon" href="<?php echo base_url('assets/images/favicon.ico'); ?>">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Cairo:wght@300;400;600;700;900&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="<?php echo base_url('assets/css/landing_page_v2.css'); ?>">
    <?php if ($isRtl): ?><style>body { font-family: 'Cairo','Inter',sans-serif; }</style><?php endif; ?>
</head>
<body class="landing-page <?php echo $isRtl ? 'rtl' : ''; ?>">
    <?php $this->load->view('public_site/partials/top_nav', ['lang'=>$lang,'isRtl'=>$isRtl]); ?>

    <section class="features-section" style="padding-top: 160px;">
        <div class="container">
            <div class="section-header">
                <h2 class="section-title"><?php echo $lang==='ar' ? 'اتصل بنا' : 'Contact Us'; ?></h2>
                <p class="section-description">
                    <?php echo $lang==='ar' ? 'يسعدنا تواصلك. املأ النموذج أو تواصل مباشرة عبر الهاتف أو البريد.' : 'We’d love to hear from you. Fill the form or contact us directly by phone or email.'; ?>
                </p>
            </div>

            <?php if (!empty($form_success)): ?>
                <div class="alert-success"><?php echo htmlspecialchars($form_success); ?></div>
            <?php endif; ?>
            <?php if (!empty($form_errors)): ?>
                <div class="alert-danger">
                    <ul>
                        <?php foreach ($form_errors as $err): ?>
                            <li><?php echo htmlspecialchars($err); ?></li>
                        <?php endforeach; ?>
                    </ul>
                </div>
            <?php endif; ?>

            <div class="contact-grid">
                <div class="contact-card">
                    <h3 class="contact-title"><i class="fas fa-paper-plane"></i> <?php echo $lang==='ar' ? 'أرسل رسالة' : 'Send a Message'; ?></h3>
                    <form method="post" action="<?php echo site_url('contact'); ?>" novalidate>
                        <input type="text" name="website" autocomplete="off" style="display:none" tabindex="-1">
                        <div class="form-row">
                            <div class="form-group">
                                <label class="form-label" for="name"><?php echo $lang==='ar' ? 'الاسم' : 'Name'; ?> *</label>
                                <input required type="text" id="name" name="name" class="form-control" value="<?php echo htmlspecialchars($old['name'] ?? ''); ?>" />
                            </div>
                            <div class="form-group">
                                <label class="form-label" for="email">Email *</label>
                                <input required type="email" id="email" name="email" class="form-control" value="<?php echo htmlspecialchars($old['email'] ?? ''); ?>" />
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group">
                                <label class="form-label" for="phone"><?php echo $lang==='ar' ? 'الهاتف' : 'Phone'; ?></label>
                                <input type="tel" id="phone" name="phone" class="form-control" value="<?php echo htmlspecialchars($old['phone'] ?? ''); ?>" />
                            </div>
                            <div class="form-group">
                                <label class="form-label" for="subject"><?php echo $lang==='ar' ? 'الموضوع' : 'Subject'; ?></label>
                                <input type="text" id="subject" name="subject" class="form-control" value="<?php echo htmlspecialchars($old['subject'] ?? ''); ?>" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="form-label" for="message"><?php echo $lang==='ar' ? 'الرسالة' : 'Message'; ?> *</label>
                            <textarea required id="message" name="message" rows="6" class="form-control"><?php echo htmlspecialchars($old['message'] ?? ''); ?></textarea>
                        </div>
                        <div class="form-actions">
                            <button type="submit" class="btn-hero btn-primary">
                                <i class="fas fa-paper-plane"></i> <?php echo $lang==='ar' ? 'إرسال' : 'Send'; ?>
                            </button>
                        </div>
                    </form>
                </div>

                <div class="contact-card info">
                    <h3 class="contact-title"><i class="fas fa-headset"></i> <?php echo $lang==='ar' ? 'معلومات التواصل' : 'Contact Details'; ?></h3>
                    <ul class="contact-list">
                        <li><i class="fas fa-phone"></i> <a href="tel:+966500000000">+966 50 000 0000</a></li>
                        <li><i class="fab fa-whatsapp"></i> <a target="_blank" href="https://wa.me/966500000000">WhatsApp</a></li>
                        <li><i class="fas fa-envelope"></i> <a href="mailto:info@globalerp.com">info@globalerp.com</a></li>
                        <li><i class="fas fa-map-marker-alt"></i> Riyadh, KSA</li>
                        <li><i class="fas fa-clock"></i> <?php echo $lang==='ar' ? 'الإثنين-الجمعة: 9ص-6م' : 'Mon-Fri: 9am - 6pm'; ?></li>
                    </ul>
                    <div class="contact-cta">
                        <a class="btn-hero btn-outline" href="tel:+966500000000"><i class="fas fa-phone"></i> <?php echo $lang==='ar' ? 'اتصل الآن' : 'Call Now'; ?></a>
                        <a class="btn-hero btn-primary" target="_blank" href="https://wa.me/966500000000"><i class="fab fa-whatsapp"></i> WhatsApp</a>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <?php $this->load->view('public_site/partials/footer', ['lang'=>$lang]); ?>
</body>
</html>