File size: 29,774 Bytes
6035a63
925be92
69872a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c21e695
925be92
60dc554
3ea1518
60dc554
3ea1518
 
60dc554
 
 
 
 
3ea1518
60dc554
 
3ea1518
 
60dc554
 
69872a1
60dc554
 
3ea1518
60dc554
 
3ea1518
 
 
60dc554
69872a1
60dc554
3ea1518
 
60dc554
 
3ea1518
 
60dc554
 
69872a1
60dc554
3ea1518
 
60dc554
 
3ea1518
 
60dc554
 
69872a1
60dc554
3ea1518
 
60dc554
 
3ea1518
 
60dc554
 
69872a1
60dc554
 
3ea1518
60dc554
 
3ea1518
 
69872a1
60dc554
 
 
 
3ea1518
60dc554
 
3ea1518
 
69872a1
60dc554
 
 
 
3ea1518
60dc554
 
3ea1518
 
69872a1
60dc554
69872a1
60dc554
 
3ea1518
60dc554
 
3ea1518
 
60dc554
3ea1518
69872a1
60dc554
 
3ea1518
60dc554
 
3ea1518
 
60dc554
 
69872a1
60dc554
 
3ea1518
60dc554
 
3ea1518
 
60dc554
 
 
 
 
3ea1518
60dc554
 
3ea1518
c21e695
 
3ea1518
 
60dc554
3ea1518
 
60dc554
 
 
3ea1518
60dc554
 
 
 
 
3ea1518
60dc554
 
 
69872a1
 
60dc554
3ea1518
60dc554
3ea1518
60dc554
 
 
 
 
3ea1518
 
60dc554
 
3ea1518
 
60dc554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ea1518
 
 
60dc554
 
 
 
 
3ea1518
60dc554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4362e02
3ea1518
69872a1
3ea1518
 
 
 
 
 
 
 
 
 
 
 
c21e695
69872a1
3ea1518
 
 
 
 
 
 
 
 
 
b8b24ec
3ea1518
69872a1
3ea1518
 
69872a1
 
3ea1518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c21e695
60dc554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6035a63
60dc554
c21e695
925be92
 
c21e695
aa1a9f0
 
 
 
 
 
 
 
c21e695
60dc554
 
 
 
 
 
 
 
6035a63
 
 
 
 
 
 
 
 
 
60dc554
 
 
 
 
 
 
 
c21e695
925be92
c21e695
aa1a9f0
c21e695
60dc554
 
c21e695
 
925be92
 
60dc554
 
 
c21e695
 
 
925be92
 
c21e695
 
 
 
6035a63
c21e695
 
 
 
 
925be92
c21e695
 
 
 
 
 
925be92
c21e695
 
 
 
 
 
60dc554
 
925be92
 
 
c21e695
 
 
 
 
 
925be92
 
c21e695
 
 
925be92
c21e695
aa1a9f0
 
69872a1
 
aa1a9f0
 
925be92
c21e695
925be92
69872a1
 
c21e695
 
925be92
c21e695
 
925be92
c21e695
 
 
925be92
aa1a9f0
925be92
 
 
 
6035a63
 
 
 
 
 
 
 
 
 
 
 
 
925be92
c21e695
 
925be92
c21e695
925be92
3ea1518
 
c21e695
 
 
925be92
c21e695
 
925be92
c21e695
 
 
 
925be92
c21e695
6035a63
 
 
 
 
 
 
c21e695
925be92
 
 
 
 
 
 
 
 
 
 
 
c21e695
6035a63
925be92
6035a63
925be92
c21e695
 
6035a63
 
 
 
 
 
c21e695
 
925be92
 
c21e695
 
 
925be92
c21e695
 
 
 
 
 
6035a63
925be92
c21e695
 
 
 
 
 
99839c8
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
import gradio as gr
from datetime import datetime
import re

