Kietcudo commited on
Commit
1b6bedb
·
verified ·
1 Parent(s): 906fc69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +300 -28
app.py CHANGED
@@ -1248,10 +1248,21 @@ body.leaf-on footer { display: none !important; }
1248
  width: 27rem !important; max-width: 80vw !important; margin: 0 !important; padding: 0 !important;
1249
  box-sizing: border-box !important;
1250
  display: flex !important; flex-direction: column !important; justify-content: center !important; gap: 10px !important;
 
 
 
 
 
 
1251
  overflow-y: auto !important;
1252
  background: transparent !important; border: none !important; box-shadow: none !important;
1253
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
1254
  }
 
 
 
 
 
1255
  /* Khối sát nhau: bỏ margin thừa của Gradio, thu gọn ô lỗi rỗng */
1256
  #login_wrapper .block, #login_wrapper .form { margin: 0 !important; }
1257
  #login_error { margin: 0 !important; min-height: 0 !important; padding: 0 !important; }
@@ -1320,6 +1331,267 @@ body.leaf-on footer { display: none !important; }
1320
  display: flex; align-items: center; gap: 10px;
1321
  }
1322
  /* =================== END LEAF HERO LOGIN =================== */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1323
  """
1324
 
1325
  initial_ticket_text, initial_ticket_img = check_user_expert_status()
@@ -1362,24 +1634,24 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
1362
  """)
1363
  with gr.Column(scale=2, min_width=210):
1364
  with gr.Row():
1365
- btn_logout = gr.Button("🚪 ĐĂNG XUẤT HỆ THỐNG", elem_classes="logout-btn-style")
1366
  with gr.Row():
1367
  with gr.Column(scale=10):
1368
  with gr.Group(elem_classes="gr-group"):
1369
- 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>")
1370
  plant_dropdown = gr.Dropdown(
1371
- 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)"],
1372
  value="Cây cà chua", label="Lựa chọn phân khoa điều trị thực vật" )
1373
  with gr.Group(elem_classes="gr-group"):
1374
- image_input = gr.Image(type="numpy", label="Ảnh quét tế bào bề mặt lá", height=370)
1375
  gr.HTML("<div style='padding: 0 10px 10px 10px;'>")
1376
- btn_analyze = gr.Button("🩺 TIẾN HÀNH QUÉT & CHẨN ĐOÁN LÂM SÀNG", variant="primary", elem_classes="scan-btn")
1377
  gr.HTML("</div>")
1378
  with gr.Column(scale=11, elem_id="prescription_col"):
1379
  with gr.Group(elem_classes="gr-group"):
1380
- 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>")
1381
- image_output = gr.Image(type="numpy", label="Bản đồ nội soi vi vị trí: Khoanh vùng khu trú ổ bệnh", height=370)
1382
- 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>")
1383
  text_output = gr.Textbox(
1384
  label="Hồ sơ bệnh án điện tử xuất từ thuật toán",
1385
  lines=5,
@@ -1388,13 +1660,13 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
1388
 
1389
  with gr.Column(scale=12, elem_id="chatbot_col"):
1390
  with gr.Row(elem_classes="chatbot-title-container"):
1391
- 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>")
1392
- btn_history_nav = gr.Button("📂 Xem Lại Lịch Sử Bệnh Án", elem_classes="inline-history-btn")
1393
  chatbot = gr.Chatbot(
1394
  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!"}],
1395
  height=550,
1396
  label="Trò chuyện trực tiếp với Chuyên gia Bảo vệ Thực vật AI",
1397
- elem_classes="chatbot_custom" )
1398
  with gr.Row(elem_id="chat_input_row"):
1399
  chat_msg = gr.Textbox(
1400
  placeholder="Hỏi chuyên gia về cách chữa trị, tên thuốc, liều lượng phun bón cho loại bệnh vừa quét...",
@@ -1402,58 +1674,58 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
1402
  btn_send = gr.Button("GỬI AI", scale=1, variant="primary", elem_classes="scan-btn")
1403
 
1404
  with gr.Group(elem_classes="gr-group", visible=True) as user_expert_section:
1405
- 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>")
1406
- 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>")
1407
  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)
1408
- btn_send_expert = gr.Button("📩 GỬI YÊU CẦU CHO CHUYÊN GIA (HỘP THƯ CHỜ)", elem_classes="expert-send-btn")
1409
  expert_status_box = gr.HTML(value=initial_ticket_text)
1410
  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)
1411
 
1412
- 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>")
1413
 
1414
  with gr.Column(visible=False) as history_panel:
1415
  with gr.Row(elem_classes="hospital-header"):
1416
  with gr.Column(scale=10):
1417
  gr.HTML("""
1418
- <h1 style='text-align: left;'>📜 KHO LƯU TRỮ HỒ SƠ & LỊCH SỬ HỆ THỐNG</h1>
1419
  <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>
1420
  """)
