Nischal Subedi commited on
Commit
89f2428
·
1 Parent(s): f6c4512
Files changed (1) hide show
  1. app.py +132 -78
app.py CHANGED
@@ -276,7 +276,6 @@ Answer:"""
276
  print(f"DEBUG: Error loading states for selection: {e}")
277
  radio_choices = ["Error: Critical failure loading states"]
278
  initial_value_radio = None
279
-
280
  example_queries_base = [
281
  ["What are the rules for security deposit returns?", "California"],
282
  ["Can a landlord enter my apartment without notice?", "New York"],
@@ -297,35 +296,79 @@ Answer:"""
297
  /* Import legible fonts from Google Fonts */
298
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@600;700;800&display=swap');
299
 
300
- /* Root variables for consistent light theme */
301
  :root {
302
- --primary-color: #FF8C00;
303
- --primary-hover: #E07B00;
304
- --background-primary: hsl(30, 100%, 99.9%);
305
- --background-secondary: hsl(30, 100%, 96%);
306
- --text-primary: #3A2F28; /* Darkened slightly for better contrast */
307
- --text-secondary: #8C7B6F;
308
- --border-color: hsl(30, 70%, 85%);
309
- --border-focus: #FF8C00;
310
- --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
311
- --shadow-md: 0 4px 10px rgba(0,0,0,0.1);
312
- --shadow-lg: 0 10px 20px rgba(0,0,0,0.15);
313
- --error-bg: #FFF0E0;
314
- --error-border: #FFD2B2;
315
- --error-text: #E05C00;
316
- }
317
-
318
- body, html {
319
- background-color: var(--background-primary) !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  color: var(--text-primary) !important;
321
- transition: none !important;
 
 
322
  }
323
  .gradio-container {
324
  max-width: 900px !important;
325
  margin: 0 auto !important;
326
  padding: 1.5rem !important;
327
- font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
328
- background-color: var(--background-primary) !important;
329
  box-shadow: none !important;
330
  color: var(--text-primary) !important;
331
  }
@@ -333,21 +376,37 @@ Answer:"""
333
  background-color: var(--background-primary) !important;
334
  }
335
  .app-header-wrapper {
336
- background-color: var(--background-primary) !important;
337
  border: 2px solid var(--border-color) !important;
338
  border-radius: 16px !important;
339
  padding: 2.5rem 1.5rem !important;
340
  margin-bottom: 1.5rem !important;
341
  box-shadow: var(--shadow-md) !important;
 
 
342
  text-align: center !important;
343
  color: var(--text-primary) !important;
344
  }
 
 
 
 
 
 
 
 
 
 
 
 
345
  .app-header-logo {
346
  font-size: 8.5rem !important;
347
  margin-bottom: 0.75rem !important;
348
  display: block !important;
349
  color: var(--primary-color) !important;
350
- animation: float-icon 3s ease-in-out infinite alternate;
 
 
351
  }
352
  @keyframes float-icon {
353
  0% { transform: translateY(0px); }
@@ -362,22 +421,25 @@ Answer:"""
362
  margin: 0 0 0.75rem 0 !important;
363
  line-height: 1.1 !important;
364
  letter-spacing: -0.03em !important;
365
- display: inline-block;
366
- max-width: 100%;
 
 
367
  }
368
  .app-header-tagline {
369
  font-size: 1.25rem !important;
370
  color: var(--text-secondary) !important;
371
  font-weight: 400 !important;
372
  margin: 0 !important;
373
- max-width: 700px;
374
- display: inline-block;
 
 
375
  }
376
  .main-dashboard-container {
377
  display: flex !important;
378
  flex-direction: column !important;
379
  gap: 1.25rem !important;
380
- background-color: var(--background-primary) !important;
381
  }
