@extends('layouts.sadmin')
@section('title', 'Application Branding')

@push('styles')
<link href="{{ asset('css/axis-enterprise.css') }}?v={{ filemtime(public_path('css/axis-enterprise.css')) }}" rel="stylesheet">
<link href="{{ asset('css/axis-sadmin-branding.css') }}?v={{ filemtime(public_path('css/axis-sadmin-branding.css')) }}" rel="stylesheet">
@endpush

@section('content')
@if($errors->any())
<div class="alert alert-danger alert-dismissible fade show mb-3" style="font-size:13px">
    <ul class="mb-0 ps-3">
        @foreach($errors->all() as $error)
            <li>{{ $error }}</li>
        @endforeach
    </ul>
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
@endif

<div class="mb-4">
    <h1 class="page-title mb-1">Application Branding</h1>
    <p class="text-muted mb-0" style="font-size:13px">
        Manage the platform logo shown on login and select-company pages before a tenant is chosen.
    </p>
</div>

<div class="row g-4">
    <div class="col-12 col-xl-7">
        <div class="card">
            <div class="card-header">
                <i class="bi bi-image me-2 text-primary"></i>Application Logo
            </div>
            <div class="card-body">
                @include('superadmin.branding._upload-form', ['logo' => $logo, 'formId' => 'Full'])
            </div>
        </div>
    </div>

    <div class="col-12 col-xl-5">
        <div class="card mb-4">
            <div class="card-header"><i class="bi bi-lightbulb me-2 text-warning"></i>How it works</div>
            <div class="card-body" style="font-size:13px;color:#475569">
                <p class="mb-2">Like QuickBooks and Xero, the app stores <strong>one master image</strong> and scales it per screen with CSS.</p>
                <ul class="mb-0 ps-3">
                    <li class="mb-2"><strong>Application logo</strong> (here) — login, select-company header, top bar</li>
                    <li class="mb-2"><strong>Company logo</strong> (Settings → General per company) — sidebar, reports, documents</li>
                    <li>Sidebar shows the company logo; if none is uploaded, the application logo is used there only</li>
                </ul>
            </div>
        </div>

        @if($logo['is_custom'])
        <div class="card border-danger">
            <div class="card-header text-danger"><i class="bi bi-trash me-2"></i>Remove Custom Logo</div>
            <div class="card-body">
                <p class="text-muted mb-3" style="font-size:13px">
                    Reverts login pages to the default {{ config('app.name') }} logo.
                </p>
                <form method="POST" action="{{ route('sadmin.branding.destroy') }}"
                      onsubmit="return confirm('Remove the custom application logo?');">
                    @csrf
                    @method('DELETE')
                    <button type="submit" class="btn btn-outline-danger btn-sm">
                        <i class="bi bi-trash me-1"></i>Remove Logo
                    </button>
                </form>
            </div>
        </div>
        @endif
    </div>
</div>
@endsection
