File size: 25,268 Bytes
f56df65
 
 
 
 
 
 
 
 
 
6a6a99c
 
 
 
f56df65
6a6a99c
f56df65
 
 
6a6a99c
f56df65
6a6a99c
f56df65
6a6a99c
f56df65
6a6a99c
 
 
f56df65
6a6a99c
 
f56df65
 
 
a3e7d7f
f56df65
6a6a99c
f56df65
 
 
 
a3e7d7f
 
 
 
 
 
 
 
 
 
f56df65
 
 
 
 
6a6a99c
a3e7d7f
 
 
 
 
 
 
 
 
f56df65
 
 
 
 
 
6a6a99c
 
f56df65
 
 
 
 
 
 
6a6a99c
f56df65
 
 
 
 
 
 
 
 
 
 
6a6a99c
f56df65
 
 
 
 
6a6a99c
f56df65
 
 
 
6a6a99c
f56df65
6a6a99c
f56df65
 
 
 
 
 
6a6a99c
 
f56df65
 
 
 
 
6a6a99c
f56df65
 
6a6a99c
 
f56df65
6a6a99c
 
 
f56df65
 
 
 
 
6a6a99c
f56df65
 
 
 
6a6a99c
 
f56df65
 
6a6a99c
f56df65
 
 
 
6a6a99c
f56df65
 
 
 
 
 
 
 
 
 
6a6a99c
f56df65
 
 
 
 
 
 
6a6a99c
f56df65
 
 
 
 
 
 
 
6a6a99c
f56df65
 
 
 
 
 
 
6a6a99c
f56df65
 
 
 
 
6a6a99c
 
f56df65
6a6a99c
f56df65
6a6a99c
 
f56df65
 
6a6a99c
f56df65
 
 
 
 
6a6a99c
f56df65
6a6a99c
f56df65
 
6a6a99c
f56df65
6a6a99c
f56df65
6a6a99c
f56df65
6a6a99c
f56df65
 
 
6a6a99c
f56df65
 
6a6a99c
f56df65
 
 
 
 
 
6a6a99c
f56df65
6a6a99c
 
f56df65
 
 
 
 
 
6a6a99c
 
f56df65
 
 
6a6a99c
f56df65
 
 
6a6a99c
f56df65
 
 
 
 
6a6a99c
f56df65
6a6a99c
 
f56df65
 
 
 
 
6a6a99c
f56df65
6a6a99c
 
f56df65
6a6a99c
f56df65
 
 
 
 
 
 
6a6a99c
f56df65
 
6a6a99c
f56df65
 
 
6a6a99c
f56df65
 
 
 
 
 
 
 
 
6a6a99c
 
f56df65
6a6a99c
 
 
f56df65
6a6a99c
f56df65
6a6a99c
 
 
f56df65
6a6a99c
f56df65
6a6a99c
 
 
f56df65
6a6a99c
 
f56df65
 
 
 
 
 
6a6a99c
f56df65
 
 
 
 
6a6a99c
f56df65
6a6a99c
f56df65
 
6a6a99c
f56df65
 
6a6a99c
 
f56df65
 
 
 
 
6a6a99c
f56df65
 
6a6a99c
f56df65
6a6a99c
 
f56df65
 
 
6a6a99c
f56df65
6a6a99c
f56df65
 
 
 
6a6a99c
f56df65
 
 
 
6a6a99c
f56df65
6a6a99c
 
f56df65
 
 
 
6a6a99c
f56df65
6a6a99c
f56df65
 
6a6a99c
f56df65
 
 
6a6a99c
 
f56df65
 
 
 
6a6a99c
f56df65
 
 
6a6a99c
f56df65
 
 
6a6a99c
f56df65
 
 
 
6a6a99c
f56df65
 
 
 
6a6a99c
f56df65
 
 
6a6a99c
f56df65
 
 
 
 
 
 
6a6a99c
 
f56df65
 
6a6a99c
f56df65
 
 
 
 
6a6a99c
f56df65
 
6a6a99c
 
 
 
 
 
 
f56df65
 
 
a3e7d7f
 
 
 
f56df65
 
6a6a99c
f56df65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a6a99c
f56df65
 
 
 
 
 
 
 
 
 
 
 
 
3938a94
f56df65
 
3938a94
6a6a99c
 
