/* Sidebar SaaS — UniLicit */
nav.sidebar,
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    box-sizing: border-box;
    background-color: var(--surface-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.25s ease, background-color var(--transition-speed);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    font-family: var(--font-saas, var(--font-family));
}

.sidebar-header {
    padding: 0 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    box-sizing: border-box;
}

.sidebar-header--slim {
    height: var(--sidebar-header-height);
    min-height: var(--sidebar-header-height);
    max-height: var(--sidebar-header-height);
    padding: 0 0.75rem;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.sidebar .logo {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-color-dark);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    white-space: nowrap;
    min-width: 0;
    text-decoration: none;
    width: 100%;
}

.sidebar .logo:hover {
    color: var(--primary-color);
}

.sidebar .logo i {
    color: var(--primary-color);
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--saas-bg-subtle, #f1f5f9);
    border: 1px solid var(--border-color);
    color: var(--text-color-body);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
    padding: 0;
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    transform: scale(1.04);
}

.theme-toggle i {
    font-size: 1rem;
    width: auto !important;
}

.sidebar .nav-list-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    flex: 1;
}

.nav-main-items {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0.5rem;
    overflow-y: auto;
}

.nav-secondary-items {
    flex-shrink: 0;
    padding: 0.75rem 0.5rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--saas-bg-subtle, #f8fafc);
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

.sidebar li {
    margin-bottom: 0.2rem;
}

.sidebar a {
    color: var(--text-color-body);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--text-sm, 0.875rem);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    transition: background 0.2s ease, color 0.2s ease;
    position: relative;
    white-space: nowrap;
}

.sidebar a .fas,
.sidebar a .far {
    width: 1.15rem;
    text-align: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar a:hover:not(.active):not(.logout-link) {
    background: var(--primary-soft, #eff6ff);
    color: var(--primary-color);
}

.sidebar a:hover .fas {
    opacity: 1;
}

.sidebar a.active {
    background: var(--primary-soft, #eff6ff);
    color: var(--primary-color);
    font-weight: 600;
}

.sidebar a.active .fas {
    opacity: 1;
    color: var(--primary-color);
}

/* Grupo expansível — Pesquisa de preços */
.nav-group {
    margin-bottom: 0.2rem;
}

.nav-group-toggle {
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-color-body);
    font-weight: 500;
    font-size: var(--text-sm, 0.875rem);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-group-toggle:hover,
.nav-group.has-active .nav-group-toggle {
    background: var(--primary-soft, #eff6ff);
    color: var(--primary-color);
}

.nav-group.has-active .nav-group-toggle {
    font-weight: 600;
}

.nav-group-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    opacity: 0.55;
    transition: transform 0.2s ease;
}

.nav-group.is-open .nav-group-chevron {
    transform: rotate(180deg);
}

.nav-group-items {
    list-style: none;
    padding: 0.15rem 0 0.35rem 0;
    margin: 0 0 0 0.35rem;
    border-left: 2px solid var(--border-color);
}

.nav-group-items[hidden] {
    display: none;
}

.sidebar a.nav-sublink {
    padding: 0.5rem 0.75rem 0.5rem 1.15rem;
    font-size: 0.8125rem;
    font-weight: 500;
    gap: 0.5rem;
}

.sidebar a.nav-sublink.active {
    box-shadow: none;
    background: #eff6ff;
}

.nav-group.is-open .nav-group-items {
    display: block;
}

@media (max-width: 992px) {
    .nav-group-toggle > span {
        display: none;
    }

    .nav-group-chevron {
        display: none;
    }

    .nav-group-items {
        border-left: none;
        margin-left: 0;
    }

    .sidebar a.nav-sublink {
        justify-content: center;
        padding: 0.65rem 0.5rem;
    }

    .sidebar a.nav-sublink span {
        display: none;
    }

    .sidebar a.nav-sublink .fas {
        display: block;
        opacity: 1;
    }
}

.sidebar a.logout-link {
    color: var(--text-color-body);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
}

.sidebar a.logout-link:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.notification-dot {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 0.85rem;
    width: 8px;
    height: 8px;
    background-color: var(--danger-color);
    border-radius: 50%;
    border: 2px solid var(--surface-color);
    animation: saas-pulse 2s infinite;
}

.sidebar a.active .notification-dot {
    border-color: #eff6ff;
}

@keyframes saas-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.nav-main-items::-webkit-scrollbar {
    width: 4px;
}

.nav-main-items::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.navbar-logo {
    height: 32px;
    width: auto;
    max-width: 100px;
    object-fit: contain;
    flex-shrink: 0;
}

@media (max-width: 992px) {
    nav.sidebar,
    .sidebar {
        width: var(--sidebar-width-collapsed);
    }

    .sidebar .logo span,
    .sidebar a span {
        display: none;
    }

    .sidebar .logo {
        justify-content: center;
    }

    .sidebar a {
        justify-content: center;
        padding: 0.75rem 0.5rem;
    }

    .notification-dot {
        top: 0.45rem;
        right: 0.45rem;
        transform: none;
    }

    .navbar-logo {
        height: 32px;
        max-width: 48px;
    }
}

:root[data-theme="dark"] .sidebar a:hover,
:root[data-theme="dark"] .sidebar a.active {
    background: rgba(59, 130, 246, 0.15);
}

:root[data-theme="dark"] .nav-secondary-items {
    background: var(--bg-color);
}