1421
  with gr.Column(scale=2, min_width=150):
1422
- btn_back_to_clinic = gr.Button("⬅️ QUAY LẠI PHÒNG KHÁM", elem_classes="history-back-btn-style")
1423
 
1424
  with gr.Row():
1425
  with gr.Column(visible=True) as user_diagnose_col:
1426
- gr.Markdown("### ⏳ Nhật Ký Chẩn Đoán Ảnh:")
1427
  history_diagnose_box = gr.Textbox(
1428
  value=load_diagnose_history(),
1429
  label="Lịch sử các ca bệnh đã quét",
1430
  lines=15,
1431
  interactive=False )
1432
- btn_clear_diagnose = gr.Button("🗑️ XÓA NHẬT KÝ CHẤN ĐOÁN", variant="stop")
1433
  with gr.Column(visible=True) as user_chat_col:
1434
- gr.Markdown("### 💬 Nhật Ký Hội Thoại Với AI:")
1435
  history_chat_box = gr.Textbox(
1436
  value=load_chat_history(),
1437
  label="Lịch sử chat kê đơn thuốc",
1438
  lines=15,
1439
  interactive=False
1440
  )
1441
- btn_clear_chat = gr.Button("🗑️ XÓA NHẬT KÝ CHAT", variant="stop")
1442
 
1443
  gr.HTML("<hr style='margin: 25px 0; border: 1px solid #d4deda;'>")
1444
 
1445
  with gr.Group(elem_classes="gr-group"):
1446
- 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>")
1447
 
1448
  with gr.Row(elem_id="expert_select_row"):
1449
  admin_ticket_select = gr.Dropdown(label="Danh sách các câu hỏi hỗ trợ:", choices=[], value=None, scale=8)
1450
- btn_delete_ticket = gr.Button("🗑️ XÓA CÂU HỎI / HỘI THOẠI NÀY", elem_classes="delete-btn-style", scale=2)
1451
 
1452
  with gr.Row():
1453
  with gr.Column(scale=1):
1454
  admin_ticket_detail = gr.HTML(value="Hiện chưa có yêu cầu hỗ trợ nào.")
1455
  with gr.Column(scale=1):
1456
- admin_ticket_img_display = gr.Image(label="📷 Mẫu lá bệnh do nhà nông gửi lên:", height=300, interactive=False)
1457
 
1458
  with gr.Row():
1459
  admin_ticket_conversation = gr.HTML(value="", elem_id="full_width_conversation")
@@ -1461,16 +1733,16 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
1461
  with gr.Row():
1462
  with gr.Column(scale=1, visible=False) as admin_control_panel:
1463
  gr.Markdown("<hr style='margin: 15px 0; border: 1px dashed #007965;'>")
1464
- 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>")
1465
  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)
1466
- btn_submit_admin_reply = gr.Button("🚀 GỬI CÂU TRẢ LỜI CHO NHÀ NÔNG", variant="primary", elem_classes="scan-btn")
1467
  admin_reply_status = gr.Markdown("")
1468
 
1469
  with gr.Group(visible=True) as user_followup_panel:
1470
  gr.Markdown("<hr style='margin: 15px 0; border: 1px dashed #27ae60;'>")
1471
- 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>")
1472
  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)
1473
- btn_send_followup = gr.Button("💬 GỬI CÂU HỎI TIẾP TỤC CHO CHUYÊN GIA", variant="primary")
1474
 
1475
  btn_login.click(
1476
  login_auth,
 
1248
  width: 27rem !important; max-width: 80vw !important; margin: 0 !important; padding: 0 !important;
1249
  box-sizing: border-box !important;
1250
  display: flex !important; flex-direction: column !important; justify-content: center !important; gap: 10px !important;
1251
+ /* Gradio đặt flex-wrap:wrap cho div cột; cột này lại cao cứng 100vh nên khi màn hình thấp,
1252
+ phần tràn không chảy xuống mà nhảy sang CỘT MỚI bên phải (khối demo bay ra ngoài).
1253
+ nowrap chặn hẳn việc đó; safe center để nội dung cao hơn khung thì tràn xuống dưới
1254
+ và cuộn được, thay vì tràn ngược lên trên rồi mất phần đầu. */
1255
+ flex-wrap: nowrap !important;
1256
+ justify-content: safe center !important;
1257
  overflow-y: auto !important;
1258
  background: transparent !important; border: none !important; box-shadow: none !important;
1259
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
1260
  }
1261
+ /* Khoá co các khối con: mặc định flex cho phép shrink, mà .form (bọc 2 ô nhập) lại
1262
+ có overflow-y:hidden nên khi màn hình thấp nó bẹp xuống ~34px và NUỐT MẤT ô nhập.
1263
+ Chặn shrink để nội dung giữ nguyên chiều cao rồi tràn ra, khi đó overflow-y:auto
1264
+ ở khối cha mới sinh thanh cuộn thật cho người dùng kéo. */
1265
+ #login_content_col > * { flex-shrink: 0 !important; }
1266
  /* Khối sát nhau: bỏ margin thừa của Gradio, thu gọn ô lỗi rỗng */
