<?php
    $isSupportChatContext = old('source') === 'support_chat' || session('contact_source') === 'support_chat';
?>

<?php if($settings?->support_chat_enabled): ?>
    <div class="ssa-support-chat <?php echo e($isSupportChatContext ? 'is-open' : ''); ?>" data-support-chat>
        <button
            type="button"
            class="ssa-support-chat__toggle"
            data-support-chat-toggle
            aria-expanded="<?php echo e($isSupportChatContext ? 'true' : 'false'); ?>"
            aria-label="<?php echo e($settings->support_chat_button_label ?: 'Open support chat'); ?>"
            <?php if($isSupportChatContext): ?> hidden <?php endif; ?>
        >
            <span class="ssa-support-chat__toggle-icon" aria-hidden="true">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
                    <path d="M21 11.5a8.5 8.5 0 0 1-8.5 8.5H7l-4 3v-6.5A8.5 8.5 0 1 1 21 11.5Z"></path>
                </svg>
            </span>
            <span><?php echo e($settings->support_chat_button_label ?: 'Quick support'); ?></span>
        </button>

        <div class="ssa-support-chat__panel" data-support-chat-panel <?php if(! $isSupportChatContext): ?> hidden <?php endif; ?>>
            <div class="ssa-support-chat__header">
                <div>
                    <p class="ssa-support-chat__eyebrow">Direct support</p>
                    <h3><?php echo e($settings->support_chat_title ?: 'Need help with tracking?'); ?></h3>
                    <p><?php echo e($settings->support_chat_intro ?: 'Send a quick message and we will follow up using the same email workflow as the contact page.'); ?></p>
                </div>
                <button type="button" class="ssa-support-chat__close" data-support-chat-close aria-label="Close support chat">&times;</button>
            </div>

            <?php if(session('success') && session('contact_source') === 'support_chat'): ?>
                <div class="ssa-success-alert">
                    <?php echo e(session('success')); ?>

                </div>
            <?php endif; ?>

            <form action="<?php echo e(route('contact.store')); ?>" method="POST" class="ssa-contact-form ssa-support-chat__form">
                <?php echo csrf_field(); ?>
                <input type="hidden" name="source" value="support_chat">
                <input type="hidden" name="page_url" value="<?php echo e(old('page_url', url()->full())); ?>">

                <label>
                    <span>Name</span>
                    <input type="text" name="name" value="<?php echo e(old('name')); ?>" required>
                    <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><p class="ssa-form-error"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </label>

                <label>
                    <span>Email</span>
                    <input type="email" name="email" value="<?php echo e(old('email')); ?>" required>
                    <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><p class="ssa-form-error"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </label>

                <label>
                    <span>Phone</span>
                    <input type="text" name="phone" value="<?php echo e(old('phone')); ?>">
                    <?php $__errorArgs = ['phone'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><p class="ssa-form-error"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </label>

                <label>
                    <span>Message</span>
                    <textarea name="message" rows="4" required><?php echo e(old('message')); ?></textarea>
                    <?php $__errorArgs = ['message'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><p class="ssa-form-error"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </label>

                <button type="submit" class="ssa-gradient-button ssa-submit-button">
                    <?php echo e($settings->support_chat_button_label ?: 'Send message'); ?>

                </button>
            </form>
        </div>
    </div>
<?php endif; ?>
<?php /**PATH /home/xsoftdev/saleemsail.xsoftdevelop.com/resources/views/partials/support-chat.blade.php ENDPATH**/ ?>