3938a94
a3e7d7f
6a6a99c
 
 
f56df65
3938a94
 
 
 
 
 
 
 
 
 
 
f56df65
6a6a99c
f56df65
 
6a6a99c
f56df65
6a6a99c
f56df65
6a6a99c
 
f56df65
 
 
6a6a99c
 
f56df65
 
 
6a6a99c
f56df65
 
 
 
6a6a99c
 
f56df65
 
 
a3e7d7f
 
 
 
f56df65
 
6a6a99c
f56df65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a6a99c
f56df65
 
6a6a99c
f56df65
 
 
 
6a6a99c
5b6c5f3
 
 
6a6a99c
f56df65
6a6a99c
 
 
 
 
 
 
 
 
 
 
 
f56df65
 
6a6a99c
 
f56df65
6a6a99c
f56df65
6a6a99c
 
f56df65
 
 
 
6a6a99c
f56df65
6a6a99c
5b6c5f3
f56df65
 
 
 
6a6a99c
f56df65
6a6a99c
 
 
 
f56df65
6a6a99c
f56df65
 
 
 
 
 
6a6a99c
f56df65
6a6a99c
f56df65
 
6a6a99c
f56df65
6a6a99c
 
 
 
 
f56df65
6a6a99c
f56df65
 
6a6a99c
f56df65
6a6a99c
5b6c5f3
 
 
f56df65
 
 
 
6a6a99c
f56df65
6a6a99c
f56df65
6a6a99c
 
 
 
f56df65
6a6a99c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f56df65
 
6a6a99c
f56df65
5b6c5f3
f56df65
5b6c5f3
6a6a99c
5b6c5f3
6a6a99c
 
 
 
 
 
 
 
 
 
 
 
 
 
f56df65
6a6a99c
f56df65
6a6a99c
f56df65
6a6a99c
f56df65
 
 
6a6a99c
 
 
 
 
f56df65
 
6a6a99c
f56df65
6a6a99c
f56df65
6a6a99c
f56df65
6a6a99c
f56df65
 
6a6a99c
 
 
 
 
 
 
f56df65
 
 
a3e7d7f
 
 
 
f56df65
 
6a6a99c
f56df65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a6a99c
f56df65
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
import gradio as gr
from typing import Dict, Any, List, Optional
import pandas as pd
import logging

logger = logging.getLogger(__name__)

