@page
@model TaxBaik.Web.Pages.IndexModel
@{
    var season = Model.CurrentSeason;
    ViewData["Title"] = season != null
        ? $"백원숙 세무회계 | {season.Name} — 지금 상담하세요"
        : "백원숙 세무회계 | 사업자·부동산·증여상속 세무 상담";
    ViewData["Description"] = "사업자 기장, 부동산 양도세·증여상속, 종합소득세 전문 상담. 온라인 맞춤 상담 제공.";
}

@* ─── 공지사항 배너 (관리자 등록 공지) ─── *@
@if (Model.ActiveAnnouncements.Count > 0)
{
    foreach (var notice in Model.ActiveAnnouncements)
    {
        <div class="announcement-bar announcement-bar--@notice.DisplayType">
            <div class="container d-flex align-items-center gap-2 py-2">
                <span class="announcement-icon">
                    @if (notice.DisplayType == "urgent") { <text>🚨</text> }
                    else if (notice.DisplayType == "banner") { <text>📢</text> }
                    else { <text>ℹ️</text> }
                </span>
                <span class="announcement-text fw-semibold">@notice.Title</span>
                @if (!string.IsNullOrEmpty(notice.Content))
                {
                    <span class="d-none d-md-inline text-muted small ms-2">— @notice.Content</span>
                }
            </div>
        </div>
    }
}

@* ─── Hero Section ─── *@
@if (season != null)
{
    <section class="hero-section hero-section--seasonal text-white pt-5 pb-4">
        <div class="container">
            <div class="row align-items-center py-4">
                <div class="col-lg-7">
                    <span class="badge bg-danger-badge mb-3 fs-6 px-3 py-2">
                        @season.UrgencyBadge
                    </span>
                    <h1 class="mb-3" style="white-space: pre-line;">@season.HeroHeadline</h1>
                    <p class="fs-5 mb-4" style="line-height: 1.8; opacity: 0.95;">
                        @season.HeroSubtext
                    </p>
                    <div class="d-flex gap-3 flex-wrap">
                        <a href="/taxbaik/contact" class="btn btn-warning btn-lg fw-bold">
                            ⏰ @season.CtaText
                        </a>
                        <a href="javascript:void(0);" class="btn btn-outline-primary btn-lg"
                           onclick="openKakao()" style="border-color: white; color: white;">
                            💬 카카오채널 문의
                        </a>
                    </div>
                    @if (season.DaysUntilDeadline <= 7)
                    {
                        <p class="mt-3 small" style="opacity: 0.8;">
                            마감까지 <strong>@(season.DaysUntilDeadline)일</strong> 남았습니다.
                            지금 바로 상담 신청하세요.
                        </p>
                    }
                </div>
                <div class="col-lg-5 d-none d-lg-block text-center">
                    <div class="seasonal-deadline-badge">
                        <div class="deadline-label">마감</div>
                        <div class="deadline-date">@season.Deadline.ToString("M월 d일")</div>
                        <div class="deadline-days">D-@season.DaysUntilDeadline</div>
                    </div>
                </div>
            </div>
        </div>
    </section>
}
else
{
    <section class="hero-section text-white pt-5 pb-4">
        <div class="container">
            <div class="row align-items-center py-4">
                <div class="col-lg-7">
                    <span class="badge bg-primary-badge mb-3">경험 있는 세무사의 맞춤 전략</span>
                    <h1 class="mb-3">
                        세금과 자산<br/>
                        <span style="color: #E8E4D8;">한 번에 해결하는</span>
                    </h1>
                    <p class="fs-5 mb-4" style="line-height: 1.8; opacity: 0.95;">
                        사업자 세무, 부동산 거래, 가족자산 관리를 위한<br/>
                        통합 솔루션을 제공합니다.
                    </p>
                    <div class="d-flex gap-3 flex-wrap">
                        <a href="/taxbaik/contact" class="btn btn-primary btn-lg">무료 상담 신청</a>
                        <a href="javascript:void(0);" class="btn btn-outline-primary btn-lg"
                           onclick="openKakao()" style="border-color: white; color: white;">
                            💬 카카오채널 문의
                        </a>
                    </div>
                </div>
                <div class="col-lg-5 d-none d-lg-block text-center">
                    <div style="font-size: 120px; opacity: 0.15;">📋</div>
                </div>
            </div>
        </div>
    </section>
}

