@extends('app.admin.layout.layout')
@section('title',__('Edit Room Category'))
@push('css')
    <link rel="stylesheet" href="{{asset('/assets/admin/plugins/src/image-uploader/uploader.css')}}">
@endpush
@section('content')
    <style>
        .form-control{
            border-radius: 10px;
            border: 1px solid #7b7bff;
            box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;        }
        .form-label{
            font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
        }
        .form-select{
            background-image: none !important;
        }
        .layout-top-spacing{
            margin: 20px;
            border-radius: 15px;
            box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
        }
        /* Ümumi container üçün stil */
.mt-3 {
    margin-top: 1rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

/* Label üçün stil */
label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

/* Select box üçün stil */
.tom-select {
    width: 100%;
    padding: 0.5rem;
    font-size: 1rem;
    color: #333;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tom-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
    outline: none;
}

/* Select elementinin genişliyini təyin etmək üçün */
.w-full {
    width: 100%;
}

/* Option elementləri üçün stil */
select option {
    padding: 0.5rem;
}

/* Mobil cihazlar üçün uyğunluq */
@media (max-width: 768px) {
    .tom-select {
        font-size: 0.9rem;
        padding: 0.4rem;
    }
}

    </style>
    <br><br><br>
    <div class="card layout-top-spacing">
        <div class="card-body">
            <div class="page-title-container">
                <div class="row">
                    <div class="col-12 col-md-7">
                        <h1 class="mb-0 pb-0 display-4" id="title">@lang('Edit Room Category')</h1>
                        <nav class="breadcrumb-container d-inline-block" aria-label="breadcrumb">
                                <ul class="breadcrumb pt-0">
                                        <li class="breadcrumb-item"><a href="{{ route('admin:home') }}">@lang('Home')</a></li>
                                        <li class="breadcrumb-item"><a href="{{ route('admin:roomCategories.index') }}">@lang('Room Categories')</a></li>
                                        <li class="breadcrumb-item"><a href="#">@lang('Edit Room Category')</a></li>
                                </ul>
                        </nav>
                    </div>

                    <div class="col-12 col-md-5 d-flex align-items-start justify-content-end">
                        <a href="{{ route('admin:roomCategories.index') }}">
                            <button type="button" class="btn btn-outline-primary btn-icon btn-icon-start w-100 w-md-auto">
                                <i data-acorn-icon="arrow-left" class="me-2" data-acorn-size="17"></i>
                                <span>@lang('Back')</span>
                            </button>
                        </a>
                    </div>
                </div>
            </div>
            <form @class(["row needs-validation","was-validated" => $errors->any()]) action="{{route('admin:roomCategories.update',$roomCategory->getAttribute('id'))}}" method="post" novalidate enctype="multipart/form-data">
                @csrf
                @method('PUT')

            <div class="col-12 p-0 p-md-3 d-flex flex-wrap flex-md-nowrap justify-content-center justify-content-md-start align-items-center">

                <div class="row w-100 my-auto">

                    <div class="row">
                        <div class="col-lg-3 col-sm-12 p-0 p-md-3 d-flex flex-wrap flex-md-nowrap justify-content-center justify-content-md-start align-items-center">
                                <div class="me-md-5" id="imageContainer">
                                    <img style="height: 224px; width: 427px; object-fit: contain; cursor:pointer;" src="{{$roomCategory->image()}}" class="img-thumbnail" alt="{{$roomCategory->room_category()}}" onclick="document.getElementById('fileInput').click()">
                                </div>
                                <!-- Hidden file input -->
                                <input id="fileInput" type="file" style="display:none;" name="image">
                        </div>
                    </div>

                    <x-admin.form.input
                        :label="__('Room Category Az')"
                        name="room_category_az"
                        custom-div-class="col-12 col-lg-12"
                        :value="old('room_category_az',$roomCategory->getAttribute('room_category_az'))"
                        required/>

                    <x-admin.form.input
                        :label="__('Room Category Ru')"
                        name="room_category_ru"
                        custom-div-class="col-12 col-lg-12"
                        :value="old('room_category_ru',$roomCategory->getAttribute('room_category_ru'))"
                        required/>

                    <x-admin.form.input
                        :label="__('Room Category En')"
                        name="room_category_en"
                        custom-div-class="col-12 col-lg-12"
                        :value="old('room_category_en',$roomCategory->getAttribute('room_category_en'))"
                        required/>


                    @php
                        $viewOptions = [
                            'room' => 'room',
                            'terrace' => 'terrace',
                        ];
                    @endphp
    
                    <x-admin.form.select
                        :label="__('Select Page')"
                        name="option"
                        custom-div-class="col-12 col-lg-3"
                        :selected="old('option',$roomCategory->getAttribute('option'))"
                        required
                        :options="$viewOptions"
                    />

                    <div class="mt-3">
                        <label>@lang('Select Main Category')</label>
                        <div class="mb-3">
                            <select name="menu_parent" class="tom-select w-full">
                                <option value=""> @lang('Select main category') </option>
                                @foreach($roomCategories as $roomCategory)
                                    <option @selected(old('menu_parent')) value="{{$roomCategory->getAttribute('id')}}"> {{ $roomCategory->room_category() }} </option>
                                @endforeach
                            </select>
                        </div>
                    </div>


                    <div class="col-span-12 mb-3">
                        <div class="form-check form-switch">
                            <input class="form-check-input" type="checkbox" id="use-background" name="show_in_main" @checked(old('show_in_main',$roomCategory->show_in_main))>
                            <label class="form-check-label" for="use-background">@lang('Show in main')</label>
                        </div>
                    </div>

                </div>
            </div>
                <x-admin.form.submit-button button-text="Update"/>
            </form>
        </div>
    </div>
@endsection
@push('js')
    <script src="{{asset('/assets/admin/plugins/src/image-uploader/uploader.js')}}"></script>

    <script src="{{asset('/assets/admin/plugins/src/tinymce/tinymce.min.js')}}"></script>
    <script>
        let tinyDarkActive = JSON.parse(localStorage.getItem("theme")).settings.layout.darkMode;
        tinymce.init({
            selector: 'textarea',
            plugins: [
                'advlist', 'autolink', 'link', 'image', 'lists', 'charmap', 'preview', 'anchor', 'pagebreak',
                'searchreplace', 'wordcount', 'visualblocks', 'visualchars', 'code', 'fullscreen', 'insertdatetime',
                'media', 'table', 'emoticons', 'help'
            ],
            skin: tinyDarkActive ? "oxide-dark" : null,
            content_css: tinyDarkActive ? "dark" : null,
            @if(in_array(app()->getLocale(),['az','ru']))
            language: '{{app()->getLocale()}}'
            @endif
        });
    </script>
@endpush
