/* =============================================
   CUSTOM SIDEBAR MODERNO - Funil de Vendas
   Carregado DEPOIS de style.min.css (cascade final)
   ============================================= */

/* ---- Hover: fundo visível + cor forte ---- */
.sidebar ul.nav > li > a {
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease !important;
    position: relative !important;
    border-radius: 6px !important;
    margin: 1px 4px !important;
}

.sidebar ul.nav > li > a:hover,
.sidebar ul.nav > li > a:focus {
    background: rgba(59, 130, 246, 0.10) !important;
    color: #1d4ed8 !important;
    border-color: rgba(59, 130, 246, 0.2) !important;
}

.sidebar ul.nav > li > a:hover .menu-icon,
.sidebar ul.nav > li > a:focus .menu-icon {
    color: #2563eb !important;
}

/* ---- Item ativo: fundo azul claro + barra lateral ---- */
.sidebar > ul.nav > li.active > a:first-child {
    background: rgba(59, 130, 246, 0.12) !important;
    border-color: rgba(59, 130, 246, 0.25) !important;
    color: #1e40af !important;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.15) !important;
}

.sidebar > ul.nav > li.active > a:first-child::before {
    content: '' !important;
    position: absolute !important;
    left: -4px !important;
    top: 6px !important;
    bottom: 6px !important;
    width: 3px !important;
    background: #3b82f6 !important;
    border-radius: 0 4px 4px 0 !important;
}

.sidebar > ul.nav > li.active > a:first-child .menu-icon {
    color: #2563eb !important;
}

/* ---- Submenu segundo nível ---- */
.sidebar ul.nav li .nav-second-level li a {
    transition: color 0.15s ease, padding-left 0.15s ease !important;
    border-radius: 4px !important;
    margin: 0 4px !important;
}

.sidebar ul.nav > li .nav-second-level > li:not(.active) > a:hover,
.sidebar ul.nav > li .nav-second-level > li:not(.active) > a:focus {
    color: #2563eb !important;
    background: rgba(59, 130, 246, 0.06) !important;
    padding-left: 52px !important;
}

.sidebar ul.nav li .nav-second-level li.active a {
    color: #1e40af !important;
    background: rgba(59, 130, 246, 0.08) !important;
    font-weight: 600 !important;
}

/* ---- Submenu terceiro nível ---- */
.sidebar ul.nav li .nav-third-level {
    padding-left: 12px !important;
}

.sidebar ul.nav li .nav-third-level li a {
    padding: 4px 15px 4px 56px !important;
    color: #6b7280 !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
    transition: color 0.15s ease !important;
    border-radius: 4px !important;
}

.sidebar ul.nav li .nav-third-level li a:hover {
    color: #2563eb !important;
    background: rgba(59, 130, 246, 0.05) !important;
}

.sidebar ul.nav li .nav-third-level li.active a {
    font-weight: 600 !important;
    color: #1e40af !important;
}

/* ---- Arrow rotation suave ---- */
.sidebar .fa.arrow {
    transition: transform 0.25s ease !important;
}

.sidebar .active > a > .fa.arrow {
    transform: rotate(-90deg) !important;
}

/* ---- Scrollbar elegante no sidebar ---- */
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ---- Profile dropdown hover ---- */
.sidebar .sidebar-user-profile .dropdown-toggle:hover {
    border-color: rgba(59, 130, 246, 0.3) !important;
    background: rgba(59, 130, 246, 0.05) !important;
}

/* =============================================
   PORTAL FLYOUT (Level 3+)
   Renders as position:fixed popup on <body>,
   completely outside sidebar DOM and overflow.
   ============================================= */

/* The portal container */
.sidebar-portal-flyout {
    position: fixed;
    z-index: 10000;
    min-width: 220px;
    max-width: 300px;
    max-height: 70vh;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08);
    padding: 6px 0;
}

/* Portal list reset */
.portal-flyout-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Portal items */
.portal-flyout-list > li > a {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    white-space: nowrap;
    border-radius: 5px;
    margin: 1px 5px;
    transition: background 0.15s ease, color 0.15s ease;
}
.portal-flyout-list > li > a:hover,
.portal-flyout-list > li > a:focus {
    background: rgba(59, 130, 246, 0.08);
    color: #1d4ed8;
    text-decoration: none;
}
.portal-flyout-list > li > a .menu-icon {
    margin-right: 8px;
    font-size: 14px;
    width: 16px;
    text-align: center;
    color: #6b7280;
}
.portal-flyout-list > li > a:hover .menu-icon {
    color: #2563eb;
}

/* Sub-flyout arrow */
.portal-flyout-arrow {
    margin-left: auto;
    font-size: 10px;
    color: #9ca3af;
}
.portal-flyout-list > li > a:hover .portal-flyout-arrow {
    color: #1d4ed8;
}

/* Nested sub-flyouts inside portal (also fixed position) */
.portal-has-sub > .portal-flyout-list {
    display: none;
    position: fixed;
    z-index: 10001;
    min-width: 200px;
    max-width: 280px;
    max-height: 60vh;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1), 0 3px 8px rgba(0, 0, 0, 0.06);
    padding: 6px 0;
}
.portal-has-sub.portal-sub-open > .portal-flyout-list {
    display: block;
}

/* Sidebar trigger styling when flyout is open */
.sidebar .has-portal-flyout.portal-flyout-open > a {
    background: rgba(59, 130, 246, 0.10);
    color: #1d4ed8;
}
.sidebar .has-portal-flyout > a .fa-chevron-right {
    float: right;
    font-size: 10px;
    margin-top: 4px;
    color: #9ca3af;
    transition: color 0.15s ease;
}
.sidebar .has-portal-flyout.portal-flyout-open > a .fa-chevron-right,
.sidebar .has-portal-flyout > a:hover .fa-chevron-right {
    color: #1d4ed8;
}

/* Portal scrollbar */
.sidebar-portal-flyout::-webkit-scrollbar,
.portal-has-sub > .portal-flyout-list::-webkit-scrollbar {
    width: 4px;
}
.sidebar-portal-flyout::-webkit-scrollbar-thumb,
.portal-has-sub > .portal-flyout-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
}