<!-- About 링크 배너 -->
<section class="py-3" style="background: rgba(46, 92, 78, 0.05); border-bottom: 1px solid rgba(46, 92, 78, 0.1);">
    <div class="container">
        <div class="d-flex justify-content-between align-items-center gap-3 flex-wrap">
            <div>
                <p class="mb-0 small text-muted">세무사의 경력, 자격, 상담 철학을 알아보세요</p>
            </div>
            <a href="/taxbaik/about" class="btn btn-sm btn-outline-primary">백원숙 세무사 소개 →</a>
        </div>
    </div>
</section>

<!-- 서비스 영역 -->
<section class="py-5">
    <div class="container">
        <div class="text-center mb-5">
            <h2 class="section-title">전문 서비스</h2>
            <p class="fs-6 text-muted" style="max-width: 600px; margin: 0 auto;">
                각 분야의 복잡한 세무 이슈를 경험과 노하우로 해결합니다
            </p>
        </div>

        @{
            var focusService = season?.FocusService ?? "";
            // 시즌에 따라 서비스 카드 순서 결정
            var cardOrder = focusService switch
            {
                "real-estate-tax" => new[] { "real-estate-tax", "business-tax", "family-asset" },
                "family-asset"    => new[] { "family-asset",    "business-tax", "real-estate-tax" },
                _                 => new[] { "business-tax",    "real-estate-tax", "family-asset" }
            };
        }

        <div class="row g-4">
            @foreach (var cardKey in cardOrder)
            {
                var isFeatured = cardKey == focusService;
                if (cardKey == "business-tax")
                {
                    <div class="col-lg-4 col-md-6">
                        <div class="card service-card h-100 @(isFeatured ? "service-card--featured" : "")">
                            @if (isFeatured) { <div class="service-card-badge">현재 시즌</div> }
                            <div class="service-icon">📊</div>
                            <div class="card-body pt-0">
                                <h3 class="card-title">사업자 세무</h3>
                                <p class="text-muted small">월 기장부터 종합소득세, 신규 사업자 세무까지 — 사업 초기부터 체계적인 세무 관리.</p>
                                <a href="/taxbaik/services#business-tax" class="btn btn-sm btn-outline-primary mt-3">자세히 보기</a>
                            </div>
                        </div>
                    </div>
                }
                else if (cardKey == "real-estate-tax")
                {
                    <div class="col-lg-4 col-md-6">
                        <div class="card service-card h-100 @(isFeatured ? "service-card--featured" : "")">
                            @if (isFeatured) { <div class="service-card-badge">현재 시즌</div> }
                            <div class="service-icon">🏠</div>
                            <div class="card-body pt-0">
                                <h3 class="card-title">부동산 세금</h3>
                                <p class="text-muted small">양도세·취득세·임대소득세 — 부동산 거래 시 세금 부담을 줄이는 전략.</p>
                                <a href="/taxbaik/services#real-estate-tax" class="btn btn-sm btn-outline-primary mt-3">자세히 보기</a>
                            </div>
                        </div>
                    </div>
                }
                else
                {
                    <div class="col-lg-4 col-md-6">
                        <div class="card service-card h-100 @(isFeatured ? "service-card--featured" : "")">
                            @if (isFeatured) { <div class="service-card-badge">현재 시즌</div> }
                            <div class="service-icon">👨‍👩‍👧‍👦</div>
                            <div class="card-body pt-0">
                                <h3 class="card-title">가족자산 관리</h3>
                                <p class="text-muted small">증여상속 사전 계획부터 대표자 리스크 관리까지 - 가족 자산을 지키는 전략.</p>
                                <a href="/taxbaik/services#family-asset" class="btn btn-sm btn-outline-primary mt-3">자세히 보기</a>
                            </div>
                        </div>
                    </div>
                }
            }
        </div>
    </div>
</section>

