-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2352 lines (2180 loc) · 124 KB
/
Copy pathindex.html
File metadata and controls
2352 lines (2180 loc) · 124 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PrescribePro Rx</title>
<link href="https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,300;0,400;0,600;0,700;1,400&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<script src="https://accounts.google.com/gsi/client" async></script>
<style>
:root {
--bg: #f7f6f2;
--surface: #ffffff;
--surface2: #f0ede6;
--border: #d8d3c8;
--border-strong: #b0a898;
--text: #1a1814;
--text-2: #5a5448;
--text-3: #8a8278;
--accent: #2c5f8a;
--accent-light: #e8f0f8;
--accent-hover: #1e4a6e;
--danger: #c0392b;
--success: #27ae60;
--warn: #e67e22;
--rx-blue: #1a3a5c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
/* ── TOP NAV ── */
#topnav {
background: var(--surface);
border-bottom: 1px solid var(--border);
display: flex; align-items: center; justify-content: space-between;
padding: 0 28px; height: 56px; position: sticky; top: 0; z-index: 100;
box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.nav-brand { font-family: 'Crimson Pro', serif; font-size: 22px; font-weight: 700; color: var(--rx-blue); letter-spacing: -.3px; }
.nav-brand span { color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-tabs { display: flex; gap: 4px; }
.nav-tab { padding: 6px 16px; border-radius: 6px; border: none; background: transparent; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: all .15s; }
.nav-tab:hover { background: var(--surface2); color: var(--text); }
.nav-tab.active { background: var(--accent-light); color: var(--accent); }
.btn-icon { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 16px; transition: all .15s; }
.btn-icon:hover { background: var(--surface2); color: var(--text); }
#user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: white; font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 2px solid var(--accent-light); }
/* ── PAGES ── */
.page { display: none; }
.page.active { display: block; }
/* ── LOGIN PAGE ── */
#page-login {
min-height: 100vh; display: flex !important; align-items: center; justify-content: center;
background: linear-gradient(135deg, #e8f0f8 0%, #f7f6f2 50%, #eef2ea 100%);
}
.login-card {
background: var(--surface); border-radius: 20px; padding: 56px 48px;
width: 420px; box-shadow: 0 8px 40px rgba(0,0,0,.1); text-align: center;
}
.login-logo { font-family: 'Crimson Pro', serif; font-size: 36px; font-weight: 700; color: var(--rx-blue); margin-bottom: 4px; }
.login-logo span { color: var(--accent); }
.login-sub { color: var(--text-3); font-size: 13px; margin-bottom: 40px; }
.login-title { font-size: 18px; font-weight: 600; margin-bottom: 24px; color: var(--text); }
.btn-google {
width: 100%; padding: 14px; border-radius: 10px; border: 1.5px solid var(--border);
background: var(--surface); font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 500;
cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 12px;
transition: all .2s; color: var(--text);
}
.btn-google:hover { background: var(--surface2); border-color: var(--border-strong); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.google-icon { width: 20px; height: 20px; }
.login-note { font-size: 11.5px; color: var(--text-3); margin-top: 20px; line-height: 1.6; }
/* ── MAIN LAYOUT ── */
#main-layout { display: flex; min-height: calc(100vh - 56px); }
#sidebar {
width: 220px; background: var(--surface); border-right: 1px solid var(--border);
padding: 20px 12px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px;
}
.sidebar-section { font-size: 10px; font-weight: 600; letter-spacing: 1.2px; color: var(--text-3); text-transform: uppercase; padding: 8px 8px 4px; }
.sidebar-btn {
display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
border: none; background: transparent; font-family: 'DM Sans', sans-serif;
font-size: 13.5px; font-weight: 400; color: var(--text-2); cursor: pointer; width: 100%; text-align: left; transition: all .15s;
}
.sidebar-btn:hover { background: var(--surface2); color: var(--text); }
.sidebar-btn.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.sidebar-btn .ico { font-size: 16px; width: 20px; text-align: center; }
#content { flex: 1; padding: 28px 32px; overflow-y: auto; }
/* ── SECTION HEADERS ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.section-title { font-family: 'Crimson Pro', serif; font-size: 26px; font-weight: 600; color: var(--rx-blue); }
.section-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }
/* ── BUTTONS ── */
.btn { padding: 9px 18px; border-radius: 8px; border: none; font-family: 'DM Sans', sans-serif; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 7px; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface2); }
.btn-danger { background: #fdf0ee; color: var(--danger); border: 1px solid #f5c6c2; }
.btn-danger:hover { background: #fbe0dc; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #1e8a4e; }
/* ── CARDS ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.card + .card { margin-top: 16px; }
/* ── FORM ELEMENTS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 500; color: var(--text-2); letter-spacing: .2px; }
input, select, textarea {
padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
font-family: 'DM Sans', sans-serif; font-size: 13.5px; color: var(--text);
background: var(--surface); transition: border-color .15s; outline: none;
width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(44,95,138,.1); }
textarea { resize: vertical; min-height: 72px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
/* ── PATIENT LIST ── */
.patient-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.patient-card {
background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
padding: 18px; cursor: pointer; transition: all .2s; position: relative;
}
.patient-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(44,95,138,.12); transform: translateY(-1px); }
.patient-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-light); color: var(--accent); font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.patient-avatar.female { background: #fce8f3; color: #9b2d7a; }
.patient-name { font-weight: 600; font-size: 15px; color: var(--text); margin-bottom: 3px; }
.patient-meta { font-size: 12px; color: var(--text-3); display: flex; gap: 8px; }
.patient-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-m { background: #e8f0f8; color: var(--accent); }
.badge-f { background: #fce8f3; color: #9b2d7a; }
.patient-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; opacity: 0; transition: opacity .2s; }
.patient-card:hover .patient-actions { opacity: 1; }
/* ── SEARCH BAR ── */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; }
/* ── DRUG ENTRY CARD STYLE ── */
.drug-card {
background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
padding: 14px 14px 12px; margin-bottom: 10px; position: relative;
}
.drug-card:hover { border-color: var(--accent); }
.drug-card-header { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.drug-card-body { display: grid; grid-template-columns: 70px 80px 1fr 100px 110px; gap: 8px; align-items: start; }
.drug-card-notes { margin-top: 8px; }
.drug-card-del { position: absolute; top: 10px; right: 10px; }
.drug-field-label { font-size: 10px; font-weight: 600; letter-spacing: .4px; color: var(--text-3); text-transform: uppercase; margin-bottom: 3px; }
.timing-radios { display: flex; flex-direction: column; gap: 3px; }
.timing-radios label { font-size: 11.5px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.timing-radios input[type=radio] { width: auto; accent-color: var(--accent); }
/* ── DRUG TABLE (kept minimal for reference, hidden now) ── */
.drug-table { width: 100%; border-collapse: collapse; }
.drug-table th { font-size: 11px; font-weight: 600; letter-spacing: .5px; color: var(--text-3); text-transform: uppercase; padding: 8px 10px; background: var(--surface2); text-align: left; border-bottom: 1px solid var(--border); }
.drug-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.drug-table tr:last-child td { border-bottom: none; }
.drug-table input, .drug-table select { padding: 6px 8px; font-size: 12.5px; }
.drug-row { position: relative; }
.drug-name-wrap { position: relative; }
.drug-autocomplete {
position: absolute; top: calc(100% + 4px); left: 0; right: 0;
background: #fff;
border: 1.5px solid #c5d8ee;
border-radius: 12px;
max-height: 340px; overflow-y: auto; z-index: 200;
box-shadow: 0 8px 32px rgba(26,58,92,.15), 0 2px 8px rgba(0,0,0,.06);
padding: 4px;
}
.drug-autocomplete::-webkit-scrollbar { width: 5px; }
.drug-autocomplete::-webkit-scrollbar-track { background: transparent; }
.drug-autocomplete::-webkit-scrollbar-thumb { background: #c5d8ee; border-radius: 10px; }
.drug-ac-item {
display: flex; align-items: center; gap: 10px;
padding: 9px 11px; cursor: pointer;
border-radius: 8px; margin-bottom: 2px;
border-left: 3px solid transparent;
transition: background .13s, border-color .13s;
position: relative;
}
.drug-ac-item:last-child { margin-bottom: 0; }
.drug-ac-item:hover {
background: linear-gradient(90deg, #e8f2fc 0%, #f4f8fd 100%);
border-left-color: var(--accent);
}
.drug-ac-icon {
width: 34px; height: 34px; border-radius: 8px;
background: linear-gradient(135deg, #ddeaf8 0%, #c8ddf4 100%);
display: flex; align-items: center; justify-content: center;
font-size: 16px; flex-shrink: 0;
}
.drug-ac-body { flex: 1; min-width: 0; }
.drug-ac-item .ac-brand {
font-size: 13.5px; font-weight: 700; color: var(--rx-blue);
display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.ac-dose-badge {
font-size: 11px; font-weight: 700; color: #fff;
background: var(--accent); border-radius: 4px;
padding: 1px 6px; letter-spacing: .2px;
}
.ac-form-badge {
font-size: 10.5px; font-weight: 600; color: var(--accent);
background: var(--accent-light); border-radius: 4px;
padding: 1px 6px; border: 1px solid #c5d8ee;
}
.drug-ac-item .ac-meta {
font-size: 11.5px; color: var(--text-2); display: flex;
align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 3px;
}
.ac-generic { color: var(--text-2); font-style: italic; }
.ac-company-badge {
font-size: 10.5px; font-weight: 600;
color: #1a6b3a; background: #e6f4ec;
border: 1px solid #b2ddc0; border-radius: 4px;
padding: 1px 6px; font-style: normal;
}
.check-group { display: flex; gap: 10px; align-items: center; }
.check-label { display: flex; align-items: center; gap: 5px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.check-label input[type=checkbox], .check-label input[type=radio] { width: auto; accent-color: var(--accent); }
.del-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.del-btn:hover { background: #fdf0ee; }
/* ── MODALS ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-lg { max-width: 860px; }
.modal-header { padding: 24px 28px 0; display: flex; justify-content: space-between; align-items: flex-start; }
.modal-title { font-family: 'Crimson Pro', serif; font-size: 22px; font-weight: 600; color: var(--rx-blue); }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-3); line-height: 1; padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-body { padding: 20px 28px 28px; }
.modal-footer { padding: 0 28px 24px; display: flex; justify-content: flex-end; gap: 10px; }
/* ── PRESCRIPTION PREVIEW (A4) ── */
#rx-preview-wrap { background: #666; padding: 24px; display: flex; justify-content: center; }
#rx-a4 {
width: 794px; min-height: 1123px; background: white;
font-family: 'Crimson Pro', serif;
padding: 48px 52px 52px;
position: relative; box-shadow: 0 8px 32px rgba(0,0,0,.3);
color: #111;
}
.rx-header { text-align: center; margin-bottom: 0; }
.rx-doc-name { font-size: 22px; font-weight: 700; letter-spacing: -.2px; color: #111; }
.rx-doc-quals { font-size: 12.5px; color: #333; line-height: 1.5; font-family: 'DM Sans', sans-serif; }
.rx-divider { border: none; border-top: 1.5px solid #111; margin: 8px 0 6px; }
.rx-patient-row { display: flex; gap: 0; font-size: 13px; font-family: 'DM Sans', sans-serif; border-bottom: 1px solid #111; padding-bottom: 6px; margin-bottom: 0; }
.rx-pfield { flex: 1; }
.rx-pfield strong { margin-right: 4px; }
.rx-body { display: flex; min-height: 800px; border-bottom: 1px solid #111; }
.rx-left { width: 165px; flex-shrink: 0; border-right: 1px solid #111; padding: 12px 12px 12px 0; display: flex; flex-direction: column; gap: 24px; }
.rx-section-label { font-size: 11.5px; font-weight: 700; font-family: 'DM Sans', sans-serif; letter-spacing: .8px; text-transform: uppercase; color: #111; }
.rx-section-content { font-size: 12.5px; font-family: 'DM Sans', sans-serif; color: #222; line-height: 1.55; white-space: pre-wrap; margin-top: 4px; }
.rx-right { flex: 1; padding: 12px 0 12px 16px; }
.rx-rx-title { font-size: 18px; font-weight: 700; color: #111; margin-bottom: 10px; }
.rx-drug-item { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px dotted #ccc; }
.rx-drug-item:last-child { border-bottom: none; }
.rx-drug-name { font-size: 14px; font-weight: 600; color: #111; }
.rx-drug-name span { font-size: 12px; font-weight: 400; color: #555; font-family: 'DM Sans', sans-serif; }
.rx-drug-sig { font-size: 12.5px; color: #333; font-family: 'DM Sans', sans-serif; margin-top: 2px; }
.rx-advice-section { margin-top: 16px; }
.rx-advice-label { font-size: 11px; font-weight: 700; font-family: 'DM Sans', sans-serif; letter-spacing: .8px; text-transform: uppercase; color: #111; margin-bottom: 4px; }
.rx-advice-text { font-size: 12.5px; font-family: 'DM Sans', sans-serif; color: #333; line-height: 1.6; }
.rx-footer-note { text-align: center; font-size: 13px; font-family: 'DM Sans', sans-serif; padding-top: 10px; color: #333; }
.rx-followup { font-size: 12.5px; font-family: 'DM Sans', sans-serif; color: #333; margin-top: 8px; }
/* ── PROFILE PAGE ── */
.profile-header-card { background: linear-gradient(135deg, var(--rx-blue) 0%, var(--accent) 100%); border-radius: 16px; padding: 32px; color: white; display: flex; gap: 24px; align-items: center; margin-bottom: 24px; }
.profile-avatar-lg { width: 80px; height: 80px; border-radius: 50%; background: rgba(255,255,255,.2); color: white; font-size: 32px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 3px solid rgba(255,255,255,.4); }
.profile-info h2 { font-family: 'Crimson Pro', serif; font-size: 26px; font-weight: 700; }
.profile-info p { opacity: .8; font-size: 14px; }
/* ── PAD PREVIEW ── */
.pad-preview { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.pad-preview-inner { padding: 16px; background: white; }
/* ── TOAST ── */
#toast { position: fixed; bottom: 28px; right: 28px; background: #1a1814; color: white; padding: 12px 20px; border-radius: 10px; font-size: 14px; z-index: 9999; opacity: 0; transform: translateY(10px); transition: all .3s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateY(0); }
/* ── EMPTY STATES ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state .ico { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text-2); margin-bottom: 6px; }
/* ── TAGS ── */
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 500; }
.tag-blue { background: var(--accent-light); color: var(--accent); }
/* ── STATS ROW ── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.stat-num { font-family: 'Crimson Pro', serif; font-size: 32px; font-weight: 700; color: var(--rx-blue); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 4px; }
/* ── HISTORY LIST ── */
.rx-history-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; cursor: pointer; transition: all .15s; }
.rx-history-item:hover { border-color: var(--accent); background: var(--accent-light); }
.rx-date-badge { background: var(--surface2); padding: 6px 10px; border-radius: 8px; text-align: center; min-width: 52px; }
.rx-date-badge .day { font-size: 20px; font-weight: 700; color: var(--rx-blue); font-family: 'Crimson Pro', serif; }
.rx-date-badge .mon { font-size: 10px; color: var(--text-3); text-transform: uppercase; }
/* ── DATABASE UPLOAD ── */
.db-upload-zone {
border: 2px dashed var(--border); border-radius: 12px; padding: 40px 24px;
text-align: center; cursor: pointer; transition: all .2s; background: var(--surface);
}
.db-upload-zone:hover, .db-upload-zone.dragover { border-color: var(--accent); background: var(--accent-light); }
.db-upload-zone .upload-ico { font-size: 40px; margin-bottom: 10px; }
.db-upload-zone .upload-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.db-upload-zone .upload-sub { font-size: 13px; color: var(--text-3); }
.db-status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.db-status-badge.active { background: #e8f5ee; color: var(--success); }
.db-status-badge.none { background: var(--surface2); color: var(--text-3); }
.db-table-wrap { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 12px; }
.db-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.db-table th { padding: 8px 12px; background: var(--surface2); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); font-weight: 600; text-align: left; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.db-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.db-table tr:last-child td { border-bottom: none; }
.db-table tr:hover td { background: var(--accent-light); }
.db-progress { height: 4px; background: var(--border); border-radius: 2px; margin-top: 12px; overflow: hidden; }
.db-progress-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
/* ── DRIVE STATUS ── */
.drive-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.drive-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
@keyframes spin { to { transform: rotate(360deg); } }
/* ── UTIL ── */
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--text-3); font-size: 12.5px; }
.mt-4 { margin-top: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
@media print { body { background: white; } #topnav, #sidebar { display: none; } #content { padding: 0; } }
</style>
</head>
<body>
<!-- LOGIN PAGE -->
<div id="page-login" class="page active">
<div class="login-card">
<div class="login-logo">Prescribe<span>Pro</span> <span style="font-size:18px; color:var(--text-3)">Rx</span></div>
<div class="login-sub">Professional Medical Prescription Software</div>
<div class="login-title">Sign in to continue</div>
<!-- Custom Google Sign-In button -->
<button class="btn-google" id="btn-google-signin" onclick="startGoogleLogin()">
<svg class="google-icon" viewBox="0 0 24 24">
<path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/>
<path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/>
<path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z"/>
<path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/>
</svg>
<span id="btn-google-text">Continue with Google</span>
</button>
<!-- Loading state shown while signing in -->
<div id="login-loading" style="display:none; flex-direction:column; align-items:center; gap:12px; padding:16px 0">
<div style="width:32px;height:32px;border:3px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite"></div>
<div id="login-loading-text" style="font-size:13px; color:var(--text-3)">Signing in with Google…</div>
</div>
<p class="login-note">Your data is stored locally and backed up to your Google Drive. We never share your patient data.</p>
</div>
</div>
<!-- TOP NAV (hidden until login) -->
<div id="topnav" class="hidden">
<div class="nav-brand">Prescribe<span>Pro</span> <span style="font-size:14px; color:var(--text-3); font-family:'DM Sans'">Rx</span></div>
<div class="nav-right">
<div class="drive-status" id="drive-status">
<div class="drive-dot" style="background:var(--warn)"></div>
<span style="color:var(--text-3)">Drive Offline</span>
</div>
<button class="btn-icon" onclick="syncDrive()" title="Sync to Google Drive">☁️</button>
<div id="user-avatar" onclick="showSection('profile')">E</div>
</div>
</div>
<!-- MAIN APP -->
<div id="main-layout" class="hidden">
<!-- Sidebar -->
<div id="sidebar">
<div class="sidebar-section">Main</div>
<button class="sidebar-btn active" onclick="showSection('dashboard')" id="sb-dashboard"><span class="ico">📊</span> Dashboard</button>
<button class="sidebar-btn" onclick="showSection('patients')" id="sb-patients"><span class="ico">👥</span> Patients</button>
<button class="sidebar-btn" onclick="showSection('prescriptions')" id="sb-prescriptions"><span class="ico">📋</span> Prescriptions</button>
<div class="sidebar-section" style="margin-top:8px">Settings</div>
<button class="sidebar-btn" onclick="showSection('profile')" id="sb-profile"><span class="ico">⚕️</span> Doctor Profile</button>
<button class="sidebar-btn" onclick="showSection('paddesign')" id="sb-paddesign"><span class="ico">🖊️</span> Pad Design</button>
<button class="sidebar-btn" onclick="showSection('drugdb')" id="sb-drugdb"><span class="ico">💊</span> Drug Database</button>
<button class="sidebar-btn" onclick="showSection('about')" id="sb-about"><span class="ico">ℹ️</span> About</button>
<div style="flex:1"></div>
<button class="sidebar-btn" onclick="logOut()" style="color:var(--danger)"><span class="ico">🚪</span> Sign Out</button>
</div>
<!-- Content -->
<div id="content">
<!-- DASHBOARD -->
<div id="section-dashboard" class="section-content">
<div class="section-header">
<div>
<div class="section-title">Dashboard</div>
<div class="section-sub" id="greeting-sub">Good morning, Doctor</div>
</div>
<button class="btn btn-primary" onclick="openNewRx()">+ New Prescription</button>
</div>
<div class="stats-row">
<div class="stat-card"><div class="stat-num" id="stat-patients">0</div><div class="stat-label">Total Patients</div></div>
<div class="stat-card"><div class="stat-num" id="stat-rx">0</div><div class="stat-label">Prescriptions</div></div>
<div class="stat-card"><div class="stat-num" id="stat-today">0</div><div class="stat-label">Today</div></div>
<div class="stat-card"><div class="stat-num" id="stat-month">0</div><div class="stat-label">This Month</div></div>
</div>
<div class="card">
<div class="flex justify-between items-center" style="margin-bottom:16px">
<div style="font-weight:600; font-size:15px;">Recent Prescriptions</div>
</div>
<div id="recent-rx-list"></div>
</div>
</div>
<!-- PATIENTS -->
<div id="section-patients" class="section-content hidden">
<div class="section-header">
<div>
<div class="section-title">Patients</div>
<div class="section-sub">Manage patient profiles</div>
</div>
<button class="btn btn-primary" onclick="openPatientModal()">+ New Patient</button>
</div>
<div style="margin-bottom:16px">
<div class="search-bar" style="max-width:340px">
<input type="text" id="patient-search" placeholder="Search patients..." oninput="renderPatients()">
</div>
</div>
<div id="patient-grid" class="patient-grid"></div>
</div>
<!-- PRESCRIPTIONS -->
<div id="section-prescriptions" class="section-content hidden">
<div class="section-header">
<div>
<div class="section-title">Prescriptions</div>
<div class="section-sub">All prescription history</div>
</div>
<button class="btn btn-primary" onclick="openNewRx()">+ New Prescription</button>
</div>
<div id="all-rx-list"></div>
</div>
<!-- PROFILE -->
<div id="section-profile" class="section-content hidden">
<div class="section-title" style="margin-bottom:20px">Doctor Profile</div>
<div class="card">
<div class="form-grid">
<div class="form-group"><label>Full Name</label><input type="text" id="doc-name" placeholder="Dr. Full Name"></div>
<div class="form-group"><label>Qualifications</label><input type="text" id="doc-qual" placeholder="MBBS (DU), FCPS"></div>
<div class="form-group"><label>Designation</label><input type="text" id="doc-designation" placeholder="Medical Officer"></div>
<div class="form-group"><label>Institution / Hospital</label><input type="text" id="doc-hospital" placeholder="Hospital Name"></div>
<div class="form-group"><label>Registration Number</label><input type="text" id="doc-reg" placeholder="Regi: A-000000"></div>
<div class="form-group"><label>Phone</label><input type="text" id="doc-phone" placeholder="+880..."></div>
<div class="form-group full"><label>Address / Chamber</label><input type="text" id="doc-address" placeholder="Chamber address"></div>
<div class="form-group"><label>Chamber Hours</label><input type="text" id="doc-hours" placeholder="Sat–Thu: 6–9 PM"></div>
<div class="form-group"><label>Footer Note (Bengali/English)</label><input type="text" id="doc-footer" placeholder="নিয়ম মাফিক ঔষধ খাবেন..."></div>
</div>
<hr class="divider" style="margin:20px 0">
<div style="font-weight:600; font-size:14px; margin-bottom:14px; color:var(--rx-blue)">🏥 Chamber Location <span style="font-size:12px; font-weight:400; color:var(--text-3)">(shown on prescription pad — leave blank to hide)</span></div>
<div class="form-grid">
<div class="form-group"><label>Chamber Name</label><input type="text" id="chamber-name" placeholder="e.g. City Medical Chamber"></div>
<div class="form-group"><label>Appointment / Phone</label><input type="text" id="chamber-phone" placeholder="e.g. 01700-000000"></div>
<div class="form-group full"><label>Address Line 1</label><input type="text" id="chamber-addr1" placeholder="e.g. House 12, Road 5, Dhanmondi"></div>
<div class="form-group full"><label>Address Line 2</label><input type="text" id="chamber-addr2" placeholder="e.g. Dhaka-1205, Bangladesh"></div>
<div class="form-group"><label>Visiting Hours</label><input type="text" id="chamber-hours" placeholder="e.g. Sat–Thu: 6–9 PM"></div>
<div class="form-group"><label>Appointment Note</label><input type="text" id="chamber-note" placeholder="e.g. By appointment only"></div>
</div>
<div style="margin-top:20px; display:flex; gap:10px">
<button class="btn btn-primary" onclick="saveProfile()">Save Profile</button>
<button class="btn btn-secondary" onclick="showSection('paddesign')">Configure Pad →</button>
</div>
</div>
</div>
<!-- PAD DESIGN -->
<div id="section-paddesign" class="section-content hidden">
<div class="section-title" style="margin-bottom:20px">Prescription Pad Design</div>
<div style="display:grid; grid-template-columns:1fr 1fr; gap:20px; align-items:start">
<div class="card">
<div style="font-weight:600; margin-bottom:16px">Pad Settings</div>
<div class="form-group" style="margin-bottom:12px"><label>Header Alignment</label>
<select id="pad-align">
<option value="center">Center</option>
<option value="left">Left</option>
<option value="right">Right</option>
</select>
</div>
<div class="form-group" style="margin-bottom:12px"><label>Left Column Width (px)</label>
<input type="number" id="pad-left-width" value="165" min="120" max="250">
</div>
<div class="form-group" style="margin-bottom:12px"><label>Show Sections</label>
<div style="display:flex; flex-direction:column; gap:8px; margin-top:4px">
<label class="check-label"><input type="checkbox" id="show-history" checked> History</label>
<label class="check-label"><input type="checkbox" id="show-findings" checked> Findings</label>
<label class="check-label"><input type="checkbox" id="show-investigation" checked> Investigation</label>
<label class="check-label"><input type="checkbox" id="show-advice" checked> Advice</label>
<label class="check-label"><input type="checkbox" id="show-followup" checked> Follow-up</label>
</div>
</div>
<div class="form-group" style="margin-bottom:12px"><label>Accent Color</label>
<input type="color" id="pad-color" value="#1a3a5c" style="height:36px; padding:2px 4px">
</div>
<button class="btn btn-primary" onclick="savePadSettings()">Save Pad Settings</button>
</div>
<div>
<div style="font-weight:600; margin-bottom:12px; font-size:14px; color:var(--text-2)">Live Preview</div>
<div class="pad-preview">
<div class="pad-preview-inner" id="pad-preview-html" style="font-family:'Crimson Pro', serif; font-size:11px; transform-origin:top left; transform:scale(0.65); width:794px; min-height:400px;">
</div>
</div>
</div>
</div>
</div>
<!-- DRUG DATABASE -->
<div id="section-drugdb" class="section-content hidden">
<div class="section-header">
<div>
<div class="section-title">Drug Database</div>
<div class="section-sub">Upload a custom drug list — stored in your Google Drive, synced across all devices</div>
</div>
<div id="db-cloud-status"></div>
</div>
<!-- Info card -->
<div class="card" style="margin-bottom:16px; background:var(--accent-light); border-color:var(--accent)">
<div style="display:flex; gap:12px; align-items:flex-start">
<div style="font-size:22px">ℹ️</div>
<div>
<div style="font-weight:600; font-size:14px; color:var(--accent); margin-bottom:4px">One-time upload per account</div>
<div style="font-size:13px; color:var(--text-2); line-height:1.7">
Upload your drug database once (JSON or Excel/CSV). It will be saved to your Google Drive and automatically loaded on every device you sign into.<br>
<strong>JSON format:</strong> Array of objects with <code style="background:#dde8f3;padding:1px 5px;border-radius:3px">name</code>, <code style="background:#dde8f3;padding:1px 5px;border-radius:3px">generic</code>, <code style="background:#dde8f3;padding:1px 5px;border-radius:3px">form</code> fields.<br>
<strong>CSV/Excel:</strong> Columns: <code style="background:#dde8f3;padding:1px 5px;border-radius:3px">name, generic, form</code> (header row required).
</div>
</div>
</div>
</div>
<!-- Download Latest Database card -->
<div class="card" style="margin-bottom:16px; border:1.5px solid #c8dff5; background:linear-gradient(135deg,#f0f7ff 0%,#e8f3fe 100%);">
<div style="display:flex; gap:14px; align-items:flex-start; flex-wrap:wrap;">
<div style="font-size:28px; line-height:1; margin-top:2px;">🗄️</div>
<div style="flex:1; min-width:200px;">
<div style="font-weight:700; font-size:15px; color:var(--rx-blue); margin-bottom:6px;">Download the Latest Database</div>
<div style="font-size:13px; color:var(--text-2); line-height:1.75; margin-bottom:12px;">
Get the most up-to-date drug database file maintained for this app.
<ol style="margin:6px 0 0 18px; padding:0; display:flex; flex-direction:column; gap:3px;">
<li>Click the <strong>Download Database</strong> icon below to open the Google Drive folder.</li>
<li>Download the latest <code style="background:#dde8f3;padding:1px 5px;border-radius:3px">.json</code> or <code style="background:#dde8f3;padding:1px 5px;border-radius:3px">.csv</code> file from there.</li>
<li>Come back and upload it using the <strong>Upload Database File</strong> panel below.</li>
</ol>
</div>
<a href="https://drive.google.com/drive/u/0/mobile/folders/1TkewJiEa7dAHq5usk0CzpCZSyxMpHccO" target="_blank" rel="noopener noreferrer"
style="display:inline-flex; align-items:center; gap:9px; padding:10px 20px; background:var(--accent); color:#fff; border-radius:8px; text-decoration:none; font-size:13px; font-weight:600; box-shadow:0 2px 8px rgba(26,58,92,0.18); transition:opacity .2s;"
onmouseover="this.style.opacity='.85'" onmouseout="this.style.opacity='1'">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>
</svg>
Download Database
</a>
</div>
</div>
</div>
<div style="display:grid; grid-template-columns:1fr 1fr; gap:20px; align-items:start">
<!-- Upload zone -->
<div class="card">
<div style="font-weight:600; font-size:15px; margin-bottom:16px">Upload Database File</div>
<div class="db-upload-zone" id="db-drop-zone" onclick="document.getElementById('db-file-input').click()"
ondragover="event.preventDefault(); this.classList.add('dragover')"
ondragleave="this.classList.remove('dragover')"
ondrop="handleDbFileDrop(event)">
<div class="upload-ico">📂</div>
<div class="upload-title">Click or drag & drop</div>
<div class="upload-sub">Supports .json, .csv, .xlsx, .xls</div>
</div>
<input type="file" id="db-file-input" accept=".json,.csv,.xlsx,.xls" style="display:none" onchange="handleDbFileSelect(event)">
<div id="db-progress-wrap" style="display:none; margin-top:16px">
<div style="font-size:13px; color:var(--text-2); margin-bottom:6px" id="db-progress-label">Processing…</div>
<div class="db-progress"><div class="db-progress-bar" id="db-progress-bar" style="width:0%"></div></div>
</div>
<div style="margin-top:20px">
<div style="font-size:13px; font-weight:500; margin-bottom:8px; color:var(--text-2)">Current Database Status</div>
<div id="db-status-info" style="display:flex; flex-direction:column; gap:8px">
<div style="display:flex; align-items:center; justify-content:space-between">
<span style="font-size:13px; color:var(--text-3)">Built-in drugs</span>
<span class="db-status-badge active" id="db-builtin-count">— entries</span>
</div>
<div style="display:flex; align-items:center; justify-content:space-between">
<span style="font-size:13px; color:var(--text-3)">Custom drugs (from your file)</span>
<span class="db-status-badge none" id="db-custom-count">None</span>
</div>
<div style="display:flex; align-items:center; justify-content:space-between">
<span style="font-size:13px; color:var(--text-3)">Cloud backup</span>
<span class="db-status-badge none" id="db-drive-status">Not uploaded</span>
</div>
</div>
</div>
<div style="margin-top:20px; display:flex; gap:8px; flex-wrap:wrap" id="db-action-btns">
<button class="btn btn-secondary btn-sm" onclick="downloadDbTemplate('json')">⬇️ Sample JSON</button>
<button class="btn btn-secondary btn-sm" onclick="downloadDbTemplate('csv')">⬇️ Sample CSV</button>
<button class="btn btn-danger btn-sm" id="db-clear-btn" style="display:none" onclick="clearCustomDb()">🗑️ Remove Custom DB</button>
</div>
</div>
<!-- Preview table -->
<div class="card">
<div style="display:flex; align-items:center; justify-content:space-between; margin-bottom:12px">
<div style="font-weight:600; font-size:15px">Preview</div>
<span id="db-preview-label" style="font-size:12px; color:var(--text-3)">Showing built-in drugs</span>
</div>
<div class="db-table-wrap" id="db-table-wrap">
<table class="db-table">
<thead><tr><th>#</th><th>Drug Name</th><th>Generic</th><th>Form</th></tr></thead>
<tbody id="db-table-body"></tbody>
</table>
</div>
</div>
</div>
</div>
<!-- ABOUT -->
<div id="section-about" class="section-content hidden">
<div class="section-title" style="margin-bottom:20px">About PrescribePro Rx</div>
<div class="card">
<h2 style="margin-bottom:12px">Dr. Gazi Md Emran Ahmed, MBBS (DU)</h2>
<p style="line-height:1.8">
Note: This project is free for all registered MBBS doctors across the world as a Sadakatul Jariya.
Please do not sell any part of it to any registered doctor.
</p>
<br>
<p style="line-height:1.8">
This app is made with various AI agents. If you find any error please send an email to:
<strong>emranahmed.bd@gmail.com</strong>
</p>
<br>
<p style="line-height:1.8">
Thanks for using this prescription software. Please pray for me, my family, and for all Muslims across the world.
</p>
</div>
</div>
</div><!-- /content -->
</div><!-- /main-layout -->
<!-- ══════════ MODALS ══════════ -->
<!-- Shared frequency datalist for drug rows -->
<datalist id="freq-options">
<option value="১+১+১">১+১+১ (তিনবার)</option>
<option value="১+০+১">১+০+১ (দুইবার)</option>
<option value="১+০+০">১+০+০ (সকাল)</option>
<option value="০+০+১">০+০+১ (রাত)</option>
<option value="০+১+০">০+১+০ (দুপুর)</option>
<option value="০+০+½">০+০+½ (আধা রাত)</option>
<option value="½+০+½">½+০+½ (আধা দুইবার)</option>
<option value="½+½+½">½+½+½ (আধা তিনবার)</option>
<option value="১+১+১+১">১+১+১+১ (চারবার)</option>
<option value="২+২+২">২+২+২ (দুই তিনবার)</option>
<option value="২+০+২">২+০+২ (দুই দুইবার)</option>
<option value="২+২+২+২">২+২+২+২ (দুই চারবার)</option>
<option value="SOS">SOS (প্রয়োজনে)</option>
<option value="Stat">Stat (এখনই)</option>
<option value="প্রতি ৮ ঘণ্টা">প্রতি ৮ ঘণ্টা</option>
<option value="প্রতি ১২ ঘণ্টা">প্রতি ১২ ঘণ্টা</option>
<option value="সপ্তাহে একবার">সপ্তাহে একবার</option>
<option value="প্রতিদিন রাতে">প্রতিদিন রাতে</option>
<option value="প্রতিদিন সকালে">প্রতিদিন সকালে</option>
</datalist>
<!-- Patient Modal -->
<div id="modal-patient" class="modal-overlay hidden">
<div class="modal">
<div class="modal-header">
<div class="modal-title" id="patient-modal-title">New Patient</div>
<button class="modal-close" onclick="closeModal('modal-patient')">✕</button>
</div>
<div class="modal-body">
<div class="form-grid">
<div class="form-group"><label>Full Name *</label><input type="text" id="p-name" placeholder="Patient full name"></div>
<div class="form-group"><label>Age</label><input type="text" id="p-age" placeholder="25 years / 6 months"></div>
<div class="form-group"><label>Gender</label>
<select id="p-gender"><option value="Male">Male</option><option value="Female">Female</option><option value="Other">Other</option></select>
</div>
<div class="form-group"><label>Weight (kg)</label><input type="number" id="p-weight" placeholder="70"></div>
<div class="form-group"><label>Blood Group</label>
<select id="p-blood"><option value="">Unknown</option><option>A+</option><option>A-</option><option>B+</option><option>B-</option><option>AB+</option><option>AB-</option><option>O+</option><option>O-</option></select>
</div>
<div class="form-group"><label>Contact Number</label><input type="tel" id="p-contact" placeholder="+880..."></div>
<div class="form-group full"><label>Allergies / Known Conditions</label><input type="text" id="p-allergies" placeholder="e.g. Penicillin allergy, Diabetes"></div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" onclick="closeModal('modal-patient')">Cancel</button>
<button class="btn btn-primary" onclick="savePatient()">Save Patient</button>
</div>
</div>
</div>
<!-- Prescription Modal -->
<div id="modal-rx" class="modal-overlay hidden">
<div class="modal" style="max-width:820px">
<div class="modal-header">
<div>
<div class="modal-title">Write Prescription</div>
<div class="text-muted" id="rx-for-patient" style="margin-top:4px"></div>
</div>
<button class="modal-close" onclick="closeModal('modal-rx')">✕</button>
</div>
<div class="modal-body">
<!-- Select patient if not pre-selected -->
<div id="rx-select-patient-wrap" class="form-group" style="margin-bottom:16px">
<label>Patient</label>
<select id="rx-patient-select" onchange="updateRxPatientLabel()">
<option value="">-- Select Patient --</option>
</select>
</div>
<div class="form-grid" style="margin-bottom:14px">
<div class="form-group"><label>Date</label><input type="date" id="rx-date"></div>
<div class="form-group"><label>Visit Type</label>
<select id="rx-visit"><option>New Visit</option><option>Follow-up</option><option>Emergency</option></select>
</div>
</div>
<div class="form-group" style="margin-bottom:12px"><label>Chief Complaints</label><textarea id="rx-complaints" placeholder="Patient's main complaints..."></textarea></div>
<div class="form-group" style="margin-bottom:12px"><label>🩺 Diagnosis</label><textarea id="rx-diagnosis" placeholder="Primary diagnosis, differential diagnosis..." style="min-height:60px; border-color: var(--accent); background: #f0f6fb;"></textarea></div>
<div class="form-group" style="margin-bottom:12px"><label>History</label><textarea id="rx-history" placeholder="Relevant history (past medical, drug, family)..."></textarea></div>
<div class="form-group" style="margin-bottom:12px"><label>Examination Findings</label><textarea id="rx-findings" placeholder="Vital signs, physical examination findings..."></textarea></div>
<div class="form-group" style="margin-bottom:12px"><label>Investigation / Advice</label><textarea id="rx-investigation" placeholder="Lab tests, imaging recommended..."></textarea></div>
<div class="form-group" style="margin-bottom:12px"><label>Advice to Patient</label><textarea id="rx-advice" placeholder="Dietary advice, lifestyle modifications..."></textarea></div>
<hr class="divider">
<div style="font-weight:600; font-size:14px; margin-bottom:10px">💊 Medications (Rx)</div>
<div id="drug-rows"></div>
<button class="btn btn-secondary btn-sm" onclick="addDrugRow()" style="margin-top:4px">+ Add Medication</button>
<hr class="divider">
<div class="form-grid">
<div class="form-group">
<label>Follow-up After</label>
<div class="form-row">
<input type="number" id="rx-followup-days" placeholder="7" style="width:80px; flex-shrink:0">
<select id="rx-followup-unit" style="width:auto">
<option value="days">days</option>
<option value="weeks">weeks</option>
<option value="months">months</option>
</select>
</div>
</div>
<div class="form-group"><label>Special Notes</label><input type="text" id="rx-notes" placeholder="Any special instructions..."></div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" onclick="closeModal('modal-rx')">Cancel</button>
<button class="btn btn-primary" onclick="previewRx()">Preview & Generate PDF</button>
</div>
</div>
</div>
<!-- Rx Preview Modal -->
<div id="modal-rx-preview" class="modal-overlay hidden">
<div class="modal" style="max-width:900px; max-height:95vh">
<div class="modal-header">
<div class="modal-title">Prescription Preview</div>
<button class="modal-close" onclick="closeModal('modal-rx-preview')">✕</button>
</div>
<div class="modal-body" style="padding:0; overflow:auto; max-height:70vh">
<div id="rx-preview-wrap">
<div id="rx-a4"></div>
</div>
</div>
<div class="modal-footer" style="gap:10px">
<button class="btn btn-secondary" onclick="editRx()">← Edit</button>
<button class="btn btn-secondary" onclick="printRx()">🖨️ Print</button>
<button class="btn btn-secondary" onclick="saveRxImage()">🖼️ Save as Image</button>
<button class="btn btn-success" onclick="saveRxPDF()">📄 Save as PDF</button>
<button class="btn btn-primary" onclick="saveRxAndClose()">✅ Save & Close</button>
</div>
</div>
</div>
<!-- Toast -->
<div id="toast"></div>
<!-- ══════════════════════════ SCRIPT ══════════════════════════ -->
<script>
// ── STATE ──
let state = {
loggedIn: false,
user: { name: 'Dr. Someone', email: '', initials: 'DS' },
profile: {
name: 'Dr. Someone',
qualifications: 'Your Qualifications (e.g. MBBS)',
designation: 'Your Designation',
hospital: 'Your Hospital / Chamber Name / Location',
reg: 'Regi: 000000',
phone: '',
address: '',
hours: '',
footer: 'নিয়ম মাফিক ঔষধ খাবেন। ডাক্তারের পরামর্শ ব্যতীত ঔষধ পরিবর্তন নিষেধ।',
chamberName: '',
chamberPhone: '',
chamberAddr1: '',
chamberAddr2: '',
chamberHours: '',
chamberNote: ''
},
padSettings: { align: 'center', leftWidth: 165, color: '#1a3a5c', showHistory: true, showFindings: true, showInvestigation: true, showAdvice: true, showFollowup: true },
patients: [],
prescriptions: [],
customDrugs: [], // ← uploaded drug database
currentRx: null,
editingPatientId: null
};
// ── DRUG DATABASE (common Bangladesh drugs) ──
const DRUGS = [
{ name: 'Napa', dose: '500mg', generic: 'Paracetamol', company: 'Beximco Pharma', price: '৳1.50/tab', form: 'Tablet' },
{ name: 'Napa Extra', dose: '500mg+65mg', generic: 'Paracetamol + Caffeine', company: 'Beximco Pharma', price: '৳2.00/tab', form: 'Tablet' },
{ name: 'Ace', dose: '500mg', generic: 'Paracetamol', company: 'Square Pharma', price: '৳1.50/tab', form: 'Tablet' },
{ name: 'Ace Plus', dose: '500mg+65mg', generic: 'Paracetamol + Caffeine', company: 'Square Pharma', price: '৳2.00/tab', form: 'Tablet' },
{ name: 'Renova', dose: '500mg', generic: 'Paracetamol', company: 'Renata Ltd', price: '৳1.50/tab', form: 'Tablet' },
{ name: 'Fast', dose: '500mg', generic: 'Paracetamol', company: 'ACI Pharma', price: '৳1.50/tab', form: 'Tablet' },
{ name: 'Seclo', dose: '20mg', generic: 'Omeprazole', company: 'Square Pharma', price: '৳4.00/cap', form: 'Capsule' },
{ name: 'Losectil', dose: '20mg', generic: 'Omeprazole', company: 'Beximco Pharma', price: '৳4.50/cap', form: 'Capsule' },
{ name: 'Omeprazol', dose: '20mg', generic: 'Omeprazole', company: 'ACI Pharma', price: '৳4.00/cap', form: 'Capsule' },
{ name: 'Pantop', dose: '40mg', generic: 'Pantoprazole', company: 'Square Pharma', price: '৳6.00/tab', form: 'Tablet' },
{ name: 'Neopan', dose: '40mg', generic: 'Pantoprazole', company: 'Beximco Pharma', price: '৳6.50/tab', form: 'Tablet' },
{ name: 'Ranitidine', dose: '150mg', generic: 'Ranitidine HCl', company: 'Various', price: '৳2.00/tab', form: 'Tablet' },
{ name: 'Amoxil', dose: '500mg', generic: 'Amoxicillin', company: 'Square Pharma', price: '৳8.00/cap', form: 'Capsule' },
{ name: 'Moxacil', dose: '500mg', generic: 'Amoxicillin', company: 'Beximco Pharma', price: '৳8.00/cap', form: 'Capsule' },
{ name: 'Zithromax', dose: '500mg', generic: 'Azithromycin', company: 'Square Pharma', price: '৳50.00/tab', form: 'Tablet' },
{ name: 'Azifast', dose: '500mg', generic: 'Azithromycin', company: 'Beximco Pharma', price: '৳48.00/tab', form: 'Tablet' },
{ name: 'Zimax', dose: '500mg', generic: 'Azithromycin', company: 'Renata Ltd', price: '৳50.00/tab', form: 'Tablet' },
{ name: 'Ciprocin', dose: '500mg', generic: 'Ciprofloxacin', company: 'Square Pharma', price: '৳12.00/tab', form: 'Tablet' },
{ name: 'Ciproflox', dose: '500mg', generic: 'Ciprofloxacin', company: 'Beximco Pharma', price: '৳12.00/tab', form: 'Tablet' },
{ name: 'Flagyl', dose: '400mg', generic: 'Metronidazole', company: 'Square Pharma', price: '৳3.00/tab', form: 'Tablet' },
{ name: 'Amodis', dose: '400mg', generic: 'Metronidazole', company: 'Beximco Pharma', price: '৳3.00/tab', form: 'Tablet' },
{ name: 'Claritek', dose: '500mg', generic: 'Clarithromycin', company: 'Square Pharma', price: '৳60.00/tab', form: 'Tablet' },
{ name: 'Cef-3', dose: '200mg', generic: 'Cefixime', company: 'Beximco Pharma', price: '৳30.00/tab', form: 'Tablet' },
{ name: 'Cefix', dose: '200mg', generic: 'Cefixime', company: 'Square Pharma', price: '৳30.00/tab', form: 'Tablet' },
{ name: 'Cefixim', dose: '200mg', generic: 'Cefixime', company: 'Renata Ltd', price: '৳28.00/tab', form: 'Tablet' },
{ name: 'Zinnat', dose: '500mg', generic: 'Cefuroxime', company: 'GSK', price: '৳80.00/tab', form: 'Tablet' },
{ name: 'Doxacin', dose: '100mg', generic: 'Doxycycline', company: 'Square Pharma', price: '৳7.00/cap', form: 'Capsule' },
{ name: 'Glucomin', dose: '500mg', generic: 'Metformin HCl', company: 'Square Pharma', price: '৳3.00/tab', form: 'Tablet' },
{ name: 'Metmin', dose: '500mg', generic: 'Metformin HCl', company: 'Beximco Pharma', price: '৳2.50/tab', form: 'Tablet' },
{ name: 'Amaryl', dose: '2mg', generic: 'Glimepiride', company: 'Sanofi-Aventis', price: '৳15.00/tab', form: 'Tablet' },
{ name: 'Glimepid', dose: '2mg', generic: 'Glimepiride', company: 'Square Pharma', price: '৳12.00/tab', form: 'Tablet' },
{ name: 'Amdocal', dose: '5mg', generic: 'Amlodipine', company: 'Square Pharma', price: '৳4.00/tab', form: 'Tablet' },
{ name: 'Amlong', dose: '5mg', generic: 'Amlodipine', company: 'Beximco Pharma', price: '৳4.00/tab', form: 'Tablet' },
{ name: 'Aten', dose: '50mg', generic: 'Atenolol', company: 'Square Pharma', price: '৳3.00/tab', form: 'Tablet' },
{ name: 'Losartan', dose: '50mg', generic: 'Losartan Potassium', company: 'Square Pharma', price: '৳8.00/tab', form: 'Tablet' },
{ name: 'Losacar', dose: '50mg', generic: 'Losartan Potassium', company: 'Beximco Pharma', price: '৳8.00/tab', form: 'Tablet' },
{ name: 'Atova', dose: '10mg', generic: 'Atorvastatin', company: 'Square Pharma', price: '৳10.00/tab', form: 'Tablet' },
{ name: 'Lipitor', dose: '10mg', generic: 'Atorvastatin', company: 'Pfizer', price: '৳35.00/tab', form: 'Tablet' },
{ name: 'Ecotrin', dose: '75mg', generic: 'Aspirin', company: 'Square Pharma', price: '৳2.00/tab', form: 'Tablet' },
{ name: 'Folic', dose: '5mg', generic: 'Folic Acid', company: 'Square Pharma', price: '৳1.00/tab', form: 'Tablet' },
{ name: 'C-Vit', dose: '500mg', generic: 'Ascorbic Acid', company: 'Square Pharma', price: '৳3.00/tab', form: 'Tablet' },
{ name: 'Zink', dose: '20mg', generic: 'Zinc Sulphate', company: 'Square Pharma', price: '৳2.00/tab', form: 'Tablet' },
{ name: 'Calbo-D', dose: '500mg+200IU', generic: 'Calcium + Cholecalciferol', company: 'Square Pharma', price: '৳8.00/tab', form: 'Tablet' },
{ name: 'Cetriz', dose: '10mg', generic: 'Cetirizine HCl', company: 'Square Pharma', price: '৳4.00/tab', form: 'Tablet' },
{ name: 'Alatrol', dose: '10mg', generic: 'Cetirizine HCl', company: 'Renata Ltd', price: '৳4.00/tab', form: 'Tablet' },
{ name: 'Loratin', dose: '10mg', generic: 'Loratadine', company: 'Square Pharma', price: '৳4.00/tab', form: 'Tablet' },
{ name: 'Fexo', dose: '120mg', generic: 'Fexofenadine HCl', company: 'Square Pharma', price: '৳12.00/tab', form: 'Tablet' },
{ name: 'Prednisolone', dose: '5mg', generic: 'Prednisolone', company: 'Square Pharma', price: '৳2.00/tab', form: 'Tablet' },
{ name: 'Dexamethasone', dose: '0.5mg', generic: 'Dexamethasone', company: 'Square Pharma', price: '৳1.50/tab', form: 'Tablet' },
{ name: 'Brufen', dose: '400mg', generic: 'Ibuprofen', company: 'Abbott', price: '৳5.00/tab', form: 'Tablet' },
{ name: 'Profen', dose: '400mg', generic: 'Ibuprofen', company: 'Square Pharma', price: '৳4.00/tab', form: 'Tablet' },
{ name: 'Voveran', dose: '50mg', generic: 'Diclofenac Sodium', company: 'Novartis', price: '৳6.00/tab', form: 'Tablet' },
{ name: 'Diclofen', dose: '50mg', generic: 'Diclofenac Sodium', company: 'Square Pharma', price: '৳4.00/tab', form: 'Tablet' },
{ name: 'Naprox', dose: '500mg', generic: 'Naproxen', company: 'Square Pharma', price: '৳8.00/tab', form: 'Tablet' },
{ name: 'Tramadol', dose: '50mg', generic: 'Tramadol HCl', company: 'Square Pharma', price: '৳10.00/cap', form: 'Capsule' },
{ name: 'Gabator', dose: '300mg', generic: 'Gabapentin', company: 'Square Pharma', price: '৳20.00/cap', form: 'Capsule' },
{ name: 'Rivotril', dose: '0.5mg', generic: 'Clonazepam', company: 'Roche', price: '৳15.00/tab', form: 'Tablet' },
{ name: 'Sedil', dose: '5mg', generic: 'Diazepam', company: 'Square Pharma', price: '৳3.00/tab', form: 'Tablet' },
{ name: 'Motigut', dose: '10mg', generic: 'Domperidone', company: 'Square Pharma', price: '৳3.00/tab', form: 'Tablet' },
{ name: 'Maxeron', dose: '10mg', generic: 'Metoclopramide', company: 'Square Pharma', price: '৳2.00/tab', form: 'Tablet' },
{ name: 'Ondem', dose: '4mg', generic: 'Ondansetron', company: 'Beximco Pharma', price: '৳20.00/tab', form: 'Tablet' },
{ name: 'Imodium', dose: '2mg', generic: 'Loperamide', company: 'Janssen', price: '৳5.00/cap', form: 'Capsule' },
{ name: 'ORS', dose: '—', generic: 'Oral Rehydration Salts', company: 'Various', price: '৳10.00/pkt', form: 'Sachet' },
{ name: 'Terbinafine', dose: '250mg', generic: 'Terbinafine HCl', company: 'Square Pharma', price: '৳25.00/tab', form: 'Tablet' },
{ name: 'Diflucan', dose: '150mg', generic: 'Fluconazole', company: 'Pfizer', price: '৳45.00/cap', form: 'Capsule' },
{ name: 'Salbulin', dose: '2mg', generic: 'Salbutamol', company: 'Square Pharma', price: '৳2.00/tab', form: 'Tablet' },
{ name: 'Theophyl', dose: '200mg', generic: 'Theophylline', company: 'Square Pharma', price: '৳4.00/tab', form: 'Tablet' },
{ name: 'Montair', dose: '10mg', generic: 'Montelukast', company: 'Cipla', price: '৳35.00/tab', form: 'Tablet' },
{ name: 'Euthyrox', dose: '50mcg', generic: 'Levothyroxine', company: 'Merck', price: '৳5.00/tab', form: 'Tablet' },
{ name: 'Ferrograd', dose: '325mg', generic: 'Ferrous Sulphate', company: 'Abbott', price: '৳5.00/tab', form: 'Tablet' },
{ name: 'Almex', dose: '400mg', generic: 'Albendazole', company: 'Square Pharma', price: '৳15.00/tab', form: 'Tablet' },
{ name: 'Nystatin', dose: '500,000 IU', generic: 'Nystatin', company: 'Square Pharma', price: '৳8.00/tab', form: 'Tablet' },
{ name: 'Betnovate', dose: '0.1%', generic: 'Betamethasone', company: 'GSK', price: '৳40.00/tube', form: 'Cream' },
{ name: 'Hydrocort', dose: '1%', generic: 'Hydrocortisone', company: 'Square Pharma', price: '৳30.00/tube', form: 'Cream' },
{ name: 'Canesten', dose: '1%', generic: 'Clotrimazole', company: 'Bayer', price: '৳45.00/tube', form: 'Cream' },
{ name: 'Fucidin', dose: '2%', generic: 'Fusidic Acid', company: 'LEO Pharma', price: '৳80.00/tube', form: 'Cream' },
{ name: 'Bactroban', dose: '2%', generic: 'Mupirocin', company: 'GSK', price: '৳120.00/tube', form: 'Cream' },
{ name: 'Ciloxan', dose: '0.3%', generic: 'Ciprofloxacin', company: 'Alcon', price: '৳60.00/drop', form: 'Eye Drop' },
{ name: 'Paracetamol Syrup', dose: '120mg/5ml', generic: 'Paracetamol', company: 'Beximco Pharma', price: '৳35.00/btl', form: 'Syrup' },
{ name: 'Amoxil Syrup', dose: '125mg/5ml', generic: 'Amoxicillin', company: 'Square Pharma', price: '৳60.00/btl', form: 'Syrup' },
{ name: 'Zinnat Syrup', dose: '125mg/5ml', generic: 'Cefuroxime', company: 'GSK', price: '৳180.00/btl', form: 'Syrup' },
{ name: 'Salbutamol Inhaler', dose: '100mcg/puff', generic: 'Salbutamol', company: 'GSK', price: '৳180.00/inhaler', form: 'Inhaler' },
{ name: 'Insulin Mixtard', dose: '30/70', generic: 'Biphasic Insulin', company: 'Novo Nordisk', price: '৳450.00/vial', form: 'Injection' },
{ name: 'Heparin', dose: '5000IU/ml', generic: 'Heparin Sodium', company: 'Various', price: '৳120.00/amp', form: 'Injection' },
];
// ── PERSISTENCE — keyed per Google account so different doctors don't share data ──
function getStorageKey() {
const email = (state.user && state.user.email) ? state.user.email : 'default';
return 'prescribepro_state_' + email;
}
function saveState() {
localStorage.setItem(getStorageKey(), JSON.stringify(state));
// Also keep a lightweight "last logged in email" pointer for seamless reload
if (state.user && state.user.email) {
localStorage.setItem('prescribepro_last_email', state.user.email);
}
}
function loadState() {
// Try to load for the last known email first; fallback to legacy key
const lastEmail = localStorage.getItem('prescribepro_last_email');
const key = lastEmail ? ('prescribepro_state_' + lastEmail) : 'prescribepro_state';
const s = localStorage.getItem(key) || localStorage.getItem('prescribepro_state');
if (s) {
const loaded = JSON.parse(s);
Object.assign(state, loaded);
}
}
// ── INIT ──
loadState();
if (state.loggedIn) {
showApp();
// For returning users: Drive token is gone (page reload), mark offline until re-auth
updateDriveStatus(false);
} else {
updateGreeting();
}
function updateGreeting() {
const h = new Date().getHours();
const g = h < 12 ? 'Good morning' : h < 17 ? 'Good afternoon' : 'Good evening';
const el = document.getElementById('greeting-sub');
if (el) el.textContent = `${g}, ${state.profile.name || 'Doctor'}`;
}
// ── GOOGLE AUTH ──
const GOOGLE_CLIENT_ID = '744204331957-vnium3sdih08go5iuv0rlpctvgqhjara.apps.googleusercontent.com';
// Single combined scope: identity + Drive appdata — ONE popup, ONE consent screen
const GOOGLE_SCOPES = 'openid profile email https://www.googleapis.com/auth/drive.appdata';
// Drive file name is per-account so each doctor's profile is isolated
function getDriveFileName() {
const email = (state.user && state.user.email) ? state.user.email.replace(/[^a-zA-Z0-9]/g, '_') : 'default';
return `prescribepro_backup_${email}.json`;
}
let googleAccessToken = null;
let tokenClient = null;
function initGoogleAuth() {
if (typeof google === 'undefined' || !google.accounts || tokenClient) return;
tokenClient = google.accounts.oauth2.initTokenClient({
client_id: GOOGLE_CLIENT_ID,