/* 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;
    /* Halvány, semleges szürke oldalháttér – a fehér kártyák így kiemelkednek */
    background: #f4f6f9 !important;
}


/* Ez a rész a navbar */
header.fixed-top {
    height: 65px;
    z-index: 1030 !important;
    /* Halvány szürke navbar-háttér – megegyezik a sidebar fejlécével és az oldalháttérrel */
    background-color: #f4f6f9;
    border-bottom: 1px solid #e4e8ef;
}

.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;
}

/* Aktív (aktuálisan megnyitott) menüpont kiemelése */
.nav-link.active {
    color: #0d6efd !important;
    background-color: #e7f1ff;
    font-weight: 600 !important;
}

.nav-link.active i {
    color: #0d6efd !important;
}

.dropdown-item.active {
    background-color: #e7f1ff !important;
    color: #0d6efd !important;
    font-weight: 600;
}

.dropdown-item.active i {
    color: #0d6efd !important;
}

.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;
    /* Ugyanaz a halvány szürke, mint a navbar / fejléc / oldalháttér – egységes összhang */
    background-color: #f4f6f9;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e4e8ef;
}

.sidebar-header {
    /* Halvány szürke fejléc – az oldalháttérrel megegyező árnyalat */
    background-color: #f4f6f9;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid #e4e8ef;
}

.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;
    }
}


/* ============================================================
   GLOBÁLIS ESZTÉTIKAI FINOMÍTÁSOK (minden oldal egységes kinézete)
   A Főoldalon bevezetett megjelenést viszi végig a többi felületen.
   ============================================================ */

/* --- Egységes, lágy belépő animáció --- */
.fade-in {
    animation: appFadeIn 0.45s ease both;
}

@keyframes appFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Egységes kártyák: lágyabb sarok + finomabb árnyék --- */
main .card {
    border-radius: 1rem;
}

main .card.shadow-sm {
    box-shadow: 0 2px 12px rgba(16, 24, 40, 0.06) !important;
}

/* --- Oldalfejléc-kártya: lágy gradiens + bal oldali színes akcentus ---
   A :has() segítségével azt a kártyát célozzuk, amely a fejléc ikon-badge-et
   tartalmazza (minden oldal tetején ugyanaz a minta). */
main .card:has(.bg-primary.bg-opacity-10.text-primary.p-3.rounded-3) {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #f5f9ff 100%);
}

main .card:has(.bg-primary.bg-opacity-10.text-primary.p-3.rounded-3)::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 5px;
    background: linear-gradient(180deg, #0d6efd, #4dabf7);
}

/* --- Fejléc ikon-badge: gradiens háttér, fix méret, lágy árnyék --- */
main .bg-primary.bg-opacity-10.text-primary.p-3.rounded-3 {
    background: linear-gradient(135deg, #0d6efd, #4dabf7) !important;
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.28);
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

main .bg-primary.bg-opacity-10.text-primary.p-3.rounded-3 i {
    color: #fff !important;
}

/* --- Kártyafejléc (card-header) vezető ikonjai egységes kapszulában --- */
main .card-header h5 i,
main .card-header h6 i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 0.6rem;
    background: rgba(100, 116, 139, 0.1);
    margin-right: 0.5rem !important;
    font-size: 0.95rem;
    vertical-align: middle;
}

/* --- "Valós idejű" / "Utolsó 7 nap" stb. címkék egységes pill stílusban --- */
main .badge.bg-light {
    background-color: #f1f5f9 !important;
    border: 1px solid #e7ecf3;
    border-radius: 999px;
    padding: 0.4em 0.8em;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-weight: 600;
}

/* --- Táblázatok: lekerekített fejlécsarok + kód-azonosító kapszulák --- */
main .table thead th:first-child {
    border-top-left-radius: 0.5rem;
}

main .table thead th:last-child {
    border-top-right-radius: 0.5rem;
}

main .table code {
    background: #f1f5f9;
    padding: 0.15rem 0.5rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
}


/* ============================================================
   MOBIL RESZPONZIVITÁS
   (a fix oldalsávot becsúszó fiókká alakítja kis kijelzőn)
   ============================================================ */

/* Desktopon a mobil-vezérlők rejtve */
#sidebar-mobile-toggle { display: none; }
#sidebar-backdrop { display: none; }