<!-- 블로그 & 시즌 포스트 (상단으로 올림) -->
<section class="py-5">
    <div class="container">
        <div class="text-center mb-5">
            @if (season != null)
            {
                <div class="seasonal-blog-header mb-2">
                    <span class="seasonal-blog-tag">📅 @season.Name 시즌</span>
                </div>
                <h2 class="section-title">이번 시즌 세무 정보</h2>
                <p class="text-muted">@season.Name 관련 절세 팁과 신고 가이드를 확인하세요</p>
            }
            else
            {
                <h2 class="section-title">세무 정보 & 절세 팁</h2>
                <p class="text-muted">최신 세법 변화와 실무 팁을 공유합니다</p>
            }
        </div>

        @{
            var hasSeasonalPosts = Model.SeasonalPosts?.Count > 0;
            var hasRecentPosts = Model.RecentPosts?.Count > 0;
        }

        @if (hasSeasonalPosts || hasRecentPosts)
        {
            <div class="row g-4">
                @* 시즌 관련 글 (배지 강조) *@
                @if (hasSeasonalPosts)
                {
                    @foreach (var post in Model.SeasonalPosts!)
                    {
                        <div class="col-lg-4 col-md-6">
                            <div class="card blog-card h-100 blog-card--seasonal">
                                <div class="blog-seasonal-ribbon">이번 시즌 추천</div>
                                <div class="blog-placeholder">🗓️</div>
                                <div class="card-body">
                                    <small class="badge bg-season-badge">@post.CategoryName</small>
                                    <h4 class="card-title mt-3">@post.Title</h4>
                                    <p class="text-muted small">@((post.PublishedAt ?? post.CreatedAt).ToString("yyyy년 MM월 dd일"))</p>
                                    <a href="/taxbaik/blog/@post.Slug" class="btn btn-sm btn-seasonal">읽기</a>
                                </div>
                            </div>
                        </div>
                    }
                }
                @* 최신 글 (나머지 채우기) *@
                @if (hasRecentPosts)
                {
                    @foreach (var post in Model.RecentPosts!)
                    {
                        <div class="col-lg-4 col-md-6">
                            <div class="card blog-card h-100">
                                <div class="blog-placeholder">📝</div>
                                <div class="card-body">
                                    <small class="badge bg-primary-badge">@post.CategoryName</small>
                                    <h4 class="card-title mt-3">@post.Title</h4>
                                    <p class="text-muted small">@((post.PublishedAt ?? post.CreatedAt).ToString("yyyy년 MM월 dd일"))</p>
                                    <a href="/taxbaik/blog/@post.Slug" class="btn btn-sm btn-primary">읽기</a>
                                </div>
                            </div>
                        </div>
                    }
                }
            </div>

            <div class="text-center mt-5 d-flex justify-content-center gap-3 flex-wrap">
                @if (season != null && !string.IsNullOrEmpty(season.RelatedCategorySlug))
                {
                    <a href="/taxbaik/blog?category=@season.RelatedCategorySlug" class="btn btn-outline-secondary btn-lg">
                        📅 @season.Name 전체 글 보기
                    </a>
                }
                <a href="/taxbaik/blog" class="btn btn-outline-primary btn-lg">전체 블로그 보기</a>
            </div>
        }
        else
        {
            <div class="text-center py-5">
                <div class="mb-3" style="font-size: 3rem;">📝</div>
                <h3 class="h5 mb-2">현재 표시할 블로그 글이 없습니다.</h3>
                <p class="text-muted mb-4">최신 세무 정보는 블로그에서 확인할 수 있습니다.</p>
                <a href="/taxbaik/blog" class="btn btn-outline-primary btn-lg">블로그 바로가기</a>
            </div>
        }
    </div>
</section>

