Initial commit: Agentic Prescription Extractor & Studio

This commit is contained in:
Abhinav gupta
2026-10-01 15:11:52 +05:30
commit 15e04f3621
40 changed files with 7472 additions and 0 deletions
+567
View File
@@ -0,0 +1,567 @@
/**
* app.js
* ------
* Client Application Logic for RxAgent Studio Node.js Web App.
* Handles live audio recording, waveform visualizer, STT engine switching,
* LangGraph extraction, interactive table manipulation, and history synchronization.
*/
// Global State
const state = {
currentView: 'studio',
inputMode: 'text',
audioSource: 'mic',
isRecording: false,
mediaRecorder: null,
audioChunks: [],
recordedBlob: null,
uploadedFile: null,
audioContext: null,
analyser: null,
animFrameId: null,
timerInterval: null,
recordSeconds: 0,
extractedRecords: [],
processId: null
};
// Preset Clinical Samples
const SAMPLES = {
1: "Take one Cefpodoxime proxetil 200 mg tablet orally twice daily after meals for 7 days, and take one Levocetirizine 5 mg with Montelukast 10 mg tablet once daily at bedtime for 10 days. Take one Paracetamol 650 mg tablet up to three times daily after food for pain or fever, take one Pantoprazole 40 mg tablet once daily before breakfast for 7 days, and administer two sprays of Oxymetazoline 0.05% nasal spray into each nostril twice daily for a strict maximum of 3 days. Use saline nasal irrigations twice daily, perform steam inhalation, and seek reassessment if eye swelling or severe headaches develop.",
2: "Inhale 2 puffs of Budesonide 200 mcg twice daily using your dry powder inhaler and rinse your mouth immediately. Take Levosalbutamol 100 mcg via an MDI spacer as needed for sudden breathlessness.",
3: "Take parasita mode, tablets 500 mg, 3 times a day, till 7 days, if the fever does not go away, increase the dosage by 20 mgs.",
4: "Apply Clotrimazole 1% cream twice daily for 14 days over the affected skin areas. Instill 2 drops of Moxifloxacin 0.5% into both eyes every 4 hours for 7 days."
};
// Initialization
document.addEventListener('DOMContentLoaded', () => {
checkApiStatus();
loadModels();
setupCanvas();
});
/**
* Checks API Gateway connectivity
*/
async function checkApiStatus() {
const badge = document.getElementById('api-status-badge');
const badgeText = document.getElementById('api-status-text');
try {
const res = await fetch('/api/status');
const data = await res.json();
if (data.status === 'online') {
badge.style.background = 'rgba(16, 185, 129, 0.1)';
badge.style.borderColor = 'rgba(16, 185, 129, 0.3)';
badge.style.color = 'var(--emerald)';
badgeText.textContent = `Agent Gateway Active (Python :8000)`;
if (data.active_process) {
state.processId = data.active_process.process_id;
document.getElementById('metric-process').innerHTML = `Process: <strong>${data.active_process.name}</strong>`;
}
}
} catch (err) {
badge.style.background = 'rgba(244, 63, 94, 0.1)';
badge.style.borderColor = 'rgba(244, 63, 94, 0.3)';
badge.style.color = 'var(--rose)';
badgeText.textContent = `Connecting to Python backend...`;
}
}
/**
* Loads available LLM & STT models into dropdowns
*/
async function loadModels() {
try {
const res = await fetch('/api/models');
const data = await res.json();
if (data.llm_models && data.llm_models.length > 0) {
const llmSelect = document.getElementById('llm-model-select');
llmSelect.innerHTML = data.llm_models.map(m => `<option value="${m.label}" ${m.is_default ? 'selected' : ''}>${m.label}</option>`).join('');
}
if (data.stt_models && data.stt_models.length > 0) {
const sttSelect = document.getElementById('stt-model-select');
sttSelect.innerHTML = data.stt_models.map(m => `<option value="${m.key}" ${m.is_default ? 'selected' : ''}>${m.label}</option>`).join('');
}
} catch (e) {
console.warn('Could not load models dynamically:', e);
}
}
/**
* View Switcher
*/
function switchView(viewName) {
state.currentView = viewName;
const studioTab = document.getElementById('tab-studio-btn');
const historyTab = document.getElementById('tab-history-btn');
const studioView = document.getElementById('view-studio');
const historyView = document.getElementById('view-history');
if (viewName === 'studio') {
studioTab.classList.add('active');
historyTab.classList.remove('active');
studioView.classList.remove('hidden');
historyView.classList.add('hidden');
} else {
historyTab.classList.add('active');
studioTab.classList.remove('active');
historyView.classList.remove('hidden');
studioView.classList.add('hidden');
loadHistory();
}
}
/**
* Input Mode Switcher
*/
function setInputMode(mode) {
state.inputMode = mode;
const textBtn = document.getElementById('mode-text-btn');
const voiceBtn = document.getElementById('mode-voice-btn');
const voiceSec = document.getElementById('voice-controls-section');
if (mode === 'text') {
textBtn.classList.add('active');
voiceBtn.classList.remove('active');
voiceSec.classList.add('hidden');
} else {
voiceBtn.classList.add('active');
textBtn.classList.remove('active');
voiceSec.classList.remove('hidden');
}
}
/**
* Audio Source Switcher
*/
function setAudioSource(source) {
state.audioSource = source;
const micBtn = document.getElementById('audio-mic-btn');
const fileBtn = document.getElementById('audio-file-btn');
const micBox = document.getElementById('mic-box');
const fileBox = document.getElementById('file-box');
if (source === 'mic') {
micBtn.classList.add('active');
fileBtn.classList.remove('active');
micBox.classList.remove('hidden');
fileBox.classList.add('hidden');
} else {
fileBtn.classList.add('active');
micBtn.classList.remove('active');
fileBox.classList.remove('hidden');
micBox.classList.add('hidden');
}
}
/**
* Load Sample Prescription
*/
function loadSample(id) {
const text = SAMPLES[id];
if (text) {
document.getElementById('rx-input-text').value = text;
showToast('Sample prescription loaded!');
}
}
/**
* Waveform Canvas Setup
*/
function setupCanvas() {
const canvas = document.getElementById('waveform-canvas');
const ctx = canvas.getContext('2d');
ctx.fillStyle = '#0B0F19';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = 'rgba(99, 102, 241, 0.4)';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(0, canvas.height / 2);
ctx.lineTo(canvas.width, canvas.height / 2);
ctx.stroke();
}
/**
* Live Microphone Audio Recording & Waveform Animation
*/
async function toggleRecording() {
const btn = document.getElementById('record-toggle-btn');
const btnText = document.getElementById('record-btn-text');
const timerText = document.getElementById('record-timer');
const preview = document.getElementById('audio-preview');
if (!state.isRecording) {
try {
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
state.audioChunks = [];
state.mediaRecorder = new MediaRecorder(stream);
// Web Audio Analyser for Waveform
state.audioContext = new (window.AudioContext || window.webkitAudioContext)();
const source = state.audioContext.createMediaStreamSource(stream);
state.analyser = state.audioContext.createAnalyser();
state.analyser.fftSize = 256;
source.connect(state.analyser);
drawWaveform();
state.mediaRecorder.ondataavailable = (e) => {
if (e.data.size > 0) state.audioChunks.push(e.data);
};
state.mediaRecorder.onstop = () => {
state.recordedBlob = new Blob(state.audioChunks, { type: 'audio/wav' });
preview.src = URL.createObjectURL(state.recordedBlob);
preview.classList.remove('hidden');
document.getElementById('transcribe-btn').disabled = false;
stream.getTracks().forEach(track => track.stop());
cancelAnimationFrame(state.animFrameId);
setupCanvas();
};
state.mediaRecorder.start();
state.isRecording = true;
state.recordSeconds = 0;
btn.classList.add('recording');
btnText.textContent = 'Stop Recording';
state.timerInterval = setInterval(() => {
state.recordSeconds++;
const mins = String(Math.floor(state.recordSeconds / 60)).padStart(2, '0');
const secs = String(state.recordSeconds % 60).padStart(2, '0');
timerText.textContent = `${mins}:${secs}`;
}, 1000);
} catch (err) {
showToast('Microphone access denied: ' + err.message);
}
} else {
// Stop recording
state.mediaRecorder.stop();
state.isRecording = false;
clearInterval(state.timerInterval);
btn.classList.remove('recording');
btnText.textContent = 'Record Again';
}
}
function drawWaveform() {
if (!state.isRecording) return;
const canvas = document.getElementById('waveform-canvas');
const ctx = canvas.getContext('2d');
const bufferLength = state.analyser.frequencyBinCount;
const dataArray = new Uint8Array(bufferLength);
state.analyser.getByteTimeDomainData(dataArray);
ctx.fillStyle = '#0B0F19';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.lineWidth = 2;
ctx.strokeStyle = '#06B6D4';
ctx.beginPath();
const sliceWidth = canvas.width * 1.0 / bufferLength;
let x = 0;
for (let i = 0; i < bufferLength; i++) {
const v = dataArray[i] / 128.0;
const y = v * canvas.height / 2;
if (i === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
x += sliceWidth;
}
ctx.lineTo(canvas.width, canvas.height / 2);
ctx.stroke();
state.animFrameId = requestAnimationFrame(drawWaveform);
}
/**
* Handle File Selection
*/
function handleFileSelected(e) {
const file = e.target.files[0];
if (file) {
state.uploadedFile = file;
document.getElementById('selected-file-name').textContent = `${file.name} (${(file.size / 1024).toFixed(1)} KB)`;
document.getElementById('transcribe-btn').disabled = false;
}
}
/**
* Transcribe Audio via Selected STT Engine
*/
async function transcribeAudio() {
const sttModel = document.getElementById('stt-model-select').value;
const statusMsg = document.getElementById('transcribe-status');
const transcribeBtn = document.getElementById('transcribe-btn');
let audioBlob = (state.audioSource === 'mic') ? state.recordedBlob : state.uploadedFile;
if (!audioBlob) {
showToast('Please record or select an audio file first.');
return;
}
transcribeBtn.disabled = true;
statusMsg.textContent = `Transcribing with ${sttModel}...`;
try {
const formData = new FormData();
formData.append('file', audioBlob, 'recording.wav');
formData.append('stt_model', sttModel);
const res = await fetch('/api/transcribe', {
method: 'POST',
body: formData
});
const data = await res.json();
if (data.success && data.transcript) {
document.getElementById('rx-input-text').value = data.transcript;
statusMsg.textContent = `✅ Transcribed in ${data.transcription_time}s`;
showToast('Audio transcribed successfully!');
} else {
statusMsg.textContent = '⚠️ No speech recognized';
}
} catch (err) {
statusMsg.textContent = '❌ Transcription error';
showToast('Error transcribing audio: ' + err.message);
} finally {
transcribeBtn.disabled = false;
}
}
/**
* Run LangGraph Multi-Agent Prescription Extraction
*/
async function runExtraction() {
const text = document.getElementById('rx-input-text').value.trim();
if (!text) {
showToast('Please enter prescription text or transcribe audio first.');
return;
}
const runBtn = document.getElementById('run-extract-btn');
const pipeline = document.getElementById('progress-pipeline');
const llmModel = document.getElementById('llm-model-select').value;
const device = document.getElementById('device-select').value;
runBtn.disabled = true;
pipeline.classList.remove('hidden');
animatePipeline();
try {
const res = await fetch('/api/extract', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: text,
llm_model: llmModel,
device: device,
process_id: state.processId
})
});
const data = await res.json();
if (data.success) {
state.extractedRecords = data.parsed_records || [];
renderTable(state.extractedRecords);
document.getElementById('metric-meds').innerHTML = `<strong>${data.total_medicines}</strong> Medications`;
document.getElementById('metric-latency').innerHTML = `<strong>${data.generation_time}s</strong> Latency`;
showToast(`Extracted ${data.total_medicines} medicines successfully!`);
} else {
showToast('Extraction failed: ' + (data.error || 'Unknown error'));
}
} catch (err) {
showToast('API Gateway error: ' + err.message);
} finally {
runBtn.disabled = false;
completePipeline();
}
}
function animatePipeline() {
const s1 = document.getElementById('step-supervisor');
const s2 = document.getElementById('step-agents');
const s3 = document.getElementById('step-validator');
const s4 = document.getElementById('step-export');
s1.className = 'pipeline-step active';
s2.className = 'pipeline-step';
s3.className = 'pipeline-step';
s4.className = 'pipeline-step';
setTimeout(() => { s1.className = 'pipeline-step completed'; s2.className = 'pipeline-step active'; }, 300);
setTimeout(() => { s2.className = 'pipeline-step completed'; s3.className = 'pipeline-step active'; }, 700);
setTimeout(() => { s3.className = 'pipeline-step completed'; s4.className = 'pipeline-step active'; }, 1100);
}
function completePipeline() {
const s4 = document.getElementById('step-export');
s4.className = 'pipeline-step completed';
setTimeout(() => {
document.getElementById('progress-pipeline').classList.add('hidden');
}, 1500);
}
/**
* Render Interactive 7-Column Clinical Table
*/
function renderTable(records) {
const tbody = document.getElementById('rx-table-body');
if (!records || records.length === 0) {
tbody.innerHTML = `
<tr>
<td colspan="9" class="empty-state">
<div class="empty-content">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
<p>No medication records found in text.</p>
</div>
</td>
</tr>`;
return;
}
tbody.innerHTML = records.map((r, i) => {
const route = (r.route || 'oral').toLowerCase();
const routeClass = `route-${route}`;
return `
<tr data-index="${i}">
<td>${i + 1}</td>
<td><input type="text" class="table-input drug-name-cell" value="${escapeHtml(r.Drug_name || '')}" onchange="updateRecord(${i}, 'Drug_name', this.value)"></td>
<td><input type="text" class="table-input" value="${escapeHtml(r.strength || 'NONE')}" onchange="updateRecord(${i}, 'strength', this.value)"></td>
<td><input type="text" class="table-input" value="${escapeHtml(r.frequency || 'NONE')}" onchange="updateRecord(${i}, 'frequency', this.value)"></td>
<td><input type="text" class="table-input" value="${escapeHtml(r.duration || 'NONE')}" onchange="updateRecord(${i}, 'duration', this.value)"></td>
<td>
<select class="table-input route-badge ${routeClass}" onchange="updateRecord(${i}, 'route', this.value); this.className='table-input route-badge route-' + this.value.toLowerCase();">
<option value="oral" ${route === 'oral' ? 'selected' : ''}>ORAL</option>
<option value="nasal" ${route === 'nasal' ? 'selected' : ''}>NASAL</option>
<option value="topical" ${route === 'topical' ? 'selected' : ''}>TOPICAL</option>
<option value="ophthalmic" ${route === 'ophthalmic' ? 'selected' : ''}>OPHTHALMIC</option>
<option value="inhalation" ${route === 'inhalation' ? 'selected' : ''}>INHALATION</option>
</select>
</td>
<td><input type="text" class="table-input" value="${escapeHtml(r.instruction || 'NONE')}" onchange="updateRecord(${i}, 'instruction', this.value)"></td>
<td><input type="text" class="table-input" value="${escapeHtml(r.additional_instruction || 'NONE')}" onchange="updateRecord(${i}, 'additional_instruction', this.value)"></td>
<td class="actions-col">
<button class="btn-del-row" onclick="deleteRow(${i})" title="Delete row">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
</button>
</td>
</tr>
`;
}).join('');
}
function updateRecord(index, field, value) {
if (state.extractedRecords[index]) {
state.extractedRecords[index][field] = value;
}
}
function addNewRow() {
state.extractedRecords.push({
Drug_name: 'New Medicine',
strength: 'NONE',
frequency: 'once daily',
duration: '5 days',
route: 'oral',
instruction: 'NONE',
additional_instruction: 'NONE'
});
renderTable(state.extractedRecords);
document.getElementById('metric-meds').innerHTML = `<strong>${state.extractedRecords.length}</strong> Medications`;
}
function deleteRow(index) {
state.extractedRecords.splice(index, 1);
renderTable(state.extractedRecords);
document.getElementById('metric-meds').innerHTML = `<strong>${state.extractedRecords.length}</strong> Medications`;
}
/**
* Export Helpers
*/
function exportToCSV() {
if (!state.extractedRecords || state.extractedRecords.length === 0) {
showToast('No records to export.');
return;
}
const headers = ['Drug_name', 'strength', 'frequency', 'duration', 'route', 'instruction', 'additional_instruction'];
const rows = state.extractedRecords.map(r => headers.map(h => `"${(r[h] || '').replace(/"/g, '""')}"`).join(','));
const csvContent = [headers.join(','), ...rows].join('\n');
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('download', `rx_extraction_${Date.now()}.csv`);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
showToast('CSV downloaded successfully.');
}
function copyTableJSON() {
if (!state.extractedRecords || state.extractedRecords.length === 0) {
showToast('No records to copy.');
return;
}
navigator.clipboard.writeText(JSON.stringify(state.extractedRecords, null, 2));
showToast('JSON copied to clipboard!');
}
/**
* Load Prescription History from SQLite
*/
async function loadHistory() {
const tbody = document.getElementById('history-table-body');
tbody.innerHTML = '<tr><td colspan="7" class="empty-state">Loading history records...</td></tr>';
try {
const res = await fetch('/api/history?limit=30');
const data = await res.json();
if (data.records && data.records.length > 0) {
tbody.innerHTML = data.records.map(r => `
<tr>
<td><strong>#${r.id}</strong></td>
<td>${r.timestamp || ''}</td>
<td>Process ${r.process_id}</td>
<td style="max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${escapeHtml(r.input_text || '')}</td>
<td><strong>${(r.parsed_records || []).length}</strong> meds</td>
<td>${r.generation_time}s</td>
<td>
<button class="btn btn-sm btn-ghost" onclick="loadHistoryItem(${escapeHtml(JSON.stringify(r))})">Load to Studio</button>
</td>
</tr>
`).join('');
} else {
tbody.innerHTML = '<tr><td colspan="7" class="empty-state">No prescription history found.</td></tr>';
}
} catch (e) {
tbody.innerHTML = `<tr><td colspan="7" class="empty-state">Failed to load history: ${e.message}</td></tr>`;
}
}
function loadHistoryItem(item) {
switchView('studio');
document.getElementById('rx-input-text').value = item.input_text || '';
state.extractedRecords = item.parsed_records || [];
renderTable(state.extractedRecords);
document.getElementById('metric-meds').innerHTML = `<strong>${state.extractedRecords.length}</strong> Medications`;
document.getElementById('metric-latency').innerHTML = `<strong>${item.generation_time}s</strong> Latency`;
showToast(`Loaded History Record #${item.id} into Studio.`);
}
function showToast(msg) {
const toast = document.getElementById('toast');
toast.textContent = msg;
toast.classList.remove('hidden');
setTimeout(() => { toast.classList.add('hidden'); }, 3000);
}
function escapeHtml(str) {
if (typeof str !== 'string') return str;
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
+305
View File
@@ -0,0 +1,305 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Agentic Prescription Extractor & Studio</title>
<meta name="description" content="Parallel Node.js Application for LangGraph Multi-Agent Clinical Prescription Extraction and Multi-Engine Speech-to-Text Transcription.">
<!-- Google Fonts: Outfit & Inter -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="app-background">
<div class="glow-orb orb-1"></div>
<div class="glow-orb orb-2"></div>
<div class="glow-orb orb-3"></div>
</div>
<!-- Header Navigation -->
<header class="app-header">
<div class="header-brand">
<div class="brand-icon">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 2v20M2 12h20M4.93 4.93l14.14 14.14M4.93 19.07l14.14-14.14"/>
</svg>
</div>
<div>
<h1 class="brand-title">RxAgent Studio</h1>
<p class="brand-subtitle">LangGraph Multi-Agent Prescription & STT Intelligence</p>
</div>
</div>
<div class="header-status-group">
<div class="status-badge" id="api-status-badge">
<span class="status-dot pulsing"></span>
<span id="api-status-text">Connecting to Agent Gateway...</span>
</div>
<nav class="nav-tabs">
<button class="nav-tab active" id="tab-studio-btn" onclick="switchView('studio')">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>
Prescription Studio
</button>
<button class="nav-tab" id="tab-history-btn" onclick="switchView('history')">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
History & Audit Logs
</button>
</nav>
</div>
</header>
<!-- Main Workspace Container -->
<main class="main-container">
<!-- VIEW 1: PRESCRIPTION STUDIO -->
<section id="view-studio" class="active-view">
<div class="workspace-grid">
<!-- Left Column: Input & Controls -->
<div class="card glass-card input-card">
<div class="card-header">
<div class="card-title-group">
<span class="step-num">01</span>
<div>
<h2 class="card-title">Clinical Consultation Input</h2>
<p class="card-desc">Record live doctor voice notes or paste doctor instructions.</p>
</div>
</div>
<div class="input-mode-toggle">
<button class="mode-btn active" id="mode-text-btn" onclick="setInputMode('text')">Text Mode 📝</button>
<button class="mode-btn" id="mode-voice-btn" onclick="setInputMode('voice')">Voice Studio 🎙️</button>
</div>
</div>
<!-- Voice Recorder & STT Controls -->
<div id="voice-controls-section" class="voice-section hidden">
<div class="voice-config-bar">
<div class="config-field">
<label for="stt-model-select">STT Model Engine</label>
<select id="stt-model-select" class="form-select">
<option value="whisper_ayush">Whisper Ayush (Fast Turbo)</option>
<option value="whisper_large_turbo">OpenAI Whisper Large v3 Turbo</option>
<option value="canary_1b">NVIDIA Canary 1B</option>
<option value="parakeet_tdt">NVIDIA Parakeet TDT 1.1B</option>
<option value="moonshine_base">Useful Sensors Moonshine Base</option>
<option value="moonshine_tiny">Useful Sensors Moonshine Tiny</option>
<option value="whisper_standard">OpenAI Whisper Base (Local)</option>
</select>
</div>
<div class="config-field">
<label>Audio Input Method</label>
<div class="audio-source-switch">
<button class="submode-btn active" id="audio-mic-btn" onclick="setAudioSource('mic')">Microphone 🎤</button>
<button class="submode-btn" id="audio-file-btn" onclick="setAudioSource('file')">Upload Audio 📁</button>
</div>
</div>
</div>
<!-- Mic Recording Box -->
<div id="mic-box" class="mic-recorder-box">
<div class="visualizer-container">
<canvas id="waveform-canvas" width="400" height="80"></canvas>
</div>
<div class="record-actions">
<button id="record-toggle-btn" class="btn btn-record" onclick="toggleRecording()">
<span class="record-dot"></span>
<span id="record-btn-text">Start Recording</span>
</button>
<span id="record-timer" class="record-time">00:00</span>
</div>
<audio id="audio-preview" controls class="audio-player hidden"></audio>
</div>
<!-- File Upload Box -->
<div id="file-box" class="file-uploader-box hidden">
<div class="drop-zone" id="drop-zone" onclick="document.getElementById('audio-file-input').click()">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
<p>Click or drag audio file here (.wav, .mp3, .m4a, .ogg)</p>
<span id="selected-file-name" class="file-tag">No file selected</span>
</div>
<input type="file" id="audio-file-input" accept="audio/*" class="hidden" onchange="handleFileSelected(event)">
</div>
<div class="transcribe-action-row">
<button id="transcribe-btn" class="btn btn-secondary" onclick="transcribeAudio()" disabled>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>
Transcribe Voice Note
</button>
<span id="transcribe-status" class="status-msg"></span>
</div>
</div>
<!-- Prescription Text Area -->
<div class="textarea-container">
<textarea id="rx-input-text" class="form-textarea" placeholder="Enter clinical prescription note or transcribe voice above... (e.g. 'Take one Cefpodoxime proxetil 200 mg tablet twice daily after meals for 7 days...')"></textarea>
</div>
<!-- Quick Sample Pills -->
<div class="sample-pills-row">
<span class="sample-label">Quick Samples:</span>
<button class="pill-btn" onclick="loadSample(1)">5-Med Complex Rx</button>
<button class="pill-btn" onclick="loadSample(2)">Respiratory & Inhaler</button>
<button class="pill-btn" onclick="loadSample(3)">Titration & Grammar</button>
<button class="pill-btn" onclick="loadSample(4)">Topicals & Drops</button>
</div>
<!-- Model Settings & Extraction Trigger -->
<div class="extraction-footer">
<div class="footer-config">
<div class="config-field mini">
<label for="llm-model-select">LLM Engine</label>
<select id="llm-model-select" class="form-select mini">
<option value="Llama 3.2 3B">Llama 3.2 3B</option>
<option value="Llama 3.2 1B">Llama 3.2 1B</option>
<option value="Llama 3.1 8B">Llama 3.1 8B</option>
</select>
</div>
<div class="config-field mini">
<label for="device-select">Compute Device</label>
<select id="device-select" class="form-select mini">
<option value="cpu">CPU (Auto Multi-Thread)</option>
<option value="cuda">CUDA GPU</option>
</select>
</div>
</div>
<button id="run-extract-btn" class="btn btn-primary" onclick="runExtraction()">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="5 3 19 12 5 21 5 3"/></svg>
<span>Run LangGraph Extraction</span>
</button>
</div>
</div>
<!-- Right Column: Agentic Workflow & Results -->
<div class="card glass-card output-card">
<div class="card-header">
<div class="card-title-group">
<span class="step-num">02</span>
<div>
<h2 class="card-title">Structured Medication Output</h2>
<p class="card-desc">Validated 7-column clinical fields with anti-drift guarantee.</p>
</div>
</div>
<div class="export-actions">
<button class="btn btn-sm btn-ghost" onclick="exportToCSV()" title="Export CSV">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
CSV
</button>
<button class="btn btn-sm btn-ghost" onclick="copyTableJSON()" title="Copy JSON">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
JSON
</button>
<button class="btn btn-sm btn-ghost" onclick="addNewRow()" title="Add Custom Row">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
Add Row
</button>
</div>
</div>
<!-- Progress Pipeline Visualizer -->
<div id="progress-pipeline" class="progress-pipeline hidden">
<div class="pipeline-step" id="step-supervisor">
<div class="step-icon">1</div>
<span>Supervisor</span>
</div>
<div class="pipeline-connector"></div>
<div class="pipeline-step" id="step-agents">
<div class="step-icon">2</div>
<span>Parallel Agents</span>
</div>
<div class="pipeline-connector"></div>
<div class="pipeline-step" id="step-validator">
<div class="step-icon">3</div>
<span>Validator Loop</span>
</div>
<div class="pipeline-connector"></div>
<div class="pipeline-step" id="step-export">
<div class="step-icon">4</div>
<span>DB & Sync</span>
</div>
</div>
<!-- Interactive Table Container -->
<div class="table-responsive">
<table id="rx-table" class="clinical-table">
<thead>
<tr>
<th>#</th>
<th>Drug Name</th>
<th>Strength</th>
<th>Frequency</th>
<th>Duration</th>
<th>Route</th>
<th>Primary Instruction</th>
<th>Additional Instruction</th>
<th class="actions-col">Actions</th>
</tr>
</thead>
<tbody id="rx-table-body">
<tr>
<td colspan="9" class="empty-state">
<div class="empty-content">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
<p>No prescription extracted yet. Record voice note or enter text on the left.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Metrics / Metadata Bar -->
<div class="metrics-bar">
<span id="metric-meds" class="metric-item"><strong>0</strong> Medications</span>
<span id="metric-latency" class="metric-item"><strong>0.00s</strong> Agent Latency</span>
<span id="metric-process" class="metric-item">Process: <strong>Default</strong></span>
</div>
</div>
</div>
</section>
<!-- VIEW 2: HISTORY & AUDIT LOGS -->
<section id="view-history" class="view-panel hidden">
<div class="card glass-card history-card">
<div class="card-header">
<div class="card-title-group">
<h2 class="card-title">Prescription History & Audit Trail</h2>
<p class="card-desc">Synchronized in real-time with SQLite database (rx_history.db).</p>
</div>
<button class="btn btn-secondary btn-sm" onclick="loadHistory()">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>
Refresh
</button>
</div>
<div class="table-responsive">
<table class="clinical-table history-table">
<thead>
<tr>
<th>ID</th>
<th>Timestamp</th>
<th>Process</th>
<th>Input Prescription Transcript</th>
<th>Extracted Meds</th>
<th>Latency</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="history-table-body">
<tr>
<td colspan="7" class="empty-state">Loading history...</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</main>
<!-- Notification Toast -->
<div id="toast" class="toast hidden"></div>
<script src="app.js"></script>
</body>
</html>
+842
View File
@@ -0,0 +1,842 @@
/**
* style.css
* ---------
* Modern Glassmorphism & High-Precision Clinical Design System.
* Dark Mode, Vibrant Accents, Responsive Grid & Fluid Typography.
*/
:root {
--bg-main: #0B0F19;
--bg-surface: rgba(17, 24, 39, 0.75);
--bg-surface-hover: rgba(31, 41, 55, 0.85);
--bg-card: rgba(15, 23, 42, 0.65);
--border-color: rgba(255, 255, 255, 0.08);
--border-highlight: rgba(99, 102, 241, 0.35);
--primary: #6366F1;
--primary-hover: #4F46E5;
--primary-glow: rgba(99, 102, 241, 0.25);
--cyan: #06B6D4;
--emerald: #10B981;
--emerald-glow: rgba(16, 185, 129, 0.2);
--rose: #F43F5E;
--amber: #F59E0B;
--violet: #8B5CF6;
--text-main: #F9FAFB;
--text-muted: #9CA3AF;
--text-subtle: #6B7280;
--font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
--font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
--radius-sm: 8px;
--radius-md: 14px;
--radius-lg: 20px;
--shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: var(--font-body);
background-color: var(--bg-main);
color: var(--text-main);
min-height: 100vh;
overflow-x: hidden;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
/* Background Ambient Glow */
.app-background {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: -1;
overflow: hidden;
pointer-events: none;
}
.glow-orb {
position: absolute;
border-radius: 50%;
filter: blur(120px);
opacity: 0.22;
}
.orb-1 {
width: 500px;
height: 500px;
background: var(--primary);
top: -100px;
left: 10%;
}
.orb-2 {
width: 450px;
height: 450px;
background: var(--cyan);
bottom: -100px;
right: 5%;
}
.orb-3 {
width: 350px;
height: 350px;
background: var(--violet);
top: 40%;
right: 35%;
}
/* App Header */
.app-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 2rem;
background: rgba(11, 15, 25, 0.85);
backdrop-filter: blur(20px);
border-bottom: 1px solid var(--border-color);
position: sticky;
top: 0;
z-index: 100;
}
.header-brand {
display: flex;
align-items: center;
gap: 1rem;
}
.brand-icon {
width: 44px;
height: 44px;
background: linear-gradient(135deg, var(--primary), var(--cyan));
border-radius: var(--radius-sm);
display: flex;
align-items: center;
justify-content: center;
color: #FFF;
box-shadow: 0 0 20px var(--primary-glow);
}
.brand-title {
font-family: var(--font-heading);
font-size: 1.35rem;
font-weight: 700;
letter-spacing: -0.5px;
background: linear-gradient(120deg, #FFFFFF 30%, var(--cyan) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.brand-subtitle {
font-size: 0.8rem;
color: var(--text-muted);
}
.header-status-group {
display: flex;
align-items: center;
gap: 1.5rem;
}
.status-badge {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.4rem 0.9rem;
background: rgba(16, 185, 129, 0.1);
border: 1px solid rgba(16, 185, 129, 0.25);
border-radius: 999px;
font-size: 0.8rem;
color: var(--emerald);
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--emerald);
}
.status-dot.pulsing {
animation: pulseGlow 1.8s infinite;
}
@keyframes pulseGlow {
0% { transform: scale(0.9); opacity: 0.6; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
70% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
100% { transform: scale(0.9); opacity: 0.6; }
}
.nav-tabs {
display: flex;
background: rgba(255, 255, 255, 0.04);
padding: 0.25rem;
border-radius: var(--radius-sm);
border: 1px solid var(--border-color);
gap: 0.25rem;
}
.nav-tab {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
background: transparent;
border: none;
color: var(--text-muted);
font-family: var(--font-body);
font-size: 0.85rem;
font-weight: 500;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s ease;
}
.nav-tab.active, .nav-tab:hover {
color: #FFF;
background: rgba(255, 255, 255, 0.08);
}
.nav-tab.active {
background: var(--primary);
box-shadow: 0 0 12px var(--primary-glow);
}
/* Main Container & Layout */
.main-container {
max-width: 1560px;
margin: 1.5rem auto;
padding: 0 1.5rem;
}
.workspace-grid {
display: grid;
grid-template-columns: 460px 1fr;
gap: 1.5rem;
align-items: start;
}
@media (max-width: 1100px) {
.workspace-grid {
grid-template-columns: 1fr;
}
}
/* Glass Card */
.glass-card {
background: var(--bg-surface);
backdrop-filter: blur(16px);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
box-shadow: var(--shadow-glass);
padding: 1.5rem;
position: relative;
overflow: hidden;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.25rem;
padding-bottom: 0.85rem;
border-bottom: 1px solid var(--border-color);
}
.card-title-group {
display: flex;
align-items: center;
gap: 0.85rem;
}
.step-num {
width: 28px;
height: 28px;
background: rgba(99, 102, 241, 0.15);
border: 1px solid var(--border-highlight);
color: var(--primary);
font-family: var(--font-heading);
font-weight: 700;
font-size: 0.8rem;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
}
.card-title {
font-family: var(--font-heading);
font-size: 1.15rem;
font-weight: 600;
color: #FFF;
}
.card-desc {
font-size: 0.8rem;
color: var(--text-muted);
}
/* Mode Toggle */
.input-mode-toggle {
display: flex;
background: rgba(0, 0, 0, 0.3);
padding: 0.25rem;
border-radius: var(--radius-sm);
border: 1px solid var(--border-color);
}
.mode-btn {
padding: 0.35rem 0.75rem;
background: transparent;
border: none;
color: var(--text-muted);
font-size: 0.8rem;
font-weight: 500;
border-radius: 5px;
cursor: pointer;
transition: all 0.2s;
}
.mode-btn.active {
background: rgba(255, 255, 255, 0.1);
color: #FFF;
}
/* Voice Studio Controls */
.voice-section {
background: rgba(0, 0, 0, 0.25);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 1rem;
margin-bottom: 1rem;
}
.voice-config-bar {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
margin-bottom: 1rem;
}
.config-field {
display: flex;
flex-direction: column;
gap: 0.35rem;
}
.config-field label {
font-size: 0.75rem;
color: var(--text-muted);
font-weight: 500;
}
.form-select, .form-textarea {
background: rgba(15, 23, 42, 0.75);
border: 1px solid var(--border-color);
color: #FFF;
border-radius: var(--radius-sm);
padding: 0.55rem 0.75rem;
font-family: var(--font-body);
font-size: 0.85rem;
outline: none;
transition: border 0.2s, box-shadow 0.2s;
}
.form-select:focus, .form-textarea:focus {
border-color: var(--primary);
box-shadow: 0 0 0 2px var(--primary-glow);
}
.audio-source-switch {
display: flex;
background: rgba(0, 0, 0, 0.3);
padding: 0.2rem;
border-radius: var(--radius-sm);
}
.submode-btn {
flex: 1;
padding: 0.35rem;
background: transparent;
border: none;
color: var(--text-muted);
font-size: 0.75rem;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s;
}
.submode-btn.active {
background: rgba(255, 255, 255, 0.1);
color: #FFF;
}
/* Mic Recorder Box */
.mic-recorder-box {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.75rem;
padding: 0.75rem;
background: rgba(0, 0, 0, 0.2);
border-radius: var(--radius-sm);
}
.visualizer-container {
width: 100%;
height: 70px;
background: rgba(0, 0, 0, 0.4);
border-radius: var(--radius-sm);
display: flex;
align-items: center;
justify-content: center;
border: 1px solid var(--border-color);
overflow: hidden;
}
#waveform-canvas {
width: 100%;
height: 100%;
}
.record-actions {
display: flex;
align-items: center;
gap: 1rem;
}
.btn-record {
display: flex;
align-items: center;
gap: 0.6rem;
padding: 0.55rem 1.25rem;
background: rgba(244, 63, 94, 0.15);
border: 1px solid rgba(244, 63, 94, 0.35);
color: #FFF;
border-radius: 999px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
}
.btn-record:hover {
background: rgba(244, 63, 94, 0.25);
box-shadow: 0 0 16px rgba(244, 63, 94, 0.3);
}
.btn-record.recording {
background: var(--rose);
box-shadow: 0 0 20px rgba(244, 63, 94, 0.5);
animation: pulseRose 1.5s infinite;
}
@keyframes pulseRose {
0% { transform: scale(1); }
50% { transform: scale(1.03); }
100% { transform: scale(1); }
}
.record-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--rose);
}
.btn-record.recording .record-dot {
background: #FFF;
}
.record-time {
font-family: monospace;
font-size: 0.95rem;
color: var(--text-muted);
}
.audio-player {
width: 100%;
height: 36px;
margin-top: 0.5rem;
}
/* File Upload Zone */
.drop-zone {
border: 2px dashed var(--border-color);
border-radius: var(--radius-sm);
padding: 1.5rem 1rem;
text-align: center;
cursor: pointer;
transition: all 0.2s;
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
color: var(--text-muted);
}
.drop-zone:hover {
border-color: var(--primary);
background: rgba(99, 102, 241, 0.05);
}
.file-tag {
font-size: 0.75rem;
padding: 0.2rem 0.6rem;
background: rgba(255, 255, 255, 0.08);
border-radius: 4px;
color: var(--cyan);
}
.transcribe-action-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 0.75rem;
gap: 0.75rem;
}
/* Textarea */
.textarea-container {
margin-bottom: 1rem;
}
.form-textarea {
width: 100%;
height: 140px;
resize: vertical;
line-height: 1.6;
}
/* Sample Pills */
.sample-pills-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.4rem;
margin-bottom: 1.25rem;
}
.sample-label {
font-size: 0.75rem;
color: var(--text-subtle);
}
.pill-btn {
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--border-color);
color: var(--text-muted);
font-size: 0.72rem;
padding: 0.25rem 0.55rem;
border-radius: 999px;
cursor: pointer;
transition: all 0.2s;
}
.pill-btn:hover {
color: #FFF;
border-color: var(--cyan);
background: rgba(6, 182, 212, 0.1);
}
/* Extraction Footer */
.extraction-footer {
display: flex;
flex-direction: column;
gap: 1rem;
padding-top: 1rem;
border-top: 1px solid var(--border-color);
}
.footer-config {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
}
.config-field.mini label {
font-size: 0.7rem;
}
.form-select.mini {
padding: 0.4rem 0.6rem;
font-size: 0.78rem;
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
font-family: var(--font-body);
font-size: 0.85rem;
font-weight: 600;
border-radius: var(--radius-sm);
padding: 0.65rem 1.25rem;
border: none;
cursor: pointer;
transition: all 0.2s ease;
}
.btn-primary {
background: linear-gradient(135deg, var(--primary), #4338CA);
color: #FFF;
box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover {
background: linear-gradient(135deg, #4F46E5, #3730A3);
box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
transform: translateY(-1px);
}
.btn-secondary {
background: rgba(255, 255, 255, 0.08);
color: #FFF;
border: 1px solid var(--border-color);
}
.btn-secondary:hover {
background: rgba(255, 255, 255, 0.15);
}
.btn-sm {
padding: 0.35rem 0.7rem;
font-size: 0.75rem;
}
.btn-ghost {
background: transparent;
color: var(--text-muted);
border: 1px solid var(--border-color);
}
.btn-ghost:hover {
color: #FFF;
background: rgba(255, 255, 255, 0.05);
border-color: var(--primary);
}
/* Progress Pipeline */
.progress-pipeline {
display: flex;
align-items: center;
justify-content: space-between;
background: rgba(0, 0, 0, 0.3);
padding: 0.85rem 1.25rem;
border-radius: var(--radius-sm);
border: 1px solid var(--border-color);
margin-bottom: 1.25rem;
}
.pipeline-step {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.75rem;
color: var(--text-subtle);
transition: all 0.3s;
}
.pipeline-step.active {
color: var(--cyan);
font-weight: 600;
}
.pipeline-step.completed {
color: var(--emerald);
}
.step-icon {
width: 22px;
height: 22px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.08);
display: flex;
align-items: center;
justify-content: center;
font-size: 0.7rem;
}
.pipeline-step.active .step-icon {
background: var(--cyan);
color: #000;
box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}
.pipeline-step.completed .step-icon {
background: var(--emerald);
color: #000;
}
.pipeline-connector {
flex: 1;
height: 2px;
background: var(--border-color);
margin: 0 0.5rem;
}
/* Clinical Table */
.table-responsive {
width: 100%;
overflow-x: auto;
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
background: rgba(0, 0, 0, 0.2);
min-height: 280px;
}
.clinical-table {
width: 100%;
border-collapse: collapse;
font-size: 0.82rem;
text-align: left;
}
.clinical-table th {
background: rgba(15, 23, 42, 0.9);
padding: 0.75rem 0.85rem;
font-weight: 600;
color: var(--text-muted);
border-bottom: 1px solid var(--border-color);
white-space: nowrap;
text-transform: uppercase;
font-size: 0.7rem;
letter-spacing: 0.5px;
}
.clinical-table td {
padding: 0.65rem 0.85rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
vertical-align: middle;
}
.clinical-table tbody tr {
transition: background 0.15s;
}
.clinical-table tbody tr:hover {
background: rgba(255, 255, 255, 0.025);
}
.table-input {
width: 100%;
background: transparent;
border: 1px solid transparent;
color: #FFF;
font-family: inherit;
font-size: inherit;
padding: 0.25rem 0.4rem;
border-radius: 4px;
transition: all 0.2s;
}
.table-input:hover {
border-color: rgba(255, 255, 255, 0.1);
background: rgba(0, 0, 0, 0.2);
}
.table-input:focus {
border-color: var(--primary);
background: rgba(15, 23, 42, 0.8);
outline: none;
}
.drug-name-cell {
font-weight: 600;
color: #FFF;
}
/* Route Badge */
.route-badge {
display: inline-block;
padding: 0.2rem 0.5rem;
border-radius: 999px;
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
}
.route-oral { background: rgba(99, 102, 241, 0.15); color: #818CF8; border: 1px solid rgba(99, 102, 241, 0.3); }
.route-nasal { background: rgba(6, 182, 212, 0.15); color: #22D3EE; border: 1px solid rgba(6, 182, 212, 0.3); }
.route-topical { background: rgba(245, 158, 11, 0.15); color: #FBBF24; border: 1px solid rgba(245, 158, 11, 0.3); }
.route-ophthalmic { background: rgba(16, 185, 129, 0.15); color: #34D399; border: 1px solid rgba(16, 185, 129, 0.3); }
.route-inhalation { background: rgba(244, 63, 94, 0.15); color: #FB7185; border: 1px solid rgba(244, 63, 94, 0.3); }
.empty-state {
text-align: center;
padding: 4rem 1rem !important;
color: var(--text-muted);
}
.empty-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.75rem;
}
.actions-col {
width: 60px;
text-align: center;
}
.btn-del-row {
background: transparent;
border: none;
color: var(--text-subtle);
cursor: pointer;
padding: 0.25rem;
border-radius: 4px;
transition: all 0.2s;
}
.btn-del-row:hover {
color: var(--rose);
background: rgba(244, 63, 94, 0.1);
}
/* Metrics Bar */
.metrics-bar {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 1.5rem;
margin-top: 0.85rem;
font-size: 0.75rem;
color: var(--text-muted);
}
.metric-item strong {
color: var(--cyan);
}
/* Toast */
.toast {
position: fixed;
bottom: 2rem;
right: 2rem;
padding: 0.75rem 1.25rem;
background: rgba(15, 23, 42, 0.95);
border: 1px solid var(--border-highlight);
border-radius: var(--radius-sm);
color: #FFF;
font-size: 0.85rem;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
z-index: 999;
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.hidden {
display: none !important;
}