1267
  #login_wrapper .block, #login_wrapper .form { margin: 0 !important; }
1268
  #login_error { margin: 0 !important; min-height: 0 !important; padding: 0 !important; }
 
1331
  display: flex; align-items: center; gap: 10px;
1332
  }
1333
  /* =================== END LEAF HERO LOGIN =================== */
1334
+
1335
+ /* ============ ĐỒNG BỘ MÀN LÀM VIỆC VỚI MÀN ĐĂNG NHẬP (leaf v4) ============
1336
+ Khối này đặt CUỐI custom_css để ghi đè các rule cũ phía trên mà không phải xoá
1337
+ chúng đi — dễ đối chiếu và lùi lại nếu cần. Không đụng tới #login_wrapper. */
1338
+ :root {
1339
+ --lf-bg1:#eef8e1; --lf-bg2:#e3f2d0;
1340
+ --lf-ink:#16281a; --lf-ink2:#3d5233; --lf-muted:#5f7255;
1341
+ --lf-em:#10b981; --lf-em-d:#047857; --lf-em-dd:#065f46;
1342
+ --lf-card:rgba(255,255,255,0.74);
1343
+ --lf-bd:rgba(90,110,70,0.22);
1344
+ --lf-r:16px;
1345
+ --lf-amber:#d97706;
1346
+ --lf-danger:#dc2626;
1347
+ --lf-leaves:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='820' height='820' viewBox='0 0 820 820'><g fill='%232f8b1c' fill-opacity='0.055'><g transform='translate(70,60) rotate(18)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(300,150) rotate(-35) scale(1.3)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(620,80) rotate(52)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(150,380) rotate(-12) scale(0.85)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(470,430) rotate(70) scale(1.15)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(740,330) rotate(-48)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(60,640) rotate(40) scale(1.25)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(360,690) rotate(-62)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(660,620) rotate(15) scale(0.9)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g></g></svg>");
1348
+ }
1349
+
1350
+ /* --- Nền: cùng tông xanh lá với màn đăng nhập + lá TĨNH rất mờ (không animation) --- */
1351
+ .gradio-container {
1352
+ /* Dung LONGHAND, khong dung shorthand + var(): neu var() thay the ra gia tri khong
1353
+ hop le thi CA shorthand background bi vut ve initial (nen thanh trong suot).
1354
+ Tach longhand ra thi mau nen van con du anh la co loi. */
1355
+ background-color: #eef8e1 !important;
1356
+ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='820' height='820' viewBox='0 0 820 820'><g fill='%232f8b1c' fill-opacity='0.055'><g transform='translate(70,60) rotate(18)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(300,150) rotate(-35) scale(1.3)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(620,80) rotate(52)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(150,380) rotate(-12) scale(0.85)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(470,430) rotate(70) scale(1.15)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(740,330) rotate(-48)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(60,640) rotate(40) scale(1.25)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(360,690) rotate(-62)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g><g transform='translate(660,620) rotate(15) scale(0.9)'><path d='M0 0c20 13 24 44 0 66-24-22-20-53 0-66z'/></g></g></svg>"), linear-gradient(180deg, #eef8e1 0%, #e3f2d0 100%) !important;
1357
+ background-attachment: fixed, fixed !important;
1358
+ background-repeat: repeat, no-repeat !important;
1359
+ font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
1360
+ color: var(--lf-ink);
1361
+ }
1362
+ .gradio-container * {
1363
+ font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
1364
+ }
1365
+
1366
+ /* --- Thanh tiêu đề: bỏ dải teal đậm, đổi sang kính mờ sáng như màn đăng nhập --- */
1367
+ .hospital-header {
1368
+ background: linear-gradient(120deg, rgba(255,255,255,0.80), rgba(240,253,244,0.60)) !important;
1369
+ border: 1px solid var(--lf-bd) !important;
1370
+ border-radius: 20px !important;
1371
+ padding: 16px 20px !important;
1372
+ -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
1373
+ box-shadow: 0 12px 32px -22px rgba(6,95,70,0.45) !important;
1374
+ color: var(--lf-ink) !important;
1375
+ }
1376
+ .hospital-header-center h1 {
1377
+ color: var(--lf-ink) !important;
1378
+ font-size: clamp(17px, 1.9vw, 23px) !important;
1379
+ line-height: 1.2 !important; letter-spacing: -0.015em !important;
1380
+ }
1381
+ .hospital-header-center p { color: var(--lf-muted) !important; font-size: 13px !important; }
1382
+ .history_panel_head h1, #root .hospital-header h1 { color: var(--lf-ink) !important; }
1383
+ .hospital-header p { color: var(--lf-muted) !important; }
1384
+
1385
+ /* Chữ thập: ĐỎ -> XANH (đỏ từ nay chỉ dành cho cảnh báo bệnh) */
1386
+ .medical-cross-red, .medical-cross-css {
1387
+ background: radial-gradient(circle at 35% 30%, #8fcb5e, #2f8b1c) !important;
1388
+ border-radius: 13px !important;
1389
+ box-shadow: 0 8px 20px -8px rgba(45,122,18,0.65) !important;
1390
+ }
1391
+
1392
+ /* --- Thẻ nội dung: kính mờ trắng, bo tròn, viền xanh nhạt --- */
1393
+ .gr-group, #chatbot_col {
1394
+ background: var(--lf-card) !important;
1395
+ border: 1px solid var(--lf-bd) !important;
1396
+ border-radius: var(--lf-r) !important;
1397
+ -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
1398
+ box-shadow: 0 10px 28px -22px rgba(6,95,70,0.5) !important;
1399
+ }
1400
+
1401
+ /* Gradio lồng .gr-group trong .gr-group. Nếu cả hai cùng nhận nền kính + viền thì
1402
+ hai lớp mờ chồng nhau tạo dải xám đục ở mép. Chỉ giữ lớp NGOÀI cùng làm thẻ. */
1403
+ .gr-group .gr-group {
1404
+ background: transparent !important; border: none !important;
1405
+ box-shadow: none !important;
1406
+ -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
1407
+ }
1408
+
1409
+ /* Viền đứt nét của vùng kéo-thả ảnh: Gradio để màu đen, chọi hẳn với tông xanh.
1410
+ Đổi sang xanh nhạt cho hợp, vẫn giữ nét đứt để người dùng biết là chỗ thả ảnh. */
1411
+ .lf-img { border-color: rgba(16,185,129,0.45) !important; border-width: 2px !important; }
1412
+ .lf-img:hover { border-color: rgba(16,185,129,0.75) !important; }
1413
+
1414
+ /* --- Tiêu đề từng mục: icon SVG + số thứ tự --- */
1415
+ .sec-head {
1416
+ display: flex !important; align-items: center; gap: 9px;
1417
+ margin: 10px 12px !important; font-size: 15px !important; font-weight: 700 !important;
1418
+ color: var(--lf-em-dd) !important; letter-spacing: .005em;
1419
+ }
1420
+ .sec-head svg { width: 19px; height: 19px; flex: 0 0 19px; stroke: var(--lf-em-d); }
1421
+ .sec-head .sec-n {
1422
+ display: inline-grid; place-items: center; width: 20px; height: 20px; flex: 0 0 20px;
1423
+ border-radius: 7px; background: rgba(16,185,129,0.16); color: var(--lf-em-dd);
1424
+ font-size: 11px; font-weight: 800;
1425
+ }
1426
+ .sec-desc { font-size: 13px !important; color: var(--lf-muted) !important; margin: 0 12px 8px !important; }
1427
+
1428
+ /* --- Nút chính: emerald y hệt nút đăng nhập --- */
1429
+ .gradio-container .scan-btn {
1430
+ background: linear-gradient(135deg, var(--lf-em), var(--lf-em-d)) !important;
1431
+ color: #fff !important; border: none !important; border-radius: 14px !important;
1432
+ min-height: 48px !important; font-weight: 800 !important; letter-spacing: .05em !important;
1433
+ box-shadow: 0 14px 30px -16px rgba(5,150,105,0.8) !important;
1434
+ transition: transform .18s ease, box-shadow .18s ease, filter .18s ease !important;
1435
+ }
1436
+ .gradio-container .scan-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
1437
+
1438
+ /* Nút phụ: viền xanh trên nền trắng mờ */
1439
+ .logout-btn-style, .inline-history-btn, .history-back-btn-style {
1440
+ background: rgba(255,255,255,0.72) !important;
1441
+ color: var(--lf-em-dd) !important;
1442
+ border: 1.5px solid rgba(16,185,129,0.42) !important;
1443
+ border-radius: 12px !important;
1444
+ box-shadow: none !important;
1445
+ font-weight: 700 !important;
1446
+ transition: all .18s ease !important;
1447
+ }
1448
+ .logout-btn-style { height: 48px !important; min-width: 0 !important; }
1449
+ .history-back-btn-style { height: 48px !important; }
1450
+ .inline-history-btn { height: 38px !important; font-size: 13px !important; }
1451
+ .logout-btn-style:hover, .inline-history-btn:hover, .history-back-btn-style:hover {
1452
+ background: #fff !important; border-color: var(--lf-em) !important;
1453
+ color: var(--lf-em-dd) !important;
1454
+ box-shadow: 0 8px 20px -14px rgba(5,150,105,0.9) !important;
1455
+ filter: none !important; transform: translateY(-1px);
1456
+ }
1457
+
1458
+ /* Nút gửi chuyên gia: cam đất (nhấn phụ), không dùng đỏ */
1459
+ .expert-send-btn {
1460
+ background: linear-gradient(135deg, #f59e0b, var(--lf-amber)) !important;
1461
+ border-radius: 12px !important; height: 48px !important;
1462
+ box-shadow: 0 12px 26px -16px rgba(217,119,6,0.85) !important;
1463
+ }
1464
+ /* Nút xoá: GIỮ đỏ vì đây là hành động phá huỷ thật sự */
1465
+ .delete-btn-style {
1466
+ background: linear-gradient(135deg, #ef4444, var(--lf-danger)) !important;
1467
+ border: none !important; border-radius: 12px !important;
1468
+ box-shadow: 0 12px 26px -16px rgba(220,38,38,0.8) !important;
1469
+ }
1470
+
1471
+ /* --- Ô nhập / dropdown / textarea: đồng bộ với ô đăng nhập --- */
1472
+ .gradio-container input[type="text"],
1473
+ .gradio-container textarea,
1474
+ .gradio-container .wrap-inner {
1475
+ background: rgba(255,255,255,0.62) !important;
1476
+ border-radius: 12px !important;
1477
+ color: var(--lf-ink) !important;
1478
+ }
1479
+ .gradio-container input:focus,
1480
+ .gradio-container textarea:focus {
1481
+ border-color: var(--lf-em) !important;
1482
+ box-shadow: 0 0 0 4px rgba(16,185,129,0.28) !important;
1483
+ outline: none !important;
1484
+ }
1485
+ .gradio-container label span { color: var(--lf-ink2) !important; font-weight: 600 !important; }
1486
+
1487
+ /* Viền nhấn bên trái: teal/xanh dương -> emerald cho đồng bộ */
1488
+ #prescription_col .textbox_custom {
1489
+ border-left: 5px solid var(--lf-em) !important;
1490
+ background-color: rgba(240,253,244,0.66) !important;
1491
+ border-radius: 12px !important;
1492
+ }
1493
+ #chatbot_col .chatbot_custom {
1494
+ border-left: 5px solid var(--lf-em-d) !important;
1495
+ background-color: rgba(240,253,244,0.5) !important;
1496
+ border-radius: 12px !important;
1497
+ }
1498
+ .footer-text { color: var(--lf-muted) !important; }
1499
+
1500
+ /* ================== Ô CO GIÃN THEO NỘI DUNG ==================
1501
+ Lúc chưa có dữ liệu thì thu nhỏ ~35-40% để nhìn thấy tổng thể bố cục,
1502
+ có dữ liệu mới giãn ra. Gradio đặt chiều cao bằng inline style nên phải !important.
1503
+ Dùng :has() để dò trạng thái rỗng — không cần sửa hàm Python nào. */
1504
+ .lf-img, .lf-chat { transition: height .3s cubic-bezier(.4,0,.2,1) !important; }
1505
+ .textbox_custom textarea { transition: height .3s cubic-bezier(.4,0,.2,1) !important; }
1506
+
1507
+ /* Ô ảnh: 370px -> 230px khi trống, 420px khi đã có ảnh */
1508
+ .lf-img:has(.upload-container), .lf-img:has(.empty) { height: 230px !important; }
1509
+ .lf-img:has(.image-container img) { height: 420px !important; }
1510
+
1511
+ /* Ô đơn thuốc: 118px -> 74px khi còn placeholder */
1512
+ .textbox_custom:has(textarea:placeholder-shown) textarea { height: 74px !important; }
1513
+
1514
+ /* Khung chat: 550px -> 340px khi mới chỉ có 1 lời chào.
1515
+ Lưu ý: .bubble-wrap chỉ có ĐÚNG 1 con là .message-wrap, mọi tin nhắn nằm bên trong,
1516
+ nên không thể đếm bằng :nth-child ở cấp .bubble-wrap. Mỗi tin nhắn là một .message-row,
1517
+ dùng bộ chọn anh-em "~" để bắt trạng thái "có từ 2 tin trở lên". */
1518
+ .lf-chat:not(:has(.message-row ~ .message-row)) { height: 340px !important; }
1519
+ .lf-chat:has(.message-row ~ .message-row) { height: 560px !important; }
1520
+
1521
+ /* --- Điện thoại: chữ to hơn, nút đủ lớn cho ngón tay --- */
1522
+ @media (max-width: 767px) {
1523
+ .gradio-container { font-size: 16px !important; }
1524
+ .gradio-container .scan-btn, .logout-btn-style, .expert-send-btn, .history-back-btn-style { min-height: 50px !important; }
1525
+ /* Nút này để 38px trên desktop cho gọn, nhưng trên điện thoại phải >= 44px
1526
+ mới đủ vùng chạm cho ngón tay (chuẩn tối thiểu về khả năng tiếp cận). */
1527
+ .inline-history-btn { min-height: 46px !important; height: auto !important; }
1528
+ .hospital-header { padding: 14px 16px !important; }
1529
+ .lf-img:has(.image-container img) { height: 330px !important; }
1530
+ .lf-chat:has(.message-row ~ .message-row) { height: 460px !important; }
1531
+ }
1532
+ @media (prefers-reduced-motion: reduce) {
1533
+ .lf-img, .lf-chat, .textbox_custom textarea, .gradio-container .scan-btn { transition: none !important; }
1534
+ .medical-cross-red, .medical-cross-css { animation: none !important; }
1535
+ }
1536
+ /* --- Icon SVG cho NÚT ---
1537
+ Gradio chỉ render nhãn nút dưới dạng text thuần, không nhận HTML. Nên icon được
1538
+ vẽ bằng ::before + mask-image: nhờ mask, icon tự ăn theo màu chữ của nút
1539
+ (trắng trên nút đặc, xanh trên nút viền) mà không cần 2 phiên bản ảnh. */
1540
+ .gradio-container .scan-btn::before,
1541
+ .logout-btn-style::before, .inline-history-btn::before,
1542
+ .history-back-btn-style::before, .expert-send-btn::before,
1543
+ .delete-btn-style::before {
1544
+ content: ""; width: 18px; height: 18px; flex: 0 0 18px; margin-right: 9px;
1545
+ background-color: currentColor;
1546
+ -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
1547
+ -webkit-mask-position: center; mask-position: center;
1548
+ -webkit-mask-size: contain; mask-size: contain;
1549
+ }
1550
+ .gradio-container .scan-btn, .logout-btn-style, .inline-history-btn,
1551
+ .history-back-btn-style, .expert-send-btn, .delete-btn-style {
1552
+ display: inline-flex !important; align-items: center !important; justify-content: center !important;
1553
+ }
1554
+ /* ống nghe - nút quét chẩn đoán */
1555
+ .gradio-container .scan-btn::before {
1556
+ -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 3v6a5 5 0 0 0 10 0V3'/><path d='M6 3H3M15 3h-3'/><circle cx='19' cy='14' r='2'/><path d='M9 14v1a6 6 0 0 0 8 5.7'/></svg>");
1557
+ mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 3v6a5 5 0 0 0 10 0V3'/><path d='M6 3H3M15 3h-3'/><circle cx='19' cy='14' r='2'/><path d='M9 14v1a6 6 0 0 0 8 5.7'/></svg>");
1558
+ }
1559
+ /* đăng xuất */
1560
+ .logout-btn-style::before {
1561
+ -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/><path d='M16 17l5-5-5-5'/><path d='M21 12H9'/></svg>");
1562
+ mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/><path d='M16 17l5-5-5-5'/><path d='M21 12H9'/></svg>");
1563
+ }
1564
+ /* kho lưu trữ - xem lịch sử */
1565
+ .inline-history-btn::before {
1566
+ -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='18' height='5' rx='1'/><path d='M5 8v12h14V8'/><path d='M10 12h4'/></svg>");
1567
+ mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='18' height='5' rx='1'/><path d='M5 8v12h14V8'/><path d='M10 12h4'/></svg>");
1568
+ }
1569
+ /* mũi tên quay lại */
1570
+ .history-back-btn-style::before {
1571
+ -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M19 12H5'/><path d='M12 19l-7-7 7-7'/></svg>");
1572
+ mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M19 12H5'/><path d='M12 19l-7-7 7-7'/></svg>");
1573
+ }
1574
+ /* máy bay giấy - gửi */
1575
+ .expert-send-btn::before {
1576
+ -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M22 2 11 13'/><path d='M22 2 15 22l-4-9-9-4z'/></svg>");
1577
+ mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M22 2 11 13'/><path d='M22 2 15 22l-4-9-9-4z'/></svg>");
1578
+ }
1579
+ /* thùng rác - xoá */
1580
+ .delete-btn-style::before {
1581
+ -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M3 6h18'/><path d='M9 6V4h6v2'/><path d='M6 6l1 14h10l1-14'/></svg>");
1582
+ mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M3 6h18'/><path d='M9 6V4h6v2'/><path d='M6 6l1 14h10l1-14'/></svg>");
1583
+ }
1584
+ /* Nút đăng nhập dùng chung class .scan-btn — KHÔNG cho nó mọc icon ống nghe,
1585
+ giữ màn đăng nhập y hệt bản leaf v4 ban đầu. */
1586
+ #login_wrapper .scan-btn::before { content: none !important; display: none !important; }
1587
+
1588
+ /* Nút xoá nhật ký (variant="stop") cũng theo tông đỏ dịu */
1589
+ .gradio-container button.stop, .gradio-container .stop {
1590
+ background: linear-gradient(135deg, #ef4444, var(--lf-danger)) !important;
1591
+ border: none !important; border-radius: 12px !important; color: #fff !important;
1592
+ min-height: 48px !important; font-weight: 700 !important;
1593
+ }
1594
+ /* ============ HẾT PHẦN ĐỒNG BỘ MÀN LÀM VIỆC ============ */
1595
  """
1596
 
1597
  initial_ticket_text, initial_ticket_img = check_user_expert_status()
 
1634
  """)
