/* ==========================================================================
   1. GLOBAL ENGINE & BODY
   ========================================================================== */
html {
    height: 100%;
}

body {
    margin: 0;
    background: #f5f6f8;
    color: #212529;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   2. TOPBAR & HEADER
   ========================================================================== */
.topbar {
    height: 64px;
    flex: 0 0 64px;
    position: sticky;
    top: 0;
    z-index: 1040;
}

.topbar-brand-wrapper {
    width: 260px;
    height: 100%;
    flex: 0 0 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    height: 44px;
    object-fit: contain;
}

.user-name {
    white-space: nowrap;
}

.topbar .dropdown-menu {
    border-radius: 8px;
    font-size: 14px;
    margin-top: 8px !important;
}

.topbar .dropdown-item {
    padding: 8px 16px;
    transition: background 0.15s ease-in-out;
}

.topbar .dropdown-item i {
    font-size: 1.1em;
}

.user-dropdown-btn {
    background: transparent;
    box-shadow: none !important;
}

.user-dropdown-btn:hover,
.user-dropdown-btn:focus {
    color: rgba(255, 255, 255, 0.85) !important;
}

.user-dropdown-btn::after {
    margin-left: 0.4em;
    vertical-align: middle;
}

/* ==========================================================================
   3. SIDEBAR NAVIGATION (NIVO 0, NIVO 1, NIVO 2)
   ========================================================================== */
.sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 260px;
    background: #212529;
    overflow-y: auto;
    z-index: 1030;
    padding: 14px 10px 20px;
}

/* Osnovni stil za sve linkove unutar sidebar-a */
.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.82);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 7px;
    transition: background 0.15s ease, color 0.15s ease;
    text-decoration: none;
}

/* Fiksna širina za glavne ikonice (Nivo 0) */
.sidebar .nav-link>i:first-child {
    width: 20px;
    text-align: center;
    flex: 0 0 20px;
}

/* Hover i Active stanje */
.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* Arrow rotacija za podmenije */
.sidebar .submenu-arrow {
    width: auto !important;
    flex: 0 0 auto !important;
    font-size: 11px;
    transition: transform 0.2s ease;
    margin-left: auto;
}

.sidebar .submenu-toggle[aria-expanded="true"] .submenu-arrow {
    transform: rotate(180deg);
}

/* --- NIVO 1 SUBMENU --- */
.sidebar .submenu {
    margin: 0 0 4px;
}

.sidebar .submenu>.nav-link {
    padding-left: 36px;
    /* Pravilno uvučen Nivo 1 */
    font-size: 14px;
}

/* --- NIVO 1 KOJI OTVIRE NIVO 2 --- */
.sidebar .submenu-level-2 {
    padding-left: 36px !important;
    font-size: 14px !important;
}

/* --- NIVO 2 KONTEJNER (Ukinuta vertikalna linija) --- */
.sidebar .submenu-level-2-container {
    margin-left: 20px;
    /* Blago uvlačenje za hijerarhiju */
    border-left: none;
    /* Uklonjena vertikalna linija */
    margin-left: 0;
    margin-bottom: 4px;
}

/* --- NIVO 2 SUBMENU LINKOVI --- */
.sidebar .submenu-level-2-container .nav-link {
    border-left: none !important;
    padding-left: 56px;
    /* Usklađeno uvlačenje da prati Nivo 1 */
    font-size: 13px;
    min-height: 38px;
}

/* --- HOVER I ACTIVE ZA NIVO 2 (Usklađeno sa tamnim sidebar-om) --- */
.sidebar .submenu-level-2-container .nav-link:hover,
.sidebar .submenu-level-2-container .nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   4. MAIN CONTENT & FIXED FOOTER
   ========================================================================== */
.main-content {
    margin-left: 260px;
    padding: 15px;
    flex: 1 0 auto;
    width: calc(100% - 260px);
}

/* Footer ostaje fiksiran na dno stranice preko flex-a */
.footer {
    margin-left: 260px;
    margin-top: auto;
    /* Osigurava trajno dno ekrana */
    width: calc(100% - 260px);
    padding: 8px 30px;
    text-align: center;
    color: #6c757d;
    background: #ffffff;
    border-top: 1px solid #dee2e6;
    flex: 0 0 auto;
    font-size: 14px;

    line-height: 1.6;
}

.sidebar-overlay {
    display: none;
}

/* ==========================================================================
   5. RESPONSIVE MEDIA QUERIES
   ========================================================================== */
@media (max-width: 991.98px) {
    .topbar-brand-wrapper {
        width: auto;
        flex: 0 0 auto;
        border-right: none;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 18px rgba(0, 0, 0, 0.15);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 64px 0 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1020;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content,
    .footer {
        margin-left: 0;
        width: 100%;
    }

    .main-content {
        padding: 24px 18px;
    }

    .footer {
        padding: 16px 18px;
    }
}

@media (max-width: 575.98px) {
    .user-name {
        font-size: 14px;
    }

    .main-content {
        padding: 20px 14px;
    }
}