@media (max-width: 991px) {

    /* Kisebb tartalmi margó, teljes szélesség
       (main.p-4, mert a loadPage Bootstrap p-4 osztályt tesz a main-re) */
    main,
    main.p-4 {
        padding: 12px;
        width: 100%;
    }

    /* --- Oldalsáv: becsúszó fiók (off-canvas) bármely állapotban --- */
    #sidebar-wrapper,
    #sidebar-wrapper.sidebar-pinned,
    #sidebar-wrapper.sidebar-unpinned {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        width: 0;
        min-width: 0;
        height: calc(100vh - var(--nav-height));
        z-index: 1045;
    }

    #sidebar-wrapper .sidebar-content,
    #sidebar-wrapper.sidebar-pinned .sidebar-content,
    #sidebar-wrapper.sidebar-unpinned .sidebar-content {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        width: 82vw;
        max-width: 320px;
        height: calc(100vh - var(--nav-height));
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 5px 0 22px rgba(0, 0, 0, 0.18);
        z-index: 1046;
    }

    /* Hover-nyitás kikapcsolása (érintésnél nem jó); csak tap-re nyíljon */
    #sidebar-wrapper.sidebar-unpinned:hover .sidebar-content {
        transform: translateX(-100%);
    }

    /* Nyitott állapot (gombnyomásra) */
    #sidebar-wrapper.sidebar-mobile-open .sidebar-content {
        transform: translateX(0) !important;
    }

    /* A desktop bekúszó-nyíl trigger elrejtése mobilon */
    #sidebar-wrapper .sidebar-trigger {
        display: none !important;
    }

    /* Lebegő nyitógomb (bal alsó sarok) */
    #sidebar-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        left: 14px;
        bottom: 18px;
        width: 52px;
        height: 52px;
        border: none;
        border-radius: 50%;
        background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
        color: #fff;
        font-size: 1.45rem;
        box-shadow: 0 6px 18px rgba(13, 110, 253, 0.4);
        z-index: 1047;
    }

    #sidebar-mobile-toggle:active {
        transform: scale(0.94);
    }

    /* Sötét háttér nyitott állapotban */
    #sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        top: var(--nav-height);
        background: rgba(0, 0, 0, 0.4);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
        z-index: 1044;
    }

    #sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    /* --- Fejléc-kártyák: a cím és a művelet-gomb törjön külön sorba --- */
    main .card .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* A fejlécben lévő gombok ne lógjanak ki, töltsék ki a sort ha kell */
    main .card .d-flex.justify-content-between > .btn {
        white-space: nowrap;
    }

    /* Oldalcímek kicsit kisebbek mobilon */
    main h2.fw-bold {
        font-size: 1.4rem;
    }

    /* A fejléc ikon-badge kicsit kisebb, hogy ne nyomja a címet */
    main .bg-primary.bg-opacity-10.text-primary.p-3.rounded-3 {
        width: 48px;
        height: 48px;
    }
}

/* Nagyon kicsi kijelzők (telefon, álló) finomítás */
@media (max-width: 575.98px) {
    main,
    main.p-4 {
        padding: 10px;
    }

    /* Kártyák belső paddingjének mérséklése (Bootstrap p-4 -> kevesebb) */
    main .card.p-4,
    main .card .card-body.p-4 {
        padding: 1rem !important;
    }
}

/* ============================================================
   MOBIL FINOMÍTÁSOK (kiegészítés) – biztonságos, általános javítások,
   amelyek az összes oldalra érvényesek (Bootstrap-alapú felépítés).
   ============================================================ */
@media (max-width: 991.98px) {
    /* Semmi ne lógjon ki vízszintesen (kép, vászon, beágyazott elem) */
    main img,
    main canvas,
    main svg,
    main iframe { max-width: 100%; }

    /* Vezérlő-sorok (szűrők, gomb-csoportok, "pill"-ek): több sorba tördelés,
       kellő függőleges köz, hogy ne csússzanak egymásba */
    main .d-flex.flex-wrap { row-gap: .5rem; }
    main .btn-group.flex-wrap { row-gap: .4rem; }

    /* Kártyafejléc: cím és a művelet-gombok külön sorba, ne préselődjenek */
    main .card-header .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: .5rem;
    }
}

@media (max-width: 575.98px) {
    /* Tipográfia mérséklése kis kijelzőn */
    main h2, main h2.fw-bold { font-size: 1.3rem; }
    main h3 { font-size: 1.15rem; }
    main .display-6, main .fs-1, main .fs-2 { font-size: 1.6rem !important; }

    /* Táblázatok kompaktabban, hogy több férjen ki görgetés nélkül is */
    main .table { font-size: .85rem; }
    main .table > :not(caption) > * > * { padding-left: .5rem; padding-right: .5rem; }

    /* ===== MODÁLOK MOBILON (minden oldalon egységesen) ===== */
    /* Közel teljes szélesség, kis margóval (a teljesképernyős modálokat kihagyjuk,
       beleértve a modal-fullscreen-*-down változatokat is). */
    .modal-dialog:not([class*="modal-fullscreen"]) {
        margin: .5rem;
        max-width: calc(100% - 1rem);
    }

    /* A tartalom SOHA ne lógjon a képernyőn túl: a modal TÖRZSE görgethető, a
       fejléc és a lábléc a helyén marad (a modal-dialog-scrollable viselkedést
       globálisan kikényszerítjük). Így a hosszú modálok teteje/alja sem csúszik le. */
    .modal-dialog:not([class*="modal-fullscreen"]) .modal-content {
        max-height: calc(100vh - 1rem);
    }
    .modal-content { overflow: hidden; }
    .modal-body { overflow-y: auto; }

    /* Kompaktabb belső terek + kisebb cím. A p-0 törzseket (pl. térkép /
       Teljesítmény modal) NEM bántjuk, csak a p-4-eseket mérsékeljük. */
    .modal-header, .modal-footer { padding: .7rem 1rem; }
    .modal-body.p-4 { padding: 1rem !important; }
    .modal-title { font-size: 1.05rem; line-height: 1.3; }

    /* Lábléc: a gombok könnyen nyomhatók legyenek, töltsék ki a sort */
    .modal-footer > .btn { flex: 1 1 auto; }

    /* Bootstrap oszlopközök mérséklése, hogy ne legyen túl sok üres hely */
    main .row.g-4 { --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; }
}

/* ============================================================
   TOUCH / MOBIL: a hover-re megjelenő MŰVELET-gombok mindig látszódjanak
   (érintőképernyőn nincs hover, így egyébként elérhetetlenek lennének).
   A `hover: none` a touch eszközöket célozza; a szélesség-fallback a
   keskeny ablakokra is kiterjeszti.
   ============================================================ */
@media (hover: none), (max-width: 767.98px) {
    .row-actions,
    tr:hover .row-actions,
    .actions-cell .btn,
    tr:hover .actions-cell .btn {
        opacity: 1 !important;
    }
}