<!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>
    
    <!-- Bootstrap CSS (Local) -->
    <link rel="stylesheet" href="/vendor/bootstrap/bootstrap.min.css">
    
    <!-- AdminLTE CSS (Local) -->
    <link rel="stylesheet" href="/vendor/adminlte/adminlte.min.css">
    
    <!-- Font Awesome (Local) -->
    <link rel="stylesheet" href="/vendor/adminlte/fontawesome.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, .content-wrapper, .main-sidebar {
            font-family: 'Noto Sans KR', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
        }
        
        .brand-text {
            font-weight: 700;
            color: #007bff !important;
        }
        
        .nav-sidebar .nav-link {
            border-radius: 8px;
            margin: 2px 0;
        }
        
        .nav-sidebar .nav-link.active {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
        
        .content-header h1 {
            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;
        }
        
        .info-box {
            border-radius: 12px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }
        
        .info-box-icon {
            border-radius: 12px 0 0 12px;
        }
        
        .navbar-light {
            background: white !important;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .main-sidebar {
            background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
        }
        
        .sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link:hover {
            background-color: rgba(255,255,255,0.1);
        }
    </style>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
    <div class="wrapper">
        <!-- Navbar -->
        <nav class="main-header navbar navbar-expand navbar-light">
            <!-- Left navbar links -->
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" data-widget="pushmenu" href="#" role="button">
                        <i class="fas fa-bars"></i>
                    </a>
                </li>
                <li class="nav-item d-none d-sm-inline-block">
                    <a href="/" class="nav-link" target="_blank">
                        <i class="fas fa-external-link-alt mr-1"></i>
                        사이트 보기
                    </a>
                </li>
            </ul>

            <!-- Right navbar links -->
            <ul class="navbar-nav ml-auto">
                <!-- User Menu -->
                <li class="nav-item dropdown">
                    <a class="nav-link" data-toggle="dropdown" href="#">
                        <i class="far fa-user mr-1"></i>
                        <%= user ? user.name : '관리자' %>
                    </a>
                    <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
                        <div class="dropdown-divider"></div>
                        <a href="/admin/settings" class="dropdown-item">
                            <i class="fas fa-cog mr-2"></i> 설정
                        </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">
                                <i class="fas fa-sign-out-alt mr-2"></i> 로그아웃
                            </button>
                        </form>
                    </div>
                </li>
            </ul>
        </nav>

        <!-- Main Sidebar Container -->
        <aside class="main-sidebar sidebar-light-primary elevation-4">
            <!-- Brand Logo -->
            <a href="/admin/dashboard" class="brand-link">
                <img src="/images/icons/icon-192x192.png" alt="SmartSolTech" class="brand-image img-circle elevation-3" style="opacity: .8">
                <span class="brand-text font-weight-bold">SmartSolTech</span>
            </a>

            <!-- Sidebar -->
            <div class="sidebar">
                <!-- Sidebar Menu -->
                <nav class="mt-3">
                    <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
                        <li class="nav-item">
                            <a href="/admin/dashboard" class="nav-link <%= currentPage === 'dashboard' ? 'active' : '' %>">
                                <i class="nav-icon fas fa-tachometer-alt"></i>
                                <p>대시보드</p>
                            </a>
                        </li>
                        
                        <li class="nav-item">
                            <a href="/admin/portfolio" class="nav-link <%= currentPage === 'portfolio' ? 'active' : '' %>">
                                <i class="nav-icon fas fa-briefcase"></i>
                                <p>
                                    포트폴리오
                                    <% if (typeof stats !== 'undefined' && stats.portfolioCount) { %>
                                    <span class="badge badge-info right"><%= stats.portfolioCount %></span>
                                    <% } %>
                                </p>
                            </a>
                        </li>
                        
                        <li class="nav-item">
                            <a href="/admin/services" class="nav-link <%= currentPage === 'services' ? 'active' : '' %>">
                                <i class="nav-icon fas fa-cogs"></i>
                                <p>
                                    서비스 관리
                                    <% if (typeof stats !== 'undefined' && stats.servicesCount) { %>
                                    <span class="badge badge-success right"><%= stats.servicesCount %></span>
                                    <% } %>
                                </p>
                            </a>
                        </li>
                        
                        <li class="nav-item">
                            <a href="/admin/contacts" class="nav-link <%= currentPage === 'contacts' ? 'active' : '' %>">
                                <i class="nav-icon fas fa-envelope"></i>
                                <p>
                                    문의 관리
                                    <% if (typeof stats !== 'undefined' && stats.contactsCount) { %>
                                    <span class="badge badge-warning right"><%= stats.contactsCount %></span>
                                    <% } %>
                                </p>
                            </a>
                        </li>
                        
                        <li class="nav-item">
                            <a href="/admin/media" class="nav-link <%= currentPage === 'media' ? 'active' : '' %>">
                                <i class="nav-icon fas fa-images"></i>
                                <p>미디어 관리</p>
                            </a>
                        </li>
                        
                        <li class="nav-header">시스템 설정</li>
                        
                        <li class="nav-item">
                            <a href="/admin/settings" class="nav-link <%= currentPage === 'settings' ? 'active' : '' %>">
                                <i class="nav-icon fas fa-cog"></i>
                                <p>사이트 설정</p>
                            </a>
                        </li>
                        
                        <li class="nav-item">
                            <a href="/admin/telegram" class="nav-link <%= currentPage === 'telegram' ? 'active' : '' %>">
                                <i class="nav-icon fab fa-telegram"></i>
                                <p>텔레그램 봇</p>
                            </a>
                        </li>
                        
                        <li class="nav-item">
                            <a href="/admin/banner-editor" class="nav-link <%= currentPage === 'banner-editor' ? 'active' : '' %>">
                                <i class="nav-icon fas fa-paint-brush"></i>
                                <p>배너 편집기</p>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </aside>

        <!-- Content Wrapper -->
        <div class="content-wrapper">
            <!-- Content Header -->
            <div class="content-header">
                <div class="container-fluid">
                    <div class="row mb-2">
                        <div class="col-sm-6">
                            <h1 class="m-0"><%= title %></h1>
                        </div>
                        <div class="col-sm-6">
                            <ol class="breadcrumb float-sm-right">
                                <li class="breadcrumb-item"><a href="/admin/dashboard">홈</a></li>
                                <% if (currentPage !== 'dashboard') { %>
                                <li class="breadcrumb-item active"><%= title %></li>
                                <% } %>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Main content -->
            <section class="content">
                <div class="container-fluid">
                    <%- body %>
                </div>
            </section>
        </div>

        <!-- Footer -->
        <footer class="main-footer">
            <strong>&copy; 2024 <a href="/">SmartSolTech</a></strong>
            모든 권리 보유.
            <div class="float-right d-none d-sm-inline-block">
                <b>Version</b> 2.0.0
            </div>
        </footer>
    </div>

    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Bootstrap 4 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
    <!-- AdminLTE App -->
    <script src="/node_modules/admin-lte/dist/js/adminlte.min.js"></script>
    
    <!-- Custom JavaScript -->
    <script src="/js/main.js"></script>
    
    <script>
        // Korean localization for AdminLTE
        $(document).ready(function() {
            // Update any English text to Korean
            $('.brand-link .brand-text').text('스마트솔테크');
            
            // Add smooth transitions
            $('.nav-link').on('click', function() {
                if (!$(this).hasClass('active')) {
                    $('.nav-link.active').removeClass('active');
                    $(this).addClass('active');
                }
            });
        });
    </script>
</body>
</html>