1635
  with gr.Column(scale=2, min_width=210):
1636
  with gr.Row():
1637
+ btn_logout = gr.Button("ĐĂNG XUẤT HỆ THỐNG", elem_classes="logout-btn-style")
1638
  with gr.Row():
1639
  with gr.Column(scale=10):
1640
  with gr.Group(elem_classes="gr-group"):
1641
+ gr.Markdown("""<p class="sec-head"><span class="sec-n">1</span><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="8" y="2" width="8" height="4" rx="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><path d="M8 11h8M8 15h5"/></svg>TIẾP NHẬN MẪU XÉT NGHIỆM</p>""")
1642
  plant_dropdown = gr.Dropdown(
1643
+ 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)"],
1644
  value="Cây cà chua", label="Lựa chọn phân khoa điều trị thực vật" )
1645
  with gr.Group(elem_classes="gr-group"):
1646
+ image_input = gr.Image(type="numpy", label="Ảnh quét tế bào bề mặt lá", height=370, elem_classes="lf-img")
1647
  gr.HTML("<div style='padding: 0 10px 10px 10px;'>")
1648
+ btn_analyze = gr.Button("TIẾN HÀNH QUÉT & CHẨN ĐOÁN LÂM SÀNG", variant="primary", elem_classes="scan-btn")
1649
  gr.HTML("</div>")
