<!DOCTYPE html>
<html lang="ko">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="Dell Server 정보 및 MAC 주소 처리 시스템">

    <title>{% block title %}Dell Server Info, MAC 정보 처리{% endblock %}</title>

    <link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">

    <!-- Bootstrap 5.3.3 CSS -->
    <link href="{{ url_for('static', filename='vendor/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">

    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="{{ url_for('static', filename='vendor/bootstrap-icons/font/bootstrap-icons.min.css') }}">

    <!-- Custom CSS -->
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">

    {% block extra_css %}{% endblock %}
</head>

<body>
    <!-- Skip to main content (접근성) -->
    <a href="#main-content" class="visually-hidden-focusable">본문으로 건너뛰기</a>

    {# 플래시 메시지 (좌측 상단 토스트 스타일) #}
    {% with messages = get_flashed_messages(with_categories=true) %}
    {% if messages %}
    <div class="toast-container position-fixed top-0 end-0 p-3" style="z-index: 2000; margin-top: 60px;">
        {% for cat, msg in messages %}
        <div class="toast align-items-center text-white bg-{{ 'success' if cat == 'success' else 'danger' if cat == 'error' else 'primary' }} border-0 fade show"
            role="alert" aria-live="assertive" aria-atomic="true" data-bs-delay="3000">
            <div class="d-flex">
                <div class="toast-body d-flex align-items-center">
                    <i
                        class="bi bi-{{ 'check-circle-fill' if cat == 'success' else 'exclamation-diamond-fill' }} me-2 fs-5"></i>
                    <div>{{ msg }}</div>
                </div>
                <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"
                    aria-label="Close"></button>
            </div>
        </div>
        {% endfor %}
    </div>
    {% endif %}
    {% endwith %}



    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
        <div class="container-fluid">
            <a class="navbar-brand" href="{{ url_for('home.home') }}">
                <i class="bi bi-server me-2"></i>
                Dell Server Info
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
                aria-controls="navbarNav" aria-expanded="false" aria-label="네비게이션 토글">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('home.home') }}">
                            <i class="bi bi-house-door me-1"></i>Home
                        </a>
                    </li>
                    {% if current_user.is_authenticated %}
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('main.index') }}">
                            <i class="bi bi-hdd-network me-1"></i>ServerInfo
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('xml.xml_management') }}">
                            <i class="bi bi-file-code me-1"></i>XML Management
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('jobs.jobs_page') }}">
                            <i class="bi bi-list-task me-1"></i>Job Monitor
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('bios_baseline.index') }}">
                            <i class="bi bi-clipboard-data me-1"></i>BIOS Baseline
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('script_manager.index') }}">
                            <i class="bi bi-code-square me-1"></i>스크립트 관리
                        </a>
                    </li>
                    {% if current_user.is_admin %}
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('admin.admin_panel') }}">
                            <i class="bi bi-shield-lock me-1"></i>Admin
                        </a>
                    </li>
                    {% endif %}
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('auth.logout') }}">
                            <i class="bi bi-box-arrow-right me-1"></i>Logout
                        </a>
                    </li>
                    {% else %}
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('auth.login') }}">
                            <i class="bi bi-box-arrow-in-right me-1"></i>Login
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('auth.register') }}">
                            <i class="bi bi-person-plus me-1"></i>Register
                        </a>
                    </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <main id="main-content"
        class="{% if request.endpoint in ['auth.login', 'auth.register', 'auth.reset_password'] %}container mt-5{% else %}container mt-4 container-card{% endif %}">

        {# 플래시 메시지 (컨텐츠 상단 표시) #}


        {% block content %}{% endblock %}
    </main>

    <!-- Footer (선택사항) -->
    <footer class="mt-5 py-3 bg-light text-center">
        <div class="container">
            <small class="text-muted">&copy; 2025 Dell Server Info. All rights reserved.</small>
        </div>
    </footer>

    <!-- Bootstrap 5.3.3 JS Bundle (Popper.js 포함) -->
    <script src="{{ url_for('static', filename='vendor/bootstrap/js/bootstrap.bundle.min.js') }}"></script>

    <!-- Socket.IO (필요한 경우만) -->
    {% if config.USE_SOCKETIO %}
    <script src="{{ url_for('static', filename='vendor/socket.io/socket.io-4.7.4.min.js') }}"></script>
    {% endif %}

    {% block scripts %}{% endblock %}

    <!-- Auto-hide Toasts -->
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var toastElList = [].slice.call(document.querySelectorAll('.toast'));
            var toastList = toastElList.map(function (toastEl) {
                // 부트스트랩 토스트 인스턴스 생성 (autohide: true 기본값)
                var toast = new bootstrap.Toast(toastEl, { delay: 3000 });
                toast.show();

                // 3초 후 자동으로 DOM에서 제거하고 싶다면 이벤트 리스너 추가 가능
                toastEl.addEventListener('hidden.bs.toast', function () {
                    // toastEl.remove(); // 필요시 제거
                });
                return toast;
            });
        });
    </script>
</body>

</html>
