from fpdf import FPDF
from fpdf.enums import XPos, YPos
import math

class PremiumPDF(FPDF):
    def draw_pill(self, x, y, w, h, text, bg_color, text_color):
        self.set_fill_color(*bg_color)
        self.rect(x, y, w, h, 'F', round_corners=True, corner_radius=h/2)
        self.set_xy(x, y + (h/2) - 1.5)
        self.set_font('helvetica', 'B', 6)
        self.set_text_color(*text_color)
        self.cell(w, 3, text, align='C')

pdf = PremiumPDF()
pdf.add_page()
pdf.set_fill_color(248, 250, 252)
pdf.rect(0, 0, 210, 297, 'F')

# Header
pdf.set_font('helvetica', '', 8)
pdf.set_text_color(100, 116, 139)
pdf.cell(0, 5, "Dashboard > Tickets > REP-50B3F4", new_x=XPos.LMARGIN, new_y=YPos.NEXT)

pdf.set_xy(165, 10)
pdf.draw_pill(165, 10, 30, 6, "Export Report", (255,255,255), (99,102,241))
pdf.set_draw_color(203, 213, 225)
pdf.line(165, 10, 195, 10) # dummy border

pdf.ln(8)

# Hero Card
hero_y = pdf.get_y()
pdf.set_fill_color(255, 255, 255)
pdf.set_draw_color(226, 232, 240)
pdf.rect(15, hero_y, 180, 28, style='DF', round_corners=True, corner_radius=3)

pdf.set_xy(20, hero_y + 5)
pdf.set_font('helvetica', 'B', 14)
pdf.set_text_color(30, 41, 59)
pdf.cell(100, 6, "Add the count of domain")

pdf.draw_pill(175, hero_y + 5, 15, 5, "HIGH", (254,242,242), (220,38,38))

# Badges
pdf.set_xy(20, hero_y + 16)
pdf.draw_pill(20, hero_y+16, 20, 5, "TASK", (224,242,254), (2,132,199))
pdf.draw_pill(45, hero_y+16, 25, 5, "BACKLOG", (220,252,231), (22,163,74))

pdf.output("test_premium.pdf")
print("Done")