382
  .dashboard-card-section {
383
  background-color: var(--background-primary) !important;
@@ -385,8 +447,8 @@ Answer:"""
385
  border-radius: 12px !important;
386
  padding: 0 !important;
387
  box-shadow: var(--shadow-sm) !important;
388
- transition: all 0.3s ease-out !important;
389
- cursor: default;
390
  color: var(--text-primary) !important;
391
  }
392
  .dashboard-card-section:hover {
@@ -399,17 +461,17 @@ Answer:"""
399
  align-items: center !important;
400
  width: 100% !important;
401
  flex-direction: column !important;
402
- background-color: var(--background-primary) !important;
403
  }
404
  .section-title-gradient-bar {
405
- background-color: var(--background-primary) !important;
406
  padding: 1.25rem 1.75rem !important;
407
  border-top-left-radius: 10px !important;
408
  border-top-right-radius: 10px !important;
409
  margin-bottom: 0 !important;
410
  text-align: center !important;
411
- box-sizing: border-box;
412
- width: 100%;
413
  color: var(--text-primary) !important;
414
  }
415
  .section-title {
@@ -428,8 +490,8 @@ Answer:"""
428
  .dashboard-card-content-area {
429
  padding: 0 1.75rem 1.75rem 1.75rem !important;
430
  background-color: var(--background-primary) !important;
431
- box-sizing: border-box;
432
- width: 100%;
433
  color: var(--text-primary) !important;
434
  }
435
  .dashboard-card-section p {
@@ -447,13 +509,13 @@ Answer:"""
447
  color: var(--primary-color) !important;
448
  }
449
  .gr-block, .gr-box, .gr-prose, .gr-form, .gr-panel,
450
- .gr-columns, .gr-column,
451
- .gradio-html, .gradio-markdown, .gradio-textbox, .gradio-radio, .gradio-button {
452
  background-color: transparent !important;
453
  color: var(--text-primary) !important;
454
  white-space: normal !important;
455
- overflow-wrap: break-word;
456
- word-break: break-word;
457
  }
458
  .gradio-textbox textarea,
459
  .gradio-textbox input,
@@ -526,9 +588,7 @@ Answer:"""
526
  box-shadow: var(--shadow-md) !important;
527
  transform: translateY(-1px) !important;
528
  }
529
- .gradio-radio input
530
-
531
- [type="radio"]:checked + label span.text-lg {
532
  color: white !important;
533
  }
534
  .gradio-radio .gr-form {
@@ -594,7 +654,7 @@ Answer:"""
594
  .gr-button-secondary {
595
  background-color: transparent !important;
596
  color: var(--text-primary) !important;
597
- border-color: var(--border-color) !important;
598
  }
599
  .gr-button-secondary:hover {
600
  background-color: var(--background-secondary) !important;
@@ -612,18 +672,18 @@ Answer:"""
612
  padding: 1.5rem !important;
613
  min-height: 150px !important;
614
  color: var(--text-primary) !important;
615
- display: flex;
616
- flex-direction: column;
617
- justify-content: center;
618
- align-items: center;
619
  }
620
  .animated-output-content {
621
- opacity: 0;
622
- animation: fadeInAndSlideUp 0.7s ease-out forwards;
623
- width: 100%;
624
- white-space: pre-wrap;
625
- overflow-wrap: break-word;
626
- word-break: break-word;
627
  text-align: left !important;
628
  color: var(--text-primary) !important;
629
  }
@@ -640,8 +700,8 @@ Answer:"""
640
  align-items: center !important;
641
  gap: 0.6rem !important;
642
  text-align: left !important;
643
- width: 100%;
644
- justify-content: flex-start;
645
  }
646
  .response-icon {
647
  font-size: 1.5rem !important;
@@ -665,8 +725,8 @@ Answer:"""
665
  font-weight: 500 !important;
666
  line-height: 1.6 !important;
667
  text-align: left !important;
668
- width: 100%;
669
- box-sizing: border-box;
670
  }
671
  .error-message a {
672
  color: var(--error-text) !important;
@@ -681,7 +741,7 @@ Answer:"""
681
  font-size: 0.85rem !important;
682
  color: var(--error-text) !important;
683
  margin-top: 0.5rem !important;
684
- opacity: 0.8;
685
  }
