@extends('layouts.app')

@section('content')
<div class="row mb-4">
    <div class="col-md-12">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb mb-1">
                <li class="breadcrumb-item"><a href="{{ route('dashboard') }}" class="text-decoration-none text-muted small">Dashboard</a></li>
                <li class="breadcrumb-item"><a href="{{ route('chatbot.index') }}" class="text-decoration-none text-muted small">Chatbot</a></li>
                <li class="breadcrumb-item active text-primary small fw-semibold" aria-current="page">Edit</li>
            </ol>
        </nav>
        <h2 class="fw-bold text-dark">Edit Chatbot Question</h2>
        <p class="text-secondary small">Update the selected question, answer, display status, or optional action button.</p>
    </div>
</div>

<div class="row">
    <div class="col-lg-8">
        <div class="card border-0 shadow-lg rounded-4 overflow-hidden">
            <div class="card-header bg-white border-0 py-3 px-4 mt-2">
                <h6 class="m-0 fw-bold text-dark"><i class="bi bi-pencil-square me-2 text-primary"></i> Edit Response Details</h6>
            </div>
            <div class="card-body p-4 pt-2">
                <form action="{{ route('chatbot.update', $question->id) }}" method="POST">
                    @csrf
                    @method('PUT')

                    @include('chatbot._form', ['question' => $question])

                    <hr class="my-4 opacity-50">

                    <div class="d-flex align-items-center justify-content-between flex-wrap gap-3">
                        <a href="{{ route('chatbot.index') }}" class="btn btn-link text-decoration-none text-secondary fw-semibold">
                            <i class="bi bi-x-circle me-1"></i> Discard Changes
                        </a>
                        <button type="submit" class="btn btn-primary rounded-3 px-5 fw-bold shadow-sm py-2">
                            <i class="bi bi-check-lg me-2"></i> Save Changes
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="col-lg-4 mt-4 mt-lg-0">
        <div class="card border-0 shadow-sm rounded-4 bg-white mb-4">
            <div class="card-body p-4">
                <h6 class="fw-bold text-dark mb-3"><i class="bi bi-info-circle me-2 text-primary"></i> Meta Information</h6>
                <div class="mb-3 pb-3 border-bottom d-flex justify-content-between align-items-center">
                    <span class="text-secondary small">Created At</span>
                    <span class="text-dark fw-medium small">{{ $question->created_at ? $question->created_at->format('M d, Y H:i') : 'Unavailable' }}</span>
                </div>
                <div class="mb-3 pb-3 border-bottom d-flex justify-content-between align-items-center">
                    <span class="text-secondary small">Last Updated</span>
                    <span class="text-dark fw-medium small">{{ $question->updated_at ? $question->updated_at->diffForHumans() : 'Not updated' }}</span>
                </div>
                <div class="d-flex justify-content-between align-items-center">
                    <span class="text-secondary small">Record ID</span>
                    <span class="badge bg-light text-dark border fw-bold">#{{ $question->id }}</span>
                </div>
            </div>
        </div>

        <div class="alert bg-primary-subtle text-primary border-0 rounded-4 p-4 shadow-sm">
            <div class="d-flex">
                <i class="bi bi-lightbulb-fill fs-4 me-3"></i>
                <div>
                    <h6 class="fw-bold mb-1">Quick Note</h6>
                    <p class="small mb-0 opacity-75">Changing status to inactive keeps the record saved while removing it from the active chatbot set.</p>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('styles')
<style>
    .input-group-text { border: none !important; }
    textarea.form-control { min-height: 150px; padding: 0.8rem; }
    .bg-primary-subtle { background-color: #eff6ff !important; }
</style>
@endsection
