<?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 service-page-wrap">
        <?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 echo e($errors->first()); ?>

            </div>
        <?php endif; ?>

        <?php
            $displayMoney = function ($service) {
                $amount = number_format((float) $service->amount, 2);
                return strtoupper((string) $service->currency) === 'USD'
                    ? '$'.$amount.' USD'
                    : strtoupper((string) $service->currency).' '.$amount;
            };

            $status = strtolower(str_replace(' ', '_', (string) $service->status));
            $statusLabel = ucwords(str_replace('_', ' ', $status ?: 'pending'));
            $isActive = $status === 'active';
            $payload = is_array($service->whmcs_payload) ? $service->whmcs_payload : [];
            $stat = fn (...$keys) => collect($keys)->map(fn ($key) => data_get($payload, $key))->first(fn ($value) => $value !== null && $value !== '');
            $diskUsed = $stat('diskusage', 'disk_usage', 'service.diskusage', 'usage.diskusage') ?? 0;
            $diskLimit = $stat('disklimit', 'disk_limit', 'service.disklimit', 'usage.disklimit') ?? 'Unlimited';
            $bwUsed = $stat('bwusage', 'bandwidthusage', 'bw_usage', 'service.bwusage', 'usage.bwusage') ?? 0;
            $bwLimit = $stat('bwlimit', 'bandwidthlimit', 'bw_limit', 'service.bwlimit', 'usage.bwlimit') ?? 'Unlimited';
            $lastUpdated = $stat('lastupdate', 'last_updated', 'service.lastupdate', 'usage.lastupdate') ?: optional($service->whmcs_synced_at)->format('d M Y h:i A');

            $serviceText = strtolower(trim(implode(' ', array_filter([
                $service->name,
                $service->service_type,
                data_get($payload, 'groupname'),
                data_get($payload, 'type'),
                data_get($payload, 'producttype'),
            ]))));
            $isReseller = str_contains($serviceText, 'reseller');
            $panelName = $isReseller ? 'WHM' : 'cPanel';

            $diskPercent = is_numeric($diskLimit) && (float) $diskLimit > 0 ? min(100, round(((float) $diskUsed / (float) $diskLimit) * 100)) : 0;
            $bwPercent = is_numeric($bwLimit) && (float) $bwLimit > 0 ? min(100, round(((float) $bwUsed / (float) $bwLimit) * 100)) : 0;
        ?>

        <div class="service-topbar">
            <a class="service-back-link" href="<?php echo e(route('client.services')); ?>">← Back to Services</a>
        </div>

        <section class="service-hero-card">
            <div class="service-hero-main">
                <span class="service-eyebrow"><?php echo e($isReseller ? 'Reseller Hosting Service' : 'Hosting Service'); ?></span>
                <h1><?php echo e($service->name); ?></h1>
                <p><?php echo e($service->domain_name ?: 'No domain assigned yet'); ?></p>
            </div>
            <div class="service-hero-status">
                <span class="status-pill <?php echo e($status); ?>"><?php echo e($statusLabel); ?></span>
                <small>Next due: <?php echo e(optional($service->next_due_date)->format('M d, Y') ?: '-'); ?></small>
            </div>
        </section>

        <?php if($isActive): ?>
        <div class="service-dashboard-grid">
            <main class="service-dashboard-main">
                <section class="service-panel service-actions-panel">
                    <div class="service-panel-head">
                        <div>
                            <span class="service-eyebrow">Quick Actions</span>
                            <h2>Manage Hosting</h2>
                        </div>
                        <p>Credentials are hidden. Access is handled through secure single sign-on.</p>
                    </div>

                    <div class="service-actions-grid">
                        <a class="service-action-card primary" href="<?php echo e(route('client.services.cpanel-sso', $service)); ?>" target="_blank" rel="noopener noreferrer">
                            <span class="service-action-icon">↗</span>
                            <strong>Login to <?php echo e($panelName); ?></strong>
                            <small><?php echo e($isReseller ? 'Open WHM reseller panel' : 'Open cPanel hosting panel'); ?></small>
                        </a>

                        <a class="service-action-card" href="<?php echo e(route('client.services.upgrade', $service)); ?>">
                            <span class="service-action-icon">⇅</span>
                            <strong>Upgrade / Downgrade</strong>
                            <small>Change package from this portal</small>
                        </a>
                    </div>
                </section>

                <section class="service-panel usage-panel">
                    <div class="service-panel-head inline">
                        <div>
                            <span class="service-eyebrow">Usage Statistics</span>
                            <h2>Resource Usage</h2>
                        </div>
                        <small>Last Updated: <?php echo e($lastUpdated ?: '-'); ?></small>
                    </div>

                    <div class="usage-stat-grid refined">
                        <div class="usage-stat-box refined">
                            <div class="usage-stat-top">
                                <span>Disk Usage</span>
                                <strong><?php echo e($diskUsed); ?> M</strong>
                            </div>
                            <div class="usage-meter"><i style="width: <?php echo e($diskPercent); ?>%"></i></div>
                            <small><?php echo e($diskUsed); ?> M / <?php echo e($diskLimit); ?> MB</small>
                        </div>

                        <div class="usage-stat-box refined">
                            <div class="usage-stat-top">
                                <span>Bandwidth Usage</span>
                                <strong><?php echo e($bwUsed); ?> M</strong>
                            </div>
                            <div class="usage-meter"><i style="width: <?php echo e($bwPercent); ?>%"></i></div>
                            <small><?php echo e($bwUsed); ?> M / <?php echo e($bwLimit); ?> M</small>
                        </div>
                    </div>
                </section>

                <section class="service-panel password-panel">
                    <div class="service-panel-head">
                        <div>
                            <span class="service-eyebrow">Security</span>
                            <h2>Change <?php echo e($panelName); ?> Password</h2>
                        </div>
                        <p>Choose a strong password. You may need to sign in again after the password changes.</p>
                    </div>

                    <form method="POST" action="<?php echo e(route('client.services.change-password', $service)); ?>" class="change-password-inline">
                        <?php echo csrf_field(); ?>
                        <input type="password" name="service_password" placeholder="New service password" required minlength="8" autocomplete="new-password">
                        <input type="password" name="service_password_confirmation" placeholder="Confirm new password" required minlength="8" autocomplete="new-password">
                        <button class="service-submit-btn" type="submit">Change Password</button>
                    </form>
                </section>
            </main>

            <aside class="service-dashboard-side">
                <section class="service-panel service-summary-panel">
                    <span class="service-eyebrow">Summary</span>
                    <h2>Service Summary</h2>
                    <dl class="service-summary-list refined">
                        <div><dt>Domain</dt><dd><?php echo e($service->domain_name ?: '-'); ?></dd></div>
                        <div><dt>Billing Cycle</dt><dd><?php echo e($service->billing_cycle ?: '-'); ?></dd></div>
                        <div><dt>Amount</dt><dd><?php echo e($displayMoney($service)); ?></dd></div>
                        <div><dt>Next Due Date</dt><dd><?php echo e(optional($service->next_due_date)->format('l, F jS, Y') ?: '-'); ?></dd></div>
                    </dl>
                </section>
            </aside>
        </div>
        <?php else: ?>
            <section class="service-panel" style="margin-top:24px; text-align:center; padding:42px 24px;">
                <span class="service-eyebrow">Activation Pending</span>
                <h2 style="margin:10px 0 8px;">Management tools are not available yet</h2>
                <p style="margin:0 auto; max-width:620px; color:#64748b; line-height:1.7;">
                    This service is currently <?php echo e(strtolower($statusLabel)); ?>. cPanel login, password changes, and package changes will become available after activation.
                </p>
            </section>
        <?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/service-detail.blade.php ENDPATH**/ ?>