def extract_month_from_period(period_text):
    """이벤트 기간에서 월 추출"""
    if not period_text or period_text.strip() == "":
        return None
    
    # 날짜 패턴 찾기 (YYYY.MM.DD 또는 MM.DD 형식)
    date_patterns = [
        r'(\d{4})\.(\d{1,2})\.(\d{1,2})',  # 2024.12.01
        r'(\d{1,2})\.(\d{1,2})',          # 12.01
        r'(\d{1,2})월',                   # 12월
    ]
    
    for pattern in date_patterns:
        matches = re.findall(pattern, period_text)
        if matches:
            if len(matches[0]) == 3:  # YYYY.MM.DD
                month = int(matches[0][1])
            elif len(matches[0]) == 2:  # MM.DD
                month = int(matches[0][0])
            else:  # 월
                month = int(matches[0])
            
            if 1 <= month <= 12:
                return f"{month}월"
    
    return None

def analyze_concepts(month):
    """20-40대 여성 맞춤 월별 컨셉 분석"""
    
    # 월별 상세 데이터 (20-40대 여성 타겟 특화)
    monthly_data = {
        "1월": {
            "holidays": ["신정", "설날"],
            "special_days": ["다이어트 시작", "새해 다짐", "리셋 라이프"],
            "seasonal_terms": ["소한", "대한", "입춘"],
            "trends": ["새해 다짐", "다이어트", "정리정돈", "미니멀라이프", "헬스케어", "자기계발"],
            "seasons": ["겨울", "신년", "새로운 시작"],
            "colors": ["#FF6B6B", "#4ECDC4", "#45B7D1"],
            "mood": "희망적이고 새로운 시작",
            "female_appeal": ["새해 다짐", "다이어트", "셀프케어", "라이프스타일 리셋"]
        },
        "2월": {
            "holidays": ["밸런타인데이"],
            "special_days": ["갈렌타인데이", "셀프러브", "사랑의 달"],
            "seasonal_terms": ["입춘", "우수"],
            "trends": ["셀프러브", "갈렌타인", "로맨스", "따뜻한 감성", "핑크 무드"],
            "seasons": ["겨울 끝", "봄 준비", "로맨틱"],
            "colors": ["#FF69B4", "#FFB6C1", "#DC143C"],
            "mood": "로맨틱하고 감성적",
            "female_appeal": ["셀프러브", "우정", "로맨스", "감성"]
        },
        "3월": {
            "holidays": ["삼일절", "화이트데이"],
            "special_days": ["여성의 날", "봄의 시작", "새학기"],
            "seasonal_terms": ["경칩", "춘분"],
            "trends": ["봄맞이", "벚꽃 시즌", "봄 패션", "새출발", "꽃구경"],
            "seasons": ["봄", "벚꽃", "새싹"],
            "colors": ["#FFB6C1", "#98FB98", "#87CEEB"],
            "mood": "설렘가득하고 활기찬",
            "female_appeal": ["봄 패션", "꽃구경", "새출발", "여성의 날"]
        },
        "4월": {
            "holidays": ["만우절"],
            "special_days": ["벚꽃 시즌", "봄나들이", "피크닉"],
            "seasonal_terms": ["청명", "곡우"],
            "trends": ["벚꽃축제", "봄피크닉", "아웃도어", "꽃놀이", "봄여행"],
            "seasons": ["봄 절정", "꽃구경", "나들이"],
            "colors": ["#98FB98", "#F0E68C", "#DDA0DD"],
            "mood": "생기발랄하고 즐거운",
            "female_appeal": ["벚꽃놀이", "피크닉", "봄여행", "감성사진"]
        },
        "5월": {
            "holidays": ["근로자의날"],
            "special_days": ["로즈데이", "가정의 달", "감사의 달"],
            "seasonal_terms": ["입하", "소만"],
            "trends": ["감사", "나들이", "로즈데이", "봄여행", "힐링"],
            "seasons": ["신록", "야외활동", "따뜻함"],
            "colors": ["#32CD32", "#FFB6C1", "#87CEEB"],
            "mood": "따뜻하고 감사한",
            "female_appeal": ["로즈데이", "감사표현", "힐링", "나들이"]
        },
        "6월": {
            "holidays": ["현충일"],
            "special_days": ["키스데이", "여름 준비", "다이어트"],
            "seasonal_terms": ["망종", "하지"],
            "trends": ["여름준비", "다이어트", "쿨링", "바캉스준비", "여름패션"],
            "seasons": ["초여름", "더위", "여름준비"],
            "colors": ["#00CED1", "#FFD700", "#FF6347"],
            "mood": "시원하고 활동적인",
            "female_appeal": ["여름 다이어트", "쿨링케어", "바캉스", "여름패션"]
        },
        "7월": {
            "holidays": ["제헌절"],
            "special_days": ["실버데이", "여름휴가", "바캉스"],
            "seasonal_terms": ["소서", "대서", "초복", "중복"],
            "trends": ["여름휴가", "바캉스", "휴가패션", "여행", "힐링"],
            "seasons": ["여름", "휴가", "바캉스"],
            "colors": ["#00BFFF", "#FFD700", "#FF6347"],
            "mood": "역동적이고 자유로운",
            "female_appeal": ["바캉스", "여행", "휴가패션", "힐링"]
        },
        "8월": {
            "holidays": ["광복절"],
            "special_days": ["그린데이", "여름 마무리", "휴가"],
            "seasonal_terms": ["입추", "처서", "말복"],
            "trends": ["여름휴가", "바다여행", "축제", "여름추억", "힐링"],
            "seasons": ["한여름", "휴가절정", "추억"],
            "colors": ["#00BFFF", "#FF6347", "#FFD700"],
            "mood": "열정적이고 추억가득한",
            "female_appeal": ["여름추억", "힐링", "여행", "감성사진"]
        },
        "9월": {
            "holidays": ["추석"],
            "special_days": ["포토데이", "뮤직데이", "가을시작"],
            "seasonal_terms": ["백로", "추분"],
            "trends": ["가을패션", "독서", "문화생활", "감성", "카페"],
            "seasons": ["가을", "선선함", "감성"],
            "colors": ["#FF8C00", "#DC143C", "#B8860B"],
            "mood": "감성적이고 성숙한",
            "female_appeal": ["가을패션", "카페", "독서", "감성사진"]
        },
        "10월": {
            "holidays": ["한글날"],
            "special_days": ["와인데이", "커피데이", "독서의 달"],
            "seasonal_terms": ["한로", "상강"],
            "trends": ["가을단풍", "독서", "카페문화", "와인", "감성"],
            "seasons": ["단풍", "가을정취", "감성"],
            "colors": ["#FF8C00", "#DC143C", "#B8860B"],
            "mood": "감성적이고 여유로운",
            "female_appeal": ["단풍구경", "카페", "와인", "독서"]
        },
        "11월": {
            "holidays": ["빼빼로데이"],
            "special_days": ["무비데이", "오렌지데이", "연말준비"],
            "seasonal_terms": ["입동", "소설"],
            "trends": ["빼빼로데이", "연말준비", "겨울패션", "따뜻함", "코지"],
            "seasons": ["늦가을", "겨울준비", "포근함"],
            "colors": ["#8B4513", "#A0522D", "#CD853F"],
            "mood": "포근하고 준비하는",
            "female_appeal": ["빼빼로데이", "겨울패션", "연말모임", "코지라이프"]
        },
        "12월": {
            "holidays": ["크리스마스"],
            "special_days": ["허그데이", "연말파티", "송년"],
            "seasonal_terms": ["대설", "동지"],
            "trends": ["크리스마스", "연말파티", "선물", "송년회", "겨울감성"],
            "seasons": ["겨울", "연말", "크리스마스"],
            "colors": ["#DC143C", "#228B22", "#FFD700"],
            "mood": "축제같고 따뜻한",
            "female_appeal": ["크리스마스", "연말모임", "선물", "겨울감성"]
        }
    }
    
    data = monthly_data.get(month, {})
    
    # 20-40대 여성 맞춤 컨셉 생성 (6가지)
    concepts = []
    
    # 컨셉 1: 여성 타겟 기념일/특별한 날 기반
    if data.get("special_days"):
        special = data["special_days"][0]
        concepts.append({
            "name": f"{special} 스페셜 이벤트",
            "theme": f"{special}를 테마로 한 20-40대 여성 맞춤 이벤트",
            "score": 8.8,
            "reason": f"20-40대 여성이 공감할 수 있는 {special} 테마로 높은 참여도 예상",
            "target": "20-40대 여성, 라이프스타일 관심층",
            "colors": data.get("colors", ["#FF69B4"]),
            "keywords": [special] + data.get("female_appeal", [])[:2],
            "participation_factor": "여성 라이프스타일 공감대, 특별함",
            "is_recommended": True
        })
    
    # 컨셉 2: 트렌드 기반 (여성 친화적)
    if data.get("trends"):
        trend = data["trends"][0]
        concepts.append({
            "name": f"{trend} 챌린지",
            "theme": f"20-40대 여성 트렌드 {trend} 참여형 이벤트",
            "score": 8.5,
            "reason": f"현재 여성층에게 인기 있는 {trend} 트렌드로 높은 관심도",
            "target": "20-30대 트렌드 민감층, SNS 활용 여성",
            "colors": data.get("colors", ["#4ECDC4"]),
            "keywords": data.get("trends", [])[:3],
            "participation_factor": "트렌드 화제성, SNS 확산성",
            "is_recommended": False
        })
    
    # 컨셉 3: 절기 기반 (현대적 해석)
    if data.get("seasonal_terms"):
        term = data["seasonal_terms"][0]
        concepts.append({
            "name": f"{term} 모던 라이프",
            "theme": f"절기 {term}을 현대적으로 해석한 라이프스타일 이벤트",
            "score": 7.5,
            "reason": f"전통 절기를 현대 여성 라이프스타일로 재해석한 참신함",
            "target": "전연령 여성, 감성적 라이프스타일 추구층",
            "colors": data.get("colors", ["#8FBC8F"]),
            "keywords": data.get("seasonal_terms", [])[:2] + ["모던", "라이프스타일"],
            "participation_factor": "전통의 현대적 재해석, 감성적 어필",
            "is_recommended": False
        })
    
    # 컨셉 4: 계절감 + 여성 어필 기반  
    if data.get("seasons"):
        season = data["seasons"][0]
        concepts.append({
            "name": f"{season} 감성 라이프",
            "theme": f"{season} 계절을 만끽하는 여성 라이프스타일 이벤트",
            "score": 8.0,
            "reason": f"{season} 계절감과 여성 감성을 결합한 자연스러운 참여 유도",
            "target": "20-40대 감성 중시 여성, 계절감 추구층",
            "colors": data.get("colors", ["#98FB98"]),
            "keywords": data.get("seasons", []) + data.get("female_appeal", [])[:2],
            "participation_factor": "계절 감성, 여성 라이프스타일 공감대",
            "is_recommended": True
        })
    
    # 컨셉 5: 셀프케어/힐링 기반
    concepts.append({
        "name": f"{month} 셀프케어 위크",
        "theme": "나를 위한 특별한 시간, 셀프케어 라이프스타일 이벤트",
        "score": 8.3,
        "reason": "20-40대 여성의 핵심 관심사인 셀프케어로 강한 어필",
        "target": "20-40대 여성, 셀프케어 관심층",
        "colors": data.get("colors", ["#FFB6C1"]),
        "keywords": ["셀프케어", "힐링", "나를 위한 시간", "웰빙"],
        "participation_factor": "자기관리 욕구, 힐링 니즈",
        "is_recommended": True
    })
    
    # 컨셉 6: 커뮤니티 소통 (여성 친화적)
    concepts.append({
        "name": f"{month} 언니들의 수다",
        "theme": "20-40대 여성들의 진솔한 소통과 공감 이벤트",
        "score": 7.8,
        "reason": "여성 커뮤니티 특성을 살린 친밀한 소통으로 참여 유도",
        "target": "기존 여성 회원, 커뮤니티 소통 선호층",
        "colors": data.get("colors", ["#87CEEB"]),
        "keywords": ["소통", "공감", "언니들", "진솔함"],
        "participation_factor": "여성 커뮤니티 소속감, 친밀감",
        "is_recommended": False
    })
    
    # 점수순 정렬 및 추천 컨셉 우선
    concepts.sort(key=lambda x: (x.get("is_recommended", False), x["score"]), reverse=True)
    
    # 추천 컨셉 찾기
    recommended_concept = next((c for c in concepts if c.get("is_recommended", False)), concepts[0])
    
    # 결과 텍스트 생성
    result = f"# 🎯 {month} 20-40대 여성 맞춤 컨셉 분석\n\n"
    result += f"## 🏆 이달의 추천 컨셉: {recommended_concept['name']}\n"
    result += f"**⭐ 추천 이유:** {recommended_concept['reason']}\n"
    result += f"**📊 예상 참여도:** {recommended_concept['score']}/10점\n\n"
    result += "---\n\n"
    
    result += f"**📊 분석 기준:** {data.get('mood', '특별한')} 분위기\n"
    result += f"**🎨 주요 색상:** {', '.join(data.get('colors', ['기본색상'])[:3])}\n"
    result += f"**🔥 여성 어필 트렌드:** {', '.join(data.get('female_appeal', ['기본트렌드'])[:3])}\n"
    result += f"**🌿 해당 절기:** {', '.join(data.get('seasonal_terms', ['해당없음']))}\n\n"
    
    concept_names = []
    
    for i, concept in enumerate(concepts, 1):
        is_recommended_mark = " 🏆 **추천**" if concept.get("is_recommended", False) else ""
        result += f"## {i}. {concept['name']}{is_recommended_mark}\n"
        result += f"**🏷️ 테마:** {concept['theme']}\n"
        result += f"**⭐ 참여도 점수:** {concept['score']}/10점\n"
        result += f"**💡 선정 이유:** {concept['reason']}\n"
        result += f"**🎯 주요 타겟:** {concept['target']}\n"
        result += f"**🔑 핵심 키워드:** {', '.join(concept['keywords'])}\n"
        result += f"**📈 참여 요인:** {concept['participation_factor']}\n"
        result += f"**🎨 추천 색상:** {', '.join(concept['colors'])}\n\n"
        result += "---\n\n"
        
        concept_names.append(concept['name'])
    
    result += f"**💬 총평:** {month}{data.get('mood', '특별한')} 특성을 가진 달로, "
    result += f"특히 20-40대 여성에게는 '{data.get('female_appeal', ['특별한'])[0]}' 관련 이벤트가 "
    result += f"높은 참여도를 보일 것으로 예상됩니다."
    
    return result, concept_names "계절 공감대, 일상 연관성"
    
    
    # 컨셉 5: 스페셜 데이 기반
    if data.get("special_days"):
        special = data["special_days"][0]
        concepts.append({
            "name": f"{special} 스페셜 위크",
            "theme": f"{special} 맞이 특별 혜택 이벤트",
            "score": 7.8,
            "reason": f"{special}의 특별함으로 프리미엄 이벤트 효과",
            "target": "20-40대 여성, 혜택 관심층",
            "colors": data.get("colors", ["#FFB6C1"]),
            "keywords": data.get("special_days", [])[:2] + ["혜택", "특별"],
            "participation_factor": "특별함 기대, 혜택 매력도"
        })
    
    # 컨셉 6: 커뮤니티 소통 기반
    concepts.append({
        "name": f"{month} 우리들의 이야기",
        "theme": "커뮤니티 멤버 간 소통과 공감 이벤트",
        "score": 7.0,
        "reason": "커뮤니티 결속력 강화와 지속적 참여 유도",
        "target": "기존 회원, 커뮤니티 활동 적극층",
        "colors": data.get("colors", ["#87CEEB"]),
        "keywords": ["소통", "공감", "스토리", "우리"],
        "participation_factor": "소속감, 진정성"
    })
    
    # 결과 텍스트 생성
    result = f"# 🎯 {month} 고도화된 컨셉 분석 (절기 포함)\n\n"
    result += f"**📊 분석 기준:** {data.get('mood', '특별한')} 분위기\n"
    result += f"**🎨 주요 색상:** {', '.join(data.get('colors', ['기본색상'])[:3])}\n"
    result += f"**🔥 핵심 트렌드:** {', '.join(data.get('trends', ['기본트렌드'])[:3])}\n"
    result += f"**🌿 해당 절기:** {', '.join(data.get('seasonal_terms', ['해당없음']))}\n\n"
    
    concept_names = []
    
    for i, concept in enumerate(concepts, 1):
        result += f"## {i}. {concept['name']}\n"
        result += f"**🏷️ 테마:** {concept['theme']}\n"
        result += f"**⭐ 참여도 점수:** {concept['score']}/10점\n"
        result += f"**💡 선정 이유:** {concept['reason']}\n"
        result += f"**🎯 주요 타겟:** {concept['target']}\n"
        result += f"**🔑 핵심 키워드:** {', '.join(concept['keywords'])}\n"
        result += f"**📈 참여 요인:** {concept['participation_factor']}\n"
        result += f"**🎨 추천 색상:** {', '.join(concept['colors'])}\n\n"
        result += "---\n\n"
        
        concept_names.append(concept['name'])
    
    result += f"**💬 총평:** {month}{data.get('mood', '특별한')} 특성을 가진 달로, "
    result += f"특히 '{data.get('trends', ['트렌드'])[0]}' 관련 이벤트가 높은 참여도를 보일 것으로 예상됩니다."
    
    return result, concept_names

