File size: 27,452 Bytes
7e54fbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ==============================================================================
# Polyphenol Estimation Pipeline - Shiny Application UI
# ==============================================================================
#
# PIPELINE DEVELOPED BY:
#   Stephanie M.G. Wilson
#   University of California, Davis
#   Contact: smgwilson@ucdavis.edu
#   Repository: https://github.com/SWi1/polyphenol_pipeline/
#   License: MIT
#
# SHINY APP DEVELOPED BY:
#   Richard Stoker
#   United States Department of Agriculture - Agricultural Research Service
#   Contact: Richard.Stoker@usda.gov
#   License: CC0 (Public Domain)
#
# VERSION: 0.1 Alpha
# DATE: November 2025
# ==============================================================================

# Custom theme using bslib
app_theme <- bs_theme(
  version = 5,
  primary = "#6f42c1",
  secondary = "#5c2d91",
  success = "#28a745",
  info = "#17a2b8",
  warning = "#ffc107",
  danger = "#dc3545",
  base_font = font_google("Lato"),
  heading_font = font_google("Lato"),
  font_scale = 1.0,
  bootswatch = NULL
)

# Main UI Definition
ui <- page_navbar(
  id = "main_nav",
  title = tags$span(
    class = "navbar-title-text",
    "Polyphenol Estimation Pipeline"
  ),
  theme = app_theme,
  fillable = TRUE,
  header = tags$head(
    tags$link(rel = "stylesheet", type = "text/css", href = "custom.css"),
    tags$link(rel = "preconnect", href = "https://fonts.googleapis.com"),
    tags$link(rel = "preconnect", href = "https://fonts.gstatic.com", crossorigin = NA),
    tags$link(href = "https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap", rel = "stylesheet")
  ),
  footer = tags$footer(
    class = "app-footer",
    tags$div(
      class = "footer-content",
      tags$span(
        class = "footer-main",
        "Pipeline developed by Stephanie M.G. Wilson | ",
        tags$a(href = "https://github.com/SWi1/polyphenol_pipeline", target = "_blank", "GitHub Repository")
      ),
      tags$span(
        class = "footer-secondary",
        "Shiny app by Richard Stoker"
      )
    )
  ),

  # --------------------------------------------------------------------------
  # Tab 1: Get Started
  # --------------------------------------------------------------------------
  nav_panel(
    title = "Get Started",
    value = "get_started",
    icon = icon("circle-play"),
    class = "fade-in",
    layout_columns(
      col_widths = c(12),

      # Main welcome card
      card(
        card_header(
          class = "card-header-primary",
          tags$h4("Welcome to the Polyphenol Estimation Pipeline", class = "mb-0 text-white")
        ),
        card_body(
          class = "p-4",
          layout_columns(
            col_widths = c(5, 7),
            # Pipeline diagram
            tags$div(
              class = "text-center",
              tags$img(
                src = "Polyphenol_Estimation_Pipeline_Overview.png",
                alt = "Polyphenol Estimation Pipeline Overview",
                class = "img-fluid pipeline-diagram",
                style = "max-width: 100%; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);"
              )
            ),
            # What this app does
            tags$div(
              class = "getting-started-content",
              tags$h5("What This App Does"),
              tags$p(
                "Polyphenols are plant-derived compounds associated with reduced risk of chronic diseases, ",
                "but estimating intake from dietary data has traditionally required manual processing of ",
                "multiple databases. This pipeline automates that process."
              ),
              tags$p(
                "The app takes your 24-hour diet recall data and:"
              ),
              tags$ul(
                tags$li("Disaggregates reported foods into underlying ingredients"),
                tags$li("Maps ingredients to polyphenol content from FooDB"),
                tags$li("Calculates intake at total, class, and compound levels"),
                tags$li("Identifies which foods contribute most to polyphenol consumption"),
                tags$li("Computes a 42-component Dietary Inflammatory Index (DII)")
              ),
              tags$p(class = "text-muted small mt-3 mb-0",
                     "Results are provided in both absolute amounts (mg) and energy-standardized values (mg/1000 kcal)."
              )
            )
          )
        )
      ),

      # How to use section
      card(
        card_header(tags$h5("How to Use This App", class = "mb-0")),
        card_body(
          layout_columns(
            col_widths = c(4, 4, 4),
            # Step 1
            tags$div(
              class = "text-center p-3",
              tags$div(
                style = "background: var(--primary-color); color: white; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem; margin-bottom: 0.75rem;",
                "1"
              ),
              tags$h6("Upload Your Data"),
              tags$p(class = "text-muted small",
                     "Upload your diet recall file, or click \"Load Demo Data\" to explore with sample data first."
              )
            ),
            # Step 2
            tags$div(
              class = "text-center p-3",
              tags$div(
                style = "background: var(--primary-color); color: white; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem; margin-bottom: 0.75rem;",
                "2"
              ),
              tags$h6("Run the Pipeline"),
              tags$p(class = "text-muted small",
                     "Select your data format and click \"Run Pipeline\" to process your data."
              )
            ),
            # Step 3
            tags$div(
              class = "text-center p-3",
              tags$div(
                style = "background: var(--primary-color); color: white; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem; margin-bottom: 0.75rem;",
                "3"
              ),
              tags$h6("View & Export"),
              tags$p(class = "text-muted small",
                     "Explore interactive charts and tables. Download results as CSV files."
              )
            )
          ),
          tags$div(
            class = "text-center pt-3",
            actionButton(
              inputId = "go_to_input",
              label = tags$span(icon("arrow-right"), " Go to Input"),
              class = "btn-primary btn-lg"
            )
          )
        )
      )
    )
  ),

  # --------------------------------------------------------------------------
  # Tab 2: Input & Configuration
  # --------------------------------------------------------------------------
  nav_panel(
    title = "Input",
    value = "input",
    icon = icon("upload"),
    class = "fade-in",
    layout_columns(
      col_widths = c(4, 8),
      card(
        card_header(
          class = "card-header-primary",
          tags$h5("Configuration", class = "mb-0 text-white")
        ),
        card_body(
          # Data source selection with context
          radioGroupButtons(
            inputId = "data_source",
            label = tags$span(icon("database"), " Data Source"),
            choices = c("ASA24" = "ASA24", "NHANES" = "NHANES"),
            selected = "ASA24",
            justified = TRUE,
            status = "primary"
          ),
          tags$p(class = "text-muted small mt-2 mb-0",
                 "ASA24: Items File from researcher site. NHANES: Individual Foods file."
          ),

          tags$hr(),

          # File upload
          tags$div(
            class = "upload-zone",
            fileInput(
              inputId = "diet_file",
              label = tags$span(icon("file-csv"), " Upload Diet Data"),
              accept = c(".csv", ".xlsx", ".xls"),
              placeholder = "CSV or Excel file",
              width = "100%"
            ),
            tags$details(
              class = "mt-2",
              tags$summary(class = "text-muted small", style = "cursor: pointer;", icon("circle-info"), " Data format help"),
              tags$div(
                class = "small text-muted mt-2 ps-2",
                style = "font-size: 0.78rem; line-height: 1.6;",
                tags$div(tags$strong("ASA24:"), " UserName, RecallNo, FoodCode, FoodAmt, KCAL, ..."),
                tags$div(tags$strong("NHANES:"), " SEQN, RecallNo, DRXIFDCD, DRXIGRMS, DRXIKCAL, ..."),
                tags$div(class = "mt-2 fst-italic", "Each participant must have 2+ recalls.")
              )
            )
          ),

          tags$hr(),

          # Demo data button
          tags$div(
            class = "text-center mb-3",
            actionButton(
              inputId = "load_demo",
              label = tags$span(icon("flask"), " Load Demo Data"),
              class = "btn-outline-secondary w-100"
            ),
            tags$small(class = "text-muted d-block mt-2", "Sample ASA24 data to try the pipeline")
          ),

          tags$hr(),

          # DII calculation option
          checkboxInput(
            inputId = "calculate_dii",
            label = "Include DII Calculation",
            value = TRUE
          ),

          tags$hr(),

          # Action buttons
          layout_columns(
            col_widths = c(6, 6),
            actionButton(
              inputId = "reset_btn",
              label = tags$span(icon("rotate-left"), " Reset"),
              class = "btn-outline-danger w-100"
            ),
            actionButton(
              inputId = "run_pipeline",
              label = tags$span(icon("play"), " Run Pipeline"),
              class = "btn-primary btn-lg w-100 run-btn"
            )
          )
        )
      ),

      card(
        card_header(
          class = "bg-light",
          tags$h5("Data Preview", class = "mb-0")
        ),
        card_body(
          uiOutput("data_status"),
          tags$hr(),
          tags$div(
            class = "data-preview-container",
            DTOutput("data_preview")
          )
        )
      )
    )
  ),

  # --------------------------------------------------------------------------
  # Tab 3: Results Dashboard
  # --------------------------------------------------------------------------
  nav_panel(
    title = "Results",
    value = "results",
    icon = icon("chart-bar"),
    class = "fade-in",

    layout_columns(
      col_widths = c(12),

      # Summary cards row
      uiOutput("summary_cards"),

      # Main results tabs
      navset_card_tab(
        id = "results_tabs",
        full_screen = TRUE,

        # Total Intake Tab
        nav_panel(
          title = "Total Intake",
          icon = icon("chart-simple"),
          card(
            card_header(
              class = "d-flex justify-content-between align-items-center",
              tags$span("Total Polyphenol Intake"),
              tags$div(
                class = "d-flex align-items-center gap-2",
                tags$div(
                  class = "btn-group btn-group-sm view-toggle",
                  role = "group",
                  `aria-label` = "Toggle between chart and table view",
                  tags$button(type = "button", class = "btn btn-outline-primary active", id = "total_chart_btn",
                              icon("chart-bar"), " Chart"),
                  tags$button(type = "button", class = "btn btn-outline-primary", id = "total_table_btn",
                              icon("table"), " Table")
                ),
                downloadButton("download_total", NULL, class = "btn-sm btn-outline-primary", icon = icon("download"))
              )
            ),
            card_body(
              class = "results-view-container",
              tags$div(id = "total_chart_view", class = "results-view-visible",
                layout_columns(
                  col_widths = c(6, 6),
                  plotlyOutput("plot_total_intake", height = "400px"),
                  plotlyOutput("plot_intake_distribution", height = "400px")
                )
              ),
              tags$div(id = "total_table_view", class = "results-view-hidden",
                DTOutput("table_total_intake")
              )
            )
          )
        ),

        # Class-Level Tab
        nav_panel(
          title = "By Polyphenol Class",
          icon = icon("layer-group"),
          card(
            card_header(
              class = "d-flex justify-content-between align-items-center",
              tags$span("Polyphenol Intake by Chemical Class"),
              tags$div(
                class = "d-flex align-items-center gap-2",
                tags$div(
                  class = "btn-group btn-group-sm view-toggle",
                  role = "group",
                  `aria-label` = "Toggle between chart and table view",
                  tags$button(type = "button", class = "btn btn-outline-primary active", id = "class_chart_btn",
                              icon("chart-bar"), " Chart"),
                  tags$button(type = "button", class = "btn btn-outline-primary", id = "class_table_btn",
                              icon("table"), " Table")
                ),
                downloadButton("download_class", NULL, class = "btn-sm btn-outline-primary", icon = icon("download"))
              )
            ),
            card_body(
              class = "results-view-container",
              tags$div(id = "class_chart_view", class = "results-view-visible",
                plotlyOutput("plot_class_intake", height = "450px")
              ),
              tags$div(id = "class_table_view", class = "results-view-hidden",
                DTOutput("table_class_intake")
              )
            )
          )
        ),

        # Food Contributors Tab
        nav_panel(
          title = "Food Contributors",
          icon = icon("apple-whole"),
          card(
            card_header(
              class = "d-flex justify-content-between align-items-center",
              tags$span("Top Food Contributors to Polyphenol Intake"),
              tags$div(
                class = "d-flex align-items-center gap-2",
                tags$div(
                  class = "btn-group btn-group-sm view-toggle",
                  role = "group",
                  `aria-label` = "Toggle between chart and table view",
                  tags$button(type = "button", class = "btn btn-outline-primary active", id = "food_chart_btn",
                              icon("chart-bar"), " Chart"),
                  tags$button(type = "button", class = "btn btn-outline-primary", id = "food_table_btn",
                              icon("table"), " Table")
                ),
                downloadButton("download_foods", NULL, class = "btn-sm btn-outline-primary", icon = icon("download"))
              )
            ),
            card_body(
              class = "results-view-container",
              tags$div(id = "food_chart_view", class = "results-view-visible",
                plotlyOutput("plot_food_treemap", height = "500px")
              ),
              tags$div(id = "food_table_view", class = "results-view-hidden",
                DTOutput("table_food_contributors")
              )
            )
          )
        ),

        # DII Tab
        nav_panel(
          title = "DII Scores",
          icon = icon("fire"),
          uiOutput("dii_content")
        )
      ),

      # Download all results
      tags$div(
        class = "text-center py-3",
        downloadButton(
          outputId = "download_all",
          label = tags$span(icon("download"), " Download All Results"),
          class = "btn-primary"
        )
      ),

      # JavaScript for chart/table toggles
      tags$script(HTML("
        $(document).ready(function() {
          // Helper function to toggle views using CSS classes
          function toggleView(chartBtn, tableBtn, chartView, tableView) {
            $(chartBtn).click(function() {
              $(chartBtn).addClass('active');
              $(tableBtn).removeClass('active');
              $(chartView).removeClass('results-view-hidden').addClass('results-view-visible');
              $(tableView).removeClass('results-view-visible').addClass('results-view-hidden');
            });
            $(tableBtn).click(function() {
              $(tableBtn).addClass('active');
              $(chartBtn).removeClass('active');
              $(chartView).removeClass('results-view-visible').addClass('results-view-hidden');
              $(tableView).removeClass('results-view-hidden').addClass('results-view-visible');
              // Trigger resize to help DataTables adjust columns
              setTimeout(function() {
                $(window).trigger('resize');
                // Also trigger DataTables column adjustment if available
                var table = $(tableView).find('.dataTable').DataTable();
                if (table && table.columns) {
                  table.columns.adjust();
                }
              }, 50);
            });
          }

          // Set up toggles for each results section
          toggleView('#total_chart_btn', '#total_table_btn', '#total_chart_view', '#total_table_view');
          toggleView('#class_chart_btn', '#class_table_btn', '#class_chart_view', '#class_table_view');
          toggleView('#food_chart_btn', '#food_table_btn', '#food_chart_view', '#food_table_view');
        });
      "))
    )
  ),

  # --------------------------------------------------------------------------
  # Tab 4: QA/QC
  # --------------------------------------------------------------------------
  nav_panel(
    title = "QA/QC",
    value = "qaqc",
    icon = icon("clipboard-check"),
    class = "fade-in",
    layout_columns(
      col_widths = c(12),
      card(
        card_header(
          class = "d-flex justify-content-between align-items-center bg-warning text-dark",
          tags$span(icon("triangle-exclamation"), " Unmapped Foods Report"),
          tags$div(
            class = "btn-group btn-group-sm view-toggle",
            role = "group",
            `aria-label` = "Toggle between chart and table view",
            tags$button(type = "button", class = "btn btn-outline-dark active", id = "qaqc_chart_btn",
                        icon("chart-bar"), " Chart"),
            tags$button(type = "button", class = "btn btn-outline-dark", id = "qaqc_table_btn",
                        icon("table"), " Table")
          )
        ),
        card_body(
          tags$p(
            class = "text-muted small",
            "Foods that could not be mapped to FooDB are listed below. ",
            "These items will not contribute to polyphenol estimates. Review this list to assess data quality."
          ),
          uiOutput("unmapped_summary"),
          tags$div(class = "results-view-container",
            tags$div(id = "qaqc_chart_view", class = "results-view-visible",
              plotlyOutput("plot_missing_distribution", height = "400px")
            ),
            tags$div(id = "qaqc_table_view", class = "results-view-hidden",
              DTOutput("table_unmapped_foods")
            )
          )
        )
      ),

      # JavaScript for QA/QC toggle
      tags$script(HTML("
        $(document).ready(function() {
          $('#qaqc_chart_btn').click(function() {
            $(this).addClass('active');
            $('#qaqc_table_btn').removeClass('active');
            $('#qaqc_chart_view').removeClass('results-view-hidden').addClass('results-view-visible');
            $('#qaqc_table_view').removeClass('results-view-visible').addClass('results-view-hidden');
          });
          $('#qaqc_table_btn').click(function() {
            $(this).addClass('active');
            $('#qaqc_chart_btn').removeClass('active');
            $('#qaqc_chart_view').removeClass('results-view-visible').addClass('results-view-hidden');
            $('#qaqc_table_view').removeClass('results-view-hidden').addClass('results-view-visible');
            setTimeout(function() {
              $(window).trigger('resize');
            }, 50);
          });
        });
      "))
    )
  ),

  # --------------------------------------------------------------------------
  # Tab 5: About
  # --------------------------------------------------------------------------
  nav_panel(
    title = "About",
    value = "about",
    icon = icon("info-circle"),
    class = "fade-in",

    # About content - use card to fill available space
    card(
      class = "about-page-card",
      card_body(
        class = "about-page-content",

        # Header with animated logo
        tags$div(
        class = "text-center mb-4",
        tags$div(
          class = "about-logo-container mx-auto",
          style = "width: 180px; height: 180px; position: relative;",
          tags$video(
            id = "about-video",
            autoplay = NA,
            muted = NA,
            playsinline = NA,
            style = "width: 100%; height: 100%; object-fit: cover; border-radius: 50%;",
            tags$source(src = "splash_animation.mp4", type = "video/mp4")
          )
        ),
        tags$h3(class = "mt-3 mb-1", style = "color: var(--primary-color);", "Polyphenol Estimation Pipeline"),
        tags$p(class = "text-muted", "Automated dietary polyphenol intake estimation")
      ),

      # About the Pipeline
      tags$div(
        class = "card mb-3",
        tags$div(class = "card-body",
          tags$h5(class = "card-title", style = "color: var(--primary-color);", "About the Pipeline"),
          tags$p(
            "The Polyphenol Estimation Pipeline automates the estimation of dietary polyphenol intake ",
            "from 24-hour diet recall data. It addresses the need for standardized, reproducible methods ",
            "to quantify polyphenol consumption in epidemiological and nutrition research."
          ),

          tags$h6(class = "mt-4", "How It Works"),
          tags$div(class = "row",
            tags$div(class = "col-md-4",
              tags$div(class = "p-2",
                tags$strong("1. Food Disaggregation"),
                tags$p(class = "small text-muted mb-0",
                  "Reported foods are broken down into ingredients using the FDA Food Disaggregation Database (FDD v3.1)."
                )
              )
            ),
            tags$div(class = "col-md-4",
              tags$div(class = "p-2",
                tags$strong("2. FooDB Mapping"),
                tags$p(class = "small text-muted mb-0",
                  "Each ingredient is mapped to its polyphenol content using FooDB, covering 3,000+ compounds."
                )
              )
            ),
            tags$div(class = "col-md-4",
              tags$div(class = "p-2",
                tags$strong("3. Intake Calculation"),
                tags$p(class = "small text-muted mb-0",
                  "Polyphenol intake calculated at total, class, and compound levels (mg and mg/1000 kcal)."
                )
              )
            )
          ),

          tags$h6(class = "mt-4", "Dietary Inflammatory Index (DII)"),
          tags$p(class = "small",
            "The pipeline calculates a 42-component DII based on Shivappa et al. (2014). This extends ",
            "previous 28-component calculations by adding 7 polyphenol subclasses (eugenol, isoflavones, ",
            "flavan-3-ols, flavones, anthocyanidins, flavanones, flavonols) and 7 anti-inflammatory foods ",
            "(garlic, ginger, onion, pepper, tea, turmeric, thyme/oregano)."
          )
        )
      ),

      # Credits
      tags$div(
        class = "card mb-3",
        tags$div(class = "card-body",
          tags$h5(class = "card-title", style = "color: var(--primary-color);", "Credits"),

          tags$div(class = "row",
            tags$div(class = "col-md-8",
              tags$h6("Pipeline Development"),
              tags$p(class = "mb-1",
                tags$strong("Stephanie M.G. Wilson")
              ),
              tags$p(class = "small text-muted mb-2",
                "University of California, Davis"
              ),
              tags$p(class = "small mb-3",
                "The polyphenol estimation methodology, database mappings, and DII calculations ",
                "were developed by Dr. Wilson as part of her research at UC Davis."
              ),
              tags$a(
                href = "https://github.com/SWi1/polyphenol_pipeline",
                target = "_blank",
                class = "btn btn-outline-primary btn-sm",
                icon("github"), " View Pipeline Repository"
              )
            ),
            tags$div(class = "col-md-4 text-md-end",
              tags$p(class = "small text-muted mb-1", "Tutorial Draft Release"),
              tags$p(class = "small text-muted", "November 2025")
            )
          ),

          tags$hr(),

          tags$h6("Web Application"),
          tags$p(class = "mb-1", tags$strong("Richard Stoker")),
          tags$p(class = "small text-muted mb-1",
            "United States Department of Agriculture - Agricultural Research Service"
          ),
          tags$p(class = "small mb-2",
            tags$a(href = "mailto:Richard.Stoker@usda.gov", "Richard.Stoker@usda.gov")
          ),
          tags$p(class = "small text-muted mb-0",
            "Shiny interface developed to provide researchers with a user-friendly way to run the pipeline ",
            "without needing to execute R scripts directly."
          )
        )
      ),

      # Citation
      tags$div(
        class = "card mb-3",
        tags$div(class = "card-body",
          tags$h5(class = "card-title", style = "color: var(--primary-color);", "Citation"),
          tags$p(class = "small mb-2",
            "If you use this pipeline in your research, please cite the pipeline repository. ",
            "For DII calculations, please also cite:"
          ),
          tags$div(
            class = "bg-light p-3 rounded",
            style = "border-left: 4px solid var(--primary-color);",
            tags$p(class = "small mb-1", tags$strong("Shivappa, N., Steck, S. E., Hurley, T. G., Hussey, J. R., & Hebert, J. R.")),
            tags$p(class = "small mb-1", "Designing and developing a literature-derived, population-based dietary inflammatory index."),
            tags$p(class = "small mb-1 text-muted", tags$em("Public Health Nutrition"), ", 17(8), 1689-1696. (2014)"),
            tags$a(href = "https://doi.org/10.1017/s1368980013002115", target = "_blank", class = "small", "https://doi.org/10.1017/s1368980013002115")
          )
        )
      ),

        # JavaScript for about page video
        tags$script(HTML("
          $(document).ready(function() {
            var aboutVideo = document.getElementById('about-video');
            if (aboutVideo) {
              aboutVideo.addEventListener('timeupdate', function() {
                if (aboutVideo.duration && aboutVideo.currentTime >= aboutVideo.duration - 1.0) {
                  aboutVideo.pause();
                }
              });
            }
          });
        "))
      )
    )
  )
)