<!-- 상담 프로세스 -->
<section class="py-5" style="background: #F9F7F3;">
    <div class="container">
        <div class="text-center mb-5">
            <h2 class="section-title">상담 과정</h2>
        </div>

        <div class="row align-items-center">
            <div class="col-md-3 text-center mb-4 mb-md-0">
                <div style="width: 80px; height: 80px; margin: 0 auto 1rem; background: linear-gradient(135deg, #C89D6E 0%, #A67C52 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 32px;">
                    📞
                </div>
                <h4>1단계: 무료 상담</h4>
                <p class="text-muted small">상황 파악 및<br/>현재 문제점 확인</p>
            </div>
            <div class="col-md-3 text-center mb-4 mb-md-0">
                <div style="width: 80px; height: 80px; margin: 0 auto 1rem; background: linear-gradient(135deg, #C89D6E 0%, #A67C52 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 32px;">
                    📋
                </div>
                <h4>2단계: 세무진단</h4>
                <p class="text-muted small">자료 분석 및<br/>최적 방안 도출</p>
            </div>
            <div class="col-md-3 text-center mb-4 mb-md-0">
                <div style="width: 80px; height: 80px; margin: 0 auto 1rem; background: linear-gradient(135deg, #C89D6E 0%, #A67C52 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 32px;">
                    💡
                </div>
                <h4>3단계: 맞춤제안</h4>
                <p class="text-muted small">절세 전략 및<br/>실행 계획 제시</p>
            </div>
            <div class="col-md-3 text-center">
                <div style="width: 80px; height: 80px; margin: 0 auto 1rem; background: linear-gradient(135deg, #C89D6E 0%, #A67C52 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 32px;">
                    ✅
                </div>
                <h4>4단계: 실행지원</h4>
                <p class="text-muted small">지속적 관리 및<br/>추가 상담 제공</p>
            </div>
        </div>

        <div class="text-center mt-5">
            <p class="text-muted mb-3">상담은 온라인 또는 오프라인으로 진행되며, 완전히 비밀이 보장됩니다.</p>
            <a href="/taxbaik/contact" class="btn btn-primary btn-lg">상담 신청하기</a>
        </div>
    </div>
</section>

<!-- 자주 묻는 질문 (DB 연동) -->
@if (Model.ActiveFaqs.Count > 0)
{
<section class="py-5" style="background: #F9F7F3;">
    <div class="container">
        <div class="text-center mb-5">
            <h2 class="section-title">자주 묻는 질문</h2>
            <p class="text-muted">상담 전 궁금하신 사항을 먼저 확인해 보세요</p>
        </div>

        <div class="faq-accordion">
            @foreach (var faqItem in Model.ActiveFaqs)
            {
                <details class="faq-item">
                    <summary class="faq-question">@faqItem.Question</summary>
                    <div class="faq-answer">
                        @faqItem.Answer
                    </div>
                </details>
            }
        </div>

        <div class="text-center mt-5">
            <p class="text-muted mb-3">더 궁금한 점이 있으시면 바로 문의해 주세요</p>
            <a href="/taxbaik/contact" class="btn btn-primary btn-lg">상담 문의하기</a>
        </div>
    </div>
</section>
}

<!-- 최종 CTA -->
<section class="py-5" style="background: linear-gradient(135deg, #2E5C4E 0%, #1F3A30 100%); color: white;">
    <div class="container text-center">
        @if (season != null)
        {
            <h2 class="mb-3 fw-bold" style="font-size: 2.5rem;">@season.Name 마감이 다가옵니다!</h2>
            <p class="fs-5 mb-5" style="opacity: 0.95; max-width: 500px; margin-left: auto; margin-right: auto;">
                마감 <strong>D-@(season.DaysUntilDeadline)일</strong> — 지금 바로 상담을 신청하세요.<br/>
                빠른 검토로 불이익 없이 신고를 완료합니다.
            </p>
            <div class="d-flex gap-3 justify-content-center flex-wrap">
                <a href="/taxbaik/contact" class="btn btn-warning btn-lg">⏰ @season.CtaText</a>
                <a href="https://pf.kakao.com/_xoxchTX" target="_blank" rel="noopener noreferrer" class="btn btn-light btn-lg">카카오채널로 문의</a>
            </div>
        }
        else
        {
            <h2 class="mb-3 fw-bold" style="font-size: 2.5rem;">세금 고민은 이제 끝!</h2>
            <p class="fs-5 mb-5" style="opacity: 0.95; max-width: 500px; margin-left: auto; margin-right: auto;">
                무료 상담으로 현재 상황을 진단하고<br/>
                맞춤형 절세 전략을 받아보세요.
            </p>
            <div class="d-flex gap-3 justify-content-center flex-wrap">
                <a href="/taxbaik/contact" class="btn btn-warning btn-lg">상담 신청하기</a>
                <a href="https://pf.kakao.com/_xoxchTX" target="_blank" rel="noopener noreferrer" class="btn btn-light btn-lg">카카오채널로 문의</a>
            </div>
        }
    </div>
</section>
