@section('header')
	@include('common.header')
@stop

@section('content')
	<div class="row">
		<div class="col-sm-8">
			<div class="widget widget-classic">
				<div class="widget-content">

					<!-- Page title -->
					<p class="lead">
						Dashboard Tabs Settings
					</p>

					@if(session('success'))
						<div class="alert alert-success">
							<i class="fa fa-check-circle"></i> {{ session('success') }}
						</div>
					@endif

					<form action="{{ route('admin.dashboard-tabs.update-all') }}" method="POST" id="mainForm">
						@csrf
						@method('PUT')

						<table class="table table-hover">
							<thead>
								<tr>
									<th>Tab Label</th>
									<th style="width: 100px; text-align: center;">Visible</th>
								</tr>
							</thead>
							<tbody>
								@foreach($tabs as $tab)
									<tr>
										<td>
											<input type="text" name="tabs[{{ $tab->id }}][tab_label]" class="form-control input-sm" value="{{ $tab->tab_label }}" required style="max-width: 500px;">
										</td>
										<td class="text-center">
											<input type="checkbox" name="tabs[{{ $tab->id }}][is_visible]" value="1" {{ $tab->is_visible ? 'checked' : '' }}>
										</td>
									</tr>
								@endforeach
							</tbody>
						</table>

						<div class="form-group">
							<button type="submit" class="btn btn-primary">
								<i class="fa fa-save"></i> Save Changes
							</button>
					</form>

					<form action="{{ route('admin.dashboard-tabs.reset') }}" method="POST" id="resetForm" style="display: inline;">
						@csrf
						<button type="submit" class="btn btn-default" onclick="return confirm('Are you sure you want to reset all tabs to default labels and make them all visible? This will save immediately.');">
							<i class="fa fa-undo"></i> Reset to Default
						</button>
					</form>
						</div>

					<hr>
					<p><small>Total of {{ count($tabs) }} tabs</small></p>
				</div>
			</div>
		</div>
		<div class="col-sm-4">
			<div class="widget widget-classic">
				<div class="widget-content">
					<p class="lead"><i class="fa fa-info-circle"></i> Help</p>

					<p>Here you can configure the dashboard tabs visibility and labels.</p>

					<p><strong>Visibility:</strong> Check the box to show the tab on the dashboard, uncheck to hide it.</p>

					<p><strong>Labels:</strong> Edit the tab labels to customize how they appear on the dashboard.</p>

					<p><strong>Reset:</strong> Click "Reset to Default" to restore the original tab labels and make all tabs visible. This will save immediately.</p>

					<p><strong>Note:</strong> Changes will be applied after clicking Save Changes. You may need to refresh the dashboard to see the changes.</p>
				</div>
			</div>
		</div>
	</div>

@stop