def create_enhanced_okr_tab():
    """
    Creates a modern, visually appealing OKR tab with improved layout and styling.
    Removes the checkbox selector for a cleaner, always-visible design.

    Returns:
        gr.HTML: The Gradio HTML component that will display the formatted OKRs.
    """

    # Custom CSS for modern OKR styling
    okr_custom_css = """
    <style>
    /* Overall Container */
    .okr-container {
        font-family: 'Inter', sans-serif; /* Using Inter font */
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        min-height: 100vh;
        padding: 2rem;
        margin: -1rem; /* Adjust margin to fill the space */
        box-sizing: border-box; /* Ensure padding is included in width/height */
        overflow-y: auto; /* Enable scrolling if content overflows */
    }

    /* Header Section */
    .okr-header {
        text-align: center;
        margin-bottom: 3rem;
        color: white; /* Keep general header text white */
    }

    .okr-title {
        font-size: 2.5rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
        /* Removed background-clip and text-fill-color from here */
        text-shadow: 0 2px 4px rgba(0,0,0,0.1);
        display: flex; /* Use flexbox to align emoji and text */
        justify-content: center;
        align-items: center;
        gap: 0.75rem; /* Space between emoji and text */
    }

    /* New class for the text content within the title */
    .okr-title-content {
        background: linear-gradient(45deg, #ffffff, #e0e7ff);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    /* Ensure emoji maintains its default color */
    .okr-title-emoji {
        font-size: 2.5rem; /* Match title font size for consistent sizing */
        color: initial; /* Reset color to browser default for emoji */
        -webkit-text-fill-color: initial; /* Reset text fill for emoji */
        background-clip: initial; /* Reset background clip for emoji */
    }


    .okr-subtitle {
        font-size: 1.2rem;
        opacity: 0.9;
        font-weight: 300;
        letter-spacing: 0.5px;
    }

    /* Stats Bar */
    .okr-stats-bar {
        display: flex;
        justify-content: center;
        gap: 2rem;
        margin: 2rem 0;
        flex-wrap: wrap;
    }

    .stat-card {
        background: rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 16px;
        padding: 1.5rem;
        text-align: center;
        color: white;
        min-width: 140px;
        transition: all 0.3s ease;
    }

    .stat-card:hover {
        transform: translateY(-2px);
        background: rgba(255, 255, 255, 0.2);
        box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    }

    .stat-number {
        font-size: 2rem;
        font-weight: 700;
        margin-bottom: 0.25rem;
        color: #fbbf24; /* Amber color for numbers */
    }

    .stat-label {
        font-size: 0.9rem;
        opacity: 0.9;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    /* Main Content Area */
    .okr-content {
        background: white;
        border-radius: 24px;
        padding: 0;
        box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        overflow: hidden; /* Ensures rounded corners are applied to children */
        margin-top: 2rem;
    }

    /* Objective Card */
    .okr-objective {
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
        border-left: 6px solid #3b82f6; /* Blue border for objectives */
        margin: 2rem; /* Add margin within the white content box */
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 4px 16px rgba(0,0,0,0.05);
        transition: all 0.3s ease;
    }

    .okr-objective:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    }

    /* Objective Header */
    .objective-header {
        padding: 2rem;
        background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
        color: white;
        position: relative;
        overflow: hidden;
    }

    .objective-header::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M20 20c0 4.4-3.6 8-8 8s-8-3.6-8-8 3.6-8 8-8 8 3.6 8 8zm0-20c0 4.4-3.6 8-8 8s-8-3.6-8-8 3.6-8 8-8 8 3.6 8 8z'/%3E%3C/g%3E%3C/svg%3E");
        pointer-events: none;
    }

    .objective-title {
        font-size: 1.5rem;
        font-weight: 700;
        margin-bottom: 0.75rem;
        position: relative;
        z-index: 1;
    }

    .objective-meta {
        display: flex;
        gap: 2rem;
        margin-top: 1rem;
        flex-wrap: wrap;
        position: relative;
        z-index: 1;
    }

    .meta-item {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.9rem;
        opacity: 0.9;
    }

    .meta-icon {
        width: 16px;
        height: 16px;
        opacity: 0.8;
    }

    /* Key Results Container */
    .key-results-container {
        padding: 2rem; /* Consistent padding for content within objectives */
    }

    /* Key Result Card */
    .key-result {
        background: white;
        border: 2px solid #e5e7eb;
        border-radius: 12px;
        margin: 1.5rem 0;
        overflow: hidden;
        transition: all 0.3s ease;
    }

    .key-result:hover {
        border-color: #3b82f6;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
    }

    .kr-header {
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        padding: 1.5rem;
        border-bottom: 1px solid #e5e7eb;
    }

    .kr-title {
        font-size: 1.2rem;
        font-weight: 600;
        color: #1e293b;
        margin-bottom: 0.75rem;
    }

    .kr-metrics {
        display: flex;
        gap: 1.5rem;
        flex-wrap: wrap;
        margin-top: 1rem;
    }

    .kr-metric {
        background: rgba(59, 130, 246, 0.1);
        color: #1e40af;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        font-size: 0.85rem;
        font-weight: 500;
        border: 1px solid rgba(59, 130, 246, 0.2);
    }

    /* Tasks Section */
    .tasks-section {
        padding: 1.5rem;
    }

    .tasks-title {
        font-size: 1rem;
        font-weight: 600;
        color: #374151;
        margin-bottom: 1rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .task-item {
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 1.25rem;
        margin: 1rem 0;
        transition: all 0.2s ease;
    }

    .task-item:hover {
        background: #f3f4f6;
        border-color: #d1d5db;
    }

    .task-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 1rem;
        gap: 1rem;
    }

    .task-title {
        font-weight: 600;
        color: #111827;
        flex: 1;
        line-height: 1.4;
    }

    .task-priority {
        padding: 0.25rem 0.75rem;
        border-radius: 12px;
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        white-space: nowrap;
    }

    /* Priority Colors */
    .priority-high {
        background: #fef2f2;
        color: #dc2626;
        border: 1px solid #fca5a5;
    }

    .priority-medium {
        background: #fffbeb;
        color: #d97706;
        border: 1px solid #fcd34d;
    }

    .priority-low {
        background: #f0fdf4;
        color: #16a34a;
        border: 1px solid #86efac;
    }

    /* Task Details Grid */
    .task-details {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
        margin-top: 1rem;
    }

    .task-detail-item {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.875rem;
        color: #6b7280;
    }

    .task-detail-label {
        font-weight: 500;
        color: #374151;
        min-width: 80px;
    }

    /* Task Description/Rationale */
    .task-description {
        margin-top: 1rem;
        padding: 1rem;
        background: white;
        border-radius: 6px;
        border-left: 3px solid #3b82f6;
        font-size: 0.9rem;
        line-height: 1.5;
        color: #4b5563;
    }

    /* Empty State */
    .empty-state {
        text-align: center;
        padding: 4rem 2rem;
        color: #6b7280;
    }

    .empty-state-icon {
        font-size: 3rem;
        margin-bottom: 1rem;
    }

    .empty-state-title {
        font-size: 1.5rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: #374151;
    }

    /* Loading Spinner */
    .loading-spinner {
        display: inline-block;
        width: 20px;
        height: 20px;
        border: 3px solid #f3f4f6;
        border-radius: 50%;
        border-top-color: #3b82f6;
        animation: spin 1s ease-in-out infinite;
    }

    @keyframes spin {
        to { transform: rotate(360deg); }
    }

    /* Responsive Adjustments */
    @media (max-width: 768px) {
        .okr-container {
            padding: 1rem;
        }

        .okr-title {
            font-size: 2rem;
        }

        .okr-stats-bar {
            gap: 1rem;
        }

        .stat-card {
            min-width: 120px;
            padding: 1rem;
        }

        .objective-meta {
            flex-direction: column;
            gap: 1rem;
        }

        .task-details {
            grid-template-columns: 1fr;
        }

        .task-header {
            flex-direction: column;
            align-items: flex-start;
        }
    }
    </style>
    """

    with gr.Column(elem_classes=["okr-root-column"]):
        # Inject custom CSS
        gr.HTML(okr_custom_css)

        # Main OKR display area with enhanced styling
        okr_display_html = gr.HTML(
            value=get_initial_okr_display(),
            elem_classes=["okr-display"]
        )

    return okr_display_html

