@extends('layouts.app')

@section('title', __('settings.consultations_settings.title'))

@push('styles')
<link href="{{ asset('css/stage-academy.css') }}" rel="stylesheet">
@endpush

@section('content')
<div class="container-fluid">
    <div class="d-flex align-items-center justify-content-between gap-3 mb-4">
        <div class="flex-grow-1">
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb mb-1">
                    <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">{{ __('dashboard') }}</a></li>
                    <li class="breadcrumb-item"><a href="{{ route('settings') }}">{{ __('settings') }}</a></li>
                    <li class="breadcrumb-item active" aria-current="page">{{ __('settings.consultations_settings.title') }}</li>
                </ol>
            </nav>
            <h4 class="fw-bold mb-0">{{ __('settings.consultations_settings.title') }}</h4>
            <div class="text-muted small">{{ __('settings.consultations_settings.subtitle') }}</div>
        </div>
        <a href="{{ route('settings') }}" class="btn btn-outline-secondary app-back-end">
            <i class="bi bi-arrow-{{ app()->getLocale() == 'ar' ? 'right' : 'left' }}"></i> {{ __('common.back') }}
        </a>
    </div>

    @if(session('success'))
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            {{ session('success') }}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    @endif
    @if($errors->any())
        <div class="alert alert-danger">
            <ul class="mb-0">
                @foreach($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    @if(!$settings)
        <div class="card sa-card border-0">
            <div class="card-body">
                <div class="text-center py-5 text-muted">
                    <i class="bi bi-sliders fs-1 d-block mb-3"></i>
                    <div>{{ __('settings.consultations_settings.empty') }}</div>
                </div>
            </div>
        </div>
    @else
        <div class="row g-3 sa-grid">
            <div class="col-12 col-lg-6">
                <div class="card sa-card h-100">
                    <div class="card-body">
                        <div class="d-flex align-items-start justify-content-between gap-3">
                            <div class="d-flex align-items-center gap-3">
                                <div class="sa-icon"><i class="bi bi-megaphone"></i></div>
                                <div class="sa-text">
                                    <h6 class="mb-1 fw-bold">{{ __('settings.consultations_settings.campaigns.title') }}</h6>
                                    <p class="mb-0 text-muted">{{ __('settings.consultations_settings.campaigns.desc') }}</p>
                                </div>
                            </div>

                            <button class="btn btn-outline-primary btn-sm"
                                    type="button"
                                    data-bs-toggle="collapse"
                                    data-bs-target="#campaignSettingsCollapse"
                                    aria-expanded="false"
                                    aria-controls="campaignSettingsCollapse">
                                اظهار واخفاء
                            </button>
                        </div>

                        <div class="collapse mt-3" id="campaignSettingsCollapse">
                            <form method="POST" action="{{ route('settings.consultations-settings.store') }}" class="mb-0">
                                @csrf
                                <div class="form-check form-switch mb-0">
                                    <input type="hidden" name="campaign_management_enabled" value="0">
                                    <input class="form-check-input" type="checkbox" role="switch" id="campaign_management_enabled" name="campaign_management_enabled" value="1" {{ $settings->campaign_management_enabled ? 'checked' : '' }} onchange="this.form.submit()">
                                    <label class="form-check-label" for="campaign_management_enabled">
                                        {{ $settings->campaign_management_enabled ? __('settings.consultations_settings.visible') : __('settings.consultations_settings.hidden') }}
                                    </label>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    @endif
</div>
@endsection
