Spaces:
Running on Zero
Running on Zero
Update app.py
#13
by Kietcudo - opened
app.py
CHANGED
|
@@ -316,23 +316,22 @@ def delete_current_ticket(selected_option):
|
|
| 316 |
|
| 317 |
def format_ticket_detail(ticket):
|
| 318 |
status_label, _ = get_ticket_status_display(ticket)
|
| 319 |
-
# Màu mang thông tin: hổ phách = đang chờ xử lý, xanh = đã xong.
|
| 320 |
if "CHƯA TRẢ LỜI" in status_label and "HỎI THÊM" not in status_label:
|
| 321 |
-
status_str = "
|
| 322 |
-
status_color = "#
|
| 323 |
elif "HỎI THÊM" in status_label:
|
| 324 |
-
status_str = "
|
| 325 |
-
status_color = "#
|
| 326 |
else:
|
| 327 |
-
status_str = "
|
| 328 |
-
status_color = "#
|
| 329 |
|
| 330 |
reply_str = ticket.get('admin_reply', 'Chưa có phản hồi.')
|
| 331 |
-
|
| 332 |
-
header_html = f"""<div style="font-size:
|
| 333 |
-
<b>
|
| 334 |
-
<b>Loại cây:</b> <span style="color: #
|
| 335 |
-
<b>Câu hỏi từ nhà nông:</b> <span
|
| 336 |
</div>"""
|
| 337 |
|
| 338 |
history_conversation = ""
|
|
@@ -342,16 +341,20 @@ def format_ticket_detail(ticket):
|
|
| 342 |
time_stamp = msg.get("time", "")
|
| 343 |
text = msg.get("text", "")
|
| 344 |
if sender == "USER":
|
| 345 |
-
history_conversation += f"""<div
|
|
|
|
|
|
|
| 346 |
else:
|
| 347 |
-
history_conversation += f"""<div
|
|
|
|
|
|
|
| 348 |
|
| 349 |
if not history_conversation:
|
| 350 |
-
history_conversation = f"""<div
|
| 351 |
|
| 352 |
-
conversation_html = f"""<div style="font-size:
|
| 353 |
-
<b>Trạng thái:</b> <span
|
| 354 |
-
<b>Nội dung trao đổi với
|
| 355 |
{history_conversation}
|
| 356 |
</div>"""
|
| 357 |
|
|
@@ -447,7 +450,7 @@ def check_user_expert_status():
|
|
| 447 |
last_ticket = user_tickets[-1]
|
| 448 |
img_p = last_ticket.get('image_path', None)
|
| 449 |
h_info, c_info = format_ticket_detail(last_ticket)
|
| 450 |
-
return h_info + "<hr
|
| 451 |
|
| 452 |
def submit_expert_request(user_question, selected_plant, input_image):
|
| 453 |
global current_detected_disease_context
|
|
@@ -487,7 +490,7 @@ def submit_expert_request(user_question, selected_plant, input_image):
|
|
| 487 |
tickets.append(new_ticket)
|
| 488 |
save_expert_tickets(tickets)
|
| 489 |
h_info, c_info = format_ticket_detail(new_ticket)
|
| 490 |
-
return "📩 Đã gửi câu hỏi đến Hộp thư chờ Chuyên gia! Chuyên gia sẽ sớm xem xét và trả lời.", h_info + "<hr
|
| 491 |
|
| 492 |
def go_to_history_panel():
|
| 493 |
global current_user_role
|
|
@@ -650,879 +653,222 @@ QUY TẮC PHẢI TUÂN THỦ:
|
|
| 650 |
save_chat_log(user_message, ai_reply)
|
| 651 |
return "", history
|
| 652 |
|
| 653 |
-
LEAF_HERO_HEAD = r"""
|
| 654 |
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 655 |
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 656 |
-
<link href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700;800&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&display=swap" rel="stylesheet">
|
| 657 |
-
<script>
|
| 658 |
-
(function () {
|
| 659 |
-
"use strict";
|
| 660 |
-
const TAU = Math.PI * 2, RAD = Math.PI / 180;
|
| 661 |
-
const LEAF_CASES = [
|
| 662 |
-
{ name:"Khỏe mạnh", a:0.387, e:0.206, i:7, node:48, peri:29, M0:175, color:"#4caf50", size:7, glow:1.15 },
|
| 663 |
-
{ name:"Thiếu đạm", a:0.723, e:0.007, i:3.4, node:77, peri:55, M0:50, color:"#8bc34a", size:9 },
|
| 664 |
-
{ name:"Đốm nâu", a:1.0, e:0.017, i:0, node:349, peri:114, M0:358, color:"#6d4c2a", size:10 },
|
| 665 |
-
{ name:"Phấn trắng", a:1.524, e:0.093, i:1.8, node:50, peri:286, M0:19, color:"#a5d6a7", size:8 },
|
| 666 |
-
{ name:"Gỉ sắt", a:5.203, e:0.048, i:1.3, node:100, peri:274, M0:20, color:"#e08d3c", size:13 },
|
| 667 |
-
{ name:"Cháy bìa lá", a:9.537, e:0.054, i:2.5, node:114, peri:339, M0:317, color:"#795548", size:12 },
|
| 668 |
-
];
|
| 669 |
-
const PLANE_FAN = [[58,35],[27,145],[71,250],[40,80],[84,190],[33,310]];
|
| 670 |
-
const ECC_FAN = [0.52, 0.34, 0.63, 0.44, 0.3, 0.58];
|
| 671 |
-
|
| 672 |
-
function eccentricAnomaly(M, e) {
|
| 673 |
-
let m = M % TAU; if (m < 0) m += TAU;
|
| 674 |
-
let E = m + e * Math.sin(m) * (1 + e * Math.cos(m));
|
| 675 |
-
for (let k = 0; k < 8; k++) {
|
| 676 |
-
const step = (E - e * Math.sin(E) - m) / (1 - e * Math.cos(E));
|
| 677 |
-
E -= step; if (Math.abs(step) < 1e-10) break;
|
| 678 |
-
}
|
| 679 |
-
return E;
|
| 680 |
-
}
|
| 681 |
-
function parseRGB(c) {
|
| 682 |
-
if (c[0]==="#") { const h=c.slice(1); const f=h.length===3?h[0]+h[0]+h[1]+h[1]+h[2]+h[2]:h; const n=parseInt(f,16); return[(n>>16)&255,(n>>8)&255,n&255]; }
|
| 683 |
-
const m=c.match(/(\d+)/g); return m?[+m[0],+m[1],+m[2]]:[0,0,0];
|
| 684 |
-
}
|
| 685 |
-
function mulberry32(seed) {
|
| 686 |
-
let t=seed>>>0;
|
| 687 |
-
return()=>{t+=0x6d2b79f5;let x=t;x=Math.imul(x^(x>>>15),x|1);x^=x+Math.imul(x^(x>>>7),x|61);return((x^(x>>>14))>>>0)/4294967296;};
|
| 688 |
-
}
|
| 689 |
-
|
| 690 |
-
function boot() {
|
| 691 |
-
if (document.getElementById("leaf-bg")) return true;
|
| 692 |
-
if (!document.body) return false;
|
| 693 |
-
const canvas = document.createElement("canvas");
|
| 694 |
-
canvas.id = "leaf-bg";
|
| 695 |
-
canvas.setAttribute("aria-hidden", "true");
|
| 696 |
-
document.body.insertBefore(canvas, document.body.firstChild);
|
| 697 |
-
const ctx = canvas.getContext("2d");
|
| 698 |
-
|
| 699 |
-
const C = {
|
| 700 |
-
leaves: LEAF_CASES, cycleSeconds: 16, trailCycles: 2.6, compress: 0.42,
|
| 701 |
-
maxTurns: 3, planeSpread: 1, eccentricity: 0.25, alignToCourse: 1,
|
| 702 |
-
driftSpeed: 1.5, driftDir: [272, 53], viewRadius: 2.6, tilt: 45, spin: 252, roll: 13.5,
|
| 703 |
-
lead: 0.12, focus: [0.74, 0.42], scrim: "left", scrimStrength: 0.90,
|
| 704 |
-
moteCount: 400, glow: 1, showCoreBeam: true, interactive: true, crossColor: "#2d7a12",
|
| 705 |
-
pulseColor: "#10b981", rayColor: "#8fd45a"
|
| 706 |
-
};
|
| 707 |
-
const PULSE_RGB = parseRGB(C.pulseColor), RAY_RGB = parseRGB(C.rayColor);
|
| 708 |
-
const reduceMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
| 709 |
-
|
| 710 |
-
function applyResponsive() {
|
| 711 |
-
const w = window.innerWidth, narrow = w <= 767;
|
| 712 |
-
if (narrow) { C.focus = [0.5, 0.62]; }
|
| 713 |
-
else {
|
| 714 |
-
// Đo trực tiếp mép phải của khối đăng nhập -> chữ thập luôn nằm giữa khoảng trống còn lại,
|
| 715 |
-
// đúng ở mọi bề rộng màn hình (laptop, máy chiếu) mà không cần đoán theo công thức.
|
| 716 |
-
let panelRight = 0.13 * w + Math.min(432, 0.81 * w);
|
| 717 |
-
try {
|
| 718 |
-
const col = document.getElementById("login_content_col");
|
| 719 |
-
if (col) {
|
| 720 |
-
const r = col.getBoundingClientRect();
|
| 721 |
-
if (r.width > 0) panelRight = r.right;
|
| 722 |
-
}
|
| 723 |
-
} catch (e) {}
|
| 724 |
-
const fx = ((panelRight + w * 0.94) / 2) / w;
|
| 725 |
-
C.focus = [Math.min(0.82, Math.max(0.58, fx)), 0.5];
|
| 726 |
-
}
|
| 727 |
-
C.scrim = narrow ? "top" : "left";
|
| 728 |
-
C.scrimStrength = narrow ? 0.90 : 0.90;
|
| 729 |
-
C.viewRadius = narrow ? 2.2 : 2.6;
|
| 730 |
-
C.lead = narrow ? 0.05 : 0.12;
|
| 731 |
-
C.glow = narrow ? 0.8 : 1;
|
| 732 |
-
/* Ở màn hẹp (<=767px) khối đăng nhập chiếm gần hết bề ngang -> chữ thập buộc phải
|
| 733 |
-
nằm trong vùng đó. Làm nó mờ hẳn (watermark) để không phá chữ, thay vì đè cứng lên form. */
|
| 734 |
-
C.heroAlpha = narrow ? 0.16 : 1;
|
| 735 |
-
}
|
| 736 |
-
applyResponsive();
|
| 737 |
-
|
| 738 |
-
let width=0, height=0, dpr=1, years=0, lastFrame=0, clock=0, pxPerAU=1, cx=0, cy=0, camDist=1;
|
| 739 |
-
const RIGHT={x:1,y:0,z:0}, UP={x:0,y:1,z:0}, FWD={x:0,y:0,z:1};
|
| 740 |
-
|
| 741 |
-
function setCamera(yaw,pitch,roll) {
|
| 742 |
-
const A=yaw*RAD, B=pitch*RAD, ca=Math.cos(A),sa=Math.sin(A),cb=Math.cos(B),sb=Math.sin(B);
|
| 743 |
-
FWD.x=sa*sb; FWD.y=-ca*sb; FWD.z=cb;
|
| 744 |
-
const rx=ca,ry=sa,rz=0,ux=-sa*cb,uy=ca*cb,uz=sb,Cr=roll*RAD, cr=Math.cos(Cr), sr=Math.sin(Cr);
|
| 745 |
-
RIGHT.x=rx*cr+ux*sr; RIGHT.y=ry*cr+uy*sr; RIGHT.z=rz*cr+uz*sr;
|
| 746 |
-
UP.x=-rx*sr+ux*cr; UP.y=-ry*sr+uy*cr; UP.z=-rz*sr+uz*cr;
|
| 747 |
-
}
|
| 748 |
-
|
| 749 |
-
const P={x:0,y:0,depth:0,s:0,ok:false};
|
| 750 |
-
function project(dx,dy,dz) {
|
| 751 |
-
const vx=dx*RIGHT.x+dy*RIGHT.y+dz*RIGHT.z, vy=dx*UP.x+dy*UP.y+dz*UP.z, vz=dx*FWD.x+dy*FWD.y+dz*FWD.z, depth=camDist-vz;
|
| 752 |
-
if(depth<0.6){P.ok=false;return;}
|
| 753 |
-
const s=camDist/depth;
|
| 754 |
-
P.x=cx+vx*pxPerAU*s; P.y=cy-vy*pxPerAU*s; P.depth=depth; P.s=s; P.ok=true;
|
| 755 |
-
}
|
| 756 |
-
|
| 757 |
-
const DIR={x:0,y:0,z:0};
|
| 758 |
-
function setDrift(lon,lat){const l=lon*RAD,b=lat*RAD;DIR.x=Math.cos(b)*Math.cos(l);DIR.y=Math.cos(b)*Math.sin(l);DIR.z=Math.sin(b);}
|
| 759 |
-
|
| 760 |
-
function elementsOf(p,idx,gamma,spread,ecc,align){
|
| 761 |
-
const aDraw=Math.pow(p.a,gamma), period=Math.pow(aDraw,1.5), fan=PLANE_FAN[idx%PLANE_FAN.length];
|
| 762 |
-
const inc=(p.i+spread*fan[0])*RAD, node=(p.node+spread*fan[1])*RAD, ci=Math.cos(inc),si=Math.sin(inc),cn=Math.cos(node),sn=Math.sin(node);
|
| 763 |
-
const target=ECC_FAN[idx%ECC_FAN.length];
|
| 764 |
-
return{p,rgb:parseRGB(p.color),e:Math.min(0.85,p.e+ecc*(target-p.e)),aDraw,period,n:TAU/period,cw:Math.cos(p.peri*RAD),sw:Math.sin(p.peri*RAD),ci,si,cn,sn,M0:p.M0*RAD,swing:align>0?swingToCourse(si*sn,-si*cn,ci,align):null};
|
| 765 |
-
}
|
| 766 |
-
|
| 767 |
-
function swingToCourse(nx,ny,nz,align){
|
| 768 |
-
const s=nx*DIR.x+ny*DIR.y+nz*DIR.z>=0?1:-1;
|
| 769 |
-
let tx=nx+align*(s*DIR.x-nx),ty=ny+align*(s*DIR.y-ny),tz=nz+align*(s*DIR.z-nz);
|
| 770 |
-
const tl=Math.hypot(tx,ty,tz); if(tl<1e-9)return null;
|
| 771 |
-
tx/=tl;ty/=tl;tz/=tl;
|
| 772 |
-
let ax=ny*tz-nz*ty,ay=nz*tx-nx*tz,az=nx*ty-ny*tx;
|
| 773 |
-
const al=Math.hypot(ax,ay,az); if(al<1e-9)return null;
|
| 774 |
-
ax/=al;ay/=al;az/=al;
|
| 775 |
-
const c=Math.max(-1,Math.min(1,nx*tx+ny*ty+nz*tz)),sA=al>1?1:al,k=1-c;
|
| 776 |
-
return[c+ax*ax*k,ax*ay*k-az*sA,ax*az*k+ay*sA,ay*ax*k+az*sA,c+ay*ay*k,ay*az*k-ax*sA,az*ax*k-ay*sA,az*ay*k+ax*sA,c+az*az*k];
|
| 777 |
-
}
|
| 778 |
-
|
| 779 |
-
const R3={x:0,y:0,z:0};
|
| 780 |
-
function helio(el,M,gamma){
|
| 781 |
-
const e=el.e,E=eccentricAnomaly(M,e),xo=el.p.a*(Math.cos(E)-e),yo=el.p.a*Math.sqrt(1-e*e)*Math.sin(E);
|
| 782 |
-
const x1=xo*el.cw-yo*el.sw,y1=xo*el.sw+yo*el.cw,y2=y1*el.ci,z2=y1*el.si;
|
| 783 |
-
let x=x1*el.cn-y2*el.sn,y=x1*el.sn+y2*el.cn,z=z2;
|
| 784 |
-
const S=el.swing;
|
| 785 |
-
if(S){const rx=S[0]*x+S[1]*y+S[2]*z,ry=S[3]*x+S[4]*y+S[5]*z,rz=S[6]*x+S[7]*y+S[8]*z;x=rx;y=ry;z=rz;}
|
| 786 |
-
if(gamma!==1){const r=Math.sqrt(x*x+y*y+z*z);if(r>1e-9){const s=Math.pow(r,gamma-1);x*=s;y*=s;z*=s;}}
|
| 787 |
-
R3.x=x;R3.y=y;R3.z=z;
|
| 788 |
-
}
|
| 789 |
-
|
| 790 |
-
let elems=[];
|
| 791 |
-
function syncElements(){elems=C.leaves.map((p,i)=>elementsOf(p,i,C.compress,C.planeSpread,C.eccentricity,C.alignToCourse));}
|
| 792 |
-
|
| 793 |
-
let D_NEAR=60,D_FAR=1400,sx=[],sy=[],sz=[],sMag=[],sPhase=[],sTint=[],starN=0,rand=mulberry32(0xc0ffee), dist=0;
|
| 794 |
-
function seedStar(k,depth,edge){
|
| 795 |
-
const d=depth??D_NEAR*Math.pow(D_FAR/D_NEAR,Math.pow(rand(),0.55)),halfW=width*0.5*1.15,halfH=height*0.5*1.15;
|
| 796 |
-
let ox,oy;
|
| 797 |
-
if(edge===0){ox=-halfW;oy=(rand()*2-1)*halfH;}
|
| 798 |
-
else if(edge===1){ox=halfW;oy=(rand()*2-1)*halfH;}
|
| 799 |
-
else if(edge===2){ox=(rand()*2-1)*halfW;oy=-halfH;}
|
| 800 |
-
else if(edge===3){ox=(rand()*2-1)*halfW;oy=halfH;}
|
| 801 |
-
else{ox=(rand()*2-1)*halfW;oy=(rand()*2-1)*halfH;}
|
| 802 |
-
const scale=d/(camDist*pxPerAU),vx=ox*scale,vy=-oy*scale,vz=camDist-d;
|
| 803 |
-
sx[k]=vx*RIGHT.x+vy*UP.x+vz*FWD.x+DIR.x*dist; sy[k]=vx*RIGHT.y+vy*UP.y+vz*FWD.y+DIR.y*dist; sz[k]=vx*RIGHT.z+vy*UP.z+vz*FWD.z+DIR.z*dist;
|
| 804 |
-
sMag[k]=Math.pow(rand(),2.4);sPhase[k]=rand()*TAU; const t=rand();sTint[k]=t>0.85?1:t<0.1?2:0;
|
| 805 |
-
}
|
| 806 |
-
function buildStars(){
|
| 807 |
-
starN=Math.max(40,Math.round(C.moteCount*Math.min(2,(width*height)/(1440*900))));
|
| 808 |
-
sx=new Array(starN);sy=new Array(starN);sz=new Array(starN);sMag=new Array(starN);sPhase=new Array(starN);sTint=new Array(starN);
|
| 809 |
-
rand=mulberry32(0xc0ffee); for(let k=0;k<starN;k++)seedStar(k);
|
| 810 |
-
}
|
| 811 |
-
|
| 812 |
-
const BORDER_LEAVES = [], LEAF_GREENS = ["#2e7d32","#388e3c","#43a047","#66bb6a","#81c784","#4caf50","#1b5e20","#558b2f"];
|
| 813 |
-
function initBorderLeaves() {
|
| 814 |
-
BORDER_LEAVES.length = 0; const n = Math.max(8, Math.round(16 * Math.min(1.5, width / 1200))), rng = mulberry32(42);
|
| 815 |
-
for (let i = 0; i < n; i++) {
|
| 816 |
-
const edge = i % 4; let x, y;
|
| 817 |
-
if (edge === 0) { x = rng() * width * 0.25; y = rng() * height; }
|
| 818 |
-
else if (edge === 1) { x = width - rng() * width * 0.25; y = rng() * height; }
|
| 819 |
-
else if (edge === 2) { x = rng() * width; y = rng() * height * 0.2; }
|
| 820 |
-
else { x = rng() * width; y = height - rng() * height * 0.2; }
|
| 821 |
-
BORDER_LEAVES.push({ x, y, size: (40 + rng() * 60) * 1.14, baseAngle: (rng() - 0.5) * 1.2, swaySpeed: 0.4 + rng() * 0.8, swayAmp: 0.06 + rng() * 0.1, phase: rng() * TAU, color: LEAF_GREENS[Math.floor(rng() * LEAF_GREENS.length)], alpha: 0.35 + rng() * 0.45 });
|
| 822 |
-
}
|
| 823 |
-
}
|
| 824 |
-
function drawBorderLeaves(t) {
|
| 825 |
-
for (const lf of BORDER_LEAVES) {
|
| 826 |
-
const angle = lf.baseAngle + Math.sin(t * lf.swaySpeed + lf.phase) * lf.swayAmp, [r,g,b] = parseRGB(lf.color), sz = lf.size;
|
| 827 |
-
ctx.save(); ctx.translate(lf.x, lf.y); ctx.rotate(angle); ctx.globalAlpha = lf.alpha;
|
| 828 |
-
ctx.beginPath(); ctx.moveTo(0, -sz * 0.55); ctx.quadraticCurveTo(sz * 0.35, -sz * 0.05, 0, sz * 0.5); ctx.quadraticCurveTo(-sz * 0.35, -sz * 0.05, 0, -sz * 0.55); ctx.closePath();
|
| 829 |
-
ctx.fillStyle = `rgb(${r},${g},${b})`; ctx.fill(); ctx.strokeStyle = `rgba(255,255,255,0.3)`; ctx.lineWidth = Math.max(0.8, sz * 0.02); ctx.beginPath(); ctx.moveTo(0, -sz * 0.45); ctx.lineTo(0, sz * 0.42); ctx.stroke();
|
| 830 |
-
ctx.globalAlpha = 1; ctx.restore();
|
| 831 |
-
}
|
| 832 |
-
}
|
| 833 |
-
|
| 834 |
-
const glowCache = new Map();
|
| 835 |
-
function glowSprite(color) {
|
| 836 |
-
const hit = glowCache.get(color); if (hit) return hit;
|
| 837 |
-
const R = 64, c = document.createElement("canvas"); c.width = c.height = R * 2;
|
| 838 |
-
const g2 = c.getContext("2d"), [r, g, b] = parseRGB(color), grad = g2.createRadialGradient(R, R, 0, R, R, R);
|
| 839 |
-
grad.addColorStop(0, `rgba(${r},${g},${b},0.7)`); grad.addColorStop(0.2, `rgba(${r},${g},${b},0.4)`); grad.addColorStop(0.5, `rgba(${r},${g},${b},0.1)`); grad.addColorStop(1, `rgba(${r},${g},${b},0)`);
|
| 840 |
-
g2.fillStyle = grad; g2.fillRect(0, 0, R * 2, R * 2); glowCache.set(color, c); return c;
|
| 841 |
-
}
|
| 842 |
-
|
| 843 |
-
function resize() {
|
| 844 |
-
const w = window.innerWidth, h = window.innerHeight; dpr = Math.min(window.devicePixelRatio || 1, 2);
|
| 845 |
-
width = w; height = h; canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr);
|
| 846 |
-
ctx.setTransform(dpr, 0, 0, dpr, 0, 0); layout(); buildStars(); initBorderLeaves();
|
| 847 |
-
}
|
| 848 |
-
function layout() {
|
| 849 |
-
pxPerAU = (Math.min(width, height) * 0.5) / C.viewRadius; camDist = C.viewRadius * 3.1;
|
| 850 |
-
D_NEAR = camDist * 5; D_FAR = camDist * 120; setDrift(C.driftDir[0], C.driftDir[1]); setCamera(C.spin, C.tilt, C.roll);
|
| 851 |
-
}
|
| 852 |
-
|
| 853 |
-
let pointerX = 0, pointerY = 0, camX = 0, camY = 0;
|
| 854 |
-
window.addEventListener("pointermove", (ev) => {
|
| 855 |
-
if (!C.interactive) return;
|
| 856 |
-
pointerX = (ev.clientX / window.innerWidth - 0.5) * 2; pointerY = (ev.clientY / window.innerHeight - 0.5) * 2;
|
| 857 |
-
});
|
| 858 |
-
|
| 859 |
-
// Nhịp tim lub-dub (0..1)
|
| 860 |
-
function heartEnv(clk) {
|
| 861 |
-
if (reduceMotion) return 0.15;
|
| 862 |
-
const T = 1.05, p = (clk % T) / T, g = (x, mu, s) => Math.exp(-((x - mu) * (x - mu)) / (2 * s * s));
|
| 863 |
-
return Math.min(1, g(p, 0.07, 0.045) + 0.58 * g(p, 0.27, 0.05));
|
| 864 |
-
}
|
| 865 |
-
function crossBaseR() { return Math.max(32, Math.min(width, height) * 0.0713); } /* to hơn ~20% */
|
| 866 |
-
|
| 867 |
-
// Tia sáng xoay quanh chữ thập
|
| 868 |
-
function drawRays(clk, env) {
|
| 869 |
-
const baseR = crossBaseR(), [r, g, b] = RAY_RGB;
|
| 870 |
-
ctx.save(); ctx.globalCompositeOperation = "lighter"; ctx.translate(cx, cy); ctx.rotate(reduceMotion ? 0 : clk * 0.12);
|
| 871 |
-
const n = 16, inner = baseR * 1.1;
|
| 872 |
-
for (let i = 0; i < n; i++) {
|
| 873 |
-
const ang = (i / n) * TAU, long = (i % 2 === 0), outer = baseR * (long ? 3.9 : 2.5), w = long ? 0.022 : 0.013, a = (long ? 0.11 : 0.07) + env * 0.06;
|
| 874 |
-
const ci = Math.cos(ang), si = Math.sin(ang), cwp = Math.cos(ang - w), swp = Math.sin(ang - w), cwn = Math.cos(ang + w), swn = Math.sin(ang + w);
|
| 875 |
-
const grad = ctx.createLinearGradient(ci * inner, si * inner, ci * outer, si * outer);
|
| 876 |
-
grad.addColorStop(0, `rgba(${r},${g},${b},${a})`); grad.addColorStop(1, `rgba(${r},${g},${b},0)`);
|
| 877 |
-
ctx.fillStyle = grad; ctx.beginPath();
|
| 878 |
-
ctx.moveTo(cwp * inner, swp * inner); ctx.lineTo(cwp * outer, swp * outer); ctx.lineTo(cwn * outer, swn * outer); ctx.lineTo(cwn * inner, swn * inner); ctx.closePath(); ctx.fill();
|
| 879 |
-
}
|
| 880 |
-
ctx.restore();
|
| 881 |
-
}
|
| 882 |
-
|
| 883 |
-
// Nhịp tim: hào quang + vòng lan tỏa (xanh ngọc)
|
| 884 |
-
function drawHeartbeat(clk, env) {
|
| 885 |
-
const baseR = crossBaseR(), [r, g, b] = PULSE_RGB;
|
| 886 |
-
ctx.save(); ctx.globalCompositeOperation = "lighter";
|
| 887 |
-
const glowR = baseR * (1.5 + env * 1.4), grad = ctx.createRadialGradient(cx, cy, baseR * 0.5, cx, cy, glowR);
|
| 888 |
-
grad.addColorStop(0, `rgba(${r},${g},${b},0)`); grad.addColorStop(0.62, `rgba(${r},${g},${b},${(0.30 * env).toFixed(3)})`); grad.addColorStop(1, `rgba(${r},${g},${b},0)`);
|
| 889 |
-
ctx.fillStyle = grad; ctx.beginPath(); ctx.arc(cx, cy, glowR, 0, TAU); ctx.fill();
|
| 890 |
-
if (!reduceMotion) {
|
| 891 |
-
const T = 1.05, p = (clk % T) / T;
|
| 892 |
-
[[0.07, 1], [0.27, 0.7]].forEach(function (mw) {
|
| 893 |
-
const mu = mw[0], w = mw[1]; let age = p - mu; if (age < 0) age += 1;
|
| 894 |
-
if (age < 0.55) {
|
| 895 |
-
const prog = age / 0.55, R = baseR * (1.0 + prog * 2.4), alpha = (1 - prog) * 0.35 * w;
|
| 896 |
-
ctx.strokeStyle = `rgba(${r},${g},${b},${alpha.toFixed(3)})`; ctx.lineWidth = (1 - prog) * 2.6 + 0.5;
|
| 897 |
-
ctx.beginPath(); ctx.arc(cx, cy, R, 0, TAU); ctx.stroke();
|
| 898 |
-
}
|
| 899 |
-
});
|
| 900 |
-
}
|
| 901 |
-
ctx.restore();
|
| 902 |
-
}
|
| 903 |
-
|
| 904 |
-
function drawCross(k, env) {
|
| 905 |
-
const [r, g, b] = parseRGB(C.crossColor), scale = 1 + env * 0.06, baseR = crossBaseR() * scale;
|
| 906 |
-
const haze = ctx.createRadialGradient(cx, cy, 0, cx, cy, baseR * 4);
|
| 907 |
-
haze.addColorStop(0, `rgba(${r},${g},${b},${0.12 * k})`); haze.addColorStop(0.4, `rgba(${r},${g},${b},${0.04 * k})`); haze.addColorStop(1, `rgba(${r},${g},${b},0)`);
|
| 908 |
-
ctx.fillStyle = haze; ctx.beginPath(); ctx.arc(cx, cy, baseR * 4, 0, TAU); ctx.fill();
|
| 909 |
-
const mid = ctx.createRadialGradient(cx, cy, 0, cx, cy, baseR * 2);
|
| 910 |
-
mid.addColorStop(0, `rgba(${r},${g},${b},${0.25 * k})`); mid.addColorStop(0.5, `rgba(${r},${g},${b},${0.08 * k})`); mid.addColorStop(1, `rgba(${r},${g},${b},0)`);
|
| 911 |
-
ctx.fillStyle = mid; ctx.beginPath(); ctx.arc(cx, cy, baseR * 2, 0, TAU); ctx.fill();
|
| 912 |
-
const badgeR = baseR * 0.95, badge = ctx.createRadialGradient(cx, cy - badgeR * 0.15, badgeR * 0.2, cx, cy, badgeR);
|
| 913 |
-
badge.addColorStop(0, "#8fcb5e"); badge.addColorStop(1, "#3c8b22");
|
| 914 |
-
ctx.fillStyle = badge; ctx.beginPath(); ctx.arc(cx, cy, badgeR, 0, TAU); ctx.fill();
|
| 915 |
-
const [pr, pg, pb] = PULSE_RGB;
|
| 916 |
-
ctx.strokeStyle = `rgba(${pr},${pg},${pb},${(0.35 + env * 0.5).toFixed(3)})`; ctx.lineWidth = 2 + env * 1.5;
|
| 917 |
-
ctx.beginPath(); ctx.arc(cx, cy, badgeR + 3, 0, TAU); ctx.stroke();
|
| 918 |
-
const armLen = badgeR * 0.6, armW = badgeR * 0.22, rad = armW * 0.45;
|
| 919 |
-
ctx.fillStyle = "#fff";
|
| 920 |
-
ctx.beginPath(); ctx.roundRect(cx - armW, cy - armLen, armW * 2, armLen * 2, rad); ctx.fill();
|
| 921 |
-
ctx.beginPath(); ctx.roundRect(cx - armLen, cy - armW, armLen * 2, armW * 2, rad); ctx.fill();
|
| 922 |
-
}
|
| 923 |
-
|
| 924 |
-
function drawLeafHead(x, y, size, color, angle, bright) {
|
| 925 |
-
const [r, g, b] = parseRGB(color); ctx.save(); ctx.translate(x, y); ctx.rotate(angle);
|
| 926 |
-
const L = size * 2.8, W = size * 1.6;
|
| 927 |
-
ctx.beginPath(); ctx.moveTo(0, -L * 0.5); ctx.quadraticCurveTo(W * 0.5, -L * 0.06, 0, L * 0.48); ctx.quadraticCurveTo(-W * 0.5, -L * 0.06, 0, -L * 0.5); ctx.closePath();
|
| 928 |
-
ctx.fillStyle = `rgba(${r},${g},${b},${Math.min(1, 0.9 * bright).toFixed(3)})`; ctx.fill();
|
| 929 |
-
ctx.strokeStyle = `rgba(255,255,255,${Math.min(1, 0.4 * bright).toFixed(3)})`; ctx.lineWidth = Math.max(0.6, size * 0.08);
|
| 930 |
-
ctx.beginPath(); ctx.moveTo(0, -size * 1.3); ctx.lineTo(0, size * 1.15); ctx.stroke(); ctx.restore();
|
| 931 |
-
}
|
| 932 |
-
|
| 933 |
-
function render(t) {
|
| 934 |
-
const k = C.glow, env = heartEnv(clock); layout(); syncElements();
|
| 935 |
-
camX += (pointerX - camX) * 0.04; camY += (pointerY - camY) * 0.04;
|
| 936 |
-
setCamera(C.spin + camX * 7, C.tilt + camY * 5, C.roll);
|
| 937 |
-
dist = C.driftSpeed * t; cx = width * C.focus[0]; cy = height * C.focus[1];
|
| 938 |
-
project(DIR.x, DIR.y, DIR.z);
|
| 939 |
-
if (P.ok) {
|
| 940 |
-
const dxs = P.x - cx, dys = P.y - cy, len = Math.hypot(dxs, dys) || 1, push = Math.min(width, height) * C.lead;
|
| 941 |
-
cx += (dxs / len) * push; cy += (dys / len) * push;
|
| 942 |
-
}
|
| 943 |
-
ctx.globalCompositeOperation = "source-over";
|
| 944 |
-
const bg = ctx.createRadialGradient(cx, cy, 0, cx, cy, Math.max(width, height) * 0.85);
|
| 945 |
-
bg.addColorStop(0, "#f0fae0"); bg.addColorStop(0.4, "#e4f4cc"); bg.addColorStop(1, "#d2eaab");
|
| 946 |
-
ctx.fillStyle = bg; ctx.fillRect(0, 0, width, height);
|
| 947 |
-
// Vòng orbit nét đứt trang trí
|
| 948 |
-
ctx.setLineDash([3, 14]);
|
| 949 |
-
ctx.strokeStyle = "rgba(120,160,80,0.20)";
|
| 950 |
-
ctx.lineWidth = 1.5;
|
| 951 |
-
[160, 110].forEach(r => {
|
| 952 |
-
const R = Math.min(width, height) * r / 417;
|
| 953 |
-
ctx.beginPath(); ctx.arc(cx, cy, R, 0, TAU); ctx.stroke();
|
| 954 |
-
});
|
| 955 |
-
ctx.setLineDash([]);
|
| 956 |
-
const dRef = D_NEAR * 3.3, left = -width * 0.12, right = width * 1.12, top = -height * 0.12, bottom = height * 1.12;
|
| 957 |
-
for (let s = 0; s < starN; s++) {
|
| 958 |
-
project(sx[s] - DIR.x * dist, sy[s] - DIR.y * dist, sz[s] - DIR.z * dist);
|
| 959 |
-
if (!P.ok || P.depth > D_FAR * 1.25) { seedStar(s); continue; }
|
| 960 |
-
if (P.x < left || P.x > right || P.y < top || P.y > bottom) { seedStar(s, undefined, P.x < left ? 1 : P.x > right ? 0 : P.y < top ? 3 : 2); continue; }
|
| 961 |
-
if (P.depth < D_NEAR * 0.75) continue;
|
| 962 |
-
const near = Math.min(1, (P.depth - D_NEAR * 0.75) / (D_NEAR * 0.6));
|
| 963 |
-
const far = 1 - Math.max(0, (P.depth - D_FAR * 0.78) / (D_FAR * 0.32));
|
| 964 |
-
let a = (0.4 + sMag[s] * 1.5) * Math.pow(dRef / P.depth, 0.8) * near * far;
|
| 965 |
-
if (a <= 0.01) continue;
|
| 966 |
-
a *= 0.85 + 0.15 * Math.sin(t * 7 + sPhase[s]);
|
| 967 |
-
const col = sTint[s] === 1 ? "211,84,0" : sTint[s] === 2 ? "20,90,20" : "39,174,96";
|
| 968 |
-
const size = Math.min(5.5, 1.5 + sMag[s] * 4.0 * Math.pow(dRef / P.depth, 0.5));
|
| 969 |
-
ctx.globalAlpha = Math.min(0.95, a);
|
| 970 |
-
ctx.fillStyle = `rgb(${col})`;
|
| 971 |
-
if (size < 1.2) ctx.fillRect(P.x, P.y, size, size);
|
| 972 |
-
else { ctx.beginPath(); ctx.arc(P.x, P.y, size * 0.5, 0, TAU); ctx.fill(); }
|
| 973 |
-
ctx.globalAlpha = 1;
|
| 974 |
-
}
|
| 975 |
-
|
| 976 |
-
const shots = [];
|
| 977 |
-
for (const el of elems) {
|
| 978 |
-
const [r, g, b] = el.rgb, bright = (el.p.glow ?? 1) * k, span = Math.min(C.trailCycles, C.maxTurns * el.period), turns = span / el.period;
|
| 979 |
-
const N = Math.max(48, Math.min(360, Math.ceil(turns * 46 * (1 + 2.2 * el.e)) + 48));
|
| 980 |
-
const xs = new Float64Array(N + 1), ys = new Float64Array(N + 1), okArr = new Uint8Array(N + 1);
|
| 981 |
-
for (let q = 0; q <= N; q++) {
|
| 982 |
-
const age = (1 - q / N) * span;
|
| 983 |
-
helio(el, el.M0 + el.n * (t - age), C.compress);
|
| 984 |
-
const back = C.driftSpeed * age;
|
| 985 |
-
project(R3.x - DIR.x * back, R3.y - DIR.y * back, R3.z - DIR.z * back);
|
| 986 |
-
xs[q] = P.x; ys[q] = P.y; okArr[q] = P.ok ? 1 : 0;
|
| 987 |
-
if (q === N && P.ok) shots.push({ el, x: P.x, y: P.y, depth: P.depth, s: P.s });
|
| 988 |
-
}
|
| 989 |
-
ctx.lineCap = "round"; ctx.lineJoin = "round"; ctx.strokeStyle = `rgba(${r},${g},${b},${(0.06 * bright).toFixed(3)})`; ctx.lineWidth = 5;
|
| 990 |
-
ctx.beginPath(); let started = false;
|
| 991 |
-
for (let q = Math.floor(N * 0.7); q <= N; q++) {
|
| 992 |
-
if (!okArr[q]) { started = false; continue; }
|
| 993 |
-
if (!started) { ctx.moveTo(xs[q], ys[q]); started = true; } else ctx.lineTo(xs[q], ys[q]);
|
| 994 |
-
}
|
| 995 |
-
ctx.stroke();
|
| 996 |
-
ctx.lineCap = "butt"; ctx.lineWidth = 1.5;
|
| 997 |
-
for (let q = 0; q < N; q++) {
|
| 998 |
-
if (!okArr[q] || !okArr[q + 1]) continue;
|
| 999 |
-
const f = (q + 1) / N, a = Math.pow(f, 2.4) * 0.7 * bright;
|
| 1000 |
-
if (a < 0.005) continue;
|
| 1001 |
-
ctx.strokeStyle = `rgba(${r},${g},${b},${a.toFixed(3)})`; ctx.beginPath(); ctx.moveTo(xs[q], ys[q]); ctx.lineTo(xs[q + 1], ys[q + 1]); ctx.stroke();
|
| 1002 |
-
}
|
| 1003 |
-
}
|
| 1004 |
-
|
| 1005 |
-
shots.sort((a, b) => b.depth - a.depth);
|
| 1006 |
-
const sizeScale = Math.min(width, height) / 500 * 1.14; /* lá to hơn ~20% */
|
| 1007 |
-
const drawShot = (o, index) => {
|
| 1008 |
-
const depth = Math.min(1.3, Math.max(0.5, o.s)), size = o.el.p.size * depth * sizeScale, bright = (o.el.p.glow ?? 1) * k, R = size * 3;
|
| 1009 |
-
ctx.globalAlpha = Math.min(0.7, 0.5 * bright); ctx.drawImage(glowSprite(o.el.p.color), o.x - R, o.y - R, R * 2, R * 2); ctx.globalAlpha = 1;
|
| 1010 |
-
const angle = Math.sin(t * 1.3 + index * 1.7) * 0.18; drawLeafHead(o.x, o.y, size, o.el.p.color, angle, bright);
|
| 1011 |
-
};
|
| 1012 |
-
|
| 1013 |
-
let idx = 0;
|
| 1014 |
-
while (idx < shots.length && shots[idx].depth > camDist) drawShot(shots[idx], idx++);
|
| 1015 |
-
ctx.save(); ctx.globalAlpha = C.heroAlpha ?? 1;
|
| 1016 |
-
drawRays(clock, env);
|
| 1017 |
-
drawHeartbeat(clock, env);
|
| 1018 |
-
drawCross(k, env);
|
| 1019 |
-
ctx.restore();
|
| 1020 |
-
while (idx < shots.length) drawShot(shots[idx], idx++);
|
| 1021 |
-
drawBorderLeaves(t);
|
| 1022 |
-
|
| 1023 |
-
if (C.scrim !== "none") {
|
| 1024 |
-
const s = Math.max(0, Math.min(1, C.scrimStrength));
|
| 1025 |
-
const g = C.scrim === "left" ? ctx.createLinearGradient(0, 0, width, 0) : ctx.createLinearGradient(0, 0, 0, height);
|
| 1026 |
-
for (let q = 0; q <= 12; q++) { const x = q / 12; g.addColorStop(x, `rgba(232,245,214,${(s * Math.pow(1 - x, 2.2)).toFixed(4)})`); }
|
| 1027 |
-
ctx.fillStyle = g; ctx.fillRect(0, 0, width, height);
|
| 1028 |
-
}
|
| 1029 |
-
}
|
| 1030 |
-
|
| 1031 |
-
let active = true;
|
| 1032 |
-
function tick(now) {
|
| 1033 |
-
requestAnimationFrame(tick);
|
| 1034 |
-
if (!active || document.hidden) { lastFrame = now; return; }
|
| 1035 |
-
const dt = lastFrame ? Math.min(0.05, (now - lastFrame) / 1000) : 0;
|
| 1036 |
-
lastFrame = now;
|
| 1037 |
-
clock = now / 1000;
|
| 1038 |
-
years += dt / Math.max(0.1, C.cycleSeconds);
|
| 1039 |
-
render(years);
|
| 1040 |
-
}
|
| 1041 |
-
|
| 1042 |
-
resize(); render(years); requestAnimationFrame(tick);
|
| 1043 |
-
window.addEventListener("resize", () => { applyResponsive(); resize(); });
|
| 1044 |
-
|
| 1045 |
-
let prevOnLogin = null;
|
| 1046 |
-
setInterval(function () {
|
| 1047 |
-
const el = document.getElementById("login_wrapper");
|
| 1048 |
-
const exists = !!el;
|
| 1049 |
-
const onLogin = exists && el.offsetParent !== null;
|
| 1050 |
-
document.body.classList.toggle("leaf-on", onLogin);
|
| 1051 |
-
document.body.classList.toggle("app-on", exists && !onLogin); /* khu làm việc: lá vẫn bay nhưng rất mờ */
|
| 1052 |
-
active = true;
|
| 1053 |
-
// Khi vừa quay lại màn đăng nhập (vd sau khi đăng xuất) -> đưa trang về đầu để login không bị lạc
|
| 1054 |
-
if (onLogin && prevOnLogin === false) { try { window.scrollTo(0, 0); } catch (e) {} }
|
| 1055 |
-
if (!onLogin && prevOnLogin === true) { try { window.scrollTo(0, 0); } catch (e) {} }
|
| 1056 |
-
prevOnLogin = onLogin;
|
| 1057 |
-
applyResponsive(); // giữ chữ thập luôn khớp vị trí khối đăng nhập
|
| 1058 |
-
}, 250);
|
| 1059 |
-
|
| 1060 |
-
/* Hiệu ứng: kết quả quét & đơn thuốc hiện ra mượt thay vì nhảy cục */
|
| 1061 |
-
try {
|
| 1062 |
-
const flash = function (el) {
|
| 1063 |
-
if (!el) return;
|
| 1064 |
-
el.classList.remove("just-updated");
|
| 1065 |
-
void el.offsetWidth;
|
| 1066 |
-
el.classList.add("just-updated");
|
| 1067 |
-
};
|
| 1068 |
-
const watch = function (sel) {
|
| 1069 |
-
const host = document.querySelector(sel);
|
| 1070 |
-
if (!host) return false;
|
| 1071 |
-
new MutationObserver(function () { flash(host); })
|
| 1072 |
-
.observe(host, { childList: true, subtree: true });
|
| 1073 |
-
return true;
|
| 1074 |
-
};
|
| 1075 |
-
let tries2 = 0;
|
| 1076 |
-
const t2 = setInterval(function () {
|
| 1077 |
-
const a = watch("#scan_result"), b = watch("#rx_box");
|
| 1078 |
-
if ((a && b) || ++tries2 > 100) clearInterval(t2);
|
| 1079 |
-
}, 200);
|
| 1080 |
-
} catch (e) {}
|
| 1081 |
-
|
| 1082 |
-
return true;
|
| 1083 |
-
}
|
| 1084 |
-
|
| 1085 |
-
let tries = 0;
|
| 1086 |
-
const timer = setInterval(function () {
|
| 1087 |
-
if (boot() || ++tries > 120) clearInterval(timer);
|
| 1088 |
-
}, 100);
|
| 1089 |
-
})();
|
| 1090 |
-
</script>
|
| 1091 |
-
"""
|
| 1092 |
-
|
| 1093 |
custom_css = """
|
| 1094 |
-
|
| 1095 |
-
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
|
| 1099 |
-
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
|
| 1107 |
-
|
| 1108 |
-
|
| 1109 |
-
|
| 1110 |
-
|
| 1111 |
-
|
| 1112 |
-
|
| 1113 |
-
|
| 1114 |
-
|
| 1115 |
-
|
| 1116 |
-
|
| 1117 |
-
|
| 1118 |
-
|
| 1119 |
-
|
| 1120 |
-
|
| 1121 |
-
|
| 1122 |
-
|
| 1123 |
-
.
|
| 1124 |
-
|
| 1125 |
-
|
| 1126 |
-
|
| 1127 |
-
|
| 1128 |
-
|
| 1129 |
-
|
| 1130 |
-
|
| 1131 |
-
|
| 1132 |
-
|
| 1133 |
-
|
| 1134 |
-
|
| 1135 |
-
}
|
| 1136 |
-
|
| 1137 |
-
|
| 1138 |
-
|
| 1139 |
-
|
| 1140 |
-
|
| 1141 |
-
|
| 1142 |
-
|
| 1143 |
-
|
| 1144 |
-
|
| 1145 |
-
|
| 1146 |
-
|
| 1147 |
-
|
| 1148 |
-
|
| 1149 |
-
|
| 1150 |
-
|
| 1151 |
-
|
| 1152 |
-
|
| 1153 |
-
|
| 1154 |
-
|
| 1155 |
-
|
| 1156 |
-
|
| 1157 |
-
|
| 1158 |
-
|
| 1159 |
-
|
| 1160 |
-
|
| 1161 |
-
}
|
| 1162 |
-
|
| 1163 |
-
|
| 1164 |
-
|
| 1165 |
-
|
| 1166 |
-
|
| 1167 |
-
|
| 1168 |
-
|
| 1169 |
-
|
| 1170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1171 |
}
|
| 1172 |
-
#login_wrapper .block, #login_wrapper .form{ margin: 0 !important; min-width: 0 !important; }
|
| 1173 |
-
#login_error{ margin: 0 !important; padding: 0 !important; min-height: 0 !important; }
|
| 1174 |
-
#login_error:empty{ display: none !important; }
|
| 1175 |
-
#login_wrapper [data-testid="status-tracker"], #login_wrapper .status-tracker{ display: none !important; }
|
| 1176 |
-
|
| 1177 |
-
/* Thương hiệu trên màn đăng nhập */
|
| 1178 |
-
.lv4-head{ display: flex; align-items: center; gap: .85rem; margin-bottom: .4rem; }
|
| 1179 |
-
.lv4-badge{
|
| 1180 |
-
width: 46px; height: 46px; flex: 0 0 46px; border-radius: 15px; display: grid; place-items: center;
|
| 1181 |
-
background: radial-gradient(circle at 34% 28%, #93cf62, #2f8b1c);
|
| 1182 |
-
box-shadow: 0 10px 22px -10px rgba(45,122,18,.75), inset 0 1px 0 rgba(255,255,255,.55);
|
| 1183 |
-
}
|
| 1184 |
-
.lv4-badge svg{ width: 24px; height: 24px; }
|
| 1185 |
-
.lv4-heart{ transform-origin: center; animation: beat 1.05s ease-in-out infinite; }
|
| 1186 |
-
.lv4-title{
|
| 1187 |
-
margin: 0; min-width: 0; font-family: var(--serif) !important;
|
| 1188 |
-
font-weight: 700; line-height: 1.18; letter-spacing: -.005em;
|
| 1189 |
-
font-size: clamp(1.45rem, 2.5vw, 2.05rem); color: var(--ink);
|
| 1190 |
-
}
|
| 1191 |
-
.lv4-accent{
|
| 1192 |
-
background: linear-gradient(120deg, #34d399, #059669 55%, #2d7a12);
|
| 1193 |
-
-webkit-background-clip: text; background-clip: text;
|
| 1194 |
-
-webkit-text-fill-color: transparent; color: transparent;
|
| 1195 |
-
font-style: italic;
|
| 1196 |
-
}
|
| 1197 |
-
.lv4-sub{ margin: .5rem 0 .2rem; font-size: .93rem; color: var(--ink-2); line-height: 1.6; }
|
| 1198 |
-
|
| 1199 |
-
#login_wrapper label span, #login_wrapper .gr-box label{
|
| 1200 |
-
color: var(--ink-2) !important; font-size: 11.5px !important; font-weight: 700 !important;
|
| 1201 |
-
letter-spacing: .12em !important; text-transform: uppercase !important;
|
| 1202 |
-
}
|
| 1203 |
-
#login_wrapper input[type="text"], #login_wrapper input[type="password"]{
|
| 1204 |
-
background: rgba(255,255,255,.72) !important; border: 1px solid var(--line) !important;
|
| 1205 |
-
border-radius: var(--r) !important; color: var(--ink) !important;
|
| 1206 |
-
font-size: 15px !important; min-height: 50px !important; padding: 0 16px !important;
|
| 1207 |
-
font-family: var(--sans) !important; transition: all .2s ease !important;
|
| 1208 |
-
}
|
| 1209 |
-
#login_wrapper input::placeholder{ color: var(--ink-3) !important; }
|
| 1210 |
-
#login_wrapper input:hover{ border-color: rgba(16,185,129,.5) !important; background: rgba(255,255,255,.85) !important; }
|
| 1211 |
-
#login_wrapper input:focus, #login_wrapper input:focus-visible{
|
| 1212 |
-
border-color: var(--emerald) !important; background: #fff !important; outline: none !important;
|
| 1213 |
-
box-shadow: 0 0 0 4px rgba(16,185,129,.3) !important;
|
| 1214 |
-
}
|
| 1215 |
-
#login_wrapper .scan-btn{
|
| 1216 |
-
min-height: 54px !important; margin-top: 4px !important; width: 100% !important;
|
| 1217 |
-
font-size: 14.5px !important; letter-spacing: .09em !important; text-transform: uppercase !important;
|
| 1218 |
-
}
|
| 1219 |
-
.lv4-demo{ margin-top: .85rem; font-size: .8rem; color: var(--ink-3); }
|
| 1220 |
-
.lv4-demo-title{ display: block; margin-bottom: .45rem; font-weight: 700; color: var(--ink-2);
|
| 1221 |
-
font-size: .72rem; letter-spacing: .11em; text-transform: uppercase; }
|
| 1222 |
-
.lv4-demo-row{ display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
|
| 1223 |
-
.lv4-chip{
|
| 1224 |
-
font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace !important;
|
| 1225 |
-
font-size: .78rem; font-weight: 600; color: var(--emerald-d);
|
| 1226 |
-
background: rgba(16,185,129,.13); border: 1px solid rgba(16,185,129,.3);
|
| 1227 |
-
padding: .22rem .6rem; border-radius: .5rem;
|
| 1228 |
-
}
|
| 1229 |
-
.sp-error{
|
| 1230 |
-
margin-top: 10px; padding: 11px 15px; border-radius: 12px;
|
| 1231 |
-
background: rgba(176,42,36,.09); border: 1px solid rgba(176,42,36,.35);
|
| 1232 |
-
color: var(--danger); font-size: 13.5px; font-weight: 600;
|
| 1233 |
-
display: flex; align-items: center; gap: 9px;
|
| 1234 |
-
}
|
| 1235 |
-
|
| 1236 |
-
/* ═══ TOPBAR (khu làm việc) ═══════════════════════════════════════ */
|
| 1237 |
-
.hospital-header{
|
| 1238 |
-
background: var(--paper) !important;
|
| 1239 |
-
border: 1px solid var(--line-2) !important;
|
| 1240 |
-
box-shadow: 0 10px 28px -22px rgba(20,60,25,.6) !important;
|
| 1241 |
-
color: var(--ink) !important;
|
| 1242 |
-
padding: 11px 16px !important; border-radius: 18px !important; margin-bottom: 14px !important;
|
| 1243 |
-
align-items: center !important;
|
| 1244 |
-
}
|
| 1245 |
-
.topbar{ display: flex; align-items: center; gap: .8rem; min-width: 0; }
|
| 1246 |
-
.tb-badge{
|
| 1247 |
-
width: 42px; height: 42px; flex: 0 0 42px; border-radius: 14px; display: grid; place-items: center;
|
| 1248 |
-
background: radial-gradient(circle at 34% 28%, #93cf62, #2f8b1c);
|
| 1249 |
-
box-shadow: 0 8px 18px -9px rgba(45,122,18,.75), inset 0 1px 0 rgba(255,255,255,.5);
|
| 1250 |
-
}
|
| 1251 |
-
.tb-badge svg{ width: 22px; height: 22px; }
|
| 1252 |
-
/* Khu làm việc dùng chữ KHÔNG chân cho đồng bộ với các nhãn mục.
|
| 1253 |
-
Chữ có chân (Lora) chỉ dành riêng cho màn đăng nhập — khoảnh khắc thương hiệu. */
|
| 1254 |
-
.tb-name{
|
| 1255 |
-
font-family: var(--sans) !important; font-weight: 800; font-size: 16px;
|
| 1256 |
-
letter-spacing: -.01em; line-height: 1.3; color: var(--ink);
|
| 1257 |
-
}
|
| 1258 |
-
.tb-name .lv4-accent{ font-style: normal; } /* bỏ chữ nghiêng trong khu làm việc */
|
| 1259 |
-
.tb-sub{
|
| 1260 |
-
font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
|
| 1261 |
-
color: var(--ink-3); margin-top: 3px;
|
| 1262 |
-
}
|
| 1263 |
-
.hospital-header-center{ text-align: left !important; width: 100%; }
|
| 1264 |
-
|
| 1265 |
-
/* ═══ THẺ NỘI DUNG — giấy kỹ thuật, KHÔNG dùng backdrop-filter ═════
|
| 1266 |
-
(backdrop-filter tạo "containing block" mới → làm hỏng danh sách
|
| 1267 |
-
thả xuống của Gradio. Đây là gốc lỗi không chọn được loại cây.) */
|
| 1268 |
-
.gr-group{
|
| 1269 |
-
border: 1px solid var(--line-2) !important;
|
| 1270 |
-
background: var(--paper) !important;
|
| 1271 |
-
border-radius: var(--r) !important;
|
| 1272 |
-
margin-bottom: 12px !important;
|
| 1273 |
-
box-shadow: 0 8px 22px -20px rgba(20,60,25,.55) !important;
|
| 1274 |
-
overflow: visible !important;
|
| 1275 |
-
-webkit-backdrop-filter: none !important; backdrop-filter: none !important;
|
| 1276 |
-
}
|
| 1277 |
-
|
| 1278 |
-
/* ── Tiêu đề mục: số + icon + nhãn IN HOA + đường kẻ mảnh (như biểu mẫu bệnh án) ── */
|
| 1279 |
-
.sec-head{ display: flex; align-items: center; gap: .55rem; margin: 13px 14px 9px; }
|
| 1280 |
-
.sec-num{
|
| 1281 |
-
width: 22px; height: 22px; flex: 0 0 22px; border-radius: 7px; display: grid; place-items: center;
|
| 1282 |
-
font-size: 11.5px; font-weight: 800; color: #fff; font-family: var(--sans);
|
| 1283 |
-
background: linear-gradient(135deg, var(--emerald), var(--emerald-d));
|
| 1284 |
-
box-shadow: 0 6px 13px -8px rgba(5,150,105,.95);
|
| 1285 |
-
}
|
| 1286 |
-
.sec-ico{ width: 17px; height: 17px; flex: 0 0 17px; color: var(--emerald-d); }
|
| 1287 |
-
.sec-title{
|
| 1288 |
-
font-size: 11.5px; font-weight: 800; letter-spacing: .1em; line-height: 1.4;
|
| 1289 |
-
text-transform: uppercase; color: var(--ink-2); white-space: nowrap;
|
| 1290 |
-
}
|
| 1291 |
-
.sec-head::after{ content: ""; flex: 1 1 auto; height: 1px; min-width: 12px;
|
| 1292 |
-
background: linear-gradient(90deg, var(--line), transparent); }
|
| 1293 |
-
.sec-note{ margin: 0 14px 12px; font-size: 12.5px; line-height: 1.65; color: var(--ink-3); }
|
| 1294 |
-
|
| 1295 |
-
/* ═══ NÚT ═════════════════════════════════════════════════════════ */
|
| 1296 |
-
.scan-btn{
|
| 1297 |
-
background: linear-gradient(135deg, var(--emerald), var(--emerald-d)) !important;
|
| 1298 |
-
color: #fff !important; font-family: var(--sans) !important;
|
| 1299 |
-
font-weight: 800 !important; letter-spacing: .04em !important;
|
| 1300 |
-
border: none !important; border-radius: 13px !important; min-height: 48px !important; cursor: pointer;
|
| 1301 |
-
box-shadow: 0 13px 26px -14px rgba(5,150,105,.85), inset 0 1px 0 rgba(255,255,255,.25) !important;
|
| 1302 |
-
transition: transform .18s ease, box-shadow .2s ease, filter .2s ease !important;
|
| 1303 |
-
}
|
| 1304 |
-
.scan-btn:hover{ transform: translateY(-1px); filter: brightness(1.05);
|
| 1305 |
-
box-shadow: 0 18px 34px -14px rgba(5,150,105,.95) !important; }
|
| 1306 |
-
.scan-btn:active{ transform: translateY(0); }
|
| 1307 |
-
|
| 1308 |
-
.logout-btn-style, .history-back-btn-style, .inline-history-btn{
|
| 1309 |
-
background: rgba(255,255,255,.8) !important; color: var(--emerald-d) !important;
|
| 1310 |
-
border: 1px solid rgba(16,185,129,.45) !important; font-weight: 700 !important;
|
| 1311 |
-
border-radius: 12px !important; cursor: pointer; box-shadow: none !important; filter: none !important;
|
| 1312 |
-
font-family: var(--sans) !important; transition: all .2s ease !important;
|
| 1313 |
-
}
|
| 1314 |
-
.logout-btn-style:hover, .history-back-btn-style:hover, .inline-history-btn:hover{
|
| 1315 |
-
background: rgba(16,185,129,.14) !important; border-color: var(--emerald) !important;
|
| 1316 |
-
color: var(--emerald-d) !important; transform: translateY(-1px); filter: none !important;
|
| 1317 |
-
}
|
| 1318 |
-
.logout-btn-style{ height: 42px !important; min-width: 0 !important; padding: 0 18px !important;
|
| 1319 |
-
font-size: 13px !important; margin: 0 !important; white-space: nowrap !important;
|
| 1320 |
-
display: flex !important; align-items: center !important; justify-content: center !important; }
|
| 1321 |
-
.history-back-btn-style{ height: 44px !important; }
|
| 1322 |
-
.inline-history-btn{ height: 34px !important; font-size: 12.5px !important; padding: 0 14px !important;
|
| 1323 |
-
display: inline-flex !important; align-items: center; justify-content: center; }
|
| 1324 |
-
|
| 1325 |
-
.expert-send-btn{
|
| 1326 |
-
background: linear-gradient(135deg, #0ea371, var(--emerald-d)) !important; color: #fff !important;
|
| 1327 |
-
font-weight: 800 !important; font-size: 14.5px !important; border: none !important;
|
| 1328 |
-
border-radius: 13px !important; height: 48px !important; cursor: pointer !important; margin-top: 10px !important;
|
| 1329 |
-
font-family: var(--sans) !important;
|
| 1330 |
-
box-shadow: 0 13px 26px -14px rgba(5,150,105,.85) !important; transition: all .22s ease !important;
|
| 1331 |
-
}
|
| 1332 |
-
.expert-send-btn:hover{ filter: brightness(1.06) !important; transform: translateY(-1px) !important; }
|
| 1333 |
-
|
| 1334 |
-
/* Đỏ chỉ dành cho hành động thật sự phá huỷ dữ liệu */
|
| 1335 |
-
.delete-btn-style, .danger-soft, button.danger-soft{
|
| 1336 |
-
background: rgba(176,42,36,.08) !important; color: var(--danger) !important;
|
| 1337 |
-
border: 1px solid rgba(176,42,36,.34) !important; font-weight: 700 !important;
|
| 1338 |
-
font-size: 13.5px !important; border-radius: 12px !important; cursor: pointer !important;
|
| 1339 |
-
box-shadow: none !important; font-family: var(--sans) !important; transition: all .2s ease !important;
|
| 1340 |
-
}
|
| 1341 |
-
.delete-btn-style{ height: 100% !important; min-height: 82px !important; margin: 0 !important;
|
| 1342 |
-
display: flex !important; align-items: center !important; justify-content: center !important; }
|
| 1343 |
-
.delete-btn-style:hover, .danger-soft:hover, button.danger-soft:hover{
|
| 1344 |
-
background: rgba(176,42,36,.15) !important; border-color: var(--danger) !important;
|
| 1345 |
-
filter: none !important; transform: none !important; }
|
| 1346 |
-
|
| 1347 |
-
/* ═══ KHU CHUYÊN BIỆT ═════════════════════════════════════════════ */
|
| 1348 |
-
#prescription_col .textbox_custom{
|
| 1349 |
-
border-left: 4px solid var(--emerald) !important;
|
| 1350 |
-
background: var(--paper) !important;
|
| 1351 |
-
border-radius: 13px !important;
|
| 1352 |
-
}
|
| 1353 |
-
#chatbot_col{
|
| 1354 |
-
background: var(--paper-2) !important;
|
| 1355 |
-
border: 1px solid var(--line-2) !important;
|
| 1356 |
-
border-radius: var(--r) !important;
|
| 1357 |
-
padding: 14px !important; margin-top: 10px !important;
|
| 1358 |
-
overflow: visible !important;
|
| 1359 |
-
-webkit-backdrop-filter: none !important; backdrop-filter: none !important;
|
| 1360 |
-
}
|
| 1361 |
-
#chatbot_col .chatbot_custom{
|
| 1362 |
-
border-left: 3px solid rgba(16,185,129,.5) !important;
|
| 1363 |
-
background: var(--paper) !important; border-radius: 12px !important;
|
| 1364 |
-
}
|
| 1365 |
-
.chatbot-title-container{ display: flex; justify-content: space-between; align-items: center;
|
| 1366 |
-
width: 100%; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
|
| 1367 |
-
|
| 1368 |
-
/* ═══ Ô NHẬP & DANH SÁCH THẢ XUỐNG (giữ cho chọn được loại cây) ══ */
|
| 1369 |
-
.gradio-container input[type="text"], .gradio-container input[type="password"],
|
| 1370 |
-
.gradio-container textarea, .gradio-container select{
|
| 1371 |
-
border-radius: 12px !important; font-family: var(--sans) !important;
|
| 1372 |
-
}
|
| 1373 |
-
.gradio-container label span{ color: var(--ink-2) !important; font-family: var(--sans) !important; }
|
| 1374 |
-
/* Không cắt/che danh sách tuỳ chọn của Dropdown */
|
| 1375 |
-
.gradio-container .wrap, .gradio-container .wrap-inner,
|
| 1376 |
-
.gradio-container [data-testid="dropdown"], .gradio-container .options{ overflow: visible !important; }
|
| 1377 |
-
.gradio-container ul.options, .gradio-container .options{ z-index: 60 !important; }
|
| 1378 |
-
/* BẢO HIỂM: tuyệt đối không dùng backdrop-filter bên trong khu làm việc.
|
| 1379 |
-
Nó biến thẻ cha thành "khung neo" cho phần tử position:fixed — chính là
|
| 1380 |
-
nguyên nhân khiến danh sách chọn loại cây bị neo sai chỗ rồi biến mất. */
|
| 1381 |
-
.gradio-container .gr-group, .gradio-container .styler,
|
| 1382 |
-
.gradio-container .block, .gradio-container .form{
|
| 1383 |
-
-webkit-backdrop-filter: none !important; backdrop-filter: none !important;
|
| 1384 |
-
filter: none !important;
|
| 1385 |
-
}
|
| 1386 |
-
|
| 1387 |
-
/* ═══ HỘI THOẠI CHUYÊN GIA ════════════════════════════════════════ */
|
| 1388 |
-
.msg{ padding: 10px 14px; margin: 8px 0; border-radius: 12px; font-size: 14.5px;
|
| 1389 |
-
line-height: 1.6; color: var(--ink); }
|
| 1390 |
-
.msg b{ font-size: 14px; }
|
| 1391 |
-
.msg-user{ background: rgba(16,185,129,.10); border-left: 4px solid var(--emerald); }
|
| 1392 |
-
.msg-user b{ color: var(--emerald-d); }
|
| 1393 |
-
.msg-expert{ background: var(--paper); border-left: 4px solid var(--leaf); }
|
| 1394 |
-
.msg-expert b{ color: var(--leaf); }
|
| 1395 |
-
.chip-status{ font-weight: 800; }
|
| 1396 |
-
.chip-q{ background: rgba(16,185,129,.12); padding: 2px 8px; border-radius: 6px; font-weight: 700; }
|
| 1397 |
-
.soft-rule{ border: none; border-top: 1px solid var(--line-2); margin: 20px 0; }
|
| 1398 |
-
|
| 1399 |
-
.footer-text{ text-align: center; margin-top: 22px; color: var(--ink-3);
|
| 1400 |
-
font-size: 12.5px; font-weight: 500; }
|
| 1401 |
-
|
| 1402 |
-
/* ═══ HIỆU ỨNG ════════════════════════════════════════════════════ */
|
| 1403 |
-
@keyframes beat{ 0%,100%{transform:scale(1);} 6%{transform:scale(1.22);} 12%{transform:scale(1);}
|
| 1404 |
-
26%{transform:scale(1.13);} 34%{transform:scale(1);} }
|
| 1405 |
-
@keyframes rise{ from{opacity:0; transform:translateY(14px);} to{opacity:1; transform:none;} }
|
| 1406 |
-
@keyframes pulseGlow{ 0%,100%{transform:scale(1);} 50%{transform:scale(1.04);} }
|
| 1407 |
-
/* Kết quả quét hiện ra mượt thay vì nhảy cục */
|
| 1408 |
-
.just-updated{ animation: rise .5s cubic-bezier(.16,1,.3,1); }
|
| 1409 |
-
|
| 1410 |
-
@media (prefers-reduced-motion: reduce){
|
| 1411 |
-
.lv4-heart, .just-updated, #login_content_col{ animation: none !important; }
|
| 1412 |
-
}
|
| 1413 |
-
|
| 1414 |
-
/* ═══ AN TOÀN MỌI KÍCH THƯỚC ══════════════════════════════════════ */
|
| 1415 |
-
@media (max-width: 900px){
|
| 1416 |
-
.sec-title{ white-space: normal; }
|
| 1417 |
-
}
|
| 1418 |
-
@media (max-width: 767px){
|
| 1419 |
-
#login_wrapper{
|
| 1420 |
-
justify-content: center !important; align-items: flex-start !important;
|
| 1421 |
-
padding: 2rem 1.25rem 3rem !important;
|
| 1422 |
-
}
|
| 1423 |
-
#login_content_col{ max-width: 100% !important; }
|
| 1424 |
-
.hospital-header{ flex-wrap: wrap !important; gap: 10px; }
|
| 1425 |
-
.tb-name{ font-size: 15px; }
|
| 1426 |
-
}
|
| 1427 |
-
"""
|
| 1428 |
-
|
| 1429 |
-
# ── Bộ icon nét mảnh + tiêu đề mục (thay emoji, đồng bộ với nhãn IN HOA ở màn đăng nhập) ──
|
| 1430 |
-
ICO_INTAKE = '<path d="M4 13h4l1.5 2.5h5L16 13h4"/><path d="M6 4h12l2 9v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4l2-9Z"/>'
|
| 1431 |
-
ICO_SCAN = '<path d="M4 8V6a2 2 0 0 1 2-2h2M16 4h2a2 2 0 0 1 2 2v2M20 16v2a2 2 0 0 1-2 2h-2M8 20H6a2 2 0 0 1-2-2v-2"/><circle cx="12" cy="12" r="3"/>'
|
| 1432 |
-
ICO_RX = '<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5Z"/><path d="M14 3v5h5"/><path d="M9 13h6M9 17h4"/>'
|
| 1433 |
-
ICO_CHAT = '<path d="M20 12a7 7 0 0 1-7 7H8l-4 3v-10a7 7 0 0 1 7-7h2a7 7 0 0 1 7 7Z"/><path d="M9 11h6M9 14h4"/>'
|
| 1434 |
-
ICO_EXPERT = '<path d="M16 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2"/><circle cx="9.5" cy="7" r="3.5"/><path d="m16.5 10.5 2 2 4-4"/>'
|
| 1435 |
-
ICO_ARCHIVE = '<rect x="3" y="4" width="18" height="4" rx="1"/><path d="M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8"/><path d="M10 12h4"/>'
|
| 1436 |
-
ICO_REPLY = '<path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 6 6v5"/>'
|
| 1437 |
-
|
| 1438 |
-
def _svg(icon):
|
| 1439 |
-
return (f'<svg class="sec-ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" '
|
| 1440 |
-
f'stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">{icon}</svg>')
|
| 1441 |
-
|
| 1442 |
-
def sec_head(num, title, icon):
|
| 1443 |
-
"""Tiêu đề mục có đánh số — chỉ dùng cho quy trình khám thật sự theo thứ tự 1→4."""
|
| 1444 |
-
return (f'<div class="sec-head"><span class="sec-num">{num}</span>{_svg(icon)}'
|
| 1445 |
-
f'<span class="sec-title">{title}</span></div>')
|
| 1446 |
-
|
| 1447 |
-
def sec_head_plain(title, icon):
|
| 1448 |
-
"""Tiêu đề mục không đánh số — cho các khu nằm ngoài quy trình tuần tự."""
|
| 1449 |
-
return f'<div class="sec-head">{_svg(icon)}<span class="sec-title">{title}</span></div>'
|
| 1450 |
-
|
| 1451 |
-
def sec_note(text):
|
| 1452 |
-
return f'<p class="sec-note">{text}</p>'
|
| 1453 |
-
|
| 1454 |
-
TOPBAR_HTML = """
|
| 1455 |
-
<div class="topbar">
|
| 1456 |
-
<div class="tb-badge" aria-hidden="true">
|
| 1457 |
-
<svg class="lv4-heart" viewBox="0 0 24 24" fill="none"><path d="M12 5v14M5 12h14" stroke="#fff" stroke-width="3.4" stroke-linecap="round"/></svg>
|
| 1458 |
-
</div>
|
| 1459 |
-
<div>
|
| 1460 |
-
<div class="tb-name">Trung tâm Chẩn đoán & Điều trị Bệnh <span class="lv4-accent">Cây trồng</span> Công nghệ cao</div>
|
| 1461 |
-
<div class="tb-sub">Phòng xét nghiệm số · YOLOv8 & Gemini</div>
|
| 1462 |
-
</div>
|
| 1463 |
-
</div>
|
| 1464 |
"""
|
| 1465 |
|
| 1466 |
initial_ticket_text, initial_ticket_img = check_user_expert_status()
|
| 1467 |
|
| 1468 |
-
with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI", css=custom_css
|
| 1469 |
with gr.Row(visible=True, elem_id="login_wrapper") as login_panel:
|
| 1470 |
-
with gr.Column(
|
| 1471 |
-
|
| 1472 |
-
<div class="lv4-head">
|
| 1473 |
-
<div class="lv4-badge" aria-hidden="true">
|
| 1474 |
-
<svg class="lv4-heart" viewBox="0 0 24 24" fill="none"><path d="M12 5v14M5 12h14" stroke="#fff" stroke-width="3.4" stroke-linecap="round"/></svg>
|
| 1475 |
-
</div>
|
| 1476 |
-
<h1 class="lv4-title">Trung tâm Chẩn đoán & Điều trị Bệnh <span class="lv4-accent">Cây trồng</span> Công nghệ cao</h1>
|
| 1477 |
-
</div>
|
| 1478 |
-
<p class="lv4-sub">Xác thực để mở phiên xét nghiệm mô lá.</p>
|
| 1479 |
-
""")
|
| 1480 |
-
username_input = gr.Textbox(label="Tên đăng nhập", placeholder="Nhập tên đăng nhập", max_lines=1)
|
| 1481 |
-
password_input = gr.Textbox(label="Mật khẩu", type="password", placeholder="••••••••", max_lines=1)
|
| 1482 |
-
error_output = gr.HTML("", elem_id="login_error")
|
| 1483 |
-
btn_login = gr.Button("Kích hoạt phiên xét nghiệm", variant="primary", elem_classes="scan-btn")
|
| 1484 |
gr.HTML("""
|
| 1485 |
-
<div class="
|
| 1486 |
-
|
| 1487 |
-
|
|
|
|
| 1488 |
</div>
|
|
|
|
|
|
|
| 1489 |
""")
|
| 1490 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1491 |
|
| 1492 |
with gr.Column(visible=False) as main_panel:
|
| 1493 |
with gr.Row(elem_classes="hospital-header"):
|
| 1494 |
with gr.Column(scale=10, elem_classes="hospital-header-center"):
|
| 1495 |
-
gr.HTML(
|
| 1496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1497 |
with gr.Row():
|
| 1498 |
-
btn_logout = gr.Button("
|
| 1499 |
with gr.Row():
|
| 1500 |
with gr.Column(scale=10):
|
| 1501 |
with gr.Group(elem_classes="gr-group"):
|
| 1502 |
-
gr.
|
| 1503 |
plant_dropdown = gr.Dropdown(
|
| 1504 |
choices=["Cây lúa", "Cây ớt", "Cây cà chua", "Cây dâu tây", "Cây cà phê", "Cây ngô (Bắp)"],
|
| 1505 |
value="Cây cà chua", label="Lựa chọn phân khoa điều trị thực vật" )
|
| 1506 |
with gr.Group(elem_classes="gr-group"):
|
| 1507 |
image_input = gr.Image(type="numpy", label="Ảnh quét tế bào bề mặt lá", height=370)
|
| 1508 |
gr.HTML("<div style='padding: 0 10px 10px 10px;'>")
|
| 1509 |
-
btn_analyze = gr.Button("
|
| 1510 |
gr.HTML("</div>")
|
| 1511 |
with gr.Column(scale=11, elem_id="prescription_col"):
|
| 1512 |
with gr.Group(elem_classes="gr-group"):
|
| 1513 |
-
gr.
|
| 1514 |
-
image_output = gr.Image(type="numpy", label="Bản đồ nội soi vi vị trí: Khoanh vùng khu trú ổ bệnh", height=370
|
| 1515 |
-
gr.
|
| 1516 |
text_output = gr.Textbox(
|
| 1517 |
label="Hồ sơ bệnh án điện tử xuất từ thuật toán",
|
| 1518 |
lines=5,
|
| 1519 |
placeholder="Hồ sơ bệnh án sơ bộ sẽ tự động xuất ra tại đây...",
|
| 1520 |
-
elem_classes="textbox_custom"
|
| 1521 |
|
| 1522 |
with gr.Column(scale=12, elem_id="chatbot_col"):
|
| 1523 |
with gr.Row(elem_classes="chatbot-title-container"):
|
| 1524 |
-
gr.
|
| 1525 |
-
btn_history_nav = gr.Button("Xem
|
| 1526 |
chatbot = gr.Chatbot(
|
| 1527 |
value=[{"role": "assistant", "content": "🤖 Hệ thống đang đợi mẫu quét. Sau khi phân tích xong ảnh lá, tôi sẽ tự động nắm thông tin bệnh lý để kê đơn thuốc chính xác cho bà con!"}],
|
| 1528 |
height=550,
|
|
@@ -1535,84 +881,75 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
|
|
| 1535 |
btn_send = gr.Button("GỬI AI", scale=1, variant="primary", elem_classes="scan-btn")
|
| 1536 |
|
| 1537 |
with gr.Group(elem_classes="gr-group", visible=True) as user_expert_section:
|
| 1538 |
-
gr.
|
| 1539 |
-
gr.
|
| 1540 |
expert_user_query = gr.Textbox(label="Thắc mắc về tình trạng lá cây / nghi ngờ bệnh:", placeholder="Ví dụ: AI đoán cháy bìa lá nhưng tui nghi là đốm vằn, nhờ chuyên gia xem kỹ lại...", lines=2)
|
| 1541 |
-
btn_send_expert = gr.Button("
|
| 1542 |
expert_status_box = gr.HTML(value=initial_ticket_text)
|
| 1543 |
expert_ticket_img_view = gr.Image(value=initial_ticket_img, label="Ảnh mẫu lá bệnh do nhà nông gửi lên", height=250, interactive=False)
|
| 1544 |
|
| 1545 |
-
gr.HTML("<div class='footer-text'>
|
| 1546 |
|
| 1547 |
with gr.Column(visible=False) as history_panel:
|
| 1548 |
with gr.Row(elem_classes="hospital-header"):
|
| 1549 |
with gr.Column(scale=10):
|
| 1550 |
gr.HTML("""
|
| 1551 |
-
<
|
| 1552 |
-
|
| 1553 |
-
<svg viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round">
|
| 1554 |
-
<rect x="3" y="4" width="18" height="4" rx="1"/><path d="M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8"/><path d="M10 12h4"/>
|
| 1555 |
-
</svg>
|
| 1556 |
-
</div>
|
| 1557 |
-
<div>
|
| 1558 |
-
<div class="tb-name">Kho lưu trữ hồ sơ & lịch sử hệ thống</div>
|
| 1559 |
-
<div class="tb-sub">Nhật ký chẩn đoán · Hội thoại · Hộp thư chuyên gia</div>
|
| 1560 |
-
</div>
|
| 1561 |
-
</div>
|
| 1562 |
""")
|
| 1563 |
with gr.Column(scale=2, min_width=150):
|
| 1564 |
-
btn_back_to_clinic = gr.Button("
|
| 1565 |
|
| 1566 |
with gr.Row():
|
| 1567 |
with gr.Column(visible=True) as user_diagnose_col:
|
| 1568 |
-
gr.
|
| 1569 |
history_diagnose_box = gr.Textbox(
|
| 1570 |
value=load_diagnose_history(),
|
| 1571 |
label="Lịch sử các ca bệnh đã quét",
|
| 1572 |
lines=15,
|
| 1573 |
interactive=False )
|
| 1574 |
-
btn_clear_diagnose = gr.Button("
|
| 1575 |
with gr.Column(visible=True) as user_chat_col:
|
| 1576 |
-
gr.
|
| 1577 |
history_chat_box = gr.Textbox(
|
| 1578 |
value=load_chat_history(),
|
| 1579 |
label="Lịch sử chat kê đơn thuốc",
|
| 1580 |
lines=15,
|
| 1581 |
interactive=False
|
| 1582 |
)
|
| 1583 |
-
btn_clear_chat = gr.Button("
|
|
|
|
|
|
|
| 1584 |
|
| 1585 |
-
gr.HTML("<hr class='soft-rule'>")
|
| 1586 |
-
|
| 1587 |
with gr.Group(elem_classes="gr-group"):
|
| 1588 |
-
gr.
|
| 1589 |
|
| 1590 |
with gr.Row(elem_id="expert_select_row"):
|
| 1591 |
admin_ticket_select = gr.Dropdown(label="Danh sách các câu hỏi hỗ trợ:", choices=[], value=None, scale=8)
|
| 1592 |
-
btn_delete_ticket = gr.Button("
|
| 1593 |
|
| 1594 |
with gr.Row():
|
| 1595 |
with gr.Column(scale=1):
|
| 1596 |
admin_ticket_detail = gr.HTML(value="Hiện chưa có yêu cầu hỗ trợ nào.")
|
| 1597 |
with gr.Column(scale=1):
|
| 1598 |
-
admin_ticket_img_display = gr.Image(label="Mẫu lá bệnh do nhà nông gửi lên", height=300, interactive=False)
|
| 1599 |
|
| 1600 |
with gr.Row():
|
| 1601 |
admin_ticket_conversation = gr.HTML(value="", elem_id="full_width_conversation")
|
| 1602 |
|
| 1603 |
with gr.Row():
|
| 1604 |
with gr.Column(scale=1, visible=False) as admin_control_panel:
|
| 1605 |
-
gr.
|
| 1606 |
-
gr.
|
| 1607 |
-
admin_reply_input = gr.Textbox(label="
|
| 1608 |
-
btn_submit_admin_reply = gr.Button("
|
| 1609 |
admin_reply_status = gr.Markdown("")
|
| 1610 |
|
| 1611 |
with gr.Group(visible=True) as user_followup_panel:
|
| 1612 |
-
gr.
|
| 1613 |
-
gr.
|
| 1614 |
-
user_followup_input = gr.Textbox(label="Nội dung câu hỏi thêm", placeholder="Ví dụ: Cảm ơn chuyên gia, cho tôi hỏi thêm phun thuốc này buổi sáng hay chiều thì tốt hơn...", lines=2)
|
| 1615 |
-
btn_send_followup = gr.Button("
|
| 1616 |
|
| 1617 |
btn_login.click(
|
| 1618 |
login_auth,
|
|
|
|
| 316 |
|
| 317 |
def format_ticket_detail(ticket):
|
| 318 |
status_label, _ = get_ticket_status_display(ticket)
|
|
|
|
| 319 |
if "CHƯA TRẢ LỜI" in status_label and "HỎI THÊM" not in status_label:
|
| 320 |
+
status_str = "⏳ ĐANG CHỜ CHUYÊN GIA TRẢ LỜI"
|
| 321 |
+
status_color = "#2980b9"
|
| 322 |
elif "HỎI THÊM" in status_label:
|
| 323 |
+
status_str = "🔄 NHÀ NÔNG ĐÃ HỎI THÊM (CHỜ PHẢN HỒI)"
|
| 324 |
+
status_color = "#d35400"
|
| 325 |
else:
|
| 326 |
+
status_str = "✅ ĐÃ ĐƯỢC CHUYÊN GIA TRẢ LỜI"
|
| 327 |
+
status_color = "#c0392b"
|
| 328 |
|
| 329 |
reply_str = ticket.get('admin_reply', 'Chưa có phản hồi.')
|
| 330 |
+
|
| 331 |
+
header_html = f"""<div style="font-size: 15px; color: #111111; line-height: 1.6; font-weight: 500;">
|
| 332 |
+
📌 <b>MÃ YÊU CẦU:</b> #{ticket['id']} | ⏱️ <b>Thời gian:</b> {ticket['time']}<br>
|
| 333 |
+
🌱 <b>Loại cây:</b> <span style="color: #27ae60; font-weight: bold;">{ticket['plant']}</span><br>
|
| 334 |
+
💬 <b>Câu hỏi từ nhà nông:</b> <span style="color: #2c3e50; font-weight: bold; background: #eef9f5; padding: 2px 8px; border-radius: 4px;">{ticket['user_query']}</span>
|
| 335 |
</div>"""
|
| 336 |
|
| 337 |
history_conversation = ""
|
|
|
|
| 341 |
time_stamp = msg.get("time", "")
|
| 342 |
text = msg.get("text", "")
|
| 343 |
if sender == "USER":
|
| 344 |
+
history_conversation += f"""<div style="background: #eef9f5; border-left: 4px solid #27ae60; padding: 10px 14px; margin: 8px 0; border-radius: 6px; font-size: 15px; line-height: 1.5; color: #111111;">
|
| 345 |
+
<b style="font-size: 15px; color: #1e7e34;">👤 Nhà nông ({time_stamp}):</b> {text}
|
| 346 |
+
</div>"""
|
| 347 |
else:
|
| 348 |
+
history_conversation += f"""<div style="background: #eef6ff; border-left: 4px solid #2980b9; padding: 10px 14px; margin: 8px 0; border-radius: 6px; font-size: 15px; line-height: 1.5; color: #111111;">
|
| 349 |
+
<b style="font-size: 15px; color: #1b4f72;">👨⚕️ Chuyên gia ({time_stamp}):</b> {text}
|
| 350 |
+
</div>"""
|
| 351 |
|
| 352 |
if not history_conversation:
|
| 353 |
+
history_conversation = f"""<div style="color: #1b4f72; font-weight: 600; font-size: 15px; background: #eef6ff; padding: 10px 14px; border-left: 4px solid #2980b9; border-radius: 6px; margin-top: 8px;">{reply_str}</div>"""
|
| 354 |
|
| 355 |
+
conversation_html = f"""<div style="font-size: 15px; color: #111111; line-height: 1.6; width: 100%;">
|
| 356 |
+
🚥 <b>Trạng thái:</b> <span style="font-weight: bold; color: {status_color};">{status_str}</span><br>
|
| 357 |
+
👨⚕️ <b>Nội dung trao đổi với Chuyên gia:</b><br>
|
| 358 |
{history_conversation}
|
| 359 |
</div>"""
|
| 360 |
|
|
|
|
| 450 |
last_ticket = user_tickets[-1]
|
| 451 |
img_p = last_ticket.get('image_path', None)
|
| 452 |
h_info, c_info = format_ticket_detail(last_ticket)
|
| 453 |
+
return h_info + "<br><hr style='border: 1px solid #d4deda; margin: 12px 0;'><br>" + c_info, img_p
|
| 454 |
|
| 455 |
def submit_expert_request(user_question, selected_plant, input_image):
|
| 456 |
global current_detected_disease_context
|
|
|
|
| 490 |
tickets.append(new_ticket)
|
| 491 |
save_expert_tickets(tickets)
|
| 492 |
h_info, c_info = format_ticket_detail(new_ticket)
|
| 493 |
+
return "📩 Đã gửi câu hỏi đến Hộp thư chờ Chuyên gia! Chuyên gia sẽ sớm xem xét và trả lời.", h_info + "<br><hr style='border: 1px solid #d4deda; margin: 12px 0;'><br>" + c_info, saved_img_path
|
| 494 |
|
| 495 |
def go_to_history_panel():
|
| 496 |
global current_user_role
|
|
|
|
| 653 |
save_chat_log(user_message, ai_reply)
|
| 654 |
return "", history
|
| 655 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 656 |
custom_css = """
|
| 657 |
+
.gradio-container {
|
| 658 |
+
background: linear-gradient(180deg, #eff5f3 0%, #e1ebe7 100%) !important;
|
| 659 |
+
font-family: 'Inter', system-ui, sans-serif !important;
|
| 660 |
+
}
|
| 661 |
+
#login_wrapper { padding: 60px 0 !important; display: flex !important; justify-content: center !important; }
|
| 662 |
+
.login-card {
|
| 663 |
+
background: #ffffff !important; border-radius: 24px !important; padding: 45px 40px !important;
|
| 664 |
+
box-shadow: 0 20px 45px rgba(0, 60, 40, 0.06) !important; border: 1px solid rgba(0, 129, 112, 0.1) !important;
|
| 665 |
+
}
|
| 666 |
+
.logo-container { display: flex; justify-content: center; align-items: center; margin-bottom: 25px; position: relative; height: 70px; gap: 12px; }
|
| 667 |
+
|
| 668 |
+
/* CẤU HÌNH LOGO BÔNG LÚA ĐỨNG IM VÀ HƯỚNG RA NGOÀI */
|
| 669 |
+
.rice-icon-left, .rice-icon-right {
|
| 670 |
+
font-size: 38px;
|
| 671 |
+
line-height: 1;
|
| 672 |
+
display: inline-block;
|
| 673 |
+
filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
|
| 674 |
+
}
|
| 675 |
+
.rice-icon-left {
|
| 676 |
+
transform: scaleX(-1);
|
| 677 |
+
}
|
| 678 |
+
.rice-icon-right {
|
| 679 |
+
transform: scaleX(1);
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
.medical-cross-css {
|
| 683 |
+
width: 46px; height: 46px; background: #007965; position: relative; border-radius: 10px; z-index: 2;
|
| 684 |
+
box-shadow: 0 4px 12px rgba(0, 121, 101, 0.25); animation: pulseGlow 2.5s infinite ease-in-out;
|
| 685 |
+
}
|
| 686 |
+
.medical-cross-css::before, .medical-cross-css::after { content: ""; position: absolute; background: white; border-radius: 2px; }
|
| 687 |
+
.medical-cross-css::before { top: 19px; left: 9px; width: 28px; height: 8px; }
|
| 688 |
+
.medical-cross-css::after { top: 9px; left: 19px; width: 8px; height: 28px; }
|
| 689 |
+
.main-title-layout { display: flex; align-items: center; justify-content: center; gap: 15px; margin: 0 auto; width: fit-content; }
|
| 690 |
+
.medical-cross-red {
|
| 691 |
+
width: 42px; height: 42px; background: #e74c3c; position: relative; border-radius: 8px; flex-shrink: 0;
|
| 692 |
+
box-shadow: 0 4px 12px rgba(231, 76, 60, 0.35); display: inline-block; vertical-align: middle;
|
| 693 |
+
animation: pulseGlow 2.5s infinite ease-in-out;
|
| 694 |
+
}
|
| 695 |
+
.medical-cross-red::before, .medical-cross-red::after { content: ""; position: absolute; background: white; border-radius: 2px; }
|
| 696 |
+
.medical-cross-red::before { top: 17px; left: 8px; width: 26px; height: 8px; }
|
| 697 |
+
.medical-cross-red::after { top: 8px; left: 17px; width: 8px; height: 26px; }
|
| 698 |
+
.app-main-title { color: #004b39 !important; font-weight: 800 !important; font-size: 28px !important; text-align: center !important; margin: 0 0 8px 0 !important; }
|
| 699 |
+
.app-sub-title { color: #557067 !important; font-size: 14px !important; text-align: center !important; margin: 0 0 30px 0 !important; font-weight: 500 !important; }
|
| 700 |
+
.hospital-header-center { text-align: center !important; width: 100%; }
|
| 701 |
+
.hospital-header-center .title-wrapper-h1 { display: inline-flex; align-items: center; justify-content: center; gap: 16px; text-align: center; margin: 0 auto; }
|
| 702 |
+
.hospital-header-center h1 { text-align: center !important; color: white !important; font-weight: 800 !important; font-size: 28px !important; margin: 0 !important; display: inline-block; }
|
| 703 |
+
.hospital-header-center p { text-align: center !important; margin: 8px auto 0 auto !important; color: #b2dfdb !important; font-size: 14px !important; }
|
| 704 |
+
.scan-btn {
|
| 705 |
+
background: linear-gradient(135deg, #007965, #00bfa5) !important; color: white !important; font-weight: 700 !important;
|
| 706 |
+
border: none !important; border-radius: 12px !important; box-shadow: 0 5px 15px rgba(0, 121, 101, 0.2) !important; height: 48px; cursor: pointer;
|
| 707 |
+
transition: all 0.25s ease !important;
|
| 708 |
+
}
|
| 709 |
+
.scan-btn:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0, 191, 165, 0.35) !important; }
|
| 710 |
+
|
| 711 |
+
/* CSS MỚI NỔI BẬT NÚT GỬI YÊU CẦU CHO CHUYÊN GIA */
|
| 712 |
+
.expert-send-btn {
|
| 713 |
+
background: linear-gradient(135deg, #d35400 0%, #e67e22 50%, #e74c3c 100%) !important;
|
| 714 |
+
color: white !important;
|
| 715 |
+
font-weight: 800 !important;
|
| 716 |
+
font-size: 15px !important;
|
| 717 |
+
border: none !important;
|
| 718 |
+
border-radius: 12px !important;
|
| 719 |
+
height: 48px !important;
|
| 720 |
+
cursor: pointer !important;
|
| 721 |
+
box-shadow: 0 6px 18px rgba(211, 84, 0, 0.4) !important;
|
| 722 |
+
transition: all 0.25s ease !important;
|
| 723 |
+
margin-top: 10px !important;
|
| 724 |
+
}
|
| 725 |
+
.expert-send-btn:hover {
|
| 726 |
+
filter: brightness(1.1) !important;
|
| 727 |
+
transform: translateY(-2px) !important;
|
| 728 |
+
box-shadow: 0 8px 24px rgba(230, 126, 34, 0.55) !important;
|
| 729 |
+
}
|
| 730 |
+
|
| 731 |
+
.inline-history-btn {
|
| 732 |
+
background: #ffffff !important; color: #007965 !important; border: 1.5px solid #007965 !important;
|
| 733 |
+
font-weight: 700 !important; border-radius: 8px !important; padding: 0px 14px !important;
|
| 734 |
+
height: 32px !important; font-size: 13px !important; cursor: pointer; transition: all 0.2s ease !important;
|
| 735 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important; display: inline-flex !important; align-items: center; justify-content: center;
|
| 736 |
+
}
|
| 737 |
+
.inline-history-btn:hover { background: #007965 !important; color: #ffffff !important; box-shadow: 0 4px 10px rgba(0,121,101,0.15) !important; }
|
| 738 |
+
|
| 739 |
+
/* TÙY CHỈNH NÚT ĐĂNG XUẤT CHO RỘNG RÃI TRỌN CHỮ */
|
| 740 |
+
.logout-btn-style {
|
| 741 |
+
background: linear-gradient(135deg, #e74c3c, #c0392b) !important; color: white !important; font-weight: 700 !important;
|
| 742 |
+
border: none !important; border-radius: 10px !important; cursor: pointer; height: 45px !important; min-width: 210px !important; padding: 0 18px !important;
|
| 743 |
+
font-size: 14px !important;
|
| 744 |
+
box-shadow: 0 4px 10px rgba(231, 76, 60, 0.2) !important; transition: all 0.2s ease !important; margin-top: 5px;
|
| 745 |
+
display: flex !important; align-items: center !important; justify-content: center !important; white-space: nowrap !important;
|
| 746 |
+
}
|
| 747 |
+
.logout-btn-style:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 5px 15px rgba(192, 57, 43, 0.4) !important; }
|
| 748 |
+
|
| 749 |
+
/* CĂN CHỈNH BẰNG CAO HOÀN TOÀN VỚI KHUNG TRẮNG CỦA DROPDOWN (BAO GỒM CẢ LABEL TRÊN) */
|
| 750 |
+
.delete-btn-style {
|
| 751 |
+
background: linear-gradient(135deg, #e74c3c, #c0392b) !important;
|
| 752 |
+
color: white !important;
|
| 753 |
+
font-weight: 700 !important;
|
| 754 |
+
font-size: 14px !important;
|
| 755 |
+
border: 1.5px solid #a93226 !important;
|
| 756 |
+
border-radius: 10px !important;
|
| 757 |
+
cursor: pointer !important;
|
| 758 |
+
height: 100% !important;
|
| 759 |
+
min-height: 82px !important;
|
| 760 |
+
margin: 0 !important;
|
| 761 |
+
box-shadow: 0 4px 12px rgba(231, 76, 60, 0.25) !important;
|
| 762 |
+
transition: all 0.25s ease !important;
|
| 763 |
+
display: flex !important;
|
| 764 |
+
align-items: center !important;
|
| 765 |
+
justify-content: center !important;
|
| 766 |
+
}
|
| 767 |
+
.delete-btn-style:hover {
|
| 768 |
+
filter: brightness(1.1) !important;
|
| 769 |
+
transform: translateY(-1px) !important;
|
| 770 |
+
box-shadow: 0 6px 18px rgba(192, 57, 43, 0.4) !important;
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
.history-back-btn-style {
|
| 774 |
+
background: linear-gradient(135deg, #f39c12, #d35400) !important; color: white !important; font-weight: 700 !important;
|
| 775 |
+
border: none !important; border-radius: 12px !important; cursor: pointer; height: 48px !important;
|
| 776 |
+
box-shadow: 0 5px 15px rgba(243, 156, 18, 0.3) !important; transition: all 0.25s ease !important;
|
| 777 |
+
}
|
| 778 |
+
.history-back-btn-style:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(211, 84, 0, 0.45) !important; }
|
| 779 |
+
.hospital-header { background: linear-gradient(135deg, #004b39 0%, #007965 60%, #00bfa5 100%); color: white; padding: 25px; border-radius: 20px; margin-bottom: 15px; }
|
| 780 |
+
.gr-group {
|
| 781 |
+
border: 1px solid #d4deda !important;
|
| 782 |
+
background: #ffffff !important;
|
| 783 |
+
border-radius: 16px !important;
|
| 784 |
+
margin-bottom: 12px !important;
|
| 785 |
+
}
|
| 786 |
+
#prescription_col .textbox_custom {
|
| 787 |
+
border-left: 6px solid #007965 !important;
|
| 788 |
+
background-color: #f7faf9 !important;
|
| 789 |
+
border-radius: 12px !important;
|
| 790 |
+
}
|
| 791 |
+
#chatbot_col {
|
| 792 |
+
background: #ffffff !important;
|
| 793 |
+
border: 1px solid #d4deda !important;
|
| 794 |
+
border-radius: 16px !important;
|
| 795 |
+
padding: 15px !important;
|
| 796 |
+
margin-top: 10px !important;
|
| 797 |
+
}
|
| 798 |
+
#chatbot_col .chatbot_custom {
|
| 799 |
+
border-left: 6px solid #3498db !important;
|
| 800 |
+
background-color: #f2f7fa !important;
|
| 801 |
+
border-radius: 12px !important;
|
| 802 |
+
}
|
| 803 |
+
.chatbot-title-container { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 8px; }
|
| 804 |
+
.footer-text { text-align: center; margin-top: 25px; color: #728681; font-size: 13px; font-weight: 500; }
|
| 805 |
+
@keyframes pulseGlow {
|
| 806 |
+
0%, 100% { transform: scale(1); filter: drop-shadow(0 2px 5px rgba(0,129,112,0.2)); }
|
| 807 |
+
50% { transform: scale(1.04); filter: drop-shadow(0 4px 12px rgba(0,191,165,0.4)); }
|
| 808 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 809 |
"""
|
| 810 |
|
| 811 |
initial_ticket_text, initial_ticket_img = check_user_expert_status()
|
| 812 |
|
| 813 |
+
with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI", css=custom_css) as demo:
|
| 814 |
with gr.Row(visible=True, elem_id="login_wrapper") as login_panel:
|
| 815 |
+
with gr.Column(scale=1): pass
|
| 816 |
+
with gr.Column(scale=1, elem_classes="login-card"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 817 |
gr.HTML("""
|
| 818 |
+
<div class="logo-container">
|
| 819 |
+
<span class="rice-icon-left">🌾</span>
|
| 820 |
+
<div class="medical-cross-css"></div>
|
| 821 |
+
<span class="rice-icon-right">🌾</span>
|
| 822 |
</div>
|
| 823 |
+
<h1 class="app-main-title">BỆNH VIỆN CÂY TRỒNG</h1>
|
| 824 |
+
<p class="app-sub-title">Cổng kết nối Trợ lý Bác sĩ AI xét nghiệm tế bào lá</p>
|
| 825 |
""")
|
| 826 |
+
username_input = gr.Textbox(label="Tên đăng nhập / Tài khoản", placeholder="Nhập tài khoản đăng nhập...", max_lines=1)
|
| 827 |
+
password_input = gr.Textbox(label="Mật khẩu bảo mật", type="password", placeholder="Nhập mật khẩu...", max_lines=1)
|
| 828 |
+
error_output = gr.HTML("")
|
| 829 |
+
btn_login = gr.Button("KÍCH HOẠT HỆ THỐNG XÉT NGHIỆM", variant="primary", elem_classes="scan-btn")
|
| 830 |
+
with gr.Column(scale=1): pass
|
| 831 |
|
| 832 |
with gr.Column(visible=False) as main_panel:
|
| 833 |
with gr.Row(elem_classes="hospital-header"):
|
| 834 |
with gr.Column(scale=10, elem_classes="hospital-header-center"):
|
| 835 |
+
gr.HTML("""
|
| 836 |
+
<div class="title-wrapper-h1">
|
| 837 |
+
<div class="medical-cross-red"></div>
|
| 838 |
+
<h1>TRUNG TÂM CHẨN ĐOÁN & ĐIỀU TRỊ BỆNH CÂY TRỒNG CÔNG NGHỆ CAO</h1>
|
| 839 |
+
</div>
|
| 840 |
+
<p>Hệ thống tự động phân tích thị giác học sâu v8, phát hiện mầm bệnh thực vật và kết xuất phác đồ điều trị thời gian thực</p>
|
| 841 |
+
""")
|
| 842 |
+
with gr.Column(scale=2, min_width=210):
|
| 843 |
with gr.Row():
|
| 844 |
+
btn_logout = gr.Button("🚪 ĐĂNG XUẤT HỆ THỐNG", elem_classes="logout-btn-style")
|
| 845 |
with gr.Row():
|
| 846 |
with gr.Column(scale=10):
|
| 847 |
with gr.Group(elem_classes="gr-group"):
|
| 848 |
+
gr.Markdown("<p style='color: #004b39; font-weight: 700; margin: 8px 10px; font-size: 15px;'>🗂️ 1. TIẾP NHẬN MẪU XÉT NGHIỆM</p>")
|
| 849 |
plant_dropdown = gr.Dropdown(
|
| 850 |
choices=["Cây lúa", "Cây ớt", "Cây cà chua", "Cây dâu tây", "Cây cà phê", "Cây ngô (Bắp)"],
|
| 851 |
value="Cây cà chua", label="Lựa chọn phân khoa điều trị thực vật" )
|
| 852 |
with gr.Group(elem_classes="gr-group"):
|
| 853 |
image_input = gr.Image(type="numpy", label="Ảnh quét tế bào bề mặt lá", height=370)
|
| 854 |
gr.HTML("<div style='padding: 0 10px 10px 10px;'>")
|
| 855 |
+
btn_analyze = gr.Button("🩺 TIẾN HÀNH QUÉT & CHẨN ĐOÁN LÂM SÀNG", variant="primary", elem_classes="scan-btn")
|
| 856 |
gr.HTML("</div>")
|
| 857 |
with gr.Column(scale=11, elem_id="prescription_col"):
|
| 858 |
with gr.Group(elem_classes="gr-group"):
|
| 859 |
+
gr.Markdown("<p style='color: #004b39; font-weight: 700; margin: 8px 10px; font-size: 15px;'>🔬 2. KẾT QUẢ QUÉT THỊ GIÁC HỌC SÂU (AI DETECT)</p>")
|
| 860 |
+
image_output = gr.Image(type="numpy", label="Bản đồ nội soi vi vị trí: Khoanh vùng khu trú ổ bệnh", height=370)
|
| 861 |
+
gr.Markdown("<p style='color: #004b39; font-weight: 700; margin: 8px 10px 4px 10px; font-size: 15px;'>📄 3. ĐƠN THUỐC LÂM SÀNG SƠ BỘ</p>")
|
| 862 |
text_output = gr.Textbox(
|
| 863 |
label="Hồ sơ bệnh án điện tử xuất từ thuật toán",
|
| 864 |
lines=5,
|
| 865 |
placeholder="Hồ sơ bệnh án sơ bộ sẽ tự động xuất ra tại đây...",
|
| 866 |
+
elem_classes="textbox_custom" )
|
| 867 |
|
| 868 |
with gr.Column(scale=12, elem_id="chatbot_col"):
|
| 869 |
with gr.Row(elem_classes="chatbot-title-container"):
|
| 870 |
+
gr.Markdown("<p style='color: #2980b9; font-weight: 700; margin: 0; font-size: 16px; display: inline-block;'>💬 4. HỘI ĐỒNG TƯ VẤN THUỐC BẢO VỆ THỰC VẬT (CHATBOT AI)</p>")
|
| 871 |
+
btn_history_nav = gr.Button("📂 Xem Lại Lịch Sử Bệnh Án", elem_classes="inline-history-btn")
|
| 872 |
chatbot = gr.Chatbot(
|
| 873 |
value=[{"role": "assistant", "content": "🤖 Hệ thống đang đợi mẫu quét. Sau khi phân tích xong ảnh lá, tôi sẽ tự động nắm thông tin bệnh lý để kê đơn thuốc chính xác cho bà con!"}],
|
| 874 |
height=550,
|
|
|
|
| 881 |
btn_send = gr.Button("GỬI AI", scale=1, variant="primary", elem_classes="scan-btn")
|
| 882 |
|
| 883 |
with gr.Group(elem_classes="gr-group", visible=True) as user_expert_section:
|
| 884 |
+
gr.Markdown("<p style='color: #d35400; font-weight: 700; margin: 8px 10px; font-size: 15px;'>👨⚕️ HỖ TRỢ TƯ VẤN TỪ CHUYÊN GIA</p>")
|
| 885 |
+
gr.Markdown("<p style='font-size: 13px; color: #555; margin: 0 10px;'>Nghi ngờ AI đoán sai hoặc muốn hỏi chi tiết cách điều trị? Gửi câu hỏi tại đây, chỉ Chuyên gia mới xem và trả lời trực tiếp cho bạn!</p>")
|
| 886 |
expert_user_query = gr.Textbox(label="Thắc mắc về tình trạng lá cây / nghi ngờ bệnh:", placeholder="Ví dụ: AI đoán cháy bìa lá nhưng tui nghi là đốm vằn, nhờ chuyên gia xem kỹ lại...", lines=2)
|
| 887 |
+
btn_send_expert = gr.Button("📩 GỬI YÊU CẦU CHO CHUYÊN GIA (HỘP THƯ CHỜ)", elem_classes="expert-send-btn")
|
| 888 |
expert_status_box = gr.HTML(value=initial_ticket_text)
|
| 889 |
expert_ticket_img_view = gr.Image(value=initial_ticket_img, label="Ảnh mẫu lá bệnh do nhà nông gửi lên", height=250, interactive=False)
|
| 890 |
|
| 891 |
+
gr.HTML("<div class='footer-text'>🔏 Hệ thống lõi được bảo mật bởi AI Doctor Lab © 2026 | Nền tảng Phân tích Công nghệ cao Học máy Ultralytics YOLOv8 & Google Gemini AI</div>")
|
| 892 |
|
| 893 |
with gr.Column(visible=False) as history_panel:
|
| 894 |
with gr.Row(elem_classes="hospital-header"):
|
| 895 |
with gr.Column(scale=10):
|
| 896 |
gr.HTML("""
|
| 897 |
+
<h1 style='text-align: left;'>📜 KHO LƯU TRỮ HỒ SƠ & LỊCH SỬ HỆ THỐNG</h1>
|
| 898 |
+
<p style='text-align: left;'>Xem lại toàn bộ nhật ký quét mô bệnh học thực vật, lịch sử hội thoại và Quản lý Hàng chờ Chuyên gia</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 899 |
""")
|
| 900 |
with gr.Column(scale=2, min_width=150):
|
| 901 |
+
btn_back_to_clinic = gr.Button("⬅️ QUAY LẠI PHÒNG KHÁM", elem_classes="history-back-btn-style")
|
| 902 |
|
| 903 |
with gr.Row():
|
| 904 |
with gr.Column(visible=True) as user_diagnose_col:
|
| 905 |
+
gr.Markdown("### ⏳ Nhật Ký Chẩn Đoán Ảnh:")
|
| 906 |
history_diagnose_box = gr.Textbox(
|
| 907 |
value=load_diagnose_history(),
|
| 908 |
label="Lịch sử các ca bệnh đã quét",
|
| 909 |
lines=15,
|
| 910 |
interactive=False )
|
| 911 |
+
btn_clear_diagnose = gr.Button("🗑️ XÓA NHẬT KÝ CHẤN ĐOÁN", variant="stop")
|
| 912 |
with gr.Column(visible=True) as user_chat_col:
|
| 913 |
+
gr.Markdown("### 💬 Nhật Ký Hội Thoại Với AI:")
|
| 914 |
history_chat_box = gr.Textbox(
|
| 915 |
value=load_chat_history(),
|
| 916 |
label="Lịch sử chat kê đơn thuốc",
|
| 917 |
lines=15,
|
| 918 |
interactive=False
|
| 919 |
)
|
| 920 |
+
btn_clear_chat = gr.Button("🗑️ XÓA NHẬT KÝ CHAT", variant="stop")
|
| 921 |
+
|
| 922 |
+
gr.HTML("<hr style='margin: 25px 0; border: 1px solid #d4deda;'>")
|
| 923 |
|
|
|
|
|
|
|
| 924 |
with gr.Group(elem_classes="gr-group"):
|
| 925 |
+
gr.Markdown("<h3 style='color: #004b39; font-weight: 800; margin: 10px 12px; font-size: 18px;'>👨⚕️ HỘP THƯ TƯ VẤN CHUYÊN GIA (LỊCH SỬ HỎI ĐÁP)</h3>")
|
| 926 |
|
| 927 |
with gr.Row(elem_id="expert_select_row"):
|
| 928 |
admin_ticket_select = gr.Dropdown(label="Danh sách các câu hỏi hỗ trợ:", choices=[], value=None, scale=8)
|
| 929 |
+
btn_delete_ticket = gr.Button("🗑️ XÓA CÂU HỎI / HỘI THOẠI NÀY", elem_classes="delete-btn-style", scale=2)
|
| 930 |
|
| 931 |
with gr.Row():
|
| 932 |
with gr.Column(scale=1):
|
| 933 |
admin_ticket_detail = gr.HTML(value="Hiện chưa có yêu cầu hỗ trợ nào.")
|
| 934 |
with gr.Column(scale=1):
|
| 935 |
+
admin_ticket_img_display = gr.Image(label="📷 Mẫu lá bệnh do nhà nông gửi lên:", height=300, interactive=False)
|
| 936 |
|
| 937 |
with gr.Row():
|
| 938 |
admin_ticket_conversation = gr.HTML(value="", elem_id="full_width_conversation")
|
| 939 |
|
| 940 |
with gr.Row():
|
| 941 |
with gr.Column(scale=1, visible=False) as admin_control_panel:
|
| 942 |
+
gr.Markdown("<hr style='margin: 15px 0; border: 1px dashed #007965;'>")
|
| 943 |
+
gr.Markdown("<p style='font-weight: 700; color: #007965; font-size: 16px;'>✍️ GỬI PHẢN HỒI BỆNH ÁN TỪ CHUYÊN GIA:</p>")
|
| 944 |
+
admin_reply_input = gr.Textbox(label="Nhập phản hồi chuyên gia / Phác đồ điều trị chuẩn:", placeholder="Gõ câu trả lời của Admin/Chuyên gia tại đây...", lines=4)
|
| 945 |
+
btn_submit_admin_reply = gr.Button("🚀 GỬI CÂU TRẢ LỜI CHO NHÀ NÔNG", variant="primary", elem_classes="scan-btn")
|
| 946 |
admin_reply_status = gr.Markdown("")
|
| 947 |
|
| 948 |
with gr.Group(visible=True) as user_followup_panel:
|
| 949 |
+
gr.Markdown("<hr style='margin: 15px 0; border: 1px dashed #27ae60;'>")
|
| 950 |
+
gr.Markdown("<p style='font-weight: 700; color: #27ae60; font-size: 16px; margin-bottom: 4px;'>💬 BẠN VẪN CHƯA RÕ VỀ BỆNH ÁN TRÊN? HỎI TIẾP CHUYÊN GIA VỀ VẤN ĐỀ NÀY:</p>")
|
| 951 |
+
user_followup_input = gr.Textbox(label="Nội dung câu hỏi thêm:", placeholder="Ví dụ: Cảm ơn chuyên gia, nhưng cho tôi hỏi thêm là phun thuốc này vào buổi sáng hay chiều thì tốt hơn...", lines=2)
|
| 952 |
+
btn_send_followup = gr.Button("💬 GỬI CÂU HỎI TIẾP TỤC CHO CHUYÊN GIA", variant="primary")
|
| 953 |
|
| 954 |
btn_login.click(
|
| 955 |
login_auth,
|