@{
    var path = (Context.Request.Path.Value ?? string.Empty).ToLowerInvariant();
    Func<string, bool> isActive = target => path.StartsWith(target.ToLowerInvariant(), StringComparison.OrdinalIgnoreCase);
    Func<string, string> activeClass = target => isActive(target) ? "active" : string.Empty;
    var breadcrumbText = ViewData["Title"]?.ToString() ?? "대시보드";
    var coreOpen = isActive("/admin/dashboard") || isActive("/admin/settings") || isActive("/admin/clientlogs") || path == "/admin";
    var customerOpen = isActive("/admin/customers") || isActive("/admin/clients") || isActive("/admin/inquiries") || isActive("/admin/consultingactivities");
    var contentOpen = isActive("/admin/blog") || isActive("/admin/announcements") || isActive("/admin/faqs");
    var financeOpen = isActive("/admin/taxprofiles") || isActive("/admin/taxfilings") || isActive("/admin/taxfilingschedules") || isActive("/admin/revenuetrackings");
}
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@(ViewData["Title"] ?? "TaxBaik Admin")</title>
    <meta name="theme-color" content="#111827" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <link href="https://cdn.jsdelivr.net/npm/@@tabler/core@1.0.0/dist/css/tabler.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/css/admin.css" asp-append-version="true" />
</head>
<body class="admin-app">
    <div class="page admin-shell">
        <header class="navbar navbar-expand-md navbar-light d-print-none admin-topbar">
            <div class="container-fluid">
                <div class="d-flex align-items-center gap-3 flex-wrap admin-topbar-branding">
                    <div class="navbar-brand navbar-brand-autodark">
                        <a href="/admin/dashboard" class="text-decoration-none text-reset fw-semibold">TaxBaik Admin</a>
                    </div>
                    <nav aria-label="breadcrumb" class="admin-topbar-breadcrumb">
                        <ol class="breadcrumb breadcrumb-muted mb-0">
                            <li class="breadcrumb-item"><a href="/admin/dashboard">관리자</a></li>
                            <li class="breadcrumb-item active" aria-current="page">@breadcrumbText</li>
                        </ol>
                    </nav>
                </div>
                <div class="navbar-nav flex-row order-md-last gap-2 align-items-center">
                    <span class="text-muted small d-none d-md-inline">@User.Identity?.Name</span>
                    <a class="btn btn-outline-secondary btn-sm" href="/admin/logout">로그아웃</a>
                </div>
            </div>
        </header>
        <div class="page-wrapper">
            <div class="container-fluid">
                <div class="row g-2">
                    <aside class="col-12 col-lg-2 col-xxl-2">
                        <div class="card shadow-sm border-0 admin-sidebar-card sticky-top">
                            <div class="card-header admin-sidebar-header">
                                <h3 class="card-title mb-0 admin-sidebar-title">관리 메뉴</h3>
                            </div>
                            <div class="card-body p-0 admin-sidebar-body">
                                <div class="accordion accordion-flush" id="adminSidebarAccordion">
                                    <div class="accordion-item">
                                        <h2 class="accordion-header">
                                            <button class="accordion-button @(coreOpen ? string.Empty : "collapsed")" type="button" data-bs-toggle="collapse" data-bs-target="#adminMenuCore" aria-expanded="@(coreOpen ? "true" : "false")">
                                                기본
                                            </button>
                                        </h2>
                                        <div id="adminMenuCore" class="accordion-collapse collapse @(coreOpen ? "show" : string.Empty)" data-bs-parent="#adminSidebarAccordion">
                                            <div class="list-group list-group-flush list-group-transparent">
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/dashboard")" href="/admin/dashboard">▣ 대시보드</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/settings")" href="/admin/settings">⚙ 설정</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/clientlogs")" href="/admin/clientlogs">⌘ 클라이언트 로그</a>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="accordion-item">
                                        <h2 class="accordion-header">
                                            <button class="accordion-button @(customerOpen ? string.Empty : "collapsed")" type="button" data-bs-toggle="collapse" data-bs-target="#adminMenuCustomer" aria-expanded="@(customerOpen ? "true" : "false")">
                                                고객/상담
                                            </button>
                                        </h2>
                                        <div id="adminMenuCustomer" class="accordion-collapse collapse @(customerOpen ? "show" : string.Empty)" data-bs-parent="#adminSidebarAccordion">
                                            <div class="list-group list-group-flush list-group-transparent">
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/customers")" href="/admin/customers">◫ 고객</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/clients")" href="/admin/clients">◫ 고객사</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/inquiries")" href="/admin/inquiries">◫ 문의</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/consultingactivities")" href="/admin/consultingactivities">◫ 상담 활동</a>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="accordion-item">
                                        <h2 class="accordion-header">
                                            <button class="accordion-button @(contentOpen ? string.Empty : "collapsed")" type="button" data-bs-toggle="collapse" data-bs-target="#adminMenuContent" aria-expanded="@(contentOpen ? "true" : "false")">
                                                콘텐츠
                                            </button>
                                        </h2>
                                        <div id="adminMenuContent" class="accordion-collapse collapse @(contentOpen ? "show" : string.Empty)" data-bs-parent="#adminSidebarAccordion">
                                            <div class="list-group list-group-flush list-group-transparent">
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/blog")" href="/admin/blog">✎ 블로그</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/announcements")" href="/admin/announcements">★ 공지사항</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/faqs")" href="/admin/faqs">? FAQ</a>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="accordion-item">
                                        <h2 class="accordion-header">
                                            <button class="accordion-button @(financeOpen ? string.Empty : "collapsed")" type="button" data-bs-toggle="collapse" data-bs-target="#adminMenuFinance" aria-expanded="@(financeOpen ? "true" : "false")">
                                                세무 관리
                                            </button>
                                        </h2>
                                        <div id="adminMenuFinance" class="accordion-collapse collapse @(financeOpen ? "show" : string.Empty)" data-bs-parent="#adminSidebarAccordion">
                                            <div class="list-group list-group-flush list-group-transparent">
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/taxprofiles")" href="/admin/taxprofiles">◧ 세무 프로필</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/taxfilings")" href="/admin/taxfilings">◧ 신고 관리</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/taxfilingschedules")" href="/admin/taxfilingschedules">◧ 신고 일정</a>
                                                <a class="list-group-item list-group-item-action @activeClass("/admin/revenuetrackings")" href="/admin/revenuetrackings">◧ 매출 추적</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </aside>
                    <main class="col-12 col-lg-10 col-xxl-10">
                        <div class="card shadow-sm border-0 admin-content-card admin-main-surface">
                            <div class="card-body p-2 p-md-2 p-lg-2">
                                @RenderBody()
                            </div>
                        </div>
                    </main>
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/@@tabler/core@1.0.0/dist/js/tabler.min.js" defer></script>
    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>









