<!DOCTYPE html>
<html lang="<%= currentLanguage %>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><%= title %> - SmartSolTech Admin</title>
    
    <!-- Tabler CSS -->
    <link href="/node_modules/@tabler/core/dist/css/tabler.min.css" rel="stylesheet"/>
    <link href="/node_modules/@tabler/icons/icons-sprite.svg" rel="stylesheet"/>
    
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    
    <!-- Google Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&display=swap" rel="stylesheet">
    
    <!-- Custom Korean Admin Styles -->
    <style>
        body {
            font-family: 'Noto Sans KR', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
        }
        
        .navbar-brand {
            font-weight: 700;
            color: #206bc4 !important;
        }
        
        .nav-link {
            border-radius: 8px;
            margin: 2px 0;
            font-weight: 500;
        }
        
        .nav-link.active {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white !important;
        }
        
        .page-header h2 {
            font-weight: 600;
            color: #2c3e50;
        }
        
        .card {
            border-radius: 12px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }
        
        .btn {
            border-radius: 8px;
            font-weight: 500;
        }
        
        .navbar {
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            background: white !important;
        }
        
        .navbar-nav .nav-link:hover {
            background-color: rgba(32, 107, 196, 0.1);
        }
        
        .navbar-vertical .navbar-nav .nav-link {
            padding: 0.5rem 1rem;
        }
        
        .page-wrapper {
            background: #f8f9fa;
        }
    </style>
</head>
<body>
    <div class="page">
        <!-- Sidebar -->
        <aside class="navbar navbar-vertical navbar-expand-lg" data-bs-theme="light">
            <div class="container-fluid">
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#sidebar-menu" aria-controls="sidebar-menu" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                
                <h1 class="navbar-brand navbar-brand-autodark">
                    <a href="/admin/dashboard">
                        <img src="/images/icons/icon-192x192.png" width="110" height="32" alt="SmartSolTech" class="navbar-brand-image">
                        SmartSolTech
                    </a>
                </h1>
                
                <div class="collapse navbar-collapse" id="sidebar-menu">
                    <ul class="navbar-nav pt-lg-3">
                        <li class="nav-item">
                            <a class="nav-link <%= currentPage === 'dashboard' ? 'active' : '' %>" href="/admin/dashboard">
                                <span class="nav-link-icon d-md-none d-lg-inline-block">
                                    <i class="fas fa-tachometer-alt"></i>
                                </span>
                                <span class="nav-link-title">대시보드</span>
                            </a>
                        </li>
                        
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#navbar-help" data-bs-toggle="dropdown" data-bs-auto-close="false" role="button" aria-expanded="false">
                                <span class="nav-link-icon d-md-none d-lg-inline-block">
                                    <i class="fas fa-briefcase"></i>
                                </span>
                                <span class="nav-link-title">포트폴리오</span>
                            </a>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="/admin/portfolio">
                                    모든 프로젝트
                                </a>
                                <a class="dropdown-item" href="/admin/portfolio/add">
                                    새 프로젝트 추가
                                </a>
                            </div>
                        </li>
                        
                        <li class="nav-item">
                            <a class="nav-link <%= currentPage === 'services' ? 'active' : '' %>" href="/admin/services">
                                <span class="nav-link-icon d-md-none d-lg-inline-block">
                                    <i class="fas fa-cogs"></i>
                                </span>
                                <span class="nav-link-title">서비스 관리</span>
                                <span class="badge badge-sm bg-green text-white ms-2"><%= stats?.servicesCount || 0 %></span>
                            </a>
                        </li>
                        
                        <li class="nav-item">
                            <a class="nav-link <%= currentPage === 'contacts' ? 'active' : '' %>" href="/admin/contacts">
                                <span class="nav-link-icon d-md-none d-lg-inline-block">
                                    <i class="fas fa-envelope"></i>
                                </span>
                                <span class="nav-link-title">문의 관리</span>
                                <span class="badge badge-sm bg-yellow text-white ms-2"><%= stats?.contactsCount || 0 %></span>
                            </a>
                        </li>
                        
                        <li class="nav-item">
                            <a class="nav-link <%= currentPage === 'media' ? 'active' : '' %>" href="/admin/media">
                                <span class="nav-link-icon d-md-none d-lg-inline-block">
                                    <i class="fas fa-images"></i>
                                </span>
                                <span class="nav-link-title">미디어 관리</span>
                            </a>
                        </li>
                        
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#navbar-settings" data-bs-toggle="dropdown" data-bs-auto-close="false" role="button" aria-expanded="false">
                                <span class="nav-link-icon d-md-none d-lg-inline-block">
                                    <i class="fas fa-cog"></i>
                                </span>
                                <span class="nav-link-title">시스템</span>
                            </a>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="/admin/settings">
                                    사이트 설정
                                </a>
                                <a class="dropdown-item" href="/admin/telegram">
                                    텔레그램 봇
                                </a>
                                <a class="dropdown-item" href="/admin/banner-editor">
                                    배너 편집기
                                </a>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </aside>
        
        <!-- Header -->
        <header class="navbar navbar-expand-md d-print-none">
            <div class="container-xl">
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-menu" aria-controls="navbar-menu" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                
                <div class="navbar-nav flex-row order-md-last">
                    <div class="nav-item dropdown">
                        <a href="#" class="nav-link d-flex lh-1 text-reset p-0" data-bs-toggle="dropdown" aria-label="Open user menu">
                            <span class="avatar avatar-sm" style="background-image: url('/images/icons/icon-192x192.png')"></span>
                            <div class="d-none d-xl-block ps-2">
                                <div><%= user ? user.name : '관리자' %></div>
                                <div class="mt-1 small text-muted">관리자</div>
                            </div>
                        </a>
                        <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow">
                            <a href="/admin/settings" class="dropdown-item">설정</a>
                            <a href="/" target="_blank" class="dropdown-item">사이트 보기</a>
                            <div class="dropdown-divider"></div>
                            <form action="/admin/logout" method="post" class="dropdown-item p-0">
                                <button type="submit" class="btn btn-link text-left w-100 text-danger">
                                    로그아웃
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </header>
        
        <div class="page-wrapper">
            <!-- Page header -->
            <div class="page-header d-print-none">
                <div class="container-xl">
                    <div class="row g-2 align-items-center">
                        <div class="col">
                            <h2 class="page-title">
                                <%= title %>
                            </h2>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Page body -->
            <div class="page-body">
                <div class="container-xl">
                    <%- body %>
                </div>
            </div>
        </div>
    </div>

    <!-- Tabler JavaScript -->
    <script src="/node_modules/@tabler/core/dist/js/tabler.min.js"></script>
    
    <!-- Custom JavaScript -->
    <script src="/js/main.js"></script>
    
    <script>
        // Korean localization and enhancements
        document.addEventListener('DOMContentLoaded', function() {
            // Add smooth transitions for navigation
            const navLinks = document.querySelectorAll('.nav-link');
            navLinks.forEach(link => {
                link.addEventListener('click', function() {
                    if (!this.classList.contains('active') && !this.classList.contains('dropdown-toggle')) {
                        const currentActive = document.querySelector('.nav-link.active');
                        if (currentActive) {
                            currentActive.classList.remove('active');
                        }
                        this.classList.add('active');
                    }
                });
            });
        });
    </script>
</body>
</html>