def generate_trendy_copy(concept_name, month, event_period):
    """트렌디한 카피라이팅 생성"""
    
    # 월별 트렌디한 키워드와 분위기
    monthly_vibes = {
        "1월": {"vibe": "새로운 시작", "keywords": ["리셋", "다짐", "새해"], "hashtags": ["#새해새출발", "#다이어트시작", "#셀프케어"]},
        "2월": {"vibe": "로맨틱", "keywords": ["사랑", "감성", "따뜻함"], "hashtags": ["#셀프러브", "#갈렌타인", "#감성충전"]},
        "3월": {"vibe": "설렘", "keywords": ["봄", "새출발", "꽃"], "hashtags": ["#봄맞이", "#새시작", "#벚꽃시즌"]},
        "4월": {"vibe": "생기발랄", "keywords": ["꽃", "나들이", "피크닉"], "hashtags": ["#벚꽃놀이", "#봄나들이", "#감성사진"]},
        "5월": {"vibe": "감사", "keywords": ["힐링", "감사", "여유"], "hashtags": ["#힐링타임", "#감사한일상", "#나를위한시간"]},
        "6월": {"vibe": "시원함", "keywords": ["여름", "쿨링", "다이어트"], "hashtags": ["#여름준비", "#쿨링케어", "#바디프로필"]},
        "7월": {"vibe": "자유로움", "keywords": ["바캉스", "휴가", "힐링"], "hashtags": ["#바캉스룩", "#여행스타그램", "#힐링여행"]},
        "8월": {"vibe": "열정", "keywords": ["추억", "여행", "자유"], "hashtags": ["#여름추억", "#휴가끝", "#감성여행"]},
        "9월": {"vibe": "감성", "keywords": ["가을", "감성", "카페"], "hashtags": ["#가을감성", "#카페투어", "#독서모드"]},
        "10월": {"vibe": "여유", "keywords": ["단풍", "카페", "감성"], "hashtags": ["#가을단풍", "#감성카페", "#독서의계절"]},
        "11월": {"vibe": "포근함", "keywords": ["따뜻함", "코지", "준비"], "hashtags": ["#코지라이프", "#겨울준비", "#따뜻한일상"]},
        "12월": {"vibe": "축제", "keywords": ["크리스마스", "연말", "마무리"], "hashtags": ["#크리스마스무드", "#연말정산", "#따뜻한겨울"]}
    }
    
    month_key = month.replace('월', '월')
    vibe_data = monthly_vibes.get(month_key, {"vibe": "특별한", "keywords": ["이벤트"], "hashtags": ["#특별한순간"]})
    
    # 언어유희와 트렌드를 반영한 카피 생성
    copies = {
        "다이어트 시작": {
            "sub1": "🌟 새해, 새로운 나를 만나는 시간",
            "main": "다이어트는 '다이'아몬드처럼 빛나는 '어트'랙티브한 나!",
            "sub2": "올해는 정말 다를거야 💪✨",
            "hashtags": ["#다이어트시작", "#새해새몸", "#건강한변화", "#셀프케어"]
        },
        "셀프러브": {
            "sub1": "💕 나를 사랑하는 가장 완벽한 방법",
            "main": "Self-Love는 셀프 러브가 아니라 '설프 러브'야!",
            "sub2": "오늘부터 나에게 더 다정하게 💖",
            "hashtags": ["#셀프러브", "#나를위한시간", "#자기사랑", "#갈렌타인"]
        },
        "봄맞이": {
            "sub1": "🌸 봄이 오면 마음도 설레는 이유",
            "main": "봄맞이? 봄 '맞다'이! 이 계절이 딱 맞아떨어져",
            "sub2": "새로운 시작이 기다리고 있어요 🌱",
            "hashtags": ["#봄맞이", "#새시작", "#벚꽃시즌", "#설렘충전"]
        },
        "바캉스": {
            "sub1": "🏖️ 올여름 가장 핫한 힐링 플랜",
            "main": "바캉스는 '바'로 '캉'스럽게 쉬는 거야!",
            "sub2": "휴가 = 휴식 + 가치있는 시간 ☀️",
            "hashtags": ["#바캉스", "#여행스타그램", "#힐링여행", "#휴가룩"]
        },
        "가을감성": {
            "sub1": "🍂 가을이 선사하는 특별한 감성",
            "main": "가을엔 '가'슴이 '을'마나 따뜻해지는지",
            "sub2": "이 계절만의 포근함을 만끽해요 🧡",
            "hashtags": ["#가을감성", "#감성카페", "#단풍구경", "#코지라이프"]
        },
        "크리스마스": {
            "sub1": "🎄 한 해의 마지막을 빛내는 특별함",
            "main": "Merry Christmas? 메리하게 크리스마스!",
            "sub2": "소중한 사람들과 따뜻한 연말 보내요 ❄️",
            "hashtags": ["#크리스마스무드", "#따뜻한겨울", "#연말감성", "#소중한순간"]
        }
    }
    
    # 컨셉명에서 키워드 추출하여 적절한 카피 선택
    selected_copy = None
    for keyword, copy_data in copies.items():
        if any(k in concept_name for k in keyword.split()):
            selected_copy = copy_data
            break
    
    # 기본 카피 (매칭되는 것이 없을 때)
    if not selected_copy:
        selected_copy = {
            "sub1": f"✨ {vibe_data['vibe']}한 순간을 위한 특별 초대",
            "main": f"{concept_name}로 만드는 나만의 스토리",
            "sub2": f"{vibe_data['keywords'][0]}의 계절, 함께 만들어가요 💫",
            "hashtags": vibe_data['hashtags']
        }
    
    return selected_copy