1650
  with gr.Column(scale=11, elem_id="prescription_col"):
1651
  with gr.Group(elem_classes="gr-group"):
1652
+ gr.Markdown("""<p class="sec-head"><span class="sec-n">2</span><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7V5a2 2 0 0 1 2-2h2"/><path d="M17 3h2a2 2 0 0 1 2 2v2"/><path d="M21 17v2a2 2 0 0 1-2 2h-2"/><path d="M7 21H5a2 2 0 0 1-2-2v-2"/><circle cx="12" cy="12" r="3"/></svg>KẾT QUẢ QUÉT THỊ GIÁC HỌC SÂU (AI DETECT)</p>""")
1653
+ image_output = gr.Image(type="numpy", label="Bản đồ nội soi vi vị trí: Khoanh vùng khu trú ổ bệnh", height=370, elem_classes="lf-img")
1654
+ gr.Markdown("""<p class="sec-head"><span class="sec-n">3</span><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M8 13h8M8 17h5"/></svg>ĐƠN THUỐC LÂM SÀNG SƠ BỘ</p>""")
1655
  text_output = gr.Textbox(
1656
  label="Hồ sơ bệnh án điện tử xuất từ thuật toán",
1657
  lines=5,
 
1660
 
1661
  with gr.Column(scale=12, elem_id="chatbot_col"):
1662
  with gr.Row(elem_classes="chatbot-title-container"):
1663
+ gr.Markdown("""<p class="sec-head" style="margin:0 !important;"><span class="sec-n">4</span><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.4 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.2A8.4 8.4 0 0 1 12 3a8.4 8.4 0 0 1 9 8.5z"/></svg>HỘI ĐỒNG TƯ VẤN THUỐC BẢO VỆ THỰC VẬT (CHATBOT AI)</p>""")
1664
+ btn_history_nav = gr.Button("Xem Lại Lịch Sử Bệnh Án", elem_classes="inline-history-btn")
1665
  chatbot = gr.Chatbot(
1666
  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!"}],
1667
  height=550,
1668
  label="Trò chuyện trực tiếp với Chuyên gia Bảo vệ Thực vật AI",
1669
+ elem_classes=["chatbot_custom", "lf-chat"] )
1670
  with gr.Row(elem_id="chat_input_row"):
1671
  chat_msg = gr.Textbox(
1672
  placeholder="Hỏi chuyên gia về cách chữa trị, tên thuốc, liều lượng phun bón cho loại bệnh vừa quét...",
 
1674
  btn_send = gr.Button("GỬI AI", scale=1, variant="primary", elem_classes="scan-btn")
1675
 
1676
  with gr.Group(elem_classes="gr-group", visible=True) as user_expert_section:
1677
+ gr.Markdown("""<p class="sec-head"><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1"/></svg>HỖ TRỢ TƯ VẤN TỪ CHUYÊN GIA</p>""")
1678
+ gr.Markdown("""<p class="sec-desc">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>""")
1679
  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)
1680
+ btn_send_expert = gr.Button("GỬI YÊU CẦU CHO CHUYÊN GIA (HỘP THƯ CHỜ)", elem_classes="expert-send-btn")
1681
  expert_status_box = gr.HTML(value=initial_ticket_text)
1682
  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)
