function PatientsTab({ filteredPatients, handleDeleteItem, handleOpenAssessment, lang, patientSearch, patients, setEditingPatient, setPatientSearch, setSelectedPatient, setShowAddPatient, setShowEditPatient, setShowPatientDetailModal, strings }) {
    return (
        <>
                            <div className="space-y-6">
                                <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
                                    <div>
                                        <h2 className="text-2xl font-extrabold text-brand-harbor">{lang === 'ar' ? 'سجلات المرضى والتاريخ الطبي' : 'Patient Records & Medical History'}</h2>
                                        <p className="text-brand-steel text-sm font-medium">{lang === 'ar' ? 'إدارة السجلات الطبية والروشتات والزيارات القابلة للتعديل بالكامل.' : 'Manage patient records with fully editable prescription & visit timeline items.'}</p>
                                    </div>
                                    <button 
                                        onClick={() => setShowAddPatient(true)}
                                        className="px-5 py-3 bg-brand-harbor hover:bg-brand-sky text-white rounded-2xl font-bold shadow-md shadow-brand-harbor/20 transition-all flex items-center space-x-2 rtl:space-x-reverse text-sm self-start"
                                    >
                                        <i data-lucide="user-plus" className="w-4 h-4"></i>
                                        <span>{strings.newPatient}</span>
                                    </button>
                                </div>

                                <div className="bg-white p-4 rounded-2xl border border-brand-dune/80 shadow-sm flex items-center space-x-3 rtl:space-x-reverse">
                                    <i data-lucide="search" className="w-5 h-5 text-brand-steel"></i>
                                    <input 
                                        type="text"
                                        value={patientSearch}
                                        onChange={(e) => setPatientSearch(e.target.value)}
                                        placeholder={strings.searchPatients}
                                        className="w-full bg-transparent text-brand-harbor placeholder-brand-steel/70 focus:outline-none text-sm font-medium"
                                    />
                                    {patientSearch && (
                                        <button onClick={() => setPatientSearch('')} className="text-brand-steel hover:text-brand-harbor text-xs font-bold">{strings.clear}</button>
                                    )}
                                </div>

                                <div className="bg-white rounded-3xl border border-brand-dune/80 shadow-md overflow-hidden">
                                    <div className="overflow-x-auto">
                                        <table className="rt w-full text-left rtl:text-right border-collapse">
                                            <thead>
                                                <tr className="bg-brand-linen/60 border-b border-brand-dune text-brand-steel text-xs font-bold uppercase tracking-wider">
                                                    <th className="py-4 px-6">{strings.patientName}</th>
                                                    <th className="py-4 px-6">{strings.triageLevel}</th>
                                                                                                        <th className="py-4 px-6 rt-phone">{strings.phone}</th>
                                                    <th className="py-4 px-6">{strings.diagnosis}</th>
                                                    <th className="py-4 px-6">{strings.lastVisit}</th>
                                                    <th className="py-4 px-6 text-right rtl:text-left">{strings.actions}</th>
                                                </tr>
                                            </thead>
                                            <tbody className="divide-y divide-brand-dune/30 text-sm">
                                                {filteredPatients.length === 0 ? (
                                                    <tr>
                                                        <td colSpan="6" className="py-14 text-center"><p className="text-brand-steel font-medium mb-4">{patientSearch ? strings.noPatientsMatch : strings.noPatients}</p>{patientSearch ? <button onClick={() => setPatientSearch("")} className="h-10 px-4 rounded-xl text-sm font-bold border border-brand-dune bg-white text-brand-harbor">{strings.clear}</button> : <button onClick={() => setShowAddPatient(true)} className="h-10 px-4 rounded-xl text-sm font-bold bg-brand-harbor text-white">{strings.newPatient}</button>}</td>
                                                    </tr>
                                                ) : (
                                                    filteredPatients.map(patient => (
                                                        <tr key={patient.id} onClick={() => { setSelectedPatient(patient); setShowPatientDetailModal(true); }} className="hover:bg-brand-linen/50 transition-colors cursor-pointer">
                                                            <td data-label={strings.patientName} className="py-4 px-6"><div className="font-bold text-brand-harbor">{patient.name}</div><div className="text-xs font-medium text-brand-steel mt-0.5">{patient.age} {lang === 'ar' ? 'سنة' : 'yrs'} / {patient.gender}</div></td>
                                                            <td data-label={strings.triageLevel} className="py-4 px-6"> <span className={`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-xl text-xs font-extrabold border ${
                                                                    patient.triage === 'Emergency' ? 'bg-rose-50 text-rose-700 border-rose-200' :
                                                                    patient.triage === 'Urgent' ? 'bg-amber-50 text-amber-800 border-amber-200' : 'bg-emerald-50 text-emerald-800 border-emerald-200'
                                                                }`}>
                                                                    <span className="w-1.5 h-1.5 rounded-full bg-current"></span>{patient.triage || 'Routine'}
                                                                </span>
                                                            </td>
                                                            <td data-label={strings.phone} className="py-4 px-6 text-brand-steel font-mono text-xs rt-phone">{patient.phone}</td>
                                                            <td data-label={strings.diagnosis} className="py-4 px-6 font-bold text-brand-harbor">{patient.diagnosis}</td>
                                                            <td data-label={strings.lastVisit} className="py-4 px-6 text-brand-steel font-medium">{patient.lastVisit}</td>
                                                            <td className="py-4 px-6 text-right rtl:text-left whitespace-nowrap rt-actions" onClick={e => e.stopPropagation()}><div className="flex items-center justify-end gap-2 flex-nowrap">
                                                                <button onClick={() => handleOpenAssessment(patient)} className="h-9 px-3 bg-brand-harbor hover:bg-brand-sky text-white rounded-xl text-xs font-bold transition-colors inline-flex items-center gap-1.5 whitespace-nowrap">
                                                                    <i data-lucide="clipboard" className="w-3.5 h-3.5"></i>
                                                                    <span>{strings.assessment}</span>
                                                                </button>
                                                                <button title={strings.edit} aria-label={strings.edit} onClick={() => { setEditingPatient(patient); setShowEditPatient(true); }} className="w-9 h-9 inline-flex items-center justify-center rounded-xl bg-white border border-brand-dune text-brand-harbor hover:bg-brand-dune/30">
                                                                    <i data-lucide="edit-3" className="w-4 h-4"></i>
                                                                </button>
                                                                <button title="Delete" aria-label="Delete" onClick={() => handleDeleteItem("patients", patient.id)} className="w-9 h-9 inline-flex items-center justify-center rounded-xl text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-500 hover:text-white hover:border-rose-500">
                                                                    <i data-lucide="trash-2" className="w-4 h-4"></i>
                                                                </button>
                                                            </div></td>
                                                        </tr>
                                                    ))
                                                )}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
        </>
    );
}