def generate_notice(concept, event_type, event_period, prize_benefits):
    """트렌디한 카피라이팅이 포함된 공지사항 생성"""
    
    if not concept:
        return "먼저 컨셉을 선택해주세요."
    
    # 이벤트 기간이 입력되지 않았으면 기본값 사용
    if not event_period or event_period.strip() == "":
        now = datetime.now()
        start_date = now.strftime("%Y.%m.%d")
        end_date = f"{now.year}.{now.month}.{now.day + 7}"
        period_text = f"{start_date} ~ {end_date}"
    else:
        period_text = event_period
    
    # 월 추출
    month = extract_month_from_period(period_text)
    if not month:
        month = f"{datetime.now().month}월"
    
    # 트렌디한 카피 생성
    copy_data = generate_trendy_copy(concept, month, period_text)
    
    # 당첨 혜택이 입력되지 않았으면 기본값 사용
    if not prize_benefits or prize_benefits.strip() == "":
        default_benefits = """✨ 1등 (1명): 스타벅스 5만원 기프트카드
🎉 2등 (3명): 베스킨라빈스 아이스크림 쿠폰
💝 3등 (10명): 편의점 5천원 상품권
🌟 참가상 (50명): 모바일 치킨 쿠폰"""
        benefits_text = default_benefits
    else:
        benefits_text = prize_benefits
    
    # 해시태그 문자열 생성
    hashtags_text = " ".join(copy_data['hashtags'])
    
    notice = f"""{copy_data['sub1']}

💫 {copy_data['main']} 💫

{copy_data['sub2']}

🎉 {concept} 🎉

📅 이벤트 기간: {period_text} 23:59

{hashtags_text}

========================
✨ EVENT
특별한 {concept}을 준비했어요!
많은 분들의 적극적인 참여를 기다리고 있습니다 💕

이번 이벤트는 단순한 참여가 아닌, 
우리만의 특별한 추억을 만들어가는 시간이에요 ✨
========================

🎯 참여 방법
1️⃣ 이벤트 내용 확인하기
2️⃣ {event_type} 참여하기
3️⃣ 참여 완료!

=================
🎁 당첨혜택
{benefits_text}

📋 추첨: 참여자 중 무작위 추첨
========================

👥 이벤트 대상
✅ 커뮤니티 회원
✅ 만 18세 이상
✅ 이벤트 기간 내 참여자
========================

⚠️ 주의사항
※ 부적절한 참여는 제외됩니다
※ 중복 참여 불가
※ 당첨자는 본인 확인 필요

===========================
📞 문의: 1234-5678
💬 카카오톡: @event_community

{hashtags_text}

💝 많은 참여 부탁드려요! 감사합니다 💕"""
    
    return notice