def get_initial_okr_display() -> str:
    """
    Returns the initial HTML display for the OKR tab, showing a loading state.

    Returns:
        str: HTML string for the initial OKR display.
    """
    return """
    <div class="okr-container">
        <div class="okr-header">
            <div class="okr-title">
                <span class="okr-title-emoji">🎯</span>
                <span class="okr-title-content">AI-Generated OKRs & Strategic Tasks</span>
            </div>
            <div class="okr-subtitle">Intelligent objectives and key results based on your LinkedIn analytics</div>
        </div>

        <div class="okr-stats-bar">
            <div class="stat-card">
                <div class="stat-number">-</div>
                <div class="stat-label">Objectives</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">-</div>
                <div class="stat-label">Key Results</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">-</div>
                <div class="stat-label">Tasks</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">-</div>
                <div class="stat-label">High Priority</div>
            </div>
        </div>

        <div class="okr-content">
            <div class="empty-state">
                <div class="empty-state-icon">⏳</div>
                <div class="empty-state-title">Loading OKR Analysis</div>
                <div class="empty-state-description">
                    <div class="loading-spinner"></div>
                    Generating intelligent objectives and actionable tasks from your LinkedIn data...
                </div>
            </div>
        </div>
    </div>
    """

def format_okrs_for_enhanced_display(reconstruction_cache: dict) -> str:
    """
    Enhanced formatting function that creates beautiful HTML for OKR display
    from the reconstruction cache dictionary.

    Args:
        reconstruction_cache (dict): The reconstruction cache containing reconstructed data.
                                     Expected to contain report data with 'actionable_okrs' key.

    Returns:
        str: A comprehensive HTML string representing the OKRs, or an empty state HTML.
    """
    if not reconstruction_cache:
        logger.warning("No reconstruction cache found for display.")
        return get_empty_okr_state()

    # Extract actionable_okrs from the first (and typically only) report in cache
    for report_id, report_data in reconstruction_cache.items():
        if isinstance(report_data, dict) and 'actionable_okrs' in report_data:
            raw_results = {'actionable_okrs': report_data['actionable_okrs']}
            break
    else:
        logger.warning("No 'actionable_okrs' found in reconstruction cache for display.")
        return get_empty_okr_state()

    actionable_okrs = raw_results.get("actionable_okrs", {})
    okrs_list = actionable_okrs.get("okrs", [])

    if not okrs_list:
        logger.info("No OKRs found in 'actionable_okrs' list.")
        return get_empty_okr_state()

    # Calculate statistics for the stats bar
    total_objectives = len(okrs_list)
    total_key_results = sum(len(okr.get('key_results', [])) for okr in okrs_list)
    total_tasks = sum(
        len(kr.get('tasks', []))
        for okr in okrs_list
        for kr in okr.get('key_results', [])
    )
    high_priority_tasks = sum(
        1 for okr in okrs_list
        for kr in okr.get('key_results', [])
        for task in kr.get('tasks', [])
        if task.get('priority', '').lower() == 'high'
    )

    # Build the HTML structure
    html_parts = [f"""
    <div class="okr-container">
        <div class="okr-header">
            <div class="okr-title">
                <span class="okr-title-emoji">🎯</span>
                <span class="okr-title-content">AI-Generated OKRs & Strategic Tasks</span>
            </div>
            <div class="okr-subtitle">Intelligent objectives and key results based on your LinkedIn analytics</div>
        </div>

        <div class="okr-stats-bar">
            <div class="stat-card">
                <div class="stat-number">{total_objectives}</div>
                <div class="stat-label">Objectives</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">{total_key_results}</div>
                <div class="stat-label">Key Results</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">{total_tasks}</div>
                <div class="stat-label">Tasks</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">{high_priority_tasks}</div>
                <div class="stat-label">High Priority</div>
            </div>
        </div>

        <div class="okr-content">
    """]

    for okr_idx, okr_data in enumerate(okrs_list):
        if not isinstance(okr_data, dict):
            logger.warning(f"OKR item at index {okr_idx} is not a dictionary, skipping.")
            continue

        objective = okr_data.get('description', f"Unnamed Objective {okr_idx + 1}")
        timeline = okr_data.get('timeline', 'Not specified')
        owner = okr_data.get('owner', 'Not assigned')

        html_parts.append(f"""
            <div class="okr-objective">
                <div class="objective-header">
                    <div class="objective-title">Objective {okr_idx + 1}: {objective}</div>
                    <div class="objective-meta">
                        <div class="meta-item">
                            <span class="meta-icon">⏰</span>
                            <span>Timeline: {timeline}</span>
                        </div>
                        <div class="meta-item">
                            <span class="meta-icon">πŸ‘€</span>
                            <span>Owner: {owner}</span>
                        </div>
                    </div>
                </div>

                <div class="key-results-container">
        """)

        key_results = okr_data.get('key_results', [])

        if not isinstance(key_results, list) or not key_results:
            html_parts.append('<div class="empty-state">No key results defined for this objective.</div>')
        else:
            for kr_idx, kr_data in enumerate(key_results):
                if not isinstance(kr_data, dict):
                    logger.warning(f"Key Result item for Objective {okr_idx+1} at index {kr_idx} is not a dictionary, skipping.")
                    continue

                kr_desc = kr_data.get('description', f"Unnamed Key Result {kr_idx + 1}")
                target_metric = kr_data.get('target_metric', '')
                target_value = kr_data.get('target_value', '')
                kr_type = kr_data.get('key_result_type', '')
                data_subject = kr_data.get('data_subject', '')

                html_parts.append(f"""
                    <div class="key-result">
                        <div class="kr-header">
                            <div class="kr-title">Key Result {kr_idx + 1}: {kr_desc}</div>
                            <div class="kr-metrics">
                """)

                if target_metric and target_value:
                    html_parts.append(f'<div class="kr-metric">Target: {target_metric} β†’ {target_value}</div>')
                if kr_type:
                    html_parts.append(f'<div class="kr-metric">Type: {kr_type}</div>')
                if data_subject:
                    html_parts.append(f'<div class="kr-metric">Data Subject: {data_subject}</div>')

                html_parts.append('</div></div>')

                # Add tasks
                tasks = kr_data.get('tasks', [])
                if tasks and isinstance(tasks, list):
                    html_parts.append("""
                        <div class="tasks-section">
                            <div class="tasks-title">
                                <span>πŸ“‹</span>
                                <span>Associated Tasks</span>
                            </div>
                    """)

                    for task_idx, task_data in enumerate(tasks):
                        if not isinstance(task_data, dict):
                            logger.warning(f"Task item for Key Result {kr_idx+1} at index {task_idx} is not a dictionary, skipping.")
                            continue

                        task_desc = task_data.get('description', f"Unnamed Task {task_idx + 1}")
                        task_category = task_data.get('category', 'General')
                        
                        priority = task_data.get('priority', 'Medium').lower()
                        effort = task_data.get('effort', 'Not specified')
                        timeline = task_data.get('timeline', 'Not specified')
                        responsible = task_data.get('responsible_party', 'Not assigned')

                        priority_class = f"priority-{priority}" if priority in ['high', 'medium', 'low'] else 'priority-medium'

                        html_parts.append(f"""
                            <div class="task-item">
                                <div class="task-header">
                                    <div class="task-title">{task_idx + 1}. {task_desc}</div>
                                    <div class="task-priority {priority_class}">{priority.upper()}</div>
                                </div>

                                <div class="task-details">
                                    <div class="task-detail-item">
                                        <span class="task-detail-label">Category:</span>
                                        <span>{task_category}</span>
                                    </div>
                                    <div class="task-detail-item">
                                        <span class="task-detail-label">Effort:</span>
                                        <span>{effort}</span>
                                    </div>
                                    <div class="task-detail-item">
                                        <span class="task-detail-label">Timeline:</span>
                                        <span>{timeline}</span>
                                    </div>
                                    <div class="task-detail-item">
                                        <span class="task-detail-label">Responsible:</span>
                                        <span>{responsible}</span>
                                    </div>
                                </div>
                        """)

                        # Add additional details if available
                        obj_deliverable = task_data.get('deliverable')
                        success_criteria = task_data.get('success_criteria_metrics')
                        why_proposed = task_data.get('why')
                        priority_just = task_data.get('priority_justification')
                        dependencies = task_data.get('dependencies')

                        detail_lines = []
                        if obj_deliverable:
                            detail_lines.append(f'<strong>Objective/Deliverable:</strong> {obj_deliverable}')
                        if success_criteria:
                            detail_lines.append(f'<strong>Success Metrics:</strong> {success_criteria}')
                        if why_proposed:
                            detail_lines.append(f'<strong>Rationale:</strong> {why_proposed}')
                        if priority_just:
                            detail_lines.append(f'<strong>Priority Justification:</strong> {priority_just}')
                        if dependencies:
                            detail_lines.append(f'<strong>Dependencies:</strong> {dependencies}')

                        if detail_lines:
                            html_parts.append('<div class="task-description">')
                            html_parts.append('<br>'.join(detail_lines))
                            html_parts.append('</div>')

                        html_parts.append('</div>') # Close task-item

                    html_parts.append('</div>') # Close tasks-section
                else:
                    html_parts.append("""
                        <div class="tasks-section">
                            <div class="empty-state-small">
                                <div class="empty-state-icon">πŸ“„</div>
                                <div class="empty-state-description">No tasks defined for this Key Result.</div>
                            </div>
                        </div>
                    """)

                html_parts.append('</div>') # Close key-result

        html_parts.append('</div></div>') # Close key-results-container and okr-objective

    html_parts.append('</div></div>') # Close okr-content and okr-container

    return ''.join(html_parts)

def get_empty_okr_state() -> str:
    """
    Returns empty state HTML for when no OKRs are available.

    Returns:
        str: HTML string for the empty OKR state.
    """
    return """
    <div class="okr-container">
        <div class="okr-header">
            <div class="okr-title">
                <span class="okr-title-emoji">🎯</span>
                <span class="okr-title-content">AI-Generated OKRs & Strategic Tasks</span>
            </div>
            <div class="okr-subtitle">Intelligent objectives and key results based on your LinkedIn analytics</div>
        </div>

        <div class="okr-stats-bar">
            <div class="stat-card">
                <div class="stat-number">0</div>
                <div class="stat-label">Objectives</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">0</div>
                <div class="stat-label">Key Results</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">0</div>
                <div class="stat-label">Tasks</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">0</div>
                <div class="stat-label">High Priority</div>
            </div>
        </div>

        <div class="okr-content">
            <div class="empty-state">
                <div class="empty-state-icon">πŸ“‹</div>
                <div class="empty-state-title">No OKRs Available</div>
                <div class="empty-state-description">
                    OKR analysis has not been generated yet or no data is available.<br>
                    Please ensure your LinkedIn data has been loaded and the AI analysis has completed.
                </div>
            </div>
        </div>
    </div>
    """