1683
 
1684
+ 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>")
1685
 
1686
  with gr.Column(visible=False) as history_panel:
1687
  with gr.Row(elem_classes="hospital-header"):
1688
  with gr.Column(scale=10):
1689
  gr.HTML("""
1690
+ <h1 style='text-align: left; display:flex; align-items:center; gap:10px;'><svg style="width:26px;height:26px;stroke:currentColor;flex:0 0 26px" viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="5" rx="1"/><path d="M5 8v12h14V8"/><path d="M10 12h4"/></svg>KHO LƯU TRỮ HỒ SƠ &amp; LỊCH SỬ HỆ THỐNG</h1>
1691
  <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>
1692
  """)
1693
  with gr.Column(scale=2, min_width=150):
1694
+ btn_back_to_clinic = gr.Button("QUAY LẠI PHÒNG KHÁM", elem_classes="history-back-btn-style")
1695
 
1696
  with gr.Row():
1697
  with gr.Column(visible=True) as user_diagnose_col:
1698
+ gr.Markdown("""<p class="sec-head"><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>NHẬT KÝ CHẨN ĐOÁN ẢNH</p>""")
1699
  history_diagnose_box = gr.Textbox(
1700
  value=load_diagnose_history(),
1701
  label="Lịch sử các ca bệnh đã quét",
1702
  lines=15,
1703
  interactive=False )
