@extends('mental.layouts.app')

@section('content')
    <div class="container py-4">
        <!-- Main Header with Right-Aligned Button -->
        <div class="main-header mb-4 d-flex justify-content-between align-items-center">
            <h1 class="h2">Alcohol Use Disorders Identification Test (AUDIT)</h1>
            <button type="button" class="btn btn-sm btn-outline-secondary show-view" data-view="dashboard">
                <i class="bi bi-arrow-left"></i> Back to Dashboard
            </button>
        </div>

        <!-- Instructions Section -->
        <h2 class="h5">Instructions</h2>
        <p>
        The following questions ask about your use of alcoholic beverages during the past year. For each question, select the answer that best describes your drinking.
        </p>
    </div>
    <form id="questionForm" onsubmit="submitForm(event)" class="ajax-form forms-sample" method="post"
        action="{{ route('mentalHealth.auditStore') }}" data-redirect="{{ route('mentalHealth.dashboard') }}">
        <!-- Centered Content with Card and Progress Bar -->
        <div class="d-flex justify-content-center min-vh-75 align-items-center">
            <div class="col-sm-12 col-xl-6">

                <!-- Progress Bar -->
                <div class="progress mb-4">
                    <div class="progress-bar bg-primary" id="progress-bar" role="progressbar" style="width: 0%;"
                        aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
                </div>

                <!-- Question 1 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question" data-question="1">
                    <h6 class="mb-4 text-white">How often do you have a drink containing alcohol?</h6>
                    <input type="hidden" name="question" value="How often do you have a drink containing alcohol?">
                
                    @for ($i = 0; $i <= 4; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question1" id="question1_{{ $i }}" value="{{ $i }}">
                            <label class="form-check-label text-white" for="question1_{{ $i }}">
                                {{ ['Never', 'Monthly or less', '2-4 times a month', '2-3 times a week', '4 or more times a week'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)" id="prevBtn">Previous</button>
                        <button class="btn btn-primary" id="nextBtn" onclick="navigateQuestion(1, event)">Next</button>
                    </div>
                </div>
                
                <!-- Question 2 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question d-none" data-question="2">
                    <h6 class="mb-4 text-white">How many drinks containing alcohol do you have on a typical day when you are drinking?</h6>
                    <input type="hidden" name="question" value="How many drinks containing alcohol do you have on a typical day when you are drinking?">
                
                    @for ($i = 0; $i <= 4; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question2" id="question2_{{ $i }}" value="{{ $i }}">
                            <label class="form-check-label text-white" for="question2_{{ $i }}">
                                {{ ['1 or 2', '3 or 4', '5 or 6', '7 to 9', '10 or more'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)" id="prevBtn">Previous</button>
                        <button class="btn btn-primary" id="nextBtn" onclick="navigateQuestion(1, event)">Next</button>
                    </div>
                </div>
                
                <!-- Question 3 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question d-none" data-question="3">
                    <h6 class="mb-4 text-white">How often do you have six or more drinks on one occasion?</h6>
                    <input type="hidden" name="question" value="How often do you have six or more drinks on one occasion?">
                
                    @for ($i = 0; $i <= 4; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question3" id="question3_{{ $i }}" value="{{ $i }}">
                            <label class="form-check-label text-white" for="question3_{{ $i }}">
                                {{ ['Never', 'Less than monthly', 'Monthly', 'Weekly', 'Daily or almost daily'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)" id="prevBtn">Previous</button>
                        <button class="btn btn-primary" id="nextBtn" onclick="navigateQuestion(1, event)">Next</button>
                    </div>
                </div>
                
                <!-- Question 4 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question d-none" data-question="4">
                    <h6 class="mb-4 text-white">How often during the last year have you found that you were not able to stop drinking once you had started?</h6>
                    <input type="hidden" name="question" value="How often during the last year have you found that you were not able to stop drinking once you had started?">
                
                    @for ($i = 0; $i <= 4; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question4" id="question4_{{ $i }}" value="{{ $i }}">
                            <label class="form-check-label text-white" for="question4_{{ $i }}">
                                {{ ['Never', 'Less than monthly', 'Monthly', 'Weekly', 'Daily or almost daily'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)" id="prevBtn">Previous</button>
                        <button class="btn btn-primary" id="nextBtn" onclick="navigateQuestion(1, event)">Next</button>
                    </div>
                </div>
                
                <!-- Question 5 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question d-none" data-question="5">
                    <h6 class="mb-4 text-white">How often during the last year have you failed to do what was normally expected of you because of drinking?</h6>
                    <input type="hidden" name="question" value="How often during the last year have you failed to do what was normally expected of you because of drinking?">
                
                    @for ($i = 0; $i <= 4; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question5" id="question5_{{ $i }}" value="{{ $i }}">
                            <label class="form-check-label text-white" for="question5_{{ $i }}">
                                {{ ['Never', 'Less than monthly', 'Monthly', 'Weekly', 'Daily or almost daily'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)" id="prevBtn">Previous</button>
                        <button class="btn btn-primary" id="nextBtn" onclick="navigateQuestion(1, event)">Next</button>
                    </div>
                </div>
                
                <!-- Question 6 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question d-none" data-question="6">
                    <h6 class="mb-4 text-white">How often during the last year have you needed a first drink in the morning to get yourself going after a heavy drinking session?</h6>
                    <input type="hidden" name="question" value="How often during the last year have you needed a first drink in the morning to get yourself going after a heavy drinking session?">
                
                    @for ($i = 0; $i <= 4; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question6" id="question6_{{ $i }}" value="{{ $i }}">
                            <label class="form-check-label text-white" for="question6_{{ $i }}">
                                {{ ['Never', 'Less than monthly', 'Monthly', 'Weekly', 'Daily or almost daily'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)" id="prevBtn">Previous</button>
                        <button class="btn btn-primary" id="nextBtn" onclick="navigateQuestion(1, event)">Next</button>
                    </div>
                </div>
                
                <!-- Question 7 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question d-none" data-question="7">
                    <h6 class="mb-4 text-white">How often during the last year have you had a feeling of guilt or remorse after drinking?</h6>
                    <input type="hidden" name="question" value="How often during the last year have you had a feeling of guilt or remorse after drinking?">
                
                    @for ($i = 0; $i <= 4; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question7" id="question7_{{ $i }}" value="{{ $i }}">
                            <label class="form-check-label text-white" for="question7_{{ $i }}">
                                {{ ['Never', 'Less than monthly', 'Monthly', 'Weekly', 'Daily or almost daily'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)" id="prevBtn">Previous</button>
                        <button class="btn btn-primary" id="nextBtn" onclick="navigateQuestion(1, event)">Next</button>
                    </div>
                </div>
                
                <!-- Question 8 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question d-none" data-question="8">
                    <h6 class="mb-4 text-white">How often during the last year have you been unable to remember what happened the night before because of your drinking?</h6>
                    <input type="hidden" name="question" value="How often during the last year have you been unable to remember what happened the night before because of your drinking?">
                
                    @for ($i = 0; $i <= 4; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question8" id="question8_{{ $i }}" value="{{ $i }}">
                            <label class="form-check-label text-white" for="question8_{{ $i }}">
                                {{ ['Never', 'Less than monthly', 'Monthly', 'Weekly', 'Daily or almost daily'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)" id="prevBtn">Previous</button>
                        <button class="btn btn-primary" id="nextBtn" onclick="navigateQuestion(1, event)">Next</button>
                    </div>
                </div>
                
                <!-- Question 9 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question d-none" data-question="9">
                    <h6 class="mb-4 text-white">Have you or someone else been injured because of your drinking?</h6>
                    <input type="hidden" name="question" value="Have you or someone else been injured because of your drinking?">
                
                    @for ($i = 0; $i <= 2; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question9" id="question9_{{ $i }}" value="{{ [0,2,4][$i] }}">
                            <label class="form-check-label text-white" for="question9_{{ $i }}">
                                {{ ['No', 'Yes, but not in the last year', 'Yes, during the last year'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)" id="prevBtn">Previous</button>
                        <button class="btn btn-primary" id="nextBtn" onclick="navigateQuestion(1, event)">Next</button>
                    </div>
                </div>
                
                <!-- Question 10 -->
                <div class="bg-secondary border border-white rounded h-100 p-4 question d-none" data-question="10">
                    <h6 class="mb-4 text-white">Has a relative, friend, doctor, or other health care worker been concerned about your drinking or suggested you cut down?</h6>
                    <input type="hidden" name="question" value="Has a relative, friend, doctor, or other health care worker been concerned about your drinking or suggested you cut down?">
                
                    @for ($i = 0; $i <= 2; $i++)
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="question10" id="question10_{{ $i }}" value="{{ [0,2,4][$i] }}">
                            <label class="form-check-label text-white" for="question10_{{ $i }}">
                                {{ ['No', 'Yes, but not in the last year', 'Yes, during the last year'][$i] }}
                            </label>
                        </div>
                        <hr>
                    @endfor
                
                    <div class="d-flex justify-content-between mt-4">
                        <button class="btn btn-outline-light" onclick="navigateQuestion(-1, event)">Previous</button>
                        <button class="btn btn-primary" id="nextBtnfinel" onclick="navigateQuestion(1, event)">Next</button>
                        <button type="submit" class="btn btn-success d-none" id="submitBtn">Submit</button>
                    </div>
                </div>

            </div>
        </div>
    </form>
    <!-- JavaScript for Navigation -->
@endsection
