Scott Harshman commited on
Commit
63ad615
·
verified ·
1 Parent(s): c10455a

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -870
app.py DELETED
@@ -1,870 +0,0 @@
1
- import streamlit as st
2
- import streamlit.components.v1 as components
3
- import os, json, re
4
- from reportlab.lib.pagesizes import letter
5
- from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
6
- from reportlab.lib.units import inch
7
- from reportlab.platypus import (
8
- SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
9
- HRFlowable, KeepTogether, PageBreak,
10
- )
11
- from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
12
- from reportlab.lib import colors
13
- from io import BytesIO
14
- from datetime import datetime
15
- from config import *
16
-
17
- # ── Shorthand color references
18
- NAVY = BRAND["colors"]["navy"]
19
- TEAL = BRAND["colors"]["teal"]
20
- SKY = BRAND["colors"]["sky"]
21
- ORANGE = BRAND["colors"]["orange"]
22
- AMBER = BRAND["colors"]["amber"]
23
- WHITE = BRAND["colors"]["white"]
24
-
25
-
26
- # =============================================================================
27
- # RECOMMENDATION ENGINE
28
- # =============================================================================
29
- def score_peptides(selected_goals):
30
- """Score every peptide against the patient's selected goals.
31
-
32
- Returns a list of (peptide_key, score, matched_categories) sorted by score
33
- descending, then by suggested-vial cost ascending (value-first tiebreaker).
34
- """
35
- # Build category weights from selected goals
36
- cat_scores = {}
37
- for goal in selected_goals:
38
- for cat_name, weight in GOAL_MAPPINGS.get(goal, []):
39
- cat_scores[cat_name] = cat_scores.get(cat_name, 0) + weight
40
-
41
- if not cat_scores:
42
- return []
43
-
44
- results = []
45
- for pep_key, pep in PEPTIDES.items():
46
- score = 0
47
- matched = []
48
- for cat in pep["categories"]:
49
- if cat in cat_scores:
50
- score += cat_scores[cat]
51
- matched.append(cat)
52
- if score > 0:
53
- results.append((pep_key, score, matched))
54
-
55
- # Sort: highest score first, then cheapest suggested-vial price as tiebreaker
56
- results.sort(
57
- key=lambda x: (
58
- -x[1],
59
- PEPTIDES[x[0]]["pricing"].get(PEPTIDES[x[0]]["suggested_vials"], 9999),
60
- )
61
- )
62
- return results
63
-
64
-
65
- def get_top_categories(selected_goals, limit=3):
66
- """Return the top N matched categories from selected goals."""
67
- cat_scores = {}
68
- for goal in selected_goals:
69
- for cat_name, weight in GOAL_MAPPINGS.get(goal, []):
70
- cat_scores[cat_name] = cat_scores.get(cat_name, 0) + weight
71
- sorted_cats = sorted(cat_scores.items(), key=lambda x: -x[1])
72
- return [c[0] for c in sorted_cats[:limit]]
73
-
74
-
75
- def group_by_tier(scored_peptides):
76
- """Group scored peptides into branded blends, other blends, and singles."""
77
- branded = []
78
- blends = []
79
- singles = []
80
- for pep_key, score, matched in scored_peptides:
81
- pep = PEPTIDES[pep_key]
82
- if pep.get("brand_name"):
83
- branded.append((pep_key, score, matched))
84
- elif pep.get("is_blend"):
85
- blends.append((pep_key, score, matched))
86
- else:
87
- singles.append((pep_key, score, matched))
88
- return branded, blends, singles
89
-
90
-
91
- # =============================================================================
92
- # PDF GENERATOR
93
- # =============================================================================
94
- def generate_pdf(patient_info, selected_goals, top_categories, recommendations):
95
- """Generate a branded PDF of the peptide recommendation."""
96
- buffer = BytesIO()
97
- doc = SimpleDocTemplate(
98
- buffer, pagesize=letter,
99
- topMargin=0.55 * inch, bottomMargin=0.6 * inch,
100
- leftMargin=0.65 * inch, rightMargin=0.65 * inch,
101
- )
102
- story = []
103
- pw = letter[0] - 1.3 * inch
104
-
105
- def ps(name, **kwargs):
106
- return ParagraphStyle(name, **kwargs)
107
-
108
- C_NAVY = colors.HexColor(NAVY)
109
- C_TEAL = colors.HexColor(TEAL)
110
- C_ORANGE = colors.HexColor(ORANGE)
111
- C_AMBER = colors.HexColor(AMBER)
112
- C_SKY = colors.HexColor(SKY)
113
- C_LIGHT = colors.HexColor("#eef4f8")
114
- C_CARD = colors.HexColor("#f0f6fa")
115
- C_BORDER = colors.HexColor("#b8d0de")
116
-
117
- brand_s = ps("Br", fontName="Helvetica-Bold", fontSize=9, textColor=C_ORANGE, spaceAfter=0, alignment=TA_CENTER)
118
- title_s = ps("T", fontName="Helvetica-Bold", fontSize=20, leading=26, textColor=colors.white, spaceAfter=0, alignment=TA_CENTER)
119
- sub_s = ps("Su", fontName="Helvetica", fontSize=10, textColor=C_SKY, spaceAfter=0, alignment=TA_CENTER)
120
- meta_s = ps("Me", fontName="Helvetica", fontSize=9, leading=14, textColor=C_NAVY, spaceAfter=3)
121
- h2_s = ps("H2", fontName="Helvetica-Bold", fontSize=11, textColor=colors.white, spaceBefore=0, spaceAfter=0)
122
- h3_s = ps("H3", fontName="Helvetica-Bold", fontSize=10, textColor=C_NAVY, spaceBefore=4, spaceAfter=3)
123
- body_s = ps("B", fontName="Helvetica", fontSize=9.5, leading=15, textColor=C_NAVY, spaceAfter=5)
124
- bullet_s = ps("Bu", fontName="Helvetica", fontSize=9.5, leading=15, textColor=C_NAVY, leftIndent=14, spaceAfter=3)
125
- disc_s = ps("Di", fontName="Helvetica-Oblique", fontSize=8, leading=12, textColor=colors.HexColor("#4a6070"), spaceAfter=4)
126
- price_s = ps("Pr", fontName="Helvetica-Bold", fontSize=10, textColor=C_ORANGE, spaceAfter=2)
127
- pep_hdr_s = ps("Ph", fontName="Helvetica-Bold", fontSize=10, textColor=colors.white, spaceBefore=0, spaceAfter=0)
128
- ft_s = ps("Ft", fontName="Helvetica", fontSize=8, leading=12, textColor=C_NAVY, spaceAfter=0, alignment=TA_CENTER)
129
-
130
- def banner(para, bg, line_below=None, pad_v=7, pad_h=12):
131
- t = Table([[para]], colWidths=[pw])
132
- cmds = [
133
- ("BACKGROUND", (0, 0), (-1, -1), bg),
134
- ("LEFTPADDING", (0, 0), (-1, -1), pad_h),
135
- ("RIGHTPADDING", (0, 0), (-1, -1), pad_h),
136
- ("TOPPADDING", (0, 0), (-1, -1), pad_v),
137
- ("BOTTOMPADDING", (0, 0), (-1, -1), pad_v),
138
- ]
139
- if line_below:
140
- cmds.append(("LINEBELOW", (0, 0), (-1, -1), 3, line_below))
141
- t.setStyle(TableStyle(cmds))
142
- return t
143
-
144
- def section_hdr(text):
145
- return KeepTogether([
146
- Spacer(1, 8),
147
- banner(Paragraph(text.upper(), h2_s), C_NAVY, line_below=C_ORANGE, pad_v=8),
148
- Spacer(1, 6),
149
- ])
150
-
151
- # ── COVER ────────────────────────────────────────────────────────────────
152
- hdr_tbl = Table([
153
- [Paragraph("IGNITE PERFORMANCE & HEALTH", brand_s)],
154
- [Paragraph("Peptide Protocol Recommendation", title_s)],
155
- [Paragraph("Physician-Supervised Peptide Therapy", sub_s)],
156
- ], colWidths=[pw])
157
- hdr_tbl.setStyle(TableStyle([
158
- ("BACKGROUND", (0, 0), (-1, -1), C_NAVY),
159
- ("LEFTPADDING", (0, 0), (-1, -1), 20),
160
- ("RIGHTPADDING", (0, 0), (-1, -1), 20),
161
- ("TOPPADDING", (0, 0), (0, 0), 14),
162
- ("BOTTOMPADDING", (0, 0), (0, 0), 4),
163
- ("TOPPADDING", (0, 1), (0, 1), 4),
164
- ("BOTTOMPADDING", (0, 1), (0, 1), 4),
165
- ("TOPPADDING", (0, 2), (0, 2), 2),
166
- ("BOTTOMPADDING", (0, 2), (0, 2), 14),
167
- ("ALIGN", (0, 0), (-1, -1), "CENTER"),
168
- ]))
169
- story.append(hdr_tbl)
170
- story.append(HRFlowable(width="100%", thickness=5, color=C_ORANGE, spaceAfter=12))
171
-
172
- # ── Patient info ──
173
- name = patient_info.get("name", "")
174
- date_str = datetime.now().strftime("%B %d, %Y")
175
- pi_tbl = Table([[
176
- Paragraph(f"<b>Prepared for:</b> {name}", meta_s),
177
- Paragraph(f"<b>Date:</b> {date_str}", meta_s),
178
- ]], colWidths=[pw * 0.6, pw * 0.4])
179
- pi_tbl.setStyle(TableStyle([
180
- ("BACKGROUND", (0, 0), (-1, -1), C_LIGHT),
181
- ("BOX", (0, 0), (-1, -1), 0.75, C_BORDER),
182
- ("LINEBELOW", (0, 0), (-1, -1), 2, C_ORANGE),
183
- ("LEFTPADDING", (0, 0), (-1, -1), 10),
184
- ("RIGHTPADDING", (0, 0), (-1, -1), 10),
185
- ("TOPPADDING", (0, 0), (-1, -1), 9),
186
- ("BOTTOMPADDING", (0, 0), (-1, -1), 9),
187
- ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
188
- ]))
189
- story.append(pi_tbl)
190
- story.append(Spacer(1, 14))
191
-
192
- # ── Goals & Categories ──
193
- story.append(section_hdr("Your Goals"))
194
- goals_text = " · ".join(selected_goals)
195
- story.append(Paragraph(f"<b>Selected goals:</b> {goals_text}", body_s))
196
- cats_text = " · ".join(top_categories)
197
- story.append(Paragraph(f"<b>Top therapeutic areas:</b> {cats_text}", body_s))
198
- story.append(Spacer(1, 8))
199
-
200
- # ── Recommendations ──
201
- story.append(section_hdr("Recommended Peptides"))
202
-
203
- branded, blends, singles = group_by_tier(recommendations)
204
-
205
- def render_pep_block(pep_key, score, matched):
206
- pep = PEPTIDES[pep_key]
207
- display_name = pep.get("brand_name") or pep_key
208
- sv = pep["suggested_vials"]
209
- sv_price = pep["pricing"].get(sv, 0)
210
- per_week = sv_price / max((sv * 4), 1) # rough per-week estimate
211
-
212
- items = [
213
- Spacer(1, 4),
214
- banner(Paragraph(f" {display_name}", pep_hdr_s), C_TEAL, line_below=C_NAVY, pad_v=5),
215
- ]
216
- if pep.get("brand_name") and pep_key != pep["brand_name"]:
217
- items.append(Paragraph(f"<i>{pep_key}</i>", disc_s))
218
- items.append(Paragraph(pep["description"], body_s))
219
- # ── Layered MOA ──
220
- moa_scott = pep.get("moa_scott", "")
221
- moa_clinical = pep.get("moa_clinical", "")
222
- if moa_scott:
223
- items.append(Paragraph(f'<font color="{ORANGE}"><b>How it works:</b></font> {moa_scott}', body_s))
224
- if moa_clinical:
225
- items.append(Paragraph(f"<i>{moa_clinical}</i>", disc_s))
226
- items.append(Paragraph(
227
- f"<b>Dosage:</b> {pep['dosage']} | <b>Cycle:</b> {pep['cycle']} | "
228
- f"<b>Suggested vials:</b> {sv}", bullet_s))
229
- items.append(Paragraph(
230
- f"<b>Suggested cycle cost:</b> ${sv_price:,.2f} ({sv} vials) | "
231
- f"<b>~${per_week:,.2f}/week</b>", price_s))
232
- items.append(Paragraph(
233
- f"Categories: {', '.join(matched)}", disc_s))
234
- items.append(Spacer(1, 6))
235
- return KeepTogether(items)
236
-
237
- if branded:
238
- story.append(Paragraph("<b>Ignite Branded Blends</b> — curated multi-peptide protocols", h3_s))
239
- for pep_key, score, matched in branded[:6]:
240
- story.append(render_pep_block(pep_key, score, matched))
241
-
242
- if blends:
243
- story.append(Paragraph("<b>Combination Blends</b>", h3_s))
244
- for pep_key, score, matched in blends[:4]:
245
- story.append(render_pep_block(pep_key, score, matched))
246
-
247
- if singles:
248
- story.append(Paragraph("<b>Individual Peptides</b>", h3_s))
249
- for pep_key, score, matched in singles[:4]:
250
- story.append(render_pep_block(pep_key, score, matched))
251
-
252
- # ── Disclaimer ──
253
- story.append(Spacer(1, 12))
254
- story.append(HRFlowable(width="100%", thickness=1, color=C_BORDER, spaceAfter=8))
255
- story.append(Paragraph(BRAND["disclaimer"], disc_s))
256
- story.append(Spacer(1, 6))
257
-
258
- # ── Footer ──
259
- story.append(HRFlowable(width="100%", thickness=3, color=C_ORANGE, spaceAfter=0))
260
- ft_brand_s = ps("Fb", fontName="Helvetica-Bold", fontSize=10, textColor=C_ORANGE, spaceAfter=1, alignment=TA_CENTER)
261
- ft_info_s = ps("Fi", fontName="Helvetica", fontSize=8, leading=12, textColor=colors.white, spaceAfter=1, alignment=TA_CENTER)
262
- ft_web_s = ps("Fw", fontName="Helvetica-Bold", fontSize=8, textColor=C_SKY, spaceAfter=0, alignment=TA_CENTER)
263
-
264
- ft_tbl = Table([
265
- [Paragraph("IGNITE PERFORMANCE &amp; HEALTH", ft_brand_s)],
266
- [Paragraph("14830 Clayton Rd, Chesterfield, MO 63017 | (314) 887-0858 | info@ignitepah.com", ft_info_s)],
267
- [Paragraph("www.ignitepah.com", ft_web_s)],
268
- ], colWidths=[pw])
269
- ft_tbl.setStyle(TableStyle([
270
- ("BACKGROUND", (0, 0), (-1, -1), C_NAVY),
271
- ("TOPPADDING", (0, 0), (0, 0), 8),
272
- ("BOTTOMPADDING", (0, -1), (0, -1), 8),
273
- ("TOPPADDING", (0, 1), (-1, -1), 1),
274
- ("BOTTOMPADDING", (0, 1), (-1, -1), 1),
275
- ("ALIGN", (0, 0), (-1, -1), "CENTER"),
276
- ]))
277
- story.append(ft_tbl)
278
-
279
- doc.build(story)
280
- buffer.seek(0)
281
- return buffer
282
-
283
-
284
- # =============================================================================
285
- # FOOTER RENDERER
286
- # =============================================================================
287
- def render_footer():
288
- st.markdown(
289
- '<div class="site-footer">'
290
- f'{"<img class=footer-logo src=" + chr(34) + LOGO_B64 + chr(34) + " alt=Ignite />" if LOGO_B64 else ""}'
291
- '<p class="brand">Ignite Performance &amp; Health</p>'
292
- '<p class="tagline">Physician-Supervised Peptide Therapy</p>'
293
- '<div style="width:60px;height:2px;background:#f58300;margin:14px auto;border-radius:2px;"></div>'
294
- '<p class="contact-label">Visit Us</p>'
295
- '<p class="contact-row">14830 Clayton Rd, Chesterfield, MO 63017</p>'
296
- '<p class="contact-label">Get In Touch</p>'
297
- '<p class="contact-row">'
298
- '<a href="tel:3148870858">(314) 887-0858</a>'
299
- '<span class="sep">|</span>'
300
- '<a href="mailto:info@ignitepah.com">info@ignitepah.com</a>'
301
- '</p>'
302
- '<p class="contact-row"><a href="https://ignitepah.com" target="_blank">www.ignitepah.com</a></p>'
303
- '<p class="disclaimer">'
304
- f'{BRAND["disclaimer"]}'
305
- '</p>'
306
- '</div>',
307
- unsafe_allow_html=True,
308
- )
309
-
310
-
311
- # =============================================================================
312
- # PAGE CONFIG & CSS
313
- # =============================================================================
314
- st.set_page_config(
315
- page_title="Ignite Performance & Health — Peptide Protocol Selector",
316
- layout="wide",
317
- initial_sidebar_state="collapsed",
318
- )
319
-
320
- st.markdown(
321
- '<link rel="preconnect" href="https://fonts.googleapis.com">'
322
- '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>'
323
- '<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,400;0,600;0,700;0,800;1,700&family=Barlow+Condensed:wght@700;800&display=swap">',
324
- unsafe_allow_html=True,
325
- )
326
-
327
- st.markdown("""
328
- <style>
329
- .stApp { background-color: #f0f6fa; }
330
- html, body, [class*="css"] { font-family: 'Barlow', 'Segoe UI', sans-serif; }
331
- .stMarkdown p, .stMarkdown span,
332
- div[data-testid="stMarkdownContainer"] p,
333
- div[data-testid="stMarkdownContainer"] span,
334
- div[data-testid="stMarkdownContainer"] li,
335
- .stRadio label, .stRadio span,
336
- .stCheckbox label, .stCheckbox span,
337
- .stNumberInput label, .stTextInput label, .stTextArea label,
338
- .stCaption, .stCaption p, .stForm p, .stForm span, .stForm label { color: #023047 !important; }
339
- div[data-testid="stMarkdownContainer"] .site-footer p,
340
- div[data-testid="stMarkdownContainer"] .site-footer span,
341
- div[data-testid="stMarkdownContainer"] .site-footer a,
342
- .stMarkdown .site-footer p, .stMarkdown .site-footer a { color: #ffffff !important; }
343
- div[data-testid="stMarkdownContainer"] .site-footer .brand,
344
- .stMarkdown .site-footer .brand { color: #f58300 !important; }
345
- div[data-testid="stMarkdownContainer"] .site-footer .tagline,
346
- .stMarkdown .site-footer .tagline { color: #8ecae6 !important; }
347
- div[data-testid="stMarkdownContainer"] .site-footer .disclaimer,
348
- .stMarkdown .site-footer .disclaimer { color: rgba(255,255,255,0.7) !important; }
349
- div[data-testid="stMarkdownContainer"] .cta-box p,
350
- div[data-testid="stMarkdownContainer"] .cta-box span,
351
- div[data-testid="stMarkdownContainer"] .cta-box a,
352
- .stMarkdown .cta-box p, .stMarkdown .cta-box span, .stMarkdown .cta-box a { color: #ffffff !important; }
353
- div[data-testid="stMarkdownContainer"] .cta-box h3,
354
- .stMarkdown .cta-box h3 { color: #ffc533 !important; }
355
- div[data-testid="stMarkdownContainer"] .cta-box strong,
356
- .stMarkdown .cta-box strong { color: #ffc533 !important; }
357
- div[data-testid="stMarkdownContainer"] .section-band,
358
- .stMarkdown .section-band { color: #ffc533 !important; }
359
- div[data-testid="stMarkdownContainer"] .hero .hero-title,
360
- .stMarkdown .hero .hero-title { color: #f58300 !important; }
361
- div[data-testid="stMarkdownContainer"] .hero .hero-sub,
362
- .stMarkdown .hero .hero-sub { color: #8ecae6 !important; }
363
- div[data-testid="stMarkdownContainer"] .hero .hero-tagline,
364
- .stMarkdown .hero .hero-tagline { color: rgba(255,255,255,0.85) !important; }
365
- div[data-testid="stMarkdownContainer"] .cat-pill,
366
- .stMarkdown .cat-pill { color: #ffffff !important; }
367
- div[data-testid="stMarkdownContainer"] .pep-badge p,
368
- div[data-testid="stMarkdownContainer"] .pep-badge span,
369
- div[data-testid="stMarkdownContainer"] .pep-badge-branded p,
370
- div[data-testid="stMarkdownContainer"] .pep-badge-branded span,
371
- .stMarkdown .pep-badge, .stMarkdown .pep-badge-branded { color: #ffffff !important; }
372
- div[data-testid="stMarkdownContainer"] .pep-moa-scott,
373
- .stMarkdown .pep-moa-scott { color: #023047 !important; }
374
- div[data-testid="stMarkdownContainer"] .pep-moa-label,
375
- .stMarkdown .pep-moa-label { color: #f58300 !important; }
376
- div[data-testid="stMarkdownContainer"] .pep-moa-clinical,
377
- .stMarkdown .pep-moa-clinical { color: #6b8a9e !important; }
378
- .stTextInput input, .stNumberInput input, .stTextArea textarea {
379
- color: #023047 !important; background-color: #ffffff !important;
380
- border: 1px solid #ccdde8 !important; border-radius: 6px !important;
381
- }
382
- .stTextInput input:focus, .stNumberInput input:focus, .stTextArea textarea:focus {
383
- border-color: #219ebc !important; box-shadow: 0 0 0 2px rgba(33,158,188,0.2) !important;
384
- }
385
-
386
- /* ── Hero ── */
387
- .hero {
388
- background: linear-gradient(135deg, #023047 60%, #219ebc 100%);
389
- border-radius: 12px; padding: 2.2rem 2.5rem 1.8rem; margin-bottom: 1.5rem;
390
- text-align: center;
391
- }
392
- .hero-logo { display: block; margin: 0 auto 18px; height: 130px; width: auto; }
393
- .hero-title { color: #f58300 !important; font-family: 'Barlow Condensed', sans-serif; font-size: 2.2rem; font-weight: 800; margin: 0 0 4px; letter-spacing: 1px; text-transform: uppercase; }
394
- .hero-sub { color: #8ecae6 !important; font-size: 1.1rem; font-weight: 600; margin: 8px 0 0; }
395
- .hero-tagline { color: rgba(255,255,255,0.85) !important; font-size: 0.85rem; margin: 8px 0 0; letter-spacing: 0.5px; }
396
-
397
- /* ── Section bands ── */
398
- .section-band {
399
- background: linear-gradient(90deg, #023047 0%, #012233 100%);
400
- color: #ffc533 !important; font-family: 'Barlow Condensed', sans-serif;
401
- font-size: 1.1rem; font-weight: 800; letter-spacing: 1.2px;
402
- padding: 12px 16px; margin: 20px 0 14px;
403
- border-radius: 4px; text-transform: uppercase;
404
- }
405
-
406
- /* ── Form & buttons ── */
407
- .stForm { background: white; padding: 20px; border-radius: 8px; }
408
- .stFormSubmitButton > button,
409
- .stFormSubmitButton > button:active,
410
- .stFormSubmitButton > button:focus {
411
- background: linear-gradient(135deg, #f58300 0%, #ffc533 100%) !important;
412
- color: #023047 !important; font-size: 1rem; font-weight: 700;
413
- letter-spacing: 0.5px; padding: 12px 24px; border-radius: 6px !important;
414
- border: none !important; box-shadow: 0 4px 12px rgba(245,131,0,0.25) !important;
415
- }
416
- .stFormSubmitButton > button p,
417
- .stFormSubmitButton > button span { color: #023047 !important; font-weight: 700 !important; }
418
- .stFormSubmitButton > button:hover {
419
- background: linear-gradient(135deg, #ffc533 0%, #f58300 100%) !important;
420
- }
421
- .stDownloadButton > button,
422
- .stDownloadButton > button:active,
423
- .stDownloadButton > button:focus {
424
- background: linear-gradient(135deg, #f58300 0%, #ffc533 100%) !important;
425
- color: #023047 !important; font-size: 0.9rem; font-weight: 700;
426
- padding: 10px 20px; border-radius: 6px !important;
427
- border: none !important; box-shadow: 0 2px 8px rgba(245,131,0,0.25) !important;
428
- width: 100%;
429
- }
430
- .stDownloadButton > button p,
431
- .stDownloadButton > button span { color: #023047 !important; font-weight: 700 !important; }
432
- .stDownloadButton > button:hover {
433
- background: linear-gradient(135deg, #ffc533 0%, #f58300 100%) !important;
434
- }
435
- .stButton > button,
436
- .stButton > button:active,
437
- .stButton > button:focus {
438
- background: linear-gradient(135deg, #f58300 0%, #ffc533 100%) !important;
439
- color: #023047 !important; font-size: 1rem; font-weight: 700;
440
- padding: 12px 24px; border-radius: 6px !important;
441
- border: none !important; box-shadow: 0 4px 12px rgba(245,131,0,0.25) !important;
442
- }
443
- .stButton > button p,
444
- .stButton > button span { color: #023047 !important; font-weight: 700 !important; }
445
- .stButton > button:hover {
446
- background: linear-gradient(135deg, #ffc533 0%, #f58300 100%) !important;
447
- }
448
-
449
- /* ── Peptide cards ── */
450
- .pep-card {
451
- background: white; border: 1px solid #b8d0de; border-radius: 8px;
452
- padding: 16px; margin-bottom: 16px;
453
- }
454
- .pep-card-branded {
455
- background: white; border: 2px solid #219ebc; border-radius: 8px;
456
- padding: 16px; margin-bottom: 16px;
457
- }
458
- .pep-badge {
459
- display: inline-block; background: #219ebc; color: white;
460
- font-size: 0.7rem; font-weight: 700; padding: 4px 8px;
461
- border-radius: 3px; margin-bottom: 8px; letter-spacing: 0.5px;
462
- }
463
- .pep-badge-branded {
464
- display: inline-block; background: #f58300; color: white;
465
- font-size: 0.7rem; font-weight: 700; padding: 4px 8px;
466
- border-radius: 3px; margin-bottom: 8px; letter-spacing: 0.5px;
467
- }
468
- .pep-name {
469
- color: #023047 !important; font-family: 'Barlow Condensed', sans-serif;
470
- font-size: 1.3rem; font-weight: 800; margin-bottom: 2px;
471
- }
472
- .pep-components {
473
- color: #219ebc !important; font-size: 0.85rem; font-style: italic; margin-bottom: 8px;
474
- }
475
- .pep-desc {
476
- color: #4a6070 !important; font-size: 0.9rem; margin-bottom: 14px; line-height: 1.5;
477
- }
478
- .pep-label {
479
- color: #f58300 !important; font-weight: 700; font-size: 0.75rem;
480
- text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
481
- }
482
- .pep-value {
483
- color: #023047 !important; font-size: 0.9rem; margin-bottom: 10px;
484
- }
485
- .pep-moa-scott {
486
- color: #023047 !important; font-size: 0.9rem; line-height: 1.55; margin-bottom: 6px;
487
- padding: 10px 12px; background: #f8fbfd; border-left: 3px solid #f58300; border-radius: 0 4px 4px 0;
488
- }
489
- .pep-moa-label { color: #f58300 !important; font-weight: 700; }
490
- .pep-moa-clinical {
491
- color: #6b8a9e !important; font-size: 0.8rem; font-style: italic; line-height: 1.5;
492
- margin-bottom: 12px; padding: 0 12px;
493
- }
494
- .pep-cats {
495
- display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px;
496
- }
497
- .cat-pill {
498
- background: #219ebc; color: #ffffff !important;
499
- font-size: 0.72rem; font-weight: 700; padding: 4px 10px;
500
- border-radius: 12px; white-space: nowrap;
501
- }
502
-
503
- /* ── Pricing grid ── */
504
- .pricing-grid {
505
- display: grid; gap: 8px; margin-top: 10px;
506
- }
507
- .price-cell {
508
- background: #f0f6fa; border: 1px solid #b8d0de; border-radius: 6px;
509
- padding: 10px 8px; text-align: center;
510
- }
511
- .price-cell-suggested {
512
- background: linear-gradient(135deg, #fff8ec 0%, #fff0d6 100%); border: 2.5px solid #f58300; border-radius: 6px;
513
- padding: 12px 8px; text-align: center; box-shadow: 0 2px 8px rgba(245,131,0,0.2);
514
- position: relative;
515
- }
516
- .price-vials { color: #023047 !important; font-weight: 700; font-size: 0.8rem; margin-bottom: 2px; }
517
- .price-per-week { color: #f58300 !important; font-family: 'Barlow Condensed', sans-serif; font-size: 1.55rem; font-weight: 800; }
518
- .price-per-week-label { color: #f58300 !important; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
519
- .price-amount { color: #4a6070 !important; font-size: 0.72rem; font-weight: 600; margin-top: 2px; }
520
- .price-suggested-label { background: #f58300; color: #ffffff !important; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; display: inline-block; margin-top: 4px; }
521
-
522
- /* ── Styled HR ── */
523
- .styled-hr { margin: 2rem 0; border: 0; height: 2px; background: linear-gradient(90deg, transparent, #f58300, transparent); }
524
-
525
- /* ── CTA box ── */
526
- .cta-box {
527
- background: linear-gradient(135deg, #023047 0%, #034a6e 100%);
528
- border: 2px solid #f58300; border-radius: 8px; padding: 24px;
529
- margin: 24px 0; color: #ffffff !important;
530
- }
531
- .cta-box, .cta-box * { color: #ffffff !important; }
532
- .cta-box h3 { color: #ffc533 !important; font-family: 'Barlow Condensed', sans-serif; font-size: 1.4rem; font-weight: 800; margin-bottom: 12px; }
533
- .cta-box p { color: #ffffff !important; line-height: 1.6; margin-bottom: 10px; }
534
- .cta-box strong { color: #ffc533 !important; }
535
- .cta-link {
536
- display: inline-block; background: #f58300; color: #ffffff !important;
537
- font-weight: 700; padding: 12px 20px; border-radius: 6px;
538
- text-decoration: none; margin-top: 14px; letter-spacing: 0.5px;
539
- }
540
- .cta-link:hover { background: #ffc533; color: #023047 !important; }
541
-
542
- /* ── Site footer ── */
543
- .site-footer {
544
- background: #023047; color: #ffffff !important; padding: 32px 24px; text-align: center;
545
- margin-top: 40px; border-top: 4px solid #f58300;
546
- }
547
- .site-footer, .site-footer * { color: #ffffff !important; }
548
- .site-footer .brand { color: #f58300 !important; font-family: 'Barlow Condensed', sans-serif; font-size: 1.3rem; font-weight: 800; margin: 8px 0 4px; letter-spacing: 1px; }
549
- .site-footer .tagline { color: #8ecae6 !important; font-size: 0.85rem; margin-bottom: 14px; }
550
- .site-footer .contact-label { color: #ffc533 !important; font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 12px; margin-bottom: 4px; }
551
- .site-footer .contact-row { color: white !important; font-size: 0.95rem; margin-bottom: 4px; line-height: 1.6; }
552
- .site-footer .contact-row a { color: white !important; text-decoration: none; }
553
- .site-footer .contact-row a:hover { color: #ffc533 !important; }
554
- .site-footer .sep { color: #8ecae6 !important; margin: 0 10px; }
555
- .site-footer .disclaimer { color: rgba(255,255,255,0.7) !important; font-size: 0.8rem; margin-top: 16px; line-height: 1.6; }
556
-
557
- /* ── Mobile ── */
558
- @media (max-width: 768px) {
559
- .hero { padding: 1.5rem 1.2rem 1.2rem; }
560
- .hero-logo { height: 90px; }
561
- .hero-title { font-size: 1.6rem !important; }
562
- .pep-name { font-size: 1.1rem; }
563
- .pricing-grid { grid-template-columns: repeat(3, 1fr) !important; }
564
- .price-per-week { font-size: 1.2rem; }
565
- }
566
- @media (max-width: 480px) {
567
- .hero-title { font-size: 1.3rem !important; }
568
- .pricing-grid { grid-template-columns: repeat(2, 1fr) !important; }
569
- }
570
- </style>
571
- """, unsafe_allow_html=True)
572
-
573
-
574
- # =============================================================================
575
- # SESSION STATE
576
- # =============================================================================
577
- if "pep_results" not in st.session_state:
578
- st.session_state["pep_results"] = None
579
- st.session_state["pep_goals"] = []
580
- st.session_state["pep_top_cats"] = []
581
- st.session_state["pep_patient_name"] = ""
582
- st.session_state["pep_patient_email"] = ""
583
- st.session_state["pep_patient_phone"] = ""
584
-
585
-
586
- # =============================================================================
587
- # RESULTS PAGE
588
- # =============================================================================
589
- if st.session_state["pep_results"]:
590
- pname = st.session_state.get("pep_patient_name", "")
591
- pemail = st.session_state.get("pep_patient_email", "")
592
- pphone = st.session_state.get("pep_patient_phone", "")
593
- selected_goals = st.session_state.get("pep_goals", [])
594
- top_cats = st.session_state.get("pep_top_cats", [])
595
- results = st.session_state["pep_results"]
596
-
597
- # ── Hero ──
598
- st.markdown(
599
- '<div class="hero">'
600
- f'{"<img class=hero-logo src=" + chr(34) + LOGO_B64 + chr(34) + " alt=Ignite />" if LOGO_B64 else ""}'
601
- '<div class="hero-title">Peptide Protocol Selector</div>'
602
- '<div class="hero-sub">Your Personalized Peptide Recommendations</div>'
603
- f'<div class="hero-tagline">Prepared for {pname}</div>'
604
- '</div>',
605
- unsafe_allow_html=True,
606
- )
607
-
608
- # ── Goals summary ──
609
- st.markdown('<div class="section-band">Your Health Goals</div>', unsafe_allow_html=True)
610
- goals_html = " · ".join(selected_goals)
611
- st.markdown(f'<p style="color:#023047;font-size:0.95rem;margin-bottom:8px;">{goals_html}</p>', unsafe_allow_html=True)
612
- cats_html = " ".join(f'<span class="cat-pill">{c}</span>' for c in top_cats)
613
- st.markdown(f'<div style="display:flex;gap:6px;flex-wrap:wrap;margin-bottom:20px;">{cats_html}</div>', unsafe_allow_html=True)
614
-
615
- # ── Group and display ──
616
- branded, blends, singles = group_by_tier(results)
617
-
618
- def render_card(pep_key, score, matched, is_branded=False):
619
- pep = PEPTIDES[pep_key]
620
- display_name = pep.get("brand_name") or pep_key
621
- card_class = "pep-card-branded" if is_branded else "pep-card"
622
- badge_class = "pep-badge-branded" if is_branded else "pep-badge"
623
- # Only show badge on singles and non-branded blends
624
- show_badge = not is_branded
625
- badge_text = "BLEND" if pep["is_blend"] else "SINGLE"
626
-
627
- components_str = " + ".join(pep["components"]) if pep["is_blend"] else ""
628
- cat_pills = " ".join(f'<span class="cat-pill">{c}</span>' for c in matched)
629
-
630
- sv = pep["suggested_vials"]
631
- price_cells = ""
632
- for vials in range(1, 7):
633
- price = pep["pricing"][vials]
634
- is_suggested = vials == sv
635
- cell_class = "price-cell-suggested" if is_suggested else "price-cell"
636
- suggested_label = '<div class="price-suggested-label">✓ Recommended</div>' if is_suggested else ""
637
- per_week = price / max(vials * 4, 1)
638
- price_cells += (
639
- f'<div class="{cell_class}">'
640
- f'<div class="price-vials">{vials} Vial{"s" if vials > 1 else ""}</div>'
641
- f'<div class="price-per-week">${per_week:,.2f}</div>'
642
- f'<div class="price-per-week-label">per week</div>'
643
- f'<div class="price-amount">${price:,.2f} total</div>'
644
- f'{suggested_label}'
645
- f'</div>'
646
- )
647
-
648
- badge_html = f'<div class="{badge_class}">{badge_text}</div>' if show_badge else ""
649
- st.markdown(
650
- f'<div class="{card_class}">'
651
- f'{badge_html}'
652
- f'<div class="pep-name">{display_name}</div>'
653
- f'{"<div class=pep-components>" + components_str + "</div>" if components_str else ""}'
654
- f'<div class="pep-desc">{pep["description"]}</div>'
655
- f'<div class="pep-moa-scott"><span class="pep-moa-label">How it works:</span> {pep.get("moa_scott", "")}</div>'
656
- f'<div class="pep-moa-clinical">{pep.get("moa_clinical", "")}</div>'
657
- f'<div class="pep-cats">{cat_pills}</div>'
658
- f'<div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:12px;">'
659
- f'<div>'
660
- f'<div class="pep-label">Dosage</div>'
661
- f'<div class="pep-value">{pep["dosage"]}</div>'
662
- f'</div>'
663
- f'<div>'
664
- f'<div class="pep-label">Cycle</div>'
665
- f'<div class="pep-value">{pep["cycle"]}</div>'
666
- f'</div>'
667
- f'</div>'
668
- f'<div class="pep-label">Vial Amount: {pep["vial_amount"]} | Source: {pep["source"]}</div>'
669
- f'<div class="pep-label" style="margin-top:10px;">Pricing</div>'
670
- f'<div class="pricing-grid" style="grid-template-columns:repeat(6,1fr)">{price_cells}</div>'
671
- f'</div>',
672
- unsafe_allow_html=True,
673
- )
674
-
675
- if branded:
676
- st.markdown('<div class="section-band">Ignite Branded Blends — Recommended</div>', unsafe_allow_html=True)
677
- st.markdown(
678
- '<p style="color:#4a6070;font-size:0.9rem;margin-bottom:16px;">'
679
- 'Curated multi-peptide protocols from our proprietary blend line. These combine complementary peptides '
680
- 'into a single vial for convenience and synergistic benefit.</p>',
681
- unsafe_allow_html=True,
682
- )
683
- for pep_key, score, matched in branded[:6]:
684
- render_card(pep_key, score, matched, is_branded=True)
685
-
686
- if blends:
687
- st.markdown('<div class="section-band">Combination Blends</div>', unsafe_allow_html=True)
688
- for pep_key, score, matched in blends[:4]:
689
- render_card(pep_key, score, matched, is_branded=False)
690
-
691
- if singles:
692
- st.markdown('<div class="section-band">Individual Peptides</div>', unsafe_allow_html=True)
693
- st.markdown(
694
- '<p style="color:#4a6070;font-size:0.9rem;margin-bottom:16px;">'
695
- 'Single-peptide options for targeted protocols or for patients who prefer to build their stack one component at a time.</p>',
696
- unsafe_allow_html=True,
697
- )
698
- for pep_key, score, matched in singles[:4]:
699
- render_card(pep_key, score, matched, is_branded=False)
700
-
701
- # ── CTA ──
702
- st.markdown(
703
- f'<div class="cta-box">'
704
- f'<h3>Ready to Get Started, {pname}?</h3>'
705
- f'<p>These recommendations are based on your stated goals. All peptide protocols require '
706
- f'physician evaluation before we begin. Our team will walk through each option during your consultation, '
707
- f'answer your questions, and build a protocol that fits your situation.</p>'
708
- f'<p><strong>What happens next:</strong> our team reaches out, we schedule your consultation, '
709
- f'and we go from there.</p>'
710
- f'<p><strong>Contact:</strong> {pemail} &nbsp;|&nbsp; {pphone}</p>'
711
- f'<a class="cta-link" href="{BRAND["scheduling_url"]}" target="_blank">Schedule Your Consultation</a>'
712
- f'</div>',
713
- unsafe_allow_html=True,
714
- )
715
-
716
- # ── PDF Download ──
717
- st.markdown('<hr class="styled-hr">', unsafe_allow_html=True)
718
- st.markdown("#### Download Your Recommendation")
719
-
720
- if "cached_pep_pdf" not in st.session_state:
721
- st.session_state["cached_pep_pdf"] = generate_pdf(
722
- {"name": pname, "email": pemail, "phone": pphone},
723
- selected_goals,
724
- top_cats,
725
- results,
726
- )
727
-
728
- st.download_button(
729
- "Download PDF",
730
- data=st.session_state["cached_pep_pdf"],
731
- file_name="ignite_peptide_protocol.pdf",
732
- mime="application/pdf",
733
- use_container_width=True,
734
- )
735
-
736
- # ── Start over ──
737
- st.markdown('<hr class="styled-hr">', unsafe_allow_html=True)
738
- if st.button("Start New Selection", use_container_width=True):
739
- for key in ["pep_results", "pep_goals", "pep_top_cats",
740
- "pep_patient_name", "pep_patient_email", "pep_patient_phone",
741
- "cached_pep_pdf"]:
742
- if key in st.session_state:
743
- del st.session_state[key]
744
- st.session_state["pep_results"] = None
745
- st.session_state["pep_goals"] = []
746
- st.session_state["pep_top_cats"] = []
747
- st.session_state["pep_patient_name"] = ""
748
- st.session_state["pep_patient_email"] = ""
749
- st.session_state["pep_patient_phone"] = ""
750
- st.rerun()
751
-
752
- render_footer()
753
- st.stop()
754
-
755
-
756
- # =============================================================================
757
- # INTAKE FORM
758
- # =============================================================================
759
- st.markdown(
760
- '<div class="hero">'
761
- f'{"<img class=hero-logo src=" + chr(34) + LOGO_B64 + chr(34) + " alt=Ignite />" if LOGO_B64 else ""}'
762
- '<div class="hero-title">Peptide Protocol Selector</div>'
763
- '<div class="hero-sub">Find the Right Peptides for Your Goals</div>'
764
- '<div class="hero-tagline">Physician-Supervised · Evidence-Informed · Personalized</div>'
765
- '</div>',
766
- unsafe_allow_html=True,
767
- )
768
-
769
- st.markdown(
770
- "Select your health goals below and we will match you to the peptide protocols that fit best. "
771
- "Every recommendation requires physician review before we proceed. "
772
- "This is not a prescription tool — it is a starting point for your consultation.",
773
- )
774
-
775
- with st.form("peptide_intake"):
776
-
777
- st.markdown('<div class="section-band">Your Information</div>', unsafe_allow_html=True)
778
- c1, c2 = st.columns(2)
779
- with c1:
780
- first_name = st.text_input("First Name *")
781
- email = st.text_input("Email Address *")
782
- with c2:
783
- last_name = st.text_input("Last Name *")
784
- phone = st.text_input("Cell Phone *")
785
-
786
- st.markdown('<div class="section-band">What Are You Looking to Address?</div>', unsafe_allow_html=True)
787
- st.caption("Select all goals that apply. We will match peptides to your priorities.")
788
-
789
- # Build flat goal list grouped by category
790
- goal_checks = {}
791
- cat_keys = list(CATEGORIES.keys())
792
- mid = (len(cat_keys) + 1) // 2
793
-
794
- c1, c2 = st.columns(2)
795
- with c1:
796
- for cat_name in cat_keys[:mid]:
797
- cat = CATEGORIES[cat_name]
798
- st.markdown(
799
- f'<p style="color:#219ebc;font-weight:700;font-size:0.85rem;margin:12px 0 4px;text-transform:uppercase;">'
800
- f'{cat_name}</p>',
801
- unsafe_allow_html=True,
802
- )
803
- for goal in cat["goals"]:
804
- goal_checks[goal] = st.checkbox(goal, key=f"g_{goal}")
805
- with c2:
806
- for cat_name in cat_keys[mid:]:
807
- cat = CATEGORIES[cat_name]
808
- st.markdown(
809
- f'<p style="color:#219ebc;font-weight:700;font-size:0.85rem;margin:12px 0 4px;text-transform:uppercase;">'
810
- f'{cat_name}</p>',
811
- unsafe_allow_html=True,
812
- )
813
- for goal in cat["goals"]:
814
- goal_checks[goal] = st.checkbox(goal, key=f"g_{goal}")
815
-
816
- st.markdown('<div class="section-band">Additional Context</div>', unsafe_allow_html=True)
817
- additional = st.text_area(
818
- "Anything else we should know? (injuries, current medications, previous peptide experience, etc.)",
819
- placeholder="Optional — helps our physician team customize your protocol.",
820
- )
821
-
822
- # ── Consent ──
823
- st.markdown('<div class="section-band">Consent &amp; Privacy</div>', unsafe_allow_html=True)
824
- st.markdown(
825
- '<p style="color:#023047;font-size:0.88rem;line-height:1.6;margin-bottom:12px;">'
826
- '<strong style="color:#f58300;">Important:</strong> This platform is '
827
- '<strong>not HIPAA-compliant</strong>. Do not share sensitive medical records, '
828
- 'Social Security numbers, or information you would not disclose on a non-secure platform.</p>',
829
- unsafe_allow_html=True,
830
- )
831
- consent = st.checkbox(
832
- "I understand this is an informational tool, not a prescription. "
833
- "All peptide protocols require physician evaluation and approval.",
834
- key="consent",
835
- )
836
-
837
- submitted = st.form_submit_button("Find My Peptides", use_container_width=True)
838
-
839
- # ── Processing ──
840
- if submitted:
841
- selected_goals = [g for g, checked in goal_checks.items() if checked]
842
-
843
- errors = []
844
- if not first_name: errors.append("First Name")
845
- if not last_name: errors.append("Last Name")
846
- if not email: errors.append("Email Address")
847
- if not phone: errors.append("Cell Phone")
848
- if not selected_goals: errors.append("At least one health goal")
849
- if not consent: errors.append("Consent acknowledgment")
850
-
851
- if errors:
852
- st.error(f"Please complete: **{', '.join(errors)}**")
853
- st.stop()
854
-
855
- results = score_peptides(selected_goals)
856
- top_cats = get_top_categories(selected_goals)
857
-
858
- if not results:
859
- st.warning("No peptides matched your selected goals. Please try different selections.")
860
- st.stop()
861
-
862
- st.session_state["pep_results"] = results
863
- st.session_state["pep_goals"] = selected_goals
864
- st.session_state["pep_top_cats"] = top_cats
865
- st.session_state["pep_patient_name"] = f"{first_name} {last_name}"
866
- st.session_state["pep_patient_email"] = email
867
- st.session_state["pep_patient_phone"] = phone
868
- st.rerun()
869
-
870
- render_footer()