1704
+ btn_clear_diagnose = gr.Button("XÓA NHẬT KÝ CHẨN ĐOÁN", variant="stop")
1705
  with gr.Column(visible=True) as user_chat_col:
1706
+ gr.Markdown("""<p class="sec-head"><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.4 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.2A8.4 8.4 0 0 1 12 3a8.4 8.4 0 0 1 9 8.5z"/></svg>NHẬT KÝ HỘI THOẠI VỚI AI</p>""")
1707
  history_chat_box = gr.Textbox(
1708
  value=load_chat_history(),
1709
  label="Lịch sử chat kê đơn thuốc",
1710
  lines=15,
1711
  interactive=False
1712
  )
1713
+ btn_clear_chat = gr.Button("XÓA NHẬT KÝ CHAT", variant="stop")
1714
 
1715
  gr.HTML("<hr style='margin: 25px 0; border: 1px solid #d4deda;'>")
1716
 
1717
  with gr.Group(elem_classes="gr-group"):
1718
+ gr.Markdown("""<p class="sec-head" style="font-size:17px !important;"><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1"/></svg>HỘP THƯ TƯ VẤN CHUYÊN GIA (LỊCH SỬ HỎI ĐÁP)</p>""")
1719
 
1720
  with gr.Row(elem_id="expert_select_row"):