def create_interface():
    """그라디오 인터페이스 생성"""
    
    with gr.Blocks(title="이벤트 공지사항 생성기") as demo:
        
        gr.Markdown("# 🎉 이벤트 공지사항 생성기")
        gr.Markdown("### 간편하게 이벤트 공지사항을 만들어보세요!")
        
        with gr.Row():
            with gr.Column():
                gr.Markdown("## 설정")
                
                event_period_input = gr.Textbox(
                    label="이벤트 기간",
                    placeholder="예: 2024.12.01 ~ 2024.12.07 (월이 자동 인식됩니다)",
                    info="이벤트 기간을 입력하면 해당 월이 자동으로 선택됩니다"
                )
                
                month_dropdown = gr.Dropdown(
                    choices=[f"{i}월" for i in range(1, 13)],
                    label="이벤트 월 선택",
                    value="1월",
                    info="이벤트 기간에서 자동 인식되거나 직접 선택"
                )
                
                analyze_btn = gr.Button("컨셉 분석하기", variant="primary")
                
                concept_dropdown = gr.Dropdown(
                    label="컨셉 선택",
                    visible=False
                )
                
                event_type_dropdown = gr.Dropdown(
                    choices=["댓글 달기", "게시글 작성", "좋아요 누르기"],
                    label="이벤트 유형",
                    value="댓글 달기"
                )
                
                gr.Markdown("## 🎁 당첨 혜택 설정")
                
                prize_benefits_input = gr.Textbox(
                    label="당첨 혜택",
                    placeholder="""예시:
✨ 1등 (1명): 아이폰 15 Pro
🎉 2등 (3명): 에어팟 프로
💝 3등 (10명): 스타벅스 1만원 기프트카드
🌟 참가상 (50명): 카페 아메리카노 쿠폰""",
                    lines=6,
                    info="당첨 혜택을 입력하지 않으면 기본 혜택이 적용됩니다"
                )
                
                generate_btn = gr.Button("공지사항 생성하기", variant="secondary", visible=False)
            
            with gr.Column():
                gr.Markdown("## 결과")
                
                concept_output = gr.Textbox(
                    label="고도화된 분석 결과",
                    lines=20,
                    placeholder="먼저 '컨셉 분석하기' 버튼을 클릭하세요"
                )
                
                notice_output = gr.Textbox(
                    label="생성된 공지사항",
                    lines=20,
                    placeholder="컨셉을 선택하고 '공지사항 생성하기' 버튼을 클릭하세요"
                )
        
        # 상태 변수
        concepts_state = gr.State([])
        selected_concept_state = gr.State("")
        
        def handle_period_change(period_text):
            """이벤트 기간 변경시 월 자동 인식"""
            detected_month = extract_month_from_period(period_text)
            if detected_month:
                return gr.update(value=detected_month)
            return gr.update()
        
        def handle_analyze(month):
            """분석 처리"""
            result, concepts = analyze_concepts(month)
            return (
                result,
                gr.update(choices=concepts, visible=True, value=concepts[0]),
                gr.update(visible=True),
                concepts
            )
        
        def handle_concept_change(concept, concepts):
            """컨셉 변경 처리"""
            return concept
        
        def handle_generate(concept, event_type, event_period, prize_benefits):
            """생성 처리"""
            notice = generate_notice(concept, event_type, event_period, prize_benefits)
            return notice
        
        # 이벤트 연결
        event_period_input.change(
            handle_period_change,
            inputs=[event_period_input],
            outputs=[month_dropdown]
        )
        
        analyze_btn.click(
            handle_analyze,
            inputs=[month_dropdown],
            outputs=[concept_output, concept_dropdown, generate_btn, concepts_state]
        )
        
        concept_dropdown.change(
            handle_concept_change,
            inputs=[concept_dropdown, concepts_state],
            outputs=[selected_concept_state]
        )
        
        generate_btn.click(
            handle_generate,
            inputs=[selected_concept_state, event_type_dropdown, event_period_input, prize_benefits_input],
            outputs=[notice_output]
        )
    
    return demo

if __name__ == "__main__":
    demo = create_interface()
    demo.launch()