686
  .placeholder {
687
  background-color: var(--background-primary) !important;
@@ -692,8 +752,8 @@ Answer:"""
692
  color: var(--text-secondary) !important;
693
  font-style: italic !important;
694
  font-size: 1.1rem !important;
695
- width: 100%;
696
- box-sizing: border-box;
697
  }
698
  .examples-section .gr-samples-table {
699
  border: 2px solid var(--border-color) !important;
@@ -723,7 +783,7 @@ Answer:"""
723
  }
724
  .examples-section .gr-samples-table tr:hover td {
725
  background-color: var(--background-secondary) !important;
726
- transform: translateX(5px);
727
  }
728
  .gr-examples .gr-label,
729
  .gr-examples .label-wrap,
@@ -731,7 +791,7 @@ Answer:"""
731
  display: none !important;
732
  }
733
  .app-footer-wrapper {
734
- background-color: var(--background-primary) !important;
735
  border: 2px solid var(--border-color) !important;
736
  border-radius: 12px !important;
737
  padding: 1.75rem !important;
@@ -754,12 +814,12 @@ Answer:"""
754
  font-weight: 700 !important;
755
  color: var(--primary-color) !important;
756
  }
757
- .app-footer a {
758
  color: var(--primary-color) !important;
759
  text-decoration: underline !important;
760
- font-weight: 600 !important;
761
  }
762
- .app-footer a:hover {
763
  text-decoration: none !important;
764
  }