1721
  admin_ticket_select = gr.Dropdown(label="Danh sách các câu hỏi hỗ trợ:", choices=[], value=None, scale=8)
1722
+ btn_delete_ticket = gr.Button("XÓA CÂU HỎI / HỘI THOẠI NÀY", elem_classes="delete-btn-style", scale=2)
1723
 
1724
  with gr.Row():
1725
  with gr.Column(scale=1):
1726
  admin_ticket_detail = gr.HTML(value="Hiện chưa có yêu cầu hỗ trợ nào.")
1727
  with gr.Column(scale=1):
1728
+ admin_ticket_img_display = gr.Image(label="Mẫu lá bệnh do nhà nông gửi lên:", height=300, interactive=False)
1729
 
1730
  with gr.Row():
1731
  admin_ticket_conversation = gr.HTML(value="", elem_id="full_width_conversation")
 
1733
  with gr.Row():
1734
  with gr.Column(scale=1, visible=False) as admin_control_panel:
1735
  gr.Markdown("<hr style='margin: 15px 0; border: 1px dashed #007965;'>")
1736
+ gr.Markdown("""<p class="sec-head"><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z"/></svg>GỬI PHẢN HỒI BỆNH ÁN TỪ CHUYÊN GIA</p>""")
1737
  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)
1738
+ btn_submit_admin_reply = gr.Button("GỬI CÂU TRẢ LỜI CHO NHÀ NÔNG", variant="primary", elem_classes="scan-btn")
1739
  admin_reply_status = gr.Markdown("")
1740
 
1741
  with gr.Group(visible=True) as user_followup_panel:
1742
  gr.Markdown("<hr style='margin: 15px 0; border: 1px dashed #27ae60;'>")
1743
+ gr.Markdown("""<p class="sec-head"><svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.4 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.2A8.4 8.4 0 0 1 12 3a8.4 8.4 0 0 1 9 8.5z"/></svg>BẠN VẪN CHƯA RÕ? HỎI TIẾP CHUYÊN GIA VỀ VẤN ĐỀ NÀY</p>""")
1744
  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)
1745
+ btn_send_followup = gr.Button("GỬI CÂU HỎI TIẾP TỤC CHO CHUYÊN GIA", variant="primary")
1746
 
1747
  btn_login.click(
1748
  login_auth,