<?php
// Mesaje de stare (redirect dupa trimitere)
$form_sent = isset($_GET['trimis']) && $_GET['trimis'] === '1';
$form_error = isset($_GET['eroare']) ? $_GET['eroare'] : '';
?>
<!-- Page Header -->
<section class="page-header">
    <div class="container">
        <p class="section-label"><?php echo $L['contact_label']; ?></p>
        <h1><?php echo $L['contact_h1']; ?></h1>
        <p class="page-header-desc"><?php echo $L['contact_desc']; ?></p>
    </div>
</section>

<!-- Contact -->
<section class="section">
    <div class="container">
        <div class="contact-layout">

            <!-- Informații contact -->
            <div class="contact-info">
                <h2><?php echo $L['contact_info_h2']; ?></h2>
                <p><?php echo $L['contact_info_p']; ?></p>

                <div class="contact-details">
                    <div class="contact-item">
                        <div class="contact-icon">
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"/><path d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
                        </div>
                        <div>
                            <h4><?php echo $L['contact_office_h']; ?></h4>
                            <p><?php echo $L['contact_office_p']; ?></p>
                        </div>
                    </div>

                    <div class="contact-item">
                        <div class="contact-icon">
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/></svg>
                        </div>
                        <div>
                            <h4><?php echo $L['contact_phone_h']; ?></h4>
                            <p><a href="tel:+40747333165">+40 747.333.165</a></p>
                        </div>
                    </div>

                    <div class="contact-item">
                        <div class="contact-icon">
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/></svg>
                        </div>
                        <div>
                            <h4><?php echo $L['contact_email_h']; ?></h4>
                            <p><a href="mailto:office@petcupartners.ro">office@petcupartners.ro</a></p>
                        </div>
                    </div>

                    <div class="contact-item">
                        <div class="contact-icon">
                            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
                        </div>
                        <div>
                            <h4><?php echo $L['contact_schedule_h']; ?></h4>
                            <p><?php echo $L['contact_schedule_p']; ?></p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Formular contact -->
            <div class="contact-form-wrapper">
                <h2><?php echo $L['contact_form_h2']; ?></h2>

                <?php if ($form_sent): ?>
                    <div class="form-success" style="display:block; margin-bottom: 1.5rem;">
                        <p><?php echo $L['contact_form_success']; ?></p>
                    </div>
                <?php endif; ?>

                <?php if ($form_error): ?>
                    <div class="form-error" style="margin-bottom: 1.5rem; padding: 1rem; background: #fdf0f0; border: 1px solid #f0c0c0; color: #a02020;">
                        <p style="margin:0;">
                            <?php
                            $msgs = [
                                'campuri'   => $L['contact_err_fields'],
                                'email'     => $L['contact_err_email'],
                                'trimitere' => $L['contact_err_send'],
                            ];
                            echo isset($msgs[$form_error]) ? $msgs[$form_error] : $L['contact_err_generic'];
                            ?>
                        </p>
                    </div>
                <?php endif; ?>

                <form class="contact-form" action="trimite-mesaj.php" method="POST">
                    <input type="hidden" name="lang" value="<?php echo htmlspecialchars($lang, ENT_QUOTES, 'UTF-8'); ?>">
                    <div class="form-row">
                        <div class="form-group">
                            <label for="nume"><?php echo $L['form_name_label']; ?></label>
                            <input type="text" id="nume" name="nume" required placeholder="<?php echo htmlspecialchars($L['form_name_placeholder'], ENT_QUOTES, 'UTF-8'); ?>">
                        </div>
                        <div class="form-group">
                            <label for="telefon"><?php echo $L['form_phone_label']; ?></label>
                            <input type="tel" id="telefon" name="telefon" required placeholder="<?php echo htmlspecialchars($L['form_phone_placeholder'], ENT_QUOTES, 'UTF-8'); ?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="email"><?php echo $L['form_email_label']; ?></label>
                        <input type="email" id="email" name="email" required placeholder="<?php echo htmlspecialchars($L['form_email_placeholder'], ENT_QUOTES, 'UTF-8'); ?>">
                    </div>
                    <div class="form-group">
                        <label for="subiect"><?php echo $L['form_subject_label']; ?></label>
                        <select id="subiect" name="subiect">
                            <option value=""><?php echo $L['form_subject_default']; ?></option>
                            <option value="<?php echo htmlspecialchars($L['form_subject_opt_business'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo $L['form_subject_opt_business']; ?></option>
                            <option value="<?php echo htmlspecialchars($L['form_subject_opt_disputes'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo $L['form_subject_opt_disputes']; ?></option>
                            <option value="<?php echo htmlspecialchars($L['form_subject_opt_procurement'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo $L['form_subject_opt_procurement']; ?></option>
                            <option value="<?php echo htmlspecialchars($L['form_subject_opt_labor'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo $L['form_subject_opt_labor']; ?></option>
                            <option value="<?php echo htmlspecialchars($L['form_subject_opt_regulatory'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo $L['form_subject_opt_regulatory']; ?></option>
                            <option value="<?php echo htmlspecialchars($L['form_subject_opt_consumer'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo $L['form_subject_opt_consumer']; ?></option>
                            <option value="<?php echo htmlspecialchars($L['form_subject_opt_fiscal'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo $L['form_subject_opt_fiscal']; ?></option>
                            <option value="<?php echo htmlspecialchars($L['form_subject_opt_customs'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo $L['form_subject_opt_customs']; ?></option>
                            <option value="<?php echo htmlspecialchars($L['form_subject_opt_other'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo $L['form_subject_opt_other']; ?></option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="mesaj"><?php echo $L['form_message_label']; ?></label>
                        <textarea id="mesaj" name="mesaj" rows="5" required placeholder="<?php echo htmlspecialchars($L['form_message_placeholder'], ENT_QUOTES, 'UTF-8'); ?>"></textarea>
                    </div>
                    <!-- Honeypot anti-spam (ascuns, dacă se completează, e bot) -->
                    <div style="position:absolute; left:-9999px;" aria-hidden="true">
                        <label for="website"><?php echo $L['form_honeypot_label']; ?></label>
                        <input type="text" id="website" name="website" tabindex="-1" autocomplete="off">
                    </div>
                    <div class="form-group form-note">
                        <p><?php echo $L['form_note']; ?></p>
                    </div>
                    <button type="submit" class="btn btn-primary btn-full"><?php echo $L['form_submit']; ?></button>
                </form>
            </div>

        </div>
    </div>
</section>
