@extends('layouts.main')

@section('content')
<div class="row">
    <div class="col-md-8 mx-auto">
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h4 class="mb-0">Settings</h4>
            </div>
            <div class="card-body">
                @if(session('success'))
                    <div class="alert alert-success">{{ session('success') }}</div>
                @endif

                <ul class="nav nav-tabs mb-4" id="settingsTabs" role="tablist">
                    <li class="nav-item">
                        <button class="nav-link active" id="receipt-tab" data-bs-toggle="tab" data-bs-target="#receipt" type="button">Receipt Settings</button>
                    </li>
                    <li class="nav-item">
                        <button class="nav-link" id="report-tab" data-bs-toggle="tab" data-bs-target="#report" type="button">Report Settings</button>
                    </li>
                    @if(Auth::user() && Auth::user()->isSuperAdmin())
                    <li class="nav-item ms-auto">
                        <a class="nav-link text-danger" href="{{ route('settings.system') }}">
                            <i class="bi bi-gear"></i> System Settings
                        </a>
                    </li>
                    @endif
                </ul>

                <form method="POST" action="{{ route('settings.update') }}">
                    @csrf

                    <div class="tab-content" id="settingsTabsContent">
                        <div class="tab-pane fade show active" id="receipt" role="tabpanel">
                            <div class="mb-3">
                                <label class="form-label">Receipt Header (Business Name)</label>
                                <input type="text" class="form-control" name="receipt_header" value="{{ $receiptSettings['receipt_header'] }}">
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Tagline</label>
                                <input type="text" class="form-control" name="receipt_tagline" value="{{ $receiptSettings['receipt_tagline'] }}" placeholder="e.g., Your Trusted Shopping Destination">
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Address</label>
                                <input type="text" class="form-control" name="receipt_address" value="{{ $receiptSettings['receipt_address'] }}">
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Phone</label>
                                <input type="text" class="form-control" name="receipt_phone" value="{{ $receiptSettings['receipt_phone'] }}">
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Footer Message</label>
                                <textarea class="form-control" name="receipt_footer" rows="2">{{ $receiptSettings['receipt_footer'] }}</textarea>
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Developer Advertisement (Bottom of Receipt)</label>
                                <textarea class="form-control" name="receipt_dev_ad" rows="2" placeholder="e.g., Developed by: Your Company | www.yourcompany.com">{{ $receiptSettings['receipt_dev_ad'] }}</textarea>
                            </div>
                        </div>

                        <div class="tab-pane fade" id="report" role="tabpanel">
                            <div class="mb-3">
                                <label class="form-label">Report Header Title</label>
                                <input type="text" class="form-control" name="report_header" value="{{ $reportSettings['report_header'] }}">
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Company Name</label>
                                <input type="text" class="form-control" name="report_company" value="{{ $reportSettings['report_company'] }}">
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Footer Message</label>
                                <textarea class="form-control" name="report_footer" rows="2">{{ $reportSettings['report_footer'] }}</textarea>
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Developer Advertisement (Bottom of Report)</label>
                                <textarea class="form-control" name="report_dev_ad" rows="2" placeholder="e.g., Software by: Your Company | www.yourcompany.com">{{ $reportSettings['report_dev_ad'] }}</textarea>
                            </div>
                        </div>
                    </div>

                    <button type="submit" class="btn btn-primary">Save Settings</button>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
