:root {
    --sidebar-width-expanded: 250px;
    --sidebar-width-collapsed: 80px;
    --sidebar-bg: #03173d;
    --sidebar-text: #e8eef7;
    --sidebar-text-muted: #9fb0c9;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(0, 102, 204, 0.35);
    --sidebar-border: rgba(255, 255, 255, 0.08);
}

.app-shell {
    display: flex;
    min-height: 100vh;
    background: #f4f6f9;
}

.sidebar {
    width: var(--sidebar-width-expanded);
    min-width: var(--sidebar-width-expanded);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease;
    border-right: 1px solid var(--sidebar-border);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar--recolhido {
    width: var(--sidebar-width-collapsed);
    min-width: var(--sidebar-width-collapsed);
}

.sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 64px;
}

.sidebar--recolhido .sidebar__header {
    justify-content: center;
    padding-inline: 0.5rem;
}

.sidebar__brand {
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar__toggle {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar__toggle:hover {
    background: var(--sidebar-hover);
}

.sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.5rem 1rem;
}

.sidebar__section-title {
    margin: 0.75rem 0.5rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-text-muted);
}

.sidebar__section-divider {
    height: 1px;
    margin: 0.75rem 0.5rem;
    background: var(--sidebar-border);
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: background 0.15s ease;
    min-height: 44px;
}

.sidebar--recolhido .sidebar__link {
    justify-content: center;
    padding-inline: 0.5rem;
}

.sidebar__link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.sidebar__link.active {
    background: var(--sidebar-active);
    font-weight: 600;
}

.sidebar__icon {
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.sidebar__label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.92rem;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.25rem;
    min-height: 64px;
    background: #ffffff;
    border-bottom: 1px solid #e0e4ea;
    box-shadow: 0 1px 2px rgba(3, 23, 61, 0.06);
}

.app-topbar__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #03173d;
}

.app-topbar__leading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.app-topbar__back {
    flex-shrink: 0;
    text-transform: none;
}

.app-topbar__user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #4a5568;
    font-size: 0.9rem;
}

.app-content {
    flex: 1;
    min-height: 0;
    padding: 1rem 1.25rem 1.5rem;
    overflow: auto;
}

.app-content:has(.chat-atendimento) {
    overflow: hidden;
}

@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        min-width: 100%;
        height: auto;
    }

    .sidebar--recolhido {
        width: 100%;
        min-width: 100%;
    }

    .sidebar__nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .sidebar__section-title,
    .sidebar__section-divider {
        width: 100%;
    }
}
