

<?php $__env->startSection('title', 'Website Settings'); ?>

<?php $__env->startSection('content'); ?>
<div class="admin-page-header">
    <h1>Website Settings</h1>
</div>

<!-- Tabs Navigation -->
<ul class="nav nav-tabs mb-4" id="settingsTabs" role="tablist">
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('settings.general')): ?>
    <li class="nav-item" role="presentation">
        <button class="nav-link <?php echo e($tab === 'general' ? 'active' : ''); ?>" 
                id="general-tab" 
                data-bs-toggle="tab" 
                data-bs-target="#general" 
                type="button" 
                role="tab">
            <i class="bi bi-gear"></i> General Settings
        </button>
    </li>
    <?php endif; ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('settings.payment')): ?>
    <li class="nav-item" role="presentation">
        <button class="nav-link <?php echo e($tab === 'payment' ? 'active' : ''); ?>" 
                id="payment-tab" 
                data-bs-toggle="tab" 
                data-bs-target="#payment" 
                type="button" 
                role="tab">
            <i class="bi bi-credit-card"></i> Payment Settings
        </button>
    </li>
    <?php endif; ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('settings.sms')): ?>
    <li class="nav-item" role="presentation">
        <button class="nav-link <?php echo e($tab === 'sms' ? 'active' : ''); ?>" 
                id="sms-tab" 
                data-bs-toggle="tab" 
                data-bs-target="#sms" 
                type="button" 
                role="tab">
            <i class="bi bi-chat-dots"></i> SMS Configuration
        </button>
    </li>
    <li class="nav-item" role="presentation">
        <button class="nav-link <?php echo e($tab === 'ticket' ? 'active' : ''); ?>"
                id="ticket-tab"
                data-bs-toggle="tab"
                data-bs-target="#ticket"
                type="button"
                role="tab">
            <i class="bi bi-life-preserver"></i> Ticket Settings
        </button>
    </li>
    <?php endif; ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('settings.carriers')): ?>
    <li class="nav-item" role="presentation">
        <button class="nav-link <?php echo e($tab === 'carriers' ? 'active' : ''); ?>" 
                id="carriers-tab" 
                data-bs-toggle="tab" 
                data-bs-target="#carriers" 
                type="button" 
                role="tab">
            <i class="bi bi-truck"></i> Carriers
        </button>
    </li>
    <?php endif; ?>
</ul>

