@extends('layouts.app')

@section('title', __('settings.pos_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.pos_settings.title') }}</li>
                </ol>
            </nav>
            <h4 class="fw-bold mb-0">{{ __('settings.pos_settings.title') }}</h4>
            <div class="text-muted small">{{ __('settings.pos_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

    <div class="card sa-card border-0">
        <div class="card-body">
            <form method="POST" action="{{ route('settings.pos-settings.store') }}">
                @csrf
                @if($cards->isEmpty())
                    <div class="text-center py-5 text-muted">
                        <i class="bi bi-sliders fs-1 d-block mb-3"></i>
                        <div>{{ __('settings.pos_settings.empty') }}</div>
                    </div>
                @else
                    <div class="sa-smart-list">
                        @foreach($cards as $card)
                            <div class="sa-smart-row">
                                <div class="d-flex align-items-center gap-3">
                                    <div class="sa-icon sa-icon-sm"><i class="bi bi-grid"></i></div>
                                    <div>
                                        <div class="fw-semibold">
                                            {{ app()->getLocale() == 'ar' ? $card->name_ar : $card->name_en }}
                                        </div>
                                        <div class="text-muted small">{{ $card->key }}</div>
                                    </div>
                                </div>
                                <div class="d-flex align-items-center gap-2">
                                    <div class="form-check form-switch mb-0">
                                        <input type="hidden" name="cards[{{ $card->id }}][is_visible]" value="0">
                                        <input class="form-check-input" type="checkbox" role="switch" id="pos_card_{{ $card->id }}" name="cards[{{ $card->id }}][is_visible]" value="1" {{ $card->is_visible ? 'checked' : '' }}>
                                        <label class="form-check-label" for="pos_card_{{ $card->id }}">
                                            {{ $card->is_visible ? __('settings.pos_settings.visible') : __('settings.pos_settings.hidden') }}
                                        </label>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    </div>

                    <div class="d-flex justify-content-end mt-3">
                        <button type="submit" class="btn btn-primary">
                            <i class="bi bi-save me-1"></i> {{ __('common.save') }}
                        </button>
                    </div>
                @endif
            </form>
        </div>
    </div>
</div>
@endsection