765
  @media (max-width: 768px) {
@@ -800,7 +860,7 @@ Answer:"""
800
  }
801
  """
802
 
803
- with gr.Blocks(css=custom_css, title="Landlord-Tenant Rights Assistant") as demo:
804
  with gr.Group(elem_classes="app-header-wrapper"):
805
  gr.Markdown(
806
  """
@@ -889,17 +949,11 @@ Answer:"""
889
  # Footer Section
890
  with gr.Group(elem_classes="app-footer-wrapper"):
891
  gr.Markdown(
892
- f"""
893
- <style>
894
- .custom-link {{
895
- font-weight: bold !important;
896
- color: var(--primary-color) !important;
897
- text-decoration: underline;
898
- }}
899
- </style>
900
  <p><strong>Disclaimer:</strong> This tool is for informational purposes only and does not constitute legal advice. For specific legal guidance, always consult with a licensed attorney in your jurisdiction.</p>
901
  <p>Developed by <strong>Nischal Subedi</strong>. Connect on <a href="https://www.linkedin.com/in/nischal1/" target="_blank" class="custom-link">LinkedIn</a> or explore insights at <a href="https://datascientistinsights.substack.com/" target="_blank" class="custom-link">Substack</a>.</p>
902
- """
 
903
  )
904
 
905
  submit_button.click(
 
276
  print(f"DEBUG: Error loading states for selection: {e}")
277
  radio_choices = ["Error: Critical failure loading states"]
278
  initial_value_radio = None
 
279
  example_queries_base = [
280
  ["What are the rules for security deposit returns?", "California"],
281
  ["Can a landlord enter my apartment without notice?", "New York"],
 
296
  /* Import legible fonts from Google Fonts */
297
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@600;700;800&display=swap');
298
 
299
+ /* Enforce light theme globally */
300
  :root {
301
+ color-scheme: light !important;
302
+ --primary-color: #FF8C00 !important;
303
+ --primary-hover: #E07B00 !important;
304
+ --background-primary: hsl(30, 100%, 99.9%) !important;
305
+ --background-secondary: hsl(30, 100%, 96%) !important;
306
+ --text-primary: #4A3C32 !important;
307
+ --text-secondary: #8C7B6F !important;
308
+ --border-color: hsl(30, 70%, 85%) !important;
309
+ --border-focus: #FF8C00 !important;
310
+ --shadow-sm: 0 1px 3px rgba(0,0,0,0.08) !important;
311
+ --shadow-md: 0 4px 10px rgba(0,0,0,0.1) !important;
312
+ --shadow-lg: 0 10px 20px rgba(0,0,0,0.15) !important;
313
+ --error-bg: #FFF0E0 !important;
314
+ --error-border: #FFD2B2 !important;
315
+ --error-text: #E05C00 !important;
316
+ }
317
+
318
+ /* Override browser dark mode completely */
319
+ @media (prefers-color-scheme: dark) {
320
+ :root, html, body, .gradio-container, .main-dashboard-container > *,
321
+ .dashboard-card-section, .section-title-gradient-bar,
322
+ .dashboard-card-content-area, .gradio-textbox textarea,
323
+ .gradio-textbox input, .gradio-radio label, .placeholder,
324
+ .output-content-wrapper, .gr-samples-table, .gr-samples-table th,
325
+ .gr-samples-table td, .app-footer-wrapper, .gradio-button,
326
+ .gr-button-primary, .gr-button-secondary, .gr-block, .gr-box,
327
+ .gr-prose, .gr-form, .gr-panel, .gr-columns, .gr-column,
328
+ .gradio-html, .gradio-markdown, .gradio-textbox, .gradio-radio {
329
+ color-scheme: light !important;
330
+ background-color: var(--background-primary) !important;
331
+ color: var(--text-primary) !important;
332
+ border-color: var(--border-color) !important;
333
+ }
334
+ .gr-button-primary {
335
+ background-color: var(--primary-color) !important;
336
+ color: white !important;
337
+ }
338
+ .gr-button-secondary {
339
+ background-color: transparent !important;
340
+ border-color: var(--border-color) !important;
341
+ color: var(--text-primary) !important;
342
+ }
343
+ .error-message, .error-message a {
344
+ background-color: var(--error-bg) !important;
345
+ color: var(--error-text) !important;
346
+ border-color: var(--error-border) !important;
347
+ }
348
+ .response-header, .response-icon, .dashboard-card-section strong,
349
+ .dashboard-card-section b, .app-footer strong, .app-footer b,
350
+ .app-footer a, .custom-link {
351
+ color: var(--primary-color) !important;
352
+ }
353
+ }
354
+
355
+ /* Base styles for all elements */
356
+ *, *:before, *:after {
357
+ box-sizing: border-box !important;
358
+ color-scheme: light !important;
359
+ }
360
+ html, body {
361
+ background-color: var(--background-secondary) !important;
362
  color: var(--text-primary) !important;
363
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
364
+ margin: 0 !important;
365
+ padding: 0 !important;
366
  }
367
  .gradio-container {
368
  max-width: 900px !important;
369
  margin: 0 auto !important;
370
  padding: 1.5rem !important;
371
+ background-color: var(--background-secondary) !important;
 
372
  box-shadow: none !important;
373
  color: var(--text-primary) !important;
374
  }
 
376
  background-color: var(--background-primary) !important;
377
  }
378
  .app-header-wrapper {
379
+ background: linear-gradient(145deg, var(--background-primary) 0%, var(--background-secondary) 100%) !important;
380
  border: 2px solid var(--border-color) !important;
381
  border-radius: 16px !important;
382
  padding: 2.5rem 1.5rem !important;
383
  margin-bottom: 1.5rem !important;
384
  box-shadow: var(--shadow-md) !important;
385
+ position: relative !important;
386
+ overflow: hidden !important;
387
  text-align: center !important;
388
  color: var(--text-primary) !important;
389
  }
390
+ .app-header-wrapper::before {
391
+ content: '';
392
+ position: absolute;
393
+ top: 0;
394
+ left: 0;
395
+ width: 100%;
396
+ height: 100%;
397
+ background: radial-gradient(circle at top left, rgba(255,140,0,0.3) 0%, transparent 60%), radial-gradient(circle at bottom right, rgba(255,140,0,0.3) 0%, transparent 60%) !important;
398
+ z-index: 0 !important;
399
+ opacity: 0.8 !important;
400
+ pointer-events: none !important;
401
+ }
402
  .app-header-logo {
403
  font-size: 8.5rem !important;
404
  margin-bottom: 0.75rem !important;
405
  display: block !important;
406
  color: var(--primary-color) !important;
407
+ position: relative !important;
408
+ z-index: 1 !important;
409
+ animation: float-icon 3s ease-in-out infinite alternate !important;
410
  }
411
  @keyframes float-icon {
412
  0% { transform: translateY(0px); }
 
421
  margin: 0 0 0.75rem 0 !important;
422
  line-height: 1.1 !important;
423
  letter-spacing: -0.03em !important;
424
+ position: relative !important;
425
+ z-index: 1 !important;
426
+ display: inline-block !important;
427
+ max-width: 100% !important;
428
  }
429
  .app-header-tagline {
430
  font-size: 1.25rem !important;
431
  color: var(--text-secondary) !important;
432
  font-weight: 400 !important;
433
  margin: 0 !important;
434
+ max-width: 700px !important;
435
+ display: inline-block !important;
436
+ position: relative !important;
437
+ z-index: 1 !important;
438
  }
439
  .main-dashboard-container {
440
  display: flex !important;
441
  flex-direction: column !important;
442
  gap: 1.25rem !important;
 
443
  }
444
  .dashboard-card-section {
445
  background-color: var(--background-primary) !important;
 
447
  border-radius: 12px !important;
448
  padding: 0 !important;
449
  box-shadow: var(--shadow-sm) !important;
450
+ transition: box-shadow 0.3s ease-out, transform 0.3s ease-out !important;
451
+ cursor: default !important;
452
  color: var(--text-primary) !important;
453
  }
454
  .dashboard-card-section:hover {
 
461
  align-items: center !important;
462
  width: 100% !important;
463
  flex-direction: column !important;
464
+ background-color: transparent !important;
465
  }
466
  .section-title-gradient-bar {
467
+ background-color: var(--background-secondary) !important;
468
  padding: 1.25rem 1.75rem !important;
469
  border-top-left-radius: 10px !important;
470
  border-top-right-radius: 10px !important;
471
  margin-bottom: 0 !important;
472
  text-align: center !important;
473
+ box-sizing: border-box !important;
474
+ width: 100% !important;
475
  color: var(--text-primary) !important;
476
  }
477
  .section-title {
 
490
  .dashboard-card-content-area {
491
  padding: 0 1.75rem 1.75rem 1.75rem !important;
492
  background-color: var(--background-primary) !important;
493
+ box-sizing: border-box !important;
494
+ width: 100% !important;
495
  color: var(--text-primary) !important;
496
  }
497
  .dashboard-card-section p {
 
509
  color: var(--primary-color) !important;
510
  }
511
  .gr-block, .gr-box, .gr-prose, .gr-form, .gr-panel,
512
+ .gr-columns, .gr-column, .gradio-html, .gradio-markdown,
513
+ .gradio-textbox, .gradio-radio, .gradio-button {
514
  background-color: transparent !important;
515
  color: var(--text-primary) !important;
516
  white-space: normal !important;
517
+ overflow-wrap: break-word !important;
518
+ word-break: break-word !important;
519
  }
520
  .gradio-textbox textarea,
521
  .gradio-textbox input,
 
588
  box-shadow: var(--shadow-md) !important;
589
  transform: translateY(-1px) !important;
590
  }
591
+ .gradio-radio input[type="radio"]:checked + label span.text-lg {
 
 
592
  color: white !important;
593
  }
594
  .gradio-radio .gr-form {
 
654
  .gr-button-secondary {
655
  background-color: transparent !important;
656
  color: var(--text-primary) !important;
657
+ border: 2px solid var(--border-color) !important;
658
  }
659
  .gr-button-secondary:hover {
660
  background-color: var(--background-secondary) !important;
 
672
  padding: 1.5rem !important;
673
  min-height: 150px !important;
674
  color: var(--text-primary) !important;
675
+ display: flex !important;
676
+ flex-direction: column !important;
677
+ justify-content: center !important;
678
+ align-items: center !important;
679
  }
680
  .animated-output-content {
681
+ opacity: 0 !important;
682
+ animation: fadeInAndSlideUp 0.7s ease-out forwards !important;
683
+ width: 100% !important;
684
+ white-space: pre-wrap !important;
685
+ overflow-wrap: break-word !important;
686
+ word-break: break-word !important;
687
  text-align: left !important;
688
  color: var(--text-primary) !important;
689
  }
 
700
  align-items: center !important;
701
  gap: 0.6rem !important;
702
  text-align: left !important;
703
+ width: 100% !important;
704
+ justify-content: flex-start !important;
705
  }
706
  .response-icon {
707
  font-size: 1.5rem !important;
 
725
  font-weight: 500 !important;
726
  line-height: 1.6 !important;
727
  text-align: left !important;
728
+ width: 100% !important;
729
+ box-sizing: border-box !important;
730
  }
731
  .error-message a {
732
  color: var(--error-text) !important;
 
741
  font-size: 0.85rem !important;
742
  color: var(--error-text) !important;
743
  margin-top: 0.5rem !important;
744
+ opacity: 0.8 !important;
745
  }
746
  .placeholder {
747
  background-color: var(--background-primary) !important;
 
752
  color: var(--text-secondary) !important;
753
  font-style: italic !important;
754
  font-size: 1.1rem !important;
755
+ width: 100% !important;
756
+ box-sizing: border-box !important;
757
  }
758
  .examples-section .gr-samples-table {
759
  border: 2px solid var(--border-color) !important;
 
783
  }
784
  .examples-section .gr-samples-table tr:hover td {
785
  background-color: var(--background-secondary) !important;
786
+ transform: translateX(5px) !important;
787
  }
788
  .gr-examples .gr-label,
789
  .gr-examples .label-wrap,
 
791
  display: none !important;
792
  }
793
  .app-footer-wrapper {
794
+ background: linear-gradient(145deg, var(--background-primary) 0%, var(--background-secondary) 100%) !important;
795
  border: 2px solid var(--border-color) !important;
796
  border-radius: 12px !important;
797
  padding: 1.75rem !important;
 
814
  font-weight: 700 !important;
815
  color: var(--primary-color) !important;
816
  }
817
+ .app-footer a, .custom-link {
818
  color: var(--primary-color) !important;
819
  text-decoration: underline !important;
820
+ font-weight: bold !important;
821
  }
822
+ .app-footer a:hover, .custom-link:hover {
823
  text-decoration: none !important;
824
  }
825
  @media (max-width: 768px) {
 
860
  }
861
  """
862
 
863
+ with gr.Blocks(css=custom_css, title="Landlord-Tenant Rights Assistant", theme_mode="light") as demo:
864
  with gr.Group(elem_classes="app-header-wrapper"):
865
  gr.Markdown(
866
  """
 
949
  # Footer Section
950
  with gr.Group(elem_classes="app-footer-wrapper"):
951
  gr.Markdown(
952
+ """
 
 
 
 
 
 
 
953
  <p><strong>Disclaimer:</strong> This tool is for informational purposes only and does not constitute legal advice. For specific legal guidance, always consult with a licensed attorney in your jurisdiction.</p>
954
  <p>Developed by <strong>Nischal Subedi</strong>. Connect on <a href="https://www.linkedin.com/in/nischal1/" target="_blank" class="custom-link">LinkedIn</a> or explore insights at <a href="https://datascientistinsights.substack.com/" target="_blank" class="custom-link">Substack</a>.</p>
955
+ """,
956
+ elem_classes="app-footer"
957
  )
958
 
959
  submit_button.click(