<!-- Tabs Content -->
<div class="tab-content" id="settingsTabsContent">
    <!-- General Settings Tab -->
    <div class="tab-pane fade <?php echo e($tab === 'general' ? 'show active' : ''); ?>" 
         id="general" 
         role="tabpanel" 
         aria-labelledby="general-tab">
        
                <form action="<?php echo e(route('admin.settings.update')); ?>" method="POST" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                     <div class="admin-card">
            <div class="card-body">
                    <h5 class="mb-4" style="color: var(--admin-primary);">Site Information</h5>
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="admin-form-label">Site Name</label>
                            <input type="text" 
                                   name="site_name" 
                                   class="admin-form-control form-control" 
                                   value="<?php echo e(\App\Models\Setting::get('site_name', 'KiyoKart')); ?>">
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="admin-form-label">Site Email</label>
                            <input type="email" 
                                   name="site_email" 
                                   class="admin-form-control form-control" 
                                   value="<?php echo e(\App\Models\Setting::get('site_email')); ?>">
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="admin-form-label">Site Phone</label>
                            <input type="text" 
                                   name="site_phone" 
                                   class="admin-form-control form-control" 
                                   value="<?php echo e(\App\Models\Setting::get('site_phone')); ?>">
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="admin-form-label">Site Address</label>
                            <textarea name="site_address" 
                                      class="admin-form-control form-control" 
                                      rows="3"><?php echo e(\App\Models\Setting::get('site_address')); ?></textarea>
                        </div>

                        <div class="col-md-6 mb-3">
                            <label class="admin-form-label">Default Product Shipping Days</label>
                            <input type="number"
                                   name="default_shipping_days"
                                   class="admin-form-control form-control"
                                   value="<?php echo e(\App\Models\Setting::get('default_shipping_days')); ?>"
                                   min="0"
                                   placeholder="e.g. 3">
                            <small class="form-text text-muted">Used when product-level shipping days are empty.</small>
                        </div>
                    </div>
            </div>
                     </div>

                    <hr class="my-4">

                    <div class="admin-card">
            <div class="card-body">

                    <h5 class="mb-3" style="color: var(--admin-primary);">Website Logo</h5>
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="admin-form-label">Site Logo</label>
                            <?php
                                $currentLogo = \App\Models\Setting::get('site_logo');
                            ?>
                            <?php if($currentLogo && \Illuminate\Support\Facades\Storage::disk('public')->exists($currentLogo)): ?>
                                <div class="mb-3">
                                    <img src="<?php echo e(asset('storage/' . $currentLogo)); ?>" 
                                         alt="Current Logo" 
                                         class="img-thumbnail" 
                                         style="max-width: 200px; max-height: 100px; object-fit: contain;">
                                    <div class="form-check mt-2">
                                        <input class="form-check-input" 
                                               type="checkbox" 
                                               name="remove_logo" 
                                               id="removeLogo" 
                                               value="1">
                                        <label class="form-check-label text-danger" for="removeLogo">
                                            Remove current logo
                                        </label>
                                    </div>
                                </div>
                            <?php endif; ?>
                            <input type="file" 
                                   name="site_logo" 
                                   class="admin-form-control form-control" 
                                   accept="image/jpeg,image/png,image/jpg,image/gif,image/svg+xml,image/webp">
                            <small class="form-text text-muted">
                                Recommended size: 200x50px or similar. Max file size: 2MB. Formats: JPG, PNG, GIF, SVG, WebP
                            </small>
                        </div>

                        <div class="col-md-6">
                            <label class="admin-form-label">Dark Mode Logo (Optional)</label>
                            <?php
                                $currentDarkLogo = \App\Models\Setting::get('site_logo_dark');
                            ?>
                            <?php if($currentDarkLogo && \Illuminate\Support\Facades\Storage::disk('public')->exists($currentDarkLogo)): ?>
                                <div class="mb-3">
                                    <img src="<?php echo e(asset('storage/' . $currentDarkLogo)); ?>" 
                                         alt="Current Dark Logo" 
                                         class="img-thumbnail" 
                                         style="max-width: 200px; max-height: 100px; object-fit: contain; background: #1a1a1a;">
                                    <div class="form-check mt-2">
                                        <input class="form-check-input" 
                                               type="checkbox" 
                                               name="remove_logo_dark" 
                                               id="removeLogoDark" 
                                               value="1">
                                        <label class="form-check-label text-danger" for="removeLogoDark">
                                            Remove current dark logo
                                        </label>
                                    </div>
                                </div>
                            <?php endif; ?>
                            <input type="file" 
                                   name="site_logo_dark" 
                                   class="admin-form-control form-control" 
                                   accept="image/jpeg,image/png,image/jpg,image/gif,image/svg+xml,image/webp">
                            <small class="form-text text-muted">
                                Logo optimized for dark backgrounds. Same size recommendations apply.
                            </small>
                        </div>
                    </div>
            </div>
                    </div>

                    <hr class="my-4">
            <div class="admin-card">
                 <div class="card-body">
                    <h5 class="mb-4" style="color: var(--admin-primary);">SEO Settings</h5>
                    <div class="row">
                        <div class="col-12 mb-3">
                            <label class="admin-form-label">Meta Title</label>
                            <input type="text" 
                                   name="meta_title" 
                                   class="admin-form-control form-control" 
                                   value="<?php echo e(\App\Models\Setting::get('meta_title')); ?>">
                            <small class="form-text text-muted">Recommended: 50-60 characters</small>
                        </div>

                        <div class="col-12">
                            <label class="admin-form-label">Meta Description</label>
                            <textarea name="meta_description" 
                                      class="admin-form-control form-control" 
                                      rows="3"><?php echo e(\App\Models\Setting::get('meta_description')); ?></textarea>
                            <small class="form-text text-muted">Recommended: 150-160 characters</small>
                        </div>

                        <div class="col-12 mb-3">
                            <label class="admin-form-label">Meta Keywords</label>
                            <input type="text" 
                                   name="meta_keywords" 
                                   class="admin-form-control form-control" 
                                   value="<?php echo e(\App\Models\Setting::get('meta_keywords')); ?>">
                            <small class="form-text text-muted">Separate keywords with commas</small>
                        </div>
                    </div>

                 </div>
            </div>
                    <div class="mt-4">
                        <button type="submit" class="admin-btn-primary">
                            <i class="bi bi-save"></i> Save Settings
                        </button>
                    </div>

                
                </form>
            </div>
        


    <!-- Payment Settings Tab -->
    <div class="tab-pane fade <?php echo e($tab === 'payment' ? 'show active' : ''); ?>" 
         id="payment" 
         role="tabpanel" 
         aria-labelledby="payment-tab">
        <div class="admin-card">
            <div class="card-body">
                <h5 class="mb-4" style="color: var(--admin-primary);">Payment Methods</h5>
                
                <form action="<?php echo e(route('admin.settings.payment.update')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>

                    <div class="mb-4">
                        <div class="form-check form-switch mb-3">
                            <input class="form-check-input" 
                                   type="checkbox" 
                                   id="razorpay_enabled" 
                                   name="payment_razorpay_enabled" 
                                   value="1"
                                   <?php echo e($razorpayEnabled ? 'checked' : ''); ?>>
                            <label class="form-check-label" for="razorpay_enabled">
                                <strong>Razorpay Payment</strong>
                                <p class="text-muted small mb-0">Enable Razorpay payment gateway (UPI, Cards, Wallets)</p>
                            </label>
                        </div>

                        <?php if($razorpayEnabled): ?>
                        <!-- Razorpay API Keys Configuration -->
                        <div class="card border-primary mb-4" style="background-color: #f8f9fa;">
                            <div class="card-body">
                                <h6 class="card-title mb-3" style="color: var(--admin-primary);">
                                    <i class="bi bi-key"></i> Razorpay API Keys
                                </h6>
                                
                                <div class="row mb-3">
                                    <div class="col-md-6">
                                        <label for="payment_razorpay_key_id" class="form-label">
                                            <strong>Key ID *</strong>
                                        </label>
                                        <input type="text" 
                                               class="form-control" 
                                               id="payment_razorpay_key_id" 
                                               name="payment_razorpay_key_id" 
                                               value="<?php echo e(old('payment_razorpay_key_id', $razorpaySettings['key_id'])); ?>"
                                               placeholder="rzp_test_xxxxxxxxxxxxx"
                                               required>
                                        <small class="text-muted">Get your Key ID from <a href="https://dashboard.razorpay.com/app/keys" target="_blank">Razorpay Dashboard</a></small>
                                        <?php $__errorArgs = ['payment_razorpay_key_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                    <div class="col-md-6">
                                        <label for="payment_razorpay_secret_key" class="form-label">
                                            <strong>Secret Key *</strong>
                                        </label>
                                        <input type="password" 
                                               class="form-control" 
                                               id="payment_razorpay_secret_key" 
                                               name="payment_razorpay_secret_key" 
                                               value="<?php echo e(old('payment_razorpay_secret_key', $razorpaySettings['secret_key'])); ?>"
                                               placeholder="Enter your Secret Key"
                                               required>
                                        <small class="text-muted">Get your Secret Key from <a href="https://dashboard.razorpay.com/app/keys" target="_blank">Razorpay Dashboard</a></small>
                                        <?php $__errorArgs = ['payment_razorpay_secret_key'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>
                                
                                <div class="row mb-3">
                                    <div class="col-md-12">
                                        <label for="payment_razorpay_webhook_secret" class="form-label">
                                            <strong>Webhook Secret</strong>
                                        </label>
                                        <input type="password" 
                                               class="form-control" 
                                               id="payment_razorpay_webhook_secret" 
                                               name="payment_razorpay_webhook_secret" 
                                               value="<?php echo e(old('payment_razorpay_webhook_secret', $razorpaySettings['webhook_secret'])); ?>"
                                               placeholder="Enter Webhook Secret (optional but recommended)">
                                        <small class="text-muted">Get your Webhook Secret from <a href="https://dashboard.razorpay.com/app/webhooks" target="_blank">Razorpay Webhooks</a> (required for production)</small>
                                        <?php $__errorArgs = ['payment_razorpay_webhook_secret'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>                               
                                 
                            </div>
                        </div>
                        
                        <!-- Razorpay Webhook Setup -->
                        <div class="card border-primary mb-4" style="background-color: #f8f9fa;">
                            <div class="card-body">
                                <h6 class="card-title mb-3" style="color: var(--admin-primary);">
                                    <i class="bi bi-webhook"></i> Razorpay Webhook Configuration
                                </h6>
                                
                                <div class="mb-3">
                                    <label class="form-label fw-bold">Webhook URL:</label>
                                    <div class="input-group">
                                        <input type="text" 
                                               class="form-control" 
                                               id="webhook_url" 
                                               value="<?php echo e($webhookUrl); ?>" 
                                               readonly>
                                        <button class="btn btn-outline-secondary" 
                                                type="button" 
                                                onclick="copyWebhookUrl(event)"
                                                title="Copy to clipboard">
                                            <i class="bi bi-clipboard"></i> Copy
                                        </button>
                                    </div>
                                    <small class="text-muted">Copy this URL and add it in Razorpay Dashboard (Webhooks). Ensure the site is reachable from the internet (no firewall blocking Razorpay).</small>
                                </div>
                                <div class="alert alert-info mb-3 small">
                                    <strong>Webhook secret:</strong> The secret you set above must exactly match the &quot;Secret&quot; shown in Razorpay Dashboard for this webhook. A mismatch causes 401 and failed delivery.
                                </div>

                                <?php if($razorpaySettings['webhook_secret']): ?>
                                <div class="alert alert-success mb-3">
                                    <i class="bi bi-check-circle-fill"></i> 
                                    <strong>Webhook Secret Configured</strong>
                                    <p class="mb-0 small">Your webhook is secured with signature verification.</p>
                                </div>
                                <?php else: ?>
                                <div class="alert alert-warning mb-3">
                                    <i class="bi bi-exclamation-triangle-fill"></i> 
                                    <strong>Webhook Secret Not Configured</strong>
                                    <p class="mb-0 small">Add the Webhook Secret above for production security.</p>
                                </div>
                                <?php endif; ?>

                                <div class="mb-3">
                                    <strong>Events to Subscribe:</strong>
                                    <ul class="small mb-0 mt-2">
                                        <li><code>payment.authorized</code> - Payment authorized</li>
                                        <li><code>payment.captured</code> - Payment captured</li>
                                        <li><code>payment.failed</code> - Payment failed</li>
                                        <li><code>payment.refunded</code> - Payment refunded</li>
                                        <li><code>refund.created</code> - Refund created</li>
                                    </ul>
                                </div>

                                <div class="d-flex gap-2">
                                    <a href="https://dashboard.razorpay.com/app/webhooks" 
                                       target="_blank" 
                                       class="btn btn-primary btn-sm">
                                        <i class="bi bi-box-arrow-up-right"></i> Configure in Razorpay Dashboard
                                    </a>
                                    <a href="https://razorpay.com/docs/webhooks/" 
                                       target="_blank" 
                                       class="btn btn-outline-secondary btn-sm">
                                        <i class="bi bi-book"></i> Documentation
                                    </a>
                                </div>
                            </div>
                        </div>
                        <?php endif; ?>

                        <!-- Stock reservation window (for Razorpay authorize-then-capture) -->
                        <div class="card border-secondary mb-4" style="background-color: #f8f9fa;">
                            <div class="card-body">
                                <h6 class="card-title mb-3">
                                    <i class="bi bi-clock"></i> Payment reservation window
                                </h6>
                                <div class="mb-2">
                                    <label for="stock_reservation_ttl_seconds" class="form-label">Stock reservation TTL (seconds)</label>
                                    <input type="number" 
                                           class="form-control" 
                                           id="stock_reservation_ttl_seconds" 
                                           name="stock_reservation_ttl_seconds" 
                                           value="<?php echo e(old('stock_reservation_ttl_seconds', $stockReservationTtlSeconds ?? 900)); ?>"
                                           min="60" 
                                           max="3600" 
                                           step="60">
                                    <small class="text-muted">How long to hold stock after "Place Order" (60–3600). Recommended: 900 (15 min) to 1800 (30 min). Reduces failed captures when the customer pays after a few minutes.</small>
                                </div>
                            </div>
                        </div>

                        <div class="form-check form-switch mb-3">
                            <input class="form-check-input" 
                                   type="checkbox" 
                                   id="cod_enabled" 
                                   name="payment_cod_enabled" 
                                   value="1"
                                   style="width: 2.5rem; padding: 0.5rem; margin-right: 0.5rem;"
                                   <?php echo e($codEnabled ? 'checked' : ''); ?>>
                            <label class="form-check-label" for="cod_enabled">
                                <strong>Cash on Delivery (COD)</strong>
                                <p class="text-muted small mb-0">Enable Cash on Delivery payment option</p>
                            </label>
                        </div>
                    </div>

                    <div class="alert alert-info">
                        <i class="bi bi-info-circle"></i> 
                        <strong>Note:</strong> At least one payment method must be enabled. Disabled payment methods will not appear in the checkout page.
                    </div>

                    <div class="mt-4">
                        <button type="submit" class="admin-btn-primary">
                            <i class="bi bi-save"></i> Save Payment Settings
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- SMS Configuration Tab -->
    <div class="tab-pane fade <?php echo e($tab === 'sms' ? 'show active' : ''); ?>" 
         id="sms" 
         role="tabpanel" 
         aria-labelledby="sms-tab">
        <div class="admin-card">
            <div class="card-body">
                <h5 class="mb-4" style="color: var(--admin-primary);">
                    <i class="bi bi-chat-dots"></i> Fast2SMS Configuration
                </h5>
                
                <form action="<?php echo e(route('admin.settings.sms.update')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?> 
                    <div class="row mb-3">
                        <div class="col-md-12">
                            <label for="sms_fast2sms_url" class="form-label">
                                <strong>API Url</strong>
                            </label>
                            <input type="text" 
                                class="form-control" 
                                id="sms_fast2sms_url" 
                                name="sms_fast2sms_url" 
                                value="<?php echo e(old('sms_fast2sms_url', $smsSettings['sms_url'])); ?>"
                                placeholder="Enter your Fast2SMS API Url"
                            >
                            <?php $__errorArgs = ['sms_fast2sms_url'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="text-danger small"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                    </div>

                    <div class="row mb-3">
                        <div class="col-md-12">
                            <label for="sms_fast2sms_api_key" class="form-label">
                                <strong>API Key *</strong>
                            </label>
                            <input type="text" 
                                   class="form-control" 
                                   id="sms_fast2sms_api_key" 
                                   name="sms_fast2sms_api_key" 
                                   value="<?php echo e(old('sms_fast2sms_api_key', $smsSettings['api_key'])); ?>"
                                   placeholder="Enter your Fast2SMS API Key"
                                   required>
                            <small class="text-muted">Get your API key from <a href="https://www.fast2sms.com/dashboard/dev-api" target="_blank">Fast2SMS Dashboard</a></small>
                            <?php $__errorArgs = ['sms_fast2sms_api_key'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="text-danger small"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                    </div>

                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label for="sms_fast2sms_sender" class="form-label">
                                <strong>Sender ID</strong>
                            </label>
                            <input type="text" 
                                   class="form-control" 
                                   id="sms_fast2sms_sender" 
                                   name="sms_fast2sms_sender" 
                                   value="<?php echo e(old('sms_fast2sms_sender', $smsSettings['sender'])); ?>"
                                   placeholder="KIYO"
                                   maxlength="10">
                            <small class="text-muted">Sender name (max 10 characters). Default: KIYO</small>
                            <?php $__errorArgs = ['sms_fast2sms_sender'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="text-danger small"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                        <div class="col-md-6">
                            <label for="sms_fast2sms_route" class="form-label">
                                <strong>Route</strong>
                            </label>
                            <select class="form-select" 
                                    id="sms_fast2sms_route" 
                                    name="sms_fast2sms_route">
                                <option value="q" <?php echo e(old('sms_fast2sms_route', $smsSettings['route']) === 'q' ? 'selected' : ''); ?>>Quick (q)</option>
                                <option value="dlt_manual" <?php echo e(old('sms_fast2sms_route', $smsSettings['route']) === 'dlt_manual' ? 'selected' : ''); ?>>DLT Manual</option>
                                <option value="dlt" <?php echo e(old('sms_fast2sms_route', $smsSettings['route']) === 'dlt' ? 'selected' : ''); ?>>DLT</option>
                            </select>
                            <small class="text-muted">SMS route type. Default: q (Quick)</small>
                            <?php $__errorArgs = ['sms_fast2sms_route'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="text-danger small"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                    </div>

                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label for="sms_fast2sms_entity_id" class="form-label">
                                <strong>Entity ID</strong>
                            </label>
                            <input type="text" 
                                   class="form-control" 
                                   id="sms_fast2sms_entity_id" 
                                   name="sms_fast2sms_entity_id" 
                                   value="<?php echo e(old('sms_fast2sms_entity_id', $smsSettings['entity_id'])); ?>"
                                   placeholder="Enter Entity ID (if required)">
                            <small class="text-muted">DLT Entity ID (if using DLT route)</small>
                            <?php $__errorArgs = ['sms_fast2sms_entity_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="text-danger small"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                        <div class="col-md-6">
                            <label for="sms_store_manager_mobile" class="form-label">
                                <strong>Store MD/Manager Mobile (POS OTP)</strong>
                            </label>
                            <input type="text" 
                                   class="form-control" 
                                   id="sms_store_manager_mobile" 
                                   name="sms_store_manager_mobile" 
                                   value="<?php echo e(old('sms_store_manager_mobile', $smsSettings['store_manager_mobile'] ?? '')); ?>"
                                   placeholder="10-digit mobile or +91...">
                            <small class="text-muted">POS OTP is sent to this number. Staff enters the OTP received by this number to complete the order.</small>
                            <?php $__errorArgs = ['sms_store_manager_mobile'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="text-danger small"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                    </div>

                    <div class="mt-4">
                        <button type="submit" class="admin-btn-primary">
                            <i class="bi bi-save"></i> Save SMS Settings
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- Ticket Settings Tab -->
    <div class="tab-pane fade <?php echo e($tab === 'ticket' ? 'show active' : ''); ?>"
         id="ticket"
         role="tabpanel"
         aria-labelledby="ticket-tab">
        <div class="admin-card">
            <div class="card-body">
                <h5 class="mb-4" style="color: var(--admin-primary);">
                    <i class="bi bi-life-preserver"></i> Ticket Notification Settings
                </h5>

                <form action="<?php echo e(route('admin.settings.ticket.update')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>

                    <h6 class="mb-3" style="color: var(--admin-primary);">
                        <i class="bi bi-bell"></i> Notification Channels
                    </h6>
                    <div class="row">
                        <div class="col-md-4 mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" id="tickets_notify_web" name="tickets_notify_web" value="1" <?php echo e(old('tickets_notify_web', $ticketSettings['notify_web'] ?? true) ? 'checked' : ''); ?>>
                                <label class="form-check-label" for="tickets_notify_web"><strong>Web (Bell)</strong></label>
                            </div>
                        </div>
                        <div class="col-md-4 mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" id="tickets_notify_sms" name="tickets_notify_sms" value="1" <?php echo e(old('tickets_notify_sms', $ticketSettings['notify_sms'] ?? true) ? 'checked' : ''); ?>>
                                <label class="form-check-label" for="tickets_notify_sms"><strong>SMS</strong></label>
                            </div>
                        </div>
                        <div class="col-md-4 mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" id="tickets_notify_whatsapp" name="tickets_notify_whatsapp" value="1" <?php echo e(old('tickets_notify_whatsapp', $ticketSettings['notify_whatsapp'] ?? false) ? 'checked' : ''); ?>>
                                <label class="form-check-label" for="tickets_notify_whatsapp"><strong>WhatsApp</strong></label>
                            </div>
                        </div>
                    </div>

                    <h6 class="mb-3 mt-2" style="color: var(--admin-primary);">
                        <i class="bi bi-funnel"></i> Event Triggers
                    </h6>
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" id="tickets_notify_on_reply" name="tickets_notify_on_reply" value="1" <?php echo e(old('tickets_notify_on_reply', $ticketSettings['notify_on_reply'] ?? true) ? 'checked' : ''); ?>>
                                <label class="form-check-label" for="tickets_notify_on_reply"><strong>Notify on admin reply</strong></label>
                            </div>
                        </div>
                        <div class="col-md-6 mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" id="tickets_notify_on_status" name="tickets_notify_on_status" value="1" <?php echo e(old('tickets_notify_on_status', $ticketSettings['notify_on_status'] ?? true) ? 'checked' : ''); ?>>
                                <label class="form-check-label" for="tickets_notify_on_status"><strong>Notify on status change</strong></label>
                            </div>
                        </div>
                    </div>

                    <hr>
                    <h6 class="mb-3 mt-2" style="color: var(--admin-primary);">
                        <i class="bi bi-hourglass-split"></i> Auto-Close Policy
                    </h6>
                    <div class="row">
                        <div class="col-md-12 mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" id="tickets_auto_close_enabled" name="tickets_auto_close_enabled" value="1" <?php echo e(old('tickets_auto_close_enabled', $ticketSettings['auto_close_enabled'] ?? true) ? 'checked' : ''); ?>>
                                <label class="form-check-label" for="tickets_auto_close_enabled"><strong>Enable auto-close for no customer response</strong></label>
                            </div>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label for="tickets_customer_reply_timeout_days" class="form-label"><strong>Reminder after (days)</strong></label>
                            <input type="number" min="1" max="30" class="form-control <?php $__errorArgs = ['tickets_customer_reply_timeout_days'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" id="tickets_customer_reply_timeout_days" name="tickets_customer_reply_timeout_days" value="<?php echo e(old('tickets_customer_reply_timeout_days', $ticketSettings['customer_reply_timeout_days'] ?? 3)); ?>">
                            <small class="text-muted">When ticket is waiting for customer response, send reminder after these days.</small>
                            <?php $__errorArgs = ['tickets_customer_reply_timeout_days'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label for="tickets_auto_close_grace_days" class="form-label"><strong>Auto-close grace (days)</strong></label>
                            <input type="number" min="1" max="30" class="form-control <?php $__errorArgs = ['tickets_auto_close_grace_days'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" id="tickets_auto_close_grace_days" name="tickets_auto_close_grace_days" value="<?php echo e(old('tickets_auto_close_grace_days', $ticketSettings['auto_close_grace_days'] ?? 1)); ?>">
                            <small class="text-muted">After reminder is sent, auto-close if customer still does not reply.</small>
                            <?php $__errorArgs = ['tickets_auto_close_grace_days'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                    </div>

                    <div class="mt-4">
                        <button type="submit" class="admin-btn-primary">
                            <i class="bi bi-save"></i> Save Ticket Settings
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- Carriers Tab -->
    <div class="tab-pane fade <?php echo e($tab === 'carriers' ? 'show active' : ''); ?>" 
         id="carriers" 
         role="tabpanel" 
         aria-labelledby="carriers-tab">
        <div class="admin-card">
            <div class="card-body">
                <h5 class="mb-4" style="color: var(--admin-primary);">Carrier Configuration</h5>
                <?php
                    $carrierTab = old('selected_carrier', $selectedCarrier ?? request('carrier', 'delhivery'));
                ?>

                <ul class="nav nav-tabs mb-3" id="carrierTabs" role="tablist">
                    <li class="nav-item" role="presentation">
                        <button class="nav-link <?php echo e($carrierTab === 'delhivery' ? 'active' : ''); ?>" id="carrier-delhivery-tab" data-bs-toggle="tab" data-bs-target="#carrier-delhivery" type="button" role="tab" aria-controls="carrier-delhivery" aria-selected="<?php echo e($carrierTab === 'delhivery' ? 'true' : 'false'); ?>" data-carrier="delhivery">
                            Delhivery
                        </button>
                    </li>
                    <li class="nav-item" role="presentation">
                        <button class="nav-link <?php echo e($carrierTab === 'expressbees' ? 'active' : ''); ?>" id="carrier-expressbees-tab" data-bs-toggle="tab" data-bs-target="#carrier-expressbees" type="button" role="tab" aria-controls="carrier-expressbees" aria-selected="<?php echo e($carrierTab === 'expressbees' ? 'true' : 'false'); ?>" data-carrier="expressbees">
                            XpressBees
                        </button>
                    </li>
                    <li class="nav-item" role="presentation">
                        <button class="nav-link <?php echo e($carrierTab === 'ekart' ? 'active' : ''); ?>" id="carrier-ekart-tab" data-bs-toggle="tab" data-bs-target="#carrier-ekart" type="button" role="tab" aria-controls="carrier-ekart" aria-selected="<?php echo e($carrierTab === 'ekart' ? 'true' : 'false'); ?>" data-carrier="ekart">
                            Ekart
                        </button>
                    </li>
                    <li class="nav-item" role="presentation">
                        <button class="nav-link <?php echo e($carrierTab === 'indiapost' ? 'active' : ''); ?>" id="carrier-indiapost-tab" data-bs-toggle="tab" data-bs-target="#carrier-indiapost" type="button" role="tab" aria-controls="carrier-indiapost" aria-selected="<?php echo e($carrierTab === 'indiapost' ? 'true' : 'false'); ?>" data-carrier="indiapost">
                            India Postal
                        </button>
                    </li>
                    <li class="nav-item" role="presentation">
                        <button class="nav-link <?php echo e($carrierTab === 'other' ? 'active' : ''); ?>" id="carrier-other-tab" data-bs-toggle="tab" data-bs-target="#carrier-other" type="button" role="tab" aria-controls="carrier-other" aria-selected="<?php echo e($carrierTab === 'other' ? 'true' : 'false'); ?>" data-carrier="other">
                            Other
                        </button>
                    </li>
                </ul>

                <div class="tab-content" id="carrierTabContent">
                    <!-- Delhivery Configuration -->
                    <div class="tab-pane fade <?php echo e($carrierTab === 'delhivery' ? 'show active' : ''); ?>" id="carrier-delhivery" role="tabpanel" aria-labelledby="carrier-delhivery-tab">
                        <form action="<?php echo e(route('admin.settings.carriers.update')); ?>" method="POST" class="mt-3">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                            <input type="hidden" name="selected_carrier" value="delhivery">

                        <div class="card border-primary mb-4" style="background-color: #f8f9fa;">
                            <div class="card-body">
                                <h6 class="card-title mb-3" style="color: var(--admin-primary);">
                                    <i class="bi bi-truck"></i> Delhivery Configuration
                                </h6>
                                
                                <!-- Status Toggle -->
                                <div class="mb-4">
                                    <label class="form-label"><strong>Status *</strong></label>
                                    <div class="d-flex gap-4">
                                        <div class="form-check">
                                            <input class="form-check-input" 
                                                   type="radio" 
                                                   name="delhivery_enabled" 
                                                   id="delhivery_active" 
                                                   value="1"
                                                   <?php echo e(old('delhivery_enabled', $delhiverySettings['enabled'] ?? '0') === '1' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="delhivery_active">
                                                Active
                                            </label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input" 
                                                   type="radio" 
                                                   name="delhivery_enabled" 
                                                   id="delhivery_inactive" 
                                                   value="0"
                                                   <?php echo e(old('delhivery_enabled', $delhiverySettings['enabled'] ?? '0') === '0' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="delhivery_inactive">
                                                Inactive
                                            </label>
                                        </div>
                                    </div>
                                    <small class="text-muted">Enable or disable Delhivery carrier</small>
                                </div>

                                <!-- Process Type -->
                                <div class="mb-4">
                                    <label class="form-label"><strong>Process Type *</strong></label>
                                    <div class="d-flex gap-4">
                                        <div class="form-check">
                                            <input class="form-check-input carrier-process-type" type="radio" name="delhivery_process_type" id="delhivery_process_automatic" value="automatic" data-carrier="delhivery"
                                                   <?php echo e(old('delhivery_process_type', $delhiverySettings['process_type'] ?? 'automatic') === 'automatic' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="delhivery_process_automatic">Automatic</label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input carrier-process-type" type="radio" name="delhivery_process_type" id="delhivery_process_manual" value="manual" data-carrier="delhivery"
                                                   <?php echo e(old('delhivery_process_type', $delhiverySettings['process_type'] ?? 'automatic') === 'manual' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="delhivery_process_manual">Manual</label>
                                        </div>
                                    </div>
                                    <small class="text-muted">Automatic: API creates shipment. Manual: staff enters tracking on the order.</small>
                                </div>
                                
                                <div class="carrier-config-fields mb-4" id="delhivery-config" style="<?php echo e(old('delhivery_process_type', $delhiverySettings['process_type'] ?? 'automatic') === 'manual' ? 'display:none;' : ''); ?>">
                                <div class="row mb-3">
                                    <div class="col-md-6">
                                        <label for="delhivery_api_url" class="form-label">
                                            <strong>API URL *</strong>
                                        </label>
                                        <input type="url" 
                                               class="form-control" 
                                               id="delhivery_api_url" 
                                               name="delhivery_api_url" 
                                               value="<?php echo e(old('delhivery_api_url', $delhiverySettings['api_url'] ?? 'https://staging-express.delhivery.com')); ?>"
                                               placeholder="https://staging-express.delhivery.com">
                                        <small class="text-muted">Delhivery API endpoint URL</small>
                                        <?php $__errorArgs = ['delhivery_api_url'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                    <div class="col-md-6">
                                        <label for="delhivery_api_key" class="form-label">
                                            <strong>API Key *</strong>
                                        </label>
                                        <input type="text" 
                                               class="form-control" 
                                               id="delhivery_api_key" 
                                               name="delhivery_api_key" 
                                               value="<?php echo e(old('delhivery_api_key', $delhiverySettings['api_key'] ?? '')); ?>"
                                               placeholder="Enter your Delhivery API key">
                                        <small class="text-muted">Get your API key from <a href="https://delhivery.com" target="_blank">Delhivery Dashboard</a></small>
                                        <?php $__errorArgs = ['delhivery_api_key'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>
                                </div>

                                    <div class="mt-4">
                                        <button type="submit" class="admin-btn-primary">
                                            <i class="bi bi-save"></i> Save Delhivery Settings
                                        </button>
                            </div>
                        </div>
                            </div>
                        </form>
                    </div>

                    <!-- XpressBees Configuration -->
                    <div class="tab-pane fade <?php echo e($carrierTab === 'expressbees' ? 'show active' : ''); ?>" id="carrier-expressbees" role="tabpanel" aria-labelledby="carrier-expressbees-tab">
                        <form action="<?php echo e(route('admin.settings.carriers.update')); ?>" method="POST" class="mt-3">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('PUT'); ?>
                            <input type="hidden" name="selected_carrier" value="expressbees">

                        <div class="card border-primary mb-4" style="background-color: #f8f9fa;">
                            <div class="card-body">
                                <h6 class="card-title mb-3" style="color: var(--admin-primary);">
                                        <i class="bi bi-truck"></i> XpressBees Configuration
                                </h6>
                                
                                <!-- Status Toggle -->
                                <div class="mb-4">
                                    <label class="form-label"><strong>Status *</strong></label>
                                    <div class="d-flex gap-4">
                                        <div class="form-check">
                                            <input class="form-check-input" 
                                                   type="radio" 
                                                   name="expressbees_enabled" 
                                                   id="expressbees_active" 
                                                   value="1"
                                                   <?php echo e(old('expressbees_enabled', $expressbeesSettings['enabled'] ?? '0') === '1' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="expressbees_active">
                                                Active
                                            </label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input" 
                                                   type="radio" 
                                                   name="expressbees_enabled" 
                                                   id="expressbees_inactive" 
                                                   value="0"
                                                   <?php echo e(old('expressbees_enabled', $expressbeesSettings['enabled'] ?? '0') === '0' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="expressbees_inactive">
                                                Inactive
                                            </label>
                                        </div>
                                    </div>
                                    <small class="text-muted">Enable or disable XpressBees carrier</small>
                                    </div>

                                    <!-- Process Type -->
                                    <div class="mb-4">
                                        <label class="form-label"><strong>Process Type *</strong></label>
                                        <div class="d-flex gap-4">
                                            <div class="form-check">
                                                <input class="form-check-input carrier-process-type" type="radio" name="expressbees_process_type" id="expressbees_process_automatic" value="automatic" data-carrier="expressbees"
                                                       <?php echo e(old('expressbees_process_type', $expressbeesSettings['process_type'] ?? 'automatic') === 'automatic' ? 'checked' : ''); ?>>
                                                <label class="form-check-label" for="expressbees_process_automatic">Automatic</label>
                                            </div>
                                            <div class="form-check">
                                                <input class="form-check-input carrier-process-type" type="radio" name="expressbees_process_type" id="expressbees_process_manual" value="manual" data-carrier="expressbees"
                                                       <?php echo e(old('expressbees_process_type', $expressbeesSettings['process_type'] ?? 'automatic') === 'manual' ? 'checked' : ''); ?>>
                                                <label class="form-check-label" for="expressbees_process_manual">Manual</label>
                                            </div>
                                        </div>
                                        <small class="text-muted">Automatic: API creates shipment. Manual: staff enters tracking on the order.</small>
                                    </div>
                                    
                                    <div class="carrier-config-fields mb-4" id="expressbees-config" style="<?php echo e(old('expressbees_process_type', $expressbeesSettings['process_type'] ?? 'automatic') === 'manual' ? 'display:none;' : ''); ?>">
                                    <div class="row mb-3">
                                    <div class="col-md-6">
                                        <label for="expressbees_email" class="form-label">
                                            <strong>Username *</strong>
                                        </label>
                                        <input type="text" 
                                               class="form-control" 
                                               id="expressbees_email" 
                                               name="expressbees_email" 
                                               value="<?php echo e(old('expressbees_email', $expressbeesSettings['email'] ?? '')); ?>" 
                                               placeholder="franchise username">
                                        <small class="text-muted">Username used for franchise login</small>
                                            <?php $__errorArgs = ['expressbees_email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                <div class="text-danger small"><?php echo e($message); ?></div>
                                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                        </div>
                                        <div class="col-md-6">
                                            <label for="expressbees_password" class="form-label">
                                                <strong>Password *</strong>
                                            </label>
                                            <input type="password" 
                                                   class="form-control" 
                                                   id="expressbees_password" 
                                                   name="expressbees_password" 
                                                   value="<?php echo e(old('expressbees_password', $expressbeesSettings['password'] ?? '')); ?>" 
                                                   placeholder="franchise password">
                                            <small class="text-muted">Password used for franchise login</small>
                                            <?php $__errorArgs = ['expressbees_password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                <div class="text-danger small"><?php echo e($message); ?></div>
                                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                        </div>
                                </div>
                                
                                <div class="row mb-3">
                                    <div class="col-md-6">
                                        <label for="expressbees_api_url" class="form-label">
                                            <strong>API URL *</strong>
                                        </label>
                                        <input type="url" 
                                               class="form-control" 
                                               id="expressbees_api_url" 
                                               name="expressbees_api_url" 
                                               value="<?php echo e(old('expressbees_api_url', $expressbeesSettings['api_url'] ?? 'https://apiv2.expressbees.com')); ?>"
                                               placeholder="https://apiv2.expressbees.com">
                                            <small class="text-muted">XpressBees API endpoint URL</small>
                                        <?php $__errorArgs = ['expressbees_api_url'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                    <div class="col-md-6">
                                        <label for="expressbees_api_key" class="form-label">
                                                <strong>API Key (Optional)</strong>
                                        </label>
                                        <input type="text" 
                                               class="form-control" 
                                               id="expressbees_api_key" 
                                               name="expressbees_api_key" 
                                               value="<?php echo e(old('expressbees_api_key', $expressbeesSettings['api_key'] ?? '')); ?>"
                                                   placeholder="Enter your XpressBees API key">
                                            <small class="text-muted">Optional: API key from <a href="https://expressbees.com" target="_blank">XpressBees Dashboard</a></small>
                                        <?php $__errorArgs = ['expressbees_api_key'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>
                                    </div>

                                    <div class="mt-4">
                                        <button type="submit" class="admin-btn-primary">
                                            <i class="bi bi-save"></i> Save XpressBees Settings
                                        </button>
                            </div>
                        </div>
                            </div>
                        </form>
                    </div>

                    <!-- Ekart Configuration -->
                    <div class="tab-pane fade <?php echo e($carrierTab === 'ekart' ? 'show active' : ''); ?>" id="carrier-ekart" role="tabpanel" aria-labelledby="carrier-ekart-tab">
                        <form action="<?php echo e(route('admin.settings.carriers.update')); ?>" method="POST" class="mt-3">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('PUT'); ?>
                            <input type="hidden" name="selected_carrier" value="ekart">

                        <div class="card border-primary mb-4" style="background-color: #f8f9fa;">
                            <div class="card-body">
                                <h6 class="card-title mb-3" style="color: var(--admin-primary);">
                                    <i class="bi bi-truck"></i> Ekart Configuration
                                </h6>
                                
                                <!-- Status Toggle -->
                                <div class="mb-4">
                                    <label class="form-label"><strong>Status *</strong></label>
                                    <div class="d-flex gap-4">
                                        <div class="form-check">
                                            <input class="form-check-input" 
                                                   type="radio" 
                                                   name="ekart_enabled" 
                                                   id="ekart_active" 
                                                   value="1"
                                                   <?php echo e(old('ekart_enabled', $ekartSettings['enabled'] ?? '0') === '1' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="ekart_active">
                                                Active
                                            </label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input" 
                                                   type="radio" 
                                                   name="ekart_enabled" 
                                                   id="ekart_inactive" 
                                                   value="0"
                                                   <?php echo e(old('ekart_enabled', $ekartSettings['enabled'] ?? '0') === '0' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="ekart_inactive">
                                                Inactive
                                            </label>
                                        </div>
                                    </div>
                                    <small class="text-muted">Enable or disable Ekart carrier</small>
                                </div>

                                <!-- Process Type -->
                                <div class="mb-4">
                                    <label class="form-label"><strong>Process Type *</strong></label>
                                    <div class="d-flex gap-4">
                                        <div class="form-check">
                                            <input class="form-check-input carrier-process-type" type="radio" name="ekart_process_type" id="ekart_process_automatic" value="automatic" data-carrier="ekart"
                                                   <?php echo e(old('ekart_process_type', $ekartSettings['process_type'] ?? 'automatic') === 'automatic' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="ekart_process_automatic">Automatic</label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input carrier-process-type" type="radio" name="ekart_process_type" id="ekart_process_manual" value="manual" data-carrier="ekart"
                                                   <?php echo e(old('ekart_process_type', $ekartSettings['process_type'] ?? 'automatic') === 'manual' ? 'checked' : ''); ?>>
                                            <label class="form-check-label" for="ekart_process_manual">Manual</label>
                                        </div>
                                    </div>
                                    <small class="text-muted">Automatic: API creates shipment. Manual: staff enters tracking on the order.</small>
                                </div>
                                
                                <div class="carrier-config-fields mb-4" id="ekart-config" style="<?php echo e(old('ekart_process_type', $ekartSettings['process_type'] ?? 'automatic') === 'manual' ? 'display:none;' : ''); ?>">
                                <div class="row mb-3">
                                    <div class="col-md-6">
                                        <label for="ekart_username" class="form-label">
                                            <strong>Username *</strong>
                                        </label>
                                        <input type="text" 
                                               class="form-control" 
                                               id="ekart_username" 
                                               name="ekart_username" 
                                               value="<?php echo e(old('ekart_username', $ekartSettings['username'] ?? '')); ?>"
                                               placeholder="Enter your Ekart username">
                                        <small class="text-muted">Username used for Ekart API authentication</small>
                                        <?php $__errorArgs = ['ekart_username'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                    <div class="col-md-6">
                                        <label for="ekart_password" class="form-label">
                                            <strong>Password *</strong>
                                        </label>
                                        <input type="password" 
                                               class="form-control" 
                                               id="ekart_password" 
                                               name="ekart_password" 
                                               value="<?php echo e(old('ekart_password', $ekartSettings['password'] ?? '')); ?>"
                                               placeholder="Enter your Ekart password">
                                        <small class="text-muted">Password used for Ekart API authentication</small>
                                        <?php $__errorArgs = ['ekart_password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>
                                
                                <div class="row mb-3">
                                    <div class="col-md-6">
                                        <label for="ekart_client_id" class="form-label">
                                            <strong>Client ID *</strong>
                                        </label>
                                        <input type="text" 
                                               class="form-control" 
                                               id="ekart_client_id" 
                                               name="ekart_client_id" 
                                               value="<?php echo e(old('ekart_client_id', $ekartSettings['client_id'] ?? '')); ?>"
                                               placeholder="Enter your Client ID">
                                        <small class="text-muted">Client ID provided by Ekart during onboarding</small>
                                        <?php $__errorArgs = ['ekart_client_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                    <div class="col-md-6">
                                        <label for="ekart_api_url" class="form-label">
                                            <strong>API URL *</strong>
                                        </label>
                                        <input type="url" 
                                               class="form-control" 
                                               id="ekart_api_url" 
                                               name="ekart_api_url" 
                                               value="<?php echo e(old('ekart_api_url', $ekartSettings['api_url'] ?? 'https://app.elite.ekartlogistics.in')); ?>"
                                               placeholder="https://app.elite.ekartlogistics.in">
                                        <small class="text-muted">Ekart API endpoint URL</small>
                                        <?php $__errorArgs = ['ekart_api_url'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>
                                
                                <div class="row mb-3">
                                    <div class="col-md-6">
                                        <label for="ekart_api_key" class="form-label">
                                            <strong>API Key (Optional)</strong>
                                        </label>
                                        <input type="text" 
                                               class="form-control" 
                                               id="ekart_api_key" 
                                               name="ekart_api_key" 
                                               value="<?php echo e(old('ekart_api_key', $ekartSettings['api_key'] ?? '')); ?>"
                                               placeholder="Enter your Ekart API key (optional)">
                                        <small class="text-muted">Optional: API key for backward compatibility</small>
                                        <?php $__errorArgs = ['ekart_api_key'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>

                                <div class="row mb-3">
                                    <div class="col-md-6">
                                        <label for="ekart_webhook_secret" class="form-label">
                                            <strong>Webhook Secret</strong>
                                        </label>
                                        <input type="password"
                                               class="form-control"
                                               id="ekart_webhook_secret"
                                               name="ekart_webhook_secret"
                                               value="<?php echo e(old('ekart_webhook_secret', $ekartSettings['webhook_secret'] ?? '')); ?>"
                                               placeholder="Enter webhook secret (6-30 chars)">
                                        <small class="text-muted">Use the same secret while creating webhook in the Ekart portal.</small>
                                        <?php $__errorArgs = ['ekart_webhook_secret'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="text-danger small"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>

                                <div class="card border-primary mb-4" style="background-color: #f8f9fa;">
                                    <div class="card-body">
                                        <h6 class="card-title mb-3" style="color: var(--admin-primary);">
                                            <i class="bi bi-webhook"></i> Ekart Webhook Configuration (Manual)
                                        </h6>

                                        <div class="mb-3">
                                            <label class="form-label fw-bold">Webhook URL:</label>
                                            <div class="input-group">
                                                <input type="text"
                                                       class="form-control"
                                                       id="ekart_webhook_url"
                                                       value="<?php echo e($ekartWebhookUrl); ?>"
                                                       readonly>
                                                <button class="btn btn-outline-secondary"
                                                        type="button"
                                                        onclick="copyWebhookUrl(event, 'ekart_webhook_url')"
                                                        title="Copy to clipboard">
                                                    <i class="bi bi-clipboard"></i> Copy
                                                </button>
                                            </div>
                                            <small class="text-muted">Add this URL in Ekart portal while creating webhook.</small>
                                        </div>

                                        <?php if(!empty($ekartSettings['webhook_secret'])): ?>
                                        <div class="alert alert-success mb-3">
                                            <i class="bi bi-check-circle-fill"></i>
                                            <strong>Webhook Secret Configured</strong>
                                            <p class="mb-0 small">Use the same secret value in the Ekart webhook form.</p>
                                        </div>
                                        <?php else: ?>
                                        <div class="alert alert-warning mb-3">
                                            <i class="bi bi-exclamation-triangle-fill"></i>
                                            <strong>Webhook Secret Missing</strong>
                                            <p class="mb-0 small">Add a webhook secret to improve webhook security.</p>
                                        </div>
                                        <?php endif; ?>

                                        <div class="mb-3">
                                            <strong>Ekart Portal Values:</strong>
                                            <ul class="small mb-0 mt-2">
                                                <li><code>url</code>: Paste the webhook URL above</li>
                                                <li><code>secret</code>: Same value as "Webhook Secret" field</li>
                                                <li><code>topics</code>: <code>track_updated</code> (required), optionally <code>shipment_created</code> and <code>shipment_recreated</code></li>
                                                <li><code>active</code>: <code>true</code></li>
                                            </ul>
                                        </div>

                                        <div class="d-flex gap-2">
                                            <a href="https://app.elite.ekartlogistics.in/api/docs"
                                               target="_blank"
                                               class="btn btn-outline-secondary btn-sm">
                                                <i class="bi bi-book"></i> Ekart API Docs
                                            </a>
                                        </div>
                                    </div>
                                </div>
                                </div>

                    <div class="mt-4">
                        <button type="submit" class="admin-btn-primary">
                                            <i class="bi bi-save"></i> Save Ekart Settings
                                        </button>
                                    </div>
                                </div>
                    </div>
                </form>
            </div>

                    <!-- India Postal Configuration -->
                    <div class="tab-pane fade <?php echo e($carrierTab === 'indiapost' ? 'show active' : ''); ?>" id="carrier-indiapost" role="tabpanel" aria-labelledby="carrier-indiapost-tab">
                        <form action="<?php echo e(route('admin.settings.carriers.update')); ?>" method="POST" class="mt-3">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('PUT'); ?>
                            <input type="hidden" name="selected_carrier" value="indiapost">
                            <div class="card border-primary mb-4" style="background-color: #f8f9fa;">
                                <div class="card-body">
                                    <h6 class="card-title mb-3" style="color: var(--admin-primary);">
                                        <i class="bi bi-truck"></i> India Postal Configuration
                                    </h6>
                                    <div class="mb-4">
                                        <label class="form-label"><strong>Status *</strong></label>
                                        <div class="d-flex gap-4">
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="indiapost_enabled" id="indiapost_active" value="1" <?php echo e(old('indiapost_enabled', $indiapostSettings['enabled'] ?? '0') === '1' ? 'checked' : ''); ?>>
                                                <label class="form-check-label" for="indiapost_active">Active</label>
                                            </div>
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="indiapost_enabled" id="indiapost_inactive" value="0" <?php echo e(old('indiapost_enabled', $indiapostSettings['enabled'] ?? '0') === '0' ? 'checked' : ''); ?>>
                                                <label class="form-check-label" for="indiapost_inactive">Inactive</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="mb-4">
                                        <label class="form-label"><strong>Process Type *</strong></label>
                                        <div class="d-flex gap-4">
                                            <div class="form-check">
                                                <input class="form-check-input carrier-process-type" type="radio" name="indiapost_process_type" id="indiapost_process_automatic" value="automatic" data-carrier="indiapost"
                                                       <?php echo e(old('indiapost_process_type', $indiapostSettings['process_type'] ?? 'automatic') === 'automatic' ? 'checked' : ''); ?>>
                                                <label class="form-check-label" for="indiapost_process_automatic">Automatic</label>
                                            </div>
                                            <div class="form-check">
                                                <input class="form-check-input carrier-process-type" type="radio" name="indiapost_process_type" id="indiapost_process_manual" value="manual" data-carrier="indiapost"
                                                       <?php echo e(old('indiapost_process_type', $indiapostSettings['process_type'] ?? 'automatic') === 'manual' ? 'checked' : ''); ?>>
                                                <label class="form-check-label" for="indiapost_process_manual">Manual</label>
                                            </div>
                                        </div>
                                        <small class="text-muted">Automatic: API creates shipment. Manual: staff enters tracking on the order.</small>
                                    </div>
                                    <div class="carrier-config-fields mb-4" id="indiapost-config" style="<?php echo e(old('indiapost_process_type', $indiapostSettings['process_type'] ?? 'automatic') === 'manual' ? 'display:none;' : ''); ?>">
                                        <div class="row mb-3">
                                            <div class="col-md-6">
                                                <label for="indiapost_api_url" class="form-label"><strong>API URL *</strong></label>
                                                <input type="url" class="form-control" id="indiapost_api_url" name="indiapost_api_url" value="<?php echo e(old('indiapost_api_url', $indiapostSettings['api_url'] ?? 'https://api.indiapost.gov.in')); ?>" placeholder="https://api.indiapost.gov.in">
                                            </div>
                                            <div class="col-md-6">
                                                <label for="indiapost_api_token" class="form-label"><strong>API Token</strong></label>
                                                <input type="text" class="form-control" id="indiapost_api_token" name="indiapost_api_token" value="<?php echo e(old('indiapost_api_token', $indiapostSettings['api_token'] ?? '')); ?>">
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <div class="col-md-6">
                                                <label for="indiapost_from_pincode" class="form-label">From Pincode</label>
                                                <input type="text" class="form-control" id="indiapost_from_pincode" name="indiapost_from_pincode" value="<?php echo e(old('indiapost_from_pincode', $indiapostSettings['from_pincode'] ?? '')); ?>">
                                            </div>
                                            <div class="col-md-6">
                                                <label for="indiapost_from_name" class="form-label">From Name</label>
                                                <input type="text" class="form-control" id="indiapost_from_name" name="indiapost_from_name" value="<?php echo e(old('indiapost_from_name', $indiapostSettings['from_name'] ?? '')); ?>">
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <div class="col-12">
                                                <label for="indiapost_from_address" class="form-label">From Address</label>
                                                <input type="text" class="form-control" id="indiapost_from_address" name="indiapost_from_address" value="<?php echo e(old('indiapost_from_address', $indiapostSettings['from_address'] ?? '')); ?>">
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <div class="col-md-6">
                                                <label for="indiapost_from_city" class="form-label">From City</label>
                                                <input type="text" class="form-control" id="indiapost_from_city" name="indiapost_from_city" value="<?php echo e(old('indiapost_from_city', $indiapostSettings['from_city'] ?? '')); ?>">
                                            </div>
                                            <div class="col-md-6">
                                                <label for="indiapost_from_state" class="form-label">From State</label>
                                                <input type="text" class="form-control" id="indiapost_from_state" name="indiapost_from_state" value="<?php echo e(old('indiapost_from_state', $indiapostSettings['from_state'] ?? '')); ?>">
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <div class="col-md-6">
                                                <label for="indiapost_from_phone" class="form-label">From Phone</label>
                                                <input type="text" class="form-control" id="indiapost_from_phone" name="indiapost_from_phone" value="<?php echo e(old('indiapost_from_phone', $indiapostSettings['from_phone'] ?? '')); ?>">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="mt-4">
                                        <button type="submit" class="admin-btn-primary"><i class="bi bi-save"></i> Save India Postal Settings</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                    <!-- Other (Manual only) -->
                    <div class="tab-pane fade <?php echo e($carrierTab === 'other' ? 'show active' : ''); ?>" id="carrier-other" role="tabpanel" aria-labelledby="carrier-other-tab">
                        <form action="<?php echo e(route('admin.settings.carriers.update')); ?>" method="POST" class="mt-3">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('PUT'); ?>
                            <input type="hidden" name="selected_carrier" value="other">
                            <div class="card border-primary mb-4" style="background-color: #f8f9fa;">
                                <div class="card-body">
                                    <h6 class="card-title mb-3" style="color: var(--admin-primary);">
                                        <i class="bi bi-truck"></i> Other Carrier (Manual Only)
                                    </h6>
                                    <div class="mb-4">
                                        <label class="form-label"><strong>Status *</strong></label>
                                        <div class="d-flex gap-4">
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="other_enabled" id="other_active" value="1" <?php echo e(old('other_enabled', $otherSettings['enabled'] ?? '0') === '1' ? 'checked' : ''); ?>>
                                                <label class="form-check-label" for="other_active">Active</label>
                                            </div>
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="other_enabled" id="other_inactive" value="0" <?php echo e(old('other_enabled', $otherSettings['enabled'] ?? '0') === '0' ? 'checked' : ''); ?>>
                                                <label class="form-check-label" for="other_inactive">Inactive</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="mb-4">
                                        <label class="form-label"><strong>Process Type</strong></label>
                                        <p class="text-muted mb-0">Manual only. Staff will send the order manually and enter the tracking number on the order.</p>
                                    </div>
                                    <div class="mt-4">
                                        <button type="submit" class="admin-btn-primary"><i class="bi bi-save"></i> Save Other Carrier Settings</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
        </div>
    </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
    // Handle tab switching via URL hash
    document.addEventListener('DOMContentLoaded', function() {
        const hash = window.location.hash;
        if (hash) {
            const tab = hash.replace('#', '');
            const tabElement = document.querySelector(`button[data-bs-target="#${tab}"]`);
            if (tabElement) {
                const tabInstance = new bootstrap.Tab(tabElement);
                tabInstance.show();
            }
        }

        // Update URL hash when tab changes
        const tabButtons = document.querySelectorAll('#settingsTabs button[data-bs-toggle="tab"]');
        tabButtons.forEach(button => {
            button.addEventListener('shown.bs.tab', function(e) {
                const target = e.target.getAttribute('data-bs-target');
                window.location.hash = target.replace('#', '');
            });
        });

        const carrierTabs = document.querySelectorAll('#carrierTabs button[data-bs-toggle="tab"]');
        carrierTabs.forEach(button => {
            button.addEventListener('shown.bs.tab', function(e) {
                const carrier = e.target.getAttribute('data-carrier');
                const url = new URL(window.location);
                url.searchParams.set('tab', 'carriers');
                url.searchParams.set('carrier', carrier);
                window.history.replaceState({}, '', url);
            });
        });

        // Toggle carrier config fields when process type (Automatic/Manual) changes
        document.querySelectorAll('.carrier-process-type').forEach(function(radio) {
            radio.addEventListener('change', function() {
                const carrier = this.getAttribute('data-carrier');
                const configEl = document.getElementById(carrier + '-config');
                if (configEl) {
                    configEl.style.display = this.value === 'automatic' ? '' : 'none';
                }
            });
        });
    });

    // Copy webhook URL to clipboard
    function copyWebhookUrl(event, inputId = 'webhook_url') {
        const webhookUrlInput = document.getElementById(inputId);
        if (!webhookUrlInput) {
            return;
        }

        webhookUrlInput.select();
        webhookUrlInput.setSelectionRange(0, 99999); // For mobile devices
        
        const button = event ? event.target.closest('button') : null;
        if (!button) {
            return;
        }

        const originalHTML = button.innerHTML;
        
        try {
            if (navigator.clipboard && navigator.clipboard.writeText) {
                navigator.clipboard.writeText(webhookUrlInput.value).then(function() {
                    // Show success feedback
                    button.innerHTML = '<i class="bi bi-check"></i> Copied!';
                    button.classList.add('btn-success');
                    button.classList.remove('btn-outline-secondary');
                    
                    setTimeout(function() {
                        button.innerHTML = originalHTML;
                        button.classList.remove('btn-success');
                        button.classList.add('btn-outline-secondary');
                    }, 2000);
                }).catch(function(err) {
                    // Fallback if clipboard API fails
                    document.execCommand('copy');
                    alert('Webhook URL copied to clipboard!');
                });
            } else {
                // Fallback for older browsers
                document.execCommand('copy');
                button.innerHTML = '<i class="bi bi-check"></i> Copied!';
                button.classList.add('btn-success');
                button.classList.remove('btn-outline-secondary');
                
                setTimeout(function() {
                    button.innerHTML = originalHTML;
                    button.classList.remove('btn-success');
                    button.classList.add('btn-outline-secondary');
                }, 2000);
            }
        } catch (err) {
            alert('Webhook URL copied to clipboard!');
        }
    }
</script>
<?php $__env->stopPush(); ?>


<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/shaa_jewels/live/resources/views/admin/settings/index.blade.php ENDPATH**/ ?>