<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
    <div class="portal-container">
        <?php if(session('status')): ?>
            <div class="alert alert-success"><?php echo e(session('status')); ?></div>
        <?php endif; ?>

        <?php if($errors->any()): ?>
            <div class="alert alert-error">
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div><?php echo e($error); ?></div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        <?php endif; ?>

        <h1 class="page-title">Support</h1>

        <?php if(auth()->guard()->guest()): ?>
            <div class="card">
                <h2 class="card-title">Need support?</h2>
                <p class="card-subtitle">Log in to open and track support tickets from your client portal.</p>
                <a class="green-btn" href="<?php echo e(route('login')); ?>">Login to Client Area</a>
            </div>
        <?php else: ?>
            <?php
                $departments = $departments ?? [];
                $tickets = $tickets ?? [];
                $ticket = $ticket ?? null;
                $ticketReplies = data_get($ticket, 'replies.reply', []);
                if (is_array($ticketReplies) && isset($ticketReplies['replyid'])) {
                    $ticketReplies = [$ticketReplies];
                }
            ?>

            <div class="dashboard-two-col" style="align-items:flex-start;">
                <div class="dashboard-card accent-cyan" id="open-ticket">
                    <div class="dashboard-card-head">
                        <h2>Open New Ticket</h2>
                    </div>

                    <?php if(! empty($departmentsError)): ?>
                        <div class="alert alert-error"><?php echo e($departmentsError); ?></div>
                    <?php endif; ?>

                    <?php if(count($departments) === 0): ?>
                        <p>Support departments are temporarily unavailable. Please try again later.</p>
                    <?php else: ?>
                        <form method="POST" action="<?php echo e(route('client.support.store')); ?>" enctype="multipart/form-data" class="mt-6 space-y-6">
                            <?php echo csrf_field(); ?>
                            <div class="form-grid">
                                <div class="form-group">
                                    <label>Department</label>
                                    <select class="select" name="deptid" required>
                                        <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e(data_get($department, 'id')); ?>" <?php echo e(old('deptid') == data_get($department, 'id') ? 'selected' : ''); ?>>
                                                <?php echo e(data_get($department, 'name', 'Department #'.data_get($department, 'id'))); ?>

                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>Priority</label>
                                    <select class="select" name="priority" required>
                                        <?php $__currentLoopData = ['Low', 'Medium', 'High']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $priority): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($priority); ?>" <?php echo e(old('priority', 'Medium') === $priority ? 'selected' : ''); ?>><?php echo e($priority); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label>Subject</label>
                                <input class="input" name="subject" value="<?php echo e(old('subject')); ?>" required maxlength="255" placeholder="Short issue title">
                            </div>
                            <div class="form-group">
                                <label>Message</label>
                                <textarea class="textarea" name="message" required maxlength="5000" placeholder="Explain the issue clearly..."><?php echo e(old('message')); ?></textarea>
                            </div>
                            <div class="form-group"><label>Attachments (up to 3 files)</label><input class="input" type="file" name="attachments[]" multiple accept=".jpg,.jpeg,.png,.webp,.pdf,.txt,.zip"></div>
                            <button class="green-btn" type="submit">Open Ticket</button>
                        </form>
                    <?php endif; ?>
                </div>

                <div class="dashboard-card accent-blue">
                    <div class="dashboard-card-head">
                        <h2>My Tickets</h2>
                    </div>

                    <?php if(! empty($ticketsError)): ?>
                        <div class="alert alert-error"><?php echo e($ticketsError); ?></div>
                    <?php endif; ?>

                    <?php $__empty_1 = true; $__currentLoopData = $tickets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <div class="summary-item" style="margin-bottom:12px;">
                            <div class="summary-item-info">
                                <strong>
                                    <a href="<?php echo e(route('client.support.show', data_get($row, 'id'))); ?>">
                                        #<?php echo e(data_get($row, 'tid', data_get($row, 'id'))); ?> — <?php echo e(data_get($row, 'subject', 'No subject')); ?>

                                    </a>
                                </strong>
                                <span><?php echo e(data_get($row, 'status', 'Unknown')); ?> · <?php echo e(data_get($row, 'priority', 'Medium')); ?> · Last reply: <?php echo e(data_get($row, 'lastreply', '-')); ?></span>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <p>No support tickets found.</p>
                    <?php endif; ?>
                </div>
            </div>

            <?php if(! empty($ticketError)): ?>
                <div class="card" style="margin-top:24px;">
                    <div class="alert alert-error"><?php echo e($ticketError); ?></div>
                </div>
            <?php endif; ?>

            <?php if($ticket): ?>
                <div class="card" style="margin-top:24px;">
                    <div class="dashboard-card-head">
                        <h2>#<?php echo e(data_get($ticket, 'tid', data_get($ticket, 'ticketid'))); ?> — <?php echo e(data_get($ticket, 'subject')); ?></h2>
                        <span><?php echo e(data_get($ticket, 'status')); ?> · <?php echo e(data_get($ticket, 'priority')); ?></span>
                    </div>
                    <p class="card-subtitle">Department: <?php echo e(data_get($ticket, 'deptname', '-')); ?> · Opened: <?php echo e(data_get($ticket, 'date', '-')); ?> · Last Reply: <?php echo e(data_get($ticket, 'lastreply', '-')); ?></p>

                    <div style="margin-top:20px;">
                        <?php $__empty_1 = true; $__currentLoopData = $ticketReplies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $reply): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <div class="dashboard-card accent-gray" style="margin-bottom:14px;">
                                <div class="dashboard-card-head">
                                    <h3><?php echo e(data_get($reply, 'requestor_name', data_get($reply, 'name', 'Reply'))); ?></h3>
                                    <span><?php echo e(data_get($reply, 'date', '-')); ?></span>
                                </div>
                                <div style="white-space:pre-wrap;"><?php echo e(data_get($reply, 'message', '')); ?></div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <p>No replies returned for this ticket.</p>
                        <?php endif; ?>
                    </div>

                    <form method="POST" action="<?php echo e(route('client.support.reply', data_get($ticket, 'ticketid'))); ?>" enctype="multipart/form-data" class="mt-6 space-y-6">
                        <?php echo csrf_field(); ?>
                        <div class="form-group">
                            <label>Add Reply</label>
                            <textarea class="textarea" name="message" required maxlength="5000" placeholder="Write your reply..."><?php echo e(old('message')); ?></textarea>
                        </div>
                        <div class="form-group"><label>Attachments (up to 3 files)</label><input class="input" type="file" name="attachments[]" multiple accept=".jpg,.jpeg,.png,.webp,.pdf,.txt,.zip"></div>
                        <button class="green-btn" type="submit">Send Reply</button>
                    </form>
                </div>
            <?php endif; ?>
        <?php endif; ?>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH /home/ovbopdha/public_html/ztcart.eagale.xyz/resources/views/client/support.blade.php ENDPATH**/ ?>