/* main rész */

:root {
    --nav-height: 65px;
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    padding-top: var(--nav-height);
}

h1 { 
    color: navy; 
}

main {
    flex: 1; 
    height: calc(100vh - 65px); 
    overflow-y: auto;
    width: 100%;
    padding: 20px;
    transition: margin-left 0.3s ease; 
}


/* Ez a rész a navbar */
header.fixed-top {
    height: 65px;
    z-index: 1030 !important; 
}

.nav-link {
    color: #475569 !important;
    transition: all 0.2s ease;
    border-radius: 8px;
    font-size: 0.95rem;
}

.nav-link:hover {
    color: #0d6efd !important;
    background-color: #f1f5f9;
}

.user-profile-btn::after { display: none; }

.user-profile-btn:hover .bg-light {
    background-color: #e2e8f0 !important;
    transform: scale(1.05);
}

/* Reszponzív nézet javítása mobilra */
@media (max-width: 991px) {
    .navbar-nav { padding: 1rem 0; }
    .mx-auto { margin-left: 0 !important; }
    .user-profile-btn { padding: 0.5rem 0; }
}


/* Ez a rész a sidebar */
/* Sidebar alaphelyzet (pinned) */
#sidebar-wrapper {
    width: 280px;
    transition: all 0.3s ease;
    z-index: 1040;
    position: relative;
}

/* A tényleges tartalom, ami mozog */
.sidebar-content {
    width: 300px;
    height: calc(100vh - 65px); 
    position: fixed;
    top: 65px;
    left: 0;
    z-index: 1020; 
    background-color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #dee2e6;
}

.sidebar-header {
    background-color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-content::-webkit-scrollbar, 
main::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-thumb, 
main::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

/* --- PINNED (Kitűzött) ÁLLAPOT --- */
#sidebar-wrapper.sidebar-pinned {
    height: calc(100vh - var(--nav-height));
    position: sticky;
    top: var(--nav-height);
}

#sidebar-wrapper.sidebar-pinned .sidebar-content {
    transform: translateX(0);
}

/* --- UNPINNED (Bekúszó) ÁLLAPOT --- */
#sidebar-wrapper.sidebar-unpinned {
    width: 0;
    min-width: 0;
    position: fixed;
    /* A navbar magassága alá pozicionáljuk pontosan */
    top: var(--nav-height); 
    left: 0;
    /* Kiszámoljuk a magasságot: teljes képernyő mínusz navbar */
    height: calc(100vh - var(--nav-height)); 
    z-index: 1050;
    background-color: transparent; /* Hogy a trigger látszódjon, de a tartalom ne */
}

/* A tartalom alapból ki van tolva balra */
#sidebar-wrapper.sidebar-unpinned .sidebar-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%; /* Kitölti a wrapper magasságát */
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    border-top: none; /* Ne legyen dupla keret a navbar alatt */
}

/* Bekúszás hoverre */
#sidebar-wrapper.sidebar-unpinned:hover .sidebar-content {
    transform: translateX(0);
}

/* Érzékelő sáv unpinned módban */
/* TRIGGER (A kék nyíl) */
.sidebar-trigger {
    display: none; /* Alapból nincs */
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 60px;
    background-color: #0d6efd;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    z-index: 1050;
    align-items: center;
    justify-content: center;
    color: white;
}

.sidebar-trigger::after {
    content: '›';
    font-weight: bold;
}

/* Csak unpinned módban mutassuk a nyilat */
#sidebar-wrapper.sidebar-unpinned .sidebar-trigger {
    display: flex;
}

.sidebar-trigger:hover {
    width: 18px;
    background-color: #0a58ca;
}

/* Amikor a sidebar kinyílt (hover), a nyíl bújjon el a sidebar mögé vagy tűnjön el */
#sidebar-wrapper.sidebar-unpinned:hover .sidebar-trigger {
    opacity: 0;
}

.unpinned-icon {
    transform: rotate(-45deg);
    color: #adb5bd !important;
}

.toggle-icon {
    transition: transform 0.2s ease;
    display: inline-block;
    cursor: pointer;
}

.toggle-icon:not(.collapsed) {
    transform: rotate(90deg);
}

.tree-node:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

#tree-container {
    flex-grow: 1;
    overflow-y: auto !important;
    padding-bottom: 20px; 
}

/* 🔥 NAVBAR FIX - EZ OLDJA MEG A SZÉTCSÚSZÁST */
@media (max-width: 991px) {

    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: white;
        z-index: 999;
        border-top: 1px solid #e5e7eb;
    }

    .navbar-nav {
        text-align: center;
    }

    .navbar-nav .nav-link {
        justify-content: center;
        padding: 12px 0;
    }

    /* 🔥 EZ A LÉNYEG: dropdown fix */
    .dropdown-menu {
        position: static !important;
        transform: none !important;
        width: 100%;
        text-align: center;
        box-shadow: none;
    }

    .dropdown-item {
        justify-content: center;
    }
}